@usesequential/browser 1.0.4 → 1.0.5

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.5
4
+
5
+ - On-screen messages (`$ui_message`) count only what the person can see. A region that is `display:none`,
6
+ `visibility:hidden` or `collapse`, marked `aria-busy="true"` (still loading), or visually hidden (positioned absolutely or
7
+ fixed and at most 1 pixel wide or high, as `.sr-only` classes do) sends nothing, and text inside such a part of a region is
8
+ not read. A loading skeleton announced to screen readers is no longer sent as a message. Styles are read only for a region
9
+ whose text just changed, never for every element on the page.
10
+
3
11
  ## 1.0.4
4
12
 
5
13
  - The person's own pointerup, touchend or keydown is noted on the window, before any handler of the page runs. So a click
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /* @usesequential/browser 1.0.4: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
1
+ /* @usesequential/browser 1.0.5: 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) {
@@ -1322,7 +1322,16 @@ var boot = (function (injectedTag) {
1322
1322
  return !!closestMatching(el, '[data-sq-mask], [data-sq-private]');
1323
1323
  }
1324
1324
 
1325
- // skip (the message detector's MSG_TYPED): also leave out what matches it, or what the browser says is editable.
1325
+ // D1 is a message the person SEES: display:none, visibility hidden, aria-busy (still loading), or visually hidden
1326
+ // (absolute/fixed and <= 1px wide or high: .sr-only) is unseen; up: the ancestors too. A loading skeleton is no message.
1327
+ function unseen(el, up) {
1328
+ for (; el && el.nodeType === 1; el = up ? el.parentNode : null) {
1329
+ var s = window.getComputedStyle(el);
1330
+ if (s.display == 'none' || /hid|col/.test(s.visibility) || el.getAttribute('aria-busy') == 'true' || (/^(abs|fix)/.test(s.position) && (parseFloat(s.width) <= 1 || parseFloat(s.height) <= 1))) return 1;
1331
+ }
1332
+ }
1333
+
1334
+ // skip (the message detector's MSG_TYPED): also leave out what matches it, what the browser says is editable, or unseen.
1326
1335
  function subtreeText(el, skip) {
1327
1336
  var out = '';
1328
1337
  function visit(node) {
@@ -1336,7 +1345,7 @@ var boot = (function (injectedTag) {
1336
1345
  if (inList(TEXT_OPAQUE_TAGS, tagNameOf(child))) continue;
1337
1346
  if (isEditable(child)) continue;
1338
1347
  if (child.hasAttribute && (child.hasAttribute('data-sq-mask') || child.hasAttribute('data-sq-private'))) continue;
1339
- if (skip && (child.isContentEditable === true || matchesSelector(child, skip))) continue;
1348
+ if (skip && (child.isContentEditable === true || matchesSelector(child, skip) || unseen(child))) continue;
1340
1349
  visit(child);
1341
1350
  }
1342
1351
  }
@@ -1935,6 +1944,8 @@ var boot = (function (injectedTag) {
1935
1944
  // Read again only when its text changed ("Saving…" → "Network error" in one window is two messages).
1936
1945
  if (!text || (msgExamined && msgExamined.get(m) === text)) return;
1937
1946
  if (msgExamined) msgExamined.set(m, text);
1947
+ // Only now, for a candidate with new text: is the region itself seen (its ancestors' styles, once per new text)?
1948
+ if (unseen(shown, 1)) return;
1938
1949
  var cl = 'other';
1939
1950
  var t0 = now();
1940
1951
  for (var i = 0; i < msgRules.length; i++) {
@@ -2217,7 +2228,7 @@ var boot = (function (injectedTag) {
2217
2228
  }
2218
2229
  });
2219
2230
 
2220
- var VERSION = '1.0.4';
2231
+ var VERSION = '1.0.5';
2221
2232
  var running = null;
2222
2233
 
2223
2234
  function logLine(level, message) {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* @usesequential/browser 1.0.4: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
1
+ /* @usesequential/browser 1.0.5: 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';
@@ -1321,7 +1321,16 @@ var boot = (function (injectedTag) {
1321
1321
  return !!closestMatching(el, '[data-sq-mask], [data-sq-private]');
1322
1322
  }
1323
1323
 
1324
- // skip (the message detector's MSG_TYPED): also leave out what matches it, or what the browser says is editable.
1324
+ // D1 is a message the person SEES: display:none, visibility hidden, aria-busy (still loading), or visually hidden
1325
+ // (absolute/fixed and <= 1px wide or high: .sr-only) is unseen; up: the ancestors too. A loading skeleton is no message.
1326
+ function unseen(el, up) {
1327
+ for (; el && el.nodeType === 1; el = up ? el.parentNode : null) {
1328
+ var s = window.getComputedStyle(el);
1329
+ if (s.display == 'none' || /hid|col/.test(s.visibility) || el.getAttribute('aria-busy') == 'true' || (/^(abs|fix)/.test(s.position) && (parseFloat(s.width) <= 1 || parseFloat(s.height) <= 1))) return 1;
1330
+ }
1331
+ }
1332
+
1333
+ // skip (the message detector's MSG_TYPED): also leave out what matches it, what the browser says is editable, or unseen.
1325
1334
  function subtreeText(el, skip) {
1326
1335
  var out = '';
1327
1336
  function visit(node) {
@@ -1335,7 +1344,7 @@ var boot = (function (injectedTag) {
1335
1344
  if (inList(TEXT_OPAQUE_TAGS, tagNameOf(child))) continue;
1336
1345
  if (isEditable(child)) continue;
1337
1346
  if (child.hasAttribute && (child.hasAttribute('data-sq-mask') || child.hasAttribute('data-sq-private'))) continue;
1338
- if (skip && (child.isContentEditable === true || matchesSelector(child, skip))) continue;
1347
+ if (skip && (child.isContentEditable === true || matchesSelector(child, skip) || unseen(child))) continue;
1339
1348
  visit(child);
1340
1349
  }
1341
1350
  }
@@ -1934,6 +1943,8 @@ var boot = (function (injectedTag) {
1934
1943
  // Read again only when its text changed ("Saving…" → "Network error" in one window is two messages).
1935
1944
  if (!text || (msgExamined && msgExamined.get(m) === text)) return;
1936
1945
  if (msgExamined) msgExamined.set(m, text);
1946
+ // Only now, for a candidate with new text: is the region itself seen (its ancestors' styles, once per new text)?
1947
+ if (unseen(shown, 1)) return;
1937
1948
  var cl = 'other';
1938
1949
  var t0 = now();
1939
1950
  for (var i = 0; i < msgRules.length; i++) {
@@ -2216,7 +2227,7 @@ var boot = (function (injectedTag) {
2216
2227
  }
2217
2228
  });
2218
2229
 
2219
- var VERSION = '1.0.4';
2230
+ var VERSION = '1.0.5';
2220
2231
  var running = null;
2221
2232
 
2222
2233
  function logLine(level, message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usesequential/browser",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "The Sequential browser SDK as an npm package: analytics and session replay, the same code as the script tag.",
5
5
  "keywords": [
6
6
  "sequential",