@interopio/desktop 6.0.2 → 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.
- package/changelog.md +27 -12
- package/desktop.d.ts +226 -7
- package/dist/desktop.browser.js +841 -708
- package/dist/desktop.browser.js.map +1 -1
- package/dist/desktop.browser.min.js +1 -1
- package/dist/desktop.browser.min.js.map +1 -1
- package/dist/desktop.es.js +841 -708
- package/dist/desktop.es.js.map +1 -1
- package/dist/desktop.umd.js +841 -708
- package/dist/desktop.umd.js.map +1 -1
- package/dist/desktop.umd.min.js +1 -1
- package/dist/desktop.umd.min.js.map +1 -1
- package/package.json +4 -6
- package/dist/desktop.umd.js.7z +0 -0
package/dist/desktop.es.js
CHANGED
|
@@ -1025,12 +1025,12 @@ function createRegistry$1(options) {
|
|
|
1025
1025
|
};
|
|
1026
1026
|
}
|
|
1027
1027
|
createRegistry$1.default = createRegistry$1;
|
|
1028
|
-
var lib$1
|
|
1028
|
+
var lib$1 = createRegistry$1;
|
|
1029
1029
|
|
|
1030
1030
|
var InProcTransport = (function () {
|
|
1031
1031
|
function InProcTransport(settings, logger) {
|
|
1032
1032
|
var _this = this;
|
|
1033
|
-
this.registry = lib$1
|
|
1033
|
+
this.registry = lib$1();
|
|
1034
1034
|
this.gw = settings.facade;
|
|
1035
1035
|
this.gw.connect(function (_client, message) {
|
|
1036
1036
|
_this.messageHandler(message);
|
|
@@ -1086,7 +1086,7 @@ var SharedWorkerTransport = (function () {
|
|
|
1086
1086
|
function SharedWorkerTransport(workerFile, logger) {
|
|
1087
1087
|
var _this = this;
|
|
1088
1088
|
this.logger = logger;
|
|
1089
|
-
this.registry = lib$1
|
|
1089
|
+
this.registry = lib$1();
|
|
1090
1090
|
this.worker = new SharedWorker(workerFile);
|
|
1091
1091
|
this.worker.port.onmessage = function (e) {
|
|
1092
1092
|
_this.messageHandler(e.data);
|
|
@@ -1236,7 +1236,7 @@ var WS = (function () {
|
|
|
1236
1236
|
function WS(settings, logger) {
|
|
1237
1237
|
this.startupTimer = timer("connection");
|
|
1238
1238
|
this._running = true;
|
|
1239
|
-
this._registry = lib$1
|
|
1239
|
+
this._registry = lib$1();
|
|
1240
1240
|
this.wsRequests = [];
|
|
1241
1241
|
this.settings = settings;
|
|
1242
1242
|
this.logger = logger;
|
|
@@ -1427,44 +1427,44 @@ var lib$2 = {
|
|
|
1427
1427
|
// Found this seed-based random generator somewhere
|
|
1428
1428
|
// Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
|
|
1429
1429
|
|
|
1430
|
-
var seed
|
|
1430
|
+
var seed = 1;
|
|
1431
1431
|
|
|
1432
1432
|
/**
|
|
1433
1433
|
* return a random number based on a seed
|
|
1434
1434
|
* @param seed
|
|
1435
1435
|
* @returns {number}
|
|
1436
1436
|
*/
|
|
1437
|
-
function getNextValue
|
|
1438
|
-
seed
|
|
1439
|
-
return seed
|
|
1437
|
+
function getNextValue() {
|
|
1438
|
+
seed = (seed * 9301 + 49297) % 233280;
|
|
1439
|
+
return seed/(233280.0);
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
|
-
function setSeed$1
|
|
1443
|
-
seed
|
|
1442
|
+
function setSeed$1(_seed_) {
|
|
1443
|
+
seed = _seed_;
|
|
1444
1444
|
}
|
|
1445
1445
|
|
|
1446
1446
|
var randomFromSeed$1 = {
|
|
1447
|
-
nextValue: getNextValue
|
|
1448
|
-
seed: setSeed$1
|
|
1447
|
+
nextValue: getNextValue,
|
|
1448
|
+
seed: setSeed$1
|
|
1449
1449
|
};
|
|
1450
1450
|
|
|
1451
|
-
var randomFromSeed
|
|
1451
|
+
var randomFromSeed = randomFromSeed$1;
|
|
1452
1452
|
|
|
1453
|
-
var ORIGINAL
|
|
1453
|
+
var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-';
|
|
1454
1454
|
var alphabet$2;
|
|
1455
|
-
var previousSeed
|
|
1455
|
+
var previousSeed;
|
|
1456
1456
|
|
|
1457
|
-
var shuffled
|
|
1457
|
+
var shuffled;
|
|
1458
1458
|
|
|
1459
|
-
function reset
|
|
1460
|
-
shuffled
|
|
1459
|
+
function reset() {
|
|
1460
|
+
shuffled = false;
|
|
1461
1461
|
}
|
|
1462
1462
|
|
|
1463
|
-
function setCharacters
|
|
1463
|
+
function setCharacters(_alphabet_) {
|
|
1464
1464
|
if (!_alphabet_) {
|
|
1465
|
-
if (alphabet$2 !== ORIGINAL
|
|
1466
|
-
alphabet$2 = ORIGINAL
|
|
1467
|
-
reset
|
|
1465
|
+
if (alphabet$2 !== ORIGINAL) {
|
|
1466
|
+
alphabet$2 = ORIGINAL;
|
|
1467
|
+
reset();
|
|
1468
1468
|
}
|
|
1469
1469
|
return;
|
|
1470
1470
|
}
|
|
@@ -1473,8 +1473,8 @@ function setCharacters$1(_alphabet_) {
|
|
|
1473
1473
|
return;
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
|
-
if (_alphabet_.length !== ORIGINAL
|
|
1477
|
-
throw new Error('Custom alphabet for shortid must be ' + ORIGINAL
|
|
1476
|
+
if (_alphabet_.length !== ORIGINAL.length) {
|
|
1477
|
+
throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_);
|
|
1478
1478
|
}
|
|
1479
1479
|
|
|
1480
1480
|
var unique = _alphabet_.split('').filter(function(item, ind, arr){
|
|
@@ -1482,50 +1482,50 @@ function setCharacters$1(_alphabet_) {
|
|
|
1482
1482
|
});
|
|
1483
1483
|
|
|
1484
1484
|
if (unique.length) {
|
|
1485
|
-
throw new Error('Custom alphabet for shortid must be ' + ORIGINAL
|
|
1485
|
+
throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', '));
|
|
1486
1486
|
}
|
|
1487
1487
|
|
|
1488
1488
|
alphabet$2 = _alphabet_;
|
|
1489
|
-
reset
|
|
1489
|
+
reset();
|
|
1490
1490
|
}
|
|
1491
1491
|
|
|
1492
|
-
function characters
|
|
1493
|
-
setCharacters
|
|
1492
|
+
function characters(_alphabet_) {
|
|
1493
|
+
setCharacters(_alphabet_);
|
|
1494
1494
|
return alphabet$2;
|
|
1495
1495
|
}
|
|
1496
1496
|
|
|
1497
|
-
function setSeed
|
|
1498
|
-
randomFromSeed
|
|
1499
|
-
if (previousSeed
|
|
1500
|
-
reset
|
|
1501
|
-
previousSeed
|
|
1497
|
+
function setSeed(seed) {
|
|
1498
|
+
randomFromSeed.seed(seed);
|
|
1499
|
+
if (previousSeed !== seed) {
|
|
1500
|
+
reset();
|
|
1501
|
+
previousSeed = seed;
|
|
1502
1502
|
}
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
|
-
function shuffle
|
|
1505
|
+
function shuffle() {
|
|
1506
1506
|
if (!alphabet$2) {
|
|
1507
|
-
setCharacters
|
|
1507
|
+
setCharacters(ORIGINAL);
|
|
1508
1508
|
}
|
|
1509
1509
|
|
|
1510
1510
|
var sourceArray = alphabet$2.split('');
|
|
1511
1511
|
var targetArray = [];
|
|
1512
|
-
var r = randomFromSeed
|
|
1512
|
+
var r = randomFromSeed.nextValue();
|
|
1513
1513
|
var characterIndex;
|
|
1514
1514
|
|
|
1515
1515
|
while (sourceArray.length > 0) {
|
|
1516
|
-
r = randomFromSeed
|
|
1516
|
+
r = randomFromSeed.nextValue();
|
|
1517
1517
|
characterIndex = Math.floor(r * sourceArray.length);
|
|
1518
1518
|
targetArray.push(sourceArray.splice(characterIndex, 1)[0]);
|
|
1519
1519
|
}
|
|
1520
1520
|
return targetArray.join('');
|
|
1521
1521
|
}
|
|
1522
1522
|
|
|
1523
|
-
function getShuffled
|
|
1524
|
-
if (shuffled
|
|
1525
|
-
return shuffled
|
|
1523
|
+
function getShuffled() {
|
|
1524
|
+
if (shuffled) {
|
|
1525
|
+
return shuffled;
|
|
1526
1526
|
}
|
|
1527
|
-
shuffled
|
|
1528
|
-
return shuffled
|
|
1527
|
+
shuffled = shuffle();
|
|
1528
|
+
return shuffled;
|
|
1529
1529
|
}
|
|
1530
1530
|
|
|
1531
1531
|
/**
|
|
@@ -1533,29 +1533,29 @@ function getShuffled$1() {
|
|
|
1533
1533
|
* @param index
|
|
1534
1534
|
* @returns {string}
|
|
1535
1535
|
*/
|
|
1536
|
-
function lookup
|
|
1537
|
-
var alphabetShuffled = getShuffled
|
|
1536
|
+
function lookup(index) {
|
|
1537
|
+
var alphabetShuffled = getShuffled();
|
|
1538
1538
|
return alphabetShuffled[index];
|
|
1539
1539
|
}
|
|
1540
1540
|
|
|
1541
1541
|
function get () {
|
|
1542
|
-
return alphabet$2 || ORIGINAL
|
|
1542
|
+
return alphabet$2 || ORIGINAL;
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
1545
|
-
var alphabet_1
|
|
1545
|
+
var alphabet_1 = {
|
|
1546
1546
|
get: get,
|
|
1547
|
-
characters: characters
|
|
1548
|
-
seed: setSeed
|
|
1549
|
-
lookup: lookup
|
|
1550
|
-
shuffled: getShuffled
|
|
1547
|
+
characters: characters,
|
|
1548
|
+
seed: setSeed,
|
|
1549
|
+
lookup: lookup,
|
|
1550
|
+
shuffled: getShuffled
|
|
1551
1551
|
};
|
|
1552
1552
|
|
|
1553
|
-
var crypto
|
|
1553
|
+
var crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto
|
|
1554
1554
|
|
|
1555
|
-
var randomByte
|
|
1555
|
+
var randomByte;
|
|
1556
1556
|
|
|
1557
|
-
if (!crypto
|
|
1558
|
-
randomByte
|
|
1557
|
+
if (!crypto || !crypto.getRandomValues) {
|
|
1558
|
+
randomByte = function(size) {
|
|
1559
1559
|
var bytes = [];
|
|
1560
1560
|
for (var i = 0; i < size; i++) {
|
|
1561
1561
|
bytes.push(Math.floor(Math.random() * 256));
|
|
@@ -1563,12 +1563,12 @@ if (!crypto$1 || !crypto$1.getRandomValues) {
|
|
|
1563
1563
|
return bytes;
|
|
1564
1564
|
};
|
|
1565
1565
|
} else {
|
|
1566
|
-
randomByte
|
|
1567
|
-
return crypto
|
|
1566
|
+
randomByte = function(size) {
|
|
1567
|
+
return crypto.getRandomValues(new Uint8Array(size));
|
|
1568
1568
|
};
|
|
1569
1569
|
}
|
|
1570
1570
|
|
|
1571
|
-
var randomByteBrowser
|
|
1571
|
+
var randomByteBrowser = randomByte;
|
|
1572
1572
|
|
|
1573
1573
|
// This file replaces `format.js` in bundlers like webpack or Rollup,
|
|
1574
1574
|
// according to `browser` config in `package.json`.
|
|
@@ -1611,8 +1611,8 @@ var format_browser = function (random, alphabet, size) {
|
|
|
1611
1611
|
}
|
|
1612
1612
|
};
|
|
1613
1613
|
|
|
1614
|
-
var alphabet$1 = alphabet_1
|
|
1615
|
-
var random = randomByteBrowser
|
|
1614
|
+
var alphabet$1 = alphabet_1;
|
|
1615
|
+
var random = randomByteBrowser;
|
|
1616
1616
|
var format = format_browser;
|
|
1617
1617
|
|
|
1618
1618
|
function generate$1(number) {
|
|
@@ -1636,65 +1636,65 @@ var generate = generate_1;
|
|
|
1636
1636
|
// Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness.
|
|
1637
1637
|
// This number should be updated every year or so to keep the generated id short.
|
|
1638
1638
|
// To regenerate `new Date() - 0` and bump the version. Always bump the version!
|
|
1639
|
-
var REDUCE_TIME
|
|
1639
|
+
var REDUCE_TIME = 1567752802062;
|
|
1640
1640
|
|
|
1641
1641
|
// don't change unless we change the algos or REDUCE_TIME
|
|
1642
1642
|
// must be an integer and less than 16
|
|
1643
|
-
var version$1
|
|
1643
|
+
var version$1 = 7;
|
|
1644
1644
|
|
|
1645
1645
|
// Counter is used when shortid is called multiple times in one second.
|
|
1646
|
-
var counter
|
|
1646
|
+
var counter;
|
|
1647
1647
|
|
|
1648
1648
|
// Remember the last time shortid was called in case counter is needed.
|
|
1649
|
-
var previousSeconds
|
|
1649
|
+
var previousSeconds;
|
|
1650
1650
|
|
|
1651
1651
|
/**
|
|
1652
1652
|
* Generate unique id
|
|
1653
1653
|
* Returns string id
|
|
1654
1654
|
*/
|
|
1655
|
-
function build
|
|
1655
|
+
function build(clusterWorkerId) {
|
|
1656
1656
|
var str = '';
|
|
1657
1657
|
|
|
1658
|
-
var seconds = Math.floor((Date.now() - REDUCE_TIME
|
|
1658
|
+
var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001);
|
|
1659
1659
|
|
|
1660
|
-
if (seconds === previousSeconds
|
|
1661
|
-
counter
|
|
1660
|
+
if (seconds === previousSeconds) {
|
|
1661
|
+
counter++;
|
|
1662
1662
|
} else {
|
|
1663
|
-
counter
|
|
1664
|
-
previousSeconds
|
|
1663
|
+
counter = 0;
|
|
1664
|
+
previousSeconds = seconds;
|
|
1665
1665
|
}
|
|
1666
1666
|
|
|
1667
|
-
str = str + generate(version$1
|
|
1667
|
+
str = str + generate(version$1);
|
|
1668
1668
|
str = str + generate(clusterWorkerId);
|
|
1669
|
-
if (counter
|
|
1670
|
-
str = str + generate(counter
|
|
1669
|
+
if (counter > 0) {
|
|
1670
|
+
str = str + generate(counter);
|
|
1671
1671
|
}
|
|
1672
1672
|
str = str + generate(seconds);
|
|
1673
1673
|
return str;
|
|
1674
1674
|
}
|
|
1675
1675
|
|
|
1676
|
-
var build_1
|
|
1676
|
+
var build_1 = build;
|
|
1677
1677
|
|
|
1678
|
-
var alphabet
|
|
1678
|
+
var alphabet = alphabet_1;
|
|
1679
1679
|
|
|
1680
|
-
function isShortId
|
|
1680
|
+
function isShortId(id) {
|
|
1681
1681
|
if (!id || typeof id !== 'string' || id.length < 6 ) {
|
|
1682
1682
|
return false;
|
|
1683
1683
|
}
|
|
1684
1684
|
|
|
1685
1685
|
var nonAlphabetic = new RegExp('[^' +
|
|
1686
|
-
alphabet
|
|
1686
|
+
alphabet.get().replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&') +
|
|
1687
1687
|
']');
|
|
1688
1688
|
return !nonAlphabetic.test(id);
|
|
1689
1689
|
}
|
|
1690
1690
|
|
|
1691
|
-
var isValid
|
|
1691
|
+
var isValid = isShortId;
|
|
1692
1692
|
|
|
1693
1693
|
(function (module) {
|
|
1694
1694
|
|
|
1695
|
-
var alphabet = alphabet_1
|
|
1696
|
-
var build = build_1
|
|
1697
|
-
var isValid$1
|
|
1695
|
+
var alphabet = alphabet_1;
|
|
1696
|
+
var build = build_1;
|
|
1697
|
+
var isValid$1 = isValid;
|
|
1698
1698
|
|
|
1699
1699
|
// if you are using cluster or multiple servers use this to make each instance
|
|
1700
1700
|
// has a unique value for worker
|
|
@@ -1751,14 +1751,14 @@ var isValid$1 = isShortId$1;
|
|
|
1751
1751
|
module.exports.seed = seed;
|
|
1752
1752
|
module.exports.worker = worker;
|
|
1753
1753
|
module.exports.characters = characters;
|
|
1754
|
-
module.exports.isValid = isValid$1
|
|
1754
|
+
module.exports.isValid = isValid$1;
|
|
1755
1755
|
} (lib$2));
|
|
1756
1756
|
|
|
1757
1757
|
(function (module) {
|
|
1758
1758
|
module.exports = libExports;
|
|
1759
1759
|
} (shortid$1));
|
|
1760
1760
|
|
|
1761
|
-
var shortid
|
|
1761
|
+
var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
|
|
1762
1762
|
|
|
1763
1763
|
function domainSession (domain, connection, logger, successMessages, errorMessages) {
|
|
1764
1764
|
if (domain == null) {
|
|
@@ -1770,7 +1770,7 @@ function domainSession (domain, connection, logger, successMessages, errorMessag
|
|
|
1770
1770
|
var tryReconnecting = false;
|
|
1771
1771
|
var _latestOptions;
|
|
1772
1772
|
var _connectionOn = false;
|
|
1773
|
-
var callbacks = lib$1
|
|
1773
|
+
var callbacks = lib$1();
|
|
1774
1774
|
connection.disconnected(handleConnectionDisconnected);
|
|
1775
1775
|
connection.loggedIn(handleConnectionLoggedIn);
|
|
1776
1776
|
connection.on("success", function (msg) { return handleSuccessMessage(msg); });
|
|
@@ -1902,7 +1902,7 @@ function domainSession (domain, connection, logger, successMessages, errorMessag
|
|
|
1902
1902
|
entry.success(msg);
|
|
1903
1903
|
}
|
|
1904
1904
|
function getNextRequestId() {
|
|
1905
|
-
return shortid
|
|
1905
|
+
return shortid();
|
|
1906
1906
|
}
|
|
1907
1907
|
function send(msg, tag, options) {
|
|
1908
1908
|
options = options || {};
|
|
@@ -1982,7 +1982,7 @@ var GW3ProtocolImpl = (function () {
|
|
|
1982
1982
|
this.datePrefixLen = this.datePrefix.length;
|
|
1983
1983
|
this.dateMinLen = this.datePrefixLen + 1;
|
|
1984
1984
|
this.datePrefixFirstChar = this.datePrefix[0];
|
|
1985
|
-
this.registry = lib$1
|
|
1985
|
+
this.registry = lib$1();
|
|
1986
1986
|
this._isLoggedIn = false;
|
|
1987
1987
|
this.shouldTryLogin = true;
|
|
1988
1988
|
this.initialLogin = true;
|
|
@@ -2412,7 +2412,7 @@ var WebPlatformTransport = (function () {
|
|
|
2412
2412
|
this.parentPingTimeout = 5000;
|
|
2413
2413
|
this.connectionRequestTimeout = 7000;
|
|
2414
2414
|
this.defaultTargetString = "*";
|
|
2415
|
-
this.registry = lib$1
|
|
2415
|
+
this.registry = lib$1();
|
|
2416
2416
|
this.messages = {
|
|
2417
2417
|
connectionAccepted: { name: "connectionAccepted", handle: this.handleConnectionAccepted.bind(this) },
|
|
2418
2418
|
connectionRejected: { name: "connectionRejected", handle: this.handleConnectionRejected.bind(this) },
|
|
@@ -2575,8 +2575,8 @@ var WebPlatformTransport = (function () {
|
|
|
2575
2575
|
var _a;
|
|
2576
2576
|
_this.connectionResolve = resolve;
|
|
2577
2577
|
_this.connectionReject = reject;
|
|
2578
|
-
_this.myClientId = (_a = _this.myClientId) !== null && _a !== void 0 ? _a : shortid
|
|
2579
|
-
var bridgeInstanceId = _this.getMyWindowId() || shortid
|
|
2578
|
+
_this.myClientId = (_a = _this.myClientId) !== null && _a !== void 0 ? _a : shortid();
|
|
2579
|
+
var bridgeInstanceId = _this.getMyWindowId() || shortid();
|
|
2580
2580
|
var request = {
|
|
2581
2581
|
glue42core: {
|
|
2582
2582
|
type: _this.messages.connectionRequest.name,
|
|
@@ -2700,7 +2700,7 @@ var WebPlatformTransport = (function () {
|
|
|
2700
2700
|
this.publicWindowId = this.getMyWindowId();
|
|
2701
2701
|
if (this.identity) {
|
|
2702
2702
|
this.identity.windowId = this.publicWindowId;
|
|
2703
|
-
this.identity.instance = this.identity.instance ? this.identity.instance : this.publicWindowId || shortid
|
|
2703
|
+
this.identity.instance = this.identity.instance ? this.identity.instance : this.publicWindowId || shortid();
|
|
2704
2704
|
}
|
|
2705
2705
|
if (this.identity && data.appName) {
|
|
2706
2706
|
this.identity.application = data.appName;
|
|
@@ -3025,7 +3025,7 @@ var WebPlatformTransport = (function () {
|
|
|
3025
3025
|
if ((_a = window.name) === null || _a === void 0 ? void 0 : _a.includes("g42")) {
|
|
3026
3026
|
return window.name;
|
|
3027
3027
|
}
|
|
3028
|
-
this.selfAssignedWindowId = this.selfAssignedWindowId || "g42-".concat(shortid
|
|
3028
|
+
this.selfAssignedWindowId = this.selfAssignedWindowId || "g42-".concat(shortid());
|
|
3029
3029
|
return this.selfAssignedWindowId;
|
|
3030
3030
|
};
|
|
3031
3031
|
return WebPlatformTransport;
|
|
@@ -3109,7 +3109,7 @@ var Connection = (function () {
|
|
|
3109
3109
|
this.logger = logger;
|
|
3110
3110
|
this.messageHandlers = {};
|
|
3111
3111
|
this.ids = 1;
|
|
3112
|
-
this.registry = lib$1
|
|
3112
|
+
this.registry = lib$1();
|
|
3113
3113
|
this._connected = false;
|
|
3114
3114
|
this.isTrace = false;
|
|
3115
3115
|
this._swapTransport = false;
|
|
@@ -3731,7 +3731,7 @@ function prepareConfig$1 (configuration, ext, glue42gd) {
|
|
|
3731
3731
|
if (typeof window !== "undefined" && typeof window.glue42electron !== "undefined") {
|
|
3732
3732
|
return window.glue42electron.application;
|
|
3733
3733
|
}
|
|
3734
|
-
var uid = shortid
|
|
3734
|
+
var uid = shortid();
|
|
3735
3735
|
if (Utils$1.isNode()) {
|
|
3736
3736
|
if (nodeStartingContext) {
|
|
3737
3737
|
return nodeStartingContext.applicationConfig.name;
|
|
@@ -6858,7 +6858,7 @@ var Client = (function () {
|
|
|
6858
6858
|
timeout = additionalOptions.methodResponseTimeoutMs;
|
|
6859
6859
|
additionalOptionsCopy = additionalOptions;
|
|
6860
6860
|
invokePromises = serversMethodMap.map(function (serversMethodPair) {
|
|
6861
|
-
var invId = shortid
|
|
6861
|
+
var invId = shortid();
|
|
6862
6862
|
var method = serversMethodPair.methods[0];
|
|
6863
6863
|
var server = serversMethodPair.server;
|
|
6864
6864
|
var invokePromise = _this.protocol.client.invoke(invId, method, argumentObj, server, additionalOptionsCopy);
|
|
@@ -7639,7 +7639,7 @@ var InstanceWrapper = (function () {
|
|
|
7639
7639
|
});
|
|
7640
7640
|
this.wrapped.user = resolvedIdentity.user;
|
|
7641
7641
|
this.wrapped.instance = resolvedIdentity.instance;
|
|
7642
|
-
this.wrapped.application = (_a = resolvedIdentity.application) !== null && _a !== void 0 ? _a : shortid
|
|
7642
|
+
this.wrapped.application = (_a = resolvedIdentity.application) !== null && _a !== void 0 ? _a : shortid();
|
|
7643
7643
|
this.wrapped.applicationName = resolvedIdentity.applicationName;
|
|
7644
7644
|
this.wrapped.pid = (_c = (_b = resolvedIdentity.pid) !== null && _b !== void 0 ? _b : resolvedIdentity.process) !== null && _c !== void 0 ? _c : Math.floor(Math.random() * 10000000000);
|
|
7645
7645
|
this.wrapped.machine = resolvedIdentity.machine;
|
|
@@ -7663,7 +7663,7 @@ var ClientRepository = (function () {
|
|
|
7663
7663
|
this.API = API;
|
|
7664
7664
|
this.servers = {};
|
|
7665
7665
|
this.methodsCount = {};
|
|
7666
|
-
this.callbacks = lib$1
|
|
7666
|
+
this.callbacks = lib$1();
|
|
7667
7667
|
var peerId = this.API.instance.peerId;
|
|
7668
7668
|
this.myServer = {
|
|
7669
7669
|
id: peerId,
|
|
@@ -7918,7 +7918,7 @@ var ServerStreaming = (function () {
|
|
|
7918
7918
|
this.repository = repository;
|
|
7919
7919
|
this.serverRepository = serverRepository;
|
|
7920
7920
|
this.ERR_URI_SUBSCRIPTION_FAILED = "com.tick42.agm.errors.subscription.failure";
|
|
7921
|
-
this.callbacks = lib$1
|
|
7921
|
+
this.callbacks = lib$1();
|
|
7922
7922
|
this.nextStreamId = 0;
|
|
7923
7923
|
session.on("add-interest", function (msg) {
|
|
7924
7924
|
_this.handleAddInterest(msg);
|
|
@@ -8180,7 +8180,7 @@ var ServerProtocol = (function () {
|
|
|
8180
8180
|
this.clientRepository = clientRepository;
|
|
8181
8181
|
this.serverRepository = serverRepository;
|
|
8182
8182
|
this.logger = logger;
|
|
8183
|
-
this.callbacks = lib$1
|
|
8183
|
+
this.callbacks = lib$1();
|
|
8184
8184
|
this.streaming = new ServerStreaming(session, clientRepository, serverRepository);
|
|
8185
8185
|
this.session.on("invoke", function (msg) { return _this.handleInvokeMessage(msg); });
|
|
8186
8186
|
}
|
|
@@ -8392,7 +8392,7 @@ var TimedCache = (function () {
|
|
|
8392
8392
|
}
|
|
8393
8393
|
TimedCache.prototype.add = function (element) {
|
|
8394
8394
|
var _this = this;
|
|
8395
|
-
var id = shortid
|
|
8395
|
+
var id = shortid();
|
|
8396
8396
|
this.cache.push({ id: id, element: element });
|
|
8397
8397
|
var timeoutId = setTimeout(function () {
|
|
8398
8398
|
var elementIdx = _this.cache.findIndex(function (entry) { return entry.id === id; });
|
|
@@ -9254,7 +9254,7 @@ var IOConnectCoreFactory = function (userConfig, ext) {
|
|
|
9254
9254
|
canUpdateMetric: canUpdateMetric,
|
|
9255
9255
|
system: "Glue42",
|
|
9256
9256
|
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,
|
|
9257
|
-
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
|
|
9257
|
+
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(),
|
|
9258
9258
|
disableAutoAppSystem: disableAutoAppSystem,
|
|
9259
9259
|
pagePerformanceMetrics: typeof config !== "boolean" ? config === null || config === void 0 ? void 0 : config.pagePerformanceMetrics : undefined
|
|
9260
9260
|
});
|
|
@@ -12493,7 +12493,7 @@ function createRegistry(options) {
|
|
|
12493
12493
|
};
|
|
12494
12494
|
}
|
|
12495
12495
|
createRegistry.default = createRegistry;
|
|
12496
|
-
var lib
|
|
12496
|
+
var lib = createRegistry;
|
|
12497
12497
|
|
|
12498
12498
|
function objectValues(source) {
|
|
12499
12499
|
if (!source) {
|
|
@@ -12525,7 +12525,7 @@ class ApplicationImpl {
|
|
|
12525
12525
|
this._name = _name;
|
|
12526
12526
|
this._agm = _agm;
|
|
12527
12527
|
this._configuration = _configuration;
|
|
12528
|
-
this._registry = lib
|
|
12528
|
+
this._registry = lib();
|
|
12529
12529
|
_appManager.onInstanceStarted((instance) => {
|
|
12530
12530
|
if (instance.application && instance.application.name !== this._name) {
|
|
12531
12531
|
return;
|
|
@@ -12789,7 +12789,7 @@ class InstanceImpl {
|
|
|
12789
12789
|
this._activities = _activities;
|
|
12790
12790
|
this._windows = _windows;
|
|
12791
12791
|
this._configuration = _configuration;
|
|
12792
|
-
this._registry = lib
|
|
12792
|
+
this._registry = lib();
|
|
12793
12793
|
if (startFailed) {
|
|
12794
12794
|
return;
|
|
12795
12795
|
}
|
|
@@ -12973,7 +12973,7 @@ class AppManagerImpl {
|
|
|
12973
12973
|
this._configuration = _configuration;
|
|
12974
12974
|
this._apps = {};
|
|
12975
12975
|
this._instances = [];
|
|
12976
|
-
this._registry = lib
|
|
12976
|
+
this._registry = lib();
|
|
12977
12977
|
this.getConfigurations = async (apps) => {
|
|
12978
12978
|
const args = {
|
|
12979
12979
|
v2: {
|
|
@@ -13230,7 +13230,7 @@ function promisify(promise, successCallback, errorCallback) {
|
|
|
13230
13230
|
class EntitlementsImpl {
|
|
13231
13231
|
constructor(_agm) {
|
|
13232
13232
|
this._agm = _agm;
|
|
13233
|
-
this._registry = lib
|
|
13233
|
+
this._registry = lib();
|
|
13234
13234
|
this._isMethodRegistered = false;
|
|
13235
13235
|
this.handleBranchModified = (branch) => {
|
|
13236
13236
|
this._registry.execute("branchChanged", branch);
|
|
@@ -13576,309 +13576,124 @@ var AppManagerFactory = (config) => {
|
|
|
13576
13576
|
return api;
|
|
13577
13577
|
};
|
|
13578
13578
|
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
/**
|
|
13589
|
-
* return a random number based on a seed
|
|
13590
|
-
* @param seed
|
|
13591
|
-
* @returns {number}
|
|
13592
|
-
*/
|
|
13593
|
-
function getNextValue() {
|
|
13594
|
-
seed = (seed * 9301 + 49297) % 233280;
|
|
13595
|
-
return seed/(233280.0);
|
|
13596
|
-
}
|
|
13597
|
-
|
|
13598
|
-
function setSeed$1(_seed_) {
|
|
13599
|
-
seed = _seed_;
|
|
13600
|
-
}
|
|
13601
|
-
|
|
13602
|
-
var randomFromSeed = {
|
|
13603
|
-
nextValue: getNextValue,
|
|
13604
|
-
seed: setSeed$1
|
|
13579
|
+
let urlAlphabet =
|
|
13580
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
13581
|
+
let nanoid = (size = 21) => {
|
|
13582
|
+
let id = '';
|
|
13583
|
+
let i = size;
|
|
13584
|
+
while (i--) {
|
|
13585
|
+
id += urlAlphabet[(Math.random() * 64) | 0];
|
|
13586
|
+
}
|
|
13587
|
+
return id
|
|
13605
13588
|
};
|
|
13606
13589
|
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
}
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
}
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13590
|
+
class Utils {
|
|
13591
|
+
static getGDMajorVersion() {
|
|
13592
|
+
if (typeof window === "undefined") {
|
|
13593
|
+
return -1;
|
|
13594
|
+
}
|
|
13595
|
+
if (!window.glueDesktop) {
|
|
13596
|
+
return -1;
|
|
13597
|
+
}
|
|
13598
|
+
if (!window.glueDesktop.version) {
|
|
13599
|
+
return -1;
|
|
13600
|
+
}
|
|
13601
|
+
const ver = Number(window.glueDesktop.version.substr(0, 1));
|
|
13602
|
+
return isNaN(ver) ? -1 : ver;
|
|
13603
|
+
}
|
|
13604
|
+
static callbackifyPromise(action, successCallback, errorCallback) {
|
|
13605
|
+
const fail = (error) => {
|
|
13606
|
+
let msg = error;
|
|
13607
|
+
if (error instanceof Error) {
|
|
13608
|
+
msg = error.message;
|
|
13609
|
+
}
|
|
13610
|
+
if (typeof errorCallback === "function") {
|
|
13611
|
+
errorCallback(msg);
|
|
13612
|
+
return;
|
|
13613
|
+
}
|
|
13614
|
+
return Promise.reject(msg);
|
|
13615
|
+
};
|
|
13616
|
+
try {
|
|
13617
|
+
return action()
|
|
13618
|
+
.then((result) => {
|
|
13619
|
+
if (typeof successCallback === "function") {
|
|
13620
|
+
successCallback(result);
|
|
13621
|
+
}
|
|
13622
|
+
return result;
|
|
13623
|
+
})
|
|
13624
|
+
.catch((error) => {
|
|
13625
|
+
return fail(error);
|
|
13626
|
+
});
|
|
13627
|
+
}
|
|
13628
|
+
catch (err) {
|
|
13629
|
+
return fail(err);
|
|
13630
|
+
}
|
|
13631
|
+
}
|
|
13632
|
+
static getMonitor(bounds, displays) {
|
|
13633
|
+
const monitorsSortedByOverlap = displays.map((m) => {
|
|
13634
|
+
const { left, top, workingAreaWidth: width, workingAreaHeight: height } = m;
|
|
13635
|
+
const overlap = this.calculateTotalOverlap({ left, top, width, height }, bounds);
|
|
13636
|
+
return {
|
|
13637
|
+
monitor: m,
|
|
13638
|
+
totalOverlap: overlap
|
|
13639
|
+
};
|
|
13640
|
+
}).sort((a, b) => b.totalOverlap - a.totalOverlap);
|
|
13641
|
+
return monitorsSortedByOverlap[0].monitor;
|
|
13642
|
+
}
|
|
13643
|
+
static getDisplayCenterOfScreen(a, currentDisplay, primaryDisplay) {
|
|
13644
|
+
const physicalWidth = a.width / currentDisplay.scaleFactor;
|
|
13645
|
+
const physicalHeight = a.height / currentDisplay.scaleFactor;
|
|
13646
|
+
const physicalDisplayLeft = currentDisplay.workArea.left / primaryDisplay.scaleFactor;
|
|
13647
|
+
const physicalDisplayTop = currentDisplay.workArea.top / primaryDisplay.scaleFactor;
|
|
13648
|
+
const physicalDisplayWidth = currentDisplay.workArea.width / currentDisplay.scaleFactor;
|
|
13649
|
+
const physicalDisplayHeight = currentDisplay.workArea.height / currentDisplay.scaleFactor;
|
|
13650
|
+
const physicalHOffset = Math.max((physicalDisplayWidth - physicalWidth) / 2, 0);
|
|
13651
|
+
const physicalVOffset = Math.max((physicalDisplayHeight - physicalHeight) / 2, 0);
|
|
13652
|
+
const centeredPhysicalLeft = Math.floor(physicalDisplayLeft + physicalHOffset);
|
|
13653
|
+
const centeredPhysicalTop = Math.floor(physicalDisplayTop + physicalVOffset);
|
|
13654
|
+
const left = centeredPhysicalLeft * primaryDisplay.scaleFactor;
|
|
13655
|
+
const top = centeredPhysicalTop * primaryDisplay.scaleFactor;
|
|
13656
|
+
return {
|
|
13657
|
+
left,
|
|
13658
|
+
top,
|
|
13659
|
+
width: a.width,
|
|
13660
|
+
height: a.height
|
|
13661
|
+
};
|
|
13662
|
+
}
|
|
13663
|
+
static isNode() {
|
|
13664
|
+
if (typeof Utils._isNode !== "undefined") {
|
|
13665
|
+
return Utils._isNode;
|
|
13666
|
+
}
|
|
13667
|
+
if (typeof window !== "undefined") {
|
|
13668
|
+
Utils._isNode = false;
|
|
13669
|
+
return false;
|
|
13670
|
+
}
|
|
13671
|
+
try {
|
|
13672
|
+
Utils._isNode = Object.prototype.toString.call(global.process) === "[object process]";
|
|
13673
|
+
}
|
|
13674
|
+
catch (e) {
|
|
13675
|
+
Utils._isNode = false;
|
|
13676
|
+
}
|
|
13677
|
+
return Utils._isNode;
|
|
13678
|
+
}
|
|
13679
|
+
static generateId() {
|
|
13680
|
+
return nanoid(10);
|
|
13681
|
+
}
|
|
13682
|
+
static calculateTotalOverlap(r1, r2) {
|
|
13683
|
+
const r1x = r1.left;
|
|
13684
|
+
const r1y = r1.top;
|
|
13685
|
+
const r1xMax = r1x + r1.width;
|
|
13686
|
+
const r1yMax = r1y + r1.height;
|
|
13687
|
+
const r2x = r2.left;
|
|
13688
|
+
const r2y = r2.top;
|
|
13689
|
+
const r2xMax = r2x + r2.width;
|
|
13690
|
+
const r2yMax = r2y + r2.height;
|
|
13691
|
+
const xOverlap = Math.max(0, Math.min(r1xMax, r2xMax) - Math.max(r1x, r2x));
|
|
13692
|
+
const yOverlap = Math.max(0, Math.min(r1yMax, r2yMax) - Math.max(r1y, r2y));
|
|
13693
|
+
return xOverlap * yOverlap;
|
|
13694
|
+
}
|
|
13675
13695
|
}
|
|
13676
13696
|
|
|
13677
|
-
function getShuffled() {
|
|
13678
|
-
if (shuffled) {
|
|
13679
|
-
return shuffled;
|
|
13680
|
-
}
|
|
13681
|
-
shuffled = shuffle();
|
|
13682
|
-
return shuffled;
|
|
13683
|
-
}
|
|
13684
|
-
|
|
13685
|
-
/**
|
|
13686
|
-
* lookup shuffled letter
|
|
13687
|
-
* @param index
|
|
13688
|
-
* @returns {string}
|
|
13689
|
-
*/
|
|
13690
|
-
function lookup(index) {
|
|
13691
|
-
var alphabetShuffled = getShuffled();
|
|
13692
|
-
return alphabetShuffled[index];
|
|
13693
|
-
}
|
|
13694
|
-
|
|
13695
|
-
var alphabet_1 = {
|
|
13696
|
-
characters: characters,
|
|
13697
|
-
seed: setSeed,
|
|
13698
|
-
lookup: lookup,
|
|
13699
|
-
shuffled: getShuffled
|
|
13700
|
-
};
|
|
13701
|
-
|
|
13702
|
-
var crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto
|
|
13703
|
-
|
|
13704
|
-
function randomByte() {
|
|
13705
|
-
if (!crypto || !crypto.getRandomValues) {
|
|
13706
|
-
return Math.floor(Math.random() * 256) & 0x30;
|
|
13707
|
-
}
|
|
13708
|
-
var dest = new Uint8Array(1);
|
|
13709
|
-
crypto.getRandomValues(dest);
|
|
13710
|
-
return dest[0] & 0x30;
|
|
13711
|
-
}
|
|
13712
|
-
|
|
13713
|
-
var randomByteBrowser = randomByte;
|
|
13714
|
-
|
|
13715
|
-
function encode(lookup, number) {
|
|
13716
|
-
var loopCounter = 0;
|
|
13717
|
-
var done;
|
|
13718
|
-
|
|
13719
|
-
var str = '';
|
|
13720
|
-
|
|
13721
|
-
while (!done) {
|
|
13722
|
-
str = str + lookup( ( (number >> (4 * loopCounter)) & 0x0f ) | randomByteBrowser() );
|
|
13723
|
-
done = number < (Math.pow(16, loopCounter + 1 ) );
|
|
13724
|
-
loopCounter++;
|
|
13725
|
-
}
|
|
13726
|
-
return str;
|
|
13727
|
-
}
|
|
13728
|
-
|
|
13729
|
-
var encode_1 = encode;
|
|
13730
|
-
|
|
13731
|
-
/**
|
|
13732
|
-
* Decode the id to get the version and worker
|
|
13733
|
-
* Mainly for debugging and testing.
|
|
13734
|
-
* @param id - the shortid-generated id.
|
|
13735
|
-
*/
|
|
13736
|
-
function decode(id) {
|
|
13737
|
-
var characters = alphabet_1.shuffled();
|
|
13738
|
-
return {
|
|
13739
|
-
version: characters.indexOf(id.substr(0, 1)) & 0x0f,
|
|
13740
|
-
worker: characters.indexOf(id.substr(1, 1)) & 0x0f
|
|
13741
|
-
};
|
|
13742
|
-
}
|
|
13743
|
-
|
|
13744
|
-
var decode_1 = decode;
|
|
13745
|
-
|
|
13746
|
-
// Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness.
|
|
13747
|
-
// This number should be updated every year or so to keep the generated id short.
|
|
13748
|
-
// To regenerate `new Date() - 0` and bump the version. Always bump the version!
|
|
13749
|
-
var REDUCE_TIME = 1459707606518;
|
|
13750
|
-
|
|
13751
|
-
// don't change unless we change the algos or REDUCE_TIME
|
|
13752
|
-
// must be an integer and less than 16
|
|
13753
|
-
var version$1 = 6;
|
|
13754
|
-
|
|
13755
|
-
// Counter is used when shortid is called multiple times in one second.
|
|
13756
|
-
var counter;
|
|
13757
|
-
|
|
13758
|
-
// Remember the last time shortid was called in case counter is needed.
|
|
13759
|
-
var previousSeconds;
|
|
13760
|
-
|
|
13761
|
-
/**
|
|
13762
|
-
* Generate unique id
|
|
13763
|
-
* Returns string id
|
|
13764
|
-
*/
|
|
13765
|
-
function build(clusterWorkerId) {
|
|
13766
|
-
|
|
13767
|
-
var str = '';
|
|
13768
|
-
|
|
13769
|
-
var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001);
|
|
13770
|
-
|
|
13771
|
-
if (seconds === previousSeconds) {
|
|
13772
|
-
counter++;
|
|
13773
|
-
} else {
|
|
13774
|
-
counter = 0;
|
|
13775
|
-
previousSeconds = seconds;
|
|
13776
|
-
}
|
|
13777
|
-
|
|
13778
|
-
str = str + encode_1(alphabet_1.lookup, version$1);
|
|
13779
|
-
str = str + encode_1(alphabet_1.lookup, clusterWorkerId);
|
|
13780
|
-
if (counter > 0) {
|
|
13781
|
-
str = str + encode_1(alphabet_1.lookup, counter);
|
|
13782
|
-
}
|
|
13783
|
-
str = str + encode_1(alphabet_1.lookup, seconds);
|
|
13784
|
-
|
|
13785
|
-
return str;
|
|
13786
|
-
}
|
|
13787
|
-
|
|
13788
|
-
var build_1 = build;
|
|
13789
|
-
|
|
13790
|
-
function isShortId(id) {
|
|
13791
|
-
if (!id || typeof id !== 'string' || id.length < 6 ) {
|
|
13792
|
-
return false;
|
|
13793
|
-
}
|
|
13794
|
-
|
|
13795
|
-
var characters = alphabet_1.characters();
|
|
13796
|
-
var len = id.length;
|
|
13797
|
-
for(var i = 0; i < len;i++) {
|
|
13798
|
-
if (characters.indexOf(id[i]) === -1) {
|
|
13799
|
-
return false;
|
|
13800
|
-
}
|
|
13801
|
-
}
|
|
13802
|
-
return true;
|
|
13803
|
-
}
|
|
13804
|
-
|
|
13805
|
-
var isValid = isShortId;
|
|
13806
|
-
|
|
13807
|
-
var lib = createCommonjsModule(function (module) {
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
// if you are using cluster or multiple servers use this to make each instance
|
|
13816
|
-
// has a unique value for worker
|
|
13817
|
-
// Note: I don't know if this is automatically set when using third
|
|
13818
|
-
// party cluster solutions such as pm2.
|
|
13819
|
-
var clusterWorkerId = 0;
|
|
13820
|
-
|
|
13821
|
-
/**
|
|
13822
|
-
* Set the seed.
|
|
13823
|
-
* Highly recommended if you don't want people to try to figure out your id schema.
|
|
13824
|
-
* exposed as shortid.seed(int)
|
|
13825
|
-
* @param seed Integer value to seed the random alphabet. ALWAYS USE THE SAME SEED or you might get overlaps.
|
|
13826
|
-
*/
|
|
13827
|
-
function seed(seedValue) {
|
|
13828
|
-
alphabet_1.seed(seedValue);
|
|
13829
|
-
return module.exports;
|
|
13830
|
-
}
|
|
13831
|
-
|
|
13832
|
-
/**
|
|
13833
|
-
* Set the cluster worker or machine id
|
|
13834
|
-
* exposed as shortid.worker(int)
|
|
13835
|
-
* @param workerId worker must be positive integer. Number less than 16 is recommended.
|
|
13836
|
-
* returns shortid module so it can be chained.
|
|
13837
|
-
*/
|
|
13838
|
-
function worker(workerId) {
|
|
13839
|
-
clusterWorkerId = workerId;
|
|
13840
|
-
return module.exports;
|
|
13841
|
-
}
|
|
13842
|
-
|
|
13843
|
-
/**
|
|
13844
|
-
*
|
|
13845
|
-
* sets new characters to use in the alphabet
|
|
13846
|
-
* returns the shuffled alphabet
|
|
13847
|
-
*/
|
|
13848
|
-
function characters(newCharacters) {
|
|
13849
|
-
if (newCharacters !== undefined) {
|
|
13850
|
-
alphabet_1.characters(newCharacters);
|
|
13851
|
-
}
|
|
13852
|
-
|
|
13853
|
-
return alphabet_1.shuffled();
|
|
13854
|
-
}
|
|
13855
|
-
|
|
13856
|
-
/**
|
|
13857
|
-
* Generate unique id
|
|
13858
|
-
* Returns string id
|
|
13859
|
-
*/
|
|
13860
|
-
function generate() {
|
|
13861
|
-
return build_1(clusterWorkerId);
|
|
13862
|
-
}
|
|
13863
|
-
|
|
13864
|
-
// Export all other functions as properties of the generate function
|
|
13865
|
-
module.exports = generate;
|
|
13866
|
-
module.exports.generate = generate;
|
|
13867
|
-
module.exports.seed = seed;
|
|
13868
|
-
module.exports.worker = worker;
|
|
13869
|
-
module.exports.characters = characters;
|
|
13870
|
-
module.exports.decode = decode_1;
|
|
13871
|
-
module.exports.isValid = isValid;
|
|
13872
|
-
});
|
|
13873
|
-
lib.generate;
|
|
13874
|
-
lib.seed;
|
|
13875
|
-
lib.worker;
|
|
13876
|
-
lib.characters;
|
|
13877
|
-
lib.decode;
|
|
13878
|
-
lib.isValid;
|
|
13879
|
-
|
|
13880
|
-
var shortid = lib;
|
|
13881
|
-
|
|
13882
13697
|
const T42JumpListAction = "T42.JumpList.Action";
|
|
13883
13698
|
class JumpListManager {
|
|
13884
13699
|
constructor() {
|
|
@@ -13968,7 +13783,7 @@ class JumpListManager {
|
|
|
13968
13783
|
const updateAction = {
|
|
13969
13784
|
icon: action.icon,
|
|
13970
13785
|
callback: action.callback,
|
|
13971
|
-
callbackId:
|
|
13786
|
+
callbackId: Utils.generateId(),
|
|
13972
13787
|
singleInstanceTitle: action.singleInstanceTitle,
|
|
13973
13788
|
multiInstanceTitle: action.multiInstanceTitle,
|
|
13974
13789
|
operation
|
|
@@ -14064,7 +13879,7 @@ class WindowStore {
|
|
|
14064
13879
|
this._windows = {};
|
|
14065
13880
|
this._pendingWindows = {};
|
|
14066
13881
|
this._pendingWindowsStates = {};
|
|
14067
|
-
this._registry = lib
|
|
13882
|
+
this._registry = lib();
|
|
14068
13883
|
}
|
|
14069
13884
|
init(logger) {
|
|
14070
13885
|
this._logger = logger;
|
|
@@ -14129,10 +13944,12 @@ class WindowStore {
|
|
|
14129
13944
|
}
|
|
14130
13945
|
waitFor(id) {
|
|
14131
13946
|
return new Promise((resolve, reject) => {
|
|
14132
|
-
let
|
|
13947
|
+
let unReady;
|
|
13948
|
+
let unRemoved;
|
|
14133
13949
|
const timeout = setTimeout(() => {
|
|
14134
|
-
|
|
14135
|
-
|
|
13950
|
+
unReady();
|
|
13951
|
+
unRemoved();
|
|
13952
|
+
reject(`Window with id "${id}" was not ready within ${this.waitForTimeoutInMilliseconds} milliseconds.`);
|
|
14136
13953
|
}, this.waitForTimeoutInMilliseconds);
|
|
14137
13954
|
const win = this._windows[id];
|
|
14138
13955
|
if (win) {
|
|
@@ -14140,14 +13957,25 @@ class WindowStore {
|
|
|
14140
13957
|
resolve(win);
|
|
14141
13958
|
}
|
|
14142
13959
|
else {
|
|
14143
|
-
|
|
13960
|
+
const cleanup = () => {
|
|
13961
|
+
clearTimeout(timeout);
|
|
13962
|
+
unReady();
|
|
13963
|
+
unRemoved();
|
|
13964
|
+
};
|
|
13965
|
+
unReady = this.onReadyWindow((w) => {
|
|
14144
13966
|
if (w.API.id !== id) {
|
|
14145
13967
|
return;
|
|
14146
13968
|
}
|
|
14147
|
-
|
|
14148
|
-
un();
|
|
13969
|
+
cleanup();
|
|
14149
13970
|
resolve(w);
|
|
14150
13971
|
});
|
|
13972
|
+
unRemoved = this.onRemoved((w) => {
|
|
13973
|
+
if (w.API.id !== id) {
|
|
13974
|
+
return;
|
|
13975
|
+
}
|
|
13976
|
+
cleanup();
|
|
13977
|
+
reject(`Window with id "${id}" was removed before it became ready.`);
|
|
13978
|
+
});
|
|
14151
13979
|
}
|
|
14152
13980
|
});
|
|
14153
13981
|
}
|
|
@@ -14171,110 +13999,6 @@ class WindowStore {
|
|
|
14171
13999
|
}
|
|
14172
14000
|
var windowStore = new WindowStore();
|
|
14173
14001
|
|
|
14174
|
-
class Utils {
|
|
14175
|
-
static getGDMajorVersion() {
|
|
14176
|
-
if (typeof window === "undefined") {
|
|
14177
|
-
return -1;
|
|
14178
|
-
}
|
|
14179
|
-
if (!window.glueDesktop) {
|
|
14180
|
-
return -1;
|
|
14181
|
-
}
|
|
14182
|
-
if (!window.glueDesktop.version) {
|
|
14183
|
-
return -1;
|
|
14184
|
-
}
|
|
14185
|
-
const ver = Number(window.glueDesktop.version.substr(0, 1));
|
|
14186
|
-
return isNaN(ver) ? -1 : ver;
|
|
14187
|
-
}
|
|
14188
|
-
static callbackifyPromise(action, successCallback, errorCallback) {
|
|
14189
|
-
const fail = (error) => {
|
|
14190
|
-
let msg = error;
|
|
14191
|
-
if (error instanceof Error) {
|
|
14192
|
-
msg = error.message;
|
|
14193
|
-
}
|
|
14194
|
-
if (typeof errorCallback === "function") {
|
|
14195
|
-
errorCallback(msg);
|
|
14196
|
-
return;
|
|
14197
|
-
}
|
|
14198
|
-
return Promise.reject(msg);
|
|
14199
|
-
};
|
|
14200
|
-
try {
|
|
14201
|
-
return action()
|
|
14202
|
-
.then((result) => {
|
|
14203
|
-
if (typeof successCallback === "function") {
|
|
14204
|
-
successCallback(result);
|
|
14205
|
-
}
|
|
14206
|
-
return result;
|
|
14207
|
-
})
|
|
14208
|
-
.catch((error) => {
|
|
14209
|
-
return fail(error);
|
|
14210
|
-
});
|
|
14211
|
-
}
|
|
14212
|
-
catch (err) {
|
|
14213
|
-
return fail(err);
|
|
14214
|
-
}
|
|
14215
|
-
}
|
|
14216
|
-
static getMonitor(bounds, displays) {
|
|
14217
|
-
const monitorsSortedByOverlap = displays.map((m) => {
|
|
14218
|
-
const { left, top, workingAreaWidth: width, workingAreaHeight: height } = m;
|
|
14219
|
-
const overlap = this.calculateTotalOverlap({ left, top, width, height }, bounds);
|
|
14220
|
-
return {
|
|
14221
|
-
monitor: m,
|
|
14222
|
-
totalOverlap: overlap
|
|
14223
|
-
};
|
|
14224
|
-
}).sort((a, b) => b.totalOverlap - a.totalOverlap);
|
|
14225
|
-
return monitorsSortedByOverlap[0].monitor;
|
|
14226
|
-
}
|
|
14227
|
-
static getDisplayCenterOfScreen(a, currentDisplay, primaryDisplay) {
|
|
14228
|
-
const physicalWidth = a.width / currentDisplay.scaleFactor;
|
|
14229
|
-
const physicalHeight = a.height / currentDisplay.scaleFactor;
|
|
14230
|
-
const physicalDisplayLeft = currentDisplay.workArea.left / primaryDisplay.scaleFactor;
|
|
14231
|
-
const physicalDisplayTop = currentDisplay.workArea.top / primaryDisplay.scaleFactor;
|
|
14232
|
-
const physicalDisplayWidth = currentDisplay.workArea.width / currentDisplay.scaleFactor;
|
|
14233
|
-
const physicalDisplayHeight = currentDisplay.workArea.height / currentDisplay.scaleFactor;
|
|
14234
|
-
const physicalHOffset = Math.max((physicalDisplayWidth - physicalWidth) / 2, 0);
|
|
14235
|
-
const physicalVOffset = Math.max((physicalDisplayHeight - physicalHeight) / 2, 0);
|
|
14236
|
-
const centeredPhysicalLeft = Math.floor(physicalDisplayLeft + physicalHOffset);
|
|
14237
|
-
const centeredPhysicalTop = Math.floor(physicalDisplayTop + physicalVOffset);
|
|
14238
|
-
const left = centeredPhysicalLeft * primaryDisplay.scaleFactor;
|
|
14239
|
-
const top = centeredPhysicalTop * primaryDisplay.scaleFactor;
|
|
14240
|
-
return {
|
|
14241
|
-
left,
|
|
14242
|
-
top,
|
|
14243
|
-
width: a.width,
|
|
14244
|
-
height: a.height
|
|
14245
|
-
};
|
|
14246
|
-
}
|
|
14247
|
-
static isNode() {
|
|
14248
|
-
if (typeof Utils._isNode !== "undefined") {
|
|
14249
|
-
return Utils._isNode;
|
|
14250
|
-
}
|
|
14251
|
-
if (typeof window !== "undefined") {
|
|
14252
|
-
Utils._isNode = false;
|
|
14253
|
-
return false;
|
|
14254
|
-
}
|
|
14255
|
-
try {
|
|
14256
|
-
Utils._isNode = Object.prototype.toString.call(global.process) === "[object process]";
|
|
14257
|
-
}
|
|
14258
|
-
catch (e) {
|
|
14259
|
-
Utils._isNode = false;
|
|
14260
|
-
}
|
|
14261
|
-
return Utils._isNode;
|
|
14262
|
-
}
|
|
14263
|
-
static calculateTotalOverlap(r1, r2) {
|
|
14264
|
-
const r1x = r1.left;
|
|
14265
|
-
const r1y = r1.top;
|
|
14266
|
-
const r1xMax = r1x + r1.width;
|
|
14267
|
-
const r1yMax = r1y + r1.height;
|
|
14268
|
-
const r2x = r2.left;
|
|
14269
|
-
const r2y = r2.top;
|
|
14270
|
-
const r2xMax = r2x + r2.width;
|
|
14271
|
-
const r2yMax = r2y + r2.height;
|
|
14272
|
-
const xOverlap = Math.max(0, Math.min(r1xMax, r2xMax) - Math.max(r1x, r2x));
|
|
14273
|
-
const yOverlap = Math.max(0, Math.min(r1yMax, r2yMax) - Math.max(r1y, r2y));
|
|
14274
|
-
return xOverlap * yOverlap;
|
|
14275
|
-
}
|
|
14276
|
-
}
|
|
14277
|
-
|
|
14278
14002
|
class JumpListActions {
|
|
14279
14003
|
constructor(windowId, configuration) {
|
|
14280
14004
|
this.windowId = windowId;
|
|
@@ -14340,7 +14064,7 @@ class JumpList {
|
|
|
14340
14064
|
|
|
14341
14065
|
var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, agm) => {
|
|
14342
14066
|
var _a, _b, _c, _d;
|
|
14343
|
-
const _registry = lib
|
|
14067
|
+
const _registry = lib();
|
|
14344
14068
|
const getChannels = () => {
|
|
14345
14069
|
const channels = channelsAPIGetter();
|
|
14346
14070
|
if (!channels) {
|
|
@@ -14361,6 +14085,8 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
14361
14085
|
let _groupId = options.groupId;
|
|
14362
14086
|
let _isGroupHeaderVisible = options.isGroupHeaderVisible;
|
|
14363
14087
|
let _isTabHeaderVisible = options.isTabHeaderVisible;
|
|
14088
|
+
let _isGroupHibernated = options.isGroupHibernated;
|
|
14089
|
+
let _isGroupVisible = options.isGroupVisible;
|
|
14364
14090
|
let _isTabSelected = (_c = options.isTabSelected) !== null && _c !== void 0 ? _c : false;
|
|
14365
14091
|
let _settings = options.settings;
|
|
14366
14092
|
const _applicationName = options.applicationName;
|
|
@@ -14843,6 +14569,15 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
14843
14569
|
function getConfiguration() {
|
|
14844
14570
|
return executor.getWindowConfiguration(resultWindow);
|
|
14845
14571
|
}
|
|
14572
|
+
function getDockingPlacement() {
|
|
14573
|
+
return executor.getDockingPlacement(resultWindow);
|
|
14574
|
+
}
|
|
14575
|
+
function dock(opts) {
|
|
14576
|
+
return executor.dock(resultWindow, opts);
|
|
14577
|
+
}
|
|
14578
|
+
async function clone(cloneOptions) {
|
|
14579
|
+
return executor.clone(resultWindow, cloneOptions);
|
|
14580
|
+
}
|
|
14846
14581
|
function onTitleChanged(callback) {
|
|
14847
14582
|
if (!isFunction(callback)) {
|
|
14848
14583
|
throw new Error("callback should be a function");
|
|
@@ -15009,6 +14744,9 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
15009
14744
|
function onNeighboursChanged(callback) {
|
|
15010
14745
|
return onEventCore("neighbours-changed", callback);
|
|
15011
14746
|
}
|
|
14747
|
+
function onDockingChanged(callback) {
|
|
14748
|
+
return onEventCore("docking-changed", callback);
|
|
14749
|
+
}
|
|
15012
14750
|
function onEventCore(key, callback, replayArguments) {
|
|
15013
14751
|
if (!isFunction(callback)) {
|
|
15014
14752
|
throw new Error("callback must be a function");
|
|
@@ -15044,6 +14782,8 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
15044
14782
|
_groupId = updated.groupId;
|
|
15045
14783
|
_isGroupHeaderVisible = updated.isGroupHeaderVisible;
|
|
15046
14784
|
_isTabHeaderVisible = updated.isTabHeaderVisible;
|
|
14785
|
+
_isGroupHibernated = updated.isGroupHibernated;
|
|
14786
|
+
_isGroupVisible = updated.isGroupVisible;
|
|
15047
14787
|
_isTabSelected = updated.isTabSelected;
|
|
15048
14788
|
_settings = updated.settings;
|
|
15049
14789
|
_isVisible = updated.isVisible;
|
|
@@ -15257,6 +14997,13 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
15257
14997
|
_registry.execute("placementSettingsChanged", resultWindow);
|
|
15258
14998
|
});
|
|
15259
14999
|
}
|
|
15000
|
+
function handleDockingChanged(data) {
|
|
15001
|
+
_registry.execute("docking-changed", resultWindow, {
|
|
15002
|
+
docked: data.docked,
|
|
15003
|
+
position: data.position,
|
|
15004
|
+
claimScreenArea: data.claimScreenArea
|
|
15005
|
+
});
|
|
15006
|
+
}
|
|
15260
15007
|
function handleGroupChanged(newGroup, oldGroup) {
|
|
15261
15008
|
_group = newGroup;
|
|
15262
15009
|
_groupId = newGroup === null || newGroup === void 0 ? void 0 : newGroup.id;
|
|
@@ -15562,6 +15309,9 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
15562
15309
|
download,
|
|
15563
15310
|
configure,
|
|
15564
15311
|
getConfiguration,
|
|
15312
|
+
getDockingPlacement,
|
|
15313
|
+
dock,
|
|
15314
|
+
clone,
|
|
15565
15315
|
getChannel: async () => {
|
|
15566
15316
|
var _a;
|
|
15567
15317
|
const wins = await getChannels().getWindowsWithChannels({ windowIds: [_id] });
|
|
@@ -15599,6 +15349,7 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
15599
15349
|
onZoomFactorChanged,
|
|
15600
15350
|
onPlacementSettingsChanged,
|
|
15601
15351
|
onNeighboursChanged,
|
|
15352
|
+
onDockingChanged,
|
|
15602
15353
|
onNavigating,
|
|
15603
15354
|
get tabs() {
|
|
15604
15355
|
return getAllTabs();
|
|
@@ -15688,11 +15439,21 @@ var windowFactory = (id, options, executor, logger, appManagerGetter, displayAPI
|
|
|
15688
15439
|
handleWindowDetached,
|
|
15689
15440
|
handleZoomFactorChanged,
|
|
15690
15441
|
handleIsStickyChanged,
|
|
15691
|
-
handlePlacementSettingsChanged
|
|
15442
|
+
handlePlacementSettingsChanged,
|
|
15443
|
+
handleDockingChanged
|
|
15444
|
+
};
|
|
15445
|
+
const groupArgs = {
|
|
15446
|
+
get isGroupHibernated() {
|
|
15447
|
+
return _isGroupHibernated;
|
|
15448
|
+
},
|
|
15449
|
+
get isGroupVisible() {
|
|
15450
|
+
return _isGroupVisible;
|
|
15451
|
+
},
|
|
15692
15452
|
};
|
|
15693
15453
|
return {
|
|
15694
15454
|
API: resultWindow,
|
|
15695
|
-
Events: events
|
|
15455
|
+
Events: events,
|
|
15456
|
+
GroupCreationArgs: groupArgs
|
|
15696
15457
|
};
|
|
15697
15458
|
};
|
|
15698
15459
|
|
|
@@ -15717,7 +15478,7 @@ class GDExecutor {
|
|
|
15717
15478
|
constructor() {
|
|
15718
15479
|
this.GroupMethodName = "T42.Group.Execute";
|
|
15719
15480
|
this.WndMethodName = "T42.Wnd.Execute";
|
|
15720
|
-
this._registry = lib
|
|
15481
|
+
this._registry = lib();
|
|
15721
15482
|
this._finished = Promise.resolve();
|
|
15722
15483
|
this.unsubCallbacks = {};
|
|
15723
15484
|
}
|
|
@@ -16186,6 +15947,9 @@ class GDExecutor {
|
|
|
16186
15947
|
async setModalState(windowId, isModal) {
|
|
16187
15948
|
return this.execute("setModalState", { windowId, options: { isModal } });
|
|
16188
15949
|
}
|
|
15950
|
+
async autoArrange(displayId) {
|
|
15951
|
+
return this.execute("autoArrange", { options: { displayId } });
|
|
15952
|
+
}
|
|
16189
15953
|
async handleFlydownBoundsRequested(targetId, data) {
|
|
16190
15954
|
const cancelCallback = () => data.cancel = true;
|
|
16191
15955
|
const callbackData = {
|
|
@@ -16311,7 +16075,7 @@ class GDExecutor {
|
|
|
16311
16075
|
}
|
|
16312
16076
|
showDialog(resultWindow, options) {
|
|
16313
16077
|
return new Promise((res, rej) => {
|
|
16314
|
-
const token =
|
|
16078
|
+
const token = Utils.generateId();
|
|
16315
16079
|
const un = this._registry.add("event", (args) => {
|
|
16316
16080
|
if (args.type === "DialogResult" && args.windowId === resultWindow.id && args.data.token === token) {
|
|
16317
16081
|
un();
|
|
@@ -16366,6 +16130,9 @@ class GDExecutor {
|
|
|
16366
16130
|
return this.nonWindowHandlers(callback, gdWindow.id, "OnClosing");
|
|
16367
16131
|
}
|
|
16368
16132
|
}
|
|
16133
|
+
onGroupClosing(callback, group) {
|
|
16134
|
+
return this.nonWindowHandlersCore(group.id, "OnClosing", true, callback);
|
|
16135
|
+
}
|
|
16369
16136
|
onRefreshing(callback, gdWindow) {
|
|
16370
16137
|
const glue42gd = typeof window !== "undefined" && window.glue42gd;
|
|
16371
16138
|
if (glue42gd && gdWindow.windowType === "electron") {
|
|
@@ -16384,27 +16151,66 @@ class GDExecutor {
|
|
|
16384
16151
|
return this.nonWindowHandlers(callback, gdWindow.id, "OnNavigating");
|
|
16385
16152
|
}
|
|
16386
16153
|
}
|
|
16154
|
+
async clone(window, cloneOptions) {
|
|
16155
|
+
const args = {
|
|
16156
|
+
windowId: window.id,
|
|
16157
|
+
options: cloneOptions
|
|
16158
|
+
};
|
|
16159
|
+
const result = await this.execute("clone", args);
|
|
16160
|
+
const win = await windowStore.waitFor(result.id);
|
|
16161
|
+
return win.API;
|
|
16162
|
+
}
|
|
16387
16163
|
async goBack(resultWindow) {
|
|
16388
16164
|
await this.execute("goBack", { windowId: resultWindow.id });
|
|
16389
16165
|
}
|
|
16390
16166
|
async goForward(resultWindow) {
|
|
16391
16167
|
await this.execute("goForward", { windowId: resultWindow.id });
|
|
16392
16168
|
}
|
|
16393
|
-
|
|
16394
|
-
|
|
16169
|
+
async getDockingPlacement(window) {
|
|
16170
|
+
return this.execute("getDockingPlacement", { windowId: window.id });
|
|
16171
|
+
}
|
|
16172
|
+
dock(window, options) {
|
|
16173
|
+
return this.execute("dock", { windowId: window.id, options });
|
|
16174
|
+
}
|
|
16175
|
+
clearCallbacks(id) {
|
|
16176
|
+
const keys = Object.keys(this.unsubCallbacks);
|
|
16177
|
+
keys.forEach((key) => {
|
|
16178
|
+
if (key.startsWith(id)) {
|
|
16179
|
+
delete this.unsubCallbacks[key];
|
|
16180
|
+
}
|
|
16181
|
+
});
|
|
16182
|
+
}
|
|
16183
|
+
nonWindowHandlers(callback, targetId, type) {
|
|
16184
|
+
return this.nonWindowHandlersCore(targetId, type, false, callback);
|
|
16185
|
+
}
|
|
16186
|
+
nonWindowHandlersCore(targetId, type, isGroup, callback) {
|
|
16187
|
+
const id = `${targetId}-${type}`;
|
|
16395
16188
|
const unsub = () => {
|
|
16189
|
+
var _a;
|
|
16396
16190
|
if (this.unsubCallbacks[id]) {
|
|
16397
16191
|
const callbacks = this.unsubCallbacks[id];
|
|
16398
16192
|
this.unsubCallbacks[id] = callbacks.filter((cb) => cb !== callback);
|
|
16193
|
+
if (this.unsubCallbacks[id].length === 0) {
|
|
16194
|
+
delete this.unsubCallbacks[id];
|
|
16195
|
+
}
|
|
16399
16196
|
}
|
|
16400
|
-
const cbs = this.unsubCallbacks[id];
|
|
16197
|
+
const cbs = (_a = this.unsubCallbacks[id]) !== null && _a !== void 0 ? _a : [];
|
|
16401
16198
|
if (cbs.length === 0) {
|
|
16402
|
-
|
|
16403
|
-
|
|
16404
|
-
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16199
|
+
const options = {
|
|
16200
|
+
unsubscribe: true
|
|
16201
|
+
};
|
|
16202
|
+
if (isGroup) {
|
|
16203
|
+
this.executeGroup(type, {
|
|
16204
|
+
groupId: targetId,
|
|
16205
|
+
options
|
|
16206
|
+
});
|
|
16207
|
+
}
|
|
16208
|
+
else {
|
|
16209
|
+
this.execute(type, {
|
|
16210
|
+
windowId: targetId,
|
|
16211
|
+
options
|
|
16212
|
+
});
|
|
16213
|
+
}
|
|
16408
16214
|
}
|
|
16409
16215
|
};
|
|
16410
16216
|
if (this.unsubCallbacks[id]) {
|
|
@@ -16414,10 +16220,12 @@ class GDExecutor {
|
|
|
16414
16220
|
else {
|
|
16415
16221
|
this.unsubCallbacks[id] = [callback];
|
|
16416
16222
|
}
|
|
16417
|
-
|
|
16418
|
-
|
|
16419
|
-
}
|
|
16420
|
-
|
|
16223
|
+
if (isGroup) {
|
|
16224
|
+
this.executeGroup(type, { groupId: targetId });
|
|
16225
|
+
}
|
|
16226
|
+
else {
|
|
16227
|
+
this.execute(type, { windowId: targetId });
|
|
16228
|
+
}
|
|
16421
16229
|
return unsub;
|
|
16422
16230
|
}
|
|
16423
16231
|
reformatFlydownOptions(windowId, options) {
|
|
@@ -16514,7 +16322,7 @@ class GDExecutor {
|
|
|
16514
16322
|
async executeWithToken(methodName, options) {
|
|
16515
16323
|
let un;
|
|
16516
16324
|
try {
|
|
16517
|
-
const token =
|
|
16325
|
+
const token = Utils.generateId();
|
|
16518
16326
|
const event = new Promise((r) => {
|
|
16519
16327
|
un = this._registry.add("event", (data) => {
|
|
16520
16328
|
if (data.token === token) {
|
|
@@ -16593,7 +16401,7 @@ var executor = new GDExecutor();
|
|
|
16593
16401
|
|
|
16594
16402
|
class GDEnvironment {
|
|
16595
16403
|
constructor(agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, wndId) {
|
|
16596
|
-
this._registry = lib
|
|
16404
|
+
this._registry = lib();
|
|
16597
16405
|
this._waitTimeout = 10000;
|
|
16598
16406
|
this._agm = agm;
|
|
16599
16407
|
this._logger = logger.subLogger("gd-env");
|
|
@@ -16697,6 +16505,9 @@ class GDEnvironment {
|
|
|
16697
16505
|
onWindowLostFocus(callback) {
|
|
16698
16506
|
return this._registry.add("lost-focus", callback);
|
|
16699
16507
|
}
|
|
16508
|
+
onWindowsAutoArrangeChanged(callback) {
|
|
16509
|
+
return this._registry.add("windows-auto-arranged-changed", callback);
|
|
16510
|
+
}
|
|
16700
16511
|
respondToEvent(args) {
|
|
16701
16512
|
if (args.type === "ShowFlydownBoundsRequested") {
|
|
16702
16513
|
return this.executor.handleFlydownBoundsRequested(args.data.windowId, args.data);
|
|
@@ -16715,6 +16526,7 @@ class GDEnvironment {
|
|
|
16715
16526
|
const existingWindow = windowStore.get(w.id);
|
|
16716
16527
|
if (existingWindow) {
|
|
16717
16528
|
existingWindow.Events.handleUpdate(this.mapToWindowConstructorOptions(w));
|
|
16529
|
+
existingWindow.GroupCreationArgs = this.mapToGroupCreationArgs(w);
|
|
16718
16530
|
}
|
|
16719
16531
|
else {
|
|
16720
16532
|
const win = this.createWindow(w.id, w);
|
|
@@ -16748,6 +16560,12 @@ class GDEnvironment {
|
|
|
16748
16560
|
this._registry.execute("window-event", windowInfo);
|
|
16749
16561
|
return;
|
|
16750
16562
|
}
|
|
16563
|
+
if (windowInfo.type === "OnWindowsAutoArrangeChanged") {
|
|
16564
|
+
const info = windowInfo;
|
|
16565
|
+
this._registry.execute("windows-auto-arranged-changed", info.data);
|
|
16566
|
+
this._registry.execute("window-event", windowInfo);
|
|
16567
|
+
return;
|
|
16568
|
+
}
|
|
16751
16569
|
const windowObjectAndEvents = windowStore.get((windowInfo).windowId);
|
|
16752
16570
|
if (!windowObjectAndEvents) {
|
|
16753
16571
|
this._logger.error(`received update for unknown window. Stream:', ${JSON.stringify(windowInfo, null, 4)}`);
|
|
@@ -16854,16 +16672,27 @@ class GDEnvironment {
|
|
|
16854
16672
|
if (windowInfo.type === "PlacementSettingsChanged") {
|
|
16855
16673
|
theWindowEvents.handlePlacementSettingsChanged(windowInfo.data);
|
|
16856
16674
|
}
|
|
16675
|
+
if (windowInfo.type === "DockingChanged") {
|
|
16676
|
+
theWindowEvents.handleDockingChanged(windowInfo.data);
|
|
16677
|
+
}
|
|
16857
16678
|
this._registry.execute("window-event", extendedStreamEvent);
|
|
16858
16679
|
}
|
|
16859
16680
|
createWindow(windowId, options) {
|
|
16860
16681
|
const windowObjAndEvents = windowFactory(windowId, this.mapToWindowConstructorOptions(options), executor, this._logger, this._appManagerGetter, this._displayAPIGetter, this._channelsAPIGetter, this._agm);
|
|
16682
|
+
windowObjAndEvents.GroupCreationArgs = this.mapToGroupCreationArgs(options);
|
|
16861
16683
|
windowStore.add(windowObjAndEvents);
|
|
16862
16684
|
return windowObjAndEvents;
|
|
16863
16685
|
}
|
|
16864
16686
|
async focusChanged(theWindowEvents, theWindow, focus) {
|
|
16865
16687
|
theWindowEvents.handleFocusChanged(focus);
|
|
16866
|
-
|
|
16688
|
+
try {
|
|
16689
|
+
if (!this._configuration.windowAvailableOnURLChanged) {
|
|
16690
|
+
await windowStore.waitFor(theWindow.id);
|
|
16691
|
+
}
|
|
16692
|
+
}
|
|
16693
|
+
catch (error) {
|
|
16694
|
+
return;
|
|
16695
|
+
}
|
|
16867
16696
|
if (focus) {
|
|
16868
16697
|
this._registry.execute("got-focus", theWindow);
|
|
16869
16698
|
}
|
|
@@ -16904,6 +16733,12 @@ class GDEnvironment {
|
|
|
16904
16733
|
applicationName: args.applicationName
|
|
16905
16734
|
};
|
|
16906
16735
|
}
|
|
16736
|
+
mapToGroupCreationArgs(args) {
|
|
16737
|
+
return {
|
|
16738
|
+
isGroupHibernated: args.isGroupHibernated,
|
|
16739
|
+
isGroupVisible: args.isGroupVisible
|
|
16740
|
+
};
|
|
16741
|
+
}
|
|
16907
16742
|
getExtendedStreamEvent(streamEvent) {
|
|
16908
16743
|
try {
|
|
16909
16744
|
if (!streamEvent.windowId) {
|
|
@@ -16954,15 +16789,18 @@ var envDetector = (agm, logger, appManagerGetter, displayAPIGetter, channelsAPIG
|
|
|
16954
16789
|
};
|
|
16955
16790
|
|
|
16956
16791
|
var groupFactory = (id, executor) => {
|
|
16957
|
-
const _registry = lib
|
|
16792
|
+
const _registry = lib();
|
|
16958
16793
|
const _windowsId = [];
|
|
16959
|
-
let _isHibernatedFlag
|
|
16960
|
-
let _isVisible
|
|
16794
|
+
let _isHibernatedFlag;
|
|
16795
|
+
let _isVisible;
|
|
16961
16796
|
async function addWindow(winId) {
|
|
16797
|
+
var _a, _b, _c, _d;
|
|
16962
16798
|
if (_windowsId.indexOf(winId) === -1) {
|
|
16963
16799
|
_windowsId.push(winId);
|
|
16964
16800
|
const win = windowStore.get(winId);
|
|
16965
16801
|
win.Events.handleGroupChanged(groupObject, undefined);
|
|
16802
|
+
_isHibernatedFlag = (_b = (_a = win.GroupCreationArgs.isGroupHibernated) !== null && _a !== void 0 ? _a : _isHibernatedFlag) !== null && _b !== void 0 ? _b : false;
|
|
16803
|
+
_isVisible = (_d = (_c = win.GroupCreationArgs.isGroupVisible) !== null && _c !== void 0 ? _c : _isVisible) !== null && _d !== void 0 ? _d : true;
|
|
16966
16804
|
await executor.finished;
|
|
16967
16805
|
_registry.execute("window-added", groupObject, win.API);
|
|
16968
16806
|
}
|
|
@@ -17036,7 +16874,7 @@ var groupFactory = (id, executor) => {
|
|
|
17036
16874
|
const _isGroupHeaderVisible = windowWithHiddenHeader === undefined;
|
|
17037
16875
|
return _isGroupHeaderVisible;
|
|
17038
16876
|
}
|
|
17039
|
-
function
|
|
16877
|
+
function isHibernated() {
|
|
17040
16878
|
return _isHibernatedFlag;
|
|
17041
16879
|
}
|
|
17042
16880
|
function onHeaderVisibilityChanged(callback) {
|
|
@@ -17057,6 +16895,21 @@ var groupFactory = (id, executor) => {
|
|
|
17057
16895
|
}
|
|
17058
16896
|
return _registry.add("group-visibility-changed", callback);
|
|
17059
16897
|
}
|
|
16898
|
+
function onClosing(callback) {
|
|
16899
|
+
if (typeof callback !== "function") {
|
|
16900
|
+
throw new Error("callback must be a function");
|
|
16901
|
+
}
|
|
16902
|
+
const callbackWrap = (success, error, prevent) => {
|
|
16903
|
+
const promise = callback(prevent);
|
|
16904
|
+
if (promise === null || promise === void 0 ? void 0 : promise.then) {
|
|
16905
|
+
promise.then(success).catch(error);
|
|
16906
|
+
}
|
|
16907
|
+
else {
|
|
16908
|
+
success();
|
|
16909
|
+
}
|
|
16910
|
+
};
|
|
16911
|
+
return executor.onGroupClosing(callbackWrap, groupObject);
|
|
16912
|
+
}
|
|
17060
16913
|
const groupObject = {
|
|
17061
16914
|
id,
|
|
17062
16915
|
get windows() {
|
|
@@ -17067,7 +16920,7 @@ var groupFactory = (id, executor) => {
|
|
|
17067
16920
|
return _getGroupHeaderVisibility();
|
|
17068
16921
|
},
|
|
17069
16922
|
get isHibernated() {
|
|
17070
|
-
return
|
|
16923
|
+
return isHibernated();
|
|
17071
16924
|
},
|
|
17072
16925
|
get isVisible() {
|
|
17073
16926
|
return _isVisible;
|
|
@@ -17123,7 +16976,8 @@ var groupFactory = (id, executor) => {
|
|
|
17123
16976
|
onHeaderVisibilityChanged,
|
|
17124
16977
|
onWindowAdded,
|
|
17125
16978
|
onWindowRemoved,
|
|
17126
|
-
onVisibilityChanged
|
|
16979
|
+
onVisibilityChanged,
|
|
16980
|
+
onClosing,
|
|
17127
16981
|
};
|
|
17128
16982
|
const internal = {
|
|
17129
16983
|
get windows() {
|
|
@@ -17142,7 +16996,7 @@ var groupFactory = (id, executor) => {
|
|
|
17142
16996
|
};
|
|
17143
16997
|
|
|
17144
16998
|
var groupsFactory = (environment, logger) => {
|
|
17145
|
-
const _registry = lib
|
|
16999
|
+
const _registry = lib();
|
|
17146
17000
|
const _groups = {};
|
|
17147
17001
|
let heardForWindowsCounter = -1;
|
|
17148
17002
|
const windows = windowStore.list;
|
|
@@ -17314,6 +17168,7 @@ var groupsFactory = (environment, logger) => {
|
|
|
17314
17168
|
const group = groupWrapper.groupAPI;
|
|
17315
17169
|
if (group.windows.length === 0) {
|
|
17316
17170
|
delete _groups[group.id];
|
|
17171
|
+
executor.clearCallbacks(group.id);
|
|
17317
17172
|
_registry.execute("group-removed", group);
|
|
17318
17173
|
}
|
|
17319
17174
|
}
|
|
@@ -17393,7 +17248,7 @@ var groupsFactory = (environment, logger) => {
|
|
|
17393
17248
|
};
|
|
17394
17249
|
|
|
17395
17250
|
var WindowsFactory = (agm, logger, appManagerGetter, displayAPIGetter, channelsGetter, gdMajorVersion) => {
|
|
17396
|
-
const _registry = lib
|
|
17251
|
+
const _registry = lib();
|
|
17397
17252
|
const _logger = logger;
|
|
17398
17253
|
let groups;
|
|
17399
17254
|
let environment;
|
|
@@ -17513,6 +17368,9 @@ var WindowsFactory = (agm, logger, appManagerGetter, displayAPIGetter, channelsG
|
|
|
17513
17368
|
const winId = win ? win.id : "";
|
|
17514
17369
|
return executor.configure(winId, options);
|
|
17515
17370
|
}
|
|
17371
|
+
function autoArrange(displayId) {
|
|
17372
|
+
return executor.autoArrange(displayId);
|
|
17373
|
+
}
|
|
17516
17374
|
function windowAdded(callback) {
|
|
17517
17375
|
return _registry.add("window-added", callback);
|
|
17518
17376
|
}
|
|
@@ -17599,6 +17457,9 @@ var WindowsFactory = (agm, logger, appManagerGetter, displayAPIGetter, channelsG
|
|
|
17599
17457
|
}
|
|
17600
17458
|
};
|
|
17601
17459
|
}
|
|
17460
|
+
function onArrangementChanged(callback) {
|
|
17461
|
+
return environment.onWindowsAutoArrangeChanged(callback);
|
|
17462
|
+
}
|
|
17602
17463
|
function onEvent(callback) {
|
|
17603
17464
|
let unsubFunc;
|
|
17604
17465
|
let unsubscribed = false;
|
|
@@ -17643,6 +17504,7 @@ var WindowsFactory = (agm, logger, appManagerGetter, displayAPIGetter, channelsG
|
|
|
17643
17504
|
onTabAttached: tabAttached,
|
|
17644
17505
|
onTabDetached: tabDetached,
|
|
17645
17506
|
onWindowFrameColorChanged,
|
|
17507
|
+
onArrangementChanged,
|
|
17646
17508
|
get groups() {
|
|
17647
17509
|
return groups.groupsAPI;
|
|
17648
17510
|
},
|
|
@@ -17651,7 +17513,8 @@ var WindowsFactory = (agm, logger, appManagerGetter, displayAPIGetter, channelsG
|
|
|
17651
17513
|
onEvent,
|
|
17652
17514
|
createFlydown,
|
|
17653
17515
|
showPopup,
|
|
17654
|
-
configure
|
|
17516
|
+
configure,
|
|
17517
|
+
autoArrange
|
|
17655
17518
|
};
|
|
17656
17519
|
};
|
|
17657
17520
|
|
|
@@ -17852,6 +17715,9 @@ class LayoutsAPIImpl {
|
|
|
17852
17715
|
if (Array.isArray(layout.instances)) {
|
|
17853
17716
|
layoutObject.options.instances = layout.instances;
|
|
17854
17717
|
}
|
|
17718
|
+
if (typeof layout.setAsCurrent === "boolean") {
|
|
17719
|
+
layoutObject.options.setAsCurrent = layout.setAsCurrent;
|
|
17720
|
+
}
|
|
17855
17721
|
}
|
|
17856
17722
|
else {
|
|
17857
17723
|
return reject(new Error(`layout type ${layout.type} is not supported`));
|
|
@@ -18147,7 +18013,7 @@ class LayoutsAPIImpl {
|
|
|
18147
18013
|
invokeMethodAndTrack(methodName, args, resolve, reject, skipStreamEvent) {
|
|
18148
18014
|
let streamEventReceived = skipStreamEvent;
|
|
18149
18015
|
let agmResult;
|
|
18150
|
-
const token =
|
|
18016
|
+
const token = Utils.generateId();
|
|
18151
18017
|
args.token = token;
|
|
18152
18018
|
const handleResult = () => {
|
|
18153
18019
|
if (streamEventReceived && agmResult) {
|
|
@@ -18389,7 +18255,7 @@ function LayoutsFactory (config) {
|
|
|
18389
18255
|
}
|
|
18390
18256
|
config.mode = config.mode || "slim";
|
|
18391
18257
|
const logger = config.logger;
|
|
18392
|
-
const callbacks = lib
|
|
18258
|
+
const callbacks = lib();
|
|
18393
18259
|
let acsStream;
|
|
18394
18260
|
if (config.mode === "full" || "fullWaitSnapshot") {
|
|
18395
18261
|
acsStream = new ACSStream(config.agm, callbacks);
|
|
@@ -18406,7 +18272,7 @@ class DisplayManager {
|
|
|
18406
18272
|
constructor(_agm, _logger) {
|
|
18407
18273
|
this._agm = _agm;
|
|
18408
18274
|
this._logger = _logger;
|
|
18409
|
-
this._registry = lib
|
|
18275
|
+
this._registry = lib();
|
|
18410
18276
|
this._registered = false;
|
|
18411
18277
|
this.all = async () => {
|
|
18412
18278
|
const displays = await this.callGD(DisplayCommand.GetAll, {});
|
|
@@ -18653,7 +18519,7 @@ class ChannelsImpl {
|
|
|
18653
18519
|
this.subsKey = "subs";
|
|
18654
18520
|
this.changedKey = "changed";
|
|
18655
18521
|
this.isInitialJoin = true;
|
|
18656
|
-
this.registry = lib
|
|
18522
|
+
this.registry = lib();
|
|
18657
18523
|
this.pendingReplays = {};
|
|
18658
18524
|
this.shared.subscribe(this.handler.bind(this));
|
|
18659
18525
|
if (typeof window !== "undefined" && typeof window.glue42gd !== "undefined") {
|
|
@@ -18667,7 +18533,7 @@ class ChannelsImpl {
|
|
|
18667
18533
|
if (typeof callback !== "function") {
|
|
18668
18534
|
throw new Error("Please provide the callback as a function!");
|
|
18669
18535
|
}
|
|
18670
|
-
const id =
|
|
18536
|
+
const id = Utils.generateId();
|
|
18671
18537
|
this.pendingReplays[id] = true;
|
|
18672
18538
|
if (this.lastUpdate) {
|
|
18673
18539
|
let lastUpdate = Object.assign({}, this.lastUpdate);
|
|
@@ -18932,7 +18798,7 @@ const UnregisterAllCommand = "unregisterAll";
|
|
|
18932
18798
|
class HotkeysImpl {
|
|
18933
18799
|
constructor(agm) {
|
|
18934
18800
|
this.agm = agm;
|
|
18935
|
-
this.registry = lib
|
|
18801
|
+
this.registry = lib();
|
|
18936
18802
|
this.firstHotkey = true;
|
|
18937
18803
|
this.hotkeys = new Map();
|
|
18938
18804
|
}
|
|
@@ -19012,7 +18878,7 @@ function factory$3(agm) {
|
|
|
19012
18878
|
};
|
|
19013
18879
|
}
|
|
19014
18880
|
|
|
19015
|
-
var version = "6.0
|
|
18881
|
+
var version = "6.2.0";
|
|
19016
18882
|
|
|
19017
18883
|
var prepareConfig = (options) => {
|
|
19018
18884
|
function getLibConfig(value, defaultMode, trueMode) {
|
|
@@ -19080,7 +18946,7 @@ var prepareConfig = (options) => {
|
|
|
19080
18946
|
class Glue42Notification {
|
|
19081
18947
|
constructor(options) {
|
|
19082
18948
|
this.options = options;
|
|
19083
|
-
this.callbacks = lib
|
|
18949
|
+
this.callbacks = lib();
|
|
19084
18950
|
this.actions = options.actions;
|
|
19085
18951
|
this.body = options.body;
|
|
19086
18952
|
this.badge = options.badge;
|
|
@@ -19146,21 +19012,21 @@ const STARTING_INDEX = 0;
|
|
|
19146
19012
|
class Notifications {
|
|
19147
19013
|
constructor(interop, logger) {
|
|
19148
19014
|
this.interop = interop;
|
|
19149
|
-
this.logger = logger;
|
|
19150
19015
|
this.NotificationsSubscribeStream = "T42.GNS.Subscribe.Notifications";
|
|
19151
19016
|
this.NotificationsCounterStream = "T42.Notifications.Counter";
|
|
19152
19017
|
this.RaiseNotificationMethodName = "T42.GNS.Publish.RaiseNotification";
|
|
19153
19018
|
this.NotificationsExecuteMethod = "T42.Notifications.Execute";
|
|
19154
19019
|
this.methodsRegistered = false;
|
|
19155
19020
|
this.NOTIFICATIONS_CONFIGURE_METHOD_NAME = "T42.Notifications.Configure";
|
|
19156
|
-
this.methodNameRoot = "T42.Notifications.Handler-" +
|
|
19021
|
+
this.methodNameRoot = "T42.Notifications.Handler-" + Utils.generateId();
|
|
19157
19022
|
this.nextId = 0;
|
|
19158
19023
|
this.notifications = {};
|
|
19159
|
-
this.registry = lib
|
|
19024
|
+
this.registry = lib();
|
|
19160
19025
|
this.subscribedForNotifications = false;
|
|
19161
19026
|
this.subscribedCounterStream = false;
|
|
19162
19027
|
this.subscriptionsCountForNotifications = 0;
|
|
19163
19028
|
this.subscriptionsCountForCounter = 0;
|
|
19029
|
+
this.logger = logger.subLogger("notifications");
|
|
19164
19030
|
this._panel = new PanelAPI(interop, this.onStreamEventCore.bind(this));
|
|
19165
19031
|
this.subscribeInternalEvents();
|
|
19166
19032
|
}
|
|
@@ -19171,7 +19037,7 @@ class Notifications {
|
|
|
19171
19037
|
return this._panel.toAPI();
|
|
19172
19038
|
}
|
|
19173
19039
|
async raise(options) {
|
|
19174
|
-
var _a, _b, _c;
|
|
19040
|
+
var _a, _b, _c, _d;
|
|
19175
19041
|
this.validate(options);
|
|
19176
19042
|
if (!this.methodsRegistered) {
|
|
19177
19043
|
const bunchOfPromises = [];
|
|
@@ -19184,9 +19050,11 @@ class Notifications {
|
|
|
19184
19050
|
const id = String(this.nextId++);
|
|
19185
19051
|
const type = (_a = options.type) !== null && _a !== void 0 ? _a : "Notification";
|
|
19186
19052
|
const notification = {
|
|
19053
|
+
id: options.id,
|
|
19054
|
+
state: (_b = options.state) !== null && _b !== void 0 ? _b : "Active",
|
|
19187
19055
|
title: options.title,
|
|
19188
19056
|
type,
|
|
19189
|
-
severity: (
|
|
19057
|
+
severity: (_c = options.severity) !== null && _c !== void 0 ? _c : "None",
|
|
19190
19058
|
description: options.body,
|
|
19191
19059
|
glueRoutingDetailMethodName: `${this.methodNameRoot}_${STARTING_INDEX}`,
|
|
19192
19060
|
actions: [],
|
|
@@ -19203,7 +19071,7 @@ class Notifications {
|
|
|
19203
19071
|
this.notifications[id] = g42notification;
|
|
19204
19072
|
try {
|
|
19205
19073
|
const invocationResult = await this.interop.invoke(this.RaiseNotificationMethodName, { notification });
|
|
19206
|
-
g42notification.id = (
|
|
19074
|
+
g42notification.id = (_d = invocationResult.returned) === null || _d === void 0 ? void 0 : _d.id;
|
|
19207
19075
|
}
|
|
19208
19076
|
catch (err) {
|
|
19209
19077
|
const errorMessage = err.message;
|
|
@@ -19222,7 +19090,7 @@ class Notifications {
|
|
|
19222
19090
|
return result.returned;
|
|
19223
19091
|
}
|
|
19224
19092
|
async configure(options) {
|
|
19225
|
-
var _a, _b, _c, _d;
|
|
19093
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19226
19094
|
if (!options || Array.isArray(options)) {
|
|
19227
19095
|
throw new Error("Invalid options - should be an object.");
|
|
19228
19096
|
}
|
|
@@ -19247,6 +19115,24 @@ class Notifications {
|
|
|
19247
19115
|
if (((_c = options.sourceFilter) === null || _c === void 0 ? void 0 : _c.blocked) && !Array.isArray((_d = options.sourceFilter) === null || _d === void 0 ? void 0 : _d.blocked)) {
|
|
19248
19116
|
throw new Error("Expected type of sourceFilter.blocked - array.");
|
|
19249
19117
|
}
|
|
19118
|
+
if (options.toasts && typeof options.toasts !== "object") {
|
|
19119
|
+
throw new Error("Expected type of (options.toasts - object.");
|
|
19120
|
+
}
|
|
19121
|
+
if (((_e = options.toasts) === null || _e === void 0 ? void 0 : _e.mode) && typeof options.toasts.mode !== "string") {
|
|
19122
|
+
throw new Error("Expected type of (options.toasts.mode - string.");
|
|
19123
|
+
}
|
|
19124
|
+
if (((_f = options.toasts) === null || _f === void 0 ? void 0 : _f.stackBy) && typeof options.toasts.stackBy !== "string") {
|
|
19125
|
+
throw new Error("Expected type of (options.toasts.stackBy - string.");
|
|
19126
|
+
}
|
|
19127
|
+
if (options.placement && typeof options.placement !== "object") {
|
|
19128
|
+
throw new Error("Expected type of (options.placement - object.");
|
|
19129
|
+
}
|
|
19130
|
+
if (((_g = options.placement) === null || _g === void 0 ? void 0 : _g.toasts) && typeof options.placement.toasts !== "string") {
|
|
19131
|
+
throw new Error("Expected type of (options.placement.toasts - string.");
|
|
19132
|
+
}
|
|
19133
|
+
if (((_h = options.placement) === null || _h === void 0 ? void 0 : _h.panel) && typeof options.placement.panel !== "string") {
|
|
19134
|
+
throw new Error("Expected type of (options.placement.panel - string.");
|
|
19135
|
+
}
|
|
19250
19136
|
const result = await this.interop.invoke(this.NOTIFICATIONS_CONFIGURE_METHOD_NAME, options);
|
|
19251
19137
|
return result.returned;
|
|
19252
19138
|
}
|
|
@@ -19258,6 +19144,17 @@ class Notifications {
|
|
|
19258
19144
|
const interopResult = await this.interop.invoke(this.NotificationsExecuteMethod, { command: "list" });
|
|
19259
19145
|
return interopResult.returned.notifications;
|
|
19260
19146
|
}
|
|
19147
|
+
async updateData(id, data) {
|
|
19148
|
+
const replacer = (key, value) => typeof value === "undefined" ? null : value;
|
|
19149
|
+
const attribute = {
|
|
19150
|
+
key: "data",
|
|
19151
|
+
value: {
|
|
19152
|
+
stringValue: JSON.stringify(data, replacer)
|
|
19153
|
+
}
|
|
19154
|
+
};
|
|
19155
|
+
const interopResult = await this.interop.invoke(this.NotificationsExecuteMethod, { command: "create-or-update-attribute", data: { id, attribute } });
|
|
19156
|
+
return interopResult.returned;
|
|
19157
|
+
}
|
|
19261
19158
|
onRaised(callback) {
|
|
19262
19159
|
return this.onStreamEventCore("on-notification-raised", callback);
|
|
19263
19160
|
}
|
|
@@ -19289,6 +19186,17 @@ class Notifications {
|
|
|
19289
19186
|
this.closeStreamCounterSubscriptionIfNoNeeded();
|
|
19290
19187
|
};
|
|
19291
19188
|
}
|
|
19189
|
+
onDataChanged(callback) {
|
|
19190
|
+
if (typeof callback !== "function") {
|
|
19191
|
+
throw new Error("Please provide the callback as a function!");
|
|
19192
|
+
}
|
|
19193
|
+
this.subscribe();
|
|
19194
|
+
const un = this.registry.add("on-notification-data-changed", callback);
|
|
19195
|
+
return () => {
|
|
19196
|
+
un();
|
|
19197
|
+
this.closeStreamSubscriptionIfNoNeeded();
|
|
19198
|
+
};
|
|
19199
|
+
}
|
|
19292
19200
|
async clearAll() {
|
|
19293
19201
|
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAll" });
|
|
19294
19202
|
}
|
|
@@ -19317,17 +19225,7 @@ class Notifications {
|
|
|
19317
19225
|
if (!state) {
|
|
19318
19226
|
throw new Error("The 'state' argument cannot be null or undefined");
|
|
19319
19227
|
}
|
|
19320
|
-
|
|
19321
|
-
throw new Error("The 'state' argument must be a string");
|
|
19322
|
-
}
|
|
19323
|
-
const validStates = [
|
|
19324
|
-
"Active",
|
|
19325
|
-
"Acknowledged",
|
|
19326
|
-
"Stale"
|
|
19327
|
-
];
|
|
19328
|
-
if (!validStates.includes(state)) {
|
|
19329
|
-
throw new Error(`The state argument: ${state} is not valid!`);
|
|
19330
|
-
}
|
|
19228
|
+
this.validateState(state);
|
|
19331
19229
|
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "updateState", data: { id, state } });
|
|
19332
19230
|
}
|
|
19333
19231
|
toAPI() {
|
|
@@ -19345,11 +19243,13 @@ class Notifications {
|
|
|
19345
19243
|
onClosed: this.onClosed.bind(this),
|
|
19346
19244
|
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
19347
19245
|
onCounterChanged: this.onCounterChanged.bind(this),
|
|
19246
|
+
onDataChanged: this.onDataChanged.bind(this),
|
|
19348
19247
|
clearAll: this.clearAll.bind(this),
|
|
19349
19248
|
clearOld: this.clearOld.bind(this),
|
|
19350
19249
|
clear: this.clear.bind(this),
|
|
19351
19250
|
click: this.click.bind(this),
|
|
19352
|
-
setState: this.setState.bind(this)
|
|
19251
|
+
setState: this.setState.bind(this),
|
|
19252
|
+
updateData: this.updateData.bind(this),
|
|
19353
19253
|
};
|
|
19354
19254
|
}
|
|
19355
19255
|
onStreamEventCore(key, callback) {
|
|
@@ -19435,6 +19335,22 @@ class Notifications {
|
|
|
19435
19335
|
if (options.toastExpiry && typeof options.toastExpiry !== "number") {
|
|
19436
19336
|
throw new Error("invalid options - toastExpiry should be a number");
|
|
19437
19337
|
}
|
|
19338
|
+
if (options.state) {
|
|
19339
|
+
this.validateState(options.state);
|
|
19340
|
+
}
|
|
19341
|
+
}
|
|
19342
|
+
validateState(state) {
|
|
19343
|
+
if (typeof (state) !== "string") {
|
|
19344
|
+
throw new Error("The 'state' argument must be a string");
|
|
19345
|
+
}
|
|
19346
|
+
const validStates = [
|
|
19347
|
+
"Active",
|
|
19348
|
+
"Acknowledged",
|
|
19349
|
+
"Stale"
|
|
19350
|
+
];
|
|
19351
|
+
if (!validStates.includes(state)) {
|
|
19352
|
+
throw new Error(`The state argument: ${state} is not valid!`);
|
|
19353
|
+
}
|
|
19438
19354
|
}
|
|
19439
19355
|
subscribe() {
|
|
19440
19356
|
this.subscriptionsCountForNotifications++;
|
|
@@ -19546,7 +19462,7 @@ class Notifications {
|
|
|
19546
19462
|
if (notification.state === "Closed") {
|
|
19547
19463
|
this.registry.execute("on-notification-closed", { id: notification.id });
|
|
19548
19464
|
}
|
|
19549
|
-
else
|
|
19465
|
+
else {
|
|
19550
19466
|
this.registry.execute("on-notification-raised", notification);
|
|
19551
19467
|
}
|
|
19552
19468
|
}
|
|
@@ -19554,14 +19470,22 @@ class Notifications {
|
|
|
19554
19470
|
handleDeltas(message) {
|
|
19555
19471
|
const deltas = message.deltas;
|
|
19556
19472
|
deltas.forEach((info) => {
|
|
19473
|
+
var _a;
|
|
19557
19474
|
const id = info.id;
|
|
19558
|
-
const delta = info.delta;
|
|
19475
|
+
const delta = (_a = info.delta) !== null && _a !== void 0 ? _a : {};
|
|
19559
19476
|
if (delta.state === "Closed") {
|
|
19560
|
-
this.registry.execute("on-notification-closed", { id });
|
|
19477
|
+
this.registry.execute("on-notification-closed", { id, ...delta });
|
|
19561
19478
|
}
|
|
19562
|
-
else {
|
|
19479
|
+
else if (delta.state) {
|
|
19563
19480
|
this.registry.execute("on-state-changed", { id }, delta.state);
|
|
19564
19481
|
}
|
|
19482
|
+
else if (delta.attributes) {
|
|
19483
|
+
const attributes = delta.attributes;
|
|
19484
|
+
const dataAttribute = attributes.find((a) => a.key === "data");
|
|
19485
|
+
if (dataAttribute) {
|
|
19486
|
+
this.registry.execute("on-notification-data-changed", { id }, JSON.parse(dataAttribute.value.stringValue));
|
|
19487
|
+
}
|
|
19488
|
+
}
|
|
19565
19489
|
});
|
|
19566
19490
|
}
|
|
19567
19491
|
handleOnClosed(id) {
|
|
@@ -19713,7 +19637,7 @@ class ThemesImpl {
|
|
|
19713
19637
|
constructor(contexts, interop) {
|
|
19714
19638
|
this.contexts = contexts;
|
|
19715
19639
|
this.interop = interop;
|
|
19716
|
-
this.registry = lib
|
|
19640
|
+
this.registry = lib();
|
|
19717
19641
|
this.isSubscribed = false;
|
|
19718
19642
|
this.getConfiguration();
|
|
19719
19643
|
}
|
|
@@ -19790,12 +19714,12 @@ const GLUE42_FDC3_INTENTS_METHOD_PREFIX = "Tick42.FDC3.Intents.";
|
|
|
19790
19714
|
const INTENTS_RESOLVER_INTEROP_PREFIX = "T42.Intents.Resolver.Control";
|
|
19791
19715
|
const INTENTS_RESOLVER_WIDTH = 400;
|
|
19792
19716
|
const INTENTS_RESOLVER_HEIGHT = 440;
|
|
19793
|
-
const DEFAULT_RESOLVER_RESPONSE_TIMEOUT =
|
|
19717
|
+
const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60 * 1000;
|
|
19794
19718
|
const INTENT_HANDLER_DEFAULT_PROPS = ["applicationName", "type"];
|
|
19795
19719
|
const INTENTS_RESOLVER_APP_NAME = "intentsResolver";
|
|
19796
|
-
const
|
|
19797
|
-
const
|
|
19798
|
-
const
|
|
19720
|
+
const DEFAULT_METHOD_RESPONSE_TIMEOUT_MS = 60 * 1000;
|
|
19721
|
+
const DEFAULT_RAISE_TIMEOUT_MS = 90 * 1000;
|
|
19722
|
+
const DEFAULT_PICK_HANDLER_BY_TIMEOUT_MS = 90 * 1000;
|
|
19799
19723
|
|
|
19800
19724
|
const PromisePlus = (executor, timeoutMilliseconds, timeoutMessage) => {
|
|
19801
19725
|
return new Promise((resolve, reject) => {
|
|
@@ -19846,6 +19770,179 @@ const PromiseWrap = (promise, timeoutMilliseconds, timeoutMessage) => {
|
|
|
19846
19770
|
});
|
|
19847
19771
|
};
|
|
19848
19772
|
|
|
19773
|
+
const validateIntentHandlerAsResponse = (handler) => {
|
|
19774
|
+
if (typeof handler !== "object") {
|
|
19775
|
+
return { isValid: false, error: `Response object has invalid 'handler' key. Expected an object, got ${typeof handler}` };
|
|
19776
|
+
}
|
|
19777
|
+
const compulsoryKeysExist = INTENT_HANDLER_DEFAULT_PROPS.filter((key) => !(key in handler));
|
|
19778
|
+
if (compulsoryKeysExist.length) {
|
|
19779
|
+
return { isValid: false, error: `Handler in Response object does not provide compulsory keys: ${compulsoryKeysExist.join(", ")}` };
|
|
19780
|
+
}
|
|
19781
|
+
return { isValid: true, ok: handler };
|
|
19782
|
+
};
|
|
19783
|
+
const validateRaiseIntentsResolverResponse = (responseObj) => {
|
|
19784
|
+
const invalidKey = Object.keys(responseObj).some((key) => key !== "intent" && key !== "handler");
|
|
19785
|
+
if (invalidKey) {
|
|
19786
|
+
return { isValid: false, error: "Response is not a valid object. Expected { intent: string, handler: IntentHandler }" };
|
|
19787
|
+
}
|
|
19788
|
+
if (typeof responseObj.intent !== "string") {
|
|
19789
|
+
return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
|
|
19790
|
+
}
|
|
19791
|
+
const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
|
|
19792
|
+
return isValid
|
|
19793
|
+
? { isValid: true, ok: { intent: responseObj.intent, handler: responseObj.handler } }
|
|
19794
|
+
: { isValid: false, error };
|
|
19795
|
+
};
|
|
19796
|
+
const validateFilterHandlersResolverResponse = (responseObj) => {
|
|
19797
|
+
if (!responseObj.handler) {
|
|
19798
|
+
return { isValid: false, error: "Response is not a valid object. Expected { handler: IntentHandler }" };
|
|
19799
|
+
}
|
|
19800
|
+
const { isValid, error } = validateIntentHandlerAsResponse(responseObj.handler);
|
|
19801
|
+
return isValid
|
|
19802
|
+
? { isValid: true, ok: { handler: responseObj.handler } }
|
|
19803
|
+
: { isValid: false, error };
|
|
19804
|
+
};
|
|
19805
|
+
const validateIntentRequestTarget = (target) => {
|
|
19806
|
+
if (!target) {
|
|
19807
|
+
return;
|
|
19808
|
+
}
|
|
19809
|
+
if (typeof target !== "string" && typeof target !== "object") {
|
|
19810
|
+
throw new Error(`Please provide the intent target as one of the valid values: "reuse", "startNew", { app: string }, { instance: string } `);
|
|
19811
|
+
}
|
|
19812
|
+
};
|
|
19813
|
+
const validateIntentRequestContext = (context) => {
|
|
19814
|
+
if (!context) {
|
|
19815
|
+
return;
|
|
19816
|
+
}
|
|
19817
|
+
if (typeof context !== "object") {
|
|
19818
|
+
throw new Error(`Please provide the intent context as an object`);
|
|
19819
|
+
}
|
|
19820
|
+
if (context.type && typeof context.type !== "string") {
|
|
19821
|
+
throw new Error(`Please provide the intent context as an object with 'type' property as string`);
|
|
19822
|
+
}
|
|
19823
|
+
if (context.data && typeof context.data !== "object") {
|
|
19824
|
+
throw new Error(`Please provide the intent context as an object with 'data' property as object`);
|
|
19825
|
+
}
|
|
19826
|
+
};
|
|
19827
|
+
const validateIntentRequestHandler = (handler) => {
|
|
19828
|
+
if (!handler.applicationName) {
|
|
19829
|
+
throw new Error(`Please provide applicationName for handler ${JSON.stringify(handler)}`);
|
|
19830
|
+
}
|
|
19831
|
+
if (!handler.type) {
|
|
19832
|
+
throw new Error(`Please provide type for handler ${JSON.stringify(handler)}`);
|
|
19833
|
+
}
|
|
19834
|
+
if (handler.type === "instance" && !handler.instanceId) {
|
|
19835
|
+
throw new Error(`Please provide instanceId for handler ${JSON.stringify(handler)}`);
|
|
19836
|
+
}
|
|
19837
|
+
};
|
|
19838
|
+
const validateIntentRequestTimeout = (timeout) => {
|
|
19839
|
+
if (!timeout) {
|
|
19840
|
+
return;
|
|
19841
|
+
}
|
|
19842
|
+
if (typeof timeout !== "number") {
|
|
19843
|
+
throw new Error(`Please provide the timeout as a number`);
|
|
19844
|
+
}
|
|
19845
|
+
if (timeout <= 0) {
|
|
19846
|
+
throw new Error(`Please provide the timeout as a positive number`);
|
|
19847
|
+
}
|
|
19848
|
+
};
|
|
19849
|
+
const validateWaitUserResponseIndefinitely = (waitUserResponseIndefinitely) => {
|
|
19850
|
+
if (!waitUserResponseIndefinitely) {
|
|
19851
|
+
return;
|
|
19852
|
+
}
|
|
19853
|
+
if (typeof waitUserResponseIndefinitely !== "boolean") {
|
|
19854
|
+
throw new Error("Please provide waitUserResponseIndefinitely as a boolean");
|
|
19855
|
+
}
|
|
19856
|
+
};
|
|
19857
|
+
const validateHandlerFilter = (handlerFilter) => {
|
|
19858
|
+
if (!handlerFilter) {
|
|
19859
|
+
throw new Error(`Provide 'handlerFilter' with at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'`);
|
|
19860
|
+
}
|
|
19861
|
+
const { title, openResolver, timeout, intent, contextTypes, resultType, applicationNames } = handlerFilter;
|
|
19862
|
+
if (typeof title !== "undefined" && (typeof title !== "string" || !title.length)) {
|
|
19863
|
+
throw new Error(`Provide 'title' as a non empty string`);
|
|
19864
|
+
}
|
|
19865
|
+
if (typeof openResolver !== "undefined" && typeof openResolver !== "boolean") {
|
|
19866
|
+
throw new Error(`Provide 'openResolver' prop as a boolean`);
|
|
19867
|
+
}
|
|
19868
|
+
if (typeof timeout !== "undefined" && (typeof timeout !== "number" || timeout <= 0)) {
|
|
19869
|
+
throw new Error(`Provide 'timeout' prop as a positive number`);
|
|
19870
|
+
}
|
|
19871
|
+
if (typeof intent !== "undefined" && (typeof intent !== "string" || !intent.length)) {
|
|
19872
|
+
throw new Error(`Provide 'intent' as a non empty string`);
|
|
19873
|
+
}
|
|
19874
|
+
if (typeof contextTypes !== "undefined" && (!Array.isArray(contextTypes) || contextTypes.some(ctx => typeof ctx !== "string"))) {
|
|
19875
|
+
throw new Error(`Provide 'contextTypes' as an array of non empty strings`);
|
|
19876
|
+
}
|
|
19877
|
+
if (typeof resultType !== "undefined" && (typeof resultType !== "string" || !resultType.length)) {
|
|
19878
|
+
throw new Error(`Provide 'resultType' as a non empty string`);
|
|
19879
|
+
}
|
|
19880
|
+
if (typeof applicationNames !== "undefined" && (!Array.isArray(applicationNames) || applicationNames.some(appName => typeof appName !== "string"))) {
|
|
19881
|
+
throw new Error(`Provide 'applicationNames' as an array of non empty strings`);
|
|
19882
|
+
}
|
|
19883
|
+
const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
|
|
19884
|
+
if (!Object.keys(handlerFilter).length) {
|
|
19885
|
+
throw new Error(errorMsg);
|
|
19886
|
+
}
|
|
19887
|
+
if (!intent && !resultType && (!contextTypes || !contextTypes.length) && (!applicationNames || !applicationNames.length)) {
|
|
19888
|
+
throw new Error(errorMsg);
|
|
19889
|
+
}
|
|
19890
|
+
};
|
|
19891
|
+
const validateIntentsResolverResponse = (method, responseObj) => {
|
|
19892
|
+
return method === "raise" ? validateRaiseIntentsResolverResponse(responseObj) : validateFilterHandlersResolverResponse(responseObj);
|
|
19893
|
+
};
|
|
19894
|
+
const validateIntentRequest = (request) => {
|
|
19895
|
+
validateIntentRequestContext(request.context);
|
|
19896
|
+
validateIntentRequestTarget(request.target);
|
|
19897
|
+
validateIntentRequestTimeout(request.timeout);
|
|
19898
|
+
validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
|
|
19899
|
+
if (request.handlers) {
|
|
19900
|
+
request.handlers.forEach((handler) => validateIntentRequestHandler(handler));
|
|
19901
|
+
}
|
|
19902
|
+
};
|
|
19903
|
+
const validateIntentHandler = (handler) => {
|
|
19904
|
+
if (typeof handler !== "object") {
|
|
19905
|
+
throw new Error("IntentHandler must be an object");
|
|
19906
|
+
}
|
|
19907
|
+
if (typeof handler.applicationName !== "string" || !handler.applicationName.length) {
|
|
19908
|
+
throw new Error(`Please provide 'applicationName' as a non-empty string`);
|
|
19909
|
+
}
|
|
19910
|
+
if (typeof handler.type !== "string" || !["app", "instance"].includes(handler.type)) {
|
|
19911
|
+
throw new Error(`Invalid 'type' property. Expected 'app' | 'instance' got ${handler.type}`);
|
|
19912
|
+
}
|
|
19913
|
+
if (typeof handler.applicationTitle !== "undefined" && typeof handler.applicationTitle !== "string") {
|
|
19914
|
+
throw new Error(`Provide 'applicationTitle' as a string`);
|
|
19915
|
+
}
|
|
19916
|
+
if (typeof handler.applicationDescription !== "undefined" && typeof handler.applicationDescription !== "string") {
|
|
19917
|
+
throw new Error(`Provide 'applicationDescription' as a string`);
|
|
19918
|
+
}
|
|
19919
|
+
if (typeof handler.applicationIcon !== "undefined" && typeof handler.applicationIcon !== "string") {
|
|
19920
|
+
throw new Error(`Provide 'applicationIcon' as a string`);
|
|
19921
|
+
}
|
|
19922
|
+
if (typeof handler.displayName !== "undefined" && typeof handler.displayName !== "string") {
|
|
19923
|
+
throw new Error(`Provide 'displayName' as a string`);
|
|
19924
|
+
}
|
|
19925
|
+
if (typeof handler.contextTypes !== "undefined" && (!Array.isArray(handler.contextTypes) || handler.contextTypes.some(ctx => typeof ctx !== "string"))) {
|
|
19926
|
+
throw new Error(`Provide 'contextTypes' as an array of non empty strings`);
|
|
19927
|
+
}
|
|
19928
|
+
if (typeof handler.instanceId !== "undefined" && typeof handler.instanceId !== "string") {
|
|
19929
|
+
throw new Error(`Provide 'instanceId' as a string`);
|
|
19930
|
+
}
|
|
19931
|
+
if (typeof handler.instanceTitle !== "undefined" && typeof handler.instanceTitle !== "string") {
|
|
19932
|
+
throw new Error(`Provide 'instanceTitle' as a string`);
|
|
19933
|
+
}
|
|
19934
|
+
if (typeof handler.resultType !== "undefined" && typeof handler.resultType !== "string") {
|
|
19935
|
+
throw new Error(`Provide 'resultType' as a string`);
|
|
19936
|
+
}
|
|
19937
|
+
};
|
|
19938
|
+
const clearNullUndefined = (obj) => {
|
|
19939
|
+
Object.keys(obj).forEach(key => {
|
|
19940
|
+
if (obj[key] === null || obj[key] === undefined) {
|
|
19941
|
+
delete obj[key];
|
|
19942
|
+
}
|
|
19943
|
+
});
|
|
19944
|
+
};
|
|
19945
|
+
|
|
19849
19946
|
class Intents {
|
|
19850
19947
|
constructor(interop, windows, logger, options, appManager) {
|
|
19851
19948
|
this.interop = interop;
|
|
@@ -19890,7 +19987,7 @@ class Intents {
|
|
|
19890
19987
|
if (typeof intentRequest === "string") {
|
|
19891
19988
|
intentRequest = { intent: intentRequest };
|
|
19892
19989
|
}
|
|
19893
|
-
|
|
19990
|
+
validateIntentRequest(intentRequest);
|
|
19894
19991
|
await Promise.all(this.unregisterIntentPromises);
|
|
19895
19992
|
const timeout = intentRequest.timeout || DEFAULT_RAISE_TIMEOUT_MS;
|
|
19896
19993
|
const resolverInstance = {};
|
|
@@ -20048,9 +20145,9 @@ class Intents {
|
|
|
20048
20145
|
intentFlag = rest;
|
|
20049
20146
|
}
|
|
20050
20147
|
try {
|
|
20051
|
-
await this.interop.register({ name: methodName, flags: { intent: intentFlag } }, (args) => {
|
|
20148
|
+
await this.interop.register({ name: methodName, flags: { intent: intentFlag } }, (args, caller) => {
|
|
20052
20149
|
if (this.myIntents.has(intentName)) {
|
|
20053
|
-
return handler(args);
|
|
20150
|
+
return handler(args, caller);
|
|
20054
20151
|
}
|
|
20055
20152
|
});
|
|
20056
20153
|
}
|
|
@@ -20062,20 +20159,79 @@ class Intents {
|
|
|
20062
20159
|
unsubscribe: () => this.unsubscribeIntent(intentName)
|
|
20063
20160
|
};
|
|
20064
20161
|
}
|
|
20162
|
+
async filterHandlers(handlerFilter) {
|
|
20163
|
+
var _a, _b;
|
|
20164
|
+
validateHandlerFilter(handlerFilter);
|
|
20165
|
+
if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
|
|
20166
|
+
throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
|
|
20167
|
+
}
|
|
20168
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Received 'filterHandlers' command with request: ${JSON.stringify(handlerFilter)}`);
|
|
20169
|
+
const filteredHandlers = this.filterHandlersBy(await this.all(), handlerFilter);
|
|
20170
|
+
if (!filteredHandlers || !filteredHandlers.length) {
|
|
20171
|
+
return { handlers: [] };
|
|
20172
|
+
}
|
|
20173
|
+
const { open, reason } = this.checkIfResolverShouldBeOpenedForFilterHandlers(filteredHandlers, handlerFilter);
|
|
20174
|
+
if (!open) {
|
|
20175
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Intent Resolver UI won't be used. Reason: ${reason}`);
|
|
20176
|
+
return { handlers: filteredHandlers };
|
|
20177
|
+
}
|
|
20178
|
+
const resolverInstance = { instanceId: undefined };
|
|
20179
|
+
const timeout = handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT_MS;
|
|
20180
|
+
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)}`);
|
|
20181
|
+
return { handlers: [handler] };
|
|
20182
|
+
}
|
|
20183
|
+
async getIntents(handler) {
|
|
20184
|
+
var _a;
|
|
20185
|
+
this.logger.trace(`Received 'getIntents' command with handler ${JSON.stringify(handler)}`);
|
|
20186
|
+
validateIntentHandler(handler);
|
|
20187
|
+
const intents = await this.all();
|
|
20188
|
+
clearNullUndefined(handler);
|
|
20189
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Extracting valid intents for the passed handler`);
|
|
20190
|
+
const intentsWithInfo = this.extractIntentsWithInfoByHandler(intents, handler);
|
|
20191
|
+
this.logger.trace(`Returning intents for handler ${JSON.stringify(handler)}`);
|
|
20192
|
+
return { intents: intentsWithInfo };
|
|
20193
|
+
}
|
|
20194
|
+
filterHandlersBy(intents, filter) {
|
|
20195
|
+
const filteredIntentsWithHandlers = intents.filter((intent) => {
|
|
20196
|
+
if (filter.intent && filter.intent !== intent.name) {
|
|
20197
|
+
return;
|
|
20198
|
+
}
|
|
20199
|
+
if (filter.resultType) {
|
|
20200
|
+
const filteredHandlers = intent.handlers.filter((handler) => handler.resultType && handler.resultType === filter.resultType);
|
|
20201
|
+
if (!filteredHandlers.length)
|
|
20202
|
+
return;
|
|
20203
|
+
intent.handlers = filteredHandlers;
|
|
20204
|
+
}
|
|
20205
|
+
if (filter.contextTypes) {
|
|
20206
|
+
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); }); });
|
|
20207
|
+
if (!filteredHandlers.length)
|
|
20208
|
+
return;
|
|
20209
|
+
intent.handlers = filteredHandlers;
|
|
20210
|
+
}
|
|
20211
|
+
if (filter.applicationNames) {
|
|
20212
|
+
const filteredHandlers = intent.handlers.filter((handler) => { var _a; return (_a = filter.applicationNames) === null || _a === void 0 ? void 0 : _a.includes(handler.applicationName); });
|
|
20213
|
+
if (!filteredHandlers.length)
|
|
20214
|
+
return;
|
|
20215
|
+
intent.handlers = filteredHandlers;
|
|
20216
|
+
}
|
|
20217
|
+
return intent;
|
|
20218
|
+
});
|
|
20219
|
+
return filteredIntentsWithHandlers.map((intent) => intent.handlers).flat(1);
|
|
20220
|
+
}
|
|
20065
20221
|
async coreRaiseIntent({ request, resolverInstance, timeout }) {
|
|
20066
20222
|
var _a, _b;
|
|
20067
20223
|
const intentDef = await this.get(request.intent);
|
|
20068
20224
|
if (typeof intentDef === "undefined") {
|
|
20069
20225
|
throw new Error(`Intent ${request.intent} not found.`);
|
|
20070
20226
|
}
|
|
20071
|
-
const { open, reason } = this.
|
|
20227
|
+
const { open, reason } = this.checkIfResolverShouldBeOpenedForRaise(intentDef, request);
|
|
20072
20228
|
if (!open) {
|
|
20073
20229
|
this.logger.trace(`Intent Resolver UI won't be used. Reason: ${reason}`);
|
|
20074
20230
|
return request.waitUserResponseIndefinitely
|
|
20075
20231
|
? PromiseWrap(() => this.raiseIntent(request, timeout), timeout, `Timeout of ${timeout}ms hit for raise to resolve`)
|
|
20076
20232
|
: this.raiseIntent(request, timeout);
|
|
20077
20233
|
}
|
|
20078
|
-
const resolverHandler = await this.startResolverApp(request, resolverInstance);
|
|
20234
|
+
const resolverHandler = await this.startResolverApp({ request, method: "raise", resolverInstance });
|
|
20079
20235
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Raising intent to target handler: ${JSON.stringify(resolverHandler)} with timeout of ${timeout}`);
|
|
20080
20236
|
if (request.waitUserResponseIndefinitely) {
|
|
20081
20237
|
return PromiseWrap(() => this.raiseIntentToTargetHandler(request, resolverHandler, timeout), timeout, `Timeout of ${timeout}ms hit for raise to resolve`);
|
|
@@ -20133,22 +20289,29 @@ class Intents {
|
|
|
20133
20289
|
result: result.returned
|
|
20134
20290
|
};
|
|
20135
20291
|
}
|
|
20136
|
-
async startResolverApp(
|
|
20292
|
+
async startResolverApp({ request, method, resolverInstance }) {
|
|
20137
20293
|
var _a, _b, _c, _d;
|
|
20138
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intents Resolver UI with app name ${this.intentsResolverAppName} will be used`);
|
|
20139
|
-
const responseMethodName = await this.registerIntentResolverMethod();
|
|
20294
|
+
(_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)}`);
|
|
20295
|
+
const responseMethodName = await this.registerIntentResolverMethod(method);
|
|
20140
20296
|
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Registered interop method ${responseMethodName}`);
|
|
20141
|
-
const startContext = this.buildStartContext(
|
|
20297
|
+
const startContext = this.buildStartContext(method, request, responseMethodName);
|
|
20142
20298
|
const startOptions = await this.buildStartOptions();
|
|
20143
20299
|
(_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)}`);
|
|
20144
20300
|
const instance = await this.appManager.application(this.intentsResolverAppName).start(startContext, startOptions);
|
|
20145
|
-
|
|
20146
|
-
resolverInstance.instanceId = instance.id;
|
|
20147
|
-
}
|
|
20301
|
+
resolverInstance.instanceId = instance.id;
|
|
20148
20302
|
(_d = this.logger) === null || _d === void 0 ? void 0 : _d.trace(`Intents Resolver instance with id ${instance.id} opened`);
|
|
20149
|
-
this.subscribeOnInstanceStopped(instance);
|
|
20150
|
-
|
|
20151
|
-
|
|
20303
|
+
this.subscribeOnInstanceStopped(instance, method);
|
|
20304
|
+
const timeout = request.timeout || method === "raise" ? DEFAULT_RAISE_TIMEOUT_MS : DEFAULT_PICK_HANDLER_BY_TIMEOUT_MS;
|
|
20305
|
+
this.createResponsePromise({
|
|
20306
|
+
intent: method === "raise" ? request.intent : undefined,
|
|
20307
|
+
instanceId: instance.id,
|
|
20308
|
+
responseMethodName,
|
|
20309
|
+
timeout,
|
|
20310
|
+
errorMsg: `Timeout of ${timeout}ms hit waiting for the user to choose a handler ${method === "raise"
|
|
20311
|
+
? `for intent ${request.intent}`
|
|
20312
|
+
: `for '${method}' method with filter ${JSON.stringify(request)}`}`
|
|
20313
|
+
});
|
|
20314
|
+
const handler = await this.handleInstanceResponse(instance.id, method);
|
|
20152
20315
|
return handler;
|
|
20153
20316
|
}
|
|
20154
20317
|
async windowsIdToTitle(id, windowsInfos) {
|
|
@@ -20160,43 +20323,43 @@ class Intents {
|
|
|
20160
20323
|
const title = await (window === null || window === void 0 ? void 0 : window.getTitle());
|
|
20161
20324
|
return title;
|
|
20162
20325
|
}
|
|
20163
|
-
async handleInstanceResponse(instanceId) {
|
|
20164
|
-
var _a;
|
|
20326
|
+
async handleInstanceResponse(instanceId, method) {
|
|
20327
|
+
var _a, _b;
|
|
20165
20328
|
try {
|
|
20166
|
-
const
|
|
20167
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(`Intent handler chosen for intent ${intent}: ${JSON.stringify(handler)}`);
|
|
20329
|
+
const response = await this.intentsResolverResponsePromises[instanceId].promise;
|
|
20330
|
+
(_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}`);
|
|
20168
20331
|
this.stopResolverInstance(instanceId);
|
|
20169
|
-
|
|
20332
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.trace(`Instance with id ${instanceId} successfully stopped`);
|
|
20333
|
+
return response.handler;
|
|
20170
20334
|
}
|
|
20171
20335
|
catch (error) {
|
|
20172
20336
|
this.stopResolverInstance(instanceId);
|
|
20173
20337
|
throw new Error(error);
|
|
20174
20338
|
}
|
|
20175
20339
|
}
|
|
20176
|
-
async registerIntentResolverMethod() {
|
|
20177
|
-
const methodName = INTENTS_RESOLVER_INTEROP_PREFIX +
|
|
20178
|
-
await this.interop.register(methodName, this.resolverResponseHandler
|
|
20340
|
+
async registerIntentResolverMethod(method) {
|
|
20341
|
+
const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + Utils.generateId();
|
|
20342
|
+
await this.interop.register(methodName, (args, callerId) => this.resolverResponseHandler(args, callerId, method));
|
|
20179
20343
|
return methodName;
|
|
20180
20344
|
}
|
|
20181
|
-
resolverResponseHandler(args, callerId) {
|
|
20345
|
+
resolverResponseHandler(args, callerId, method) {
|
|
20182
20346
|
const { instance } = callerId;
|
|
20183
|
-
const isValid =
|
|
20347
|
+
const isValid = validateIntentsResolverResponse(method, args);
|
|
20184
20348
|
if (!isValid) {
|
|
20185
|
-
this.logger.trace(`Intent Resolver sent invalid response. Error: ${isValid.error}`);
|
|
20349
|
+
this.logger.trace(`Intent Resolver instance with id ${callerId.instance} sent invalid response. Error: ${isValid.error}`);
|
|
20186
20350
|
this.intentsResolverResponsePromises[instance].reject(isValid.error);
|
|
20187
20351
|
this.stopResolverInstance(instance);
|
|
20352
|
+
return;
|
|
20188
20353
|
}
|
|
20189
20354
|
const validResponse = isValid.ok;
|
|
20190
20355
|
this.intentsResolverResponsePromises[instance].resolve(validResponse);
|
|
20191
20356
|
this.cleanUpIntentResolverPromise(instance);
|
|
20192
20357
|
}
|
|
20193
|
-
buildStartContext(request, methodName) {
|
|
20194
|
-
const
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
};
|
|
20199
|
-
return startContext;
|
|
20358
|
+
buildStartContext(method, request, methodName) {
|
|
20359
|
+
const baseStartContext = { callerId: this.interop.instance.instance, methodName };
|
|
20360
|
+
return method === "raise"
|
|
20361
|
+
? { ...baseStartContext, intent: request }
|
|
20362
|
+
: { ...baseStartContext, handlerFilter: request };
|
|
20200
20363
|
}
|
|
20201
20364
|
async buildStartOptions() {
|
|
20202
20365
|
const win = this.windows.my();
|
|
@@ -20207,29 +20370,35 @@ class Intents {
|
|
|
20207
20370
|
return {
|
|
20208
20371
|
top: (bounds.height - INTENTS_RESOLVER_HEIGHT) / 2 + bounds.top,
|
|
20209
20372
|
left: (bounds.width - INTENTS_RESOLVER_WIDTH) / 2 + bounds.left,
|
|
20373
|
+
width: INTENTS_RESOLVER_WIDTH,
|
|
20374
|
+
height: INTENTS_RESOLVER_HEIGHT
|
|
20210
20375
|
};
|
|
20211
20376
|
}
|
|
20212
|
-
createResponsePromise(
|
|
20213
|
-
let resolve;
|
|
20214
|
-
let reject;
|
|
20215
|
-
const waitResponseTimeout = intentRequest.waitUserResponseIndefinitely ? MAX_SET_TIMEOUT_DELAY : this.intentsResolverResponseTimeout;
|
|
20377
|
+
createResponsePromise({ instanceId, intent, responseMethodName, timeout, errorMsg }) {
|
|
20378
|
+
let resolve = () => { };
|
|
20379
|
+
let reject = () => { };
|
|
20216
20380
|
const promise = PromisePlus((res, rej) => {
|
|
20217
20381
|
resolve = res;
|
|
20218
20382
|
reject = rej;
|
|
20219
|
-
},
|
|
20220
|
-
this.intentsResolverResponsePromises[instanceId] = { intent
|
|
20383
|
+
}, timeout, errorMsg);
|
|
20384
|
+
this.intentsResolverResponsePromises[instanceId] = { intent, resolve, reject, promise, methodName: responseMethodName };
|
|
20221
20385
|
}
|
|
20222
20386
|
async invokeStartApp(application, context, options) {
|
|
20223
20387
|
const result = await this.interop.invoke("T42.ACS.StartApplication", { Name: application, options });
|
|
20224
20388
|
return result.returned.Id;
|
|
20225
20389
|
}
|
|
20226
|
-
subscribeOnInstanceStopped(instance) {
|
|
20227
|
-
const
|
|
20390
|
+
subscribeOnInstanceStopped(instance, method) {
|
|
20391
|
+
const { application } = instance;
|
|
20392
|
+
const unsub = application.onInstanceStopped((inst) => {
|
|
20393
|
+
if (inst.id !== instance.id) {
|
|
20394
|
+
return;
|
|
20395
|
+
}
|
|
20228
20396
|
const intentPromise = this.intentsResolverResponsePromises[inst.id];
|
|
20229
20397
|
if (!intentPromise) {
|
|
20230
20398
|
return unsub();
|
|
20231
20399
|
}
|
|
20232
|
-
|
|
20400
|
+
const errorMsg = `Cannot resolve ${method === "raise" ? `raised intent ${intentPromise.intent}` : `'${method}' method`} - User closed ${instance.application.name} app without choosing a handler`;
|
|
20401
|
+
intentPromise.reject(errorMsg);
|
|
20233
20402
|
this.cleanUpIntentResolverPromise(inst.id);
|
|
20234
20403
|
unsub();
|
|
20235
20404
|
});
|
|
@@ -20243,23 +20412,6 @@ class Intents {
|
|
|
20243
20412
|
unregisterPromise.catch((error) => this.logger.warn(error));
|
|
20244
20413
|
delete this.intentsResolverResponsePromises[instanceId];
|
|
20245
20414
|
}
|
|
20246
|
-
validateIntentsResolverResponse(responseObj) {
|
|
20247
|
-
const invalidKey = Object.keys(responseObj).some((key) => key !== "intent" && key !== "handler");
|
|
20248
|
-
if (invalidKey) {
|
|
20249
|
-
return { isValid: false, error: "Response is not a valid object. Expected { intent: string, handler: IntentHandler }" };
|
|
20250
|
-
}
|
|
20251
|
-
if (typeof responseObj.intent !== "string") {
|
|
20252
|
-
return { isValid: false, error: `Response object has invalid 'intent' key. Expected a string, got ${typeof responseObj.intent}` };
|
|
20253
|
-
}
|
|
20254
|
-
if (typeof responseObj.handler !== "object") {
|
|
20255
|
-
return { isValid: false, error: `Response object has invalid 'handler' key. Expected an object, got ${typeof responseObj.handler}` };
|
|
20256
|
-
}
|
|
20257
|
-
const compulsoryKeysExist = INTENT_HANDLER_DEFAULT_PROPS.filter((key) => !(key in responseObj.handler));
|
|
20258
|
-
if (compulsoryKeysExist.length) {
|
|
20259
|
-
return { isValid: false, error: `Handler in Response object does not provide compulsory keys: ${compulsoryKeysExist.join(", ")}` };
|
|
20260
|
-
}
|
|
20261
|
-
return { isValid: true, ok: { intent: responseObj.intent, handler: { ...responseObj.handler } } };
|
|
20262
|
-
}
|
|
20263
20415
|
handleRaiseOnError(instanceId) {
|
|
20264
20416
|
if (!instanceId) {
|
|
20265
20417
|
return;
|
|
@@ -20282,18 +20434,34 @@ class Intents {
|
|
|
20282
20434
|
this.intentsResolverAppName = (_c = (_b = options.intents) === null || _b === void 0 ? void 0 : _b.intentsResolverAppName) !== null && _c !== void 0 ? _c : INTENTS_RESOLVER_APP_NAME;
|
|
20283
20435
|
this.intentsResolverResponseTimeout = (_e = (_d = options.intents) === null || _d === void 0 ? void 0 : _d.methodResponseTimeoutMs) !== null && _e !== void 0 ? _e : DEFAULT_RESOLVER_RESPONSE_TIMEOUT;
|
|
20284
20436
|
}
|
|
20285
|
-
|
|
20437
|
+
checkIfResolverShouldBeOpenedForRaise(intent, request) {
|
|
20438
|
+
const checkOpen = this.checkIfIntentsResolverShouldBeOpened();
|
|
20439
|
+
if (!checkOpen.open) {
|
|
20440
|
+
return checkOpen;
|
|
20441
|
+
}
|
|
20442
|
+
const hasMoreThanOneHandler = this.checkIfIntentHasMoreThanOneHandler(intent, request);
|
|
20443
|
+
if (!hasMoreThanOneHandler) {
|
|
20444
|
+
return { open: false, reason: `Raised intent ${intent.name} has only one handler` };
|
|
20445
|
+
}
|
|
20446
|
+
return { open: true };
|
|
20447
|
+
}
|
|
20448
|
+
checkIfResolverShouldBeOpenedForFilterHandlers(handlers, filter) {
|
|
20449
|
+
if (handlers.length === 1) {
|
|
20450
|
+
return { open: false, reason: `There's only one valid intent handler for filter ${JSON.stringify(filter)}` };
|
|
20451
|
+
}
|
|
20452
|
+
if (typeof (filter === null || filter === void 0 ? void 0 : filter.openResolver) === "boolean" && !filter.openResolver) {
|
|
20453
|
+
return { open: false, reason: "Intents resolver is disabled by IntentHandler filter" };
|
|
20454
|
+
}
|
|
20455
|
+
return this.checkIfIntentsResolverShouldBeOpened();
|
|
20456
|
+
}
|
|
20457
|
+
checkIfIntentsResolverShouldBeOpened() {
|
|
20286
20458
|
if (!this.useIntentsResolverUI) {
|
|
20287
|
-
return { open: false, reason: `Intent Resolver is disabled.
|
|
20459
|
+
return { open: false, reason: `Intent Resolver is disabled. Resolving to first found handler` };
|
|
20288
20460
|
}
|
|
20289
20461
|
const intentsResolverApp = this.appManager.application(this.intentsResolverAppName);
|
|
20290
20462
|
if (!intentsResolverApp) {
|
|
20291
20463
|
return { open: false, reason: `Intent Resolver Application with name ${this.intentsResolverAppName} not found.` };
|
|
20292
20464
|
}
|
|
20293
|
-
const hasMoreThanOneHandler = this.checkIfIntentHasMoreThanOneHandler(intent, request);
|
|
20294
|
-
if (!hasMoreThanOneHandler) {
|
|
20295
|
-
return { open: false, reason: `Raised intent ${intent.name} has only one handler` };
|
|
20296
|
-
}
|
|
20297
20465
|
return { open: true };
|
|
20298
20466
|
}
|
|
20299
20467
|
checkIfIntentHasMoreThanOneHandler(intent, request) {
|
|
@@ -20337,67 +20505,6 @@ class Intents {
|
|
|
20337
20505
|
this.clearUnregistrationPromise(unregisterPromise);
|
|
20338
20506
|
});
|
|
20339
20507
|
}
|
|
20340
|
-
validateIntentRequest(request) {
|
|
20341
|
-
this.validateIntentRequestContext(request.context);
|
|
20342
|
-
this.validateIntentRequestTarget(request.target);
|
|
20343
|
-
this.validateIntentRequestTimeout(request.timeout);
|
|
20344
|
-
this.validateWaitUserResponseIndefinitely(request.waitUserResponseIndefinitely);
|
|
20345
|
-
if (request.handlers) {
|
|
20346
|
-
request.handlers.forEach((handler) => this.validateIntentRequestHandler(handler));
|
|
20347
|
-
}
|
|
20348
|
-
}
|
|
20349
|
-
validateIntentRequestTarget(target) {
|
|
20350
|
-
if (!target) {
|
|
20351
|
-
return;
|
|
20352
|
-
}
|
|
20353
|
-
if (typeof target !== "string" && typeof target !== "object") {
|
|
20354
|
-
throw new Error(`Please provide the intent target as one of the valid values: "reuse", "startNew", { app: string }, { instance: string } `);
|
|
20355
|
-
}
|
|
20356
|
-
}
|
|
20357
|
-
validateIntentRequestContext(context) {
|
|
20358
|
-
if (!context) {
|
|
20359
|
-
return;
|
|
20360
|
-
}
|
|
20361
|
-
if (typeof context !== "object") {
|
|
20362
|
-
throw new Error(`Please provide the intent context as an object`);
|
|
20363
|
-
}
|
|
20364
|
-
if (context.type && typeof context.type !== "string") {
|
|
20365
|
-
throw new Error(`Please provide the intent context as an object with 'type' property as string`);
|
|
20366
|
-
}
|
|
20367
|
-
if (context.data && typeof context.data !== "object") {
|
|
20368
|
-
throw new Error(`Please provide the intent context as an object with 'data' property as object`);
|
|
20369
|
-
}
|
|
20370
|
-
}
|
|
20371
|
-
validateIntentRequestHandler(handler) {
|
|
20372
|
-
if (!handler.applicationName) {
|
|
20373
|
-
throw new Error(`Please provide applicationName for handler ${JSON.stringify(handler)}`);
|
|
20374
|
-
}
|
|
20375
|
-
if (!handler.type) {
|
|
20376
|
-
throw new Error(`Please provide type for handler ${JSON.stringify(handler)}`);
|
|
20377
|
-
}
|
|
20378
|
-
if (handler.type === "instance" && !handler.instanceId) {
|
|
20379
|
-
throw new Error(`Please provide instanceId for handler ${JSON.stringify(handler)}`);
|
|
20380
|
-
}
|
|
20381
|
-
}
|
|
20382
|
-
validateIntentRequestTimeout(timeout) {
|
|
20383
|
-
if (!timeout) {
|
|
20384
|
-
return;
|
|
20385
|
-
}
|
|
20386
|
-
if (typeof timeout !== "number") {
|
|
20387
|
-
throw new Error(`Please provide the timeout as a number`);
|
|
20388
|
-
}
|
|
20389
|
-
if (timeout <= 0) {
|
|
20390
|
-
throw new Error(`Please provide the timeout as a positive number`);
|
|
20391
|
-
}
|
|
20392
|
-
}
|
|
20393
|
-
validateWaitUserResponseIndefinitely(waitUserResponseIndefinitely) {
|
|
20394
|
-
if (!waitUserResponseIndefinitely) {
|
|
20395
|
-
return;
|
|
20396
|
-
}
|
|
20397
|
-
if (typeof waitUserResponseIndefinitely !== "boolean") {
|
|
20398
|
-
throw new Error("Please provide waitUserResponseIndefinitely as a boolean");
|
|
20399
|
-
}
|
|
20400
|
-
}
|
|
20401
20508
|
findHandlerByFilter(handlers, filter) {
|
|
20402
20509
|
if (filter.type) {
|
|
20403
20510
|
return handlers.find((handler) => handler.type === filter.type);
|
|
@@ -20411,6 +20518,32 @@ class Intents {
|
|
|
20411
20518
|
return handlers.find((handler) => handler.applicationName === filter.app);
|
|
20412
20519
|
}
|
|
20413
20520
|
}
|
|
20521
|
+
extractIntentsWithInfoByHandler(intents, handler) {
|
|
20522
|
+
const intentsWithInfo = intents.reduce((validIntentsWithInfo, intent) => {
|
|
20523
|
+
intent.handlers.forEach((currentHandler) => {
|
|
20524
|
+
const isValid = Object.keys(handler).every((key) => {
|
|
20525
|
+
var _a;
|
|
20526
|
+
return key === "contextTypes"
|
|
20527
|
+
? (_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); })
|
|
20528
|
+
: currentHandler[key] === handler[key];
|
|
20529
|
+
});
|
|
20530
|
+
if (!isValid) {
|
|
20531
|
+
return;
|
|
20532
|
+
}
|
|
20533
|
+
const intentWithInfo = {
|
|
20534
|
+
intent: intent.name,
|
|
20535
|
+
contextTypes: currentHandler.contextTypes,
|
|
20536
|
+
description: currentHandler.applicationDescription,
|
|
20537
|
+
displayName: currentHandler.displayName,
|
|
20538
|
+
icon: currentHandler.applicationIcon,
|
|
20539
|
+
resultType: currentHandler.resultType
|
|
20540
|
+
};
|
|
20541
|
+
validIntentsWithInfo.push(intentWithInfo);
|
|
20542
|
+
});
|
|
20543
|
+
return validIntentsWithInfo;
|
|
20544
|
+
}, []);
|
|
20545
|
+
return intentsWithInfo;
|
|
20546
|
+
}
|
|
20414
20547
|
}
|
|
20415
20548
|
|
|
20416
20549
|
class FactoryCallInfo {
|
|
@@ -20443,7 +20576,7 @@ class Prefs {
|
|
|
20443
20576
|
constructor(appName, interop) {
|
|
20444
20577
|
this.appName = appName;
|
|
20445
20578
|
this.interop = interop;
|
|
20446
|
-
this.registry = lib
|
|
20579
|
+
this.registry = lib();
|
|
20447
20580
|
this.interopMethodRegistered = false;
|
|
20448
20581
|
}
|
|
20449
20582
|
async get(app) {
|