@interopio/desktop 6.6.1-next.0 → 6.6.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/desktop.d.ts CHANGED
@@ -6059,9 +6059,9 @@ export declare namespace IOConnectDesktop {
6059
6059
  /**
6060
6060
  * Updates the context of the current or a specified Channel.
6061
6061
  * @param data Data object with which to update the Channel context.
6062
- * @param options The name of the Channel to update, or an object containing the name of the Channel to update and a flag indicating whether the published data is an FDC3 context. If no options are provided, the current Channel will be updated.
6062
+ * @param name The name of the Channel to update. If not provided, will update the current Channel.
6063
6063
  */
6064
- publish(data: any, options?: string | PublishOptions): Promise<void>;
6064
+ publish(data: any, name?: string): Promise<void>;
6065
6065
 
6066
6066
  /**
6067
6067
  * Sets a specified path within the Channel context to the provided value. If the path doesn't exist, it will be created.
@@ -6240,21 +6240,6 @@ export declare namespace IOConnectDesktop {
6240
6240
  data: any;
6241
6241
  }
6242
6242
 
6243
- /**
6244
- * Options for updating a Channel context with the `publish()` method.
6245
- */
6246
- export interface PublishOptions {
6247
- /**
6248
- * The name of the Channel to update. If not provided, the current Channel will be updated.
6249
- */
6250
- name?: string;
6251
-
6252
- /**
6253
- * Flag indicating whether the published data is an FDC3 context. If so, it must contain a required `type` property.
6254
- */
6255
- fdc3?: boolean;
6256
- }
6257
-
6258
6243
  /**
6259
6244
  * All restrictions applied to a window for publishing or subscribing to Channels.
6260
6245
  */
@@ -6419,11 +6404,6 @@ export declare namespace IOConnectDesktop {
6419
6404
  */
6420
6405
  getIntents(handler: IntentHandler): Promise<GetIntentsResult>;
6421
6406
 
6422
- /**
6423
- * Removes all saved Intent handlers for previously raised Intents.
6424
- */
6425
- clearSavedHandlers(): Promise<void>;
6426
-
6427
6407
  /**
6428
6408
  * API for controlling the Intents Resolver UI app.
6429
6409
  */
@@ -6476,11 +6456,6 @@ export declare namespace IOConnectDesktop {
6476
6456
  */
6477
6457
  handlerFilter?: HandlerFilter;
6478
6458
 
6479
- /**
6480
- * Details about the app instance that opened the Intents Resolver UI.
6481
- */
6482
- caller?: ResolverCaller;
6483
-
6484
6459
  /**
6485
6460
  * Retrieves the title for the search operation. Available only if the `filterHandlers()` method was used to open the Intents Resolver UI and the `title` property of the `HandlerFilter` object was set.
6486
6461
  */
@@ -6501,40 +6476,7 @@ export declare namespace IOConnectDesktop {
6501
6476
  /**
6502
6477
  * Sends the chosen Intent handler to the app which raised the Intent.
6503
6478
  */
6504
- sendResponse(handler: ResolverIntentHandler, options?: SendResolverResponseOptions): Promise<IOConnectDesktop.Interop.InvocationResult | undefined>;
6505
- }
6506
-
6507
- /**
6508
- * Describes the app instance that opened the Intents Resolver UI.
6509
- */
6510
- export interface ResolverCaller {
6511
- /**
6512
- * ID of the Interop instance of the app that opened the Intents Resolver UI.
6513
- */
6514
- id: string;
6515
- /**
6516
- * Name of the app that opened the Intents Resolver UI.
6517
- */
6518
- applicationName?: string;
6519
- /**
6520
- * Title of the app that opened the Intents Resolver UI.
6521
- */
6522
- applicationTitle?: string;
6523
- }
6524
-
6525
- /**
6526
- * Options for sending the chosen Intent handler to the app that raised the Intent.
6527
- */
6528
- export interface SendResolverResponseOptions {
6529
- /**
6530
- * If `true`, the chosen Intent handler will be saved as a handler for the raised Intent. If the handler is saved, the next time the same Intent is raised, the Intents Resolver UI won't open and the saved handler will be used automatically.
6531
- * @default false
6532
- */
6533
- saveHandler: boolean;
6534
- /**
6535
- * Use this property to supply the name of the Intent when the Intents Resolver UI is opened via the `filterHandlers()` method and you want to save the Intent handler for that Intent. If the Intents Resolver UI is opened via the `raise()` method, it isn't necessary to explicitly provide the Intent name here, as specifying an Intent name is mandatory when using the `raise()` method.
6536
- */
6537
- intent?: string;
6479
+ sendResponse(handler: ResolverIntentHandler): Promise<IOConnectDesktop.Interop.InvocationResult | undefined>;
6538
6480
  }
6539
6481
 
6540
6482
  /**
@@ -6546,11 +6488,6 @@ export declare namespace IOConnectDesktop {
6546
6488
  */
6547
6489
  applicationName: string;
6548
6490
 
6549
- /**
6550
- * Title of the Intent handler.
6551
- */
6552
- applicationTitle?: string;
6553
-
6554
6491
  /**
6555
6492
  * Icon of the Intent handler app.
6556
6493
  */
@@ -6786,12 +6723,6 @@ export declare namespace IOConnectDesktop {
6786
6723
  * @default false
6787
6724
  */
6788
6725
  readonly waitUserResponseIndefinitely?: boolean;
6789
-
6790
- /**
6791
- * If `true`, the previously saved Intent handler for this Intent (if any) will be cleared.
6792
- * @default false
6793
- */
6794
- readonly clearSavedHandler?: boolean;
6795
6726
  }
6796
6727
 
6797
6728
  /**
@@ -2933,7 +2933,7 @@
2933
2933
  }
2934
2934
  };
2935
2935
 
2936
- var version$1 = "6.3.5-next.0";
2936
+ var version$1 = "6.3.5";
2937
2937
 
2938
2938
  function prepareConfig$1 (configuration, ext, glue42gd) {
2939
2939
  let nodeStartingContext;
@@ -17573,9 +17573,6 @@
17573
17573
  channels.handleRestrictionsChanged(restrictions, targetWindowId);
17574
17574
  return;
17575
17575
  }
17576
- if (command === "isFdc3DataWrappingSupported") {
17577
- return { isSupported: true };
17578
- }
17579
17576
  throw new Error(`unknown command ${command}`);
17580
17577
  });
17581
17578
  const result = await interop.invoke("T42.Channels.Announce", { swId: windowId, instance: interop.instance.instance });
@@ -17674,7 +17671,8 @@
17674
17671
  const contextName = this.createContextName(name);
17675
17672
  const contextData = await this.contexts.get(contextName);
17676
17673
  if (contextData[LATEST_FDC3_TYPE]) {
17677
- return this.getContextWithFdc3Data(contextData);
17674
+ const { latest_fdc3_type, ...data } = contextData;
17675
+ return data;
17678
17676
  }
17679
17677
  return contextData;
17680
17678
  }
@@ -17753,21 +17751,6 @@
17753
17751
  }
17754
17752
  return fdc3PropsArr[0].split("_").slice(1).join("_");
17755
17753
  }
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
- }
17771
17754
  }
17772
17755
 
17773
17756
  class ChannelsImpl {
@@ -17797,7 +17780,17 @@
17797
17780
  }
17798
17781
  const id = Utils.generateId();
17799
17782
  this.pendingReplays[id] = true;
17800
- const wrappedCallback = this.getWrappedSubscribeCallback(callback, id);
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
+ };
17801
17794
  if (this.lastUpdate) {
17802
17795
  let lastUpdate = Object.assign({}, this.lastUpdate);
17803
17796
  setTimeout(async () => {
@@ -17805,12 +17798,12 @@
17805
17798
  if (this.lastUpdate) {
17806
17799
  lastUpdate = this.lastUpdate;
17807
17800
  }
17808
- wrappedCallback(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
17801
+ callbackWithPermissionCheck(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
17809
17802
  }
17810
17803
  delete this.pendingReplays[id];
17811
17804
  }, 0);
17812
17805
  }
17813
- const unsub = this.registry.add(this.subsKey, wrappedCallback);
17806
+ const unsub = this.registry.add(this.subsKey, callbackWithPermissionCheck);
17814
17807
  return () => {
17815
17808
  this.pendingReplays[id] = false;
17816
17809
  this.pendingRestrictionCallbacks.delete(id);
@@ -17825,35 +17818,46 @@
17825
17818
  throw new Error("Please provide the callback as a function!");
17826
17819
  }
17827
17820
  const id = Utils.generateId();
17828
- const wrappedCallback = this.getWrappedSubscribeCallback(callback, id);
17829
- const unsub = await this.shared.subscribeFor(name, wrappedCallback);
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);
17830
17833
  return () => {
17831
17834
  this.pendingRestrictionCallbacks.delete(id);
17832
17835
  unsub();
17833
17836
  };
17834
17837
  }
17835
- async publish(data, options) {
17838
+ async publish(data, name) {
17836
17839
  if (typeof data !== "object") {
17837
17840
  throw new Error("Please provide the data as an object!");
17838
17841
  }
17839
- if (options) {
17840
- this.validatePublishOptions(options);
17841
- }
17842
- if (typeof options === "object") {
17843
- return this.publishWithOptions(data, options);
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);
17844
17853
  }
17845
- const channelName = typeof options === "string" ? options : this.currentContext;
17846
- if (!channelName) {
17854
+ if (!this.currentContext) {
17847
17855
  throw new Error("Not joined to any channel!");
17848
17856
  }
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) {
17857
+ if (!(await this.getRestrictionsByChannel(this.currentContext)).write) {
17854
17858
  throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
17855
17859
  }
17856
- return this.shared.updateData(channelName, data);
17860
+ return this.shared.updateData(this.currentContext, data);
17857
17861
  }
17858
17862
  async setPaths(paths, name) {
17859
17863
  if (name) {
@@ -18157,82 +18161,6 @@
18157
18161
  throw new Error(`path property is not a valid string from the Path Value argument: ${JSON.stringify(path)}`);
18158
18162
  }
18159
18163
  }
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
- }
18236
18164
  }
18237
18165
 
18238
18166
  function factory$4(contexts, agm, getWindows, logger) {
@@ -19264,6 +19192,28 @@
19264
19192
  }
19265
19193
  return { isValid: true, ok: handler };
19266
19194
  };
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
+ };
19267
19217
  const validateIntentRequestTarget = (target) => {
19268
19218
  if (!target) {
19269
19219
  return;
@@ -19350,27 +19300,14 @@
19350
19300
  throw new Error(errorMsg);
19351
19301
  }
19352
19302
  };
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 };
19303
+ const validateIntentsResolverResponse = (method, responseObj) => {
19304
+ return method === "raise" ? validateRaiseIntentsResolverResponse(responseObj) : validateFilterHandlersResolverResponse(responseObj);
19365
19305
  };
19366
19306
  const validateIntentRequest = (request) => {
19367
19307
  validateIntentRequestContext(request.context);
19368
19308
  validateIntentRequestTarget(request.target);
19369
19309
  validateIntentRequestTimeout(request.timeout);
19370
19310
  validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
19371
- if (typeof request.clearSavedHandler !== "undefined" && typeof request.clearSavedHandler !== "boolean") {
19372
- throw new Error("Please provide 'clearSavedHandler' as a boolean");
19373
- }
19374
19311
  if (request.handlers) {
19375
19312
  request.handlers.forEach((handler) => validateIntentRequestHandler(handler));
19376
19313
  }
@@ -19419,11 +19356,10 @@
19419
19356
  };
19420
19357
 
19421
19358
  class Intents {
19422
- constructor(interop, windows, logger, options, prefsController, appManager) {
19359
+ constructor(interop, windows, logger, options, appManager) {
19423
19360
  this.interop = interop;
19424
19361
  this.windows = windows;
19425
19362
  this.logger = logger;
19426
- this.prefsController = prefsController;
19427
19363
  this.appManager = appManager;
19428
19364
  this.myIntents = new Set();
19429
19365
  this.intentsResolverResponsePromises = {};
@@ -19465,16 +19401,8 @@
19465
19401
  }
19466
19402
  validateIntentRequest(intentRequest);
19467
19403
  await Promise.all(this.unregisterIntentPromises);
19468
- if (intentRequest.clearSavedHandler) {
19469
- this.logger.trace(`User removes saved handler for intent ${intentRequest.intent}`);
19470
- await this.removeRememberedHandler(intentRequest.intent);
19471
- }
19472
- const resolverInstance = {};
19473
19404
  const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
19474
- const resultFromRememberedHandler = await this.checkHandleRaiseWithRememberedHandler(intentRequest, resolverInstance, timeout);
19475
- if (resultFromRememberedHandler) {
19476
- return resultFromRememberedHandler;
19477
- }
19405
+ const resolverInstance = {};
19478
19406
  const coreRaiseIntentFn = this.coreRaiseIntent.bind(this, { request: intentRequest, resolverInstance, timeout });
19479
19407
  if (intentRequest.waitUserResponseIndefinitely) {
19480
19408
  return coreRaiseIntentFn();
@@ -19675,10 +19603,6 @@
19675
19603
  this.logger.trace(`Returning intents for handler ${JSON.stringify(handler)}`);
19676
19604
  return { intents: intentsWithInfo };
19677
19605
  }
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
- }
19682
19606
  filterHandlersBy(intents, filter) {
19683
19607
  const filteredIntentsWithHandlers = intents.filter((intent) => {
19684
19608
  if (filter.intent && filter.intent !== intent.name) {
@@ -19780,7 +19704,7 @@
19780
19704
  async startResolverApp({ request, method, resolverInstance }) {
19781
19705
  var _a, _b, _c, _d;
19782
19706
  (_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)}`);
19783
- const responseMethodName = await this.registerIntentResolverMethod();
19707
+ const responseMethodName = await this.registerIntentResolverMethod(method);
19784
19708
  (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Registered interop method ${responseMethodName}`);
19785
19709
  const startContext = this.buildStartContext(method, request, responseMethodName);
19786
19710
  const startOptions = await this.buildStartOptions();
@@ -19799,7 +19723,7 @@
19799
19723
  ? `for intent ${request.intent}`
19800
19724
  : `for '${method}' method with filter ${JSON.stringify(request)}`}`
19801
19725
  });
19802
- const handler = await this.handleInstanceResponse({ instanceId: instance.id, caller: startContext.initialCaller, method, request });
19726
+ const handler = await this.handleInstanceResponse(instance.id, method);
19803
19727
  return handler;
19804
19728
  }
19805
19729
  async windowsIdToTitle(id, windowsInfos) {
@@ -19811,23 +19735,13 @@
19811
19735
  const title = await (window === null || window === void 0 ? void 0 : window.getTitle());
19812
19736
  return title;
19813
19737
  }
19814
- async handleInstanceResponse({ instanceId, method, request, caller }) {
19815
- var _a, _b, _c;
19738
+ async handleInstanceResponse(instanceId, method) {
19739
+ var _a, _b;
19816
19740
  try {
19817
19741
  const response = await this.intentsResolverResponsePromises[instanceId].promise;
19818
19742
  (_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}`);
19819
19743
  this.stopResolverInstance(instanceId);
19820
19744
  (_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
- }
19831
19745
  return response.handler;
19832
19746
  }
19833
19747
  catch (error) {
@@ -19835,14 +19749,14 @@
19835
19749
  throw new Error(error);
19836
19750
  }
19837
19751
  }
19838
- async registerIntentResolverMethod() {
19752
+ async registerIntentResolverMethod(method) {
19839
19753
  const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + Utils.generateId();
19840
- await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId));
19754
+ await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId, method));
19841
19755
  return methodName;
19842
19756
  }
19843
- resolverResponseHandler(args, callerId) {
19757
+ resolverResponseHandler(args, callerId, method) {
19844
19758
  const { instance } = callerId;
19845
- const isValid = validateResolverResponse(args);
19759
+ const isValid = validateIntentsResolverResponse(method, args);
19846
19760
  if (!isValid) {
19847
19761
  this.logger.trace(`Intent Resolver instance with id ${callerId.instance} sent invalid response. Error: ${isValid.error}`);
19848
19762
  this.intentsResolverResponsePromises[instance].reject(isValid.error);
@@ -19854,15 +19768,7 @@
19854
19768
  this.cleanUpIntentResolverPromise(instance);
19855
19769
  }
19856
19770
  buildStartContext(method, request, 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
- };
19771
+ const baseStartContext = { callerId: this.interop.instance.instance, methodName };
19866
19772
  return method === "raise"
19867
19773
  ? { ...baseStartContext, intent: request }
19868
19774
  : { ...baseStartContext, handlerFilter: request };
@@ -20050,64 +19956,6 @@
20050
19956
  }, []);
20051
19957
  return intentsWithInfo;
20052
19958
  }
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
- }
20111
19959
  }
20112
19960
 
20113
19961
  class FactoryCallInfo {
@@ -20354,7 +20202,6 @@
20354
20202
  let _windows;
20355
20203
  let _displays;
20356
20204
  let _channels;
20357
- let _prefs;
20358
20205
  const _browserEventsDispatcher = new EventsDispatcher(glueConfig);
20359
20206
  function createWindows(core) {
20360
20207
  if (glueConfig.windows) {
@@ -20451,7 +20298,7 @@
20451
20298
  return hotkeysAPI;
20452
20299
  }
20453
20300
  function createIntents(core) {
20454
- const intentsAPI = new Intents(core.agm, _windows, core.logger.subLogger("intents"), options, _prefs, _appManager);
20301
+ const intentsAPI = new Intents(core.agm, _windows, core.logger.subLogger("intents"), options, _appManager);
20455
20302
  debugLog(intentsAPI);
20456
20303
  return intentsAPI;
20457
20304
  }
@@ -20479,9 +20326,9 @@
20479
20326
  function createPrefs(core) {
20480
20327
  var _a, _b;
20481
20328
  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;
20482
- _prefs = new Prefs(appName, core.interop);
20483
- debugLog(_prefs);
20484
- return _prefs;
20329
+ const prefs = new Prefs(appName, core.interop);
20330
+ debugLog(prefs);
20331
+ return prefs;
20485
20332
  }
20486
20333
  function createCookies(core) {
20487
20334
  const api = factory$1(core.interop, T42GDExecuteMethod);
@@ -20510,10 +20357,10 @@
20510
20357
  { name: "channels", create: createChannels },
20511
20358
  { name: "hotkeys", create: createHotkeys },
20512
20359
  { name: "displays", create: createDisplaysApi },
20513
- { name: "prefs", create: createPrefs },
20514
20360
  { name: "intents", create: createIntents },
20515
20361
  { name: "notifications", create: createNotifications },
20516
20362
  { name: "themes", create: createThemes },
20363
+ { name: "prefs", create: createPrefs },
20517
20364
  { name: "cookies", create: createCookies }
20518
20365
  ],
20519
20366
  version,