UNPKG

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