abledom 0.6.2 → 0.6.3
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 +40 -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 +40 -8
- package/dist/index.js.map +1 -1
- package/dist/ts3.9/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -94,6 +94,7 @@ declare class AbleDOM {
|
|
|
94
94
|
private _idleResolve;
|
|
95
95
|
private _currentAnchoredIssues;
|
|
96
96
|
private _currentNotAnchoredIssues;
|
|
97
|
+
private _readIssues;
|
|
97
98
|
constructor(win: Window, props?: AbleDOMProps);
|
|
98
99
|
private _onElementId;
|
|
99
100
|
private _getHighlighter;
|
|
@@ -110,7 +111,7 @@ declare class AbleDOM {
|
|
|
110
111
|
private _onFocusOut;
|
|
111
112
|
private _notifyAsync;
|
|
112
113
|
private _getCurrentIssues;
|
|
113
|
-
idle(): Promise<ValidationIssue[]>;
|
|
114
|
+
idle(markAsRead?: boolean, timeout?: number): Promise<ValidationIssue[] | null>;
|
|
114
115
|
clearCurrentIssues(anchored?: boolean, notAnchored?: boolean): void;
|
|
115
116
|
highlightElement(element: HTMLElement | null, scrollIntoView?: boolean, autoHideTime?: number): void;
|
|
116
117
|
log: typeof console.error;
|
package/dist/index.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ declare class AbleDOM {
|
|
|
94
94
|
private _idleResolve;
|
|
95
95
|
private _currentAnchoredIssues;
|
|
96
96
|
private _currentNotAnchoredIssues;
|
|
97
|
+
private _readIssues;
|
|
97
98
|
constructor(win: Window, props?: AbleDOMProps);
|
|
98
99
|
private _onElementId;
|
|
99
100
|
private _getHighlighter;
|
|
@@ -110,7 +111,7 @@ declare class AbleDOM {
|
|
|
110
111
|
private _onFocusOut;
|
|
111
112
|
private _notifyAsync;
|
|
112
113
|
private _getCurrentIssues;
|
|
113
|
-
idle(): Promise<ValidationIssue[]>;
|
|
114
|
+
idle(markAsRead?: boolean, timeout?: number): Promise<ValidationIssue[] | null>;
|
|
114
115
|
clearCurrentIssues(anchored?: boolean, notAnchored?: boolean): void;
|
|
115
116
|
highlightElement(element: HTMLElement | null, scrollIntoView?: boolean, autoHideTime?: number): void;
|
|
116
117
|
log: typeof console.error;
|
package/dist/index.js
CHANGED
|
@@ -1100,6 +1100,7 @@ var AbleDOM = class {
|
|
|
1100
1100
|
__publicField(this, "_idleResolve");
|
|
1101
1101
|
__publicField(this, "_currentAnchoredIssues", /* @__PURE__ */ new Map());
|
|
1102
1102
|
__publicField(this, "_currentNotAnchoredIssues", []);
|
|
1103
|
+
__publicField(this, "_readIssues", /* @__PURE__ */ new Set());
|
|
1103
1104
|
__publicField(this, "_getHighlighter", () => {
|
|
1104
1105
|
if (!this._elementHighlighter && !this._isDisposed) {
|
|
1105
1106
|
this._elementHighlighter = new ElementHighlighter(this._win);
|
|
@@ -1459,29 +1460,60 @@ var AbleDOM = class {
|
|
|
1459
1460
|
rules.forEach((rule) => this._removeIssue(element, rule));
|
|
1460
1461
|
});
|
|
1461
1462
|
}
|
|
1462
|
-
_getCurrentIssues() {
|
|
1463
|
-
const issues =
|
|
1463
|
+
_getCurrentIssues(markAsRead) {
|
|
1464
|
+
const issues = [];
|
|
1465
|
+
this._currentNotAnchoredIssues.forEach((issue) => {
|
|
1466
|
+
if (!this._readIssues.has(issue)) {
|
|
1467
|
+
issues.push(issue);
|
|
1468
|
+
}
|
|
1469
|
+
if (markAsRead) {
|
|
1470
|
+
this._readIssues.add(issue);
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1464
1473
|
this._currentAnchoredIssues.forEach((issueByRule) => {
|
|
1465
1474
|
issueByRule.forEach((issue) => {
|
|
1466
|
-
|
|
1475
|
+
if (!this._readIssues.has(issue)) {
|
|
1476
|
+
issues.push(issue);
|
|
1477
|
+
}
|
|
1478
|
+
if (markAsRead) {
|
|
1479
|
+
this._readIssues.add(issue);
|
|
1480
|
+
}
|
|
1467
1481
|
});
|
|
1468
1482
|
});
|
|
1469
1483
|
return issues;
|
|
1470
1484
|
}
|
|
1471
|
-
idle() {
|
|
1485
|
+
idle(markAsRead, timeout) {
|
|
1472
1486
|
if (!this._clearValidationTimeout) {
|
|
1473
|
-
return Promise.resolve(this._getCurrentIssues());
|
|
1474
|
-
}
|
|
1487
|
+
return Promise.resolve(this._getCurrentIssues(!!markAsRead));
|
|
1488
|
+
}
|
|
1489
|
+
let timeoutClear;
|
|
1490
|
+
let timeoutResolve;
|
|
1491
|
+
let timeoutPromise = timeout ? new Promise((resolve) => {
|
|
1492
|
+
timeoutResolve = () => {
|
|
1493
|
+
timeoutClear == null ? void 0 : timeoutClear();
|
|
1494
|
+
timeoutResolve = void 0;
|
|
1495
|
+
resolve(null);
|
|
1496
|
+
};
|
|
1497
|
+
let timeoutTimer = this._win.setTimeout(() => {
|
|
1498
|
+
timeoutClear = void 0;
|
|
1499
|
+
timeoutResolve == null ? void 0 : timeoutResolve();
|
|
1500
|
+
}, timeout);
|
|
1501
|
+
timeoutClear = () => {
|
|
1502
|
+
this._win.clearTimeout(timeoutTimer);
|
|
1503
|
+
timeoutClear = void 0;
|
|
1504
|
+
};
|
|
1505
|
+
}) : void 0;
|
|
1475
1506
|
if (!this._idlePromise) {
|
|
1476
1507
|
this._idlePromise = new Promise((resolve) => {
|
|
1477
1508
|
this._idleResolve = () => {
|
|
1478
1509
|
delete this._idlePromise;
|
|
1479
1510
|
delete this._idleResolve;
|
|
1480
|
-
resolve(this._getCurrentIssues());
|
|
1511
|
+
resolve(this._getCurrentIssues(!!markAsRead));
|
|
1512
|
+
timeoutResolve == null ? void 0 : timeoutResolve();
|
|
1481
1513
|
};
|
|
1482
1514
|
});
|
|
1483
1515
|
}
|
|
1484
|
-
return this._idlePromise;
|
|
1516
|
+
return timeoutPromise ? Promise.race([this._idlePromise, timeoutPromise]) : this._idlePromise;
|
|
1485
1517
|
}
|
|
1486
1518
|
clearCurrentIssues(anchored = true, notAnchored = true) {
|
|
1487
1519
|
if (anchored) {
|