@interopio/browser 3.4.4 → 3.4.6
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/browser.d.ts +38 -5
- package/changelog.md +8 -0
- package/dist/browser.es.js +112 -21
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +112 -21
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +1 -1
- package/package.json +5 -5
package/dist/browser.umd.js
CHANGED
|
@@ -2484,6 +2484,9 @@
|
|
|
2484
2484
|
const channelNameDecoder = (channelNames) => {
|
|
2485
2485
|
return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
|
|
2486
2486
|
};
|
|
2487
|
+
const fdc3OptionsDecoder = object$1({
|
|
2488
|
+
contextType: optional$1(nonEmptyStringDecoder)
|
|
2489
|
+
});
|
|
2487
2490
|
const publishOptionsDecoder = optional$1(oneOf$1(nonEmptyStringDecoder, object$1({
|
|
2488
2491
|
name: optional$1(nonEmptyStringDecoder),
|
|
2489
2492
|
fdc3: optional$1(boolean$1())
|
|
@@ -2546,7 +2549,8 @@
|
|
|
2546
2549
|
id: nonEmptyStringDecoder,
|
|
2547
2550
|
state: notificationStateDecoder
|
|
2548
2551
|
});
|
|
2549
|
-
|
|
2552
|
+
object$1().where((value) => value.fdc3 ? typeof value.fdc3.type === "string" : true, "Expected a valid FDC3 Context with compulsory 'type' field");
|
|
2553
|
+
const channelDefinitionDecoder = object$1({
|
|
2550
2554
|
name: nonEmptyStringDecoder,
|
|
2551
2555
|
meta: object$1({
|
|
2552
2556
|
color: nonEmptyStringDecoder
|
|
@@ -2764,6 +2768,7 @@
|
|
|
2764
2768
|
platform: object$1({
|
|
2765
2769
|
app: nonEmptyStringDecoder,
|
|
2766
2770
|
}),
|
|
2771
|
+
validNonExistentApps: optional$1(array$1(nonEmptyStringDecoder)),
|
|
2767
2772
|
});
|
|
2768
2773
|
const clientErrorDataDecoder = object$1({
|
|
2769
2774
|
message: nonEmptyStringDecoder
|
|
@@ -4735,6 +4740,9 @@
|
|
|
4735
4740
|
return prefsForIntent?.handler;
|
|
4736
4741
|
}
|
|
4737
4742
|
async checkHandleRaiseWithRememberedHandler(intentRequest) {
|
|
4743
|
+
if (intentRequest.target) {
|
|
4744
|
+
return;
|
|
4745
|
+
}
|
|
4738
4746
|
const rememberedHandler = await this.checkForRememberedHandler(intentRequest);
|
|
4739
4747
|
if (!rememberedHandler) {
|
|
4740
4748
|
return;
|
|
@@ -4765,7 +4773,7 @@
|
|
|
4765
4773
|
}
|
|
4766
4774
|
|
|
4767
4775
|
const operations$4 = {
|
|
4768
|
-
addChannel: { name: "addChannel", dataDecoder:
|
|
4776
|
+
addChannel: { name: "addChannel", dataDecoder: channelDefinitionDecoder },
|
|
4769
4777
|
removeChannel: { name: "removeChannel", dataDecoder: removeChannelDataDecoder },
|
|
4770
4778
|
getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
|
|
4771
4779
|
getWindowIdsOnChannel: { name: "getWindowIdsOnChannel", dataDecoder: getWindowIdsOnChannelDataDecoder, resultDecoder: getWindowIdsOnChannelResultDecoder },
|
|
@@ -4938,25 +4946,35 @@
|
|
|
4938
4946
|
}
|
|
4939
4947
|
return fdc3PropsArr[0].split("_").slice(1).join("_");
|
|
4940
4948
|
}
|
|
4941
|
-
subscribe(callback) {
|
|
4949
|
+
subscribe(callback, options) {
|
|
4942
4950
|
if (typeof callback !== "function") {
|
|
4943
4951
|
return ioError.raiseError("Cannot subscribe to channels, because the provided callback is not a function!");
|
|
4944
4952
|
}
|
|
4953
|
+
if (options) {
|
|
4954
|
+
runDecoderWithIOError(fdc3OptionsDecoder, options);
|
|
4955
|
+
}
|
|
4945
4956
|
const currentChannel = this.current();
|
|
4946
|
-
const wrappedCallback =
|
|
4957
|
+
const wrappedCallback = options?.contextType
|
|
4958
|
+
? this.getWrappedSubscribeCallbackWithFdc3Type(callback, options.contextType)
|
|
4959
|
+
: this.getWrappedSubscribeCallback(callback);
|
|
4947
4960
|
if (currentChannel) {
|
|
4948
4961
|
this.replaySubscribe(wrappedCallback, currentChannel);
|
|
4949
4962
|
}
|
|
4950
4963
|
return this.registry.add(this.SubsKey, wrappedCallback);
|
|
4951
4964
|
}
|
|
4952
|
-
async subscribeFor(name, callback) {
|
|
4965
|
+
async subscribeFor(name, callback, options) {
|
|
4953
4966
|
const channelNames = this.getAllChannelNames();
|
|
4954
4967
|
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
4955
4968
|
if (typeof callback !== "function") {
|
|
4956
4969
|
return ioError.raiseError(`Cannot subscribe to channel ${name}, because the provided callback is not a function!`);
|
|
4957
4970
|
}
|
|
4971
|
+
if (options) {
|
|
4972
|
+
runDecoderWithIOError(fdc3OptionsDecoder, options);
|
|
4973
|
+
}
|
|
4958
4974
|
const contextName = this.createContextName(name);
|
|
4959
|
-
const wrappedCallback =
|
|
4975
|
+
const wrappedCallback = options?.contextType
|
|
4976
|
+
? this.getWrappedSubscribeCallbackWithFdc3Type(callback, options.contextType)
|
|
4977
|
+
: this.getWrappedSubscribeCallback(callback);
|
|
4960
4978
|
return this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
4961
4979
|
wrappedCallback(context.data, context, extraData?.updaterId);
|
|
4962
4980
|
});
|
|
@@ -4987,16 +5005,38 @@
|
|
|
4987
5005
|
const channelNames = this.getAllChannelNames();
|
|
4988
5006
|
return channelNames;
|
|
4989
5007
|
}
|
|
4990
|
-
async get(name) {
|
|
5008
|
+
async get(name, options) {
|
|
4991
5009
|
const channelNames = this.getAllChannelNames();
|
|
4992
5010
|
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
5011
|
+
if (options) {
|
|
5012
|
+
runDecoderWithIOError(fdc3OptionsDecoder, options);
|
|
5013
|
+
}
|
|
4993
5014
|
const contextName = this.createContextName(name);
|
|
4994
5015
|
const channelContext = await this.contexts.get(contextName);
|
|
5016
|
+
if (options?.contextType) {
|
|
5017
|
+
return this.getContextForFdc3Type(channelContext, options.contextType);
|
|
5018
|
+
}
|
|
4995
5019
|
if (channelContext.latest_fdc3_type) {
|
|
4996
5020
|
return this.getContextWithFdc3Data(channelContext);
|
|
4997
5021
|
}
|
|
4998
5022
|
return channelContext;
|
|
4999
5023
|
}
|
|
5024
|
+
getContextForFdc3Type(channelContext, searchedType) {
|
|
5025
|
+
const encodedType = `fdc3_${searchedType.split(".").join("&")}`;
|
|
5026
|
+
if (!channelContext.data[encodedType]) {
|
|
5027
|
+
return {
|
|
5028
|
+
name: channelContext.name,
|
|
5029
|
+
meta: channelContext.meta,
|
|
5030
|
+
data: {}
|
|
5031
|
+
};
|
|
5032
|
+
}
|
|
5033
|
+
const fdc3Context = { type: searchedType, ...channelContext.data[encodedType] };
|
|
5034
|
+
return {
|
|
5035
|
+
name: channelContext.name,
|
|
5036
|
+
meta: channelContext.meta,
|
|
5037
|
+
data: { fdc3: fdc3Context }
|
|
5038
|
+
};
|
|
5039
|
+
}
|
|
5000
5040
|
getContextWithFdc3Data(channelContext) {
|
|
5001
5041
|
const { latest_fdc3_type, ...rest } = channelContext;
|
|
5002
5042
|
const parsedType = latest_fdc3_type.split("&").join(".");
|
|
@@ -5022,13 +5062,17 @@
|
|
|
5022
5062
|
return this.registry.add(this.ChangedKey, callback);
|
|
5023
5063
|
}
|
|
5024
5064
|
async add(info) {
|
|
5025
|
-
const channelContext = runDecoderWithIOError(
|
|
5065
|
+
const channelContext = runDecoderWithIOError(channelDefinitionDecoder, info);
|
|
5026
5066
|
const channelWithSuchNameExists = this.getAllChannelNames().includes(channelContext.name);
|
|
5027
5067
|
if (channelWithSuchNameExists) {
|
|
5028
5068
|
return ioError.raiseError("There's an already existing channel with such name");
|
|
5029
5069
|
}
|
|
5030
5070
|
await this.bridge.send("channels", operations$4.addChannel, channelContext);
|
|
5031
|
-
return
|
|
5071
|
+
return {
|
|
5072
|
+
name: channelContext.name,
|
|
5073
|
+
meta: channelContext.meta,
|
|
5074
|
+
data: channelContext.data || {}
|
|
5075
|
+
};
|
|
5032
5076
|
}
|
|
5033
5077
|
async remove(name) {
|
|
5034
5078
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
@@ -5056,11 +5100,14 @@
|
|
|
5056
5100
|
})
|
|
5057
5101
|
.catch(err => this.logger.trace(err));
|
|
5058
5102
|
};
|
|
5059
|
-
async getMy() {
|
|
5103
|
+
async getMy(options) {
|
|
5060
5104
|
if (!this.currentChannelName) {
|
|
5061
5105
|
return;
|
|
5062
5106
|
}
|
|
5063
|
-
|
|
5107
|
+
if (options) {
|
|
5108
|
+
runDecoderWithIOError(fdc3OptionsDecoder, options);
|
|
5109
|
+
}
|
|
5110
|
+
return this.get(this.currentChannelName, options);
|
|
5064
5111
|
}
|
|
5065
5112
|
async getWindowsOnChannel(channel) {
|
|
5066
5113
|
const channelNames = this.getAllChannelNames();
|
|
@@ -5204,6 +5251,36 @@
|
|
|
5204
5251
|
};
|
|
5205
5252
|
return wrappedCallback;
|
|
5206
5253
|
}
|
|
5254
|
+
getWrappedSubscribeCallbackWithFdc3Type(callback, fdc3Type) {
|
|
5255
|
+
const didReplay = { replayed: false };
|
|
5256
|
+
const wrappedCallback = (_, context, updaterId) => {
|
|
5257
|
+
const canRead = this.isAllowedByRestrictions(context.name, "read");
|
|
5258
|
+
if (!canRead) {
|
|
5259
|
+
return;
|
|
5260
|
+
}
|
|
5261
|
+
const { data, latest_fdc3_type } = context;
|
|
5262
|
+
const searchedType = `fdc3_${fdc3Type.split(".").join("&")}`;
|
|
5263
|
+
if (!data[searchedType]) {
|
|
5264
|
+
return;
|
|
5265
|
+
}
|
|
5266
|
+
if (didReplay.replayed) {
|
|
5267
|
+
return this.parseDataAndInvokeSubscribeCallback({ latestFdc3TypeEncoded: latest_fdc3_type, searchedType: fdc3Type, callback, context, updaterId });
|
|
5268
|
+
}
|
|
5269
|
+
const fdc3Data = { type: fdc3Type, ...data[searchedType] };
|
|
5270
|
+
callback({ fdc3: fdc3Data }, context, updaterId);
|
|
5271
|
+
didReplay.replayed = true;
|
|
5272
|
+
};
|
|
5273
|
+
return wrappedCallback;
|
|
5274
|
+
}
|
|
5275
|
+
parseDataAndInvokeSubscribeCallback(args) {
|
|
5276
|
+
const { latestFdc3TypeEncoded, searchedType, callback, context, updaterId } = args;
|
|
5277
|
+
const latestPublishedType = latestFdc3TypeEncoded.split("&").join(".");
|
|
5278
|
+
if (latestPublishedType !== searchedType) {
|
|
5279
|
+
return;
|
|
5280
|
+
}
|
|
5281
|
+
const fdc3Data = { type: searchedType, ...context.data[`fdc3_${latestFdc3TypeEncoded}`] };
|
|
5282
|
+
callback({ fdc3: fdc3Data }, context, updaterId);
|
|
5283
|
+
}
|
|
5207
5284
|
}
|
|
5208
5285
|
|
|
5209
5286
|
const operations$3 = {
|
|
@@ -6013,6 +6090,7 @@
|
|
|
6013
6090
|
appManagerController;
|
|
6014
6091
|
platformAppName;
|
|
6015
6092
|
registry = CallbackRegistryFactory$1();
|
|
6093
|
+
validNonExistentApps;
|
|
6016
6094
|
handlePlatformShutdown() {
|
|
6017
6095
|
this.registry.clear();
|
|
6018
6096
|
}
|
|
@@ -6026,6 +6104,7 @@
|
|
|
6026
6104
|
try {
|
|
6027
6105
|
const prefsHelloSuccess = await this.bridge.send("prefs", operations.prefsHello, undefined, undefined, { includeOperationCheck: true });
|
|
6028
6106
|
this.platformAppName = prefsHelloSuccess.platform.app;
|
|
6107
|
+
this.validNonExistentApps = prefsHelloSuccess.validNonExistentApps ?? [];
|
|
6029
6108
|
}
|
|
6030
6109
|
catch (error) {
|
|
6031
6110
|
this.logger.warn("The platform of this client is outdated and does not support Prefs API.");
|
|
@@ -6048,12 +6127,12 @@
|
|
|
6048
6127
|
return await operation.execute(operationData);
|
|
6049
6128
|
}
|
|
6050
6129
|
async get(app) {
|
|
6051
|
-
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder
|
|
6130
|
+
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6052
6131
|
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6053
6132
|
return prefs;
|
|
6054
6133
|
}
|
|
6055
6134
|
async update(data, options) {
|
|
6056
|
-
const verifiedOptions = optional$1(basePrefsConfigDecoder)
|
|
6135
|
+
const verifiedOptions = runDecoderWithIOError(optional$1(basePrefsConfigDecoder), options);
|
|
6057
6136
|
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
6058
6137
|
await this.updateFor(app, data);
|
|
6059
6138
|
}
|
|
@@ -6108,7 +6187,7 @@
|
|
|
6108
6187
|
subscribeFor(app, callback) {
|
|
6109
6188
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6110
6189
|
const applications = this.appManagerController.getApplications();
|
|
6111
|
-
const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp);
|
|
6190
|
+
const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp) || this.validNonExistentApps.includes(verifiedApp);
|
|
6112
6191
|
if (!isValidApp) {
|
|
6113
6192
|
return ioError.raiseError(`The provided app name "${app}" is not valid.`);
|
|
6114
6193
|
}
|
|
@@ -6299,16 +6378,12 @@
|
|
|
6299
6378
|
}
|
|
6300
6379
|
}
|
|
6301
6380
|
|
|
6302
|
-
var version$1 = "3.4.
|
|
6381
|
+
var version$1 = "3.4.6";
|
|
6303
6382
|
|
|
6304
6383
|
const createFactoryFunction = (coreFactoryFunction) => {
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
return enterprise(userConfig);
|
|
6308
|
-
}
|
|
6384
|
+
let cachedApiPromise;
|
|
6385
|
+
const initAPI = async (config) => {
|
|
6309
6386
|
const ioc = new IoC();
|
|
6310
|
-
const config = parseConfig(userConfig);
|
|
6311
|
-
checkSingleton();
|
|
6312
6387
|
const glue = await PromiseWrap(() => coreFactoryFunction(config, { version: version$1 }), 30000, "Glue Web initialization timed out, because core didn't resolve");
|
|
6313
6388
|
const logger = glue.logger.subLogger("web.main.controller");
|
|
6314
6389
|
ioc.defineGlue(glue);
|
|
@@ -6330,6 +6405,22 @@
|
|
|
6330
6405
|
return ioError.raiseError(error, true);
|
|
6331
6406
|
}
|
|
6332
6407
|
};
|
|
6408
|
+
const factory = (userConfig) => {
|
|
6409
|
+
if (window.glue42gd || window.iodesktop) {
|
|
6410
|
+
return enterprise(userConfig);
|
|
6411
|
+
}
|
|
6412
|
+
const config = parseConfig(userConfig);
|
|
6413
|
+
try {
|
|
6414
|
+
checkSingleton();
|
|
6415
|
+
}
|
|
6416
|
+
catch (error) {
|
|
6417
|
+
return typeof cachedApiPromise === "undefined" ? Promise.reject(new Error(error)) : cachedApiPromise;
|
|
6418
|
+
}
|
|
6419
|
+
const apiPromise = initAPI(config);
|
|
6420
|
+
cachedApiPromise = userConfig?.memoizeAPI ? apiPromise : undefined;
|
|
6421
|
+
return apiPromise;
|
|
6422
|
+
};
|
|
6423
|
+
return factory;
|
|
6333
6424
|
};
|
|
6334
6425
|
|
|
6335
6426
|
var MetricTypes = {
|