@interopio/desktop 6.16.3 → 6.18.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.
@@ -1224,6 +1224,13 @@
1224
1224
  }
1225
1225
  seen.add(value);
1226
1226
  }
1227
+ if (value instanceof Error) {
1228
+ return {
1229
+ message: value.message,
1230
+ name: value.name,
1231
+ stack: value.stack
1232
+ };
1233
+ }
1227
1234
  return value;
1228
1235
  };
1229
1236
  reason = JSON.stringify(err, replacer);
@@ -1468,6 +1475,7 @@
1468
1475
  this.notifyStatusChanged(true);
1469
1476
  }
1470
1477
  close() {
1478
+ this.logger.debug(`closing connection - clientId: ${this.myClientId}, windowId: ${this.identity?.windowId || "unknown"}, client connected: ${this.iAmConnected}`);
1471
1479
  const message = {
1472
1480
  glue42core: {
1473
1481
  type: this.messages.gatewayDisconnect.name,
@@ -1540,7 +1548,7 @@
1540
1548
  selfAssignedWindowId: this.selfAssignedWindowId
1541
1549
  }
1542
1550
  };
1543
- this.logger.debug("sending connection request");
1551
+ this.logger.debug(`sending connection request - clientId: ${this.myClientId}`);
1544
1552
  if (this.extContentConnecting) {
1545
1553
  request.glue42core.clientType = "child";
1546
1554
  request.glue42core.bridgeInstanceId = this.myClientId;
@@ -1567,6 +1575,7 @@
1567
1575
  this.logger.debug("skipping generic message listener, because this is an internal client");
1568
1576
  return;
1569
1577
  }
1578
+ this.logger.debug("setting up window message listener");
1570
1579
  window.addEventListener("message", (event) => {
1571
1580
  const data = event.data?.glue42core;
1572
1581
  if (!data || this.rejected) {
@@ -1591,6 +1600,7 @@
1591
1600
  this.logger.debug("skipping unload event listener, because this is an internal client");
1592
1601
  return;
1593
1602
  }
1603
+ this.logger.debug("setting up unload event listeners");
1594
1604
  window.addEventListener("beforeunload", () => {
1595
1605
  if (this._connectionProtocolVersion) {
1596
1606
  return;
@@ -1608,6 +1618,7 @@
1608
1618
  if (this.extContentConnected) {
1609
1619
  return;
1610
1620
  }
1621
+ this.logger.debug(`signaling client disappearing for clientId: ${this.myClientId}`);
1611
1622
  const message = {
1612
1623
  glue42core: {
1613
1624
  type: this.messages.clientUnload.name,
@@ -1742,6 +1753,7 @@
1742
1753
  source.postMessage(message, event.origin);
1743
1754
  }
1744
1755
  setupPlatformUnloadListener() {
1756
+ this.logger.debug("setting up platform unload listener");
1745
1757
  this.onMessage((msg) => {
1746
1758
  if (msg.type === "platformUnload") {
1747
1759
  this.logger.debug("detected a web platform unload");
@@ -1751,6 +1763,7 @@
1751
1763
  });
1752
1764
  }
1753
1765
  handleManualUnload() {
1766
+ this.logger.debug("handling manual unload");
1754
1767
  const message = {
1755
1768
  glue42core: {
1756
1769
  type: this.messages.clientUnload.name,
@@ -1769,6 +1782,7 @@
1769
1782
  return;
1770
1783
  }
1771
1784
  notifyStatusChanged(status, reason) {
1785
+ this.logger.debug(`status changed - connected: ${status}, reason: ${reason || "none"}`);
1772
1786
  this.iAmConnected = status;
1773
1787
  this.registry.execute("onConnectedChanged", status, reason);
1774
1788
  }
@@ -2738,7 +2752,7 @@
2738
2752
  return authentication;
2739
2753
  }
2740
2754
  async logoutCore() {
2741
- this.logger.debug("logging out...");
2755
+ this.logger.debug("core logging out...");
2742
2756
  this.shouldTryLogin = false;
2743
2757
  if (this.pingTimer) {
2744
2758
  clearTimeout(this.pingTimer);
@@ -2969,7 +2983,7 @@
2969
2983
  }
2970
2984
  };
2971
2985
 
2972
- var version$1 = "6.7.3";
2986
+ var version$1 = "6.8.1";
2973
2987
 
2974
2988
  function prepareConfig$1 (configuration, ext, glue42gd) {
2975
2989
  let nodeStartingContext;
@@ -6752,7 +6766,6 @@
6752
6766
  };
6753
6767
  const nonEmptyStringDecoder$1 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
6754
6768
  const nonNegativeNumberDecoder$1 = number$1().where((num) => num >= 0, "Expected a non-negative number or 0");
6755
- const positiveNumberDecoder = number$1().where((num) => num > 0, "Expected a positive number");
6756
6769
  const methodDefinitionDecoder = object$1({
6757
6770
  name: nonEmptyStringDecoder$1,
6758
6771
  objectTypes: optional$1(array$1(nonEmptyStringDecoder$1)),
@@ -6785,8 +6798,8 @@
6785
6798
  });
6786
6799
  const targetDecoder = union(constant$1("best"), constant$1("all"), constant$1("skipMine"), instanceDecoder, array$1(instanceDecoder));
6787
6800
  const invokeOptionsDecoder = object$1({
6788
- waitTimeoutMs: optional$1(positiveNumberDecoder),
6789
- methodResponseTimeoutMs: optional$1(positiveNumberDecoder)
6801
+ waitTimeoutMs: optional$1(nonNegativeNumberDecoder$1),
6802
+ methodResponseTimeoutMs: optional$1(nonNegativeNumberDecoder$1)
6790
6803
  });
6791
6804
 
6792
6805
  var InvokeStatus;
@@ -13650,7 +13663,11 @@
13650
13663
  resolveFunc = resolve;
13651
13664
  rejectFunc = reject;
13652
13665
  });
13653
- agm.subscribe(OnEventMethodName, { arguments: { skipIcon: skipIcons }, waitTimeoutMs: 10000 })
13666
+ agm.subscribe(OnEventMethodName, {
13667
+ arguments: { skipIcon: skipIcons },
13668
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
13669
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS
13670
+ })
13654
13671
  .then((s) => {
13655
13672
  subscription = s;
13656
13673
  subscription.onData((streamData) => {
@@ -16877,6 +16894,8 @@
16877
16894
  arguments: {
16878
16895
  withConfig: true
16879
16896
  },
16897
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
16898
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS,
16880
16899
  onData: (streamData) => {
16881
16900
  if (streamData.data.type === "Configuration") {
16882
16901
  this._configuration = streamData.data;
@@ -18447,9 +18466,6 @@
18447
18466
  if (!isUndefinedOrNull(options.context) && !isObject(options.context)) {
18448
18467
  return reject(new Error("`context` must hold an object value."));
18449
18468
  }
18450
- if (!isUndefinedOrNull(options.timeout) && typeof options.timeout !== "number") {
18451
- return reject(new Error("`timeout` must hold an number value."));
18452
- }
18453
18469
  options.context = (_c = options.context) !== null && _c !== void 0 ? _c : {};
18454
18470
  const restoreOptions = {
18455
18471
  activityToJoin: options.activityIdToJoin,
@@ -18464,11 +18480,9 @@
18464
18480
  type: options.type,
18465
18481
  name: options.name,
18466
18482
  context: options.context,
18467
- options: restoreOptions
18483
+ options: restoreOptions,
18484
+ timeout: INTEROP_METHOD_MAX_TIMEOUT_MS
18468
18485
  };
18469
- if (options.timeout) {
18470
- arg.timeout = options.timeout;
18471
- }
18472
18486
  this.invokeMethodAndTrack("RestoreLayout", arg, resolve, reject, true);
18473
18487
  });
18474
18488
  }
@@ -18602,6 +18616,7 @@
18602
18616
  const request = {
18603
18617
  name,
18604
18618
  type: "Global",
18619
+ timeout: INTEROP_METHOD_MAX_TIMEOUT_MS,
18605
18620
  context,
18606
18621
  ...options
18607
18622
  };
@@ -18750,7 +18765,7 @@
18750
18765
  const err = Utils.typedError(error);
18751
18766
  reject(err);
18752
18767
  };
18753
- const methodResponseTimeoutMs = 120 * 1000;
18768
+ const methodResponseTimeoutMs = ("timeout" in args && typeof args.timeout === "number") ? args.timeout : 120 * 1000;
18754
18769
  if (!skipStreamEvent) {
18755
18770
  this.stream.waitFor(token, methodResponseTimeoutMs)
18756
18771
  .then(() => {
@@ -18839,7 +18854,7 @@
18839
18854
  }
18840
18855
  else {
18841
18856
  this.logger.trace(`subscribing to "${this.StreamName}" stream`);
18842
- this.agm.subscribe(this.StreamName, { waitTimeoutMs: 10000 })
18857
+ this.agm.subscribe(this.StreamName, { waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS, methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS })
18843
18858
  .then((subs) => {
18844
18859
  this.logger.trace(`subscribed to "${this.StreamName}" stream`);
18845
18860
  subs.onData((args) => {
@@ -19520,12 +19535,17 @@
19520
19535
  validateFdc3Options(options);
19521
19536
  }
19522
19537
  const id = Utils.generateId();
19538
+ let handlerInvoked = false;
19539
+ const markHandlerInvoked = () => { handlerInvoked = true; };
19523
19540
  const wrappedCallback = (options === null || options === void 0 ? void 0 : options.contextType)
19524
- ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType)
19525
- : this.getWrappedSubscribeCallback(callback, id);
19541
+ ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType, markHandlerInvoked)
19542
+ : this.getWrappedSubscribeCallback(callback, id, markHandlerInvoked);
19526
19543
  let timeoutIndex;
19527
19544
  if (this.lastUpdate) {
19528
19545
  timeoutIndex = setTimeout(() => {
19546
+ if (handlerInvoked) {
19547
+ return;
19548
+ }
19529
19549
  wrappedCallback(this.lastUpdate.context.data, this.lastUpdate.context, {}, this.lastUpdate.updaterId);
19530
19550
  }, 0);
19531
19551
  }
@@ -19547,9 +19567,10 @@
19547
19567
  validateFdc3Options(options);
19548
19568
  }
19549
19569
  const id = Utils.generateId();
19570
+ const markHandlerInvoked = () => { };
19550
19571
  const wrappedCallback = (options === null || options === void 0 ? void 0 : options.contextType)
19551
- ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType)
19552
- : this.getWrappedSubscribeCallback(callback, id);
19572
+ ? this.getWrappedSubscribeCallbackWithFdc3Type(callback, id, options.contextType, markHandlerInvoked)
19573
+ : this.getWrappedSubscribeCallback(callback, id, markHandlerInvoked);
19553
19574
  const unsub = await this.shared.subscribeFor(name, wrappedCallback);
19554
19575
  return () => {
19555
19576
  this.pendingRestrictionCallbacks.delete(id);
@@ -20085,8 +20106,9 @@
20085
20106
  const fdc3DataToPublish = { [`fdc3_${parsedType}`]: rest };
20086
20107
  return this.shared.updateData(channelName, fdc3DataToPublish);
20087
20108
  }
20088
- getWrappedSubscribeCallback(callback, id) {
20109
+ getWrappedSubscribeCallback(callback, id, markHandlerInvoked) {
20089
20110
  const wrappedCallback = async (_, context, delta, updaterId) => {
20111
+ markHandlerInvoked();
20090
20112
  const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
20091
20113
  const channelData = this.getDataWithFdc3Encoding(context, delta);
20092
20114
  if (restrictionByChannel.read) {
@@ -20097,9 +20119,10 @@
20097
20119
  };
20098
20120
  return wrappedCallback;
20099
20121
  }
20100
- getWrappedSubscribeCallbackWithFdc3Type(callback, id, fdc3Type) {
20122
+ getWrappedSubscribeCallbackWithFdc3Type(callback, id, fdc3Type, markHandlerInvoked) {
20101
20123
  const didReplay = { replayed: false };
20102
20124
  const wrappedCallback = async (_, context, delta, updaterId) => {
20125
+ markHandlerInvoked();
20103
20126
  const restrictionByChannel = await this.getRestrictionsByChannel(context.name);
20104
20127
  const callbackWithTypesChecks = () => {
20105
20128
  const { data, latest_fdc3_type } = context;
@@ -20457,7 +20480,7 @@
20457
20480
  }
20458
20481
  }
20459
20482
 
20460
- var version = "6.16.3";
20483
+ var version = "6.18.0";
20461
20484
 
20462
20485
  var prepareConfig = (options) => {
20463
20486
  function getLibConfig(value, defaultMode, trueMode) {
@@ -21076,7 +21099,9 @@
21076
21099
  arguments: {
21077
21100
  sendDeltaOnly: true,
21078
21101
  statesVersion2: true
21079
- }
21102
+ },
21103
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
21104
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS
21080
21105
  })
21081
21106
  .then((sub) => {
21082
21107
  this.subscriptionForNotifications = sub;
@@ -21108,7 +21133,9 @@
21108
21133
  .subscribe(this.NotificationsCounterStream, {
21109
21134
  arguments: {
21110
21135
  sendDeltaOnly: true
21111
- }
21136
+ },
21137
+ waitTimeoutMs: INTEROP_METHOD_WAIT_TIMEOUT_MS,
21138
+ methodResponseTimeout: INTEROP_METHOD_WAIT_TIMEOUT_MS
21112
21139
  })
21113
21140
  .then((sub) => {
21114
21141
  this.subscriptionForCounter = sub;
@@ -22860,6 +22887,32 @@
22860
22887
  }
22861
22888
  });
22862
22889
  };
22890
+ const validateAddIntentListenerRequest = (request) => {
22891
+ if ((typeof request !== "string" && typeof request !== "object") || (typeof request === "object" && typeof request.intent !== "string")) {
22892
+ throw new Error("Please provide the intent as a string or an object with an intent property!");
22893
+ }
22894
+ if (typeof request === "string") {
22895
+ return;
22896
+ }
22897
+ if (typeof request.contextTypes !== "undefined" && (!Array.isArray(request.contextTypes) || request.contextTypes.some(ctx => typeof ctx !== "string"))) {
22898
+ throw new Error("Please provide the 'contextTypes' as an array of strings!");
22899
+ }
22900
+ if (typeof request.resultType !== "undefined" && typeof request.resultType !== "string") {
22901
+ throw new Error("Please provide the 'resultType' as a string!");
22902
+ }
22903
+ if (typeof request.displayName !== "undefined" && typeof request.displayName !== "string") {
22904
+ throw new Error("Please provide the 'displayName' as a string!");
22905
+ }
22906
+ if (typeof request.icon !== "undefined" && typeof request.icon !== "string") {
22907
+ throw new Error("Please provide the 'icon' as a string!");
22908
+ }
22909
+ if (typeof request.description !== "undefined" && typeof request.description !== "string") {
22910
+ throw new Error("Please provide the 'description' as a string!");
22911
+ }
22912
+ if (typeof request.customConfig !== "undefined" && (typeof request.customConfig !== "object" || Array.isArray(request.customConfig))) {
22913
+ throw new Error("Please provide the 'customConfig' as an object!");
22914
+ }
22915
+ };
22863
22916
 
22864
22917
  class Intents {
22865
22918
  constructor(interop, windows, logger, options, prefsController, appsController) {
@@ -22964,7 +23017,8 @@
22964
23017
  contextTypes: intentDef.contexts,
22965
23018
  applicationIcon: app.icon,
22966
23019
  type: "app",
22967
- resultType: intentDef.resultType
23020
+ resultType: intentDef.resultType,
23021
+ customConfig: intentDef === null || intentDef === void 0 ? void 0 : intentDef.customConfig,
22968
23022
  };
22969
23023
  intent.handlers.push(handler);
22970
23024
  }
@@ -23045,9 +23099,7 @@
23045
23099
  return result;
23046
23100
  }
23047
23101
  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
- }
23102
+ validateAddIntentListenerRequest(intent);
23051
23103
  if (typeof handler !== "function") {
23052
23104
  throw new Error("Please provide the handler as a function!");
23053
23105
  }
@@ -23750,7 +23802,8 @@
23750
23802
  contextTypes: info.contextTypes || (appIntent === null || appIntent === void 0 ? void 0 : appIntent.contexts),
23751
23803
  instanceTitle: title,
23752
23804
  type: "instance",
23753
- resultType: (appIntent === null || appIntent === void 0 ? void 0 : appIntent.resultType) || info.resultType
23805
+ resultType: (appIntent === null || appIntent === void 0 ? void 0 : appIntent.resultType) || info.resultType,
23806
+ customConfig: info === null || info === void 0 ? void 0 : info.customConfig
23754
23807
  };
23755
23808
  return handler;
23756
23809
  }
@@ -23763,7 +23816,8 @@
23763
23816
  contextTypes: intent.contexts,
23764
23817
  applicationIcon: app.icon,
23765
23818
  type: "app",
23766
- resultType: intent.resultType
23819
+ resultType: intent.resultType,
23820
+ customConfig: intent === null || intent === void 0 ? void 0 : intent.customConfig
23767
23821
  };
23768
23822
  }
23769
23823
  }
@@ -24397,9 +24451,10 @@
24397
24451
  };
24398
24452
  }
24399
24453
  catch (error) {
24400
- const msg = `Failed to import app definitions: ${error.message}`;
24454
+ const errorMessage = error instanceof Error ? error.message : String(error);
24455
+ const msg = `Failed to import app definitions: ${errorMessage}`;
24401
24456
  this.logger.error(msg, error);
24402
- throw new Error(msg);
24457
+ throw new Error(msg, { cause: error });
24403
24458
  }
24404
24459
  }
24405
24460
  async has(name) {
@@ -24410,18 +24465,40 @@
24410
24465
  return result.returned.result !== undefined ? result.returned.result : false;
24411
24466
  }
24412
24467
  async remove(options) {
24413
- if (!(options === null || options === void 0 ? void 0 : options.name)) {
24468
+ if ((options === null || options === void 0 ? void 0 : options.name) === undefined) {
24414
24469
  throw new Error("App name is required for removal");
24415
24470
  }
24416
- this.logger.debug(`Removing app definition: ${options.name}`);
24471
+ const names = Array.isArray(options.name) ? options.name : [options.name];
24472
+ if (names.length === 0) {
24473
+ throw new Error("At least one app name is required for removal");
24474
+ }
24475
+ const invalidEntries = [];
24476
+ names.forEach((entry, index) => {
24477
+ if (typeof entry !== 'string') {
24478
+ invalidEntries.push(`index ${index}: expected string, got ${typeof entry}`);
24479
+ }
24480
+ else if (entry.trim() === '') {
24481
+ invalidEntries.push(`index ${index}: empty or whitespace-only string`);
24482
+ }
24483
+ });
24484
+ if (invalidEntries.length > 0) {
24485
+ throw new Error(`Invalid app name(s) for removal: ${invalidEntries.join('; ')}`);
24486
+ }
24487
+ const maxSampleSize = 10;
24488
+ const sampleNames = names.slice(0, maxSampleSize);
24489
+ const displayNames = Array.isArray(options.name)
24490
+ ? `[${sampleNames.join(", ")}${names.length > maxSampleSize ? ", ..." : ""}] (total ${names.length})`
24491
+ : options.name;
24492
+ this.logger.debug(`Removing app definition(s): ${displayNames}`);
24417
24493
  try {
24418
24494
  await invokeAppsCommand(this.interop, "in-memory-remove", options);
24419
- this.logger.debug(`Removed app definition: ${options.name}`);
24495
+ this.logger.debug(`Removed app definition(s): ${displayNames}`);
24420
24496
  }
24421
24497
  catch (error) {
24422
- const msg = `Failed to remove app definition: ${options.name}`;
24498
+ const errorMessage = error instanceof Error ? error.message : String(error);
24499
+ const msg = `Failed to remove app definition(s): ${displayNames}. ${errorMessage}`;
24423
24500
  this.logger.error(msg, error);
24424
- throw new Error(msg);
24501
+ throw new Error(msg, { cause: error });
24425
24502
  }
24426
24503
  }
24427
24504
  async clear(options) {
@@ -24430,9 +24507,10 @@
24430
24507
  await invokeAppsCommand(this.interop, "in-memory-clear", options);
24431
24508
  }
24432
24509
  catch (error) {
24433
- const msg = `Failed to clear in-memory app definitions: ${error.message}`;
24510
+ const errorMessage = error instanceof Error ? error.message : String(error);
24511
+ const msg = `Failed to clear in-memory app definitions: ${errorMessage}`;
24434
24512
  this.logger.error(msg, error);
24435
- throw new Error(msg);
24513
+ throw new Error(msg, { cause: error });
24436
24514
  }
24437
24515
  }
24438
24516
  }