@interopio/desktop 6.6.0 → 6.6.1-next.0

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.
@@ -2933,7 +2933,7 @@
2933
2933
  }
2934
2934
  };
2935
2935
 
2936
- var version$1 = "6.3.4";
2936
+ var version$1 = "6.3.5-next.0";
2937
2937
 
2938
2938
  function prepareConfig$1 (configuration, ext, glue42gd) {
2939
2939
  let nodeStartingContext;
@@ -17573,6 +17573,9 @@
17573
17573
  channels.handleRestrictionsChanged(restrictions, targetWindowId);
17574
17574
  return;
17575
17575
  }
17576
+ if (command === "isFdc3DataWrappingSupported") {
17577
+ return { isSupported: true };
17578
+ }
17576
17579
  throw new Error(`unknown command ${command}`);
17577
17580
  });
17578
17581
  const result = await interop.invoke("T42.Channels.Announce", { swId: windowId, instance: interop.instance.instance });
@@ -17671,8 +17674,7 @@
17671
17674
  const contextName = this.createContextName(name);
17672
17675
  const contextData = await this.contexts.get(contextName);
17673
17676
  if (contextData[LATEST_FDC3_TYPE]) {
17674
- const { latest_fdc3_type, ...data } = contextData;
17675
- return data;
17677
+ return this.getContextWithFdc3Data(contextData);
17676
17678
  }
17677
17679
  return contextData;
17678
17680
  }
@@ -17751,6 +17753,21 @@
17751
17753
  }
17752
17754
  return fdc3PropsArr[0].split("_").slice(1).join("_");
17753
17755
  }
17756
+ getContextWithFdc3Data(channelContext) {
17757
+ const { latest_fdc3_type, ...rest } = channelContext;
17758
+ const parsedType = latest_fdc3_type.split("&").join(".");
17759
+ const fdc3Context = { type: parsedType, ...rest.data[`fdc3_${latest_fdc3_type}`] };
17760
+ delete rest.data[`fdc3_${latest_fdc3_type}`];
17761
+ const context = {
17762
+ name: channelContext.name,
17763
+ meta: channelContext.meta,
17764
+ data: {
17765
+ ...rest.data,
17766
+ fdc3: fdc3Context
17767
+ }
17768
+ };
17769
+ return context;
17770
+ }
17754
17771
  }
17755
17772
 
17756
17773
  class ChannelsImpl {
@@ -17780,17 +17797,7 @@
17780
17797
  }
17781
17798
  const id = Utils.generateId();
17782
17799
  this.pendingReplays[id] = true;
17783
- const callbackWithPermissionCheck = async (data, context, updaterId) => {
17784
- const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
17785
- if (restrictionByChannel.read) {
17786
- callback(data, context, updaterId);
17787
- }
17788
- else {
17789
- this.onRestrictionsChanged(() => {
17790
- callback(data, context, updaterId);
17791
- }, id, context.name);
17792
- }
17793
- };
17800
+ const wrappedCallback = this.getWrappedSubscribeCallback(callback, id);
17794
17801
  if (this.lastUpdate) {
17795
17802
  let lastUpdate = Object.assign({}, this.lastUpdate);
17796
17803
  setTimeout(async () => {
@@ -17798,12 +17805,12 @@
17798
17805
  if (this.lastUpdate) {
17799
17806
  lastUpdate = this.lastUpdate;
17800
17807
  }
17801
- callbackWithPermissionCheck(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
17808
+ wrappedCallback(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
17802
17809
  }
17803
17810
  delete this.pendingReplays[id];
17804
17811
  }, 0);
17805
17812
  }
17806
- const unsub = this.registry.add(this.subsKey, callbackWithPermissionCheck);
17813
+ const unsub = this.registry.add(this.subsKey, wrappedCallback);
17807
17814
  return () => {
17808
17815
  this.pendingReplays[id] = false;
17809
17816
  this.pendingRestrictionCallbacks.delete(id);
@@ -17818,46 +17825,35 @@
17818
17825
  throw new Error("Please provide the callback as a function!");
17819
17826
  }
17820
17827
  const id = Utils.generateId();
17821
- const callbackWithPermissionCheck = async (data, context, updaterId) => {
17822
- const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
17823
- if (restrictionByChannel.read) {
17824
- callback(data, context, updaterId);
17825
- }
17826
- else {
17827
- this.onRestrictionsChanged(() => {
17828
- callback(data, context, updaterId);
17829
- }, id, context.name);
17830
- }
17831
- };
17832
- const unsub = await this.shared.subscribeFor(name, callbackWithPermissionCheck);
17828
+ const wrappedCallback = this.getWrappedSubscribeCallback(callback, id);
17829
+ const unsub = await this.shared.subscribeFor(name, wrappedCallback);
17833
17830
  return () => {
17834
17831
  this.pendingRestrictionCallbacks.delete(id);
17835
17832
  unsub();
17836
17833
  };
17837
17834
  }
17838
- async publish(data, name) {
17835
+ async publish(data, options) {
17839
17836
  if (typeof data !== "object") {
17840
17837
  throw new Error("Please provide the data as an object!");
17841
17838
  }
17842
- if (name) {
17843
- if (typeof name !== "string") {
17844
- throw new Error("Please provide the name as a string!");
17845
- }
17846
- if (!this.shared.isChannel(name)) {
17847
- return Promise.reject(new Error(`A channel with name: ${name} doesn't exist!`));
17848
- }
17849
- if (!(await this.getRestrictionsByChannel(name)).write) {
17850
- throw new Error(`Window does not have permission to write to channel ${name}`);
17851
- }
17852
- return this.shared.updateData(name, data);
17839
+ if (options) {
17840
+ this.validatePublishOptions(options);
17853
17841
  }
17854
- if (!this.currentContext) {
17842
+ if (typeof options === "object") {
17843
+ return this.publishWithOptions(data, options);
17844
+ }
17845
+ const channelName = typeof options === "string" ? options : this.currentContext;
17846
+ if (!channelName) {
17855
17847
  throw new Error("Not joined to any channel!");
17856
17848
  }
17857
- if (!(await this.getRestrictionsByChannel(this.currentContext)).write) {
17849
+ if (!this.shared.isChannel(channelName)) {
17850
+ return Promise.reject(new Error(`A channel with name: ${channelName} doesn't exist!`));
17851
+ }
17852
+ const canPublish = (await this.getRestrictionsByChannel(channelName)).write;
17853
+ if (!canPublish) {
17858
17854
  throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
17859
17855
  }
17860
- return this.shared.updateData(this.currentContext, data);
17856
+ return this.shared.updateData(channelName, data);
17861
17857
  }
17862
17858
  async setPaths(paths, name) {
17863
17859
  if (name) {
@@ -18161,6 +18157,82 @@
18161
18157
  throw new Error(`path property is not a valid string from the Path Value argument: ${JSON.stringify(path)}`);
18162
18158
  }
18163
18159
  }
18160
+ validatePublishOptions(options) {
18161
+ if ((typeof options !== "string" && typeof options !== "object") || Array.isArray(options)) {
18162
+ throw new Error("Provide options as a string or an object");
18163
+ }
18164
+ if (typeof options === "object") {
18165
+ this.validatePublishOptionsObject(options);
18166
+ return;
18167
+ }
18168
+ if (options === "string" && !options.length) {
18169
+ throw new Error("Provide options as a non-empty string");
18170
+ }
18171
+ }
18172
+ validatePublishOptionsObject(options) {
18173
+ if (typeof options !== "object" || Array.isArray(options)) {
18174
+ throw new Error("Provide options as an object");
18175
+ }
18176
+ if (options.name && (typeof options.name !== "string" || !options.name.length)) {
18177
+ throw new Error("Provide options.name as a non-empty string");
18178
+ }
18179
+ if (Object.keys(options).includes("fdc3") && typeof options.fdc3 !== "boolean") {
18180
+ throw new Error("Provide options.fdc3 as a boolean");
18181
+ }
18182
+ }
18183
+ async publishWithOptions(data, options) {
18184
+ const channelName = options.name || this.currentContext;
18185
+ if (!this.shared.isChannel(channelName)) {
18186
+ throw new Error(`A channel with name: ${options.name} doesn't exist!`);
18187
+ }
18188
+ if (!channelName) {
18189
+ throw new Error("Cannot publish to channel, because not joined to a channel!");
18190
+ }
18191
+ const canPublish = (await this.getRestrictionsByChannel(channelName)).write;
18192
+ if (!canPublish) {
18193
+ throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
18194
+ }
18195
+ if (!options.fdc3) {
18196
+ return this.shared.updateData(channelName, data);
18197
+ }
18198
+ return this.publishFdc3Data(channelName, data);
18199
+ }
18200
+ async publishFdc3Data(channelName, data) {
18201
+ var _a;
18202
+ if (typeof data.type !== "string" || !((_a = data.type) === null || _a === void 0 ? void 0 : _a.length)) {
18203
+ throw new Error("Expected a valid FDC3 Context with compulsory 'type' field");
18204
+ }
18205
+ const { type, ...rest } = data;
18206
+ const parsedType = type.split(".").join("&");
18207
+ const fdc3DataToPublish = { [`fdc3_${parsedType}`]: rest };
18208
+ return this.shared.updateData(channelName, fdc3DataToPublish);
18209
+ }
18210
+ getWrappedSubscribeCallback(callback, id) {
18211
+ const wrappedCallback = async (_, context, updaterId) => {
18212
+ const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
18213
+ const channelData = this.getDataWithFdc3Encoding(context);
18214
+ if (restrictionByChannel.read) {
18215
+ callback(channelData, context, updaterId);
18216
+ }
18217
+ else {
18218
+ this.onRestrictionsChanged(() => {
18219
+ callback(channelData, context, updaterId);
18220
+ }, id, context.name);
18221
+ }
18222
+ };
18223
+ return wrappedCallback;
18224
+ }
18225
+ getDataWithFdc3Encoding(context) {
18226
+ const { data, latest_fdc3_type } = context;
18227
+ if (!latest_fdc3_type) {
18228
+ return data;
18229
+ }
18230
+ const parsedType = latest_fdc3_type.split("&").join(".");
18231
+ const latestTypePropName = `fdc3_${latest_fdc3_type}`;
18232
+ const fdc3Data = { type: parsedType, ...data[latestTypePropName] };
18233
+ const { [latestTypePropName]: latestFDC3Type, ...rest } = data;
18234
+ return { ...rest, fdc3: fdc3Data };
18235
+ }
18164
18236
  }
18165
18237
 
18166
18238
  function factory$4(contexts, agm, getWindows, logger) {
@@ -18284,7 +18356,7 @@
18284
18356
  };
18285
18357
  }
18286
18358
 
18287
- var version = "6.5.1";
18359
+ var version = "6.6.0";
18288
18360
 
18289
18361
  var prepareConfig = (options) => {
18290
18362
  function getLibConfig(value, defaultMode, trueMode) {
@@ -19192,28 +19264,6 @@
19192
19264
  }
19193
19265
  return { isValid: true, ok: handler };
19194
19266
  };
19195
- const validateRaiseIntentsResolverResponse = (responseObj) => {
19196
- const invalidKey = Object.keys(responseObj).some((key) => key !== "intent" && key !== "handler");
19197
- if (invalidKey) {
19198
- return { isValid: false, error: "Response is not a valid object. Expected { intent: string, handler: IntentHandler }" };
19199
- }
19200
- if (typeof responseObj.intent !== "string") {
19201
- return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
19202
- }
19203
- const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19204
- return isValid
19205
- ? { isValid: true, ok: { intent: responseObj.intent, handler: responseObj.handler } }
19206
- : { isValid: false, error };
19207
- };
19208
- const validateFilterHandlersResolverResponse = (responseObj) => {
19209
- if (!responseObj.handler) {
19210
- return { isValid: false, error: "Response is not a valid object. Expected { handler: IntentHandler }" };
19211
- }
19212
- const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19213
- return isValid
19214
- ? { isValid: true, ok: { handler: responseObj.handler } }
19215
- : { isValid: false, error };
19216
- };
19217
19267
  const validateIntentRequestTarget = (target) => {
19218
19268
  if (!target) {
19219
19269
  return;
@@ -19300,14 +19350,27 @@
19300
19350
  throw new Error(errorMsg);
19301
19351
  }
19302
19352
  };
19303
- const validateIntentsResolverResponse = (method, responseObj) => {
19304
- return method === "raise" ? validateRaiseIntentsResolverResponse(responseObj) : validateFilterHandlersResolverResponse(responseObj);
19353
+ const validateResolverResponse = (responseObj) => {
19354
+ var _a, _b;
19355
+ if (typeof responseObj.intent !== "string") {
19356
+ return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
19357
+ }
19358
+ if (((_a = responseObj.userSettings) === null || _a === void 0 ? void 0 : _a.preserveChoice) && typeof ((_b = responseObj.userSettings) === null || _b === void 0 ? void 0 : _b.preserveChoice) !== "boolean") {
19359
+ return { isValid: false, error: `Response object has invalid 'userSettings.preserveChoice' key. Expected a boolean, got ${typeof responseObj.userSettings.preserveChoice}` };
19360
+ }
19361
+ const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19362
+ return isValid
19363
+ ? { isValid: true, ok: responseObj }
19364
+ : { isValid, error };
19305
19365
  };
19306
19366
  const validateIntentRequest = (request) => {
19307
19367
  validateIntentRequestContext(request.context);
19308
19368
  validateIntentRequestTarget(request.target);
19309
19369
  validateIntentRequestTimeout(request.timeout);
19310
19370
  validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
19371
+ if (typeof request.clearSavedHandler !== "undefined" && typeof request.clearSavedHandler !== "boolean") {
19372
+ throw new Error("Please provide 'clearSavedHandler' as a boolean");
19373
+ }
19311
19374
  if (request.handlers) {
19312
19375
  request.handlers.forEach((handler) => validateIntentRequestHandler(handler));
19313
19376
  }
@@ -19356,10 +19419,11 @@
19356
19419
  };
19357
19420
 
19358
19421
  class Intents {
19359
- constructor(interop, windows, logger, options, appManager) {
19422
+ constructor(interop, windows, logger, options, prefsController, appManager) {
19360
19423
  this.interop = interop;
19361
19424
  this.windows = windows;
19362
19425
  this.logger = logger;
19426
+ this.prefsController = prefsController;
19363
19427
  this.appManager = appManager;
19364
19428
  this.myIntents = new Set();
19365
19429
  this.intentsResolverResponsePromises = {};
@@ -19401,8 +19465,16 @@
19401
19465
  }
19402
19466
  validateIntentRequest(intentRequest);
19403
19467
  await Promise.all(this.unregisterIntentPromises);
19404
- const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
19468
+ if (intentRequest.clearSavedHandler) {
19469
+ this.logger.trace(`User removes saved handler for intent ${intentRequest.intent}`);
19470
+ await this.removeRememberedHandler(intentRequest.intent);
19471
+ }
19405
19472
  const resolverInstance = {};
19473
+ const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
19474
+ const resultFromRememberedHandler = await this.checkHandleRaiseWithRememberedHandler(intentRequest, resolverInstance, timeout);
19475
+ if (resultFromRememberedHandler) {
19476
+ return resultFromRememberedHandler;
19477
+ }
19406
19478
  const coreRaiseIntentFn = this.coreRaiseIntent.bind(this, { request: intentRequest, resolverInstance, timeout });
19407
19479
  if (intentRequest.waitUserResponseIndefinitely) {
19408
19480
  return coreRaiseIntentFn();
@@ -19603,6 +19675,10 @@
19603
19675
  this.logger.trace(`Returning intents for handler ${JSON.stringify(handler)}`);
19604
19676
  return { intents: intentsWithInfo };
19605
19677
  }
19678
+ async clearSavedHandlers() {
19679
+ this.logger.trace("Removing all saved handlers from prefs storage for current app");
19680
+ await this.prefsController.update({ intents: undefined });
19681
+ }
19606
19682
  filterHandlersBy(intents, filter) {
19607
19683
  const filteredIntentsWithHandlers = intents.filter((intent) => {
19608
19684
  if (filter.intent && filter.intent !== intent.name) {
@@ -19704,7 +19780,7 @@
19704
19780
  async startResolverApp({ request, method, resolverInstance }) {
19705
19781
  var _a, _b, _c, _d;
19706
19782
  (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intents Resolver UI with app name ${this.intentsResolverAppName} will be used for request: ${JSON.stringify(request)}`);
19707
- const responseMethodName = await this.registerIntentResolverMethod(method);
19783
+ const responseMethodName = await this.registerIntentResolverMethod();
19708
19784
  (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Registered interop method ${responseMethodName}`);
19709
19785
  const startContext = this.buildStartContext(method, request, responseMethodName);
19710
19786
  const startOptions = await this.buildStartOptions();
@@ -19723,7 +19799,7 @@
19723
19799
  ? `for intent ${request.intent}`
19724
19800
  : `for '${method}' method with filter ${JSON.stringify(request)}`}`
19725
19801
  });
19726
- const handler = await this.handleInstanceResponse(instance.id, method);
19802
+ const handler = await this.handleInstanceResponse({ instanceId: instance.id, caller: startContext.initialCaller, method, request });
19727
19803
  return handler;
19728
19804
  }
19729
19805
  async windowsIdToTitle(id, windowsInfos) {
@@ -19735,13 +19811,23 @@
19735
19811
  const title = await (window === null || window === void 0 ? void 0 : window.getTitle());
19736
19812
  return title;
19737
19813
  }
19738
- async handleInstanceResponse(instanceId, method) {
19739
- var _a, _b;
19814
+ async handleInstanceResponse({ instanceId, method, request, caller }) {
19815
+ var _a, _b, _c;
19740
19816
  try {
19741
19817
  const response = await this.intentsResolverResponsePromises[instanceId].promise;
19742
19818
  (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intent handler chosen ${method === "raise" ? `for intent ${response.intent} ` : ""}: ${JSON.stringify(response.handler)}. Stopping resolver instance with id ${instanceId}`);
19743
19819
  this.stopResolverInstance(instanceId);
19744
19820
  (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Instance with id ${instanceId} successfully stopped`);
19821
+ if ((_c = response.userSettings) === null || _c === void 0 ? void 0 : _c.preserveChoice) {
19822
+ await this.saveUserChoice({
19823
+ intent: response.intent,
19824
+ handler: response.handler,
19825
+ filter: method === "filterHandlers"
19826
+ ? { applicationNames: request.applicationNames, contextTypes: request.contextTypes, resultType: request.resultType }
19827
+ : undefined,
19828
+ caller
19829
+ });
19830
+ }
19745
19831
  return response.handler;
19746
19832
  }
19747
19833
  catch (error) {
@@ -19749,14 +19835,14 @@
19749
19835
  throw new Error(error);
19750
19836
  }
19751
19837
  }
19752
- async registerIntentResolverMethod(method) {
19838
+ async registerIntentResolverMethod() {
19753
19839
  const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + Utils.generateId();
19754
- await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId, method));
19840
+ await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId));
19755
19841
  return methodName;
19756
19842
  }
19757
- resolverResponseHandler(args, callerId, method) {
19843
+ resolverResponseHandler(args, callerId) {
19758
19844
  const { instance } = callerId;
19759
- const isValid = validateIntentsResolverResponse(method, args);
19845
+ const isValid = validateResolverResponse(args);
19760
19846
  if (!isValid) {
19761
19847
  this.logger.trace(`Intent Resolver instance with id ${callerId.instance} sent invalid response. Error: ${isValid.error}`);
19762
19848
  this.intentsResolverResponsePromises[instance].reject(isValid.error);
@@ -19768,7 +19854,15 @@
19768
19854
  this.cleanUpIntentResolverPromise(instance);
19769
19855
  }
19770
19856
  buildStartContext(method, request, methodName) {
19771
- const baseStartContext = { callerId: this.interop.instance.instance, methodName };
19857
+ var _a;
19858
+ const myAppName = this.interop.instance.application || this.interop.instance.applicationName;
19859
+ const myAppTitle = ((_a = this.appManager.application(myAppName)) === null || _a === void 0 ? void 0 : _a.title) || "";
19860
+ const baseStartContext = {
19861
+ callerId: this.interop.instance.instance,
19862
+ methodName,
19863
+ initialCaller: { id: this.interop.instance.instance, applicationName: myAppName, applicationTitle: myAppTitle },
19864
+ resolverApi: "1.0"
19865
+ };
19772
19866
  return method === "raise"
19773
19867
  ? { ...baseStartContext, intent: request }
19774
19868
  : { ...baseStartContext, handlerFilter: request };
@@ -19956,6 +20050,64 @@
19956
20050
  }, []);
19957
20051
  return intentsWithInfo;
19958
20052
  }
20053
+ async removeRememberedHandler(intentName) {
20054
+ var _a;
20055
+ this.logger.trace(`Removing saved handler from prefs storage for intent ${intentName}`);
20056
+ const prefs = await this.prefsController.get();
20057
+ const intentPrefs = (_a = prefs.data) === null || _a === void 0 ? void 0 : _a.intents;
20058
+ if (!intentPrefs) {
20059
+ this.logger.trace("No app prefs found for current app");
20060
+ return;
20061
+ }
20062
+ delete intentPrefs[intentName];
20063
+ const updatedPrefs = {
20064
+ ...prefs.data,
20065
+ intents: intentPrefs
20066
+ };
20067
+ await this.prefsController.update(updatedPrefs);
20068
+ this.logger.trace(`Handler saved choice for intent ${intentName} removed successfully`);
20069
+ }
20070
+ async checkForRememberedHandler(intentRequest) {
20071
+ var _a, _b;
20072
+ const prefs = await this.prefsController.get();
20073
+ const prefsForIntent = (_b = (_a = prefs.data) === null || _a === void 0 ? void 0 : _a.intents) === null || _b === void 0 ? void 0 : _b[intentRequest.intent];
20074
+ return prefsForIntent === null || prefsForIntent === void 0 ? void 0 : prefsForIntent.handler;
20075
+ }
20076
+ async checkHandleRaiseWithRememberedHandler(intentRequest, resolverInstance, timeout) {
20077
+ const rememberedHandler = await this.checkForRememberedHandler(intentRequest);
20078
+ if (!rememberedHandler) {
20079
+ return;
20080
+ }
20081
+ const request = {
20082
+ ...intentRequest,
20083
+ target: {
20084
+ app: rememberedHandler.applicationName,
20085
+ instance: rememberedHandler.instanceId
20086
+ }
20087
+ };
20088
+ try {
20089
+ const response = await this.coreRaiseIntent({ request, resolverInstance, timeout });
20090
+ return response;
20091
+ }
20092
+ catch (error) {
20093
+ this.logger.trace("Could not raise intent to remembered handler. Removing it from Prefs store");
20094
+ await this.removeRememberedHandler(intentRequest.intent);
20095
+ }
20096
+ }
20097
+ async saveUserChoice({ intent, handler, filter, caller }) {
20098
+ var _a, _b;
20099
+ const prevPrefs = await this.prefsController.get(caller.applicationName);
20100
+ const prevIntentsPrefs = ((_a = prevPrefs === null || prevPrefs === void 0 ? void 0 : prevPrefs.data) === null || _a === void 0 ? void 0 : _a.intents) || {};
20101
+ const prefsToUpdate = {
20102
+ ...prevPrefs.data,
20103
+ intents: {
20104
+ ...prevIntentsPrefs,
20105
+ [intent]: { handler, filter }
20106
+ }
20107
+ };
20108
+ await this.prefsController.update(prefsToUpdate, { app: caller.applicationName });
20109
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.info(`Saved user's choice of handler for '${caller.applicationName}' app`);
20110
+ }
19959
20111
  }
19960
20112
 
19961
20113
  class FactoryCallInfo {
@@ -20202,6 +20354,7 @@
20202
20354
  let _windows;
20203
20355
  let _displays;
20204
20356
  let _channels;
20357
+ let _prefs;
20205
20358
  const _browserEventsDispatcher = new EventsDispatcher(glueConfig);
20206
20359
  function createWindows(core) {
20207
20360
  if (glueConfig.windows) {
@@ -20298,7 +20451,7 @@
20298
20451
  return hotkeysAPI;
20299
20452
  }
20300
20453
  function createIntents(core) {
20301
- const intentsAPI = new Intents(core.agm, _windows, core.logger.subLogger("intents"), options, _appManager);
20454
+ const intentsAPI = new Intents(core.agm, _windows, core.logger.subLogger("intents"), options, _prefs, _appManager);
20302
20455
  debugLog(intentsAPI);
20303
20456
  return intentsAPI;
20304
20457
  }
@@ -20326,9 +20479,9 @@
20326
20479
  function createPrefs(core) {
20327
20480
  var _a, _b;
20328
20481
  const appName = (_b = (_a = options.application) !== null && _a !== void 0 ? _a : glue42gd === null || glue42gd === void 0 ? void 0 : glue42gd.applicationName) !== null && _b !== void 0 ? _b : core.interop.instance.application;
20329
- const prefs = new Prefs(appName, core.interop);
20330
- debugLog(prefs);
20331
- return prefs;
20482
+ _prefs = new Prefs(appName, core.interop);
20483
+ debugLog(_prefs);
20484
+ return _prefs;
20332
20485
  }
20333
20486
  function createCookies(core) {
20334
20487
  const api = factory$1(core.interop, T42GDExecuteMethod);
@@ -20357,10 +20510,10 @@
20357
20510
  { name: "channels", create: createChannels },
20358
20511
  { name: "hotkeys", create: createHotkeys },
20359
20512
  { name: "displays", create: createDisplaysApi },
20513
+ { name: "prefs", create: createPrefs },
20360
20514
  { name: "intents", create: createIntents },
20361
20515
  { name: "notifications", create: createNotifications },
20362
20516
  { name: "themes", create: createThemes },
20363
- { name: "prefs", create: createPrefs },
20364
20517
  { name: "cookies", create: createCookies }
20365
20518
  ],
20366
20519
  version,