rrweb-snapshot
Advanced tools
Comparing version 1.1.12 to 1.1.13
@@ -1,2 +0,2 @@ | ||
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)}function a(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}e.NodeType=void 0,(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 i,o,s=1,c=new RegExp("[^a-z0-9-_:]");function u(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(l).join(""):null}catch(e){return null}}function l(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=u(e.styleSheet)||t}catch(e){}return t}var f=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,d=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,p=/^(data:)([^,]*),(.*)/i;function m(e,t){return(e||"").replace(f,(function(e,r,n,a,i,o){var s,c=n||i||o,u=r||a||"";if(!c)return e;if(!d.test(c))return"url("+u+c+u+")";if(p.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 l=t.split("/"),f=c.split("/");l.pop();for(var m=0,h=f;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?l.pop():l.push(v))}return"url("+u+l.join("/")+u+")"}))}var h=/^[^ \t\n\r\u000c]+/,v=/^[, \t\n\r\u000c]+/;function y(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function g(){var e=document.createElement("a");return e.href="",e.href}function T(e,t,r,n){return"src"===r||"href"===r&&n||"xlink:href"===r&&n&&"#"!==n[0]?y(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(v),!(r>=t.length);){var i=n(h);if(","===i.slice(-1))i=y(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=y(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?m(n,g()):"object"===t&&"data"===r&&n?y(e,n):n:y(e,n)}function b(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach((function(e){if(t.test(e))return!0}));return!(!r||!e.matches(r))||b(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,b(e.parentNode,t,r)}function k(t,r){var n,s,l,f,d=r.doc,p=r.blockClass,h=r.blockSelector,v=r.maskTextClass,y=r.maskTextSelector,k=r.inlineStylesheet,C=r.maskInputOptions,N=void 0===C?{}:C,w=r.maskTextFn,S=r.maskInputFn,x=r.inlineImages,E=r.recordCanvas,I=r.keepIframeSrcFn;if(d.__sn){var D=d.__sn.id;s=1===D?void 0:D}switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.NodeType.Document,childNodes:[],compatMode:t.compatMode,rootId:s}:{type:e.NodeType.Document,childNodes:[],rootId:s};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:s};case t.ELEMENT_NODE:for(var _=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,p,h),O=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return c.test(t)?"div":t}(t),L={},A=0,M=Array.from(t.attributes);A<M.length;A++){var R=M[A],F=R.name,W=R.value;L[F]=T(d,O,F,W)}if("link"===O&&k){var j,P=Array.from(d.styleSheets).find((function(e){return e.href===t.href}));(j=u(P))&&(delete L.rel,delete L.href,L._cssText=m(j,P.href))}if("style"===O&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(j=u(t.sheet))&&(L._cssText=m(j,g()));if("input"===O||"textarea"===O||"select"===O){W=t.value;"radio"!==L.type&&"checkbox"!==L.type&&"submit"!==L.type&&"button"!==L.type&&W?L.value=a({type:L.type,tagName:O,value:W,maskInputOptions:N,maskInputFn:S}):t.checked&&(L.checked=t.checked)}if("option"===O&&(t.selected?L.selected=!0:delete L.selected),"canvas"===O&&E&&(L.rr_dataURL=t.toDataURL()),"img"===O&&x&&i&&o){var H=t;H.crossOrigin="anonymous";try{i.width=H.naturalWidth,i.height=H.naturalHeight,o.drawImage(H,0,0),L.rr_dataURL=i.toDataURL()}catch(e){}}if("audio"!==O&&"video"!==O||(L.rr_mediaState=t.paused?"paused":"played",L.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(L.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(L.rr_scrollTop=t.scrollTop),_){var G=t.getBoundingClientRect(),z=G.width,B=G.height;L={class:L.class,rr_width:z+"px",rr_height:B+"px"}}return"iframe"!==O||I(L.src)||(t.contentDocument||(L.rr_src=L.src),delete L.src),{type:e.NodeType.Element,tagName:O,attributes:L,childNodes:[],isSVG:(f=t,"svg"===f.tagName||f instanceof SVGElement||void 0),needBlock:_,rootId:s};case t.TEXT_NODE:var U=t.parentNode&&t.parentNode.tagName,V=t.textContent,$="STYLE"===U||void 0,q="SCRIPT"===U||void 0;if($&&V){try{(null===(n=t.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(V=(l=t.parentNode.sheet).cssRules?Array.from(l.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(e){}V=m(V,g())}return q&&(V="SCRIPT_PLACEHOLDER"),!$&&!q&&b(t,v,y)&&V&&(V=w?w(V):V.replace(/[\S]/g,"*")),{type:e.NodeType.Text,textContent:V||"",isStyle:$,rootId:s};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:s};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:s};default:return!1}}function C(e){return void 0===e?"":e.toLowerCase()}function N(t,a){var c,u=a.doc,l=a.map,f=a.blockClass,d=a.blockSelector,p=a.maskTextClass,m=a.maskTextSelector,h=a.skipChild,v=void 0!==h&&h,y=a.inlineStylesheet,g=void 0===y||y,T=a.maskInputOptions,b=void 0===T?{}:T,w=a.maskTextFn,S=a.maskInputFn,x=a.slimDOMOptions,E=a.inlineImages,I=void 0!==E&&E,D=a.recordCanvas,_=void 0!==D&&D,O=a.onSerialize,L=a.onIframeLoad,A=a.iframeLoadTimeout,M=void 0===A?5e3:A,R=a.keepIframeSrcFn,F=void 0===R?function(){return!1}:R,W=a.preserveWhiteSpace,j=void 0===W||W,P=k(t,{doc:u,blockClass:f,blockSelector:d,maskTextClass:p,maskTextSelector:m,inlineStylesheet:g,maskInputOptions:b,maskTextFn:w,maskInputFn:S,inlineImages:I,recordCanvas:_,keepIframeSrcFn:F});if(!P)return console.warn(t,"not serialized"),null;c="__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||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(C(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===C(t.attributes.name)||"icon"===C(t.attributes.rel)||"apple-touch-icon"===C(t.attributes.rel)||"shortcut icon"===C(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&C(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(C(t.attributes.property).match(/^(og|twitter|fb):/)||C(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===C(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===C(t.attributes.name)||"googlebot"===C(t.attributes.name)||"bingbot"===C(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===C(t.attributes.name)||"generator"===C(t.attributes.name)||"framework"===C(t.attributes.name)||"publisher"===C(t.attributes.name)||"progid"===C(t.attributes.name)||C(t.attributes.property).match(/^article:/)||C(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===C(t.attributes.name)||"yandex-verification"===C(t.attributes.name)||"csrf-token"===C(t.attributes.name)||"p:domain_verify"===C(t.attributes.name)||"verify-v1"===C(t.attributes.name)||"verification"===C(t.attributes.name)||"shopify-checkout-api-token"===C(t.attributes.name)))return!0}}return!1}(P,x)&&(j||P.type!==e.NodeType.Text||P.isStyle||P.textContent.replace(/^\s+|\s+$/gm,"").length)?s++:-2;var H=Object.assign(P,{id:c});if(t.__sn=H,-2===c)return null;l[c]=t,O&&O(t);var G=!v;if(H.type===e.NodeType.Element&&(G=G&&!H.needBlock,delete H.needBlock),(H.type===e.NodeType.Document||H.type===e.NodeType.Element)&&G){x.headWhitespace&&P.type===e.NodeType.Element&&"head"===P.tagName&&(j=!1),I&&function(e){i||(i=e.createElement("canvas")),o||(o=i.getContext("2d")),i.width=0,i.height=0}(u);for(var z={doc:u,map:l,blockClass:f,blockSelector:d,maskTextClass:p,maskTextSelector:m,skipChild:v,inlineStylesheet:g,maskInputOptions:b,maskTextFn:w,maskInputFn:S,slimDOMOptions:x,inlineImages:I,recordCanvas:_,preserveWhiteSpace:j,onSerialize:O,onIframeLoad:L,iframeLoadTimeout:M,keepIframeSrcFn:F},B=0,U=Array.from(t.childNodes);B<U.length;B++){(q=N(U[B],z))&&H.childNodes.push(q)}if(r(t)&&t.shadowRoot){H.isShadowHost=!0;for(var V=0,$=Array.from(t.shadowRoot.childNodes);V<$.length;V++){var q;(q=N($[V],z))&&(q.isShadow=!0,H.childNodes.push(q))}}}return t.parentNode&&n(t.parentNode)&&(H.isShadow=!0),H.type===e.NodeType.Element&&"iframe"===H.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){var o="about:blank";n.location.href===o&&e.src!==o&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var s=setTimeout((function(){i||(t(),i=!0)}),r);e.addEventListener("load",(function(){clearTimeout(s),i=!0,t()}))}}}(t,(function(){var e=t.contentDocument;if(e&&L){var r=N(e,{doc:e,map:l,blockClass:f,blockSelector:d,maskTextClass:p,maskTextSelector:m,skipChild:!1,inlineStylesheet:g,maskInputOptions:b,maskTextFn:w,maskInputFn:S,slimDOMOptions:x,inlineImages:I,recordCanvas:_,preserveWhiteSpace:j,onSerialize:O,onIframeLoad:L,iframeLoadTimeout:M,keepIframeSrcFn:F});r&&L(t,r)}}),M),H}var w=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function S(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 i(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(e){this.start=e,this.end={line:r,column:n},this.source=t.source};o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return d(/^{\s*/)}function l(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=I()||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=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 c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=d(/^([^{]+)/);if(e)return x(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=i(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=x(t[0]);if(!d(/^:\s*/))return c("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(w,""),value:n?x(n[0]).replace(w,""):""});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=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:g()})}var b,k=S("import"),C=S("charset"),N=S("namespace");function S(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=d(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function I(){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 c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=m();n=T();)o.push(n),o=o.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=d(/^@media *([^{]+)/);if(t){var r=x(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=i(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:x(t[1]),media:x(t[2])})}()||function(){var e=i(),t=d(/^@supports *([^{]+)/);if(t){var r=x(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()||C()||N()||function(){var e=i(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=x(t[1]),n=x(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=i();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=i();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=i();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=i(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:g()})):c("selector missing")}return E((b=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:b,parsingErrors:s}}))}function x(e){return e?e.replace(/^\s+|\s+$/g,""):""}function E(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,i=Object.keys(e);a<i.length;a++){var o=e[i[a]];Array.isArray(o)?o.forEach((function(e){E(e,n)})):o&&"object"==typeof o&&E(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var I={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 D=/([^\\]):hover/,_=new RegExp(D.source,"g");function O(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=S(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach((function(e){"selectors"in e&&(e.selectors||[]).forEach((function(e){D.test(e)&&a.push(e)}))})),0===a.length)return e;var i=new RegExp(a.filter((function(e,t){return a.indexOf(e)===t})).sort((function(e,t){return t.length-e.length})).map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})).join("|"),"g"),o=e.replace(i,(function(e){var t=e.replace(_,"$1.\\:hover");return e+", "+t}));return null==t||t.stylesWithHoverClass.set(e,o),o}function L(t,r){var n=r.doc,a=r.hackCss,i=r.cache;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,s=function(e){var t=I[e.tagName]?I[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",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}else if("img"===s&&"rr_dataURL"===e){var u=o;u.currentSrc.startsWith("data:")||(u.setAttribute("data-rrweb-src",u.currentSrc),u.src=r),u.removeAttribute(e)}if("rr_width"===e)o.style.width=r;else if("rr_height"===e)o.style.height=r;else if("rr_mediaCurrentTime"===e)o.currentTime=t.attributes.rr_mediaCurrentTime;else if("rr_mediaState"===e)switch(r){case"played":o.play().catch((function(e){return console.warn("media playback error",e)}));break;case"paused":o.pause()}}else{var l="textarea"===s&&"value"===e,f="style"===s&&"_cssText"===e;if(f&&a&&(r=O(r,i)),l||f){for(var d=n.createTextNode(r),p=0,m=Array.from(o.childNodes);p<m.length;p++){var h=m[p];h.nodeType===o.TEXT_NODE&&o.removeChild(h)}return o.appendChild(d),"continue"}try{if(t.isSVG&&"xlink:href"===e)o.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))o.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return o.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||o.setAttribute(e,r)}}catch(e){}}};for(var u in t.attributes)c(u);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?O(t.textContent,i):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function A(t,n){var a=n.doc,i=n.map,o=n.skipChild,s=void 0!==o&&o,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,d=L(t,{doc:a,hackCss:u,cache:f});if(!d)return null;if(t.rootId&&console.assert(i[t.rootId]===a,"Target document should has the same root id."),t.type===e.NodeType.Document&&(a.close(),a.open(),"BackCompat"===t.compatMode&&t.childNodes&&t.childNodes[0].type!==e.NodeType.DocumentType&&(t.childNodes[0].type===e.NodeType.Element&&"xmlns"in t.childNodes[0].attributes&&"http://www.w3.org/1999/xhtml"===t.childNodes[0].attributes.xmlns?a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),d=a),d.__sn=t,i[t.id]=d,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var p=0,m=t.childNodes;p<m.length;p++){var h=m[p],v=A(h,{doc:a,map:i,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&r(d)&&d.shadowRoot?d.shadowRoot.appendChild(v):d.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return d}return e.IGNORED_NODE=-2,e.addHoverClass=O,e.buildNodeWithSN=A,e.cleanupSnapshot=function(){s=1},e.createCache=function(){return{stylesWithHoverClass:new Map}},e.isElement=r,e.isShadowRoot=n,e.maskInputValue=a,e.needMaskingText=b,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=A(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,(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 i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)})),[s,o]},e.serializeNodeWithId=N,e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,d=void 0===f||f,p=r.inlineImages,m=void 0!==p&&p,h=r.recordCanvas,v=void 0!==h&&h,y=r.maskAllInputs,g=void 0!==y&&y,T=r.maskTextFn,b=r.maskInputFn,k=r.slimDOM,C=void 0!==k&&k,w=r.preserveWhiteSpace,S=r.onSerialize,x=r.onIframeLoad,E=r.iframeLoadTimeout,I=r.keepIframeSrcFn,D={};return[N(e,{doc:e,map:D,blockClass:a,blockSelector:o,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:!0===g?{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,password:!0}:!1===g?{password:!0}:g,maskTextFn:T,maskInputFn:b,slimDOMOptions:!0===C||"all"===C?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===C,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===C?{}:C,inlineImages:m,recordCanvas:v,preserveWhiteSpace:w,onSerialize:S,onIframeLoad:x,iframeLoadTimeout:E,keepIframeSrcFn:void 0===I?function(){return!1}:I}),D]},e.transformAttribute=T,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)},Object.defineProperty(e,"__esModule",{value:!0}),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)}function a(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}e.NodeType=void 0,(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 i="__rrweb_original__";function o(e){var t=e.getContext("2d");if(!t)return!0;for(var r=0;r<e.width;r+=50)for(var n=0;n<e.height;n+=50){var a=t.getImageData,o=i in a?a.__rrweb_original__:a;if(new Uint32Array(o.call(t,r,n,Math.min(50,e.width-r),Math.min(50,e.height-n)).data.buffer).some((function(e){return 0!==e})))return!1}return!0}var s,c,u=1,l=new RegExp("[^a-z0-9-_:]");function f(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(d).join(""):null}catch(e){return null}}function d(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=f(e.styleSheet)||t}catch(e){}return t}var p=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,m=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,h=/^(data:)([^,]*),(.*)/i;function v(e,t){return(e||"").replace(p,(function(e,r,n,a,i,o){var s,c=n||i||o,u=r||a||"";if(!c)return e;if(!m.test(c))return"url("+u+c+u+")";if(h.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 l=t.split("/"),f=c.split("/");l.pop();for(var d=0,p=f;d<p.length;d++){var v=p[d];"."!==v&&(".."===v?l.pop():l.push(v))}return"url("+u+l.join("/")+u+")"}))}var y=/^[^ \t\n\r\u000c]+/,g=/^[, \t\n\r\u000c]+/;function T(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function b(){var e=document.createElement("a");return e.href="",e.href}function k(e,t,r,n){return"src"===r||"href"===r&&n||"xlink:href"===r&&n&&"#"!==n[0]?T(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(g),!(r>=t.length);){var i=n(y);if(","===i.slice(-1))i=T(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=T(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?v(n,b()):"object"===t&&"data"===r&&n?T(e,n):n:T(e,n)}function C(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach((function(e){if(t.test(e))return!0}));return!(!r||!e.matches(r))||C(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,C(e.parentNode,t,r)}function N(t,r){var n,i,u,d,p=r.doc,m=r.blockClass,h=r.blockSelector,y=r.maskTextClass,g=r.maskTextSelector,T=r.inlineStylesheet,N=r.maskInputOptions,w=void 0===N?{}:N,S=r.maskTextFn,x=r.maskInputFn,E=r.dataURLOptions,_=void 0===E?{}:E,I=r.inlineImages,D=r.recordCanvas,L=r.keepIframeSrcFn;if(p.__sn){var O=p.__sn.id;i=1===O?void 0:O}switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.NodeType.Document,childNodes:[],compatMode:t.compatMode,rootId:i}:{type:e.NodeType.Document,childNodes:[],rootId:i};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:i};case t.ELEMENT_NODE:for(var A=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,m,h),R=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return l.test(t)?"div":t}(t),M={},F=0,U=Array.from(t.attributes);F<U.length;F++){var W=U[F],j=W.name,P=W.value;M[j]=k(p,R,j,P)}if("link"===R&&T){var B=Array.from(p.styleSheets).find((function(e){return e.href===t.href})),H=null;B&&(H=f(B)),H&&(delete M.rel,delete M.href,M._cssText=v(H,B.href))}if("style"===R&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(H=f(t.sheet))&&(M._cssText=v(H,b()));if("input"===R||"textarea"===R||"select"===R){P=t.value;"radio"!==M.type&&"checkbox"!==M.type&&"submit"!==M.type&&"button"!==M.type&&P?M.value=a({type:M.type,tagName:R,value:P,maskInputOptions:w,maskInputFn:x}):t.checked&&(M.checked=t.checked)}if("option"===R&&(t.selected&&!w.select?M.selected=!0:delete M.selected),"canvas"===R&&D)if("2d"===t.__context)o(t)||(M.rr_dataURL=t.toDataURL(_.type,_.quality));else if(!("__context"in t)){var G=t.toDataURL(_.type,_.quality),z=document.createElement("canvas");z.width=t.width,z.height=t.height,G!==z.toDataURL(_.type,_.quality)&&(M.rr_dataURL=G)}if("img"===R&&I){s||(s=p.createElement("canvas"),c=s.getContext("2d"));var q=t,V=q.crossOrigin;q.crossOrigin="anonymous";var $=function(){try{s.width=q.naturalWidth,s.height=q.naturalHeight,c.drawImage(q,0,0),M.rr_dataURL=s.toDataURL(_.type,_.quality)}catch(e){console.warn("Cannot inline img src="+q.currentSrc+"! Error: "+e)}V?M.crossOrigin=V:delete M.crossOrigin};q.complete&&0!==q.naturalWidth?$():q.onload=$}if("audio"!==R&&"video"!==R||(M.rr_mediaState=t.paused?"paused":"played",M.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(M.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(M.rr_scrollTop=t.scrollTop),A){var X=t.getBoundingClientRect(),Y=X.width,K=X.height;M={class:M.class,rr_width:Y+"px",rr_height:K+"px"}}return"iframe"!==R||L(M.src)||(t.contentDocument||(M.rr_src=M.src),delete M.src),{type:e.NodeType.Element,tagName:R,attributes:M,childNodes:[],isSVG:(d=t,Boolean("svg"===d.tagName||d.ownerSVGElement)||void 0),needBlock:A,rootId:i};case t.TEXT_NODE:var Z=t.parentNode&&t.parentNode.tagName,J=t.textContent,Q="STYLE"===Z||void 0,ee="SCRIPT"===Z||void 0;if(Q&&J){try{(null===(n=t.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(J=(u=t.parentNode.sheet).cssRules?Array.from(u.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(e){console.warn("Cannot get CSS styles from text's parentNode. Error: "+e,t)}J=v(J,b())}return ee&&(J="SCRIPT_PLACEHOLDER"),!Q&&!ee&&C(t,y,g)&&J&&(J=S?S(J):J.replace(/[\S]/g,"*")),{type:e.NodeType.Text,textContent:J||"",isStyle:Q,rootId:i};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:i};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:i};default:return!1}}function w(e){return void 0===e?"":e.toLowerCase()}function S(t,a){var i,o=a.doc,s=a.map,c=a.blockClass,l=a.blockSelector,f=a.maskTextClass,d=a.maskTextSelector,p=a.skipChild,m=void 0!==p&&p,h=a.inlineStylesheet,v=void 0===h||h,y=a.maskInputOptions,g=void 0===y?{}:y,T=a.maskTextFn,b=a.maskInputFn,k=a.slimDOMOptions,C=a.dataURLOptions,x=void 0===C?{}:C,E=a.inlineImages,_=void 0!==E&&E,I=a.recordCanvas,D=void 0!==I&&I,L=a.onSerialize,O=a.onIframeLoad,A=a.iframeLoadTimeout,R=void 0===A?5e3:A,M=a.keepIframeSrcFn,F=void 0===M?function(){return!1}:M,U=a.preserveWhiteSpace,W=void 0===U||U,j=N(t,{doc:o,blockClass:c,blockSelector:l,maskTextClass:f,maskTextSelector:d,inlineStylesheet:v,maskInputOptions:g,maskTextFn:T,maskInputFn:b,dataURLOptions:x,inlineImages:_,recordCanvas:D,keepIframeSrcFn:F});if(!j)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||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(w(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===w(t.attributes.name)||"icon"===w(t.attributes.rel)||"apple-touch-icon"===w(t.attributes.rel)||"shortcut icon"===w(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&w(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(w(t.attributes.property).match(/^(og|twitter|fb):/)||w(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===w(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===w(t.attributes.name)||"googlebot"===w(t.attributes.name)||"bingbot"===w(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===w(t.attributes.name)||"generator"===w(t.attributes.name)||"framework"===w(t.attributes.name)||"publisher"===w(t.attributes.name)||"progid"===w(t.attributes.name)||w(t.attributes.property).match(/^article:/)||w(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===w(t.attributes.name)||"yandex-verification"===w(t.attributes.name)||"csrf-token"===w(t.attributes.name)||"p:domain_verify"===w(t.attributes.name)||"verify-v1"===w(t.attributes.name)||"verification"===w(t.attributes.name)||"shopify-checkout-api-token"===w(t.attributes.name)))return!0}}return!1}(j,k)&&(W||j.type!==e.NodeType.Text||j.isStyle||j.textContent.replace(/^\s+|\s+$/gm,"").length)?u++:-2;var P=Object.assign(j,{id:i});if(t.__sn=P,-2===i)return null;s[i]=t,L&&L(t);var B=!m;if(P.type===e.NodeType.Element&&(B=B&&!P.needBlock,delete P.needBlock),(P.type===e.NodeType.Document||P.type===e.NodeType.Element)&&B){k.headWhitespace&&j.type===e.NodeType.Element&&"head"===j.tagName&&(W=!1);for(var H={doc:o,map:s,blockClass:c,blockSelector:l,maskTextClass:f,maskTextSelector:d,skipChild:m,inlineStylesheet:v,maskInputOptions:g,maskTextFn:T,maskInputFn:b,slimDOMOptions:k,dataURLOptions:x,inlineImages:_,recordCanvas:D,preserveWhiteSpace:W,onSerialize:L,onIframeLoad:O,iframeLoadTimeout:R,keepIframeSrcFn:F},G=0,z=Array.from(t.childNodes);G<z.length;G++){($=S(z[G],H))&&P.childNodes.push($)}if(r(t)&&t.shadowRoot){P.isShadowHost=!0;for(var q=0,V=Array.from(t.shadowRoot.childNodes);q<V.length;q++){var $;($=S(V[q],H))&&($.isShadow=!0,P.childNodes.push($))}}}return t.parentNode&&n(t.parentNode)&&(P.isShadow=!0),P.type===e.NodeType.Element&&"iframe"===P.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){var o="about:blank";n.location.href===o&&e.src!==o&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var s=setTimeout((function(){i||(t(),i=!0)}),r);e.addEventListener("load",(function(){clearTimeout(s),i=!0,t()}))}}}(t,(function(){var e=t.contentDocument;if(e&&O){var r=S(e,{doc:e,map:s,blockClass:c,blockSelector:l,maskTextClass:f,maskTextSelector:d,skipChild:!1,inlineStylesheet:v,maskInputOptions:g,maskTextFn:T,maskInputFn:b,slimDOMOptions:k,dataURLOptions:x,inlineImages:_,recordCanvas:D,preserveWhiteSpace:W,onSerialize:L,onIframeLoad:O,iframeLoadTimeout:R,keepIframeSrcFn:F});r&&O(t,r)}}),R),P}var x=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function E(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 i(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(e){this.start=e,this.end={line:r,column:n},this.source=t.source};o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return d(/^{\s*/)}function l(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=S()||E());)!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=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 c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=d(/^([^{]+)/);if(e)return _(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=i(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=_(t[0]);if(!d(/^:\s*/))return c("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(x,""),value:n?_(n[0]).replace(x,""):""});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=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:g()})}var b,k=w("import"),C=w("charset"),N=w("namespace");function w(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=d(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function S(){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 c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=m();n=T();)o.push(n),o=o.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=d(/^@media *([^{]+)/);if(t){var r=_(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=i(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:_(t[1]),media:_(t[2])})}()||function(){var e=i(),t=d(/^@supports *([^{]+)/);if(t){var r=_(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()||C()||N()||function(){var e=i(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=_(t[1]),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=i();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=i();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=i();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 E(){var e=i(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:g()})):c("selector missing")}return I((b=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:b,parsingErrors:s}}))}function _(e){return e?e.replace(/^\s+|\s+$/g,""):""}function I(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,i=Object.keys(e);a<i.length;a++){var o=e[i[a]];Array.isArray(o)?o.forEach((function(e){I(e,n)})):o&&"object"==typeof o&&I(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var D={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 L=/([^\\]):hover/,O=new RegExp(L.source,"g");function A(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=E(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach((function(e){"selectors"in e&&(e.selectors||[]).forEach((function(e){L.test(e)&&a.push(e)}))})),0===a.length)return e;var i=new RegExp(a.filter((function(e,t){return a.indexOf(e)===t})).sort((function(e,t){return t.length-e.length})).map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})).join("|"),"g"),o=e.replace(i,(function(e){var t=e.replace(O,"$1.\\:hover");return e+", "+t}));return null==t||t.stylesWithHoverClass.set(e,o),o}function R(t,r){var n=r.doc,a=r.hackCss,i=r.cache;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,s=function(e){var t=D[e.tagName]?D[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",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}else if("img"===s&&"rr_dataURL"===e){var u=o;u.currentSrc.startsWith("data:")||(u.setAttribute("rrweb-original-src",t.attributes.src),u.src=r)}if("rr_width"===e)o.style.width=r;else if("rr_height"===e)o.style.height=r;else if("rr_mediaCurrentTime"===e)o.currentTime=t.attributes.rr_mediaCurrentTime;else if("rr_mediaState"===e)switch(r){case"played":o.play().catch((function(e){return console.warn("media playback error",e)}));break;case"paused":o.pause()}}else{var l="textarea"===s&&"value"===e,f="style"===s&&"_cssText"===e;if(f&&a&&(r=A(r,i)),l||f){for(var d=n.createTextNode(r),p=0,m=Array.from(o.childNodes);p<m.length;p++){var h=m[p];h.nodeType===o.TEXT_NODE&&o.removeChild(h)}return o.appendChild(d),"continue"}try{if(t.isSVG&&"xlink:href"===e)o.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))o.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return o.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||("img"===s&&t.attributes.srcset&&t.attributes.rr_dataURL?o.setAttribute("rrweb-original-srcset",t.attributes.srcset):o.setAttribute(e,r))}}catch(e){}}};for(var u in t.attributes)c(u);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?A(t.textContent,i):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function M(t,n){var a=n.doc,i=n.map,o=n.skipChild,s=void 0!==o&&o,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,d=R(t,{doc:a,hackCss:u,cache:f});if(!d)return null;if(t.rootId&&console.assert(i[t.rootId]===a,"Target document should has the same root id."),t.type===e.NodeType.Document&&(a.close(),a.open(),"BackCompat"===t.compatMode&&t.childNodes&&t.childNodes[0].type!==e.NodeType.DocumentType&&(t.childNodes[0].type===e.NodeType.Element&&"xmlns"in t.childNodes[0].attributes&&"http://www.w3.org/1999/xhtml"===t.childNodes[0].attributes.xmlns?a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),d=a),d.__sn=t,i[t.id]=d,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var p=0,m=t.childNodes;p<m.length;p++){var h=m[p],v=M(h,{doc:a,map:i,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&r(d)&&d.shadowRoot?d.shadowRoot.appendChild(v):d.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return d}return e.IGNORED_NODE=-2,e.addHoverClass=A,e.buildNodeWithSN=M,e.cleanupSnapshot=function(){u=1},e.createCache=function(){return{stylesWithHoverClass:new Map}},e.is2DCanvasBlank=o,e.isElement=r,e.isShadowRoot=n,e.maskInputValue=a,e.needMaskingText=C,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=M(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,(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 i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)})),[s,o]},e.serializeNodeWithId=S,e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,d=void 0===f||f,p=r.inlineImages,m=void 0!==p&&p,h=r.recordCanvas,v=void 0!==h&&h,y=r.maskAllInputs,g=void 0!==y&&y,T=r.maskTextFn,b=r.maskInputFn,k=r.slimDOM,C=void 0!==k&&k,N=r.dataURLOptions,w=r.preserveWhiteSpace,x=r.onSerialize,E=r.onIframeLoad,_=r.iframeLoadTimeout,I=r.keepIframeSrcFn,D={};return[S(e,{doc:e,map:D,blockClass:a,blockSelector:o,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:!0===g?{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,password:!0}:!1===g?{password:!0}:g,maskTextFn:T,maskInputFn:b,slimDOMOptions:!0===C||"all"===C?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===C,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===C?{}:C,dataURLOptions:N,inlineImages:m,recordCanvas:v,preserveWhiteSpace:w,onSerialize:x,onIframeLoad:E,iframeLoadTimeout:_,keepIframeSrcFn:void 0===I?function(){return!1}:I}),D]},e.transformAttribute=k,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)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=rrweb-snapshot.min.js.map |
@@ -33,2 +33,21 @@ var NodeType; | ||
} | ||
var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__'; | ||
function is2DCanvasBlank(canvas) { | ||
var ctx = canvas.getContext('2d'); | ||
if (!ctx) | ||
return true; | ||
var chunkSize = 50; | ||
for (var x = 0; x < canvas.width; x += chunkSize) { | ||
for (var y = 0; y < canvas.height; y += chunkSize) { | ||
var getImageData = ctx.getImageData; | ||
var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData | ||
? getImageData[ORIGINAL_ATTRIBUTE_NAME] | ||
: getImageData; | ||
var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer); | ||
if (pixelBuffer.some(function (pixel) { return pixel !== 0; })) | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
@@ -74,4 +93,11 @@ var _id = 1; | ||
} | ||
function stringifyStyleSheet(sheet) { | ||
return sheet.cssRules | ||
? Array.from(sheet.cssRules) | ||
.map(function (rule) { return rule.cssText || ''; }) | ||
.join('') | ||
: ''; | ||
} | ||
function extractOrigin(url) { | ||
var origin; | ||
var origin = ''; | ||
if (url.indexOf('//') > -1) { | ||
@@ -88,12 +114,2 @@ origin = url.split('/').slice(0, 3).join('/'); | ||
var canvasCtx; | ||
function initCanvasService(doc) { | ||
if (!canvasService) { | ||
canvasService = doc.createElement('canvas'); | ||
} | ||
if (!canvasCtx) { | ||
canvasCtx = canvasService.getContext('2d'); | ||
} | ||
canvasService.width = 0; | ||
canvasService.height = 0; | ||
} | ||
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm; | ||
@@ -205,3 +221,3 @@ var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/; | ||
function isSVGElement(el) { | ||
return el.tagName === 'svg' || el instanceof SVGElement; | ||
return Boolean(el.tagName === 'svg' || el.ownerSVGElement); | ||
} | ||
@@ -322,12 +338,5 @@ function getHref() { | ||
} | ||
function stringifyStyleSheet(sheet) { | ||
return sheet.cssRules | ||
? Array.from(sheet.cssRules) | ||
.map(function (rule) { return rule.cssText || ''; }) | ||
.join('') | ||
: ''; | ||
} | ||
function serializeNode(n, options) { | ||
var _a; | ||
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; | ||
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; | ||
var rootId; | ||
@@ -366,6 +375,6 @@ if (doc.__sn) { | ||
var tagName = getValidTagName(n); | ||
var attributes = {}; | ||
for (var _i = 0, _c = Array.from(n.attributes); _i < _c.length; _i++) { | ||
var _d = _c[_i], name_1 = _d.name, value = _d.value; | ||
attributes[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
var attributes_1 = {}; | ||
for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { | ||
var _e = _d[_i], name_1 = _e.name, value = _e.value; | ||
attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
} | ||
@@ -376,7 +385,10 @@ if (tagName === 'link' && inlineStylesheet) { | ||
}); | ||
var cssText = getCssRulesString(stylesheet); | ||
var cssText = null; | ||
if (stylesheet) { | ||
cssText = getCssRulesString(stylesheet); | ||
} | ||
if (cssText) { | ||
delete attributes.rel; | ||
delete attributes.href; | ||
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
delete attributes_1.rel; | ||
delete attributes_1.href; | ||
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
} | ||
@@ -391,3 +403,3 @@ } | ||
if (cssText) { | ||
attributes._cssText = absoluteToStylesheet(cssText, getHref()); | ||
attributes_1._cssText = absoluteToStylesheet(cssText, getHref()); | ||
} | ||
@@ -399,9 +411,9 @@ } | ||
var value = n.value; | ||
if (attributes.type !== 'radio' && | ||
attributes.type !== 'checkbox' && | ||
attributes.type !== 'submit' && | ||
attributes.type !== 'button' && | ||
if (attributes_1.type !== 'radio' && | ||
attributes_1.type !== 'checkbox' && | ||
attributes_1.type !== 'submit' && | ||
attributes_1.type !== 'button' && | ||
value) { | ||
attributes.value = maskInputValue({ | ||
type: attributes.type, | ||
attributes_1.value = maskInputValue({ | ||
type: attributes_1.type, | ||
tagName: tagName, | ||
@@ -414,44 +426,73 @@ value: value, | ||
else if (n.checked) { | ||
attributes.checked = n.checked; | ||
attributes_1.checked = n.checked; | ||
} | ||
} | ||
if (tagName === 'option') { | ||
if (n.selected) { | ||
attributes.selected = true; | ||
if (n.selected && !maskInputOptions['select']) { | ||
attributes_1.selected = true; | ||
} | ||
else { | ||
delete attributes.selected; | ||
delete attributes_1.selected; | ||
} | ||
} | ||
if (tagName === 'canvas' && recordCanvas) { | ||
attributes.rr_dataURL = n.toDataURL(); | ||
} | ||
if (tagName === 'img' && inlineImages && canvasService && canvasCtx) { | ||
var image = n; | ||
image.crossOrigin = 'anonymous'; | ||
try { | ||
canvasService.width = image.naturalWidth; | ||
canvasService.height = image.naturalHeight; | ||
canvasCtx.drawImage(image, 0, 0); | ||
attributes.rr_dataURL = canvasService.toDataURL(); | ||
if (n.__context === '2d') { | ||
if (!is2DCanvasBlank(n)) { | ||
attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
} | ||
} | ||
catch (_e) { | ||
else if (!('__context' in n)) { | ||
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
var blankCanvas = document.createElement('canvas'); | ||
blankCanvas.width = n.width; | ||
blankCanvas.height = n.height; | ||
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
if (canvasDataURL !== blankCanvasDataURL) { | ||
attributes_1.rr_dataURL = canvasDataURL; | ||
} | ||
} | ||
} | ||
if (tagName === 'img' && inlineImages) { | ||
if (!canvasService) { | ||
canvasService = doc.createElement('canvas'); | ||
canvasCtx = canvasService.getContext('2d'); | ||
} | ||
var image_1 = n; | ||
var oldValue_1 = image_1.crossOrigin; | ||
image_1.crossOrigin = 'anonymous'; | ||
var recordInlineImage = function () { | ||
try { | ||
canvasService.width = image_1.naturalWidth; | ||
canvasService.height = image_1.naturalHeight; | ||
canvasCtx.drawImage(image_1, 0, 0); | ||
attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
} | ||
catch (err) { | ||
console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err); | ||
} | ||
oldValue_1 | ||
? (attributes_1.crossOrigin = oldValue_1) | ||
: delete attributes_1.crossOrigin; | ||
}; | ||
if (image_1.complete && image_1.naturalWidth !== 0) | ||
recordInlineImage(); | ||
else | ||
image_1.onload = recordInlineImage; | ||
} | ||
if (tagName === 'audio' || tagName === 'video') { | ||
attributes.rr_mediaState = n.paused | ||
attributes_1.rr_mediaState = n.paused | ||
? 'paused' | ||
: 'played'; | ||
attributes.rr_mediaCurrentTime = n.currentTime; | ||
attributes_1.rr_mediaCurrentTime = n.currentTime; | ||
} | ||
if (n.scrollLeft) { | ||
attributes.rr_scrollLeft = n.scrollLeft; | ||
attributes_1.rr_scrollLeft = n.scrollLeft; | ||
} | ||
if (n.scrollTop) { | ||
attributes.rr_scrollTop = n.scrollTop; | ||
attributes_1.rr_scrollTop = n.scrollTop; | ||
} | ||
if (needBlock) { | ||
var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height; | ||
attributes = { | ||
"class": attributes["class"], | ||
attributes_1 = { | ||
"class": attributes_1["class"], | ||
rr_width: width + "px", | ||
@@ -461,7 +502,7 @@ rr_height: height + "px" | ||
} | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) { | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) { | ||
if (!n.contentDocument) { | ||
attributes.rr_src = attributes.src; | ||
attributes_1.rr_src = attributes_1.src; | ||
} | ||
delete attributes.src; | ||
delete attributes_1.src; | ||
} | ||
@@ -471,3 +512,3 @@ return { | ||
tagName: tagName, | ||
attributes: attributes, | ||
attributes: attributes_1, | ||
childNodes: [], | ||
@@ -489,3 +530,4 @@ isSVG: isSVGElement(n) || undefined, | ||
} | ||
catch (_g) { | ||
catch (err) { | ||
console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n); | ||
} | ||
@@ -607,4 +649,4 @@ textContent = absoluteToStylesheet(textContent, getHref()); | ||
function serializeNodeWithId(n, options) { | ||
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.inlineImages, inlineImages = _d === void 0 ? false : _d, _e = options.recordCanvas, recordCanvas = _e === void 0 ? false : _e, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _f = options.iframeLoadTimeout, iframeLoadTimeout = _f === void 0 ? 5000 : _f, _g = options.keepIframeSrcFn, keepIframeSrcFn = _g === void 0 ? function () { return false; } : _g; | ||
var _h = options.preserveWhiteSpace, preserveWhiteSpace = _h === void 0 ? true : _h; | ||
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; | ||
var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; | ||
var _serializedNode = serializeNode(n, { | ||
@@ -620,2 +662,3 @@ doc: doc, | ||
maskInputFn: maskInputFn, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -665,5 +708,2 @@ recordCanvas: recordCanvas, | ||
} | ||
if (inlineImages) { | ||
initCanvasService(doc); | ||
} | ||
var bypassOptions = { | ||
@@ -682,2 +722,3 @@ doc: doc, | ||
slimDOMOptions: slimDOMOptions, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -691,4 +732,4 @@ recordCanvas: recordCanvas, | ||
}; | ||
for (var _i = 0, _j = Array.from(n.childNodes); _i < _j.length; _i++) { | ||
var childN = _j[_i]; | ||
for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) { | ||
var childN = _k[_i]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
@@ -701,4 +742,4 @@ if (serializedChildNode) { | ||
serializedNode.isShadowHost = true; | ||
for (var _k = 0, _l = Array.from(n.shadowRoot.childNodes); _k < _l.length; _k++) { | ||
var childN = _l[_k]; | ||
for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) { | ||
var childN = _m[_l]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
@@ -733,2 +774,3 @@ if (serializedChildNode) { | ||
slimDOMOptions: slimDOMOptions, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -751,3 +793,3 @@ recordCanvas: recordCanvas, | ||
function snapshot(n, options) { | ||
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; | ||
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; | ||
var idNodeMap = {}; | ||
@@ -809,2 +851,3 @@ var maskInputOptions = maskAllInputs === true | ||
slimDOMOptions: slimDOMOptions, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -1436,2 +1479,7 @@ recordCanvas: recordCanvas, | ||
} | ||
else if (tagName === 'img' && | ||
n.attributes.srcset && | ||
n.attributes.rr_dataURL) { | ||
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset); | ||
} | ||
else { | ||
@@ -1458,6 +1506,5 @@ node_1.setAttribute(name_1, value); | ||
if (!image.currentSrc.startsWith('data:')) { | ||
image.setAttribute('data-rrweb-src', image.currentSrc); | ||
image.setAttribute('rrweb-original-src', n.attributes.src); | ||
image.src = value; | ||
} | ||
image.removeAttribute(name_1); | ||
} | ||
@@ -1619,2 +1666,2 @@ if (name_1 === 'rr_width') { | ||
export { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot }; | ||
export { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot }; |
@@ -1,2 +0,2 @@ | ||
var e;function t(e){return e.nodeType===e.ELEMENT_NODE}function r(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function n(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}!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"}(e||(e={}));var a,i,o=1,s=new RegExp("[^a-z0-9-_:]"),c=-2;function u(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(l).join(""):null}catch(e){return null}}function l(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=u(e.styleSheet)||t}catch(e){}return t}var f=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,m=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,p=/^(data:)([^,]*),(.*)/i;function d(e,t){return(e||"").replace(f,(function(e,r,n,a,i,o){var s,c=n||i||o,u=r||a||"";if(!c)return e;if(!m.test(c))return"url("+u+c+u+")";if(p.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 l=t.split("/"),f=c.split("/");l.pop();for(var d=0,h=f;d<h.length;d++){var v=h[d];"."!==v&&(".."===v?l.pop():l.push(v))}return"url("+u+l.join("/")+u+")"}))}var h=/^[^ \t\n\r\u000c]+/,v=/^[, \t\n\r\u000c]+/;function g(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function y(){var e=document.createElement("a");return e.href="",e.href}function b(e,t,r,n){return"src"===r||"href"===r&&n||"xlink:href"===r&&n&&"#"!==n[0]?g(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(v),!(r>=t.length);){var i=n(h);if(","===i.slice(-1))i=g(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=g(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?d(n,y()):"object"===t&&"data"===r&&n?g(e,n):n:g(e,n)}function k(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach((function(e){if(t.test(e))return!0}));return!(!r||!e.matches(r))||k(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,k(e.parentNode,t,r)}function T(t,r){var o,c,l,f,m=r.doc,p=r.blockClass,h=r.blockSelector,v=r.maskTextClass,g=r.maskTextSelector,T=r.inlineStylesheet,C=r.maskInputOptions,w=void 0===C?{}:C,x=r.maskTextFn,S=r.maskInputFn,E=r.inlineImages,N=r.recordCanvas,I=r.keepIframeSrcFn;if(m.__sn){var D=m.__sn.id;c=1===D?void 0:D}switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.Document,childNodes:[],compatMode:t.compatMode,rootId:c}:{type:e.Document,childNodes:[],rootId:c};case t.DOCUMENT_TYPE_NODE:return{type:e.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:c};case t.ELEMENT_NODE:for(var _=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,p,h),L=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return s.test(t)?"div":t}(t),A={},O=0,M=Array.from(t.attributes);O<M.length;O++){var F=M[O],R=F.name,W=F.value;A[R]=b(m,L,R,W)}if("link"===L&&T){var j,P=Array.from(m.styleSheets).find((function(e){return e.href===t.href}));(j=u(P))&&(delete A.rel,delete A.href,A._cssText=d(j,P.href))}if("style"===L&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(j=u(t.sheet))&&(A._cssText=d(j,y()));if("input"===L||"textarea"===L||"select"===L){W=t.value;"radio"!==A.type&&"checkbox"!==A.type&&"submit"!==A.type&&"button"!==A.type&&W?A.value=n({type:A.type,tagName:L,value:W,maskInputOptions:w,maskInputFn:S}):t.checked&&(A.checked=t.checked)}if("option"===L&&(t.selected?A.selected=!0:delete A.selected),"canvas"===L&&N&&(A.rr_dataURL=t.toDataURL()),"img"===L&&E&&a&&i){var H=t;H.crossOrigin="anonymous";try{a.width=H.naturalWidth,a.height=H.naturalHeight,i.drawImage(H,0,0),A.rr_dataURL=a.toDataURL()}catch(e){}}if("audio"!==L&&"video"!==L||(A.rr_mediaState=t.paused?"paused":"played",A.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(A.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(A.rr_scrollTop=t.scrollTop),_){var B=t.getBoundingClientRect(),G=B.width,z=B.height;A={class:A.class,rr_width:G+"px",rr_height:z+"px"}}return"iframe"!==L||I(A.src)||(t.contentDocument||(A.rr_src=A.src),delete A.src),{type:e.Element,tagName:L,attributes:A,childNodes:[],isSVG:(f=t,"svg"===f.tagName||f instanceof SVGElement||void 0),needBlock:_,rootId:c};case t.TEXT_NODE:var U=t.parentNode&&t.parentNode.tagName,V=t.textContent,$="STYLE"===U||void 0,q="SCRIPT"===U||void 0;if($&&V){try{(null===(o=t.parentNode.sheet)||void 0===o?void 0:o.cssRules)&&(V=(l=t.parentNode.sheet).cssRules?Array.from(l.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(e){}V=d(V,y())}return q&&(V="SCRIPT_PLACEHOLDER"),!$&&!q&&k(t,v,g)&&V&&(V=x?x(V):V.replace(/[\S]/g,"*")),{type:e.Text,textContent:V||"",isStyle:$,rootId:c};case t.CDATA_SECTION_NODE:return{type:e.CDATA,textContent:"",rootId:c};case t.COMMENT_NODE:return{type:e.Comment,textContent:t.textContent||"",rootId:c};default:return!1}}function C(e){return void 0===e?"":e.toLowerCase()}function w(n,s){var c,u=s.doc,l=s.map,f=s.blockClass,m=s.blockSelector,p=s.maskTextClass,d=s.maskTextSelector,h=s.skipChild,v=void 0!==h&&h,g=s.inlineStylesheet,y=void 0===g||g,b=s.maskInputOptions,k=void 0===b?{}:b,x=s.maskTextFn,S=s.maskInputFn,E=s.slimDOMOptions,N=s.inlineImages,I=void 0!==N&&N,D=s.recordCanvas,_=void 0!==D&&D,L=s.onSerialize,A=s.onIframeLoad,O=s.iframeLoadTimeout,M=void 0===O?5e3:O,F=s.keepIframeSrcFn,R=void 0===F?function(){return!1}:F,W=s.preserveWhiteSpace,j=void 0===W||W,P=T(n,{doc:u,blockClass:f,blockSelector:m,maskTextClass:p,maskTextSelector:d,inlineStylesheet:y,maskInputOptions:k,maskTextFn:x,maskInputFn:S,inlineImages:I,recordCanvas:_,keepIframeSrcFn:R});if(!P)return console.warn(n,"not serialized"),null;c="__sn"in n?n.__sn.id:!function(t,r){if(r.comment&&t.type===e.Comment)return!0;if(t.type===e.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(C(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===C(t.attributes.name)||"icon"===C(t.attributes.rel)||"apple-touch-icon"===C(t.attributes.rel)||"shortcut icon"===C(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&C(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(C(t.attributes.property).match(/^(og|twitter|fb):/)||C(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===C(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===C(t.attributes.name)||"googlebot"===C(t.attributes.name)||"bingbot"===C(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===C(t.attributes.name)||"generator"===C(t.attributes.name)||"framework"===C(t.attributes.name)||"publisher"===C(t.attributes.name)||"progid"===C(t.attributes.name)||C(t.attributes.property).match(/^article:/)||C(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===C(t.attributes.name)||"yandex-verification"===C(t.attributes.name)||"csrf-token"===C(t.attributes.name)||"p:domain_verify"===C(t.attributes.name)||"verify-v1"===C(t.attributes.name)||"verification"===C(t.attributes.name)||"shopify-checkout-api-token"===C(t.attributes.name)))return!0}}return!1}(P,E)&&(j||P.type!==e.Text||P.isStyle||P.textContent.replace(/^\s+|\s+$/gm,"").length)?o++:-2;var H=Object.assign(P,{id:c});if(n.__sn=H,-2===c)return null;l[c]=n,L&&L(n);var B=!v;if(H.type===e.Element&&(B=B&&!H.needBlock,delete H.needBlock),(H.type===e.Document||H.type===e.Element)&&B){E.headWhitespace&&P.type===e.Element&&"head"===P.tagName&&(j=!1),I&&function(e){a||(a=e.createElement("canvas")),i||(i=a.getContext("2d")),a.width=0,a.height=0}(u);for(var G={doc:u,map:l,blockClass:f,blockSelector:m,maskTextClass:p,maskTextSelector:d,skipChild:v,inlineStylesheet:y,maskInputOptions:k,maskTextFn:x,maskInputFn:S,slimDOMOptions:E,inlineImages:I,recordCanvas:_,preserveWhiteSpace:j,onSerialize:L,onIframeLoad:A,iframeLoadTimeout:M,keepIframeSrcFn:R},z=0,U=Array.from(n.childNodes);z<U.length;z++){(q=w(U[z],G))&&H.childNodes.push(q)}if(t(n)&&n.shadowRoot){H.isShadowHost=!0;for(var V=0,$=Array.from(n.shadowRoot.childNodes);V<$.length;V++){var q;(q=w($[V],G))&&(q.isShadow=!0,H.childNodes.push(q))}}}return n.parentNode&&r(n.parentNode)&&(H.isShadow=!0),H.type===e.Element&&"iframe"===H.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){var o="about:blank";n.location.href===o&&e.src!==o&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var s=setTimeout((function(){i||(t(),i=!0)}),r);e.addEventListener("load",(function(){clearTimeout(s),i=!0,t()}))}}}(n,(function(){var e=n.contentDocument;if(e&&A){var t=w(e,{doc:e,map:l,blockClass:f,blockSelector:m,maskTextClass:p,maskTextSelector:d,skipChild:!1,inlineStylesheet:y,maskInputOptions:k,maskTextFn:x,maskInputFn:S,slimDOMOptions:E,inlineImages:I,recordCanvas:_,preserveWhiteSpace:j,onSerialize:L,onIframeLoad:A,iframeLoadTimeout:M,keepIframeSrcFn:R});t&&A(n,t)}}),M),H}function x(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,m=void 0===f||f,p=r.inlineImages,d=void 0!==p&&p,h=r.recordCanvas,v=void 0!==h&&h,g=r.maskAllInputs,y=void 0!==g&&g,b=r.maskTextFn,k=r.maskInputFn,T=r.slimDOM,C=void 0!==T&&T,x=r.preserveWhiteSpace,S=r.onSerialize,E=r.onIframeLoad,N=r.iframeLoadTimeout,I=r.keepIframeSrcFn,D={};return[w(e,{doc:e,map:D,blockClass:a,blockSelector:o,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===y?{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,password:!0}:!1===y?{password:!0}:y,maskTextFn:b,maskInputFn:k,slimDOMOptions:!0===C||"all"===C?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===C,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===C?{}:C,inlineImages:d,recordCanvas:v,preserveWhiteSpace:x,onSerialize:S,onIframeLoad:E,iframeLoadTimeout:N,keepIframeSrcFn:void 0===I?function(){return!1}:I}),D]}function S(t,r){!function t(n){r(n),n.type!==e.Document&&n.type!==e.Element||n.childNodes.forEach(t)}(t)}function E(){o=1}var N=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function I(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 i(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(e){this.start=e,this.end={line:r,column:n},this.source=t.source};o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return m(/^{\s*/)}function l(){return m(/^}/)}function f(){var t,r=[];for(p(),d(r);e.length&&"}"!==e.charAt(0)&&(t=S()||E());)!1!==t&&(r.push(t),d(r));return r}function m(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function p(){m(/^\s*/)}function d(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 c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=m(/^([^{]+)/);if(e)return D(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=m(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=D(t[0]);if(!m(/^:\s*/))return c("property missing ':'");var n=m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(N,""),value:n?D(n[0]).replace(N,""):""});return m(/^[;\s]*/),a}}function y(){var e,t=[];if(!u())return c("missing '{'");for(d(t);e=g();)!1!==e&&(t.push(e),d(t)),e=g();return l()?t:c("missing '}'")}function b(){for(var e,t=[],r=i();e=m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),m(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var k,T=x("import"),C=x("charset"),w=x("namespace");function x(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=m(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function S(){if("@"===e[0])return function(){var e=i(),t=m(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=m(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=d();n=b();)o.push(n),o=o.concat(d());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=m(/^@media *([^{]+)/);if(t){var r=D(t[1]);if(!u())return c("@media missing '{'");var n=d().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=i(),t=m(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:D(t[1]),media:D(t[2])})}()||function(){var e=i(),t=m(/^@supports *([^{]+)/);if(t){var r=D(t[1]);if(!u())return c("@supports missing '{'");var n=d().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||T()||C()||w()||function(){var e=i(),t=m(/^@([-\w]+)?document *([^{]+)/);if(t){var r=D(t[1]),n=D(t[2]);if(!u())return c("@document missing '{'");var a=d().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=i();if(m(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=d();r=g();)n.push(r),n=n.concat(d());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=i();if(m(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=d().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(m(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=d();t=g();)r.push(t),r=r.concat(d());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function E(){var e=i(),t=v();return t?(d(),e({type:"rule",selectors:t,declarations:y()})):c("selector missing")}return _((k=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:k,parsingErrors:s}}))}function D(e){return e?e.replace(/^\s+|\s+$/g,""):""}function _(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,i=Object.keys(e);a<i.length;a++){var o=e[i[a]];Array.isArray(o)?o.forEach((function(e){_(e,n)})):o&&"object"==typeof o&&_(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var L={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 A=/([^\\]):hover/,O=new RegExp(A.source,"g");function M(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=I(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach((function(e){"selectors"in e&&(e.selectors||[]).forEach((function(e){A.test(e)&&a.push(e)}))})),0===a.length)return e;var i=new RegExp(a.filter((function(e,t){return a.indexOf(e)===t})).sort((function(e,t){return t.length-e.length})).map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})).join("|"),"g"),o=e.replace(i,(function(e){var t=e.replace(O,"$1.\\:hover");return e+", "+t}));return null==t||t.stylesWithHoverClass.set(e,o),o}function F(){return{stylesWithHoverClass:new Map}}function R(t,r){var n=r.doc,a=r.hackCss,i=r.cache;switch(t.type){case e.Document:return n.implementation.createDocument(null,"",null);case e.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.Element:var o,s=function(e){var t=L[e.tagName]?L[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",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}else if("img"===s&&"rr_dataURL"===e){var u=o;u.currentSrc.startsWith("data:")||(u.setAttribute("data-rrweb-src",u.currentSrc),u.src=r),u.removeAttribute(e)}if("rr_width"===e)o.style.width=r;else if("rr_height"===e)o.style.height=r;else if("rr_mediaCurrentTime"===e)o.currentTime=t.attributes.rr_mediaCurrentTime;else if("rr_mediaState"===e)switch(r){case"played":o.play().catch((function(e){return console.warn("media playback error",e)}));break;case"paused":o.pause()}}else{var l="textarea"===s&&"value"===e,f="style"===s&&"_cssText"===e;if(f&&a&&(r=M(r,i)),l||f){for(var m=n.createTextNode(r),p=0,d=Array.from(o.childNodes);p<d.length;p++){var h=d[p];h.nodeType===o.TEXT_NODE&&o.removeChild(h)}return o.appendChild(m),"continue"}try{if(t.isSVG&&"xlink:href"===e)o.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))o.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return o.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||o.setAttribute(e,r)}}catch(e){}}};for(var u in t.attributes)c(u);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.Text:return n.createTextNode(t.isStyle&&a?M(t.textContent,i):t.textContent);case e.CDATA:return n.createCDATASection(t.textContent);case e.Comment:return n.createComment(t.textContent);default:return null}}function W(r,n){var a=n.doc,i=n.map,o=n.skipChild,s=void 0!==o&&o,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,m=R(r,{doc:a,hackCss:u,cache:f});if(!m)return null;if(r.rootId&&console.assert(i[r.rootId]===a,"Target document should has the same root id."),r.type===e.Document&&(a.close(),a.open(),"BackCompat"===r.compatMode&&r.childNodes&&r.childNodes[0].type!==e.DocumentType&&(r.childNodes[0].type===e.Element&&"xmlns"in r.childNodes[0].attributes&&"http://www.w3.org/1999/xhtml"===r.childNodes[0].attributes.xmlns?a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),m=a),m.__sn=r,i[r.id]=m,(r.type===e.Document||r.type===e.Element)&&!s)for(var p=0,d=r.childNodes;p<d.length;p++){var h=d[p],v=W(h,{doc:a,map:i,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&t(m)&&m.shadowRoot?m.shadowRoot.appendChild(v):m.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return m}function j(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=W(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,(function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)})),[s,o]}export{c as IGNORED_NODE,e as NodeType,M as addHoverClass,W as buildNodeWithSN,E as cleanupSnapshot,F as createCache,t as isElement,r as isShadowRoot,n as maskInputValue,k as needMaskingText,j as rebuild,w as serializeNodeWithId,x as snapshot,b as transformAttribute,S as visitSnapshot}; | ||
var e;function t(e){return e.nodeType===e.ELEMENT_NODE}function r(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function n(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}!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"}(e||(e={}));function a(e){var t=e.getContext("2d");if(!t)return!0;for(var r=0;r<e.width;r+=50)for(var n=0;n<e.height;n+=50){var a=t.getImageData,i="__rrweb_original__"in a?a.__rrweb_original__:a;if(new Uint32Array(i.call(t,r,n,Math.min(50,e.width-r),Math.min(50,e.height-n)).data.buffer).some((function(e){return 0!==e})))return!1}return!0}var i,o,s=1,c=new RegExp("[^a-z0-9-_:]"),u=-2;function l(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(f).join(""):null}catch(e){return null}}function f(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=l(e.styleSheet)||t}catch(e){}return t}var m=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,d=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,p=/^(data:)([^,]*),(.*)/i;function h(e,t){return(e||"").replace(m,(function(e,r,n,a,i,o){var s,c=n||i||o,u=r||a||"";if(!c)return e;if(!d.test(c))return"url("+u+c+u+")";if(p.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 l=t.split("/"),f=c.split("/");l.pop();for(var m=0,h=f;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?l.pop():l.push(v))}return"url("+u+l.join("/")+u+")"}))}var v=/^[^ \t\n\r\u000c]+/,g=/^[, \t\n\r\u000c]+/;function y(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function b(){var e=document.createElement("a");return e.href="",e.href}function k(e,t,r,n){return"src"===r||"href"===r&&n||"xlink:href"===r&&n&&"#"!==n[0]?y(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(g),!(r>=t.length);){var i=n(v);if(","===i.slice(-1))i=y(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=y(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?h(n,b()):"object"===t&&"data"===r&&n?y(e,n):n:y(e,n)}function C(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach((function(e){if(t.test(e))return!0}));return!(!r||!e.matches(r))||C(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,C(e.parentNode,t,r)}function T(t,r){var s,u,f,m,d=r.doc,p=r.blockClass,v=r.blockSelector,g=r.maskTextClass,y=r.maskTextSelector,T=r.inlineStylesheet,w=r.maskInputOptions,x=void 0===w?{}:w,S=r.maskTextFn,E=r.maskInputFn,_=r.dataURLOptions,N=void 0===_?{}:_,I=r.inlineImages,D=r.recordCanvas,L=r.keepIframeSrcFn;if(d.__sn){var O=d.__sn.id;u=1===O?void 0:O}switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.Document,childNodes:[],compatMode:t.compatMode,rootId:u}:{type:e.Document,childNodes:[],rootId:u};case t.DOCUMENT_TYPE_NODE:return{type:e.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:u};case t.ELEMENT_NODE:for(var A=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,p,v),R=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return c.test(t)?"div":t}(t),M={},F=0,U=Array.from(t.attributes);F<U.length;F++){var W=U[F],j=W.name,P=W.value;M[j]=k(d,R,j,P)}if("link"===R&&T){var B=Array.from(d.styleSheets).find((function(e){return e.href===t.href})),H=null;B&&(H=l(B)),H&&(delete M.rel,delete M.href,M._cssText=h(H,B.href))}if("style"===R&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(H=l(t.sheet))&&(M._cssText=h(H,b()));if("input"===R||"textarea"===R||"select"===R){P=t.value;"radio"!==M.type&&"checkbox"!==M.type&&"submit"!==M.type&&"button"!==M.type&&P?M.value=n({type:M.type,tagName:R,value:P,maskInputOptions:x,maskInputFn:E}):t.checked&&(M.checked=t.checked)}if("option"===R&&(t.selected&&!x.select?M.selected=!0:delete M.selected),"canvas"===R&&D)if("2d"===t.__context)a(t)||(M.rr_dataURL=t.toDataURL(N.type,N.quality));else if(!("__context"in t)){var G=t.toDataURL(N.type,N.quality),z=document.createElement("canvas");z.width=t.width,z.height=t.height,G!==z.toDataURL(N.type,N.quality)&&(M.rr_dataURL=G)}if("img"===R&&I){i||(i=d.createElement("canvas"),o=i.getContext("2d"));var q=t,V=q.crossOrigin;q.crossOrigin="anonymous";var $=function(){try{i.width=q.naturalWidth,i.height=q.naturalHeight,o.drawImage(q,0,0),M.rr_dataURL=i.toDataURL(N.type,N.quality)}catch(e){console.warn("Cannot inline img src="+q.currentSrc+"! Error: "+e)}V?M.crossOrigin=V:delete M.crossOrigin};q.complete&&0!==q.naturalWidth?$():q.onload=$}if("audio"!==R&&"video"!==R||(M.rr_mediaState=t.paused?"paused":"played",M.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(M.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(M.rr_scrollTop=t.scrollTop),A){var X=t.getBoundingClientRect(),Y=X.width,K=X.height;M={class:M.class,rr_width:Y+"px",rr_height:K+"px"}}return"iframe"!==R||L(M.src)||(t.contentDocument||(M.rr_src=M.src),delete M.src),{type:e.Element,tagName:R,attributes:M,childNodes:[],isSVG:(m=t,Boolean("svg"===m.tagName||m.ownerSVGElement)||void 0),needBlock:A,rootId:u};case t.TEXT_NODE:var Z=t.parentNode&&t.parentNode.tagName,J=t.textContent,Q="STYLE"===Z||void 0,ee="SCRIPT"===Z||void 0;if(Q&&J){try{(null===(s=t.parentNode.sheet)||void 0===s?void 0:s.cssRules)&&(J=(f=t.parentNode.sheet).cssRules?Array.from(f.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(e){console.warn("Cannot get CSS styles from text's parentNode. Error: "+e,t)}J=h(J,b())}return ee&&(J="SCRIPT_PLACEHOLDER"),!Q&&!ee&&C(t,g,y)&&J&&(J=S?S(J):J.replace(/[\S]/g,"*")),{type:e.Text,textContent:J||"",isStyle:Q,rootId:u};case t.CDATA_SECTION_NODE:return{type:e.CDATA,textContent:"",rootId:u};case t.COMMENT_NODE:return{type:e.Comment,textContent:t.textContent||"",rootId:u};default:return!1}}function w(e){return void 0===e?"":e.toLowerCase()}function x(n,a){var i,o=a.doc,c=a.map,u=a.blockClass,l=a.blockSelector,f=a.maskTextClass,m=a.maskTextSelector,d=a.skipChild,p=void 0!==d&&d,h=a.inlineStylesheet,v=void 0===h||h,g=a.maskInputOptions,y=void 0===g?{}:g,b=a.maskTextFn,k=a.maskInputFn,C=a.slimDOMOptions,S=a.dataURLOptions,E=void 0===S?{}:S,_=a.inlineImages,N=void 0!==_&&_,I=a.recordCanvas,D=void 0!==I&&I,L=a.onSerialize,O=a.onIframeLoad,A=a.iframeLoadTimeout,R=void 0===A?5e3:A,M=a.keepIframeSrcFn,F=void 0===M?function(){return!1}:M,U=a.preserveWhiteSpace,W=void 0===U||U,j=T(n,{doc:o,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:m,inlineStylesheet:v,maskInputOptions:y,maskTextFn:b,maskInputFn:k,dataURLOptions:E,inlineImages:N,recordCanvas:D,keepIframeSrcFn:F});if(!j)return console.warn(n,"not serialized"),null;i="__sn"in n?n.__sn.id:!function(t,r){if(r.comment&&t.type===e.Comment)return!0;if(t.type===e.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(w(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===w(t.attributes.name)||"icon"===w(t.attributes.rel)||"apple-touch-icon"===w(t.attributes.rel)||"shortcut icon"===w(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&w(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(w(t.attributes.property).match(/^(og|twitter|fb):/)||w(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===w(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===w(t.attributes.name)||"googlebot"===w(t.attributes.name)||"bingbot"===w(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===w(t.attributes.name)||"generator"===w(t.attributes.name)||"framework"===w(t.attributes.name)||"publisher"===w(t.attributes.name)||"progid"===w(t.attributes.name)||w(t.attributes.property).match(/^article:/)||w(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===w(t.attributes.name)||"yandex-verification"===w(t.attributes.name)||"csrf-token"===w(t.attributes.name)||"p:domain_verify"===w(t.attributes.name)||"verify-v1"===w(t.attributes.name)||"verification"===w(t.attributes.name)||"shopify-checkout-api-token"===w(t.attributes.name)))return!0}}return!1}(j,C)&&(W||j.type!==e.Text||j.isStyle||j.textContent.replace(/^\s+|\s+$/gm,"").length)?s++:-2;var P=Object.assign(j,{id:i});if(n.__sn=P,-2===i)return null;c[i]=n,L&&L(n);var B=!p;if(P.type===e.Element&&(B=B&&!P.needBlock,delete P.needBlock),(P.type===e.Document||P.type===e.Element)&&B){C.headWhitespace&&j.type===e.Element&&"head"===j.tagName&&(W=!1);for(var H={doc:o,map:c,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:m,skipChild:p,inlineStylesheet:v,maskInputOptions:y,maskTextFn:b,maskInputFn:k,slimDOMOptions:C,dataURLOptions:E,inlineImages:N,recordCanvas:D,preserveWhiteSpace:W,onSerialize:L,onIframeLoad:O,iframeLoadTimeout:R,keepIframeSrcFn:F},G=0,z=Array.from(n.childNodes);G<z.length;G++){($=x(z[G],H))&&P.childNodes.push($)}if(t(n)&&n.shadowRoot){P.isShadowHost=!0;for(var q=0,V=Array.from(n.shadowRoot.childNodes);q<V.length;q++){var $;($=x(V[q],H))&&($.isShadow=!0,P.childNodes.push($))}}}return n.parentNode&&r(n.parentNode)&&(P.isShadow=!0),P.type===e.Element&&"iframe"===P.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){var o="about:blank";n.location.href===o&&e.src!==o&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var s=setTimeout((function(){i||(t(),i=!0)}),r);e.addEventListener("load",(function(){clearTimeout(s),i=!0,t()}))}}}(n,(function(){var e=n.contentDocument;if(e&&O){var t=x(e,{doc:e,map:c,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:m,skipChild:!1,inlineStylesheet:v,maskInputOptions:y,maskTextFn:b,maskInputFn:k,slimDOMOptions:C,dataURLOptions:E,inlineImages:N,recordCanvas:D,preserveWhiteSpace:W,onSerialize:L,onIframeLoad:O,iframeLoadTimeout:R,keepIframeSrcFn:F});t&&O(n,t)}}),R),P}function S(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,m=void 0===f||f,d=r.inlineImages,p=void 0!==d&&d,h=r.recordCanvas,v=void 0!==h&&h,g=r.maskAllInputs,y=void 0!==g&&g,b=r.maskTextFn,k=r.maskInputFn,C=r.slimDOM,T=void 0!==C&&C,w=r.dataURLOptions,S=r.preserveWhiteSpace,E=r.onSerialize,_=r.onIframeLoad,N=r.iframeLoadTimeout,I=r.keepIframeSrcFn,D={};return[x(e,{doc:e,map:D,blockClass:a,blockSelector:o,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===y?{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,password:!0}:!1===y?{password:!0}:y,maskTextFn:b,maskInputFn:k,slimDOMOptions:!0===T||"all"===T?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===T,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===T?{}:T,dataURLOptions:w,inlineImages:p,recordCanvas:v,preserveWhiteSpace:S,onSerialize:E,onIframeLoad:_,iframeLoadTimeout:N,keepIframeSrcFn:void 0===I?function(){return!1}:I}),D]}function E(t,r){!function t(n){r(n),n.type!==e.Document&&n.type!==e.Element||n.childNodes.forEach(t)}(t)}function _(){s=1}var N=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function I(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 i(){var e={line:r,column:n};return function(t){return t.position=new o(e),d(),t}}var o=function(e){this.start=e,this.end={line:r,column:n},this.source=t.source};o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return m(/^{\s*/)}function l(){return m(/^}/)}function f(){var t,r=[];for(d(),p(r);e.length&&"}"!==e.charAt(0)&&(t=S()||E());)!1!==t&&(r.push(t),p(r));return r}function m(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function d(){m(/^\s*/)}function p(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 c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=m(/^([^{]+)/);if(e)return D(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=m(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=D(t[0]);if(!m(/^:\s*/))return c("property missing ':'");var n=m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(N,""),value:n?D(n[0]).replace(N,""):""});return m(/^[;\s]*/),a}}function y(){var e,t=[];if(!u())return c("missing '{'");for(p(t);e=g();)!1!==e&&(t.push(e),p(t)),e=g();return l()?t:c("missing '}'")}function b(){for(var e,t=[],r=i();e=m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),m(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var k,C=x("import"),T=x("charset"),w=x("namespace");function x(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=m(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function S(){if("@"===e[0])return function(){var e=i(),t=m(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=m(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=p();n=b();)o.push(n),o=o.concat(p());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=m(/^@media *([^{]+)/);if(t){var r=D(t[1]);if(!u())return c("@media missing '{'");var n=p().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=i(),t=m(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:D(t[1]),media:D(t[2])})}()||function(){var e=i(),t=m(/^@supports *([^{]+)/);if(t){var r=D(t[1]);if(!u())return c("@supports missing '{'");var n=p().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||C()||T()||w()||function(){var e=i(),t=m(/^@([-\w]+)?document *([^{]+)/);if(t){var r=D(t[1]),n=D(t[2]);if(!u())return c("@document missing '{'");var a=p().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=i();if(m(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=p();r=g();)n.push(r),n=n.concat(p());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=i();if(m(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=p().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(m(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=p();t=g();)r.push(t),r=r.concat(p());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function E(){var e=i(),t=v();return t?(p(),e({type:"rule",selectors:t,declarations:y()})):c("selector missing")}return L((k=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:k,parsingErrors:s}}))}function D(e){return e?e.replace(/^\s+|\s+$/g,""):""}function L(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,i=Object.keys(e);a<i.length;a++){var o=e[i[a]];Array.isArray(o)?o.forEach((function(e){L(e,n)})):o&&"object"==typeof o&&L(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var O={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 A=/([^\\]):hover/,R=new RegExp(A.source,"g");function M(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=I(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach((function(e){"selectors"in e&&(e.selectors||[]).forEach((function(e){A.test(e)&&a.push(e)}))})),0===a.length)return e;var i=new RegExp(a.filter((function(e,t){return a.indexOf(e)===t})).sort((function(e,t){return t.length-e.length})).map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})).join("|"),"g"),o=e.replace(i,(function(e){var t=e.replace(R,"$1.\\:hover");return e+", "+t}));return null==t||t.stylesWithHoverClass.set(e,o),o}function F(){return{stylesWithHoverClass:new Map}}function U(t,r){var n=r.doc,a=r.hackCss,i=r.cache;switch(t.type){case e.Document:return n.implementation.createDocument(null,"",null);case e.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.Element:var o,s=function(e){var t=O[e.tagName]?O[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",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}else if("img"===s&&"rr_dataURL"===e){var u=o;u.currentSrc.startsWith("data:")||(u.setAttribute("rrweb-original-src",t.attributes.src),u.src=r)}if("rr_width"===e)o.style.width=r;else if("rr_height"===e)o.style.height=r;else if("rr_mediaCurrentTime"===e)o.currentTime=t.attributes.rr_mediaCurrentTime;else if("rr_mediaState"===e)switch(r){case"played":o.play().catch((function(e){return console.warn("media playback error",e)}));break;case"paused":o.pause()}}else{var l="textarea"===s&&"value"===e,f="style"===s&&"_cssText"===e;if(f&&a&&(r=M(r,i)),l||f){for(var m=n.createTextNode(r),d=0,p=Array.from(o.childNodes);d<p.length;d++){var h=p[d];h.nodeType===o.TEXT_NODE&&o.removeChild(h)}return o.appendChild(m),"continue"}try{if(t.isSVG&&"xlink:href"===e)o.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))o.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return o.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||("img"===s&&t.attributes.srcset&&t.attributes.rr_dataURL?o.setAttribute("rrweb-original-srcset",t.attributes.srcset):o.setAttribute(e,r))}}catch(e){}}};for(var u in t.attributes)c(u);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.Text:return n.createTextNode(t.isStyle&&a?M(t.textContent,i):t.textContent);case e.CDATA:return n.createCDATASection(t.textContent);case e.Comment:return n.createComment(t.textContent);default:return null}}function W(r,n){var a=n.doc,i=n.map,o=n.skipChild,s=void 0!==o&&o,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,m=U(r,{doc:a,hackCss:u,cache:f});if(!m)return null;if(r.rootId&&console.assert(i[r.rootId]===a,"Target document should has the same root id."),r.type===e.Document&&(a.close(),a.open(),"BackCompat"===r.compatMode&&r.childNodes&&r.childNodes[0].type!==e.DocumentType&&(r.childNodes[0].type===e.Element&&"xmlns"in r.childNodes[0].attributes&&"http://www.w3.org/1999/xhtml"===r.childNodes[0].attributes.xmlns?a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),m=a),m.__sn=r,i[r.id]=m,(r.type===e.Document||r.type===e.Element)&&!s)for(var d=0,p=r.childNodes;d<p.length;d++){var h=p[d],v=W(h,{doc:a,map:i,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&t(m)&&m.shadowRoot?m.shadowRoot.appendChild(v):m.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return m}function j(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=W(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,(function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)})),[s,o]}export{u as IGNORED_NODE,e as NodeType,M as addHoverClass,W as buildNodeWithSN,_ as cleanupSnapshot,F as createCache,a as is2DCanvasBlank,t as isElement,r as isShadowRoot,n as maskInputValue,C as needMaskingText,j as rebuild,x as serializeNodeWithId,S as snapshot,k as transformAttribute,E as visitSnapshot}; | ||
//# sourceMappingURL=rrweb-snapshot.min.js.map |
@@ -37,2 +37,21 @@ 'use strict'; | ||
} | ||
var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__'; | ||
function is2DCanvasBlank(canvas) { | ||
var ctx = canvas.getContext('2d'); | ||
if (!ctx) | ||
return true; | ||
var chunkSize = 50; | ||
for (var x = 0; x < canvas.width; x += chunkSize) { | ||
for (var y = 0; y < canvas.height; y += chunkSize) { | ||
var getImageData = ctx.getImageData; | ||
var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData | ||
? getImageData[ORIGINAL_ATTRIBUTE_NAME] | ||
: getImageData; | ||
var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer); | ||
if (pixelBuffer.some(function (pixel) { return pixel !== 0; })) | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
@@ -78,4 +97,11 @@ var _id = 1; | ||
} | ||
function stringifyStyleSheet(sheet) { | ||
return sheet.cssRules | ||
? Array.from(sheet.cssRules) | ||
.map(function (rule) { return rule.cssText || ''; }) | ||
.join('') | ||
: ''; | ||
} | ||
function extractOrigin(url) { | ||
var origin; | ||
var origin = ''; | ||
if (url.indexOf('//') > -1) { | ||
@@ -92,12 +118,2 @@ origin = url.split('/').slice(0, 3).join('/'); | ||
var canvasCtx; | ||
function initCanvasService(doc) { | ||
if (!canvasService) { | ||
canvasService = doc.createElement('canvas'); | ||
} | ||
if (!canvasCtx) { | ||
canvasCtx = canvasService.getContext('2d'); | ||
} | ||
canvasService.width = 0; | ||
canvasService.height = 0; | ||
} | ||
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm; | ||
@@ -209,3 +225,3 @@ var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/; | ||
function isSVGElement(el) { | ||
return el.tagName === 'svg' || el instanceof SVGElement; | ||
return Boolean(el.tagName === 'svg' || el.ownerSVGElement); | ||
} | ||
@@ -326,12 +342,5 @@ function getHref() { | ||
} | ||
function stringifyStyleSheet(sheet) { | ||
return sheet.cssRules | ||
? Array.from(sheet.cssRules) | ||
.map(function (rule) { return rule.cssText || ''; }) | ||
.join('') | ||
: ''; | ||
} | ||
function serializeNode(n, options) { | ||
var _a; | ||
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; | ||
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; | ||
var rootId; | ||
@@ -370,6 +379,6 @@ if (doc.__sn) { | ||
var tagName = getValidTagName(n); | ||
var attributes = {}; | ||
for (var _i = 0, _c = Array.from(n.attributes); _i < _c.length; _i++) { | ||
var _d = _c[_i], name_1 = _d.name, value = _d.value; | ||
attributes[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
var attributes_1 = {}; | ||
for (var _i = 0, _d = Array.from(n.attributes); _i < _d.length; _i++) { | ||
var _e = _d[_i], name_1 = _e.name, value = _e.value; | ||
attributes_1[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
} | ||
@@ -380,7 +389,10 @@ if (tagName === 'link' && inlineStylesheet) { | ||
}); | ||
var cssText = getCssRulesString(stylesheet); | ||
var cssText = null; | ||
if (stylesheet) { | ||
cssText = getCssRulesString(stylesheet); | ||
} | ||
if (cssText) { | ||
delete attributes.rel; | ||
delete attributes.href; | ||
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
delete attributes_1.rel; | ||
delete attributes_1.href; | ||
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
} | ||
@@ -395,3 +407,3 @@ } | ||
if (cssText) { | ||
attributes._cssText = absoluteToStylesheet(cssText, getHref()); | ||
attributes_1._cssText = absoluteToStylesheet(cssText, getHref()); | ||
} | ||
@@ -403,9 +415,9 @@ } | ||
var value = n.value; | ||
if (attributes.type !== 'radio' && | ||
attributes.type !== 'checkbox' && | ||
attributes.type !== 'submit' && | ||
attributes.type !== 'button' && | ||
if (attributes_1.type !== 'radio' && | ||
attributes_1.type !== 'checkbox' && | ||
attributes_1.type !== 'submit' && | ||
attributes_1.type !== 'button' && | ||
value) { | ||
attributes.value = maskInputValue({ | ||
type: attributes.type, | ||
attributes_1.value = maskInputValue({ | ||
type: attributes_1.type, | ||
tagName: tagName, | ||
@@ -418,44 +430,73 @@ value: value, | ||
else if (n.checked) { | ||
attributes.checked = n.checked; | ||
attributes_1.checked = n.checked; | ||
} | ||
} | ||
if (tagName === 'option') { | ||
if (n.selected) { | ||
attributes.selected = true; | ||
if (n.selected && !maskInputOptions['select']) { | ||
attributes_1.selected = true; | ||
} | ||
else { | ||
delete attributes.selected; | ||
delete attributes_1.selected; | ||
} | ||
} | ||
if (tagName === 'canvas' && recordCanvas) { | ||
attributes.rr_dataURL = n.toDataURL(); | ||
} | ||
if (tagName === 'img' && inlineImages && canvasService && canvasCtx) { | ||
var image = n; | ||
image.crossOrigin = 'anonymous'; | ||
try { | ||
canvasService.width = image.naturalWidth; | ||
canvasService.height = image.naturalHeight; | ||
canvasCtx.drawImage(image, 0, 0); | ||
attributes.rr_dataURL = canvasService.toDataURL(); | ||
if (n.__context === '2d') { | ||
if (!is2DCanvasBlank(n)) { | ||
attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
} | ||
} | ||
catch (_e) { | ||
else if (!('__context' in n)) { | ||
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
var blankCanvas = document.createElement('canvas'); | ||
blankCanvas.width = n.width; | ||
blankCanvas.height = n.height; | ||
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
if (canvasDataURL !== blankCanvasDataURL) { | ||
attributes_1.rr_dataURL = canvasDataURL; | ||
} | ||
} | ||
} | ||
if (tagName === 'img' && inlineImages) { | ||
if (!canvasService) { | ||
canvasService = doc.createElement('canvas'); | ||
canvasCtx = canvasService.getContext('2d'); | ||
} | ||
var image_1 = n; | ||
var oldValue_1 = image_1.crossOrigin; | ||
image_1.crossOrigin = 'anonymous'; | ||
var recordInlineImage = function () { | ||
try { | ||
canvasService.width = image_1.naturalWidth; | ||
canvasService.height = image_1.naturalHeight; | ||
canvasCtx.drawImage(image_1, 0, 0); | ||
attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality); | ||
} | ||
catch (err) { | ||
console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err); | ||
} | ||
oldValue_1 | ||
? (attributes_1.crossOrigin = oldValue_1) | ||
: delete attributes_1.crossOrigin; | ||
}; | ||
if (image_1.complete && image_1.naturalWidth !== 0) | ||
recordInlineImage(); | ||
else | ||
image_1.onload = recordInlineImage; | ||
} | ||
if (tagName === 'audio' || tagName === 'video') { | ||
attributes.rr_mediaState = n.paused | ||
attributes_1.rr_mediaState = n.paused | ||
? 'paused' | ||
: 'played'; | ||
attributes.rr_mediaCurrentTime = n.currentTime; | ||
attributes_1.rr_mediaCurrentTime = n.currentTime; | ||
} | ||
if (n.scrollLeft) { | ||
attributes.rr_scrollLeft = n.scrollLeft; | ||
attributes_1.rr_scrollLeft = n.scrollLeft; | ||
} | ||
if (n.scrollTop) { | ||
attributes.rr_scrollTop = n.scrollTop; | ||
attributes_1.rr_scrollTop = n.scrollTop; | ||
} | ||
if (needBlock) { | ||
var _f = n.getBoundingClientRect(), width = _f.width, height = _f.height; | ||
attributes = { | ||
"class": attributes["class"], | ||
attributes_1 = { | ||
"class": attributes_1["class"], | ||
rr_width: width + "px", | ||
@@ -465,7 +506,7 @@ rr_height: height + "px" | ||
} | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) { | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) { | ||
if (!n.contentDocument) { | ||
attributes.rr_src = attributes.src; | ||
attributes_1.rr_src = attributes_1.src; | ||
} | ||
delete attributes.src; | ||
delete attributes_1.src; | ||
} | ||
@@ -475,3 +516,3 @@ return { | ||
tagName: tagName, | ||
attributes: attributes, | ||
attributes: attributes_1, | ||
childNodes: [], | ||
@@ -493,3 +534,4 @@ isSVG: isSVGElement(n) || undefined, | ||
} | ||
catch (_g) { | ||
catch (err) { | ||
console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n); | ||
} | ||
@@ -611,4 +653,4 @@ textContent = absoluteToStylesheet(textContent, getHref()); | ||
function serializeNodeWithId(n, options) { | ||
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.inlineImages, inlineImages = _d === void 0 ? false : _d, _e = options.recordCanvas, recordCanvas = _e === void 0 ? false : _e, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _f = options.iframeLoadTimeout, iframeLoadTimeout = _f === void 0 ? 5000 : _f, _g = options.keepIframeSrcFn, keepIframeSrcFn = _g === void 0 ? function () { return false; } : _g; | ||
var _h = options.preserveWhiteSpace, preserveWhiteSpace = _h === void 0 ? true : _h; | ||
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5000 : _g, _h = options.keepIframeSrcFn, keepIframeSrcFn = _h === void 0 ? function () { return false; } : _h; | ||
var _j = options.preserveWhiteSpace, preserveWhiteSpace = _j === void 0 ? true : _j; | ||
var _serializedNode = serializeNode(n, { | ||
@@ -624,2 +666,3 @@ doc: doc, | ||
maskInputFn: maskInputFn, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -669,5 +712,2 @@ recordCanvas: recordCanvas, | ||
} | ||
if (inlineImages) { | ||
initCanvasService(doc); | ||
} | ||
var bypassOptions = { | ||
@@ -686,2 +726,3 @@ doc: doc, | ||
slimDOMOptions: slimDOMOptions, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -695,4 +736,4 @@ recordCanvas: recordCanvas, | ||
}; | ||
for (var _i = 0, _j = Array.from(n.childNodes); _i < _j.length; _i++) { | ||
var childN = _j[_i]; | ||
for (var _i = 0, _k = Array.from(n.childNodes); _i < _k.length; _i++) { | ||
var childN = _k[_i]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
@@ -705,4 +746,4 @@ if (serializedChildNode) { | ||
serializedNode.isShadowHost = true; | ||
for (var _k = 0, _l = Array.from(n.shadowRoot.childNodes); _k < _l.length; _k++) { | ||
var childN = _l[_k]; | ||
for (var _l = 0, _m = Array.from(n.shadowRoot.childNodes); _l < _m.length; _l++) { | ||
var childN = _m[_l]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
@@ -737,2 +778,3 @@ if (serializedChildNode) { | ||
slimDOMOptions: slimDOMOptions, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -755,3 +797,3 @@ recordCanvas: recordCanvas, | ||
function snapshot(n, options) { | ||
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; | ||
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.inlineImages, inlineImages = _g === void 0 ? false : _g, _h = _a.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = _a.maskAllInputs, maskAllInputs = _j === void 0 ? false : _j, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _k = _a.slimDOM, slimDOM = _k === void 0 ? false : _k, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _l = _a.keepIframeSrcFn, keepIframeSrcFn = _l === void 0 ? function () { return false; } : _l; | ||
var idNodeMap = {}; | ||
@@ -813,2 +855,3 @@ var maskInputOptions = maskAllInputs === true | ||
slimDOMOptions: slimDOMOptions, | ||
dataURLOptions: dataURLOptions, | ||
inlineImages: inlineImages, | ||
@@ -1440,2 +1483,7 @@ recordCanvas: recordCanvas, | ||
} | ||
else if (tagName === 'img' && | ||
n.attributes.srcset && | ||
n.attributes.rr_dataURL) { | ||
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset); | ||
} | ||
else { | ||
@@ -1462,6 +1510,5 @@ node_1.setAttribute(name_1, value); | ||
if (!image.currentSrc.startsWith('data:')) { | ||
image.setAttribute('data-rrweb-src', image.currentSrc); | ||
image.setAttribute('rrweb-original-src', n.attributes.src); | ||
image.src = value; | ||
} | ||
image.removeAttribute(name_1); | ||
} | ||
@@ -1628,2 +1675,3 @@ if (name_1 === 'rr_width') { | ||
exports.createCache = createCache; | ||
exports.is2DCanvasBlank = is2DCanvasBlank; | ||
exports.isElement = isElement; | ||
@@ -1630,0 +1678,0 @@ exports.isShadowRoot = isShadowRoot; |
{ | ||
"name": "rrweb-snapshot", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer", | ||
@@ -61,3 +61,3 @@ "scripts": { | ||
}, | ||
"gitHead": "e9ea287bc569dff889b0139973e4ed35ffa26771" | ||
"gitHead": "bd144be39be799dc598e11377bb5356b0752e986" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { serializedNodeWithId, INode, idNodeMap, MaskInputOptions, SlimDOMOptions, MaskTextFn, MaskInputFn, KeepIframeSrcFn } from './types'; | ||
import { serializedNodeWithId, INode, idNodeMap, MaskInputOptions, SlimDOMOptions, DataURLOptions, MaskTextFn, MaskInputFn, KeepIframeSrcFn } from './types'; | ||
export declare const IGNORED_NODE = -2; | ||
@@ -21,2 +21,3 @@ export declare function absoluteToStylesheet(cssText: string | null, href: string): string; | ||
slimDOMOptions: SlimDOMOptions; | ||
dataURLOptions?: DataURLOptions; | ||
keepIframeSrcFn?: KeepIframeSrcFn; | ||
@@ -40,2 +41,3 @@ inlineImages?: boolean; | ||
slimDOM?: boolean | SlimDOMOptions; | ||
dataURLOptions?: DataURLOptions; | ||
inlineImages?: boolean; | ||
@@ -42,0 +44,0 @@ recordCanvas?: boolean; |
@@ -58,2 +58,5 @@ export declare enum NodeType { | ||
} | ||
export interface ICanvas extends HTMLCanvasElement { | ||
__context: string; | ||
} | ||
export declare type idNodeMap = { | ||
@@ -92,2 +95,6 @@ [key: number]: INode; | ||
}>; | ||
export declare type DataURLOptions = Partial<{ | ||
type: string; | ||
quality: number; | ||
}>; | ||
export declare type MaskTextFn = (text: string) => string; | ||
@@ -94,0 +101,0 @@ export declare type MaskInputFn = (text: string) => string; |
@@ -11,1 +11,2 @@ import { INode, MaskInputFn, MaskInputOptions } from './types'; | ||
}): string; | ||
export declare function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean; |
Sorry, the diff of this file is too big to display
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
445485
5428