@interopio/desktop 6.16.2 → 6.17.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.
package/changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ 6.17.0
2
+ - feat: intents - add customConfig in intent's app definition
3
+ - fix: layouts - restore method timeout removed
4
+ - fix: channels - prevent callback replay after handler invocation
5
+ - chore: intents - validations for add intent listener method - register
6
+ - chore: increase the timeout for streams in io.CD from 30 to 90 seconds
7
+ 6.16.3
8
+ - chore: prefs: lastUpdate type to Date
1
9
  6.16.2
2
10
  - chore: apps: fix types and documentation
3
11
  6.16.1
@@ -5,7 +13,7 @@
5
13
  - fix: prefs - when calling `io.prefs.get()`, the returned object looks like an unparsed fetch response
6
14
  6.16.0
7
15
  - feat: layouts - restoreWorkspacesByReference option added
8
- - chore: increase the timeout for streams in io.CD from 30 to 90 seconds
16
+
9
17
  - chore: reconnect logic improvement
10
18
  6.15.0
11
19
  - fix: channels - creation inconsistency - G4E-9871
package/desktop.d.ts CHANGED
@@ -1018,7 +1018,7 @@ export declare namespace IOConnectDesktop {
1018
1018
  * Notifies when io.Connect will shut down or restart. If the callback is asynchronous, it will be awaited up to 60 seconds before shutdown continues.
1019
1019
  * @param callback Callback function for handling the event.
1020
1020
  */
1021
- onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): void;
1021
+ onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): UnsubscribeFunction;
1022
1022
  }
1023
1023
 
1024
1024
  /**
@@ -2506,7 +2506,7 @@ export declare namespace IOConnectDesktop {
2506
2506
  * before the platform shuts down or restarts. The available time for the execution of your code is 60 seconds.
2507
2507
  * To prevent the platform shutdown or restart, the callback must resolve with an object with a `prevent` property set to `true`.
2508
2508
  */
2509
- onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): () => void;
2509
+ onShuttingDown(callback: (args: ShuttingDownEventArgs) => Promise<{ prevent: boolean }>): UnsubscribeFunction;
2510
2510
  }
2511
2511
 
2512
2512
  /**
@@ -3322,12 +3322,6 @@ export declare namespace IOConnectDesktop {
3322
3322
  */
3323
3323
  context?: unknown;
3324
3324
 
3325
- /**
3326
- * Timeout in milliseconds for restoring the Layout.
3327
- * If the time limit is hit, all apps opened up to this point will be closed and an error will be thrown.
3328
- */
3329
- timeout?: number;
3330
-
3331
3325
  /**
3332
3326
  * Only if the type is `"Activity"`. If `true`, will try to reuse existing windows when restoring the Layout.
3333
3327
  * @default true
@@ -7936,6 +7930,12 @@ export declare namespace IOConnectDesktop {
7936
7930
  * The type of predefined data structure which the Intent handler returns.
7937
7931
  */
7938
7932
  resultType?: string;
7933
+
7934
+ /**
7935
+ * Object containing custom configuration for the Intent handler.
7936
+ * @since io.Connect Desktop 10.0.4
7937
+ */
7938
+ customConfig?: { [key: string]: any };
7939
7939
  }
7940
7940
 
7941
7941
  /**
@@ -8109,6 +8109,12 @@ export declare namespace IOConnectDesktop {
8109
8109
  * The type of predefined data structure which the Intent handler returns.
8110
8110
  */
8111
8111
  resultType?: string;
8112
+
8113
+ /**
8114
+ * Object containing custom configuration for the Intent handler provided via the app definition or dynamically.
8115
+ * @since io.Connect Desktop 10.0.4
8116
+ */
8117
+ customConfig?: { [key: string]: any };
8112
8118
  }
8113
8119
 
8114
8120
  /**
@@ -9013,7 +9019,7 @@ export declare namespace IOConnectDesktop {
9013
9019
  /**
9014
9020
  * Timestamp of the last update of the user preferences.
9015
9021
  */
9016
- lastUpdate?: string;
9022
+ lastUpdate?: Date;
9017
9023
  }
9018
9024
  }
9019
9025
 
@@ -13650,7 +13650,11 @@
13650
13650
  resolveFunc = resolve;
13651
13651
  rejectFunc = reject;
13652
13652
  });
13653
- agm.subscribe(OnEventMethodName, { arguments: { skipIcon: skipIcons }, waitTimeoutMs: 10000 })
13653
+ agm.subscribe(OnEventMethodName, {
13654
+ arguments: { skipIcon: skipIcons },
13655
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
13656
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS
13657
+ })
13654
13658
  .then((s) => {
13655
13659
  subscription = s;
13656
13660
  subscription.onData((streamData) => {
@@ -16877,6 +16881,8 @@
16877
16881
  arguments: {
16878
16882
  withConfig: true
16879
16883
  },
16884
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
16885
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS,
16880
16886
  onData: (streamData) => {
16881
16887
  if (streamData.data.type === "Configuration") {
16882
16888
  this._configuration = streamData.data;
@@ -18447,9 +18453,6 @@
18447
18453
  if (!isUndefinedOrNull(options.context) && !isObject(options.context)) {
18448
18454
  return reject(new Error("`context` must hold an object value."));
18449
18455
  }
18450
- if (!isUndefinedOrNull(options.timeout) && typeof options.timeout !== "number") {
18451
- return reject(new Error("`timeout` must hold an number value."));
18452
- }
18453
18456
  options.context = (_c = options.context) !== null && _c !== void 0 ? _c : {};
18454
18457
  const restoreOptions = {
18455
18458
  activityToJoin: options.activityIdToJoin,
@@ -18464,11 +18467,9 @@
18464
18467
  type: options.type,
18465
18468
  name: options.name,
18466
18469
  context: options.context,
18467
- options: restoreOptions
18470
+ options: restoreOptions,
18471
+ timeout: INTEROP_METHOD_MAX_TIMEOUT_MS
18468
18472
  };
18469
- if (options.timeout) {
18470
- arg.timeout = options.timeout;
18471
- }
18472
18473
  this.invokeMethodAndTrack("RestoreLayout", arg, resolve, reject, true);
18473
18474
  });
18474
18475
  }
@@ -18602,6 +18603,7 @@
18602
18603
  const request = {
18603
18604
  name,
18604
18605
  type: "Global",
18606
+ timeout: INTEROP_METHOD_MAX_TIMEOUT_MS,
18605
18607
  context,
18606
18608
  ...options
18607
18609
  };
@@ -18750,7 +18752,7 @@
18750
18752
  const err = Utils.typedError(error);
18751
18753
  reject(err);
18752
18754
  };
18753
- const methodResponseTimeoutMs = 120 * 1000;
18755
+ const methodResponseTimeoutMs = ("timeout" in args && typeof args.timeout === "number") ? args.timeout : 120 * 1000;
18754
18756
  if (!skipStreamEvent) {
18755
18757
  this.stream.waitFor(token, methodResponseTimeoutMs)
18756
18758
  .then(() => {
@@ -18839,7 +18841,7 @@
18839
18841
  }
18840
18842
  else {
18841
18843
  this.logger.trace(`subscribing to "${this.StreamName}" stream`);
18842
- this.agm.subscribe(this.StreamName, { waitTimeoutMs: 10000 })
18844
+ this.agm.subscribe(this.StreamName, { waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS, methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS })
18843
18845
  .then((subs) => {
18844
18846
  this.logger.trace(`subscribed to "${this.StreamName}" stream`);
18845
18847
  subs.onData((args) => {
@@ -19520,12 +19522,17 @@
19520
19522
  validateFdc3Options(options);
19521
19523
  }
19522
19524
  const id = Utils.generateId();
19525
+ let handlerInvoked = false;
19526
+ const markHandlerInvoked = () => { handlerInvoked = true; };
19523
19527
  const wrappedCallback = (options === null || options === void 0 ? void 0 : options.contextType)
19524
- ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType)
19525
- : this.getWrappedSubscribeCallback(callback, id);
19528
+ ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType, markHandlerInvoked)
19529
+ : this.getWrappedSubscribeCallback(callback, id, markHandlerInvoked);
19526
19530
  let timeoutIndex;
19527
19531
  if (this.lastUpdate) {
19528
19532
  timeoutIndex = setTimeout(() => {
19533
+ if (handlerInvoked) {
19534
+ return;
19535
+ }
19529
19536
  wrappedCallback(this.lastUpdate.context.data, this.lastUpdate.context, {}, this.lastUpdate.updaterId);
19530
19537
  }, 0);
19531
19538
  }
@@ -19547,9 +19554,10 @@
19547
19554
  validateFdc3Options(options);
19548
19555
  }
19549
19556
  const id = Utils.generateId();
19557
+ const markHandlerInvoked = () => { };
19550
19558
  const wrappedCallback = (options === null || options === void 0 ? void 0 : options.contextType)
19551
- ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType)
19552
- : this.getWrappedSubscribeCallback(callback, id);
19559
+ ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType, markHandlerInvoked)
19560
+ : this.getWrappedSubscribeCallback(callback, id, markHandlerInvoked);
19553
19561
  const unsub = await this.shared.subscribeFor(name, wrappedCallback);
19554
19562
  return () => {
19555
19563
  this.pendingRestrictionCallbacks.delete(id);
@@ -20085,8 +20093,9 @@
20085
20093
  const fdc3DataToPublish = { [`fdc3_${parsedType}`]: rest };
20086
20094
  return this.shared.updateData(channelName, fdc3DataToPublish);
20087
20095
  }
20088
- getWrappedSubscribeCallback(callback, id) {
20096
+ getWrappedSubscribeCallback(callback, id, markHandlerInvoked) {
20089
20097
  const wrappedCallback = async (_, context, delta, updaterId) => {
20098
+ markHandlerInvoked();
20090
20099
  const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
20091
20100
  const channelData = this.getDataWithFdc3Encoding(context, delta);
20092
20101
  if (restrictionByChannel.read) {
@@ -20097,9 +20106,10 @@
20097
20106
  };
20098
20107
  return wrappedCallback;
20099
20108
  }
20100
- getWrappedSubscribeCallbackWithFdc3Type(callback, id, fdc3Type) {
20109
+ getWrappedSubscribeCallbackWithFdc3Type(callback, id, fdc3Type, markHandlerInvoked) {
20101
20110
  const didReplay = { replayed: false };
20102
20111
  const wrappedCallback = async (_, context, delta, updaterId) => {
20112
+ markHandlerInvoked();
20103
20113
  const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
20104
20114
  const callbackWithTypesChecks = () => {
20105
20115
  const { data, latest_fdc3_type } = context;
@@ -20457,7 +20467,7 @@
20457
20467
  }
20458
20468
  }
20459
20469
 
20460
- var version = "6.16.2";
20470
+ var version = "6.17.0";
20461
20471
 
20462
20472
  var prepareConfig = (options) => {
20463
20473
  function getLibConfig(value, defaultMode, trueMode) {
@@ -21076,7 +21086,9 @@
21076
21086
  arguments: {
21077
21087
  sendDeltaOnly: true,
21078
21088
  statesVersion2: true
21079
- }
21089
+ },
21090
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
21091
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS
21080
21092
  })
21081
21093
  .then((sub) => {
21082
21094
  this.subscriptionForNotifications = sub;
@@ -21108,7 +21120,9 @@
21108
21120
  .subscribe(this.NotificationsCounterStream, {
21109
21121
  arguments: {
21110
21122
  sendDeltaOnly: true
21111
- }
21123
+ },
21124
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
21125
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS
21112
21126
  })
21113
21127
  .then((sub) => {
21114
21128
  this.subscriptionForCounter = sub;
@@ -22860,6 +22874,32 @@
22860
22874
  }
22861
22875
  });
22862
22876
  };
22877
+ const validateAddIntentListenerRequest = (request) => {
22878
+ if ((typeof request !== "string" && typeof request !== "object") || (typeof request === "object" && typeof request.intent !== "string")) {
22879
+ throw new Error("Please provide the intent as a string or an object with an intent property!");
22880
+ }
22881
+ if (typeof request === "string") {
22882
+ return;
22883
+ }
22884
+ if (typeof request.contextTypes !== "undefined" && (!Array.isArray(request.contextTypes) || request.contextTypes.some(ctx => typeof ctx !== "string"))) {
22885
+ throw new Error("Please provide the 'contextTypes' as an array of strings!");
22886
+ }
22887
+ if (typeof request.resultType !== "undefined" && typeof request.resultType !== "string") {
22888
+ throw new Error("Please provide the 'resultType' as a string!");
22889
+ }
22890
+ if (typeof request.displayName !== "undefined" && typeof request.displayName !== "string") {
22891
+ throw new Error("Please provide the 'displayName' as a string!");
22892
+ }
22893
+ if (typeof request.icon !== "undefined" && typeof request.icon !== "string") {
22894
+ throw new Error("Please provide the 'icon' as a string!");
22895
+ }
22896
+ if (typeof request.description !== "undefined" && typeof request.description !== "string") {
22897
+ throw new Error("Please provide the 'description' as a string!");
22898
+ }
22899
+ if (typeof request.customConfig !== "undefined" && (typeof request.customConfig !== "object" || Array.isArray(request.customConfig))) {
22900
+ throw new Error("Please provide the 'customConfig' as an object!");
22901
+ }
22902
+ };
22863
22903
 
22864
22904
  class Intents {
22865
22905
  constructor(interop, windows, logger, options, prefsController, appsController) {
@@ -22964,7 +23004,8 @@
22964
23004
  contextTypes: intentDef.contexts,
22965
23005
  applicationIcon: app.icon,
22966
23006
  type: "app",
22967
- resultType: intentDef.resultType
23007
+ resultType: intentDef.resultType,
23008
+ customConfig: intentDef === null || intentDef === void 0 ? void 0 : intentDef.customConfig,
22968
23009
  };
22969
23010
  intent.handlers.push(handler);
22970
23011
  }
@@ -23045,9 +23086,7 @@
23045
23086
  return result;
23046
23087
  }
23047
23088
  async register(intent, handler) {
23048
- if ((typeof intent !== "string" && typeof intent !== "object") || (typeof intent === "object" && typeof intent.intent !== "string")) {
23049
- throw new Error("Please provide the intent as a string or an object with an intent property!");
23050
- }
23089
+ validateAddIntentListenerRequest(intent);
23051
23090
  if (typeof handler !== "function") {
23052
23091
  throw new Error("Please provide the handler as a function!");
23053
23092
  }
@@ -23750,7 +23789,8 @@
23750
23789
  contextTypes: info.contextTypes || (appIntent === null || appIntent === void 0 ? void 0 : appIntent.contexts),
23751
23790
  instanceTitle: title,
23752
23791
  type: "instance",
23753
- resultType: (appIntent === null || appIntent === void 0 ? void 0 : appIntent.resultType) || info.resultType
23792
+ resultType: (appIntent === null || appIntent === void 0 ? void 0 : appIntent.resultType) || info.resultType,
23793
+ customConfig: info === null || info === void 0 ? void 0 : info.customConfig
23754
23794
  };
23755
23795
  return handler;
23756
23796
  }
@@ -23763,7 +23803,8 @@
23763
23803
  contextTypes: intent.contexts,
23764
23804
  applicationIcon: app.icon,
23765
23805
  type: "app",
23766
- resultType: intent.resultType
23806
+ resultType: intent.resultType,
23807
+ customConfig: intent === null || intent === void 0 ? void 0 : intent.customConfig
23767
23808
  };
23768
23809
  }
23769
23810
  }