@interopio/desktop 6.1.0 → 6.2.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.
@@ -1031,12 +1031,12 @@
1031
1031
  };
1032
1032
  }
1033
1033
  createRegistry$1.default = createRegistry$1;
1034
- var lib$1$1 = createRegistry$1;
1034
+ var lib$1 = createRegistry$1;
1035
1035
 
1036
1036
  var InProcTransport = (function () {
1037
1037
  function InProcTransport(settings, logger) {
1038
1038
  var _this = this;
1039
- this.registry = lib$1$1();
1039
+ this.registry = lib$1();
1040
1040
  this.gw = settings.facade;
1041
1041
  this.gw.connect(function (_client, message) {
1042
1042
  _this.messageHandler(message);
@@ -1092,7 +1092,7 @@
1092
1092
  function SharedWorkerTransport(workerFile, logger) {
1093
1093
  var _this = this;
1094
1094
  this.logger = logger;
1095
- this.registry = lib$1$1();
1095
+ this.registry = lib$1();
1096
1096
  this.worker = new SharedWorker(workerFile);
1097
1097
  this.worker.port.onmessage = function (e) {
1098
1098
  _this.messageHandler(e.data);
@@ -1242,7 +1242,7 @@
1242
1242
  function WS(settings, logger) {
1243
1243
  this.startupTimer = timer("connection");
1244
1244
  this._running = true;
1245
- this._registry = lib$1$1();
1245
+ this._registry = lib$1();
1246
1246
  this.wsRequests = [];
1247
1247
  this.settings = settings;
1248
1248
  this.logger = logger;
@@ -1433,44 +1433,44 @@
1433
1433
  // Found this seed-based random generator somewhere
1434
1434
  // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
1435
1435
 
1436
- var seed$1 = 1;
1436
+ var seed = 1;
1437
1437
 
1438
1438
  /**
1439
1439
  * return a random number based on a seed
1440
1440
  * @param seed
1441
1441
  * @returns {number}
1442
1442
  */
1443
- function getNextValue$1() {
1444
- seed$1 = (seed$1 * 9301 + 49297) % 233280;
1445
- return seed$1/(233280.0);
1443
+ function getNextValue() {
1444
+ seed = (seed * 9301 + 49297) % 233280;
1445
+ return seed/(233280.0);
1446
1446
  }
1447
1447
 
1448
- function setSeed$1$1(_seed_) {
1449
- seed$1 = _seed_;
1448
+ function setSeed$1(_seed_) {
1449
+ seed = _seed_;
1450
1450
  }
1451
1451
 
1452
1452
  var randomFromSeed$1 = {
1453
- nextValue: getNextValue$1,
1454
- seed: setSeed$1$1
1453
+ nextValue: getNextValue,
1454
+ seed: setSeed$1
1455
1455
  };
1456
1456
 
1457
- var randomFromSeed$2 = randomFromSeed$1;
1457
+ var randomFromSeed = randomFromSeed$1;
1458
1458
 
1459
- var ORIGINAL$1 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
1459
+ var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
1460
1460
  var alphabet$2;
1461
- var previousSeed$1;
1461
+ var previousSeed;
1462
1462
 
1463
- var shuffled$1;
1463
+ var shuffled;
1464
1464
 
1465
- function reset$1() {
1466
- shuffled$1 = false;
1465
+ function reset() {
1466
+ shuffled = false;
1467
1467
  }
1468
1468
 
1469
- function setCharacters$1(_alphabet_) {
1469
+ function setCharacters(_alphabet_) {
1470
1470
  if (!_alphabet_) {
1471
- if (alphabet$2 !== ORIGINAL$1) {
1472
- alphabet$2 = ORIGINAL$1;
1473
- reset$1();
1471
+ if (alphabet$2 !== ORIGINAL) {
1472
+ alphabet$2 = ORIGINAL;
1473
+ reset();
1474
1474
  }
1475
1475
  return;
1476
1476
  }
@@ -1479,8 +1479,8 @@
1479
1479
  return;
1480
1480
  }
1481
1481
 
1482
- if (_alphabet_.length !== ORIGINAL$1.length) {
1483
- throw new Error('Custom alphabet for shortid must be ' + ORIGINAL$1.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);
1482
+ if (_alphabet_.length !== ORIGINAL.length) {
1483
+ throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);
1484
1484
  }
1485
1485
 
1486
1486
  var unique = _alphabet_.split('').filter(function(item, ind, arr){
@@ -1488,50 +1488,50 @@
1488
1488
  });
1489
1489
 
1490
1490
  if (unique.length) {
1491
- throw new Error('Custom alphabet for shortid must be ' + ORIGINAL$1.length + ' unique characters. These characters were not unique: ' + unique.join(', '));
1491
+ throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', '));
1492
1492
  }
1493
1493
 
1494
1494
  alphabet$2 = _alphabet_;
1495
- reset$1();
1495
+ reset();
1496
1496
  }
1497
1497
 
1498
- function characters$1(_alphabet_) {
1499
- setCharacters$1(_alphabet_);
1498
+ function characters(_alphabet_) {
1499
+ setCharacters(_alphabet_);
1500
1500
  return alphabet$2;
1501
1501
  }
1502
1502
 
1503
- function setSeed$2(seed) {
1504
- randomFromSeed$2.seed(seed);
1505
- if (previousSeed$1 !== seed) {
1506
- reset$1();
1507
- previousSeed$1 = seed;
1503
+ function setSeed(seed) {
1504
+ randomFromSeed.seed(seed);
1505
+ if (previousSeed !== seed) {
1506
+ reset();
1507
+ previousSeed = seed;
1508
1508
  }
1509
1509
  }
1510
1510
 
1511
- function shuffle$1() {
1511
+ function shuffle() {
1512
1512
  if (!alphabet$2) {
1513
- setCharacters$1(ORIGINAL$1);
1513
+ setCharacters(ORIGINAL);
1514
1514
  }
1515
1515
 
1516
1516
  var sourceArray = alphabet$2.split('');
1517
1517
  var targetArray = [];
1518
- var r = randomFromSeed$2.nextValue();
1518
+ var r = randomFromSeed.nextValue();
1519
1519
  var characterIndex;
1520
1520
 
1521
1521
  while (sourceArray.length > 0) {
1522
- r = randomFromSeed$2.nextValue();
1522
+ r = randomFromSeed.nextValue();
1523
1523
  characterIndex = Math.floor(r * sourceArray.length);
1524
1524
  targetArray.push(sourceArray.splice(characterIndex, 1)[0]);
1525
1525
  }
1526
1526
  return targetArray.join('');
1527
1527
  }
1528
1528
 
1529
- function getShuffled$1() {
1530
- if (shuffled$1) {
1531
- return shuffled$1;
1529
+ function getShuffled() {
1530
+ if (shuffled) {
1531
+ return shuffled;
1532
1532
  }
1533
- shuffled$1 = shuffle$1();
1534
- return shuffled$1;
1533
+ shuffled = shuffle();
1534
+ return shuffled;
1535
1535
  }
1536
1536
 
1537
1537
  /**
@@ -1539,29 +1539,29 @@
1539
1539
  * @param index
1540
1540
  * @returns {string}
1541
1541
  */
1542
- function lookup$1(index) {
1543
- var alphabetShuffled = getShuffled$1();
1542
+ function lookup(index) {
1543
+ var alphabetShuffled = getShuffled();
1544
1544
  return alphabetShuffled[index];
1545
1545
  }
1546
1546
 
1547
1547
  function get () {
1548
- return alphabet$2 || ORIGINAL$1;
1548
+ return alphabet$2 || ORIGINAL;
1549
1549
  }
1550
1550
 
1551
- var alphabet_1$1 = {
1551
+ var alphabet_1 = {
1552
1552
  get: get,
1553
- characters: characters$1,
1554
- seed: setSeed$2,
1555
- lookup: lookup$1,
1556
- shuffled: getShuffled$1
1553
+ characters: characters,
1554
+ seed: setSeed,
1555
+ lookup: lookup,
1556
+ shuffled: getShuffled
1557
1557
  };
1558
1558
 
1559
- var crypto$1 = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto
1559
+ var crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto
1560
1560
 
1561
- var randomByte$1;
1561
+ var randomByte;
1562
1562
 
1563
- if (!crypto$1 || !crypto$1.getRandomValues) {
1564
- randomByte$1 = function(size) {
1563
+ if (!crypto || !crypto.getRandomValues) {
1564
+ randomByte = function(size) {
1565
1565
  var bytes = [];
1566
1566
  for (var i = 0; i < size; i++) {
1567
1567
  bytes.push(Math.floor(Math.random() * 256));
@@ -1569,12 +1569,12 @@
1569
1569
  return bytes;
1570
1570
  };
1571
1571
  } else {
1572
- randomByte$1 = function(size) {
1573
- return crypto$1.getRandomValues(new Uint8Array(size));
1572
+ randomByte = function(size) {
1573
+ return crypto.getRandomValues(new Uint8Array(size));
1574
1574
  };
1575
1575
  }
1576
1576
 
1577
- var randomByteBrowser$1 = randomByte$1;
1577
+ var randomByteBrowser = randomByte;
1578
1578
 
1579
1579
  // This file replaces `format.js` in bundlers like webpack or Rollup,
1580
1580
  // according to `browser` config in `package.json`.
@@ -1617,8 +1617,8 @@
1617
1617
  }
1618
1618
  };
1619
1619
 
1620
- var alphabet$1 = alphabet_1$1;
1621
- var random = randomByteBrowser$1;
1620
+ var alphabet$1 = alphabet_1;
1621
+ var random = randomByteBrowser;
1622
1622
  var format = format_browser;
1623
1623
 
1624
1624
  function generate$1(number) {
@@ -1642,65 +1642,65 @@
1642
1642
  // Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness.
1643
1643
  // This number should be updated every year or so to keep the generated id short.
1644
1644
  // To regenerate `new Date() - 0` and bump the version. Always bump the version!
1645
- var REDUCE_TIME$1 = 1567752802062;
1645
+ var REDUCE_TIME = 1567752802062;
1646
1646
 
1647
1647
  // don't change unless we change the algos or REDUCE_TIME
1648
1648
  // must be an integer and less than 16
1649
- var version$1$1 = 7;
1649
+ var version$1 = 7;
1650
1650
 
1651
1651
  // Counter is used when shortid is called multiple times in one second.
1652
- var counter$1;
1652
+ var counter;
1653
1653
 
1654
1654
  // Remember the last time shortid was called in case counter is needed.
1655
- var previousSeconds$1;
1655
+ var previousSeconds;
1656
1656
 
1657
1657
  /**
1658
1658
  * Generate unique id
1659
1659
  * Returns string id
1660
1660
  */
1661
- function build$1(clusterWorkerId) {
1661
+ function build(clusterWorkerId) {
1662
1662
  var str = '';
1663
1663
 
1664
- var seconds = Math.floor((Date.now() - REDUCE_TIME$1) * 0.001);
1664
+ var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001);
1665
1665
 
1666
- if (seconds === previousSeconds$1) {
1667
- counter$1++;
1666
+ if (seconds === previousSeconds) {
1667
+ counter++;
1668
1668
  } else {
1669
- counter$1 = 0;
1670
- previousSeconds$1 = seconds;
1669
+ counter = 0;
1670
+ previousSeconds = seconds;
1671
1671
  }
1672
1672
 
1673
- str = str + generate(version$1$1);
1673
+ str = str + generate(version$1);
1674
1674
  str = str + generate(clusterWorkerId);
1675
- if (counter$1 > 0) {
1676
- str = str + generate(counter$1);
1675
+ if (counter > 0) {
1676
+ str = str + generate(counter);
1677
1677
  }
1678
1678
  str = str + generate(seconds);
1679
1679
  return str;
1680
1680
  }
1681
1681
 
1682
- var build_1$1 = build$1;
1682
+ var build_1 = build;
1683
1683
 
1684
- var alphabet$3 = alphabet_1$1;
1684
+ var alphabet = alphabet_1;
1685
1685
 
1686
- function isShortId$1(id) {
1686
+ function isShortId(id) {
1687
1687
  if (!id || typeof id !== 'string' || id.length < 6 ) {
1688
1688
  return false;
1689
1689
  }
1690
1690
 
1691
1691
  var nonAlphabetic = new RegExp('[^' +
1692
- alphabet$3.get().replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&') +
1692
+ alphabet.get().replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&') +
1693
1693
  ']');
1694
1694
  return !nonAlphabetic.test(id);
1695
1695
  }
1696
1696
 
1697
- var isValid$1 = isShortId$1;
1697
+ var isValid = isShortId;
1698
1698
 
1699
1699
  (function (module) {
1700
1700
 
1701
- var alphabet = alphabet_1$1;
1702
- var build = build_1$1;
1703
- var isValid$1$1 = isValid$1;
1701
+ var alphabet = alphabet_1;
1702
+ var build = build_1;
1703
+ var isValid$1 = isValid;
1704
1704
 
1705
1705
  // if you are using cluster or multiple servers use this to make each instance
1706
1706
  // has a unique value for worker
@@ -1757,14 +1757,14 @@
1757
1757
  module.exports.seed = seed;
1758
1758
  module.exports.worker = worker;
1759
1759
  module.exports.characters = characters;
1760
- module.exports.isValid = isValid$1$1;
1760
+ module.exports.isValid = isValid$1;
1761
1761
  } (lib$2));
1762
1762
 
1763
1763
  (function (module) {
1764
1764
  module.exports = libExports;
1765
1765
  } (shortid$1));
1766
1766
 
1767
- var shortid$2 = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
1767
+ var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
1768
1768
 
1769
1769
  function domainSession (domain, connection, logger, successMessages, errorMessages) {
1770
1770
  if (domain == null) {
@@ -1776,7 +1776,7 @@
1776
1776
  var tryReconnecting = false;
1777
1777
  var _latestOptions;
1778
1778
  var _connectionOn = false;
1779
- var callbacks = lib$1$1();
1779
+ var callbacks = lib$1();
1780
1780
  connection.disconnected(handleConnectionDisconnected);
1781
1781
  connection.loggedIn(handleConnectionLoggedIn);
1782
1782
  connection.on("success", function (msg) { return handleSuccessMessage(msg); });
@@ -1908,7 +1908,7 @@
1908
1908
  entry.success(msg);
1909
1909
  }
1910
1910
  function getNextRequestId() {
1911
- return shortid$2();
1911
+ return shortid();
1912
1912
  }
1913
1913
  function send(msg, tag, options) {
1914
1914
  options = options || {};
@@ -1988,7 +1988,7 @@
1988
1988
  this.datePrefixLen = this.datePrefix.length;
1989
1989
  this.dateMinLen = this.datePrefixLen + 1;
1990
1990
  this.datePrefixFirstChar = this.datePrefix[0];
1991
- this.registry = lib$1$1();
1991
+ this.registry = lib$1();
1992
1992
  this._isLoggedIn = false;
1993
1993
  this.shouldTryLogin = true;
1994
1994
  this.initialLogin = true;
@@ -2418,7 +2418,7 @@
2418
2418
  this.parentPingTimeout = 5000;
2419
2419
  this.connectionRequestTimeout = 7000;
2420
2420
  this.defaultTargetString = "*";
2421
- this.registry = lib$1$1();
2421
+ this.registry = lib$1();
2422
2422
  this.messages = {
2423
2423
  connectionAccepted: { name: "connectionAccepted", handle: this.handleConnectionAccepted.bind(this) },
2424
2424
  connectionRejected: { name: "connectionRejected", handle: this.handleConnectionRejected.bind(this) },
@@ -2581,8 +2581,8 @@
2581
2581
  var _a;
2582
2582
  _this.connectionResolve = resolve;
2583
2583
  _this.connectionReject = reject;
2584
- _this.myClientId = (_a = _this.myClientId) !== null && _a !== void 0 ? _a : shortid$2();
2585
- var bridgeInstanceId = _this.getMyWindowId() || shortid$2();
2584
+ _this.myClientId = (_a = _this.myClientId) !== null && _a !== void 0 ? _a : shortid();
2585
+ var bridgeInstanceId = _this.getMyWindowId() || shortid();
2586
2586
  var request = {
2587
2587
  glue42core: {
2588
2588
  type: _this.messages.connectionRequest.name,
@@ -2706,7 +2706,7 @@
2706
2706
  this.publicWindowId = this.getMyWindowId();
2707
2707
  if (this.identity) {
2708
2708
  this.identity.windowId = this.publicWindowId;
2709
- this.identity.instance = this.identity.instance ? this.identity.instance : this.publicWindowId || shortid$2();
2709
+ this.identity.instance = this.identity.instance ? this.identity.instance : this.publicWindowId || shortid();
2710
2710
  }
2711
2711
  if (this.identity && data.appName) {
2712
2712
  this.identity.application = data.appName;
@@ -3031,7 +3031,7 @@
3031
3031
  if ((_a = window.name) === null || _a === void 0 ? void 0 : _a.includes("g42")) {
3032
3032
  return window.name;
3033
3033
  }
3034
- this.selfAssignedWindowId = this.selfAssignedWindowId || "g42-".concat(shortid$2());
3034
+ this.selfAssignedWindowId = this.selfAssignedWindowId || "g42-".concat(shortid());
3035
3035
  return this.selfAssignedWindowId;
3036
3036
  };
3037
3037
  return WebPlatformTransport;
@@ -3115,7 +3115,7 @@
3115
3115
  this.logger = logger;
3116
3116
  this.messageHandlers = {};
3117
3117
  this.ids = 1;
3118
- this.registry = lib$1$1();
3118
+ this.registry = lib$1();
3119
3119
  this._connected = false;
3120
3120
  this.isTrace = false;
3121
3121
  this._swapTransport = false;
@@ -3737,7 +3737,7 @@
3737
3737
  if (typeof window !== "undefined" && typeof window.glue42electron !== "undefined") {
3738
3738
  return window.glue42electron.application;
3739
3739
  }
3740
- var uid = shortid$2();
3740
+ var uid = shortid();
3741
3741
  if (Utils$1.isNode()) {
3742
3742
  if (nodeStartingContext) {
3743
3743
  return nodeStartingContext.applicationConfig.name;
@@ -6864,7 +6864,7 @@
6864
6864
  timeout = additionalOptions.methodResponseTimeoutMs;
6865
6865
  additionalOptionsCopy = additionalOptions;
6866
6866
  invokePromises = serversMethodMap.map(function (serversMethodPair) {
6867
- var invId = shortid$2();
6867
+ var invId = shortid();
6868
6868
  var method = serversMethodPair.methods[0];
6869
6869
  var server = serversMethodPair.server;
6870
6870
  var invokePromise = _this.protocol.client.invoke(invId, method, argumentObj, server, additionalOptionsCopy);
@@ -7645,7 +7645,7 @@
7645
7645
  });
7646
7646
  this.wrapped.user = resolvedIdentity.user;
7647
7647
  this.wrapped.instance = resolvedIdentity.instance;
7648
- this.wrapped.application = (_a = resolvedIdentity.application) !== null && _a !== void 0 ? _a : shortid$2();
7648
+ this.wrapped.application = (_a = resolvedIdentity.application) !== null && _a !== void 0 ? _a : shortid();
7649
7649
  this.wrapped.applicationName = resolvedIdentity.applicationName;
7650
7650
  this.wrapped.pid = (_c = (_b = resolvedIdentity.pid) !== null && _b !== void 0 ? _b : resolvedIdentity.process) !== null && _c !== void 0 ? _c : Math.floor(Math.random() * 10000000000);
7651
7651
  this.wrapped.machine = resolvedIdentity.machine;
@@ -7669,7 +7669,7 @@
7669
7669
  this.API = API;
7670
7670
  this.servers = {};
7671
7671
  this.methodsCount = {};
7672
- this.callbacks = lib$1$1();
7672
+ this.callbacks = lib$1();
7673
7673
  var peerId = this.API.instance.peerId;
7674
7674
  this.myServer = {
7675
7675
  id: peerId,
@@ -7924,7 +7924,7 @@
7924
7924
  this.repository = repository;
7925
7925
  this.serverRepository = serverRepository;
7926
7926
  this.ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
7927
- this.callbacks = lib$1$1();
7927
+ this.callbacks = lib$1();
7928
7928
  this.nextStreamId = 0;
7929
7929
  session.on("add-interest", function (msg) {
7930
7930
  _this.handleAddInterest(msg);
@@ -8186,7 +8186,7 @@
8186
8186
  this.clientRepository = clientRepository;
8187
8187
  this.serverRepository = serverRepository;
8188
8188
  this.logger = logger;
8189
- this.callbacks = lib$1$1();
8189
+ this.callbacks = lib$1();
8190
8190
  this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
8191
8191
  this.session.on("invoke", function (msg) { return _this.handleInvokeMessage(msg); });
8192
8192
  }
@@ -8398,7 +8398,7 @@
8398
8398
  }
8399
8399
  TimedCache.prototype.add = function (element) {
8400
8400
  var _this = this;
8401
- var id = shortid$2();
8401
+ var id = shortid();
8402
8402
  this.cache.push({ id: id, element: element });
8403
8403
  var timeoutId = setTimeout(function () {
8404
8404
  var elementIdx = _this.cache.findIndex(function (entry) { return entry.id === id; });
@@ -9260,7 +9260,7 @@
9260
9260
  canUpdateMetric: canUpdateMetric,
9261
9261
  system: "Glue42",
9262
9262
  service: (_c = (_b = identity === null || identity === void 0 ? void 0 : identity.service) !== null && _b !== void 0 ? _b : iodesktop === null || iodesktop === void 0 ? void 0 : iodesktop.applicationName) !== null && _c !== void 0 ? _c : internalConfig.application,
9263
- instance: (_e = (_d = identity === null || identity === void 0 ? void 0 : identity.instance) !== null && _d !== void 0 ? _d : identity === null || identity === void 0 ? void 0 : identity.windowId) !== null && _e !== void 0 ? _e : shortid$2(),
9263
+ instance: (_e = (_d = identity === null || identity === void 0 ? void 0 : identity.instance) !== null && _d !== void 0 ? _d : identity === null || identity === void 0 ? void 0 : identity.windowId) !== null && _e !== void 0 ? _e : shortid(),
9264
9264
  disableAutoAppSystem: disableAutoAppSystem,
9265
9265
  pagePerformanceMetrics: typeof config !== "boolean" ? config === null || config === void 0 ? void 0 : config.pagePerformanceMetrics : undefined
9266
9266
  });
@@ -12499,7 +12499,7 @@
12499
12499
  };
12500
12500
  }
12501
12501
  createRegistry.default = createRegistry;
12502
- var lib$1 = createRegistry;
12502
+ var lib = createRegistry;
12503
12503
 
12504
12504
  function objectValues(source) {
12505
12505
  if (!source) {
@@ -12531,7 +12531,7 @@
12531
12531
  this._name = _name;
12532
12532
  this._agm = _agm;
12533
12533
  this._configuration = _configuration;
12534
- this._registry = lib$1();
12534
+ this._registry = lib();
12535
12535
  _appManager.onInstanceStarted((instance) => {
12536
12536
  if (instance.application && instance.application.name !== this._name) {
12537
12537
  return;
@@ -12795,7 +12795,7 @@
12795
12795
  this._activities = _activities;
12796
12796
  this._windows = _windows;
12797
12797
  this._configuration = _configuration;
12798
- this._registry = lib$1();
12798
+ this._registry = lib();
12799
12799
  if (startFailed) {
12800
12800
  return;
12801
12801
  }
@@ -12979,7 +12979,7 @@
12979
12979
  this._configuration = _configuration;
12980
12980
  this._apps = {};
12981
12981
  this._instances = [];
12982
- this._registry = lib$1();
12982
+ this._registry = lib();
12983
12983
  this.getConfigurations = async (apps) => {
12984
12984
  const args = {
12985
12985
  v2: {
@@ -13236,7 +13236,7 @@
13236
13236
  class EntitlementsImpl {
13237
13237
  constructor(_agm) {
13238
13238
  this._agm = _agm;
13239
- this._registry = lib$1();
13239
+ this._registry = lib();
13240
13240
  this._isMethodRegistered = false;
13241
13241
  this.handleBranchModified = (branch) => {
13242
13242
  this._registry.execute("branchChanged", branch);
@@ -13582,309 +13582,124 @@
13582
13582
  return api;
13583
13583
  };
13584
13584
 
13585
- function createCommonjsModule(fn, module) {
13586
- return module = { exports: {} }, fn(module, module.exports), module.exports;
13587
- }
13588
-
13589
- // Found this seed-based random generator somewhere
13590
- // Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
13591
-
13592
- var seed = 1;
13593
-
13594
- /**
13595
- * return a random number based on a seed
13596
- * @param seed
13597
- * @returns {number}
13598
- */
13599
- function getNextValue() {
13600
- seed = (seed * 9301 + 49297) % 233280;
13601
- return seed/(233280.0);
13602
- }
13603
-
13604
- function setSeed$1(_seed_) {
13605
- seed = _seed_;
13606
- }
13607
-
13608
- var randomFromSeed = {
13609
- nextValue: getNextValue,
13610
- seed: setSeed$1
13585
+ let urlAlphabet =
13586
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
13587
+ let nanoid = (size = 21) => {
13588
+ let id = '';
13589
+ let i = size;
13590
+ while (i--) {
13591
+ id += urlAlphabet[(Math.random() * 64) | 0];
13592
+ }
13593
+ return id
13611
13594
  };
13612
13595
 
13613
- var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
13614
- var alphabet;
13615
- var previousSeed;
13616
-
13617
- var shuffled;
13618
-
13619
- function reset() {
13620
- shuffled = false;
13621
- }
13622
-
13623
- function setCharacters(_alphabet_) {
13624
- if (!_alphabet_) {
13625
- if (alphabet !== ORIGINAL) {
13626
- alphabet = ORIGINAL;
13627
- reset();
13628
- }
13629
- return;
13630
- }
13631
-
13632
- if (_alphabet_ === alphabet) {
13633
- return;
13634
- }
13635
-
13636
- if (_alphabet_.length !== ORIGINAL.length) {
13637
- throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);
13638
- }
13639
-
13640
- var unique = _alphabet_.split('').filter(function(item, ind, arr){
13641
- return ind !== arr.lastIndexOf(item);
13642
- });
13643
-
13644
- if (unique.length) {
13645
- throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', '));
13646
- }
13647
-
13648
- alphabet = _alphabet_;
13649
- reset();
13650
- }
13651
-
13652
- function characters(_alphabet_) {
13653
- setCharacters(_alphabet_);
13654
- return alphabet;
13655
- }
13656
-
13657
- function setSeed(seed) {
13658
- randomFromSeed.seed(seed);
13659
- if (previousSeed !== seed) {
13660
- reset();
13661
- previousSeed = seed;
13662
- }
13663
- }
13664
-
13665
- function shuffle() {
13666
- if (!alphabet) {
13667
- setCharacters(ORIGINAL);
13668
- }
13669
-
13670
- var sourceArray = alphabet.split('');
13671
- var targetArray = [];
13672
- var r = randomFromSeed.nextValue();
13673
- var characterIndex;
13674
-
13675
- while (sourceArray.length > 0) {
13676
- r = randomFromSeed.nextValue();
13677
- characterIndex = Math.floor(r * sourceArray.length);
13678
- targetArray.push(sourceArray.splice(characterIndex, 1)[0]);
13679
- }
13680
- return targetArray.join('');
13596
+ class Utils {
13597
+ static getGDMajorVersion() {
13598
+ if (typeof window === "undefined") {
13599
+ return -1;
13600
+ }
13601
+ if (!window.glueDesktop) {
13602
+ return -1;
13603
+ }
13604
+ if (!window.glueDesktop.version) {
13605
+ return -1;
13606
+ }
13607
+ const ver = Number(window.glueDesktop.version.substr(0, 1));
13608
+ return isNaN(ver) ? -1 : ver;
13609
+ }
13610
+ static callbackifyPromise(action, successCallback, errorCallback) {
13611
+ const fail = (error) => {
13612
+ let msg = error;
13613
+ if (error instanceof Error) {
13614
+ msg = error.message;
13615
+ }
13616
+ if (typeof errorCallback === "function") {
13617
+ errorCallback(msg);
13618
+ return;
13619
+ }
13620
+ return Promise.reject(msg);
13621
+ };
13622
+ try {
13623
+ return action()
13624
+ .then((result) => {
13625
+ if (typeof successCallback === "function") {
13626
+ successCallback(result);
13627
+ }
13628
+ return result;
13629
+ })
13630
+ .catch((error) => {
13631
+ return fail(error);
13632
+ });
13633
+ }
13634
+ catch (err) {
13635
+ return fail(err);
13636
+ }
13637
+ }
13638
+ static getMonitor(bounds, displays) {
13639
+ const monitorsSortedByOverlap = displays.map((m) => {
13640
+ const { left, top, workingAreaWidth: width, workingAreaHeight: height } = m;
13641
+ const overlap = this.calculateTotalOverlap({ left, top, width, height }, bounds);
13642
+ return {
13643
+ monitor: m,
13644
+ totalOverlap: overlap
13645
+ };
13646
+ }).sort((a, b) => b.totalOverlap - a.totalOverlap);
13647
+ return monitorsSortedByOverlap[0].monitor;
13648
+ }
13649
+ static getDisplayCenterOfScreen(a, currentDisplay, primaryDisplay) {
13650
+ const physicalWidth = a.width / currentDisplay.scaleFactor;
13651
+ const physicalHeight = a.height / currentDisplay.scaleFactor;
13652
+ const physicalDisplayLeft = currentDisplay.workArea.left / primaryDisplay.scaleFactor;
13653
+ const physicalDisplayTop = currentDisplay.workArea.top / primaryDisplay.scaleFactor;
13654
+ const physicalDisplayWidth = currentDisplay.workArea.width / currentDisplay.scaleFactor;
13655
+ const physicalDisplayHeight = currentDisplay.workArea.height / currentDisplay.scaleFactor;
13656
+ const physicalHOffset = Math.max((physicalDisplayWidth - physicalWidth) / 2, 0);
13657
+ const physicalVOffset = Math.max((physicalDisplayHeight - physicalHeight) / 2, 0);
13658
+ const centeredPhysicalLeft = Math.floor(physicalDisplayLeft + physicalHOffset);
13659
+ const centeredPhysicalTop = Math.floor(physicalDisplayTop + physicalVOffset);
13660
+ const left = centeredPhysicalLeft * primaryDisplay.scaleFactor;
13661
+ const top = centeredPhysicalTop * primaryDisplay.scaleFactor;
13662
+ return {
13663
+ left,
13664
+ top,
13665
+ width: a.width,
13666
+ height: a.height
13667
+ };
13668
+ }
13669
+ static isNode() {
13670
+ if (typeof Utils._isNode !== "undefined") {
13671
+ return Utils._isNode;
13672
+ }
13673
+ if (typeof window !== "undefined") {
13674
+ Utils._isNode = false;
13675
+ return false;
13676
+ }
13677
+ try {
13678
+ Utils._isNode = Object.prototype.toString.call(global.process) === "[object process]";
13679
+ }
13680
+ catch (e) {
13681
+ Utils._isNode = false;
13682
+ }
13683
+ return Utils._isNode;
13684
+ }
13685
+ static generateId() {
13686
+ return nanoid(10);
13687
+ }
13688
+ static calculateTotalOverlap(r1, r2) {
13689
+ const r1x = r1.left;
13690
+ const r1y = r1.top;
13691
+ const r1xMax = r1x + r1.width;
13692
+ const r1yMax = r1y + r1.height;
13693
+ const r2x = r2.left;
13694
+ const r2y = r2.top;
13695
+ const r2xMax = r2x + r2.width;
13696
+ const r2yMax = r2y + r2.height;
13697
+ const xOverlap = Math.max(0, Math.min(r1xMax, r2xMax) - Math.max(r1x, r2x));
13698
+ const yOverlap = Math.max(0, Math.min(r1yMax, r2yMax) - Math.max(r1y, r2y));
13699
+ return xOverlap * yOverlap;
13700
+ }
13681
13701
  }
13682
13702
 
13683
- function getShuffled() {
13684
- if (shuffled) {
13685
- return shuffled;
13686
- }
13687
- shuffled = shuffle();
13688
- return shuffled;
13689
- }
13690
-
13691
- /**
13692
- * lookup shuffled letter
13693
- * @param index
13694
- * @returns {string}
13695
- */
13696
- function lookup(index) {
13697
- var alphabetShuffled = getShuffled();
13698
- return alphabetShuffled[index];
13699
- }
13700
-
13701
- var alphabet_1 = {
13702
- characters: characters,
13703
- seed: setSeed,
13704
- lookup: lookup,
13705
- shuffled: getShuffled
13706
- };
13707
-
13708
- var crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto
13709
-
13710
- function randomByte() {
13711
- if (!crypto || !crypto.getRandomValues) {
13712
- return Math.floor(Math.random() * 256) & 0x30;
13713
- }
13714
- var dest = new Uint8Array(1);
13715
- crypto.getRandomValues(dest);
13716
- return dest[0] & 0x30;
13717
- }
13718
-
13719
- var randomByteBrowser = randomByte;
13720
-
13721
- function encode(lookup, number) {
13722
- var loopCounter = 0;
13723
- var done;
13724
-
13725
- var str = '';
13726
-
13727
- while (!done) {
13728
- str = str + lookup( ( (number >> (4 * loopCounter)) & 0x0f ) | randomByteBrowser() );
13729
- done = number < (Math.pow(16, loopCounter + 1 ) );
13730
- loopCounter++;
13731
- }
13732
- return str;
13733
- }
13734
-
13735
- var encode_1 = encode;
13736
-
13737
- /**
13738
- * Decode the id to get the version and worker
13739
- * Mainly for debugging and testing.
13740
- * @param id - the shortid-generated id.
13741
- */
13742
- function decode(id) {
13743
- var characters = alphabet_1.shuffled();
13744
- return {
13745
- version: characters.indexOf(id.substr(0, 1)) & 0x0f,
13746
- worker: characters.indexOf(id.substr(1, 1)) & 0x0f
13747
- };
13748
- }
13749
-
13750
- var decode_1 = decode;
13751
-
13752
- // Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness.
13753
- // This number should be updated every year or so to keep the generated id short.
13754
- // To regenerate `new Date() - 0` and bump the version. Always bump the version!
13755
- var REDUCE_TIME = 1459707606518;
13756
-
13757
- // don't change unless we change the algos or REDUCE_TIME
13758
- // must be an integer and less than 16
13759
- var version$1 = 6;
13760
-
13761
- // Counter is used when shortid is called multiple times in one second.
13762
- var counter;
13763
-
13764
- // Remember the last time shortid was called in case counter is needed.
13765
- var previousSeconds;
13766
-
13767
- /**
13768
- * Generate unique id
13769
- * Returns string id
13770
- */
13771
- function build(clusterWorkerId) {
13772
-
13773
- var str = '';
13774
-
13775
- var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001);
13776
-
13777
- if (seconds === previousSeconds) {
13778
- counter++;
13779
- } else {
13780
- counter = 0;
13781
- previousSeconds = seconds;
13782
- }
13783
-
13784
- str = str + encode_1(alphabet_1.lookup, version$1);
13785
- str = str + encode_1(alphabet_1.lookup, clusterWorkerId);
13786
- if (counter > 0) {
13787
- str = str + encode_1(alphabet_1.lookup, counter);
13788
- }
13789
- str = str + encode_1(alphabet_1.lookup, seconds);
13790
-
13791
- return str;
13792
- }
13793
-
13794
- var build_1 = build;
13795
-
13796
- function isShortId(id) {
13797
- if (!id || typeof id !== 'string' || id.length < 6 ) {
13798
- return false;
13799
- }
13800
-
13801
- var characters = alphabet_1.characters();
13802
- var len = id.length;
13803
- for(var i = 0; i < len;i++) {
13804
- if (characters.indexOf(id[i]) === -1) {
13805
- return false;
13806
- }
13807
- }
13808
- return true;
13809
- }
13810
-
13811
- var isValid = isShortId;
13812
-
13813
- var lib = createCommonjsModule(function (module) {
13814
-
13815
-
13816
-
13817
-
13818
-
13819
-
13820
-
13821
- // if you are using cluster or multiple servers use this to make each instance
13822
- // has a unique value for worker
13823
- // Note: I don't know if this is automatically set when using third
13824
- // party cluster solutions such as pm2.
13825
- var clusterWorkerId = 0;
13826
-
13827
- /**
13828
- * Set the seed.
13829
- * Highly recommended if you don't want people to try to figure out your id schema.
13830
- * exposed as shortid.seed(int)
13831
- * @param seed Integer value to seed the random alphabet. ALWAYS USE THE SAME SEED or you might get overlaps.
13832
- */
13833
- function seed(seedValue) {
13834
- alphabet_1.seed(seedValue);
13835
- return module.exports;
13836
- }
13837
-
13838
- /**
13839
- * Set the cluster worker or machine id
13840
- * exposed as shortid.worker(int)
13841
- * @param workerId worker must be positive integer. Number less than 16 is recommended.
13842
- * returns shortid module so it can be chained.
13843
- */
13844
- function worker(workerId) {
13845
- clusterWorkerId = workerId;
13846
- return module.exports;
13847
- }
13848
-
13849
- /**
13850
- *
13851
- * sets new characters to use in the alphabet
13852
- * returns the shuffled alphabet
13853
- */
13854
- function characters(newCharacters) {
13855
- if (newCharacters !== undefined) {
13856
- alphabet_1.characters(newCharacters);
13857
- }
13858
-
13859
- return alphabet_1.shuffled();
13860
- }
13861
-
13862
- /**
13863
- * Generate unique id
13864
- * Returns string id
13865
- */
13866
- function generate() {
13867
- return build_1(clusterWorkerId);
13868
- }
13869
-
13870
- // Export all other functions as properties of the generate function
13871
- module.exports = generate;
13872
- module.exports.generate = generate;
13873
- module.exports.seed = seed;
13874
- module.exports.worker = worker;
13875
- module.exports.characters = characters;
13876
- module.exports.decode = decode_1;
13877
- module.exports.isValid = isValid;
13878
- });
13879
- lib.generate;
13880
- lib.seed;
13881
- lib.worker;
13882
- lib.characters;
13883
- lib.decode;
13884
- lib.isValid;
13885
-
13886
- var shortid = lib;
13887
-
13888
13703
  const T42JumpListAction = "T42.JumpList.Action";
13889
13704
  class JumpListManager {
13890
13705
  constructor() {
@@ -13974,7 +13789,7 @@
13974
13789
  const updateAction = {
13975
13790
  icon: action.icon,
13976
13791
  callback: action.callback,
13977
- callbackId: shortid.generate(),
13792
+ callbackId: Utils.generateId(),
13978
13793
  singleInstanceTitle: action.singleInstanceTitle,
13979
13794
  multiInstanceTitle: action.multiInstanceTitle,
13980
13795
  operation
@@ -14070,7 +13885,7 @@
14070
13885
  this._windows = {};
14071
13886
  this._pendingWindows = {};
14072
13887
  this._pendingWindowsStates = {};
14073
- this._registry = lib$1();
13888
+ this._registry = lib();
14074
13889
  }
14075
13890
  init(logger) {
14076
13891
  this._logger = logger;
@@ -14190,110 +14005,6 @@
14190
14005
  }
14191
14006
  var windowStore = new WindowStore();
14192
14007
 
14193
- class Utils {
14194
- static getGDMajorVersion() {
14195
- if (typeof window === "undefined") {
14196
- return -1;
14197
- }
14198
- if (!window.glueDesktop) {
14199
- return -1;
14200
- }
14201
- if (!window.glueDesktop.version) {
14202
- return -1;
14203
- }
14204
- const ver = Number(window.glueDesktop.version.substr(0, 1));
14205
- return isNaN(ver) ? -1 : ver;
14206
- }
14207
- static callbackifyPromise(action, successCallback, errorCallback) {
14208
- const fail = (error) => {
14209
- let msg = error;
14210
- if (error instanceof Error) {
14211
- msg = error.message;
14212
- }
14213
- if (typeof errorCallback === "function") {
14214
- errorCallback(msg);
14215
- return;
14216
- }
14217
- return Promise.reject(msg);
14218
- };
14219
- try {
14220
- return action()
14221
- .then((result) => {
14222
- if (typeof successCallback === "function") {
14223
- successCallback(result);
14224
- }
14225
- return result;
14226
- })
14227
- .catch((error) => {
14228
- return fail(error);
14229
- });
14230
- }
14231
- catch (err) {
14232
- return fail(err);
14233
- }
14234
- }
14235
- static getMonitor(bounds, displays) {
14236
- const monitorsSortedByOverlap = displays.map((m) => {
14237
- const { left, top, workingAreaWidth: width, workingAreaHeight: height } = m;
14238
- const overlap = this.calculateTotalOverlap({ left, top, width, height }, bounds);
14239
- return {
14240
- monitor: m,
14241
- totalOverlap: overlap
14242
- };
14243
- }).sort((a, b) => b.totalOverlap - a.totalOverlap);
14244
- return monitorsSortedByOverlap[0].monitor;
14245
- }
14246
- static getDisplayCenterOfScreen(a, currentDisplay, primaryDisplay) {
14247
- const physicalWidth = a.width / currentDisplay.scaleFactor;
14248
- const physicalHeight = a.height / currentDisplay.scaleFactor;
14249
- const physicalDisplayLeft = currentDisplay.workArea.left / primaryDisplay.scaleFactor;
14250
- const physicalDisplayTop = currentDisplay.workArea.top / primaryDisplay.scaleFactor;
14251
- const physicalDisplayWidth = currentDisplay.workArea.width / currentDisplay.scaleFactor;
14252
- const physicalDisplayHeight = currentDisplay.workArea.height / currentDisplay.scaleFactor;
14253
- const physicalHOffset = Math.max((physicalDisplayWidth - physicalWidth) / 2, 0);
14254
- const physicalVOffset = Math.max((physicalDisplayHeight - physicalHeight) / 2, 0);
14255
- const centeredPhysicalLeft = Math.floor(physicalDisplayLeft + physicalHOffset);
14256
- const centeredPhysicalTop = Math.floor(physicalDisplayTop + physicalVOffset);
14257
- const left = centeredPhysicalLeft * primaryDisplay.scaleFactor;
14258
- const top = centeredPhysicalTop * primaryDisplay.scaleFactor;
14259
- return {
14260
- left,
14261
- top,
14262
- width: a.width,
14263
- height: a.height
14264
- };
14265
- }
14266
- static isNode() {
14267
- if (typeof Utils._isNode !== "undefined") {
14268
- return Utils._isNode;
14269
- }
14270
- if (typeof window !== "undefined") {
14271
- Utils._isNode = false;
14272
- return false;
14273
- }
14274
- try {
14275
- Utils._isNode = Object.prototype.toString.call(global.process) === "[object process]";
14276
- }
14277
- catch (e) {
14278
- Utils._isNode = false;
14279
- }
14280
- return Utils._isNode;
14281
- }
14282
- static calculateTotalOverlap(r1, r2) {
14283
- const r1x = r1.left;
14284
- const r1y = r1.top;
14285
- const r1xMax = r1x + r1.width;
14286
- const r1yMax = r1y + r1.height;
14287
- const r2x = r2.left;
14288
- const r2y = r2.top;
14289
- const r2xMax = r2x + r2.width;
14290
- const r2yMax = r2y + r2.height;
14291
- const xOverlap = Math.max(0, Math.min(r1xMax, r2xMax) - Math.max(r1x, r2x));
14292
- const yOverlap = Math.max(0, Math.min(r1yMax, r2yMax) - Math.max(r1y, r2y));
14293
- return xOverlap * yOverlap;
14294
- }
14295
- }
14296
-
14297
14008
  class JumpListActions {
14298
14009
  constructor(windowId, configuration) {
14299
14010
  this.windowId = windowId;
@@ -14359,7 +14070,7 @@
14359
14070
 
14360
14071
  var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, agm) => {
14361
14072
  var _a, _b, _c, _d;
14362
- const _registry = lib$1();
14073
+ const _registry = lib();
14363
14074
  const getChannels = () => {
14364
14075
  const channels = channelsAPIGetter();
14365
14076
  if (!channels) {
@@ -14870,6 +14581,9 @@
14870
14581
  function dock(opts) {
14871
14582
  return executor.dock(resultWindow, opts);
14872
14583
  }
14584
+ async function clone(cloneOptions) {
14585
+ return executor.clone(resultWindow, cloneOptions);
14586
+ }
14873
14587
  function onTitleChanged(callback) {
14874
14588
  if (!isFunction(callback)) {
14875
14589
  throw new Error("callback should be a function");
@@ -15603,6 +15317,7 @@
15603
15317
  getConfiguration,
15604
15318
  getDockingPlacement,
15605
15319
  dock,
15320
+ clone,
15606
15321
  getChannel: async () => {
15607
15322
  var _a;
15608
15323
  const wins = await getChannels().getWindowsWithChannels({ windowIds: [_id] });
@@ -15769,7 +15484,7 @@
15769
15484
  constructor() {
15770
15485
  this.GroupMethodName = "T42.Group.Execute";
15771
15486
  this.WndMethodName = "T42.Wnd.Execute";
15772
- this._registry = lib$1();
15487
+ this._registry = lib();
15773
15488
  this._finished = Promise.resolve();
15774
15489
  this.unsubCallbacks = {};
15775
15490
  }
@@ -16366,7 +16081,7 @@
16366
16081
  }
16367
16082
  showDialog(resultWindow, options) {
16368
16083
  return new Promise((res, rej) => {
16369
- const token = shortid.generate();
16084
+ const token = Utils.generateId();
16370
16085
  const un = this._registry.add("event", (args) => {
16371
16086
  if (args.type === "DialogResult" && args.windowId === resultWindow.id && args.data.token === token) {
16372
16087
  un();
@@ -16421,6 +16136,9 @@
16421
16136
  return this.nonWindowHandlers(callback, gdWindow.id, "OnClosing");
16422
16137
  }
16423
16138
  }
16139
+ onGroupClosing(callback, group) {
16140
+ return this.nonWindowHandlersCore(group.id, "OnClosing", true, callback);
16141
+ }
16424
16142
  onRefreshing(callback, gdWindow) {
16425
16143
  const glue42gd = typeof window !== "undefined" && window.glue42gd;
16426
16144
  if (glue42gd && gdWindow.windowType === "electron") {
@@ -16439,6 +16157,15 @@
16439
16157
  return this.nonWindowHandlers(callback, gdWindow.id, "OnNavigating");
16440
16158
  }
16441
16159
  }
16160
+ async clone(window, cloneOptions) {
16161
+ const args = {
16162
+ windowId: window.id,
16163
+ options: cloneOptions
16164
+ };
16165
+ const result = await this.execute("clone", args);
16166
+ const win = await windowStore.waitFor(result.id);
16167
+ return win.API;
16168
+ }
16442
16169
  async goBack(resultWindow) {
16443
16170
  await this.execute("goBack", { windowId: resultWindow.id });
16444
16171
  }
@@ -16451,21 +16178,45 @@
16451
16178
  dock(window, options) {
16452
16179
  return this.execute("dock", { windowId: window.id, options });
16453
16180
  }
16454
- nonWindowHandlers(callback, winId, type) {
16455
- const id = `${winId}-${type}`;
16181
+ clearCallbacks(id) {
16182
+ const keys = Object.keys(this.unsubCallbacks);
16183
+ keys.forEach((key) => {
16184
+ if (key.startsWith(id)) {
16185
+ delete this.unsubCallbacks[key];
16186
+ }
16187
+ });
16188
+ }
16189
+ nonWindowHandlers(callback, targetId, type) {
16190
+ return this.nonWindowHandlersCore(targetId, type, false, callback);
16191
+ }
16192
+ nonWindowHandlersCore(targetId, type, isGroup, callback) {
16193
+ const id = `${targetId}-${type}`;
16456
16194
  const unsub = () => {
16195
+ var _a;
16457
16196
  if (this.unsubCallbacks[id]) {
16458
16197
  const callbacks = this.unsubCallbacks[id];
16459
16198
  this.unsubCallbacks[id] = callbacks.filter((cb) => cb !== callback);
16199
+ if (this.unsubCallbacks[id].length === 0) {
16200
+ delete this.unsubCallbacks[id];
16201
+ }
16460
16202
  }
16461
- const cbs = this.unsubCallbacks[id];
16203
+ const cbs = (_a = this.unsubCallbacks[id]) !== null && _a !== void 0 ? _a : [];
16462
16204
  if (cbs.length === 0) {
16463
- this.execute(type, {
16464
- windowId: winId,
16465
- options: {
16466
- unsubscribe: true
16467
- }
16468
- });
16205
+ const options = {
16206
+ unsubscribe: true
16207
+ };
16208
+ if (isGroup) {
16209
+ this.executeGroup(type, {
16210
+ groupId: targetId,
16211
+ options
16212
+ });
16213
+ }
16214
+ else {
16215
+ this.execute(type, {
16216
+ windowId: targetId,
16217
+ options
16218
+ });
16219
+ }
16469
16220
  }
16470
16221
  };
16471
16222
  if (this.unsubCallbacks[id]) {
@@ -16475,10 +16226,12 @@
16475
16226
  else {
16476
16227
  this.unsubCallbacks[id] = [callback];
16477
16228
  }
16478
- const args = {
16479
- windowId: winId
16480
- };
16481
- this.execute(type, args);
16229
+ if (isGroup) {
16230
+ this.executeGroup(type, { groupId: targetId });
16231
+ }
16232
+ else {
16233
+ this.execute(type, { windowId: targetId });
16234
+ }
16482
16235
  return unsub;
16483
16236
  }
16484
16237
  reformatFlydownOptions(windowId, options) {
@@ -16575,7 +16328,7 @@
16575
16328
  async executeWithToken(methodName, options) {
16576
16329
  let un;
16577
16330
  try {
16578
- const token = shortid.generate();
16331
+ const token = Utils.generateId();
16579
16332
  const event = new Promise((r) => {
16580
16333
  un = this._registry.add("event", (data) => {
16581
16334
  if (data.token === token) {
@@ -16654,7 +16407,7 @@
16654
16407
 
16655
16408
  class GDEnvironment {
16656
16409
  constructor(agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, wndId) {
16657
- this._registry = lib$1();
16410
+ this._registry = lib();
16658
16411
  this._waitTimeout = 10000;
16659
16412
  this._agm = agm;
16660
16413
  this._logger = logger.subLogger("gd-env");
@@ -17042,7 +16795,7 @@
17042
16795
  };
17043
16796
 
17044
16797
  var groupFactory = (id, executor) => {
17045
- const _registry = lib$1();
16798
+ const _registry = lib();
17046
16799
  const _windowsId = [];
17047
16800
  let _isHibernatedFlag;
17048
16801
  let _isVisible;
@@ -17148,6 +16901,21 @@
17148
16901
  }
17149
16902
  return _registry.add("group-visibility-changed", callback);
17150
16903
  }
16904
+ function onClosing(callback) {
16905
+ if (typeof callback !== "function") {
16906
+ throw new Error("callback must be a function");
16907
+ }
16908
+ const callbackWrap = (success, error, prevent) => {
16909
+ const promise = callback(prevent);
16910
+ if (promise === null || promise === void 0 ? void 0 : promise.then) {
16911
+ promise.then(success).catch(error);
16912
+ }
16913
+ else {
16914
+ success();
16915
+ }
16916
+ };
16917
+ return executor.onGroupClosing(callbackWrap, groupObject);
16918
+ }
17151
16919
  const groupObject = {
17152
16920
  id,
17153
16921
  get windows() {
@@ -17214,7 +16982,8 @@
17214
16982
  onHeaderVisibilityChanged,
17215
16983
  onWindowAdded,
17216
16984
  onWindowRemoved,
17217
- onVisibilityChanged
16985
+ onVisibilityChanged,
16986
+ onClosing,
17218
16987
  };
17219
16988
  const internal = {
17220
16989
  get windows() {
@@ -17233,7 +17002,7 @@
17233
17002
  };
17234
17003
 
17235
17004
  var groupsFactory = (environment, logger) => {
17236
- const _registry = lib$1();
17005
+ const _registry = lib();
17237
17006
  const _groups = {};
17238
17007
  let heardForWindowsCounter = -1;
17239
17008
  const windows = windowStore.list;
@@ -17405,6 +17174,7 @@
17405
17174
  const group = groupWrapper.groupAPI;
17406
17175
  if (group.windows.length === 0) {
17407
17176
  delete _groups[group.id];
17177
+ executor.clearCallbacks(group.id);
17408
17178
  _registry.execute("group-removed", group);
17409
17179
  }
17410
17180
  }
@@ -17484,7 +17254,7 @@
17484
17254
  };
17485
17255
 
17486
17256
  var WindowsFactory = (agm, logger, appManagerGetter, displayAPIGetter, channelsGetter, gdMajorVersion) => {
17487
- const _registry = lib$1();
17257
+ const _registry = lib();
17488
17258
  const _logger = logger;
17489
17259
  let groups;
17490
17260
  let environment;
@@ -18249,7 +18019,7 @@
18249
18019
  invokeMethodAndTrack(methodName, args, resolve, reject, skipStreamEvent) {
18250
18020
  let streamEventReceived = skipStreamEvent;
18251
18021
  let agmResult;
18252
- const token = shortid();
18022
+ const token = Utils.generateId();
18253
18023
  args.token = token;
18254
18024
  const handleResult = () => {
18255
18025
  if (streamEventReceived && agmResult) {
@@ -18491,7 +18261,7 @@
18491
18261
  }
18492
18262
  config.mode = config.mode || "slim";
18493
18263
  const logger = config.logger;
18494
- const callbacks = lib$1();
18264
+ const callbacks = lib();
18495
18265
  let acsStream;
18496
18266
  if (config.mode === "full" || "fullWaitSnapshot") {
18497
18267
  acsStream = new ACSStream(config.agm, callbacks);
@@ -18508,7 +18278,7 @@
18508
18278
  constructor(_agm, _logger) {
18509
18279
  this._agm = _agm;
18510
18280
  this._logger = _logger;
18511
- this._registry = lib$1();
18281
+ this._registry = lib();
18512
18282
  this._registered = false;
18513
18283
  this.all = async () => {
18514
18284
  const displays = await this.callGD(DisplayCommand.GetAll, {});
@@ -18755,7 +18525,7 @@
18755
18525
  this.subsKey = "subs";
18756
18526
  this.changedKey = "changed";
18757
18527
  this.isInitialJoin = true;
18758
- this.registry = lib$1();
18528
+ this.registry = lib();
18759
18529
  this.pendingReplays = {};
18760
18530
  this.shared.subscribe(this.handler.bind(this));
18761
18531
  if (typeof window !== "undefined" && typeof window.glue42gd !== "undefined") {
@@ -18769,7 +18539,7 @@
18769
18539
  if (typeof callback !== "function") {
18770
18540
  throw new Error("Please provide the callback as a function!");
18771
18541
  }
18772
- const id = shortid();
18542
+ const id = Utils.generateId();
18773
18543
  this.pendingReplays[id] = true;
18774
18544
  if (this.lastUpdate) {
18775
18545
  let lastUpdate = Object.assign({}, this.lastUpdate);
@@ -19034,7 +18804,7 @@
19034
18804
  class HotkeysImpl {
19035
18805
  constructor(agm) {
19036
18806
  this.agm = agm;
19037
- this.registry = lib$1();
18807
+ this.registry = lib();
19038
18808
  this.firstHotkey = true;
19039
18809
  this.hotkeys = new Map();
19040
18810
  }
@@ -19114,7 +18884,7 @@
19114
18884
  };
19115
18885
  }
19116
18886
 
19117
- var version = "6.1.0";
18887
+ var version = "6.2.0";
19118
18888
 
19119
18889
  var prepareConfig = (options) => {
19120
18890
  function getLibConfig(value, defaultMode, trueMode) {
@@ -19182,7 +18952,7 @@
19182
18952
  class Glue42Notification {
19183
18953
  constructor(options) {
19184
18954
  this.options = options;
19185
- this.callbacks = lib$1();
18955
+ this.callbacks = lib();
19186
18956
  this.actions = options.actions;
19187
18957
  this.body = options.body;
19188
18958
  this.badge = options.badge;
@@ -19254,10 +19024,10 @@
19254
19024
  this.NotificationsExecuteMethod = "T42.Notifications.Execute";
19255
19025
  this.methodsRegistered = false;
19256
19026
  this.NOTIFICATIONS_CONFIGURE_METHOD_NAME = "T42.Notifications.Configure";
19257
- this.methodNameRoot = "T42.Notifications.Handler-" + shortid();
19027
+ this.methodNameRoot = "T42.Notifications.Handler-" + Utils.generateId();
19258
19028
  this.nextId = 0;
19259
19029
  this.notifications = {};
19260
- this.registry = lib$1();
19030
+ this.registry = lib();
19261
19031
  this.subscribedForNotifications = false;
19262
19032
  this.subscribedCounterStream = false;
19263
19033
  this.subscriptionsCountForNotifications = 0;
@@ -19326,7 +19096,7 @@
19326
19096
  return result.returned;
19327
19097
  }
19328
19098
  async configure(options) {
19329
- var _a, _b, _c, _d, _e, _f;
19099
+ var _a, _b, _c, _d, _e, _f, _g, _h;
19330
19100
  if (!options || Array.isArray(options)) {
19331
19101
  throw new Error("Invalid options - should be an object.");
19332
19102
  }
@@ -19360,6 +19130,15 @@
19360
19130
  if (((_f = options.toasts) === null || _f === void 0 ? void 0 : _f.stackBy) && typeof options.toasts.stackBy !== "string") {
19361
19131
  throw new Error("Expected type of (options.toasts.stackBy - string.");
19362
19132
  }
19133
+ if (options.placement && typeof options.placement !== "object") {
19134
+ throw new Error("Expected type of (options.placement - object.");
19135
+ }
19136
+ if (((_g = options.placement) === null || _g === void 0 ? void 0 : _g.toasts) && typeof options.placement.toasts !== "string") {
19137
+ throw new Error("Expected type of (options.placement.toasts - string.");
19138
+ }
19139
+ if (((_h = options.placement) === null || _h === void 0 ? void 0 : _h.panel) && typeof options.placement.panel !== "string") {
19140
+ throw new Error("Expected type of (options.placement.panel - string.");
19141
+ }
19363
19142
  const result = await this.interop.invoke(this.NOTIFICATIONS_CONFIGURE_METHOD_NAME, options);
19364
19143
  return result.returned;
19365
19144
  }
@@ -19864,7 +19643,7 @@
19864
19643
  constructor(contexts, interop) {
19865
19644
  this.contexts = contexts;
19866
19645
  this.interop = interop;
19867
- this.registry = lib$1();
19646
+ this.registry = lib();
19868
19647
  this.isSubscribed = false;
19869
19648
  this.getConfiguration();
19870
19649
  }
@@ -19941,12 +19720,12 @@
19941
19720
  const INTENTS_RESOLVER_INTEROP_PREFIX = "T42.Intents.Resolver.Control";
19942
19721
  const INTENTS_RESOLVER_WIDTH = 400;
19943
19722
  const INTENTS_RESOLVER_HEIGHT = 440;
19944
- const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60000;
19723
+ const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60 * 1000;
19945
19724
  const INTENT_HANDLER_DEFAULT_PROPS = ["applicationName", "type"];
19946
19725
  const INTENTS_RESOLVER_APP_NAME = "intentsResolver";
19947
- const MAX_SET_TIMEOUT_DELAY = 2147483647;
19948
- const DEFAULT_METHOD_RESPONSE_TIMEOUT_MS = 60000;
19949
- const DEFAULT_RAISE_TIMEOUT_MS = 90000;
19726
+ const DEFAULT_METHOD_RESPONSE_TIMEOUT_MS = 60 * 1000;
19727
+ const DEFAULT_RAISE_TIMEOUT_MS = 90 * 1000;
19728
+ const DEFAULT_PICK_HANDLER_BY_TIMEOUT_MS = 90 * 1000;
19950
19729
 
19951
19730
  const PromisePlus = (executor, timeoutMilliseconds, timeoutMessage) => {
19952
19731
  return new Promise((resolve, reject) => {
@@ -19997,6 +19776,179 @@
19997
19776
  });
19998
19777
  };
19999
19778
 
19779
+ const validateIntentHandlerAsResponse = (handler) => {
19780
+ if (typeof handler !== "object") {
19781
+ return { isValid: false, error: `Response object has invalid 'handler' key. Expected an object, got ${typeof handler}` };
19782
+ }
19783
+ const compulsoryKeysExist = INTENT_HANDLER_DEFAULT_PROPS.filter((key) => !(key in handler));
19784
+ if (compulsoryKeysExist.length) {
19785
+ return { isValid: false, error: `Handler in Response object does not provide compulsory keys: ${compulsoryKeysExist.join(", ")}` };
19786
+ }
19787
+ return { isValid: true, ok: handler };
19788
+ };
19789
+ const validateRaiseIntentsResolverResponse = (responseObj) => {
19790
+ const invalidKey = Object.keys(responseObj).some((key) => key !== "intent" && key !== "handler");
19791
+ if (invalidKey) {
19792
+ return { isValid: false, error: "Response is not a valid object. Expected { intent: string, handler: IntentHandler }" };
19793
+ }
19794
+ if (typeof responseObj.intent !== "string") {
19795
+ return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
19796
+ }
19797
+ const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19798
+ return isValid
19799
+ ? { isValid: true, ok: { intent: responseObj.intent, handler: responseObj.handler } }
19800
+ : { isValid: false, error };
19801
+ };
19802
+ const validateFilterHandlersResolverResponse = (responseObj) => {
19803
+ if (!responseObj.handler) {
19804
+ return { isValid: false, error: "Response is not a valid object. Expected { handler: IntentHandler }" };
19805
+ }
19806
+ const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
19807
+ return isValid
19808
+ ? { isValid: true, ok: { handler: responseObj.handler } }
19809
+ : { isValid: false, error };
19810
+ };
19811
+ const validateIntentRequestTarget = (target) => {
19812
+ if (!target) {
19813
+ return;
19814
+ }
19815
+ if (typeof target !== "string" && typeof target !== "object") {
19816
+ throw new Error(`Please provide the intent target as one of the valid values: "reuse", "startNew", { app: string }, { instance: string } `);
19817
+ }
19818
+ };
19819
+ const validateIntentRequestContext = (context) => {
19820
+ if (!context) {
19821
+ return;
19822
+ }
19823
+ if (typeof context !== "object") {
19824
+ throw new Error(`Please provide the intent context as an object`);
19825
+ }
19826
+ if (context.type && typeof context.type !== "string") {
19827
+ throw new Error(`Please provide the intent context as an object with 'type' property as string`);
19828
+ }
19829
+ if (context.data && typeof context.data !== "object") {
19830
+ throw new Error(`Please provide the intent context as an object with 'data' property as object`);
19831
+ }
19832
+ };
19833
+ const validateIntentRequestHandler = (handler) => {
19834
+ if (!handler.applicationName) {
19835
+ throw new Error(`Please provide applicationName for handler ${JSON.stringify(handler)}`);
19836
+ }
19837
+ if (!handler.type) {
19838
+ throw new Error(`Please provide type for handler ${JSON.stringify(handler)}`);
19839
+ }
19840
+ if (handler.type === "instance" && !handler.instanceId) {
19841
+ throw new Error(`Please provide instanceId for handler ${JSON.stringify(handler)}`);
19842
+ }
19843
+ };
19844
+ const validateIntentRequestTimeout = (timeout) => {
19845
+ if (!timeout) {
19846
+ return;
19847
+ }
19848
+ if (typeof timeout !== "number") {
19849
+ throw new Error(`Please provide the timeout as a number`);
19850
+ }
19851
+ if (timeout <= 0) {
19852
+ throw new Error(`Please provide the timeout as a positive number`);
19853
+ }
19854
+ };
19855
+ const validateWaitUserResponseIndefinitely = (waitUserResponseIndefinitely) => {
19856
+ if (!waitUserResponseIndefinitely) {
19857
+ return;
19858
+ }
19859
+ if (typeof waitUserResponseIndefinitely !== "boolean") {
19860
+ throw new Error("Please provide waitUserResponseIndefinitely as a boolean");
19861
+ }
19862
+ };
19863
+ const validateHandlerFilter = (handlerFilter) => {
19864
+ if (!handlerFilter) {
19865
+ throw new Error(`Provide 'handlerFilter' with at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'`);
19866
+ }
19867
+ const { title, openResolver, timeout, intent, contextTypes, resultType, applicationNames } = handlerFilter;
19868
+ if (typeof title !== "undefined" && (typeof title !== "string" || !title.length)) {
19869
+ throw new Error(`Provide 'title' as a non empty string`);
19870
+ }
19871
+ if (typeof openResolver !== "undefined" && typeof openResolver !== "boolean") {
19872
+ throw new Error(`Provide 'openResolver' prop as a boolean`);
19873
+ }
19874
+ if (typeof timeout !== "undefined" && (typeof timeout !== "number" || timeout <= 0)) {
19875
+ throw new Error(`Provide 'timeout' prop as a positive number`);
19876
+ }
19877
+ if (typeof intent !== "undefined" && (typeof intent !== "string" || !intent.length)) {
19878
+ throw new Error(`Provide 'intent' as a non empty string`);
19879
+ }
19880
+ if (typeof contextTypes !== "undefined" && (!Array.isArray(contextTypes) || contextTypes.some(ctx => typeof ctx !== "string"))) {
19881
+ throw new Error(`Provide 'contextTypes' as an array of non empty strings`);
19882
+ }
19883
+ if (typeof resultType !== "undefined" && (typeof resultType !== "string" || !resultType.length)) {
19884
+ throw new Error(`Provide 'resultType' as a non empty string`);
19885
+ }
19886
+ if (typeof applicationNames !== "undefined" && (!Array.isArray(applicationNames) || applicationNames.some(appName => typeof appName !== "string"))) {
19887
+ throw new Error(`Provide 'applicationNames' as an array of non empty strings`);
19888
+ }
19889
+ const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
19890
+ if (!Object.keys(handlerFilter).length) {
19891
+ throw new Error(errorMsg);
19892
+ }
19893
+ if (!intent && !resultType && (!contextTypes || !contextTypes.length) && (!applicationNames || !applicationNames.length)) {
19894
+ throw new Error(errorMsg);
19895
+ }
19896
+ };
19897
+ const validateIntentsResolverResponse = (method, responseObj) => {
19898
+ return method === "raise" ? validateRaiseIntentsResolverResponse(responseObj) : validateFilterHandlersResolverResponse(responseObj);
19899
+ };
19900
+ const validateIntentRequest = (request) => {
19901
+ validateIntentRequestContext(request.context);
19902
+ validateIntentRequestTarget(request.target);
19903
+ validateIntentRequestTimeout(request.timeout);
19904
+ validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
19905
+ if (request.handlers) {
19906
+ request.handlers.forEach((handler) => validateIntentRequestHandler(handler));
19907
+ }
19908
+ };
19909
+ const validateIntentHandler = (handler) => {
19910
+ if (typeof handler !== "object") {
19911
+ throw new Error("IntentHandler must be an object");
19912
+ }
19913
+ if (typeof handler.applicationName !== "string" || !handler.applicationName.length) {
19914
+ throw new Error(`Please provide 'applicationName' as a non-empty string`);
19915
+ }
19916
+ if (typeof handler.type !== "string" || !["app", "instance"].includes(handler.type)) {
19917
+ throw new Error(`Invalid 'type' property. Expected 'app' | 'instance' got ${handler.type}`);
19918
+ }
19919
+ if (typeof handler.applicationTitle !== "undefined" && typeof handler.applicationTitle !== "string") {
19920
+ throw new Error(`Provide 'applicationTitle' as a string`);
19921
+ }
19922
+ if (typeof handler.applicationDescription !== "undefined" && typeof handler.applicationDescription !== "string") {
19923
+ throw new Error(`Provide 'applicationDescription' as a string`);
19924
+ }
19925
+ if (typeof handler.applicationIcon !== "undefined" && typeof handler.applicationIcon !== "string") {
19926
+ throw new Error(`Provide 'applicationIcon' as a string`);
19927
+ }
19928
+ if (typeof handler.displayName !== "undefined" && typeof handler.displayName !== "string") {
19929
+ throw new Error(`Provide 'displayName' as a string`);
19930
+ }
19931
+ if (typeof handler.contextTypes !== "undefined" && (!Array.isArray(handler.contextTypes) || handler.contextTypes.some(ctx => typeof ctx !== "string"))) {
19932
+ throw new Error(`Provide 'contextTypes' as an array of non empty strings`);
19933
+ }
19934
+ if (typeof handler.instanceId !== "undefined" && typeof handler.instanceId !== "string") {
19935
+ throw new Error(`Provide 'instanceId' as a string`);
19936
+ }
19937
+ if (typeof handler.instanceTitle !== "undefined" && typeof handler.instanceTitle !== "string") {
19938
+ throw new Error(`Provide 'instanceTitle' as a string`);
19939
+ }
19940
+ if (typeof handler.resultType !== "undefined" && typeof handler.resultType !== "string") {
19941
+ throw new Error(`Provide 'resultType' as a string`);
19942
+ }
19943
+ };
19944
+ const clearNullUndefined = (obj) => {
19945
+ Object.keys(obj).forEach(key => {
19946
+ if (obj[key] === null || obj[key] === undefined) {
19947
+ delete obj[key];
19948
+ }
19949
+ });
19950
+ };
19951
+
20000
19952
  class Intents {
20001
19953
  constructor(interop, windows, logger, options, appManager) {
20002
19954
  this.interop = interop;
@@ -20041,7 +19993,7 @@
20041
19993
  if (typeof intentRequest === "string") {
20042
19994
  intentRequest = { intent: intentRequest };
20043
19995
  }
20044
- this.validateIntentRequest(intentRequest);
19996
+ validateIntentRequest(intentRequest);
20045
19997
  await Promise.all(this.unregisterIntentPromises);
20046
19998
  const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
20047
19999
  const resolverInstance = {};
@@ -20213,20 +20165,79 @@
20213
20165
  unsubscribe: () => this.unsubscribeIntent(intentName)
20214
20166
  };
20215
20167
  }
20168
+ async filterHandlers(handlerFilter) {
20169
+ var _a, _b;
20170
+ validateHandlerFilter(handlerFilter);
20171
+ if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
20172
+ throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
20173
+ }
20174
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Received 'filterHandlers' command with request: ${JSON.stringify(handlerFilter)}`);
20175
+ const filteredHandlers = this.filterHandlersBy(await this.all(), handlerFilter);
20176
+ if (!filteredHandlers || !filteredHandlers.length) {
20177
+ return { handlers: [] };
20178
+ }
20179
+ const { open, reason } = this.checkIfResolverShouldBeOpenedForFilterHandlers(filteredHandlers, handlerFilter);
20180
+ if (!open) {
20181
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Intent Resolver UI won't be used. Reason: ${reason}`);
20182
+ return { handlers: filteredHandlers };
20183
+ }
20184
+ const resolverInstance = { instanceId: undefined };
20185
+ const timeout = handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT_MS;
20186
+ const handler = await PromiseWrap(() => this.startResolverApp({ request: handlerFilter, resolverInstance, method: 'filterHandlers' }), timeout, `Timeout of ${timeout}ms hit for 'filterHandlers' request with filter: ${JSON.stringify(handlerFilter)}`);
20187
+ return { handlers: [handler] };
20188
+ }
20189
+ async getIntents(handler) {
20190
+ var _a;
20191
+ this.logger.trace(`Received 'getIntents' command with handler ${JSON.stringify(handler)}`);
20192
+ validateIntentHandler(handler);
20193
+ const intents = await this.all();
20194
+ clearNullUndefined(handler);
20195
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Extracting valid intents for the passed handler`);
20196
+ const intentsWithInfo = this.extractIntentsWithInfoByHandler(intents, handler);
20197
+ this.logger.trace(`Returning intents for handler ${JSON.stringify(handler)}`);
20198
+ return { intents: intentsWithInfo };
20199
+ }
20200
+ filterHandlersBy(intents, filter) {
20201
+ const filteredIntentsWithHandlers = intents.filter((intent) => {
20202
+ if (filter.intent && filter.intent !== intent.name) {
20203
+ return;
20204
+ }
20205
+ if (filter.resultType) {
20206
+ const filteredHandlers = intent.handlers.filter((handler) => handler.resultType && handler.resultType === filter.resultType);
20207
+ if (!filteredHandlers.length)
20208
+ return;
20209
+ intent.handlers = filteredHandlers;
20210
+ }
20211
+ if (filter.contextTypes) {
20212
+ const filteredHandlers = intent.handlers.filter((handler) => { var _a; return (_a = filter.contextTypes) === null || _a === void 0 ? void 0 : _a.every((contextType) => { var _a; return (_a = handler.contextTypes) === null || _a === void 0 ? void 0 : _a.includes(contextType); }); });
20213
+ if (!filteredHandlers.length)
20214
+ return;
20215
+ intent.handlers = filteredHandlers;
20216
+ }
20217
+ if (filter.applicationNames) {
20218
+ const filteredHandlers = intent.handlers.filter((handler) => { var _a; return (_a = filter.applicationNames) === null || _a === void 0 ? void 0 : _a.includes(handler.applicationName); });
20219
+ if (!filteredHandlers.length)
20220
+ return;
20221
+ intent.handlers = filteredHandlers;
20222
+ }
20223
+ return intent;
20224
+ });
20225
+ return filteredIntentsWithHandlers.map((intent) => intent.handlers).flat(1);
20226
+ }
20216
20227
  async coreRaiseIntent({ request, resolverInstance, timeout }) {
20217
20228
  var _a, _b;
20218
20229
  const intentDef = await this.get(request.intent);
20219
20230
  if (typeof intentDef === "undefined") {
20220
20231
  throw new Error(`Intent ${request.intent} not found.`);
20221
20232
  }
20222
- const { open, reason } = this.checkIfResolverShouldBeOpened(intentDef, request);
20233
+ const { open, reason } = this.checkIfResolverShouldBeOpenedForRaise(intentDef, request);
20223
20234
  if (!open) {
20224
20235
  this.logger.trace(`Intent Resolver UI won't be used. Reason: ${reason}`);
20225
20236
  return request.waitUserResponseIndefinitely
20226
20237
  ? PromiseWrap(() => this.raiseIntent(request, timeout), timeout, `Timeout of ${timeout}ms hit for raise to resolve`)
20227
20238
  : this.raiseIntent(request, timeout);
20228
20239
  }
20229
- const resolverHandler = await this.startResolverApp(request, resolverInstance);
20240
+ const resolverHandler = await this.startResolverApp({ request, method: "raise", resolverInstance });
20230
20241
  (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Raising intent to target handler: ${JSON.stringify(resolverHandler)} with timeout of ${timeout}`);
20231
20242
  if (request.waitUserResponseIndefinitely) {
20232
20243
  return PromiseWrap(() => this.raiseIntentToTargetHandler(request, resolverHandler, timeout), timeout, `Timeout of ${timeout}ms hit for raise to resolve`);
@@ -20284,22 +20295,29 @@
20284
20295
  result: result.returned
20285
20296
  };
20286
20297
  }
20287
- async startResolverApp(intentRequest, resolverInstance) {
20298
+ async startResolverApp({ request, method, resolverInstance }) {
20288
20299
  var _a, _b, _c, _d;
20289
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intents Resolver UI with app name ${this.intentsResolverAppName} will be used`);
20290
- const responseMethodName = await this.registerIntentResolverMethod();
20300
+ (_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)}`);
20301
+ const responseMethodName = await this.registerIntentResolverMethod(method);
20291
20302
  (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Registered interop method ${responseMethodName}`);
20292
- const startContext = this.buildStartContext(intentRequest, responseMethodName);
20303
+ const startContext = this.buildStartContext(method, request, responseMethodName);
20293
20304
  const startOptions = await this.buildStartOptions();
20294
20305
  (_c = this.logger) === null || _c === void 0 ? void 0 : _c.trace(`Starting Intents Resolver UI with context: ${JSON.stringify(startContext)} and options: ${JSON.stringify(startOptions)}`);
20295
20306
  const instance = await this.appManager.application(this.intentsResolverAppName).start(startContext, startOptions);
20296
- if (resolverInstance) {
20297
- resolverInstance.instanceId = instance.id;
20298
- }
20307
+ resolverInstance.instanceId = instance.id;
20299
20308
  (_d = this.logger) === null || _d === void 0 ? void 0 : _d.trace(`Intents Resolver instance with id ${instance.id} opened`);
20300
- this.subscribeOnInstanceStopped(instance);
20301
- this.createResponsePromise(intentRequest, instance.id, responseMethodName);
20302
- const handler = await this.handleInstanceResponse(instance.id);
20309
+ this.subscribeOnInstanceStopped(instance, method);
20310
+ const timeout = request.timeout || method === "raise" ? DEFAULT_RAISE_TIMEOUT_MS : DEFAULT_PICK_HANDLER_BY_TIMEOUT_MS;
20311
+ this.createResponsePromise({
20312
+ intent: method === "raise" ? request.intent : undefined,
20313
+ instanceId: instance.id,
20314
+ responseMethodName,
20315
+ timeout,
20316
+ errorMsg: `Timeout of ${timeout}ms hit waiting for the user to choose a handler ${method === "raise"
20317
+ ? `for intent ${request.intent}`
20318
+ : `for '${method}' method with filter ${JSON.stringify(request)}`}`
20319
+ });
20320
+ const handler = await this.handleInstanceResponse(instance.id, method);
20303
20321
  return handler;
20304
20322
  }
20305
20323
  async windowsIdToTitle(id, windowsInfos) {
@@ -20311,43 +20329,43 @@
20311
20329
  const title = await (window === null || window === void 0 ? void 0 : window.getTitle());
20312
20330
  return title;
20313
20331
  }
20314
- async handleInstanceResponse(instanceId) {
20315
- var _a;
20332
+ async handleInstanceResponse(instanceId, method) {
20333
+ var _a, _b;
20316
20334
  try {
20317
- const { handler, intent } = await this.intentsResolverResponsePromises[instanceId].promise;
20318
- (_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intent handler chosen for intent ${intent}: ${JSON.stringify(handler)}`);
20335
+ const response = await this.intentsResolverResponsePromises[instanceId].promise;
20336
+ (_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}`);
20319
20337
  this.stopResolverInstance(instanceId);
20320
- return handler;
20338
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Instance with id ${instanceId} successfully stopped`);
20339
+ return response.handler;
20321
20340
  }
20322
20341
  catch (error) {
20323
20342
  this.stopResolverInstance(instanceId);
20324
20343
  throw new Error(error);
20325
20344
  }
20326
20345
  }
20327
- async registerIntentResolverMethod() {
20328
- const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + shortid();
20329
- await this.interop.register(methodName, this.resolverResponseHandler.bind(this));
20346
+ async registerIntentResolverMethod(method) {
20347
+ const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + Utils.generateId();
20348
+ await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId, method));
20330
20349
  return methodName;
20331
20350
  }
20332
- resolverResponseHandler(args, callerId) {
20351
+ resolverResponseHandler(args, callerId, method) {
20333
20352
  const { instance } = callerId;
20334
- const isValid = this.validateIntentsResolverResponse(args);
20353
+ const isValid = validateIntentsResolverResponse(method, args);
20335
20354
  if (!isValid) {
20336
- this.logger.trace(`Intent Resolver sent invalid response. Error: ${isValid.error}`);
20355
+ this.logger.trace(`Intent Resolver instance with id ${callerId.instance} sent invalid response. Error: ${isValid.error}`);
20337
20356
  this.intentsResolverResponsePromises[instance].reject(isValid.error);
20338
20357
  this.stopResolverInstance(instance);
20358
+ return;
20339
20359
  }
20340
20360
  const validResponse = isValid.ok;
20341
20361
  this.intentsResolverResponsePromises[instance].resolve(validResponse);
20342
20362
  this.cleanUpIntentResolverPromise(instance);
20343
20363
  }
20344
- buildStartContext(request, methodName) {
20345
- const startContext = {
20346
- intent: request,
20347
- callerId: this.interop.instance.instance,
20348
- methodName
20349
- };
20350
- return startContext;
20364
+ buildStartContext(method, request, methodName) {
20365
+ const baseStartContext = { callerId: this.interop.instance.instance, methodName };
20366
+ return method === "raise"
20367
+ ? { ...baseStartContext, intent: request }
20368
+ : { ...baseStartContext, handlerFilter: request };
20351
20369
  }
20352
20370
  async buildStartOptions() {
20353
20371
  const win = this.windows.my();
@@ -20358,29 +20376,35 @@
20358
20376
  return {
20359
20377
  top: (bounds.height - INTENTS_RESOLVER_HEIGHT) / 2 + bounds.top,
20360
20378
  left: (bounds.width - INTENTS_RESOLVER_WIDTH) / 2 + bounds.left,
20379
+ width: INTENTS_RESOLVER_WIDTH,
20380
+ height: INTENTS_RESOLVER_HEIGHT
20361
20381
  };
20362
20382
  }
20363
- createResponsePromise(intentRequest, instanceId, methodName) {
20364
- let resolve;
20365
- let reject;
20366
- const waitResponseTimeout = intentRequest.waitUserResponseIndefinitely ? MAX_SET_TIMEOUT_DELAY : this.intentsResolverResponseTimeout;
20383
+ createResponsePromise({ instanceId, intent, responseMethodName, timeout, errorMsg }) {
20384
+ let resolve = () => { };
20385
+ let reject = () => { };
20367
20386
  const promise = PromisePlus((res, rej) => {
20368
20387
  resolve = res;
20369
20388
  reject = rej;
20370
- }, waitResponseTimeout, `Timeout of ${waitResponseTimeout}ms hit waiting for the user to choose a handler for intent ${intentRequest.intent}`);
20371
- this.intentsResolverResponsePromises[instanceId] = { intent: intentRequest.intent, resolve, reject, promise, methodName };
20389
+ }, timeout, errorMsg);
20390
+ this.intentsResolverResponsePromises[instanceId] = { intent, resolve, reject, promise, methodName: responseMethodName };
20372
20391
  }
20373
20392
  async invokeStartApp(application, context, options) {
20374
20393
  const result = await this.interop.invoke("T42.ACS.StartApplication", { Name: application, options });
20375
20394
  return result.returned.Id;
20376
20395
  }
20377
- subscribeOnInstanceStopped(instance) {
20378
- const unsub = instance.onStopped((inst) => {
20396
+ subscribeOnInstanceStopped(instance, method) {
20397
+ const { application } = instance;
20398
+ const unsub = application.onInstanceStopped((inst) => {
20399
+ if (inst.id !== instance.id) {
20400
+ return;
20401
+ }
20379
20402
  const intentPromise = this.intentsResolverResponsePromises[inst.id];
20380
20403
  if (!intentPromise) {
20381
20404
  return unsub();
20382
20405
  }
20383
- intentPromise.reject(`Cannot resolve raise intent ${intentPromise.intent} - User closed ${this.intentsResolverAppName} app without choosing an intent handler`);
20406
+ const errorMsg = `Cannot resolve ${method === "raise" ? `raised intent ${intentPromise.intent}` : `'${method}' method`} - User closed ${instance.application.name} app without choosing a handler`;
20407
+ intentPromise.reject(errorMsg);
20384
20408
  this.cleanUpIntentResolverPromise(inst.id);
20385
20409
  unsub();
20386
20410
  });
@@ -20394,23 +20418,6 @@
20394
20418
  unregisterPromise.catch((error) => this.logger.warn(error));
20395
20419
  delete this.intentsResolverResponsePromises[instanceId];
20396
20420
  }
20397
- validateIntentsResolverResponse(responseObj) {
20398
- const invalidKey = Object.keys(responseObj).some((key) => key !== "intent" && key !== "handler");
20399
- if (invalidKey) {
20400
- return { isValid: false, error: "Response is not a valid object. Expected { intent: string, handler: IntentHandler }" };
20401
- }
20402
- if (typeof responseObj.intent !== "string") {
20403
- return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
20404
- }
20405
- if (typeof responseObj.handler !== "object") {
20406
- return { isValid: false, error: `Response object has invalid 'handler' key. Expected an object, got ${typeof responseObj.handler}` };
20407
- }
20408
- const compulsoryKeysExist = INTENT_HANDLER_DEFAULT_PROPS.filter((key) => !(key in responseObj.handler));
20409
- if (compulsoryKeysExist.length) {
20410
- return { isValid: false, error: `Handler in Response object does not provide compulsory keys: ${compulsoryKeysExist.join(", ")}` };
20411
- }
20412
- return { isValid: true, ok: { intent: responseObj.intent, handler: { ...responseObj.handler } } };
20413
- }
20414
20421
  handleRaiseOnError(instanceId) {
20415
20422
  if (!instanceId) {
20416
20423
  return;
@@ -20433,18 +20440,34 @@
20433
20440
  this.intentsResolverAppName = (_c = (_b = options.intents) === null || _b === void 0 ? void 0 : _b.intentsResolverAppName) !== null && _c !== void 0 ? _c : INTENTS_RESOLVER_APP_NAME;
20434
20441
  this.intentsResolverResponseTimeout = (_e = (_d = options.intents) === null || _d === void 0 ? void 0 : _d.methodResponseTimeoutMs) !== null && _e !== void 0 ? _e : DEFAULT_RESOLVER_RESPONSE_TIMEOUT;
20435
20442
  }
20436
- checkIfResolverShouldBeOpened(intent, request) {
20443
+ checkIfResolverShouldBeOpenedForRaise(intent, request) {
20444
+ const checkOpen = this.checkIfIntentsResolverShouldBeOpened();
20445
+ if (!checkOpen.open) {
20446
+ return checkOpen;
20447
+ }
20448
+ const hasMoreThanOneHandler = this.checkIfIntentHasMoreThanOneHandler(intent, request);
20449
+ if (!hasMoreThanOneHandler) {
20450
+ return { open: false, reason: `Raised intent ${intent.name} has only one handler` };
20451
+ }
20452
+ return { open: true };
20453
+ }
20454
+ checkIfResolverShouldBeOpenedForFilterHandlers(handlers, filter) {
20455
+ if (handlers.length === 1) {
20456
+ return { open: false, reason: `There's only one valid intent handler for filter ${JSON.stringify(filter)}` };
20457
+ }
20458
+ if (typeof (filter === null || filter === void 0 ? void 0 : filter.openResolver) === "boolean" && !filter.openResolver) {
20459
+ return { open: false, reason: "Intents resolver is disabled by IntentHandler filter" };
20460
+ }
20461
+ return this.checkIfIntentsResolverShouldBeOpened();
20462
+ }
20463
+ checkIfIntentsResolverShouldBeOpened() {
20437
20464
  if (!this.useIntentsResolverUI) {
20438
- return { open: false, reason: `Intent Resolver is disabled. Raising intent to first found handler` };
20465
+ return { open: false, reason: `Intent Resolver is disabled. Resolving to first found handler` };
20439
20466
  }
20440
20467
  const intentsResolverApp = this.appManager.application(this.intentsResolverAppName);
20441
20468
  if (!intentsResolverApp) {
20442
20469
  return { open: false, reason: `Intent Resolver Application with name ${this.intentsResolverAppName} not found.` };
20443
20470
  }
20444
- const hasMoreThanOneHandler = this.checkIfIntentHasMoreThanOneHandler(intent, request);
20445
- if (!hasMoreThanOneHandler) {
20446
- return { open: false, reason: `Raised intent ${intent.name} has only one handler` };
20447
- }
20448
20471
  return { open: true };
20449
20472
  }
20450
20473
  checkIfIntentHasMoreThanOneHandler(intent, request) {
@@ -20488,67 +20511,6 @@
20488
20511
  this.clearUnregistrationPromise(unregisterPromise);
20489
20512
  });
20490
20513
  }
20491
- validateIntentRequest(request) {
20492
- this.validateIntentRequestContext(request.context);
20493
- this.validateIntentRequestTarget(request.target);
20494
- this.validateIntentRequestTimeout(request.timeout);
20495
- this.validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
20496
- if (request.handlers) {
20497
- request.handlers.forEach((handler) => this.validateIntentRequestHandler(handler));
20498
- }
20499
- }
20500
- validateIntentRequestTarget(target) {
20501
- if (!target) {
20502
- return;
20503
- }
20504
- if (typeof target !== "string" && typeof target !== "object") {
20505
- throw new Error(`Please provide the intent target as one of the valid values: "reuse", "startNew", { app: string }, { instance: string } `);
20506
- }
20507
- }
20508
- validateIntentRequestContext(context) {
20509
- if (!context) {
20510
- return;
20511
- }
20512
- if (typeof context !== "object") {
20513
- throw new Error(`Please provide the intent context as an object`);
20514
- }
20515
- if (context.type && typeof context.type !== "string") {
20516
- throw new Error(`Please provide the intent context as an object with 'type' property as string`);
20517
- }
20518
- if (context.data && typeof context.data !== "object") {
20519
- throw new Error(`Please provide the intent context as an object with 'data' property as object`);
20520
- }
20521
- }
20522
- validateIntentRequestHandler(handler) {
20523
- if (!handler.applicationName) {
20524
- throw new Error(`Please provide applicationName for handler ${JSON.stringify(handler)}`);
20525
- }
20526
- if (!handler.type) {
20527
- throw new Error(`Please provide type for handler ${JSON.stringify(handler)}`);
20528
- }
20529
- if (handler.type === "instance" && !handler.instanceId) {
20530
- throw new Error(`Please provide instanceId for handler ${JSON.stringify(handler)}`);
20531
- }
20532
- }
20533
- validateIntentRequestTimeout(timeout) {
20534
- if (!timeout) {
20535
- return;
20536
- }
20537
- if (typeof timeout !== "number") {
20538
- throw new Error(`Please provide the timeout as a number`);
20539
- }
20540
- if (timeout <= 0) {
20541
- throw new Error(`Please provide the timeout as a positive number`);
20542
- }
20543
- }
20544
- validateWaitUserResponseIndefinitely(waitUserResponseIndefinitely) {
20545
- if (!waitUserResponseIndefinitely) {
20546
- return;
20547
- }
20548
- if (typeof waitUserResponseIndefinitely !== "boolean") {
20549
- throw new Error("Please provide waitUserResponseIndefinitely as a boolean");
20550
- }
20551
- }
20552
20514
  findHandlerByFilter(handlers, filter) {
20553
20515
  if (filter.type) {
20554
20516
  return handlers.find((handler) => handler.type === filter.type);
@@ -20562,6 +20524,32 @@
20562
20524
  return handlers.find((handler) => handler.applicationName === filter.app);
20563
20525
  }
20564
20526
  }
20527
+ extractIntentsWithInfoByHandler(intents, handler) {
20528
+ const intentsWithInfo = intents.reduce((validIntentsWithInfo, intent) => {
20529
+ intent.handlers.forEach((currentHandler) => {
20530
+ const isValid = Object.keys(handler).every((key) => {
20531
+ var _a;
20532
+ return key === "contextTypes"
20533
+ ? (_a = handler.contextTypes) === null || _a === void 0 ? void 0 : _a.every((contextType) => { var _a; return (_a = currentHandler.contextTypes) === null || _a === void 0 ? void 0 : _a.includes(contextType); })
20534
+ : currentHandler[key] === handler[key];
20535
+ });
20536
+ if (!isValid) {
20537
+ return;
20538
+ }
20539
+ const intentWithInfo = {
20540
+ intent: intent.name,
20541
+ contextTypes: currentHandler.contextTypes,
20542
+ description: currentHandler.applicationDescription,
20543
+ displayName: currentHandler.displayName,
20544
+ icon: currentHandler.applicationIcon,
20545
+ resultType: currentHandler.resultType
20546
+ };
20547
+ validIntentsWithInfo.push(intentWithInfo);
20548
+ });
20549
+ return validIntentsWithInfo;
20550
+ }, []);
20551
+ return intentsWithInfo;
20552
+ }
20565
20553
  }
20566
20554
 
20567
20555
  class FactoryCallInfo {
@@ -20594,7 +20582,7 @@
20594
20582
  constructor(appName, interop) {
20595
20583
  this.appName = appName;
20596
20584
  this.interop = interop;
20597
- this.registry = lib$1();
20585
+ this.registry = lib();
20598
20586
  this.interopMethodRegistered = false;
20599
20587
  }
20600
20588
  async get(app) {