@usesequential/browser 1.0.2 → 1.0.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/CHANGELOG.md +11 -0
- package/dist/index.cjs +62 -30
- package/dist/index.mjs +62 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
- A click that a script makes (`el.click()`, `dispatchEvent`; the browser marks it `isTrusted: false`) is recorded only
|
|
6
|
+
while the person acts: while the page has transient user activation, or within 1 second of the person's own
|
|
7
|
+
pointerup, touchend or keydown. So a tap or key that the page forwards as its own click (FastClick on iOS, a key
|
|
8
|
+
handler on a `role="button"`) is still recorded, and a script that clicks on a timer from page load is not: no
|
|
9
|
+
`$click` and no dead click. A browser that does not set `isTrusted` is unchanged.
|
|
10
|
+
- At most 5 `$click` per element per second, on a monotonic clock. A faster loop on one element, even with events the
|
|
11
|
+
browser trusts, sends no more. Rage and dead clicks are unchanged.
|
|
12
|
+
- A dead click on an option that was already selected carries `$el_state: 'selected'`.
|
|
13
|
+
|
|
3
14
|
## 1.0.2
|
|
4
15
|
|
|
5
16
|
- The package now holds the same code as the script tag of 3 November 2026. Changes since 1.0.0:
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @usesequential/browser 1.0.
|
|
1
|
+
/* @usesequential/browser 1.0.3: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
|
|
2
2
|
* `boot` below is sequential.js, the file the script tag loads, unchanged. */
|
|
3
3
|
'use strict';
|
|
4
4
|
var boot = (function (injectedTag) {
|
|
@@ -206,10 +206,7 @@ var boot = (function (injectedTag) {
|
|
|
206
206
|
var REQUEST_TIMEOUT_MS = 10000;
|
|
207
207
|
var MAX_SEND_ATTEMPTS = 3;
|
|
208
208
|
var RETRY_BASE_MS = 500;
|
|
209
|
-
// A 429
|
|
210
|
-
// server's retry time, clamped; hold the refused batch whole and what is captured meanwhile, capped, the oldest dropped
|
|
211
|
-
// first. A held batch is resent after each pause, as its own request, until 5 min after its first refusal
|
|
212
|
-
// (sequential.core.ts holdRateLimited).
|
|
209
|
+
// A 429 or a 503 overloaded: pause and hold, as sequential.core.ts holdRateLimited.
|
|
213
210
|
var RATE_LIMIT_DEFAULT_SEC = 60;
|
|
214
211
|
var RATE_LIMIT_MIN_SEC = 1;
|
|
215
212
|
var RATE_LIMIT_MAX_SEC = 300;
|
|
@@ -960,11 +957,11 @@ var boot = (function (injectedTag) {
|
|
|
960
957
|
for (i = 0; i < w.length; i++) if (w[i].length > 2 && inList(idWords, w[i])) return true;
|
|
961
958
|
}
|
|
962
959
|
|
|
963
|
-
// Account UI (the element or
|
|
964
|
-
//
|
|
965
|
-
//
|
|
966
|
-
//
|
|
967
|
-
//
|
|
960
|
+
// Account UI (the element or its 3 nearest ancestors):
|
|
961
|
+
// as in sequential.autocapture.ts.
|
|
962
|
+
// `profile` alone is not
|
|
963
|
+
// account UI
|
|
964
|
+
// (2026-10-26).
|
|
968
965
|
var ACCOUNT_WORD = /(\b|_)(avatar|account|user[-_]?menu|profile[-_](menu|dropdown|button|avatar)|(my|user)[-_]profile)(\b|_)/;
|
|
969
966
|
var ACCOUNT_LABEL = /^(account|user|profile)$|\b(my|your|open) (account|profile)\b|\b(user|account|profile)( navigation)? (menu|dropdown|options)\b/;
|
|
970
967
|
function inAccountUi(node) {
|
|
@@ -1123,11 +1120,11 @@ var boot = (function (injectedTag) {
|
|
|
1123
1120
|
} catch (e) {}
|
|
1124
1121
|
}
|
|
1125
1122
|
|
|
1126
|
-
// Another tab's optOut() (
|
|
1127
|
-
//
|
|
1128
|
-
//
|
|
1129
|
-
//
|
|
1130
|
-
//
|
|
1123
|
+
// Another tab's optOut() (__sq_opt set to '1') opts this tab out at once;
|
|
1124
|
+
// it writes back none of the ids that tab deleted.
|
|
1125
|
+
// Another tab's optIn() or localStorage.clear()
|
|
1126
|
+
// does not opt this tab in:
|
|
1127
|
+
// that waits for the next page load.
|
|
1131
1128
|
try {
|
|
1132
1129
|
window.addEventListener('storage', function (e) {
|
|
1133
1130
|
if (e && e.key === OPT_OUT_KEY && e.newValue === '1' && !optedOut) optOut();
|
|
@@ -1543,9 +1540,7 @@ var boot = (function (injectedTag) {
|
|
|
1543
1540
|
return r.target.getAttribute(r.attributeName) !== r.oldValue;
|
|
1544
1541
|
}
|
|
1545
1542
|
|
|
1546
|
-
//
|
|
1547
|
-
// isPrimary: Chromium sends `click` as a PointerEvent with isPrimary=false; only pointer events
|
|
1548
|
-
// check it (isPlainPointer).
|
|
1543
|
+
// As sequential.autocapture.ts isPlainClick and isPlainPointer.
|
|
1549
1544
|
function isPlainClick(ev) {
|
|
1550
1545
|
return ev.button === 0 && !ev.ctrlKey && !ev.metaKey && !ev.shiftKey && !ev.altKey;
|
|
1551
1546
|
}
|
|
@@ -1554,6 +1549,12 @@ var boot = (function (injectedTag) {
|
|
|
1554
1549
|
return isPlainClick(ev) && ev.isPrimary !== false;
|
|
1555
1550
|
}
|
|
1556
1551
|
|
|
1552
|
+
// Monotonic where there is one, so a step of the wall clock cannot freeze the $click cap's window.
|
|
1553
|
+
function now() {
|
|
1554
|
+
var p = window.performance;
|
|
1555
|
+
return p && p.now ? p.now() : Date.now();
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1557
1558
|
function startAutocapture(attachUrl) {
|
|
1558
1559
|
if (autocaptureStarted || !redactor) return;
|
|
1559
1560
|
autocaptureStarted = true;
|
|
@@ -1576,9 +1577,7 @@ var boot = (function (injectedTag) {
|
|
|
1576
1577
|
});
|
|
1577
1578
|
}
|
|
1578
1579
|
|
|
1579
|
-
// One page key
|
|
1580
|
-
// route) for every trigger, as in
|
|
1581
|
-
// sequential.autocapture.ts pageKey: a router's same-URL replaceState is not a pageview.
|
|
1580
|
+
// One page key for every trigger, as sequential.autocapture.ts pageKey.
|
|
1582
1581
|
var lastPageKey = null;
|
|
1583
1582
|
var lastPathKey = null;
|
|
1584
1583
|
var lastNavigationType;
|
|
@@ -1600,9 +1599,7 @@ var boot = (function (injectedTag) {
|
|
|
1600
1599
|
} catch (e) {}
|
|
1601
1600
|
}
|
|
1602
1601
|
|
|
1603
|
-
// A traversal the page's router answers with replaceState
|
|
1604
|
-
// replace while a popstate is being handled (window.event, or our capture listener's mark) is that traversal, of
|
|
1605
|
-
// the kind of the last navigate event before it that was not a replace.
|
|
1602
|
+
// A traversal the page's router answers with replaceState: as sequential.autocapture.ts inPopstate (F1).
|
|
1606
1603
|
var popPending = false;
|
|
1607
1604
|
var popKind;
|
|
1608
1605
|
function onPopCapture() {
|
|
@@ -1658,20 +1655,41 @@ var boot = (function (injectedTag) {
|
|
|
1658
1655
|
};
|
|
1659
1656
|
}
|
|
1660
1657
|
|
|
1658
|
+
// At most 5 $click per element per second (sequential.autocapture.ts CLICK_CAP): capAt is the window's start, caps
|
|
1659
|
+
// each element's count in it; the clicks past 5 are counted there, not sent.
|
|
1660
|
+
var caps = {};
|
|
1661
|
+
var capAt = 0;
|
|
1662
|
+
// The last trusted pointerup, touchend or keydown (sequential.autocapture.ts GESTURE_MS).
|
|
1663
|
+
var gestureAt = -1e9;
|
|
1664
|
+
|
|
1665
|
+
function onGesture(ev) {
|
|
1666
|
+
if (ev.isTrusted) gestureAt = now();
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1661
1669
|
function onClick(ev) {
|
|
1662
1670
|
try {
|
|
1663
1671
|
var target = ev && ev.target;
|
|
1664
1672
|
if (!target || target.nodeType !== 1) return;
|
|
1673
|
+
// A script's click (isTrusted false) counts only while the person acts (sequential.autocapture.ts untrusted).
|
|
1674
|
+
if (ev.isTrusted === false) {
|
|
1675
|
+
var ua = window.navigator.userActivation;
|
|
1676
|
+
if (!(ua && ua.isActive) && now() - gestureAt >= 1000) return;
|
|
1677
|
+
}
|
|
1665
1678
|
var matched = closestMatching(target, INTERACTIVE_SELECTOR);
|
|
1666
1679
|
if (!matched) return;
|
|
1667
|
-
|
|
1680
|
+
var props = elementProps(matched);
|
|
1681
|
+
var t = now();
|
|
1682
|
+
if (t - capAt >= 1000) {
|
|
1683
|
+
caps = {};
|
|
1684
|
+
capAt = t;
|
|
1685
|
+
}
|
|
1686
|
+
if ((caps[props.$el_selector] = (caps[props.$el_selector] || 0) + 1) <= 5) captureInternal('$click', props);
|
|
1668
1687
|
if (isPlainClick(ev) && !deadExcluded(matched, target)) openDead(matched);
|
|
1669
1688
|
} catch (e) {}
|
|
1670
1689
|
}
|
|
1671
1690
|
|
|
1672
1691
|
// ── rage and dead clicks: as in sequential.autocapture.ts (BE spec 2026-10-08, BE #432) ──
|
|
1673
|
-
// One MutationObserver, only while a burst or a dead window is open
|
|
1674
|
-
// neither signal runs, because "no effect" cannot be told from "an effect we cannot see".
|
|
1692
|
+
// One MutationObserver, only while a burst or a dead window is open; none: neither signal runs.
|
|
1675
1693
|
var Observer = window.MutationObserver;
|
|
1676
1694
|
var rage = null;
|
|
1677
1695
|
var dead = null;
|
|
@@ -1780,7 +1798,7 @@ var boot = (function (injectedTag) {
|
|
|
1780
1798
|
if (!Observer || document.visibilityState === 'hidden') return;
|
|
1781
1799
|
// A new click means the person did something: the old window ends with no event.
|
|
1782
1800
|
if (dead) clearTimeout(dead.timer);
|
|
1783
|
-
dead = { at: Date.now(), el: el, href: String(window.location.href), timer: setTimeout(endDead, DEAD_WAIT_MS) };
|
|
1801
|
+
dead = { at: Date.now(), el: el, href: String(window.location.href), selected: !closestMatching(el, '[data-sq-private]') && selectedState(el), timer: setTimeout(endDead, DEAD_WAIT_MS) };
|
|
1784
1802
|
syncObserver();
|
|
1785
1803
|
}
|
|
1786
1804
|
|
|
@@ -1791,7 +1809,7 @@ var boot = (function (injectedTag) {
|
|
|
1791
1809
|
syncObserver();
|
|
1792
1810
|
if (!d || String(window.location.href) !== d.href) return;
|
|
1793
1811
|
var props = elementProps(d.el);
|
|
1794
|
-
props.$wait_ms = DEAD_WAIT_MS;
|
|
1812
|
+
props.$wait_ms = DEAD_WAIT_MS; if (d.selected) props.$el_state = 'selected';
|
|
1795
1813
|
captureInternal('$deadclick', props, d.at);
|
|
1796
1814
|
} catch (e) {}
|
|
1797
1815
|
}
|
|
@@ -1844,6 +1862,9 @@ var boot = (function (injectedTag) {
|
|
|
1844
1862
|
document.addEventListener('submit', onSubmit, true);
|
|
1845
1863
|
document.addEventListener('pointerdown', onPointerDown, true);
|
|
1846
1864
|
document.addEventListener('pointerup', onPointerUp, true);
|
|
1865
|
+
document.addEventListener('pointerup', onGesture, true);
|
|
1866
|
+
document.addEventListener('touchend', onGesture, true);
|
|
1867
|
+
document.addEventListener('keydown', onGesture, true);
|
|
1847
1868
|
document.addEventListener('focusin', onFocusIn, true);
|
|
1848
1869
|
document.addEventListener('selectionchange', onSelectionChange, true);
|
|
1849
1870
|
document.addEventListener('scroll', onScroll, true);
|
|
@@ -2027,6 +2048,17 @@ var boot = (function (injectedTag) {
|
|
|
2027
2048
|
} catch (e) {}
|
|
2028
2049
|
}
|
|
2029
2050
|
|
|
2051
|
+
// F7: already selected when clicked (ARIA, or a class like is-active); only 'selected' is sent ($deadclick)
|
|
2052
|
+
function selectedState(el) {
|
|
2053
|
+
var v = el.getAttribute('aria-current');
|
|
2054
|
+
return ['pressed', 'checked', 'selected'].some(function (a) { return /^\s*true\s*$/i.test(el.getAttribute('aria-' + a)); }) ||
|
|
2055
|
+
(v !== null && !/^\s*(false)?\s*$/i.test(v)) ||
|
|
2056
|
+
String(el.getAttribute('class') || '').toLowerCase().split(/\s+/).some(function (t) {
|
|
2057
|
+
t = t.split(/--|__|[-_]/);
|
|
2058
|
+
return /^(active|selected|checked|current|on)$/.test(t[t.length - 1]) && !t.some(function (x) { return /^(not|un|non|no)$/.test(x); });
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2030
2062
|
if (!DISABLED) {
|
|
2031
2063
|
try {
|
|
2032
2064
|
document.addEventListener('visibilitychange', function () {
|
|
@@ -2039,7 +2071,7 @@ var boot = (function (injectedTag) {
|
|
|
2039
2071
|
}
|
|
2040
2072
|
});
|
|
2041
2073
|
|
|
2042
|
-
var VERSION = '1.0.
|
|
2074
|
+
var VERSION = '1.0.3';
|
|
2043
2075
|
var running = null;
|
|
2044
2076
|
|
|
2045
2077
|
function logLine(level, message) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @usesequential/browser 1.0.
|
|
1
|
+
/* @usesequential/browser 1.0.3: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
|
|
2
2
|
* `boot` below is sequential.js, the file the script tag loads, unchanged. */
|
|
3
3
|
var boot = (function (injectedTag) {
|
|
4
4
|
'use strict';
|
|
@@ -205,10 +205,7 @@ var boot = (function (injectedTag) {
|
|
|
205
205
|
var REQUEST_TIMEOUT_MS = 10000;
|
|
206
206
|
var MAX_SEND_ATTEMPTS = 3;
|
|
207
207
|
var RETRY_BASE_MS = 500;
|
|
208
|
-
// A 429
|
|
209
|
-
// server's retry time, clamped; hold the refused batch whole and what is captured meanwhile, capped, the oldest dropped
|
|
210
|
-
// first. A held batch is resent after each pause, as its own request, until 5 min after its first refusal
|
|
211
|
-
// (sequential.core.ts holdRateLimited).
|
|
208
|
+
// A 429 or a 503 overloaded: pause and hold, as sequential.core.ts holdRateLimited.
|
|
212
209
|
var RATE_LIMIT_DEFAULT_SEC = 60;
|
|
213
210
|
var RATE_LIMIT_MIN_SEC = 1;
|
|
214
211
|
var RATE_LIMIT_MAX_SEC = 300;
|
|
@@ -959,11 +956,11 @@ var boot = (function (injectedTag) {
|
|
|
959
956
|
for (i = 0; i < w.length; i++) if (w[i].length > 2 && inList(idWords, w[i])) return true;
|
|
960
957
|
}
|
|
961
958
|
|
|
962
|
-
// Account UI (the element or
|
|
963
|
-
//
|
|
964
|
-
//
|
|
965
|
-
//
|
|
966
|
-
//
|
|
959
|
+
// Account UI (the element or its 3 nearest ancestors):
|
|
960
|
+
// as in sequential.autocapture.ts.
|
|
961
|
+
// `profile` alone is not
|
|
962
|
+
// account UI
|
|
963
|
+
// (2026-10-26).
|
|
967
964
|
var ACCOUNT_WORD = /(\b|_)(avatar|account|user[-_]?menu|profile[-_](menu|dropdown|button|avatar)|(my|user)[-_]profile)(\b|_)/;
|
|
968
965
|
var ACCOUNT_LABEL = /^(account|user|profile)$|\b(my|your|open) (account|profile)\b|\b(user|account|profile)( navigation)? (menu|dropdown|options)\b/;
|
|
969
966
|
function inAccountUi(node) {
|
|
@@ -1122,11 +1119,11 @@ var boot = (function (injectedTag) {
|
|
|
1122
1119
|
} catch (e) {}
|
|
1123
1120
|
}
|
|
1124
1121
|
|
|
1125
|
-
// Another tab's optOut() (
|
|
1126
|
-
//
|
|
1127
|
-
//
|
|
1128
|
-
//
|
|
1129
|
-
//
|
|
1122
|
+
// Another tab's optOut() (__sq_opt set to '1') opts this tab out at once;
|
|
1123
|
+
// it writes back none of the ids that tab deleted.
|
|
1124
|
+
// Another tab's optIn() or localStorage.clear()
|
|
1125
|
+
// does not opt this tab in:
|
|
1126
|
+
// that waits for the next page load.
|
|
1130
1127
|
try {
|
|
1131
1128
|
window.addEventListener('storage', function (e) {
|
|
1132
1129
|
if (e && e.key === OPT_OUT_KEY && e.newValue === '1' && !optedOut) optOut();
|
|
@@ -1542,9 +1539,7 @@ var boot = (function (injectedTag) {
|
|
|
1542
1539
|
return r.target.getAttribute(r.attributeName) !== r.oldValue;
|
|
1543
1540
|
}
|
|
1544
1541
|
|
|
1545
|
-
//
|
|
1546
|
-
// isPrimary: Chromium sends `click` as a PointerEvent with isPrimary=false; only pointer events
|
|
1547
|
-
// check it (isPlainPointer).
|
|
1542
|
+
// As sequential.autocapture.ts isPlainClick and isPlainPointer.
|
|
1548
1543
|
function isPlainClick(ev) {
|
|
1549
1544
|
return ev.button === 0 && !ev.ctrlKey && !ev.metaKey && !ev.shiftKey && !ev.altKey;
|
|
1550
1545
|
}
|
|
@@ -1553,6 +1548,12 @@ var boot = (function (injectedTag) {
|
|
|
1553
1548
|
return isPlainClick(ev) && ev.isPrimary !== false;
|
|
1554
1549
|
}
|
|
1555
1550
|
|
|
1551
|
+
// Monotonic where there is one, so a step of the wall clock cannot freeze the $click cap's window.
|
|
1552
|
+
function now() {
|
|
1553
|
+
var p = window.performance;
|
|
1554
|
+
return p && p.now ? p.now() : Date.now();
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1556
1557
|
function startAutocapture(attachUrl) {
|
|
1557
1558
|
if (autocaptureStarted || !redactor) return;
|
|
1558
1559
|
autocaptureStarted = true;
|
|
@@ -1575,9 +1576,7 @@ var boot = (function (injectedTag) {
|
|
|
1575
1576
|
});
|
|
1576
1577
|
}
|
|
1577
1578
|
|
|
1578
|
-
// One page key
|
|
1579
|
-
// route) for every trigger, as in
|
|
1580
|
-
// sequential.autocapture.ts pageKey: a router's same-URL replaceState is not a pageview.
|
|
1579
|
+
// One page key for every trigger, as sequential.autocapture.ts pageKey.
|
|
1581
1580
|
var lastPageKey = null;
|
|
1582
1581
|
var lastPathKey = null;
|
|
1583
1582
|
var lastNavigationType;
|
|
@@ -1599,9 +1598,7 @@ var boot = (function (injectedTag) {
|
|
|
1599
1598
|
} catch (e) {}
|
|
1600
1599
|
}
|
|
1601
1600
|
|
|
1602
|
-
// A traversal the page's router answers with replaceState
|
|
1603
|
-
// replace while a popstate is being handled (window.event, or our capture listener's mark) is that traversal, of
|
|
1604
|
-
// the kind of the last navigate event before it that was not a replace.
|
|
1601
|
+
// A traversal the page's router answers with replaceState: as sequential.autocapture.ts inPopstate (F1).
|
|
1605
1602
|
var popPending = false;
|
|
1606
1603
|
var popKind;
|
|
1607
1604
|
function onPopCapture() {
|
|
@@ -1657,20 +1654,41 @@ var boot = (function (injectedTag) {
|
|
|
1657
1654
|
};
|
|
1658
1655
|
}
|
|
1659
1656
|
|
|
1657
|
+
// At most 5 $click per element per second (sequential.autocapture.ts CLICK_CAP): capAt is the window's start, caps
|
|
1658
|
+
// each element's count in it; the clicks past 5 are counted there, not sent.
|
|
1659
|
+
var caps = {};
|
|
1660
|
+
var capAt = 0;
|
|
1661
|
+
// The last trusted pointerup, touchend or keydown (sequential.autocapture.ts GESTURE_MS).
|
|
1662
|
+
var gestureAt = -1e9;
|
|
1663
|
+
|
|
1664
|
+
function onGesture(ev) {
|
|
1665
|
+
if (ev.isTrusted) gestureAt = now();
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1660
1668
|
function onClick(ev) {
|
|
1661
1669
|
try {
|
|
1662
1670
|
var target = ev && ev.target;
|
|
1663
1671
|
if (!target || target.nodeType !== 1) return;
|
|
1672
|
+
// A script's click (isTrusted false) counts only while the person acts (sequential.autocapture.ts untrusted).
|
|
1673
|
+
if (ev.isTrusted === false) {
|
|
1674
|
+
var ua = window.navigator.userActivation;
|
|
1675
|
+
if (!(ua && ua.isActive) && now() - gestureAt >= 1000) return;
|
|
1676
|
+
}
|
|
1664
1677
|
var matched = closestMatching(target, INTERACTIVE_SELECTOR);
|
|
1665
1678
|
if (!matched) return;
|
|
1666
|
-
|
|
1679
|
+
var props = elementProps(matched);
|
|
1680
|
+
var t = now();
|
|
1681
|
+
if (t - capAt >= 1000) {
|
|
1682
|
+
caps = {};
|
|
1683
|
+
capAt = t;
|
|
1684
|
+
}
|
|
1685
|
+
if ((caps[props.$el_selector] = (caps[props.$el_selector] || 0) + 1) <= 5) captureInternal('$click', props);
|
|
1667
1686
|
if (isPlainClick(ev) && !deadExcluded(matched, target)) openDead(matched);
|
|
1668
1687
|
} catch (e) {}
|
|
1669
1688
|
}
|
|
1670
1689
|
|
|
1671
1690
|
// ── rage and dead clicks: as in sequential.autocapture.ts (BE spec 2026-10-08, BE #432) ──
|
|
1672
|
-
// One MutationObserver, only while a burst or a dead window is open
|
|
1673
|
-
// neither signal runs, because "no effect" cannot be told from "an effect we cannot see".
|
|
1691
|
+
// One MutationObserver, only while a burst or a dead window is open; none: neither signal runs.
|
|
1674
1692
|
var Observer = window.MutationObserver;
|
|
1675
1693
|
var rage = null;
|
|
1676
1694
|
var dead = null;
|
|
@@ -1779,7 +1797,7 @@ var boot = (function (injectedTag) {
|
|
|
1779
1797
|
if (!Observer || document.visibilityState === 'hidden') return;
|
|
1780
1798
|
// A new click means the person did something: the old window ends with no event.
|
|
1781
1799
|
if (dead) clearTimeout(dead.timer);
|
|
1782
|
-
dead = { at: Date.now(), el: el, href: String(window.location.href), timer: setTimeout(endDead, DEAD_WAIT_MS) };
|
|
1800
|
+
dead = { at: Date.now(), el: el, href: String(window.location.href), selected: !closestMatching(el, '[data-sq-private]') && selectedState(el), timer: setTimeout(endDead, DEAD_WAIT_MS) };
|
|
1783
1801
|
syncObserver();
|
|
1784
1802
|
}
|
|
1785
1803
|
|
|
@@ -1790,7 +1808,7 @@ var boot = (function (injectedTag) {
|
|
|
1790
1808
|
syncObserver();
|
|
1791
1809
|
if (!d || String(window.location.href) !== d.href) return;
|
|
1792
1810
|
var props = elementProps(d.el);
|
|
1793
|
-
props.$wait_ms = DEAD_WAIT_MS;
|
|
1811
|
+
props.$wait_ms = DEAD_WAIT_MS; if (d.selected) props.$el_state = 'selected';
|
|
1794
1812
|
captureInternal('$deadclick', props, d.at);
|
|
1795
1813
|
} catch (e) {}
|
|
1796
1814
|
}
|
|
@@ -1843,6 +1861,9 @@ var boot = (function (injectedTag) {
|
|
|
1843
1861
|
document.addEventListener('submit', onSubmit, true);
|
|
1844
1862
|
document.addEventListener('pointerdown', onPointerDown, true);
|
|
1845
1863
|
document.addEventListener('pointerup', onPointerUp, true);
|
|
1864
|
+
document.addEventListener('pointerup', onGesture, true);
|
|
1865
|
+
document.addEventListener('touchend', onGesture, true);
|
|
1866
|
+
document.addEventListener('keydown', onGesture, true);
|
|
1846
1867
|
document.addEventListener('focusin', onFocusIn, true);
|
|
1847
1868
|
document.addEventListener('selectionchange', onSelectionChange, true);
|
|
1848
1869
|
document.addEventListener('scroll', onScroll, true);
|
|
@@ -2026,6 +2047,17 @@ var boot = (function (injectedTag) {
|
|
|
2026
2047
|
} catch (e) {}
|
|
2027
2048
|
}
|
|
2028
2049
|
|
|
2050
|
+
// F7: already selected when clicked (ARIA, or a class like is-active); only 'selected' is sent ($deadclick)
|
|
2051
|
+
function selectedState(el) {
|
|
2052
|
+
var v = el.getAttribute('aria-current');
|
|
2053
|
+
return ['pressed', 'checked', 'selected'].some(function (a) { return /^\s*true\s*$/i.test(el.getAttribute('aria-' + a)); }) ||
|
|
2054
|
+
(v !== null && !/^\s*(false)?\s*$/i.test(v)) ||
|
|
2055
|
+
String(el.getAttribute('class') || '').toLowerCase().split(/\s+/).some(function (t) {
|
|
2056
|
+
t = t.split(/--|__|[-_]/);
|
|
2057
|
+
return /^(active|selected|checked|current|on)$/.test(t[t.length - 1]) && !t.some(function (x) { return /^(not|un|non|no)$/.test(x); });
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2029
2061
|
if (!DISABLED) {
|
|
2030
2062
|
try {
|
|
2031
2063
|
document.addEventListener('visibilitychange', function () {
|
|
@@ -2038,7 +2070,7 @@ var boot = (function (injectedTag) {
|
|
|
2038
2070
|
}
|
|
2039
2071
|
});
|
|
2040
2072
|
|
|
2041
|
-
var VERSION = '1.0.
|
|
2073
|
+
var VERSION = '1.0.3';
|
|
2042
2074
|
var running = null;
|
|
2043
2075
|
|
|
2044
2076
|
function logLine(level, message) {
|
package/package.json
CHANGED