@interopio/desktop 6.6.0 → 6.7.0-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.
@@ -2927,7 +2927,7 @@ const ContextMessageReplaySpec = {
2927
2927
  }
2928
2928
  };
2929
2929
 
2930
- var version$1 = "6.3.4";
2930
+ var version$1 = "6.4.0-next.0";
2931
2931
 
2932
2932
  function prepareConfig$1 (configuration, ext, glue42gd) {
2933
2933
  let nodeStartingContext;
@@ -17567,6 +17567,9 @@ async function setupInterop(interopLib, channels) {
17567
17567
  channels.handleRestrictionsChanged(restrictions, targetWindowId);
17568
17568
  return;
17569
17569
  }
17570
+ if (command === "isFdc3DataWrappingSupported") {
17571
+ return { isSupported: true };
17572
+ }
17570
17573
  throw new Error(`unknown command ${command}`);
17571
17574
  });
17572
17575
  const result = await interop.invoke("T42.Channels.Announce", { swId: windowId, instance: interop.instance.instance });
@@ -17665,8 +17668,7 @@ class SharedContextSubscriber {
17665
17668
  const contextName = this.createContextName(name);
17666
17669
  const contextData = await this.contexts.get(contextName);
17667
17670
  if (contextData[LATEST_FDC3_TYPE]) {
17668
- const { latest_fdc3_type, ...data } = contextData;
17669
- return data;
17671
+ return this.getContextWithFdc3Data(contextData);
17670
17672
  }
17671
17673
  return contextData;
17672
17674
  }
@@ -17745,6 +17747,21 @@ class SharedContextSubscriber {
17745
17747
  }
17746
17748
  return fdc3PropsArr[0].split("_").slice(1).join("_");
17747
17749
  }
17750
+ getContextWithFdc3Data(channelContext) {
17751
+ const { latest_fdc3_type, ...rest } = channelContext;
17752
+ const parsedType = latest_fdc3_type.split("&").join(".");
17753
+ const fdc3Context = { type: parsedType, ...rest.data[`fdc3_${latest_fdc3_type}`] };
17754
+ delete rest.data[`fdc3_${latest_fdc3_type}`];
17755
+ const context = {
17756
+ name: channelContext.name,
17757
+ meta: channelContext.meta,
17758
+ data: {
17759
+ ...rest.data,
17760
+ fdc3: fdc3Context
17761
+ }
17762
+ };
17763
+ return context;
17764
+ }
17748
17765
  }
17749
17766
 
17750
17767
  class ChannelsImpl {
@@ -17774,17 +17791,7 @@ class ChannelsImpl {
17774
17791
  }
17775
17792
  const id = Utils.generateId();
17776
17793
  this.pendingReplays[id] = true;
17777
- const callbackWithPermissionCheck = async (data, context, updaterId) => {
17778
- const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
17779
- if (restrictionByChannel.read) {
17780
- callback(data, context, updaterId);
17781
- }
17782
- else {
17783
- this.onRestrictionsChanged(() => {
17784
- callback(data, context, updaterId);
17785
- }, id, context.name);
17786
- }
17787
- };
17794
+ const wrappedCallback = this.getWrappedSubscribeCallback(callback, id);
17788
17795
  if (this.lastUpdate) {
17789
17796
  let lastUpdate = Object.assign({}, this.lastUpdate);
17790
17797
  setTimeout(async () => {
@@ -17792,12 +17799,12 @@ class ChannelsImpl {
17792
17799
  if (this.lastUpdate) {
17793
17800
  lastUpdate = this.lastUpdate;
17794
17801
  }
17795
- callbackWithPermissionCheck(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
17802
+ wrappedCallback(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
17796
17803
  }
17797
17804
  delete this.pendingReplays[id];
17798
17805
  }, 0);
17799
17806
  }
17800
- const unsub = this.registry.add(this.subsKey, callbackWithPermissionCheck);
17807
+ const unsub = this.registry.add(this.subsKey, wrappedCallback);
17801
17808
  return () => {
17802
17809
  this.pendingReplays[id] = false;
17803
17810
  this.pendingRestrictionCallbacks.delete(id);
@@ -17812,46 +17819,35 @@ class ChannelsImpl {
17812
17819
  throw new Error("Please provide the callback as a function!");
17813
17820
  }
17814
17821
  const id = Utils.generateId();
17815
- const callbackWithPermissionCheck = async (data, context, updaterId) => {
17816
- const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
17817
- if (restrictionByChannel.read) {
17818
- callback(data, context, updaterId);
17819
- }
17820
- else {
17821
- this.onRestrictionsChanged(() => {
17822
- callback(data, context, updaterId);
17823
- }, id, context.name);
17824
- }
17825
- };
17826
- const unsub = await this.shared.subscribeFor(name, callbackWithPermissionCheck);
17822
+ const wrappedCallback = this.getWrappedSubscribeCallback(callback, id);
17823
+ const unsub = await this.shared.subscribeFor(name, wrappedCallback);
17827
17824
  return () => {
17828
17825
  this.pendingRestrictionCallbacks.delete(id);
17829
17826
  unsub();
17830
17827
  };
17831
17828
  }
17832
- async publish(data, name) {
17829
+ async publish(data, options) {
17833
17830
  if (typeof data !== "object") {
17834
17831
  throw new Error("Please provide the data as an object!");
17835
17832
  }
17836
- if (name) {
17837
- if (typeof name !== "string") {
17838
- throw new Error("Please provide the name as a string!");
17839
- }
17840
- if (!this.shared.isChannel(name)) {
17841
- return Promise.reject(new Error(`A channel with name: ${name} doesn't exist!`));
17842
- }
17843
- if (!(await this.getRestrictionsByChannel(name)).write) {
17844
- throw new Error(`Window does not have permission to write to channel ${name}`);
17845
- }
17846
- return this.shared.updateData(name, data);
17833
+ if (options) {
17834
+ this.validatePublishOptions(options);
17847
17835
  }
17848
- if (!this.currentContext) {
17836
+ if (typeof options === "object") {
17837
+ return this.publishWithOptions(data, options);
17838
+ }
17839
+ const channelName = typeof options === "string" ? options : this.currentContext;
17840
+ if (!channelName) {
17849
17841
  throw new Error("Not joined to any channel!");
17850
17842
  }
17851
- if (!(await this.getRestrictionsByChannel(this.currentContext)).write) {
17843
+ if (!this.shared.isChannel(channelName)) {
17844
+ return Promise.reject(new Error(`A channel with name: ${channelName} doesn't exist!`));
17845
+ }
17846
+ const canPublish = (await this.getRestrictionsByChannel(channelName)).write;
17847
+ if (!canPublish) {
17852
17848
  throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
17853
17849
  }
17854
- return this.shared.updateData(this.currentContext, data);
17850
+ return this.shared.updateData(channelName, data);
17855
17851
  }
17856
17852
  async setPaths(paths, name) {
17857
17853
  if (name) {
@@ -18155,6 +18151,82 @@ class ChannelsImpl {
18155
18151
  throw new Error(`path property is not a valid string from the Path Value argument: ${JSON.stringify(path)}`);
18156
18152
  }
18157
18153
  }
18154
+ validatePublishOptions(options) {
18155
+ if ((typeof options !== "string" && typeof options !== "object") || Array.isArray(options)) {
18156
+ throw new Error("Provide options as a string or an object");
18157
+ }
18158
+ if (typeof options === "object") {
18159
+ this.validatePublishOptionsObject(options);
18160
+ return;
18161
+ }
18162
+ if (options === "string" && !options.length) {
18163
+ throw new Error("Provide options as a non-empty string");
18164
+ }
18165
+ }
18166
+ validatePublishOptionsObject(options) {
18167
+ if (typeof options !== "object" || Array.isArray(options)) {
18168
+ throw new Error("Provide options as an object");
18169
+ }
18170
+ if (options.name && (typeof options.name !== "string" || !options.name.length)) {
18171
+ throw new Error("Provide options.name as a non-empty string");
18172
+ }
18173
+ if (Object.keys(options).includes("fdc3") && typeof options.fdc3 !== "boolean") {
18174
+ throw new Error("Provide options.fdc3 as a boolean");
18175
+ }
18176
+ }
18177
+ async publishWithOptions(data, options) {
18178
+ const channelName = options.name || this.currentContext;
18179
+ if (!this.shared.isChannel(channelName)) {
18180
+ throw new Error(`A channel with name: ${options.name} doesn't exist!`);
18181
+ }
18182
+ if (!channelName) {
18183
+ throw new Error("Cannot publish to channel, because not joined to a channel!");
18184
+ }
18185
+ const canPublish = (await this.getRestrictionsByChannel(channelName)).write;
18186
+ if (!canPublish) {
18187
+ throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
18188
+ }
18189
+ if (!options.fdc3) {
18190
+ return this.shared.updateData(channelName, data);
18191
+ }
18192
+ return this.publishFdc3Data(channelName, data);
18193
+ }
18194
+ async publishFdc3Data(channelName, data) {
18195
+ var _a;
18196
+ if (typeof data.type !== "string" || !((_a = data.type) === null || _a === void 0 ? void 0 : _a.length)) {
18197
+ throw new Error("Expected a valid FDC3 Context with compulsory 'type' field");
18198
+ }
18199
+ const { type, ...rest } = data;
18200
+ const parsedType = type.split(".").join("&");
18201
+ const fdc3DataToPublish = { [`fdc3_${parsedType}`]: rest };
18202
+ return this.shared.updateData(channelName, fdc3DataToPublish);
18203
+ }
18204
+ getWrappedSubscribeCallback(callback, id) {
18205
+ const wrappedCallback = async (_, context, updaterId) => {
18206
+ const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
18207
+ const channelData = this.getDataWithFdc3Encoding(context);
18208
+ if (restrictionByChannel.read) {
18209
+ callback(channelData, context, updaterId);
18210
+ }
18211
+ else {
18212
+ this.onRestrictionsChanged(() => {
18213
+ callback(channelData, context, updaterId);
18214
+ }, id, context.name);
18215
+ }
18216
+ };
18217
+ return wrappedCallback;
18218
+ }
18219
+ getDataWithFdc3Encoding(context) {
18220
+ const { data, latest_fdc3_type } = context;
18221
+ if (!latest_fdc3_type) {
18222
+ return data;
18223
+ }
18224
+ const parsedType = latest_fdc3_type.split("&").join(".");
18225
+ const latestTypePropName = `fdc3_${latest_fdc3_type}`;
18226
+ const fdc3Data = { type: parsedType, ...data[latestTypePropName] };
18227
+ const { [latestTypePropName]: latestFDC3Type, ...rest } = data;
18228
+ return { ...rest, fdc3: fdc3Data };
18229
+ }
18158
18230
  }
18159
18231
 
18160
18232
  function factory$4(contexts, agm, getWindows, logger) {
@@ -18278,7 +18350,7 @@ function factory$3(agm) {
18278
18350
  };
18279
18351
  }
18280
18352
 
18281
- var version = "6.5.1";
18353
+ var version = "6.6.0";
18282
18354
 
18283
18355
  var prepareConfig = (options) => {
18284
18356
  function getLibConfig(value, defaultMode, trueMode) {
@@ -19186,28 +19258,6 @@ const validateIntentHandlerAsResponse = (handler) => {
19186
19258
  }
19187
19259
  return { isValid: true, ok: handler };
19188
19260
  };
19189
- const validateRaiseIntentsResolverResponse = (responseObj) => {
19190
- const invalidKey = Object.keys(responseObj).some((key) => key !== "intent" && key !== "handler");
19191
- if (invalidKey) {
19192
- return { isValid: false, error: "Response is not a valid object. Expected { intent: string, handler: IntentHandler }" };
19193
- }
19194
- if (typeof responseObj.intent !== "string") {
19195
- return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
19196
- }
19197
- const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19198
- return isValid
19199
- ? { isValid: true, ok: { intent: responseObj.intent, handler: responseObj.handler } }
19200
- : { isValid: false, error };
19201
- };
19202
- const validateFilterHandlersResolverResponse = (responseObj) => {
19203
- if (!responseObj.handler) {
19204
- return { isValid: false, error: "Response is not a valid object. Expected { handler: IntentHandler }" };
19205
- }
19206
- const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19207
- return isValid
19208
- ? { isValid: true, ok: { handler: responseObj.handler } }
19209
- : { isValid: false, error };
19210
- };
19211
19261
  const validateIntentRequestTarget = (target) => {
19212
19262
  if (!target) {
19213
19263
  return;
@@ -19294,14 +19344,27 @@ const validateHandlerFilter = (handlerFilter) => {
19294
19344
  throw new Error(errorMsg);
19295
19345
  }
19296
19346
  };
19297
- const validateIntentsResolverResponse = (method, responseObj) => {
19298
- return method === "raise" ? validateRaiseIntentsResolverResponse(responseObj) : validateFilterHandlersResolverResponse(responseObj);
19347
+ const validateResolverResponse = (responseObj) => {
19348
+ var _a, _b;
19349
+ if (typeof responseObj.intent !== "string") {
19350
+ return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
19351
+ }
19352
+ 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") {
19353
+ return { isValid: false, error: `Response object has invalid 'userSettings.preserveChoice' key. Expected a boolean, got ${typeof responseObj.userSettings.preserveChoice}` };
19354
+ }
19355
+ const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19356
+ return isValid
19357
+ ? { isValid: true, ok: responseObj }
19358
+ : { isValid, error };
19299
19359
  };
19300
19360
  const validateIntentRequest = (request) => {
19301
19361
  validateIntentRequestContext(request.context);
19302
19362
  validateIntentRequestTarget(request.target);
19303
19363
  validateIntentRequestTimeout(request.timeout);
19304
19364
  validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
19365
+ if (typeof request.clearSavedHandler !== "undefined" && typeof request.clearSavedHandler !== "boolean") {
19366
+ throw new Error("Please provide 'clearSavedHandler' as a boolean");
19367
+ }
19305
19368
  if (request.handlers) {
19306
19369
  request.handlers.forEach((handler) => validateIntentRequestHandler(handler));
19307
19370
  }
@@ -19350,10 +19413,11 @@ const clearNullUndefined = (obj) => {
19350
19413
  };
19351
19414
 
19352
19415
  class Intents {
19353
- constructor(interop, windows, logger, options, appManager) {
19416
+ constructor(interop, windows, logger, options, prefsController, appManager) {
19354
19417
  this.interop = interop;
19355
19418
  this.windows = windows;
19356
19419
  this.logger = logger;
19420
+ this.prefsController = prefsController;
19357
19421
  this.appManager = appManager;
19358
19422
  this.myIntents = new Set();
19359
19423
  this.intentsResolverResponsePromises = {};
@@ -19395,8 +19459,16 @@ class Intents {
19395
19459
  }
19396
19460
  validateIntentRequest(intentRequest);
19397
19461
  await Promise.all(this.unregisterIntentPromises);
19398
- const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
19462
+ if (intentRequest.clearSavedHandler) {
19463
+ this.logger.trace(`User removes saved handler for intent ${intentRequest.intent}`);
19464
+ await this.removeRememberedHandler(intentRequest.intent);
19465
+ }
19399
19466
  const resolverInstance = {};
19467
+ const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
19468
+ const resultFromRememberedHandler = await this.checkHandleRaiseWithRememberedHandler(intentRequest, resolverInstance, timeout);
19469
+ if (resultFromRememberedHandler) {
19470
+ return resultFromRememberedHandler;
19471
+ }
19400
19472
  const coreRaiseIntentFn = this.coreRaiseIntent.bind(this, { request: intentRequest, resolverInstance, timeout });
19401
19473
  if (intentRequest.waitUserResponseIndefinitely) {
19402
19474
  return coreRaiseIntentFn();
@@ -19597,6 +19669,10 @@ class Intents {
19597
19669
  this.logger.trace(`Returning intents for handler ${JSON.stringify(handler)}`);
19598
19670
  return { intents: intentsWithInfo };
19599
19671
  }
19672
+ async clearSavedHandlers() {
19673
+ this.logger.trace("Removing all saved handlers from prefs storage for current app");
19674
+ await this.prefsController.update({ intents: undefined });
19675
+ }
19600
19676
  filterHandlersBy(intents, filter) {
19601
19677
  const filteredIntentsWithHandlers = intents.filter((intent) => {
19602
19678
  if (filter.intent && filter.intent !== intent.name) {
@@ -19698,7 +19774,7 @@ class Intents {
19698
19774
  async startResolverApp({ request, method, resolverInstance }) {
19699
19775
  var _a, _b, _c, _d;
19700
19776
  (_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)}`);
19701
- const responseMethodName = await this.registerIntentResolverMethod(method);
19777
+ const responseMethodName = await this.registerIntentResolverMethod();
19702
19778
  (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Registered interop method ${responseMethodName}`);
19703
19779
  const startContext = this.buildStartContext(method, request, responseMethodName);
19704
19780
  const startOptions = await this.buildStartOptions();
@@ -19717,7 +19793,7 @@ class Intents {
19717
19793
  ? `for intent ${request.intent}`
19718
19794
  : `for '${method}' method with filter ${JSON.stringify(request)}`}`
19719
19795
  });
19720
- const handler = await this.handleInstanceResponse(instance.id, method);
19796
+ const handler = await this.handleInstanceResponse({ instanceId: instance.id, caller: startContext.initialCaller, method, request });
19721
19797
  return handler;
19722
19798
  }
19723
19799
  async windowsIdToTitle(id, windowsInfos) {
@@ -19729,13 +19805,24 @@ class Intents {
19729
19805
  const title = await (window === null || window === void 0 ? void 0 : window.getTitle());
19730
19806
  return title;
19731
19807
  }
19732
- async handleInstanceResponse(instanceId, method) {
19733
- var _a, _b;
19808
+ async handleInstanceResponse({ instanceId, method, request, caller }) {
19809
+ var _a, _b, _c;
19734
19810
  try {
19735
19811
  const response = await this.intentsResolverResponsePromises[instanceId].promise;
19736
- (_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}`);
19812
+ const subMessage = method === "raise" ? `for intent ${response.intent} ` : "";
19813
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intent handler chosen ${subMessage}: ${JSON.stringify(response.handler)}. Stopping resolver instance with id ${instanceId}`);
19737
19814
  this.stopResolverInstance(instanceId);
19738
19815
  (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Instance with id ${instanceId} successfully stopped`);
19816
+ if ((_c = response.userSettings) === null || _c === void 0 ? void 0 : _c.preserveChoice) {
19817
+ await this.saveUserChoice({
19818
+ intent: response.intent,
19819
+ handler: response.handler,
19820
+ filter: method === "filterHandlers"
19821
+ ? { applicationNames: request.applicationNames, contextTypes: request.contextTypes, resultType: request.resultType }
19822
+ : undefined,
19823
+ caller
19824
+ });
19825
+ }
19739
19826
  return response.handler;
19740
19827
  }
19741
19828
  catch (error) {
@@ -19743,14 +19830,14 @@ class Intents {
19743
19830
  throw new Error(error);
19744
19831
  }
19745
19832
  }
19746
- async registerIntentResolverMethod(method) {
19833
+ async registerIntentResolverMethod() {
19747
19834
  const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + Utils.generateId();
19748
- await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId, method));
19835
+ await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId));
19749
19836
  return methodName;
19750
19837
  }
19751
- resolverResponseHandler(args, callerId, method) {
19838
+ resolverResponseHandler(args, callerId) {
19752
19839
  const { instance } = callerId;
19753
- const isValid = validateIntentsResolverResponse(method, args);
19840
+ const isValid = validateResolverResponse(args);
19754
19841
  if (!isValid) {
19755
19842
  this.logger.trace(`Intent Resolver instance with id ${callerId.instance} sent invalid response. Error: ${isValid.error}`);
19756
19843
  this.intentsResolverResponsePromises[instance].reject(isValid.error);
@@ -19762,7 +19849,15 @@ class Intents {
19762
19849
  this.cleanUpIntentResolverPromise(instance);
19763
19850
  }
19764
19851
  buildStartContext(method, request, methodName) {
19765
- const baseStartContext = { callerId: this.interop.instance.instance, methodName };
19852
+ var _a;
19853
+ const myAppName = this.interop.instance.application || this.interop.instance.applicationName;
19854
+ const myAppTitle = ((_a = this.appManager.application(myAppName)) === null || _a === void 0 ? void 0 : _a.title) || "";
19855
+ const baseStartContext = {
19856
+ callerId: this.interop.instance.instance,
19857
+ methodName,
19858
+ initialCaller: { id: this.interop.instance.instance, applicationName: myAppName, applicationTitle: myAppTitle },
19859
+ resolverApi: "1.0"
19860
+ };
19766
19861
  return method === "raise"
19767
19862
  ? { ...baseStartContext, intent: request }
19768
19863
  : { ...baseStartContext, handlerFilter: request };
@@ -19950,6 +20045,64 @@ class Intents {
19950
20045
  }, []);
19951
20046
  return intentsWithInfo;
19952
20047
  }
20048
+ async removeRememberedHandler(intentName) {
20049
+ var _a;
20050
+ this.logger.trace(`Removing saved handler from prefs storage for intent ${intentName}`);
20051
+ const prefs = await this.prefsController.get();
20052
+ const intentPrefs = (_a = prefs.data) === null || _a === void 0 ? void 0 : _a.intents;
20053
+ if (!intentPrefs) {
20054
+ this.logger.trace("No app prefs found for current app");
20055
+ return;
20056
+ }
20057
+ delete intentPrefs[intentName];
20058
+ const updatedPrefs = {
20059
+ ...prefs.data,
20060
+ intents: intentPrefs
20061
+ };
20062
+ await this.prefsController.update(updatedPrefs);
20063
+ this.logger.trace(`Handler saved choice for intent ${intentName} removed successfully`);
20064
+ }
20065
+ async checkForRememberedHandler(intentRequest) {
20066
+ var _a, _b;
20067
+ const prefs = await this.prefsController.get();
20068
+ const prefsForIntent = (_b = (_a = prefs.data) === null || _a === void 0 ? void 0 : _a.intents) === null || _b === void 0 ? void 0 : _b[intentRequest.intent];
20069
+ return prefsForIntent === null || prefsForIntent === void 0 ? void 0 : prefsForIntent.handler;
20070
+ }
20071
+ async checkHandleRaiseWithRememberedHandler(intentRequest, resolverInstance, timeout) {
20072
+ const rememberedHandler = await this.checkForRememberedHandler(intentRequest);
20073
+ if (!rememberedHandler) {
20074
+ return;
20075
+ }
20076
+ const request = {
20077
+ ...intentRequest,
20078
+ target: {
20079
+ app: rememberedHandler.applicationName,
20080
+ instance: rememberedHandler.instanceId
20081
+ }
20082
+ };
20083
+ try {
20084
+ const response = await this.coreRaiseIntent({ request, resolverInstance, timeout });
20085
+ return response;
20086
+ }
20087
+ catch (error) {
20088
+ this.logger.trace("Could not raise intent to remembered handler. Removing it from Prefs store");
20089
+ await this.removeRememberedHandler(intentRequest.intent);
20090
+ }
20091
+ }
20092
+ async saveUserChoice({ intent, handler, filter, caller }) {
20093
+ var _a, _b;
20094
+ const prevPrefs = await this.prefsController.get(caller.applicationName);
20095
+ const prevIntentsPrefs = ((_a = prevPrefs === null || prevPrefs === void 0 ? void 0 : prevPrefs.data) === null || _a === void 0 ? void 0 : _a.intents) || {};
20096
+ const prefsToUpdate = {
20097
+ ...prevPrefs.data,
20098
+ intents: {
20099
+ ...prevIntentsPrefs,
20100
+ [intent]: { handler, filter }
20101
+ }
20102
+ };
20103
+ await this.prefsController.update(prefsToUpdate, { app: caller.applicationName });
20104
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.info(`Saved user's choice of handler for '${caller.applicationName}' app`);
20105
+ }
19953
20106
  }
19954
20107
 
19955
20108
  class FactoryCallInfo {
@@ -20196,6 +20349,7 @@ const factoryCore = async (options, glue42gd) => {
20196
20349
  let _windows;
20197
20350
  let _displays;
20198
20351
  let _channels;
20352
+ let _prefs;
20199
20353
  const _browserEventsDispatcher = new EventsDispatcher(glueConfig);
20200
20354
  function createWindows(core) {
20201
20355
  if (glueConfig.windows) {
@@ -20292,7 +20446,7 @@ const factoryCore = async (options, glue42gd) => {
20292
20446
  return hotkeysAPI;
20293
20447
  }
20294
20448
  function createIntents(core) {
20295
- const intentsAPI = new Intents(core.agm, _windows, core.logger.subLogger("intents"), options, _appManager);
20449
+ const intentsAPI = new Intents(core.agm, _windows, core.logger.subLogger("intents"), options, _prefs, _appManager);
20296
20450
  debugLog(intentsAPI);
20297
20451
  return intentsAPI;
20298
20452
  }
@@ -20320,9 +20474,9 @@ const factoryCore = async (options, glue42gd) => {
20320
20474
  function createPrefs(core) {
20321
20475
  var _a, _b;
20322
20476
  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;
20323
- const prefs = new Prefs(appName, core.interop);
20324
- debugLog(prefs);
20325
- return prefs;
20477
+ _prefs = new Prefs(appName, core.interop);
20478
+ debugLog(_prefs);
20479
+ return _prefs;
20326
20480
  }
20327
20481
  function createCookies(core) {
20328
20482
  const api = factory$1(core.interop, T42GDExecuteMethod);
@@ -20351,10 +20505,10 @@ const factoryCore = async (options, glue42gd) => {
20351
20505
  { name: "channels", create: createChannels },
20352
20506
  { name: "hotkeys", create: createHotkeys },
20353
20507
  { name: "displays", create: createDisplaysApi },
20508
+ { name: "prefs", create: createPrefs },
20354
20509
  { name: "intents", create: createIntents },
20355
20510
  { name: "notifications", create: createNotifications },
20356
20511
  { name: "themes", create: createThemes },
20357
- { name: "prefs", create: createPrefs },
20358
20512
  { name: "cookies", create: createCookies }
20359
20513
  ],
20360
20514
  version,