@appsurify-testmap/rrweb-utils
Version:
This package contains the shared utility functions used across rrweb packages. See the [guide](../../guide.md) for more info on rrweb.
33 lines (32 loc) • 4.87 kB
JavaScript
(function (g, f) {
if ("object" == typeof exports && "object" == typeof module) {
module.exports = f();
} else if ("function" == typeof define && define.amd) {
define("rrwebUtils", [], f);
} else if ("object" == typeof exports) {
exports["rrwebUtils"] = f();
} else {
g["rrwebUtils"] = f();
}
}(this, () => {
var exports = {};
var module = { exports };
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},S={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},d={},w=()=>!!globalThis.Zone;function h(t){if(d[t])return d[t];const e=globalThis[t],r=e.prototype,o=t in N?N[t]:void 0,n=!!(o&&o.every(s=>{var i,u;return!!((u=(i=Object.getOwnPropertyDescriptor(r,s))==null?void 0:i.get)!=null&&u.toString().includes("[native code]"))})),c=t in S?S[t]:void 0,l=!!(c&&c.every(s=>{var i;return typeof r[s]=="function"&&((i=r[s])==null?void 0:i.toString().includes("[native code]"))}));if(n&&l&&!w())return d[t]=e.prototype,e.prototype;try{const s=document.createElement("iframe");document.body.appendChild(s);const i=s.contentWindow;if(!i)return e.prototype;const u=i[t].prototype;return document.body.removeChild(s),u?d[t]=u:r}catch(s){return r}}const p={};function a(t,e,r){var o;const n=`${t}.${String(r)}`;if(p[n])return p[n].call(e);const c=h(t),l=(o=Object.getOwnPropertyDescriptor(c,r))==null?void 0:o.get;return l?(p[n]=l,l.call(e)):e[r]}const f={};function g(t,e,r){const o=`${t}.${String(r)}`;if(f[o])return f[o].bind(e);const c=h(t)[r];return typeof c!="function"?e[r]:(f[o]=c,c.bind(e))}function M(t){return a("Node",t,"childNodes")}function O(t){return a("Node",t,"parentNode")}function A(t){return a("Node",t,"parentElement")}function E(t){return a("Node",t,"textContent")}function R(t,e){return g("Node",t,"contains")(e)}function C(t){return g("Node",t,"getRootNode")()}function P(t){return!t||!("host"in t)?null:a("ShadowRoot",t,"host")}function _(t){return t.styleSheets}function x(t){return!t||!("shadowRoot"in t)?null:a("Element",t,"shadowRoot")}function q(t,e){return a("Element",t,"querySelector")(e)}function U(t,e){return a("Element",t,"querySelectorAll")(e)}function $(){return h("MutationObserver").constructor}function j(t,e,r){try{if(!(e in t))return()=>{};const o=t[e],n=r(o);return typeof n=="function"&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__rrweb_original__:{enumerable:!1,value:o}})),t[e]=n,()=>{t[e]=o}}catch(o){return()=>{}}}function V(t){const e=t.tagName.toLowerCase(),r=t.id?`#${t.id}`:"",o=t.classList.length?"."+Array.from(t.classList).join("."):"";return`${e}${r}${o}`}function B(t){var b;var e,r;const o=(b=(e=t.ownerDocument)==null?void 0:e.defaultView)!=null?b:window,n=t.getBoundingClientRect(),c=o.innerWidth||o.document.documentElement.clientWidth||0,l=o.innerHeight||o.document.documentElement.clientHeight||0,s=n.width>0&&n.height>0&&n.bottom>0&&n.right>0&&n.top<l&&n.left<c,i=(r=o.getComputedStyle)==null?void 0:r.call(o,t),y=!!i&&i.display!=="none"&&i.visibility!=="hidden"&&(parseFloat(i.opacity)||0)>0&&s;let m=0;if(y){const W=Math.max(0,Math.min(n.right,c)-Math.max(n.left,0)),D=Math.max(0,Math.min(n.bottom,l)-Math.max(n.top,0)),H=W*D,v=n.width*n.height;m=v>0?H/v:0}return{isVisible:y,ratio:m}}const L={childNodes:M,parentNode:O,parentElement:A,textContent:E,contains:R,getRootNode:C,host:P,styleSheets:_,shadowRoot:x,querySelector:q,querySelectorAll:U,mutationObserver:$,patch:j,describeNode:V,getElementVisibility:B};exports.childNodes=M;exports.contains=R;exports.default=L;exports.describeNode=V;exports.getElementVisibility=B;exports.getRootNode=C;exports.getUntaintedAccessor=a;exports.getUntaintedMethod=g;exports.getUntaintedPrototype=h;exports.host=P;exports.isAngularZonePresent=w;exports.mutationObserverCtor=$;exports.parentElement=A;exports.parentNode=O;exports.patch=j;exports.querySelector=q;exports.querySelectorAll=U;exports.shadowRoot=x;exports.styleSheets=_;exports.textContent=E;
if (typeof module.exports == "object" && typeof exports == "object") {
var __cp = (to, from, except, desc) => {
if ((from && typeof from === "object") || typeof from === "function") {
for (let key of Object.getOwnPropertyNames(from)) {
if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
Object.defineProperty(to, key, {
get: () => from[key],
enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
});
}
}
return to;
};
module.exports = __cp(module.exports, exports);
}
return module.exports;
}))
//# sourceMappingURL=rrweb-utils.umd.min.cjs.map