@mixpanel/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) • 3.99 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 g={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},b={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},l={},v=()=>!!globalThis.Zone;function p(t){if(l[t])return l[t];const e=globalThis[t],o=e.prototype,n=t in g?g[t]:void 0,r=!!(n&&n.every(i=>{var s,a;return!!((a=(s=Object.getOwnPropertyDescriptor(o,i))==null?void 0:s.get)!=null&&a.toString().includes("[native code]"))})),u=t in b?b[t]:void 0,d=!!(u&&u.every(i=>{var s;return typeof o[i]=="function"&&((s=o[i])==null?void 0:s.toString().includes("[native code]"))}));if(r&&d&&!v())return l[t]=e.prototype,e.prototype;try{const i=document.createElement("iframe");document.body.appendChild(i);const s=i.contentWindow;if(!s)return e.prototype;const a=s[t].prototype;return document.body.removeChild(i),a?l[t]=a:o}catch(i){return o}}const f={};function c(t,e,o){var n;const r=`${t}.${String(o)}`;if(f[r])return f[r].call(e);const u=p(t),d=(n=Object.getOwnPropertyDescriptor(u,o))==null?void 0:n.get;return d?(f[r]=d,d.call(e)):e[o]}const h={};function y(t,e,o){const n=`${t}.${String(o)}`;if(h[n])return h[n].bind(e);const u=p(t)[o];return typeof u!="function"?e[o]:(h[n]=u,u.bind(e))}function N(t){return c("Node",t,"childNodes")}function S(t){return c("Node",t,"parentNode")}function m(t){return c("Node",t,"parentElement")}function w(t){return c("Node",t,"textContent")}function O(t,e){return y("Node",t,"contains")(e)}function P(t){return y("Node",t,"getRootNode")()}function A(t){return!t||!("host"in t)?null:c("ShadowRoot",t,"host")}function R(t){return t.styleSheets}function E(t){return!t||!("shadowRoot"in t)?null:c("Element",t,"shadowRoot")}function M(t,e){return c("Element",t,"querySelector")(e)}function _(t,e){return c("Element",t,"querySelectorAll")(e)}function C(){return p("MutationObserver").constructor}function q(t,e,o){try{if(!(e in t))return()=>{};const n=t[e],r=o(n);return typeof r=="function"&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:n}})),t[e]=r,()=>{t[e]=n}}catch(n){return()=>{}}}const U={childNodes:N,parentNode:S,parentElement:m,textContent:w,contains:O,getRootNode:P,host:A,styleSheets:R,shadowRoot:E,querySelector:M,querySelectorAll:_,mutationObserver:C,patch:q};exports.childNodes=N;exports.contains=O;exports.default=U;exports.getRootNode=P;exports.getUntaintedAccessor=c;exports.getUntaintedMethod=y;exports.getUntaintedPrototype=p;exports.host=A;exports.isAngularZonePresent=v;exports.mutationObserverCtor=C;exports.parentElement=m;exports.parentNode=S;exports.patch=q;exports.querySelector=M;exports.querySelectorAll=_;exports.shadowRoot=E;exports.styleSheets=R;exports.textContent=w;
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