rrweb-snapshot
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -16,2 +16,7 @@ var rrwebSnapshot = (function (exports) { | ||
} | ||
function isShadowRoot(n) { | ||
var _a; | ||
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host; | ||
return Boolean(host && host.shadowRoot && host.shadowRoot === n); | ||
} | ||
@@ -513,2 +518,5 @@ var _id = 1; | ||
} | ||
if (n.parentNode && isShadowRoot(n.parentNode)) { | ||
serializedNode.isShadow = true; | ||
} | ||
if (serializedNode.type === exports.NodeType.Element && | ||
@@ -1333,2 +1341,4 @@ serializedNode.tagName === 'iframe') { | ||
exports.IGNORED_NODE = IGNORED_NODE; | ||
exports.isElement = isElement; | ||
exports.isShadowRoot = isShadowRoot; | ||
@@ -1335,0 +1345,0 @@ return exports; |
@@ -1,2 +0,2 @@ | ||
var rrwebSnapshot=function(e){"use strict";var t;function r(e){return e.nodeType===e.ELEMENT_NODE}(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var n=1,a=RegExp("[^a-z0-9-_]"),o=-2;function i(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(s).join(""):null}catch(e){return null}}function s(e){return function(e){return"styleSheet"in e}(e)?i(e.styleSheet)||"":e.cssText}var c=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,u=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,l=/^(data:)([^,]*),(.*)/i;function f(e,t){return(e||"").replace(c,function(e,r,n,a,o,i){var s,c=n||o||i,f=r||a||"";if(!c)return e;if(!u.test(c))return"url("+f+c+f+")";if(l.test(c))return"url("+f+c+f+")";if("/"===c[0])return"url("+f+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+f+")";var p=t.split("/"),d=c.split("/");p.pop();for(var m=0,h=d;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?p.pop():p.push(v))}return"url("+f+p.join("/")+f+")"})}function p(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function d(){var e=document.createElement("a");return e.href="",e.href}function m(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?p(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?p(e,r[0])+" "+r[1]:1===r.length?""+p(e,r[0]):""}).join(", ")}(e,n):"style"===r&&n?f(n,d()):n:p(e,n)}function h(t,r){var n,o,s=r.doc,c=r.blockClass,u=r.blockSelector,l=r.inlineStylesheet,p=r.maskInputOptions,h=void 0===p?{}:p,v=r.recordCanvas;if(s.__sn){var y=s.__sn.id;n=1===y?void 0:y}switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[],rootId:n};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:n};case t.ELEMENT_NODE:for(var g=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var a=e.classList[n];if(t.test(a))return!0}return!!r&&e.matches(r)}(t,c,u),b=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return a.test(t)?"div":t}(t),T={},N=0,C=Array.from(t.attributes);N<C.length;N++){var k=C[N],w=k.name,E=k.value;T[w]=m(s,b,w,E)}if("link"===b&&l){var S,_=Array.from(s.styleSheets).find(function(e){return e.href===t.href});(S=i(_))&&(delete T.rel,delete T.href,T._cssText=f(S,_.href))}if("style"===b&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(S=i(t.sheet))&&(T._cssText=f(S,d()));if("input"===b||"textarea"===b||"select"===b){E=t.value;"radio"!==T.type&&"checkbox"!==T.type&&"submit"!==T.type&&"button"!==T.type&&E?T.value=h[T.type]||h[b]?"*".repeat(E.length):E:t.checked&&(T.checked=t.checked)}if("option"===b){var D=t.parentElement;T.value===D.value&&(T.selected=t.selected)}if("canvas"===b&&v&&(T.rr_dataURL=t.toDataURL()),"audio"!==b&&"video"!==b||(T.rr_mediaState=t.paused?"paused":"played"),t.scrollLeft&&(T.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(T.rr_scrollTop=t.scrollTop),g){var x=t.getBoundingClientRect(),A=x.width,O=x.height;T={class:T.class,rr_width:A+"px",rr_height:O+"px"}}return"iframe"===b&&delete T.src,{type:e.NodeType.Element,tagName:b,attributes:T,childNodes:[],isSVG:(o=t,"svg"===o.tagName||o instanceof SVGElement||void 0),needBlock:g,rootId:n};case t.TEXT_NODE:var L=t.parentNode&&t.parentNode.tagName,I=t.textContent,M="STYLE"===L||void 0;return M&&I&&(I=f(I,d())),"SCRIPT"===L&&(I="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:I||"",isStyle:M,rootId:n};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:n};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:n};default:return!1}}function v(e){return void 0===e?"":e.toLowerCase()}function y(t,a){var i,s=a.doc,c=a.map,u=a.blockClass,l=a.blockSelector,f=a.skipChild,p=void 0!==f&&f,d=a.inlineStylesheet,m=void 0===d||d,g=a.maskInputOptions,b=void 0===g?{}:g,T=a.slimDOMOptions,N=a.recordCanvas,C=void 0!==N&&N,k=a.onSerialize,w=a.onIframeLoad,E=a.iframeLoadTimeout,S=void 0===E?5e3:E,_=a.preserveWhiteSpace,D=void 0===_||_,x=h(t,{doc:s,blockClass:u,blockSelector:l,inlineStylesheet:m,maskInputOptions:b,recordCanvas:C});if(!x)return console.warn(t,"not serialized"),null;i="__sn"in t?t.__sn.id:!function(t,r){if(r.comment&&t.type===e.NodeType.Comment)return!0;if(t.type===e.NodeType.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(v(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===v(t.attributes.name)||"icon"===v(t.attributes.rel)||"apple-touch-icon"===v(t.attributes.rel)||"shortcut icon"===v(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&v(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(v(t.attributes.property).match(/^(og|twitter|fb):/)||v(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===v(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===v(t.attributes.name)||"googlebot"===v(t.attributes.name)||"bingbot"===v(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===v(t.attributes.name)||"generator"===v(t.attributes.name)||"framework"===v(t.attributes.name)||"publisher"===v(t.attributes.name)||"progid"===v(t.attributes.name)||v(t.attributes.property).match(/^article:/)||v(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===v(t.attributes.name)||"yandex-verification"===v(t.attributes.name)||"csrf-token"===v(t.attributes.name)||"p:domain_verify"===v(t.attributes.name)||"verify-v1"===v(t.attributes.name)||"verification"===v(t.attributes.name)||"shopify-checkout-api-token"===v(t.attributes.name)))return!0}}return!1}(x,T)&&(D||x.type!==e.NodeType.Text||x.isStyle||x.textContent.replace(/^\s+|\s+$/gm,"").length)?n++:o;var A=Object.assign(x,{id:i});if(t.__sn=A,i===o)return null;c[i]=t,k&&k(t);var O=!p;if(A.type===e.NodeType.Element&&(O=O&&!A.needBlock,delete A.needBlock),(A.type===e.NodeType.Document||A.type===e.NodeType.Element)&&O){T.headWhitespace&&x.type===e.NodeType.Element&&"head"===x.tagName&&(D=!1);for(var L={doc:s,map:c,blockClass:u,blockSelector:l,skipChild:p,inlineStylesheet:m,maskInputOptions:b,slimDOMOptions:T,recordCanvas:C,preserveWhiteSpace:D,onSerialize:k,onIframeLoad:w,iframeLoadTimeout:S},I=0,M=Array.from(t.childNodes);I<M.length;I++){(W=y(M[I],L))&&A.childNodes.push(W)}if(r(t)&&t.shadowRoot){A.isShadowHost=!0;for(var R=0,G=Array.from(t.shadowRoot.childNodes);R<G.length;R++){var W;(W=y(G[R],L))&&(W.isShadow=!0,A.childNodes.push(W))}}}return A.type===e.NodeType.Element&&"iframe"===A.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,o=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a)"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t();else{var i=setTimeout(function(){o||(t(),o=!0)},r);e.addEventListener("load",function(){clearTimeout(i),o=!0,t()})}}}(t,function(){var e=t.contentDocument;if(e&&w){var r=y(e,{doc:e,map:c,blockClass:u,blockSelector:l,skipChild:!1,inlineStylesheet:m,maskInputOptions:b,slimDOMOptions:T,recordCanvas:C,preserveWhiteSpace:D,onSerialize:k,onIframeLoad:w,iframeLoadTimeout:S});r&&w(t,r)}},S),A}var g=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function b(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function o(){var e={line:r,column:n};return function(t){return t.position=new i(e),d(),t}}var i=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();i.prototype.content=e;var s=[];function c(a){var o=new Error(t.source+":"+r+":"+n+": "+a);if(o.reason=a,o.filename=t.source,o.line=r,o.column=n,o.source=e,!t.silent)throw o;s.push(o)}function u(){return p(/^{\s*/)}function l(){return p(/^}/)}function f(){var t,r=[];for(d(),m(r);e.length&&"}"!==e.charAt(0)&&(t=_()||D());)!1!==t&&(r.push(t),m(r));return r}function p(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function d(){p(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=o();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var i=e.slice(2,r-2);return n+=2,a(i),e=e.slice(r),n+=2,t({type:"comment",comment:i})}}function v(){var e=p(/^([^{]+)/);if(e)return T(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=o(),t=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=T(t[0]);if(!p(/^:\s*/))return c("property missing ':'");var n=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(g,""),value:n?T(n[0]).replace(g,""):""});return p(/^[;\s]*/),a}}function b(){var e,t=[];if(!u())return c("missing '{'");for(m(t);e=y();)!1!==e&&(t.push(e),m(t)),e=y();return l()?t:c("missing '}'")}function N(){for(var e,t=[],r=o();e=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),p(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:b()})}var C,k=S("import"),w=S("charset"),E=S("namespace");function S(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=o(),n=p(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function _(){if("@"===e[0])return function(){var e=o(),t=p(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=p(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var i=m();n=N();)i.push(n),i=i.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:i}):c("@keyframes missing '}'")}}()||function(){var e=o(),t=p(/^@media *([^{]+)/);if(t){var r=T(t[1]);if(!u())return c("@media missing '{'");var n=m().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=o(),t=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:T(t[1]),media:T(t[2])})}()||function(){var e=o(),t=p(/^@supports *([^{]+)/);if(t){var r=T(t[1]);if(!u())return c("@supports missing '{'");var n=m().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||k()||w()||E()||function(){var e=o(),t=p(/^@([-\w]+)?document *([^{]+)/);if(t){var r=T(t[1]),n=T(t[2]);if(!u())return c("@document missing '{'");var a=m().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=o();if(p(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=m();r=y();)n.push(r),n=n.concat(m());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=o();if(p(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=m().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=o();if(p(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=m();t=y();)r.push(t),r=r.concat(m());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function D(){var e=o(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:b()})):c("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var a=n?t:r;for(var o=0,i=Object.keys(t);o<i.length;o++){var s=i[o],c=t[s];Array.isArray(c)?c.forEach(function(t){e(t,a)}):c&&"object"==typeof c&&e(c,a)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}((C=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:C,parsingErrors:s}}))}function T(e){return e?e.replace(/^\s+|\s+$/g,""):""}var N={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var C=/([^\\]):hover/g;function k(e){var t=b(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(C.test(t)){var r=t.replace(C,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function w(t,r){var n=r.doc,a=r.hackCss;switch(t.type){case e.NodeType.Document:return n.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.NodeType.Element:var o,i=function(e){var t=N[e.tagName]?N[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);o=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",i):n.createElement(i);var s=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===i&&"rr_dataURL"===e){var s=document.createElement("img");s.src=r,s.onload=function(){var e=o.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===e&&(o.style.width=r),"rr_height"===e&&(o.style.height=r),"rr_mediaState"===e)switch(r){case"played":o.play();case"paused":o.pause()}}else{var c="textarea"===i&&"value"===e,u="style"===i&&"_cssText"===e;if(u&&a&&(r=k(r)),c||u){for(var l=n.createTextNode(r),f=0,p=Array.from(o.childNodes);f<p.length;f++){var d=p[f];d.nodeType===o.TEXT_NODE&&o.removeChild(d)}return o.appendChild(l),"continue"}if("iframe"===i&&"src"===e)return"continue";try{t.isSVG&&"xlink:href"===e?o.setAttributeNS("http://www.w3.org/1999/xlink",e,r):"onload"===e||"onclick"===e||"onmouse"===e.substring(0,7)?o.setAttribute("_"+e,r):o.setAttribute(e,r)}catch(e){}}};for(var c in t.attributes)s(c);if(t.isShadowHost)if(o.shadowRoot)for(;o.shadowRoot.firstChild;)o.shadowRoot.removeChild(o.shadowRoot.firstChild);else o.attachShadow({mode:"open"});return o;case e.NodeType.Text:return n.createTextNode(t.isStyle&&a?k(t.textContent):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function E(t,n){var a=n.doc,o=n.map,i=n.skipChild,s=void 0!==i&&i,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=w(t,{doc:a,hackCss:u});if(!f)return null;if(t.rootId&&console.assert(o[t.rootId]===a,"Target document should has the same root id."),t.type===e.NodeType.Document&&(a.close(),a.open(),f=a),f.__sn=t,o[t.id]=f,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var p=0,d=t.childNodes;p<d.length;p++){var m=d[p],h=E(m,{doc:a,map:o,skipChild:!1,hackCss:u,afterAppend:l});h?(m.isShadow&&r(f)&&f.shadowRoot?f.shadowRoot.appendChild(h):f.appendChild(h),l&&l(h)):console.warn("Failed to rebuild",m)}return f}return e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,o=r.inlineStylesheet,i=void 0===o||o,s=r.recordCanvas,c=void 0!==s&&s,u=r.blockSelector,l=void 0===u?null:u,f=r.maskAllInputs,p=void 0!==f&&f,d=r.slimDOM,m=void 0!==d&&d,h={};return[y(e,{doc:e,map:h,blockClass:a,blockSelector:l,skipChild:!1,inlineStylesheet:i,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===p?{}:p,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:c,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]},e.serializeNodeWithId=y,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,o=r.hackCss,i={},s=E(t,{doc:n,map:i,skipChild:!1,hackCss:void 0===o||o,afterAppend:r.afterAppend});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(i,function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.NodeType.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var o=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=o),"rr_scrollTop"===a&&(n.scrollTop=o)}}}(t)}),[s,i]},e.buildNodeWithSN=E,e.addHoverClass=k,e.transformAttribute=m,e.visitSnapshot=function(t,r){!function t(n){r(n),n.type!==e.NodeType.Document&&n.type!==e.NodeType.Element||n.childNodes.forEach(t)}(t)},e.cleanupSnapshot=function(){n=1},e.IGNORED_NODE=o,e}({}); | ||
var rrwebSnapshot=function(e){"use strict";var t;function r(e){return e.nodeType===e.ELEMENT_NODE}function n(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var a=1,o=RegExp("[^a-z0-9-_]"),i=-2;function s(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(c).join(""):null}catch(e){return null}}function c(e){return function(e){return"styleSheet"in e}(e)?s(e.styleSheet)||"":e.cssText}var u=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,l=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,f=/^(data:)([^,]*),(.*)/i;function d(e,t){return(e||"").replace(u,function(e,r,n,a,o,i){var s,c=n||o||i,u=r||a||"";if(!c)return e;if(!l.test(c))return"url("+u+c+u+")";if(f.test(c))return"url("+u+c+u+")";if("/"===c[0])return"url("+u+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+u+")";var d=t.split("/"),p=c.split("/");d.pop();for(var m=0,h=p;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?d.pop():d.push(v))}return"url("+u+d.join("/")+u+")"})}function p(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function m(){var e=document.createElement("a");return e.href="",e.href}function h(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?p(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?p(e,r[0])+" "+r[1]:1===r.length?""+p(e,r[0]):""}).join(", ")}(e,n):"style"===r&&n?d(n,m()):n:p(e,n)}function v(t,r){var n,a,i=r.doc,c=r.blockClass,u=r.blockSelector,l=r.inlineStylesheet,f=r.maskInputOptions,p=void 0===f?{}:f,v=r.recordCanvas;if(i.__sn){var y=i.__sn.id;n=1===y?void 0:y}switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[],rootId:n};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:n};case t.ELEMENT_NODE:for(var g=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var a=e.classList[n];if(t.test(a))return!0}return!!r&&e.matches(r)}(t,c,u),b=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return o.test(t)?"div":t}(t),T={},N=0,C=Array.from(t.attributes);N<C.length;N++){var k=C[N],w=k.name,E=k.value;T[w]=h(i,b,w,E)}if("link"===b&&l){var S,_=Array.from(i.styleSheets).find(function(e){return e.href===t.href});(S=s(_))&&(delete T.rel,delete T.href,T._cssText=d(S,_.href))}if("style"===b&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(S=s(t.sheet))&&(T._cssText=d(S,m()));if("input"===b||"textarea"===b||"select"===b){E=t.value;"radio"!==T.type&&"checkbox"!==T.type&&"submit"!==T.type&&"button"!==T.type&&E?T.value=p[T.type]||p[b]?"*".repeat(E.length):E:t.checked&&(T.checked=t.checked)}if("option"===b){var D=t.parentElement;T.value===D.value&&(T.selected=t.selected)}if("canvas"===b&&v&&(T.rr_dataURL=t.toDataURL()),"audio"!==b&&"video"!==b||(T.rr_mediaState=t.paused?"paused":"played"),t.scrollLeft&&(T.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(T.rr_scrollTop=t.scrollTop),g){var x=t.getBoundingClientRect(),A=x.width,O=x.height;T={class:T.class,rr_width:A+"px",rr_height:O+"px"}}return"iframe"===b&&delete T.src,{type:e.NodeType.Element,tagName:b,attributes:T,childNodes:[],isSVG:(a=t,"svg"===a.tagName||a instanceof SVGElement||void 0),needBlock:g,rootId:n};case t.TEXT_NODE:var L=t.parentNode&&t.parentNode.tagName,I=t.textContent,M="STYLE"===L||void 0;return M&&I&&(I=d(I,m())),"SCRIPT"===L&&(I="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:I||"",isStyle:M,rootId:n};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:n};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:n};default:return!1}}function y(e){return void 0===e?"":e.toLowerCase()}function g(t,o){var s,c=o.doc,u=o.map,l=o.blockClass,f=o.blockSelector,d=o.skipChild,p=void 0!==d&&d,m=o.inlineStylesheet,h=void 0===m||m,b=o.maskInputOptions,T=void 0===b?{}:b,N=o.slimDOMOptions,C=o.recordCanvas,k=void 0!==C&&C,w=o.onSerialize,E=o.onIframeLoad,S=o.iframeLoadTimeout,_=void 0===S?5e3:S,D=o.preserveWhiteSpace,x=void 0===D||D,A=v(t,{doc:c,blockClass:l,blockSelector:f,inlineStylesheet:h,maskInputOptions:T,recordCanvas:k});if(!A)return console.warn(t,"not serialized"),null;s="__sn"in t?t.__sn.id:!function(t,r){if(r.comment&&t.type===e.NodeType.Comment)return!0;if(t.type===e.NodeType.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(y(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===y(t.attributes.name)||"icon"===y(t.attributes.rel)||"apple-touch-icon"===y(t.attributes.rel)||"shortcut icon"===y(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&y(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(y(t.attributes.property).match(/^(og|twitter|fb):/)||y(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===y(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===y(t.attributes.name)||"googlebot"===y(t.attributes.name)||"bingbot"===y(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===y(t.attributes.name)||"generator"===y(t.attributes.name)||"framework"===y(t.attributes.name)||"publisher"===y(t.attributes.name)||"progid"===y(t.attributes.name)||y(t.attributes.property).match(/^article:/)||y(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===y(t.attributes.name)||"yandex-verification"===y(t.attributes.name)||"csrf-token"===y(t.attributes.name)||"p:domain_verify"===y(t.attributes.name)||"verify-v1"===y(t.attributes.name)||"verification"===y(t.attributes.name)||"shopify-checkout-api-token"===y(t.attributes.name)))return!0}}return!1}(A,N)&&(x||A.type!==e.NodeType.Text||A.isStyle||A.textContent.replace(/^\s+|\s+$/gm,"").length)?a++:i;var O=Object.assign(A,{id:s});if(t.__sn=O,s===i)return null;u[s]=t,w&&w(t);var L=!p;if(O.type===e.NodeType.Element&&(L=L&&!O.needBlock,delete O.needBlock),(O.type===e.NodeType.Document||O.type===e.NodeType.Element)&&L){N.headWhitespace&&A.type===e.NodeType.Element&&"head"===A.tagName&&(x=!1);for(var I={doc:c,map:u,blockClass:l,blockSelector:f,skipChild:p,inlineStylesheet:h,maskInputOptions:T,slimDOMOptions:N,recordCanvas:k,preserveWhiteSpace:x,onSerialize:w,onIframeLoad:E,iframeLoadTimeout:_},M=0,R=Array.from(t.childNodes);M<R.length;M++){(z=g(R[M],I))&&O.childNodes.push(z)}if(r(t)&&t.shadowRoot){O.isShadowHost=!0;for(var G=0,W=Array.from(t.shadowRoot.childNodes);G<W.length;G++){var z;(z=g(W[G],I))&&(z.isShadow=!0,O.childNodes.push(z))}}}return t.parentNode&&n(t.parentNode)&&(O.isShadow=!0),O.type===e.NodeType.Element&&"iframe"===O.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,o=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a)"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t();else{var i=setTimeout(function(){o||(t(),o=!0)},r);e.addEventListener("load",function(){clearTimeout(i),o=!0,t()})}}}(t,function(){var e=t.contentDocument;if(e&&E){var r=g(e,{doc:e,map:u,blockClass:l,blockSelector:f,skipChild:!1,inlineStylesheet:h,maskInputOptions:T,slimDOMOptions:N,recordCanvas:k,preserveWhiteSpace:x,onSerialize:w,onIframeLoad:E,iframeLoadTimeout:_});r&&E(t,r)}},_),O}var b=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function T(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function o(){var e={line:r,column:n};return function(t){return t.position=new i(e),p(),t}}var i=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();i.prototype.content=e;var s=[];function c(a){var o=new Error(t.source+":"+r+":"+n+": "+a);if(o.reason=a,o.filename=t.source,o.line=r,o.column=n,o.source=e,!t.silent)throw o;s.push(o)}function u(){return d(/^{\s*/)}function l(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=_()||D());)!1!==t&&(r.push(t),m(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function p(){d(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=o();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var i=e.slice(2,r-2);return n+=2,a(i),e=e.slice(r),n+=2,t({type:"comment",comment:i})}}function v(){var e=d(/^([^{]+)/);if(e)return N(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=o(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=N(t[0]);if(!d(/^:\s*/))return c("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(b,""),value:n?N(n[0]).replace(b,""):""});return d(/^[;\s]*/),a}}function g(){var e,t=[];if(!u())return c("missing '{'");for(m(t);e=y();)!1!==e&&(t.push(e),m(t)),e=y();return l()?t:c("missing '}'")}function T(){for(var e,t=[],r=o();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:g()})}var C,k=S("import"),w=S("charset"),E=S("namespace");function S(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=o(),n=d(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function _(){if("@"===e[0])return function(){var e=o(),t=d(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var i=m();n=T();)i.push(n),i=i.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:i}):c("@keyframes missing '}'")}}()||function(){var e=o(),t=d(/^@media *([^{]+)/);if(t){var r=N(t[1]);if(!u())return c("@media missing '{'");var n=m().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=o(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:N(t[1]),media:N(t[2])})}()||function(){var e=o(),t=d(/^@supports *([^{]+)/);if(t){var r=N(t[1]);if(!u())return c("@supports missing '{'");var n=m().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||k()||w()||E()||function(){var e=o(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=N(t[1]),n=N(t[2]);if(!u())return c("@document missing '{'");var a=m().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=o();if(d(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=m();r=y();)n.push(r),n=n.concat(m());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=o();if(d(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=m().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=o();if(d(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=m();t=y();)r.push(t),r=r.concat(m());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function D(){var e=o(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:g()})):c("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var a=n?t:r;for(var o=0,i=Object.keys(t);o<i.length;o++){var s=i[o],c=t[s];Array.isArray(c)?c.forEach(function(t){e(t,a)}):c&&"object"==typeof c&&e(c,a)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}((C=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:C,parsingErrors:s}}))}function N(e){return e?e.replace(/^\s+|\s+$/g,""):""}var C={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var k=/([^\\]):hover/g;function w(e){var t=T(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(k.test(t)){var r=t.replace(k,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function E(t,r){var n=r.doc,a=r.hackCss;switch(t.type){case e.NodeType.Document:return n.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.NodeType.Element:var o,i=function(e){var t=C[e.tagName]?C[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);o=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",i):n.createElement(i);var s=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===i&&"rr_dataURL"===e){var s=document.createElement("img");s.src=r,s.onload=function(){var e=o.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===e&&(o.style.width=r),"rr_height"===e&&(o.style.height=r),"rr_mediaState"===e)switch(r){case"played":o.play();case"paused":o.pause()}}else{var c="textarea"===i&&"value"===e,u="style"===i&&"_cssText"===e;if(u&&a&&(r=w(r)),c||u){for(var l=n.createTextNode(r),f=0,d=Array.from(o.childNodes);f<d.length;f++){var p=d[f];p.nodeType===o.TEXT_NODE&&o.removeChild(p)}return o.appendChild(l),"continue"}if("iframe"===i&&"src"===e)return"continue";try{t.isSVG&&"xlink:href"===e?o.setAttributeNS("http://www.w3.org/1999/xlink",e,r):"onload"===e||"onclick"===e||"onmouse"===e.substring(0,7)?o.setAttribute("_"+e,r):o.setAttribute(e,r)}catch(e){}}};for(var c in t.attributes)s(c);if(t.isShadowHost)if(o.shadowRoot)for(;o.shadowRoot.firstChild;)o.shadowRoot.removeChild(o.shadowRoot.firstChild);else o.attachShadow({mode:"open"});return o;case e.NodeType.Text:return n.createTextNode(t.isStyle&&a?w(t.textContent):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function S(t,n){var a=n.doc,o=n.map,i=n.skipChild,s=void 0!==i&&i,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=E(t,{doc:a,hackCss:u});if(!f)return null;if(t.rootId&&console.assert(o[t.rootId]===a,"Target document should has the same root id."),t.type===e.NodeType.Document&&(a.close(),a.open(),f=a),f.__sn=t,o[t.id]=f,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var d=0,p=t.childNodes;d<p.length;d++){var m=p[d],h=S(m,{doc:a,map:o,skipChild:!1,hackCss:u,afterAppend:l});h?(m.isShadow&&r(f)&&f.shadowRoot?f.shadowRoot.appendChild(h):f.appendChild(h),l&&l(h)):console.warn("Failed to rebuild",m)}return f}return e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,o=r.inlineStylesheet,i=void 0===o||o,s=r.recordCanvas,c=void 0!==s&&s,u=r.blockSelector,l=void 0===u?null:u,f=r.maskAllInputs,d=void 0!==f&&f,p=r.slimDOM,m=void 0!==p&&p,h={};return[g(e,{doc:e,map:h,blockClass:a,blockSelector:l,skipChild:!1,inlineStylesheet:i,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===d?{}:d,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:c,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]},e.serializeNodeWithId=g,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,o=r.hackCss,i={},s=S(t,{doc:n,map:i,skipChild:!1,hackCss:void 0===o||o,afterAppend:r.afterAppend});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(i,function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.NodeType.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var o=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=o),"rr_scrollTop"===a&&(n.scrollTop=o)}}}(t)}),[s,i]},e.buildNodeWithSN=S,e.addHoverClass=w,e.transformAttribute=h,e.visitSnapshot=function(t,r){!function t(n){r(n),n.type!==e.NodeType.Document&&n.type!==e.NodeType.Element||n.childNodes.forEach(t)}(t)},e.cleanupSnapshot=function(){a=1},e.IGNORED_NODE=i,e.isElement=r,e.isShadowRoot=n,e}({}); | ||
//# sourceMappingURL=rrweb-snapshot.min.js.map |
@@ -14,2 +14,7 @@ var NodeType; | ||
} | ||
function isShadowRoot(n) { | ||
var _a; | ||
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host; | ||
return Boolean(host && host.shadowRoot && host.shadowRoot === n); | ||
} | ||
@@ -511,2 +516,5 @@ var _id = 1; | ||
} | ||
if (n.parentNode && isShadowRoot(n.parentNode)) { | ||
serializedNode.isShadow = true; | ||
} | ||
if (serializedNode.type === NodeType.Element && | ||
@@ -1322,2 +1330,2 @@ serializedNode.tagName === 'iframe') { | ||
export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, transformAttribute, visitSnapshot, cleanupSnapshot, IGNORED_NODE, NodeType }; | ||
export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, transformAttribute, visitSnapshot, cleanupSnapshot, IGNORED_NODE, NodeType, isElement, isShadowRoot }; |
@@ -1,2 +0,2 @@ | ||
var NodeType;function isElement(e){return e.nodeType===e.ELEMENT_NODE}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(NodeType||(NodeType={}));var _id=1,tagNameRegex=RegExp("[^a-z0-9-_]"),IGNORED_NODE=-2;function genId(){return _id++}function getValidTagName(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return tagNameRegex.test(t)?"div":t}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(getCssRuleString).join(""):null}catch(e){return null}}function getCssRuleString(e){return isCSSImportRule(e)?getCssRulesString(e.styleSheet)||"":e.cssText}function isCSSImportRule(e){return"styleSheet"in e}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,DATA_URI=/^(data:)([^,]*),(.*)/i;function absoluteToStylesheet(e,t){return(e||"").replace(URL_IN_CSS_REF,function(e,r,n,i,a,o){var s=n||a||o,l=r||i||"";if(!s)return e;if(!RELATIVE_PATH.test(s))return"url("+l+s+l+")";if(DATA_URI.test(s))return"url("+l+s+l+")";if("/"===s[0])return"url("+l+(extractOrigin(t)+s)+l+")";var c=t.split("/"),u=s.split("/");c.pop();for(var f=0,d=u;f<d.length;f++){var p=d[f];"."!==p&&(".."===p?c.pop():c.push(p))}return"url("+l+c.join("/")+l+")"})}function getAbsoluteSrcsetString(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?absoluteToDoc(e,r[0])+" "+r[1]:1===r.length?""+absoluteToDoc(e,r[0]):""}).join(", ")}function absoluteToDoc(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}function getHref(){var e=document.createElement("a");return e.href="",e.href}function transformAttribute(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?absoluteToDoc(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?getAbsoluteSrcsetString(e,n):"style"===r&&n?absoluteToStylesheet(n,getHref()):n:absoluteToDoc(e,n)}function _isBlockedElement(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var i=e.classList[n];if(t.test(i))return!0}return!!r&&e.matches(r)}function onceIframeLoaded(e,t,r){var n=e.contentWindow;if(n){var i,a=!1;try{i=n.document.readyState}catch(e){return}if("complete"===i){"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t()}else{var o=setTimeout(function(){a||(t(),a=!0)},r);e.addEventListener("load",function(){clearTimeout(o),a=!0,t()})}}}function serializeNode(e,t){var r,n=t.doc,i=t.blockClass,a=t.blockSelector,o=t.inlineStylesheet,s=t.maskInputOptions,l=void 0===s?{}:s,c=t.recordCanvas;if(n.__sn){var u=n.__sn.id;r=1===u?void 0:u}switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[],rootId:r};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:r};case e.ELEMENT_NODE:for(var f=_isBlockedElement(e,i,a),d=getValidTagName(e),p={},m=0,h=Array.from(e.attributes);m<h.length;m++){var v=h[m],g=v.name,y=v.value;p[g]=transformAttribute(n,d,g,y)}if("link"===d&&o){var b,E=Array.from(n.styleSheets).find(function(t){return t.href===e.href});(b=getCssRulesString(E))&&(delete p.rel,delete p.href,p._cssText=absoluteToStylesheet(b,E.href))}if("style"===d&&e.sheet&&!(e.innerText||e.textContent||"").trim().length)(b=getCssRulesString(e.sheet))&&(p._cssText=absoluteToStylesheet(b,getHref()));if("input"===d||"textarea"===d||"select"===d){y=e.value;"radio"!==p.type&&"checkbox"!==p.type&&"submit"!==p.type&&"button"!==p.type&&y?p.value=l[p.type]||l[d]?"*".repeat(y.length):y:e.checked&&(p.checked=e.checked)}if("option"===d){var T=e.parentElement;p.value===T.value&&(p.selected=e.selected)}if("canvas"===d&&c&&(p.rr_dataURL=e.toDataURL()),"audio"!==d&&"video"!==d||(p.rr_mediaState=e.paused?"paused":"played"),e.scrollLeft&&(p.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(p.rr_scrollTop=e.scrollTop),f){var N=e.getBoundingClientRect(),S=N.width,C=N.height;p={class:p.class,rr_width:S+"px",rr_height:C+"px"}}return"iframe"===d&&delete p.src,{type:NodeType.Element,tagName:d,attributes:p,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:f,rootId:r};case e.TEXT_NODE:var w=e.parentNode&&e.parentNode.tagName,I=e.textContent,x="STYLE"===w||void 0;return x&&I&&(I=absoluteToStylesheet(I,getHref())),"SCRIPT"===w&&(I="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:I||"",isStyle:x,rootId:r};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:"",rootId:r};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||"",rootId:r};default:return!1}}function lowerIfExists(e){return void 0===e?"":e.toLowerCase()}function slimDOMExcluded(e,t){if(t.comment&&e.type===NodeType.Comment)return!0;if(e.type===NodeType.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(lowerIfExists(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===lowerIfExists(e.attributes.name)||"icon"===lowerIfExists(e.attributes.rel)||"apple-touch-icon"===lowerIfExists(e.attributes.rel)||"shortcut icon"===lowerIfExists(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&lowerIfExists(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(lowerIfExists(e.attributes.property).match(/^(og|twitter|fb):/)||lowerIfExists(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===lowerIfExists(e.attributes.name)||"googlebot"===lowerIfExists(e.attributes.name)||"bingbot"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===lowerIfExists(e.attributes.name)||"generator"===lowerIfExists(e.attributes.name)||"framework"===lowerIfExists(e.attributes.name)||"publisher"===lowerIfExists(e.attributes.name)||"progid"===lowerIfExists(e.attributes.name)||lowerIfExists(e.attributes.property).match(/^article:/)||lowerIfExists(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===lowerIfExists(e.attributes.name)||"yandex-verification"===lowerIfExists(e.attributes.name)||"csrf-token"===lowerIfExists(e.attributes.name)||"p:domain_verify"===lowerIfExists(e.attributes.name)||"verify-v1"===lowerIfExists(e.attributes.name)||"verification"===lowerIfExists(e.attributes.name)||"shopify-checkout-api-token"===lowerIfExists(e.attributes.name)))return!0}}return!1}function serializeNodeWithId(e,t){var r,n=t.doc,i=t.map,a=t.blockClass,o=t.blockSelector,s=t.skipChild,l=void 0!==s&&s,c=t.inlineStylesheet,u=void 0===c||c,f=t.maskInputOptions,d=void 0===f?{}:f,p=t.slimDOMOptions,m=t.recordCanvas,h=void 0!==m&&m,v=t.onSerialize,g=t.onIframeLoad,y=t.iframeLoadTimeout,b=void 0===y?5e3:y,E=t.preserveWhiteSpace,T=void 0===E||E,N=serializeNode(e,{doc:n,blockClass:a,blockSelector:o,inlineStylesheet:u,maskInputOptions:d,recordCanvas:h});if(!N)return console.warn(e,"not serialized"),null;r="__sn"in e?e.__sn.id:slimDOMExcluded(N,p)||!T&&N.type===NodeType.Text&&!N.isStyle&&!N.textContent.replace(/^\s+|\s+$/gm,"").length?IGNORED_NODE:genId();var S=Object.assign(N,{id:r});if(e.__sn=S,r===IGNORED_NODE)return null;i[r]=e,v&&v(e);var C=!l;if(S.type===NodeType.Element&&(C=C&&!S.needBlock,delete S.needBlock),(S.type===NodeType.Document||S.type===NodeType.Element)&&C){p.headWhitespace&&N.type===NodeType.Element&&"head"===N.tagName&&(T=!1);for(var w={doc:n,map:i,blockClass:a,blockSelector:o,skipChild:l,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b},I=0,x=Array.from(e.childNodes);I<x.length;I++){(D=serializeNodeWithId(x[I],w))&&S.childNodes.push(D)}if(isElement(e)&&e.shadowRoot){S.isShadowHost=!0;for(var k=0,_=Array.from(e.shadowRoot.childNodes);k<_.length;k++){var D;(D=serializeNodeWithId(_[k],w))&&(D.isShadow=!0,S.childNodes.push(D))}}}return S.type===NodeType.Element&&"iframe"===S.tagName&&onceIframeLoaded(e,function(){var t=e.contentDocument;if(t&&g){var r=serializeNodeWithId(t,{doc:t,map:i,blockClass:a,blockSelector:o,skipChild:!1,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b});r&&g(e,r)}},b),S}function snapshot(e,t){var r=t||{},n=r.blockClass,i=void 0===n?"rr-block":n,a=r.inlineStylesheet,o=void 0===a||a,s=r.recordCanvas,l=void 0!==s&&s,c=r.blockSelector,u=void 0===c?null:c,f=r.maskAllInputs,d=void 0!==f&&f,p=r.slimDOM,m=void 0!==p&&p,h={};return[serializeNodeWithId(e,{doc:e,map:h,blockClass:i,blockSelector:u,skipChild:!1,inlineStylesheet:o,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===d?{}:d,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:l,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]}function visitSnapshot(e,t){!function e(r){t(r),r.type!==NodeType.Document&&r.type!==NodeType.Element||r.childNodes.forEach(e)}(e)}function cleanupSnapshot(){_id=1}var commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function parse(e,t){void 0===t&&(t={});var r=1,n=1;function i(e){var t=e.match(/\n/g);t&&(r+=t.length);var i=e.lastIndexOf("\n");n=-1===i?n+e.length:e.length-i}function a(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function l(i){var a=new Error(t.source+":"+r+":"+n+": "+i);if(a.reason=i,a.filename=t.source,a.line=r,a.column=n,a.source=e,!t.silent)throw a;s.push(a)}function c(){return d(/^{\s*/)}function u(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=w()||I());)!1!==t&&(r.push(t),m(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return i(n),e=e.slice(n.length),r}}function p(){d(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=a();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var o=e.slice(2,r-2);return n+=2,i(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=d(/^([^{]+)/);if(e)return trim(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=a(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=trim(t[0]);if(!d(/^:\s*/))return l("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:r.replace(commentre,""),value:n?trim(n[0]).replace(commentre,""):""});return d(/^[;\s]*/),i}}function y(){var e,t=[];if(!c())return l("missing '{'");for(m(t);e=g();)!1!==e&&(t.push(e),m(t)),e=g();return u()?t:l("missing '}'")}function b(){for(var e,t=[],r=a();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var E,T=C("import"),N=C("charset"),S=C("namespace");function C(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=a(),n=d(t);if(n){var i={type:e};return i[e]=n[1].trim(),r(i)}}}function w(){if("@"===e[0])return function(){var e=a(),t=d(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return l("@keyframes missing name");var n,i=t[1];if(!c())return l("@keyframes missing '{'");for(var o=m();n=b();)o.push(n),o=o.concat(m());return u()?e({type:"keyframes",name:i,vendor:r,keyframes:o}):l("@keyframes missing '}'")}}()||function(){var e=a(),t=d(/^@media *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@media missing '{'");var n=m().concat(f());return u()?e({type:"media",media:r,rules:n}):l("@media missing '}'")}}()||function(){var e=a(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:trim(t[1]),media:trim(t[2])})}()||function(){var e=a(),t=d(/^@supports *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@supports missing '{'");var n=m().concat(f());return u()?e({type:"supports",supports:r,rules:n}):l("@supports missing '}'")}}()||T()||N()||S()||function(){var e=a(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=trim(t[1]),n=trim(t[2]);if(!c())return l("@document missing '{'");var i=m().concat(f());return u()?e({type:"document",document:n,vendor:r,rules:i}):l("@document missing '}'")}}()||function(){var e=a();if(d(/^@page */)){var t=v()||[];if(!c())return l("@page missing '{'");for(var r,n=m();r=g();)n.push(r),n=n.concat(m());return u()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}()||function(){var e=a();if(d(/^@host\s*/)){if(!c())return l("@host missing '{'");var t=m().concat(f());return u()?e({type:"host",rules:t}):l("@host missing '}'")}}()||function(){var e=a();if(d(/^@font-face\s*/)){if(!c())return l("@font-face missing '{'");for(var t,r=m();t=g();)r.push(t),r=r.concat(m());return u()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}()}function I(){var e=a(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:y()})):l("selector missing")}return addParent((E=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:s}}))}function trim(e){return e?e.replace(/^\s+|\s+$/g,""):""}function addParent(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,i=0,a=Object.keys(e);i<a.length;i++){var o=e[a[i]];Array.isArray(o)?o.forEach(function(e){addParent(e,n)}):o&&"object"==typeof o&&addParent(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var tagMap={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}var HOVER_SELECTOR=/([^\\]):hover/g;function addHoverClass(e){var t=parse(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(HOVER_SELECTOR.test(t)){var r=t.replace(HOVER_SELECTOR,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function buildNode(e,t){var r=t.doc,n=t.hackCss;switch(e.type){case NodeType.Document:return r.implementation.createDocument(null,"",null);case NodeType.DocumentType:return r.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case NodeType.Element:var i,a=getTagName(e);i=e.isSVG?r.createElementNS("http://www.w3.org/2000/svg",a):r.createElement(a);var o=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";var o=e.attributes[t];if(o="boolean"==typeof o||"number"==typeof o?"":o,t.startsWith("rr_")){if("canvas"===a&&"rr_dataURL"===t){var s=document.createElement("img");s.src=o,s.onload=function(){var e=i.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===t&&(i.style.width=o),"rr_height"===t&&(i.style.height=o),"rr_mediaState"===t)switch(o){case"played":i.play();case"paused":i.pause()}}else{var l="textarea"===a&&"value"===t,c="style"===a&&"_cssText"===t;if(c&&n&&(o=addHoverClass(o)),l||c){for(var u=r.createTextNode(o),f=0,d=Array.from(i.childNodes);f<d.length;f++){var p=d[f];p.nodeType===i.TEXT_NODE&&i.removeChild(p)}return i.appendChild(u),"continue"}if("iframe"===a&&"src"===t)return"continue";try{e.isSVG&&"xlink:href"===t?i.setAttributeNS("http://www.w3.org/1999/xlink",t,o):"onload"===t||"onclick"===t||"onmouse"===t.substring(0,7)?i.setAttribute("_"+t,o):i.setAttribute(t,o)}catch(e){}}};for(var s in e.attributes)o(s);if(e.isShadowHost)if(i.shadowRoot)for(;i.shadowRoot.firstChild;)i.shadowRoot.removeChild(i.shadowRoot.firstChild);else i.attachShadow({mode:"open"});return i;case NodeType.Text:return r.createTextNode(e.isStyle&&n?addHoverClass(e.textContent):e.textContent);case NodeType.CDATA:return r.createCDATASection(e.textContent);case NodeType.Comment:return r.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t){var r=t.doc,n=t.map,i=t.skipChild,a=void 0!==i&&i,o=t.hackCss,s=void 0===o||o,l=t.afterAppend,c=buildNode(e,{doc:r,hackCss:s});if(!c)return null;if(e.rootId&&console.assert(n[e.rootId]===r,"Target document should has the same root id."),e.type===NodeType.Document&&(r.close(),r.open(),c=r),c.__sn=e,n[e.id]=c,(e.type===NodeType.Document||e.type===NodeType.Element)&&!a)for(var u=0,f=e.childNodes;u<f.length;u++){var d=f[u],p=buildNodeWithSN(d,{doc:r,map:n,skipChild:!1,hackCss:s,afterAppend:l});p?(d.isShadow&&isElement(c)&&c.shadowRoot?c.shadowRoot.appendChild(p):c.appendChild(p),l&&l(p)):console.warn("Failed to rebuild",d)}return c}function visit(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}function handleScroll(e){var t=e.__sn;if(t.type===NodeType.Element){var r=e;for(var n in t.attributes)if(t.attributes.hasOwnProperty(n)&&n.startsWith("rr_")){var i=t.attributes[n];"rr_scrollLeft"===n&&(r.scrollLeft=i),"rr_scrollTop"===n&&(r.scrollTop=i)}}}function rebuild(e,t){var r=t.doc,n=t.onVisit,i=t.hackCss,a={},o=buildNodeWithSN(e,{doc:r,map:a,skipChild:!1,hackCss:void 0===i||i,afterAppend:t.afterAppend});return visit(a,function(e){n&&n(e),handleScroll(e)}),[o,a]}export{snapshot,serializeNodeWithId,rebuild,buildNodeWithSN,addHoverClass,transformAttribute,visitSnapshot,cleanupSnapshot,IGNORED_NODE,NodeType}; | ||
var NodeType;function isElement(e){return e.nodeType===e.ELEMENT_NODE}function isShadowRoot(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(NodeType||(NodeType={}));var _id=1,tagNameRegex=RegExp("[^a-z0-9-_]"),IGNORED_NODE=-2;function genId(){return _id++}function getValidTagName(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return tagNameRegex.test(t)?"div":t}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(getCssRuleString).join(""):null}catch(e){return null}}function getCssRuleString(e){return isCSSImportRule(e)?getCssRulesString(e.styleSheet)||"":e.cssText}function isCSSImportRule(e){return"styleSheet"in e}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,DATA_URI=/^(data:)([^,]*),(.*)/i;function absoluteToStylesheet(e,t){return(e||"").replace(URL_IN_CSS_REF,function(e,r,n,o,i,a){var s=n||i||a,l=r||o||"";if(!s)return e;if(!RELATIVE_PATH.test(s))return"url("+l+s+l+")";if(DATA_URI.test(s))return"url("+l+s+l+")";if("/"===s[0])return"url("+l+(extractOrigin(t)+s)+l+")";var c=t.split("/"),u=s.split("/");c.pop();for(var f=0,d=u;f<d.length;f++){var p=d[f];"."!==p&&(".."===p?c.pop():c.push(p))}return"url("+l+c.join("/")+l+")"})}function getAbsoluteSrcsetString(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?absoluteToDoc(e,r[0])+" "+r[1]:1===r.length?""+absoluteToDoc(e,r[0]):""}).join(", ")}function absoluteToDoc(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}function getHref(){var e=document.createElement("a");return e.href="",e.href}function transformAttribute(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?absoluteToDoc(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?getAbsoluteSrcsetString(e,n):"style"===r&&n?absoluteToStylesheet(n,getHref()):n:absoluteToDoc(e,n)}function _isBlockedElement(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var o=e.classList[n];if(t.test(o))return!0}return!!r&&e.matches(r)}function onceIframeLoaded(e,t,r){var n=e.contentWindow;if(n){var o,i=!1;try{o=n.document.readyState}catch(e){return}if("complete"===o){"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t()}else{var a=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(a),i=!0,t()})}}}function serializeNode(e,t){var r,n=t.doc,o=t.blockClass,i=t.blockSelector,a=t.inlineStylesheet,s=t.maskInputOptions,l=void 0===s?{}:s,c=t.recordCanvas;if(n.__sn){var u=n.__sn.id;r=1===u?void 0:u}switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[],rootId:r};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:r};case e.ELEMENT_NODE:for(var f=_isBlockedElement(e,o,i),d=getValidTagName(e),p={},m=0,h=Array.from(e.attributes);m<h.length;m++){var v=h[m],g=v.name,y=v.value;p[g]=transformAttribute(n,d,g,y)}if("link"===d&&a){var b,E=Array.from(n.styleSheets).find(function(t){return t.href===e.href});(b=getCssRulesString(E))&&(delete p.rel,delete p.href,p._cssText=absoluteToStylesheet(b,E.href))}if("style"===d&&e.sheet&&!(e.innerText||e.textContent||"").trim().length)(b=getCssRulesString(e.sheet))&&(p._cssText=absoluteToStylesheet(b,getHref()));if("input"===d||"textarea"===d||"select"===d){y=e.value;"radio"!==p.type&&"checkbox"!==p.type&&"submit"!==p.type&&"button"!==p.type&&y?p.value=l[p.type]||l[d]?"*".repeat(y.length):y:e.checked&&(p.checked=e.checked)}if("option"===d){var T=e.parentElement;p.value===T.value&&(p.selected=e.selected)}if("canvas"===d&&c&&(p.rr_dataURL=e.toDataURL()),"audio"!==d&&"video"!==d||(p.rr_mediaState=e.paused?"paused":"played"),e.scrollLeft&&(p.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(p.rr_scrollTop=e.scrollTop),f){var N=e.getBoundingClientRect(),S=N.width,w=N.height;p={class:p.class,rr_width:S+"px",rr_height:w+"px"}}return"iframe"===d&&delete p.src,{type:NodeType.Element,tagName:d,attributes:p,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:f,rootId:r};case e.TEXT_NODE:var C=e.parentNode&&e.parentNode.tagName,I=e.textContent,x="STYLE"===C||void 0;return x&&I&&(I=absoluteToStylesheet(I,getHref())),"SCRIPT"===C&&(I="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:I||"",isStyle:x,rootId:r};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:"",rootId:r};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||"",rootId:r};default:return!1}}function lowerIfExists(e){return void 0===e?"":e.toLowerCase()}function slimDOMExcluded(e,t){if(t.comment&&e.type===NodeType.Comment)return!0;if(e.type===NodeType.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(lowerIfExists(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===lowerIfExists(e.attributes.name)||"icon"===lowerIfExists(e.attributes.rel)||"apple-touch-icon"===lowerIfExists(e.attributes.rel)||"shortcut icon"===lowerIfExists(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&lowerIfExists(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(lowerIfExists(e.attributes.property).match(/^(og|twitter|fb):/)||lowerIfExists(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===lowerIfExists(e.attributes.name)||"googlebot"===lowerIfExists(e.attributes.name)||"bingbot"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===lowerIfExists(e.attributes.name)||"generator"===lowerIfExists(e.attributes.name)||"framework"===lowerIfExists(e.attributes.name)||"publisher"===lowerIfExists(e.attributes.name)||"progid"===lowerIfExists(e.attributes.name)||lowerIfExists(e.attributes.property).match(/^article:/)||lowerIfExists(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===lowerIfExists(e.attributes.name)||"yandex-verification"===lowerIfExists(e.attributes.name)||"csrf-token"===lowerIfExists(e.attributes.name)||"p:domain_verify"===lowerIfExists(e.attributes.name)||"verify-v1"===lowerIfExists(e.attributes.name)||"verification"===lowerIfExists(e.attributes.name)||"shopify-checkout-api-token"===lowerIfExists(e.attributes.name)))return!0}}return!1}function serializeNodeWithId(e,t){var r,n=t.doc,o=t.map,i=t.blockClass,a=t.blockSelector,s=t.skipChild,l=void 0!==s&&s,c=t.inlineStylesheet,u=void 0===c||c,f=t.maskInputOptions,d=void 0===f?{}:f,p=t.slimDOMOptions,m=t.recordCanvas,h=void 0!==m&&m,v=t.onSerialize,g=t.onIframeLoad,y=t.iframeLoadTimeout,b=void 0===y?5e3:y,E=t.preserveWhiteSpace,T=void 0===E||E,N=serializeNode(e,{doc:n,blockClass:i,blockSelector:a,inlineStylesheet:u,maskInputOptions:d,recordCanvas:h});if(!N)return console.warn(e,"not serialized"),null;r="__sn"in e?e.__sn.id:slimDOMExcluded(N,p)||!T&&N.type===NodeType.Text&&!N.isStyle&&!N.textContent.replace(/^\s+|\s+$/gm,"").length?IGNORED_NODE:genId();var S=Object.assign(N,{id:r});if(e.__sn=S,r===IGNORED_NODE)return null;o[r]=e,v&&v(e);var w=!l;if(S.type===NodeType.Element&&(w=w&&!S.needBlock,delete S.needBlock),(S.type===NodeType.Document||S.type===NodeType.Element)&&w){p.headWhitespace&&N.type===NodeType.Element&&"head"===N.tagName&&(T=!1);for(var C={doc:n,map:o,blockClass:i,blockSelector:a,skipChild:l,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b},I=0,x=Array.from(e.childNodes);I<x.length;I++){(D=serializeNodeWithId(x[I],C))&&S.childNodes.push(D)}if(isElement(e)&&e.shadowRoot){S.isShadowHost=!0;for(var k=0,_=Array.from(e.shadowRoot.childNodes);k<_.length;k++){var D;(D=serializeNodeWithId(_[k],C))&&(D.isShadow=!0,S.childNodes.push(D))}}}return e.parentNode&&isShadowRoot(e.parentNode)&&(S.isShadow=!0),S.type===NodeType.Element&&"iframe"===S.tagName&&onceIframeLoaded(e,function(){var t=e.contentDocument;if(t&&g){var r=serializeNodeWithId(t,{doc:t,map:o,blockClass:i,blockSelector:a,skipChild:!1,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b});r&&g(e,r)}},b),S}function snapshot(e,t){var r=t||{},n=r.blockClass,o=void 0===n?"rr-block":n,i=r.inlineStylesheet,a=void 0===i||i,s=r.recordCanvas,l=void 0!==s&&s,c=r.blockSelector,u=void 0===c?null:c,f=r.maskAllInputs,d=void 0!==f&&f,p=r.slimDOM,m=void 0!==p&&p,h={};return[serializeNodeWithId(e,{doc:e,map:h,blockClass:o,blockSelector:u,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===d?{}:d,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:l,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]}function visitSnapshot(e,t){!function e(r){t(r),r.type!==NodeType.Document&&r.type!==NodeType.Element||r.childNodes.forEach(e)}(e)}function cleanupSnapshot(){_id=1}var commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function parse(e,t){void 0===t&&(t={});var r=1,n=1;function o(e){var t=e.match(/\n/g);t&&(r+=t.length);var o=e.lastIndexOf("\n");n=-1===o?n+e.length:e.length-o}function i(){var e={line:r,column:n};return function(t){return t.position=new a(e),p(),t}}var a=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();a.prototype.content=e;var s=[];function l(o){var i=new Error(t.source+":"+r+":"+n+": "+o);if(i.reason=o,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function c(){return d(/^{\s*/)}function u(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=C()||I());)!1!==t&&(r.push(t),m(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return o(n),e=e.slice(n.length),r}}function p(){d(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var a=e.slice(2,r-2);return n+=2,o(a),e=e.slice(r),n+=2,t({type:"comment",comment:a})}}function v(){var e=d(/^([^{]+)/);if(e)return trim(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=i(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=trim(t[0]);if(!d(/^:\s*/))return l("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),o=e({type:"declaration",property:r.replace(commentre,""),value:n?trim(n[0]).replace(commentre,""):""});return d(/^[;\s]*/),o}}function y(){var e,t=[];if(!c())return l("missing '{'");for(m(t);e=g();)!1!==e&&(t.push(e),m(t)),e=g();return u()?t:l("missing '}'")}function b(){for(var e,t=[],r=i();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var E,T=w("import"),N=w("charset"),S=w("namespace");function w(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=d(t);if(n){var o={type:e};return o[e]=n[1].trim(),r(o)}}}function C(){if("@"===e[0])return function(){var e=i(),t=d(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return l("@keyframes missing name");var n,o=t[1];if(!c())return l("@keyframes missing '{'");for(var a=m();n=b();)a.push(n),a=a.concat(m());return u()?e({type:"keyframes",name:o,vendor:r,keyframes:a}):l("@keyframes missing '}'")}}()||function(){var e=i(),t=d(/^@media *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@media missing '{'");var n=m().concat(f());return u()?e({type:"media",media:r,rules:n}):l("@media missing '}'")}}()||function(){var e=i(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:trim(t[1]),media:trim(t[2])})}()||function(){var e=i(),t=d(/^@supports *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@supports missing '{'");var n=m().concat(f());return u()?e({type:"supports",supports:r,rules:n}):l("@supports missing '}'")}}()||T()||N()||S()||function(){var e=i(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=trim(t[1]),n=trim(t[2]);if(!c())return l("@document missing '{'");var o=m().concat(f());return u()?e({type:"document",document:n,vendor:r,rules:o}):l("@document missing '}'")}}()||function(){var e=i();if(d(/^@page */)){var t=v()||[];if(!c())return l("@page missing '{'");for(var r,n=m();r=g();)n.push(r),n=n.concat(m());return u()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}()||function(){var e=i();if(d(/^@host\s*/)){if(!c())return l("@host missing '{'");var t=m().concat(f());return u()?e({type:"host",rules:t}):l("@host missing '}'")}}()||function(){var e=i();if(d(/^@font-face\s*/)){if(!c())return l("@font-face missing '{'");for(var t,r=m();t=g();)r.push(t),r=r.concat(m());return u()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}()}function I(){var e=i(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:y()})):l("selector missing")}return addParent((E=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:s}}))}function trim(e){return e?e.replace(/^\s+|\s+$/g,""):""}function addParent(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,o=0,i=Object.keys(e);o<i.length;o++){var a=e[i[o]];Array.isArray(a)?a.forEach(function(e){addParent(e,n)}):a&&"object"==typeof a&&addParent(a,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var tagMap={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}var HOVER_SELECTOR=/([^\\]):hover/g;function addHoverClass(e){var t=parse(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(HOVER_SELECTOR.test(t)){var r=t.replace(HOVER_SELECTOR,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function buildNode(e,t){var r=t.doc,n=t.hackCss;switch(e.type){case NodeType.Document:return r.implementation.createDocument(null,"",null);case NodeType.DocumentType:return r.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case NodeType.Element:var o,i=getTagName(e);o=e.isSVG?r.createElementNS("http://www.w3.org/2000/svg",i):r.createElement(i);var a=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";var a=e.attributes[t];if(a="boolean"==typeof a||"number"==typeof a?"":a,t.startsWith("rr_")){if("canvas"===i&&"rr_dataURL"===t){var s=document.createElement("img");s.src=a,s.onload=function(){var e=o.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===t&&(o.style.width=a),"rr_height"===t&&(o.style.height=a),"rr_mediaState"===t)switch(a){case"played":o.play();case"paused":o.pause()}}else{var l="textarea"===i&&"value"===t,c="style"===i&&"_cssText"===t;if(c&&n&&(a=addHoverClass(a)),l||c){for(var u=r.createTextNode(a),f=0,d=Array.from(o.childNodes);f<d.length;f++){var p=d[f];p.nodeType===o.TEXT_NODE&&o.removeChild(p)}return o.appendChild(u),"continue"}if("iframe"===i&&"src"===t)return"continue";try{e.isSVG&&"xlink:href"===t?o.setAttributeNS("http://www.w3.org/1999/xlink",t,a):"onload"===t||"onclick"===t||"onmouse"===t.substring(0,7)?o.setAttribute("_"+t,a):o.setAttribute(t,a)}catch(e){}}};for(var s in e.attributes)a(s);if(e.isShadowHost)if(o.shadowRoot)for(;o.shadowRoot.firstChild;)o.shadowRoot.removeChild(o.shadowRoot.firstChild);else o.attachShadow({mode:"open"});return o;case NodeType.Text:return r.createTextNode(e.isStyle&&n?addHoverClass(e.textContent):e.textContent);case NodeType.CDATA:return r.createCDATASection(e.textContent);case NodeType.Comment:return r.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t){var r=t.doc,n=t.map,o=t.skipChild,i=void 0!==o&&o,a=t.hackCss,s=void 0===a||a,l=t.afterAppend,c=buildNode(e,{doc:r,hackCss:s});if(!c)return null;if(e.rootId&&console.assert(n[e.rootId]===r,"Target document should has the same root id."),e.type===NodeType.Document&&(r.close(),r.open(),c=r),c.__sn=e,n[e.id]=c,(e.type===NodeType.Document||e.type===NodeType.Element)&&!i)for(var u=0,f=e.childNodes;u<f.length;u++){var d=f[u],p=buildNodeWithSN(d,{doc:r,map:n,skipChild:!1,hackCss:s,afterAppend:l});p?(d.isShadow&&isElement(c)&&c.shadowRoot?c.shadowRoot.appendChild(p):c.appendChild(p),l&&l(p)):console.warn("Failed to rebuild",d)}return c}function visit(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}function handleScroll(e){var t=e.__sn;if(t.type===NodeType.Element){var r=e;for(var n in t.attributes)if(t.attributes.hasOwnProperty(n)&&n.startsWith("rr_")){var o=t.attributes[n];"rr_scrollLeft"===n&&(r.scrollLeft=o),"rr_scrollTop"===n&&(r.scrollTop=o)}}}function rebuild(e,t){var r=t.doc,n=t.onVisit,o=t.hackCss,i={},a=buildNodeWithSN(e,{doc:r,map:i,skipChild:!1,hackCss:void 0===o||o,afterAppend:t.afterAppend});return visit(i,function(e){n&&n(e),handleScroll(e)}),[a,i]}export{snapshot,serializeNodeWithId,rebuild,buildNodeWithSN,addHoverClass,transformAttribute,visitSnapshot,cleanupSnapshot,IGNORED_NODE,NodeType,isElement,isShadowRoot}; | ||
//# sourceMappingURL=rrweb-snapshot.min.js.map |
@@ -17,2 +17,7 @@ 'use strict'; | ||
} | ||
function isShadowRoot(n) { | ||
var _a; | ||
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host; | ||
return Boolean(host && host.shadowRoot && host.shadowRoot === n); | ||
} | ||
@@ -514,2 +519,5 @@ var _id = 1; | ||
} | ||
if (n.parentNode && isShadowRoot(n.parentNode)) { | ||
serializedNode.isShadow = true; | ||
} | ||
if (serializedNode.type === exports.NodeType.Element && | ||
@@ -1334,1 +1342,3 @@ serializedNode.tagName === 'iframe') { | ||
exports.IGNORED_NODE = IGNORED_NODE; | ||
exports.isElement = isElement; | ||
exports.isShadowRoot = isShadowRoot; |
{ | ||
"name": "rrweb-snapshot", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer", | ||
@@ -5,0 +5,0 @@ "scripts": { |
import snapshot, { serializeNodeWithId, transformAttribute, visitSnapshot, cleanupSnapshot, IGNORED_NODE } from './snapshot'; | ||
import rebuild, { buildNodeWithSN, addHoverClass } from './rebuild'; | ||
export * from './types'; | ||
export * from './utils'; | ||
export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, transformAttribute, visitSnapshot, cleanupSnapshot, IGNORED_NODE, }; |
import { INode } from './types'; | ||
export declare function isElement(n: Node | INode): n is Element; | ||
export declare function isShadowRoot(n: Node): n is ShadowRoot; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
344274
4385