@appsurify-testmap/rrweb-snapshot 3.11.0-alpha.1 → 3.12.0-alpha.1
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/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/rrweb-snapshot.cjs +29 -9
- package/dist/rrweb-snapshot.cjs.map +1 -1
- package/dist/rrweb-snapshot.js +29 -9
- package/dist/rrweb-snapshot.js.map +1 -1
- package/dist/rrweb-snapshot.umd.cjs +29 -9
- package/dist/rrweb-snapshot.umd.cjs.map +3 -3
- package/dist/rrweb-snapshot.umd.min.cjs +16 -16
- package/dist/rrweb-snapshot.umd.min.cjs.map +3 -3
- package/package.json +3 -3
package/dist/rrweb-snapshot.js
CHANGED
|
@@ -170,16 +170,30 @@ function describeNode(el) {
|
|
|
170
170
|
const classes = el.classList.length ? "." + Array.from(el.classList).join(".") : "";
|
|
171
171
|
return `${tag}${id}${classes}`;
|
|
172
172
|
}
|
|
173
|
+
function isAncestorOpacityVisible(el, win) {
|
|
174
|
+
var _a;
|
|
175
|
+
let node2 = el.parentElement;
|
|
176
|
+
while (node2) {
|
|
177
|
+
const s = (_a = win.getComputedStyle) == null ? void 0 : _a.call(win, node2);
|
|
178
|
+
if (s && (parseFloat(s.opacity) || 0) <= 0) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
node2 = node2.parentElement;
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
173
185
|
function getElementVisibility(el) {
|
|
174
186
|
var _a, _b;
|
|
175
187
|
const win = ((_a = el.ownerDocument) == null ? void 0 : _a.defaultView) ?? window;
|
|
176
188
|
const rect = el.getBoundingClientRect();
|
|
177
189
|
const viewportWidth = win.innerWidth || win.document.documentElement.clientWidth || 0;
|
|
178
190
|
const viewportHeight = win.innerHeight || win.document.documentElement.clientHeight || 0;
|
|
179
|
-
const
|
|
191
|
+
const elHasSize = rect.width > 0 && rect.height > 0;
|
|
192
|
+
const isViewportVisible = elHasSize && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth;
|
|
180
193
|
const style = (_b = win.getComputedStyle) == null ? void 0 : _b.call(win, el);
|
|
181
|
-
const
|
|
182
|
-
const
|
|
194
|
+
const isOwnStyleVisible = !!style && style.display !== "none" && style.visibility !== "hidden" && (parseFloat(style.opacity) || 0) > 0;
|
|
195
|
+
const isCSSVisible = isOwnStyleVisible && isAncestorOpacityVisible(el, win);
|
|
196
|
+
const isVisible = isCSSVisible && isViewportVisible;
|
|
183
197
|
let ratio = 0;
|
|
184
198
|
if (isVisible) {
|
|
185
199
|
const xOverlap = Math.max(
|
|
@@ -196,6 +210,9 @@ function getElementVisibility(el) {
|
|
|
196
210
|
}
|
|
197
211
|
return {
|
|
198
212
|
isVisible,
|
|
213
|
+
isCSSVisible,
|
|
214
|
+
isViewportVisible,
|
|
215
|
+
hasSize: elHasSize,
|
|
199
216
|
ratio
|
|
200
217
|
};
|
|
201
218
|
}
|
|
@@ -647,19 +664,18 @@ function isTextVisible(n) {
|
|
|
647
664
|
var _a;
|
|
648
665
|
const parent = index.parentNode(n);
|
|
649
666
|
const parentElement2 = parent && parent;
|
|
650
|
-
if (!parentElement2) {
|
|
667
|
+
if (!parentElement2 || parentElement2.nodeType !== Node.ELEMENT_NODE) {
|
|
651
668
|
return false;
|
|
652
669
|
}
|
|
653
|
-
const
|
|
654
|
-
if (!
|
|
670
|
+
const parentVis = isElementVisible(parentElement2);
|
|
671
|
+
if (!parentVis.isVisible) {
|
|
655
672
|
return false;
|
|
656
673
|
}
|
|
657
674
|
const textContent2 = (_a = n.textContent) == null ? void 0 : _a.trim();
|
|
658
675
|
return textContent2 !== "";
|
|
659
676
|
}
|
|
660
677
|
function isElementVisible(el) {
|
|
661
|
-
|
|
662
|
-
return visibility.isVisible;
|
|
678
|
+
return index.getElementVisibility(el);
|
|
663
679
|
}
|
|
664
680
|
const interactiveEvents = [
|
|
665
681
|
"change",
|
|
@@ -3089,7 +3105,11 @@ function serializeNodeWithId(n, options) {
|
|
|
3089
3105
|
serializedNode.isVisible = isTextVisible(n);
|
|
3090
3106
|
}
|
|
3091
3107
|
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
3092
|
-
|
|
3108
|
+
const vis = isElementVisible(n);
|
|
3109
|
+
serializedNode.isVisible = vis.isVisible;
|
|
3110
|
+
serializedNode.isCSSVisible = vis.isCSSVisible;
|
|
3111
|
+
serializedNode.isViewportVisible = vis.isViewportVisible;
|
|
3112
|
+
serializedNode.hasSize = vis.hasSize;
|
|
3093
3113
|
serializedNode.isInteractive = isElementInteractive(n);
|
|
3094
3114
|
}
|
|
3095
3115
|
}
|