abledom 0.6.2 → 0.6.4
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/dist/esm/index.js +42 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +42 -8
- package/dist/index.js.map +1 -1
- package/dist/ts3.9/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1058,6 +1058,7 @@ var AbleDOM = class {
|
|
|
1058
1058
|
__publicField(this, "_idleResolve");
|
|
1059
1059
|
__publicField(this, "_currentAnchoredIssues", /* @__PURE__ */ new Map());
|
|
1060
1060
|
__publicField(this, "_currentNotAnchoredIssues", []);
|
|
1061
|
+
__publicField(this, "_readIssues", /* @__PURE__ */ new Set());
|
|
1061
1062
|
__publicField(this, "_getHighlighter", () => {
|
|
1062
1063
|
if (!this._elementHighlighter && !this._isDisposed) {
|
|
1063
1064
|
this._elementHighlighter = new ElementHighlighter(this._win);
|
|
@@ -1417,29 +1418,62 @@ var AbleDOM = class {
|
|
|
1417
1418
|
rules.forEach((rule) => this._removeIssue(element, rule));
|
|
1418
1419
|
});
|
|
1419
1420
|
}
|
|
1420
|
-
_getCurrentIssues() {
|
|
1421
|
-
const issues =
|
|
1421
|
+
_getCurrentIssues(markAsRead) {
|
|
1422
|
+
const issues = [];
|
|
1423
|
+
this._currentNotAnchoredIssues.forEach((issue) => {
|
|
1424
|
+
if (!this._readIssues.has(issue)) {
|
|
1425
|
+
issues.push(issue);
|
|
1426
|
+
}
|
|
1427
|
+
if (markAsRead) {
|
|
1428
|
+
this._readIssues.add(issue);
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1422
1431
|
this._currentAnchoredIssues.forEach((issueByRule) => {
|
|
1423
1432
|
issueByRule.forEach((issue) => {
|
|
1424
|
-
|
|
1433
|
+
if (!this._readIssues.has(issue)) {
|
|
1434
|
+
issues.push(issue);
|
|
1435
|
+
}
|
|
1436
|
+
if (markAsRead) {
|
|
1437
|
+
this._readIssues.add(issue);
|
|
1438
|
+
}
|
|
1425
1439
|
});
|
|
1426
1440
|
});
|
|
1427
1441
|
return issues;
|
|
1428
1442
|
}
|
|
1429
|
-
idle() {
|
|
1443
|
+
idle(markAsRead, timeout) {
|
|
1430
1444
|
if (!this._clearValidationTimeout) {
|
|
1431
|
-
return Promise.resolve(this._getCurrentIssues());
|
|
1432
|
-
}
|
|
1445
|
+
return Promise.resolve(this._getCurrentIssues(!!markAsRead));
|
|
1446
|
+
}
|
|
1447
|
+
let timeoutClear;
|
|
1448
|
+
let timeoutResolve;
|
|
1449
|
+
let timedOut = false;
|
|
1450
|
+
let timeoutPromise = timeout ? new Promise((resolve) => {
|
|
1451
|
+
timeoutResolve = () => {
|
|
1452
|
+
timeoutClear == null ? void 0 : timeoutClear();
|
|
1453
|
+
timeoutResolve = void 0;
|
|
1454
|
+
resolve(null);
|
|
1455
|
+
};
|
|
1456
|
+
let timeoutTimer = this._win.setTimeout(() => {
|
|
1457
|
+
timeoutClear = void 0;
|
|
1458
|
+
timedOut = true;
|
|
1459
|
+
timeoutResolve == null ? void 0 : timeoutResolve();
|
|
1460
|
+
}, timeout);
|
|
1461
|
+
timeoutClear = () => {
|
|
1462
|
+
this._win.clearTimeout(timeoutTimer);
|
|
1463
|
+
timeoutClear = void 0;
|
|
1464
|
+
};
|
|
1465
|
+
}) : void 0;
|
|
1433
1466
|
if (!this._idlePromise) {
|
|
1434
1467
|
this._idlePromise = new Promise((resolve) => {
|
|
1435
1468
|
this._idleResolve = () => {
|
|
1436
1469
|
delete this._idlePromise;
|
|
1437
1470
|
delete this._idleResolve;
|
|
1438
|
-
resolve(this._getCurrentIssues());
|
|
1471
|
+
resolve(this._getCurrentIssues(timedOut ? false : !!markAsRead));
|
|
1472
|
+
timeoutResolve == null ? void 0 : timeoutResolve();
|
|
1439
1473
|
};
|
|
1440
1474
|
});
|
|
1441
1475
|
}
|
|
1442
|
-
return this._idlePromise;
|
|
1476
|
+
return timeoutPromise ? Promise.race([this._idlePromise, timeoutPromise]) : this._idlePromise;
|
|
1443
1477
|
}
|
|
1444
1478
|
clearCurrentIssues(anchored = true, notAnchored = true) {
|
|
1445
1479
|
if (anchored) {
|