Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rrweb-snapshot

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rrweb-snapshot - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

8

dist/rrweb-snapshot.js

@@ -45,7 +45,8 @@ var rrwebSnapshot = (function (exports) {

}
var URL_IN_CSS_REF = /url\((['"]|)([^'"]*)\1\)/gm;
var URL_IN_CSS_REF = /url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm;
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
var DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
function absoluteToStylesheet(cssText, href) {
return cssText.replace(URL_IN_CSS_REF, function (_1, _2, filePath) {
return cssText.replace(URL_IN_CSS_REF, function (_1, path1, path2, path3) {
var filePath = path1 || path2 || path3;
if (!RELATIVE_PATH.test(filePath)) {

@@ -110,2 +111,5 @@ return "url('" + filePath + "')";

}
else if (name === 'style') {
attributes_1[name] = absoluteToStylesheet(value, location.href);
}
else {

@@ -112,0 +116,0 @@ attributes_1[name] = value;

@@ -1,2 +0,2 @@

var rrwebSnapshot=function(e){"use strict";var t;(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 r=1;function n(){r=1}var a=/url\((['"]|)([^'"]*)\1\)/gm,o=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/,i=/^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;function l(e,t){return e.replace(a,function(e,r,n){if(!o.test(n))return"url('"+n+"')";if(i.test(n))return"url("+n+")";if("/"===n[0])return"url('"+(((a=t).indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+n)+"')";var a,l=t.split("/"),c=n.split("/");l.pop();for(var u=0,s=c;u<s.length;u++){var f=s[u];"."!==f&&(".."===f?l.pop():l.push(f))}return"url('"+l.join("/")+"')"})}function c(e,t){var r=e.createElement("a");return r.href=t,r.href}var u="rr-block";function s(t,r){switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId};case t.ELEMENT_NODE:for(var n=t.classList.contains(u),a=t.tagName.toLowerCase(),o={},i=0,s=Array.from(t.attributes);i<s.length;i++){var f=s[i],p=f.name,d=f.value;o[p]="src"===p||"href"===p?c(r,d):d}if("link"===a){var m=Array.from(r.styleSheets).find(function(e){return e.href===t.href}),h=function(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).reduce(function(e,t){return e+t.cssText},""):null}catch(e){return null}}(m);h&&(o={_cssText:l(h,m.href)})}if("input"===a||"textarea"===a||"select"===a){d=t.value;"radio"!==o.type&&"checkbox"!==o.type&&d?o.value=d:t.checked&&(o.checked=t.checked)}if("option"===a){var y=t.parentElement;o.value===y.value&&(o.selected=t.selected)}if(n){var g=t.getBoundingClientRect(),T=g.width,v=g.height;o.rr_width=T+"px",o.rr_height=v+"px"}return{type:e.NodeType.Element,tagName:a,attributes:o,childNodes:[],isSVG:(b=t,"svg"===b.tagName||b instanceof SVGElement||void 0),needBlock:n};case t.TEXT_NODE:var N=t.parentNode&&t.parentNode.tagName,C=t.textContent,D="STYLE"===N||void 0;return D&&C&&(C=l(C,location.href)),"SCRIPT"===N&&(C="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:C||"",isStyle:D};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:""};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||""};default:return!1}var b}function f(t,n,a,o){void 0===o&&(o=!1);var i=s(t,n);if(!i)return console.warn(t,"not serialized"),null;var l=Object.assign(i,{id:r++});t.__sn=l,a[l.id]=t;var c=!o;if(l.type===e.NodeType.Element&&(c=c&&!l.needBlock,delete l.needBlock),(l.type===e.NodeType.Document||l.type===e.NodeType.Element)&&c)for(var u=0,p=Array.from(t.childNodes);u<p.length;u++){var d=f(p[u],n,a);d&&l.childNodes.push(d)}return l}var p={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=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,m=/([^\\]):hover/g;function h(e){return e.replace(d,function(e,t,r){if(m.test(t)){var n=t.replace(m,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+n.replace(/^\s*/,"")+r}return e})}function y(t,r){switch(t.type){case e.NodeType.Document:return r.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return r.implementation.createDocumentType(t.name,t.publicId,t.systemId);case e.NodeType.Element:var n=function(e){var t=p[e.tagName]?p[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t),a=void 0;for(var o in a=t.isSVG?r.createElementNS("http://www.w3.org/2000/svg",n):r.createElement(n),t.attributes)if(t.attributes.hasOwnProperty(o)&&!o.startsWith("rr_")){var i=t.attributes[o];i="boolean"==typeof i?"":i;var l="textarea"===n&&"value"===o,c="style"===n&&"_cssText"===o;if(c&&(i=h(i)),l||c){var u=r.createTextNode(i);a.appendChild(u);continue}if("iframe"===n&&"src"===o)continue;try{a.setAttribute(o,i)}catch(e){}}else t.attributes.rr_width&&(a.style.width=t.attributes.rr_width),t.attributes.rr_height&&(a.style.height=t.attributes.rr_height);return a;case e.NodeType.Text:return r.createTextNode(t.isStyle?h(t.textContent):t.textContent);case e.NodeType.CDATA:return r.createCDATASection(t.textContent);case e.NodeType.Comment:return r.createComment(t.textContent);default:return null}}function g(t,r,n,a){void 0===a&&(a=!1);var o=y(t,r);if(!o)return null;if(t.type===e.NodeType.Document&&(r.close(),r.open(),o=r),o.__sn=t,n[t.id]=o,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!a)for(var i=0,l=t.childNodes;i<l.length;i++){var c=l[i],u=g(c,r,n);u?o.appendChild(u):console.warn("Failed to rebuild",c)}return o}return e.snapshot=function(e){n();var t={};return[f(e,e,t),t]},e.serializeNodeWithId=f,e.resetId=n,e.rebuild=function(e,t){var r={};return[g(e,t,r),r]},e.buildNodeWithSN=g,e}({});
var rrwebSnapshot=function(e){"use strict";var t;(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 r=1;function n(){r=1}var a=/url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm,o=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/,i=/^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;function l(e,t){return e.replace(a,function(e,r,n,a){var l,c=r||n||a;if(!o.test(c))return"url('"+c+"')";if(i.test(c))return"url("+c+")";if("/"===c[0])return"url('"+(((l=t).indexOf("//")>-1?l.split("/").slice(0,3).join("/"):l.split("/")[0]).split("?")[0]+c)+"')";var u=t.split("/"),s=c.split("/");u.pop();for(var f=0,p=s;f<p.length;f++){var d=p[f];"."!==d&&(".."===d?u.pop():u.push(d))}return"url('"+u.join("/")+"')"})}function c(e,t){var r=e.createElement("a");return r.href=t,r.href}var u="rr-block";function s(t,r){switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId};case t.ELEMENT_NODE:for(var n=t.classList.contains(u),a=t.tagName.toLowerCase(),o={},i=0,s=Array.from(t.attributes);i<s.length;i++){var f=s[i],p=f.name,d=f.value;o[p]="src"===p||"href"===p?c(r,d):"style"===p?l(d,location.href):d}if("link"===a){var m=Array.from(r.styleSheets).find(function(e){return e.href===t.href}),h=function(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).reduce(function(e,t){return e+t.cssText},""):null}catch(e){return null}}(m);h&&(o={_cssText:l(h,m.href)})}if("input"===a||"textarea"===a||"select"===a){d=t.value;"radio"!==o.type&&"checkbox"!==o.type&&d?o.value=d:t.checked&&(o.checked=t.checked)}if("option"===a){var y=t.parentElement;o.value===y.value&&(o.selected=t.selected)}if(n){var g=t.getBoundingClientRect(),T=g.width,v=g.height;o.rr_width=T+"px",o.rr_height=v+"px"}return{type:e.NodeType.Element,tagName:a,attributes:o,childNodes:[],isSVG:(b=t,"svg"===b.tagName||b instanceof SVGElement||void 0),needBlock:n};case t.TEXT_NODE:var N=t.parentNode&&t.parentNode.tagName,C=t.textContent,D="STYLE"===N||void 0;return D&&C&&(C=l(C,location.href)),"SCRIPT"===N&&(C="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:C||"",isStyle:D};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:""};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||""};default:return!1}var b}function f(t,n,a,o){void 0===o&&(o=!1);var i=s(t,n);if(!i)return console.warn(t,"not serialized"),null;var l=Object.assign(i,{id:r++});t.__sn=l,a[l.id]=t;var c=!o;if(l.type===e.NodeType.Element&&(c=c&&!l.needBlock,delete l.needBlock),(l.type===e.NodeType.Document||l.type===e.NodeType.Element)&&c)for(var u=0,p=Array.from(t.childNodes);u<p.length;u++){var d=f(p[u],n,a);d&&l.childNodes.push(d)}return l}var p={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=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,m=/([^\\]):hover/g;function h(e){return e.replace(d,function(e,t,r){if(m.test(t)){var n=t.replace(m,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+n.replace(/^\s*/,"")+r}return e})}function y(t,r){switch(t.type){case e.NodeType.Document:return r.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return r.implementation.createDocumentType(t.name,t.publicId,t.systemId);case e.NodeType.Element:var n=function(e){var t=p[e.tagName]?p[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t),a=void 0;for(var o in a=t.isSVG?r.createElementNS("http://www.w3.org/2000/svg",n):r.createElement(n),t.attributes)if(t.attributes.hasOwnProperty(o)&&!o.startsWith("rr_")){var i=t.attributes[o];i="boolean"==typeof i?"":i;var l="textarea"===n&&"value"===o,c="style"===n&&"_cssText"===o;if(c&&(i=h(i)),l||c){var u=r.createTextNode(i);a.appendChild(u);continue}if("iframe"===n&&"src"===o)continue;try{a.setAttribute(o,i)}catch(e){}}else t.attributes.rr_width&&(a.style.width=t.attributes.rr_width),t.attributes.rr_height&&(a.style.height=t.attributes.rr_height);return a;case e.NodeType.Text:return r.createTextNode(t.isStyle?h(t.textContent):t.textContent);case e.NodeType.CDATA:return r.createCDATASection(t.textContent);case e.NodeType.Comment:return r.createComment(t.textContent);default:return null}}function g(t,r,n,a){void 0===a&&(a=!1);var o=y(t,r);if(!o)return null;if(t.type===e.NodeType.Document&&(r.close(),r.open(),o=r),o.__sn=t,n[t.id]=o,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!a)for(var i=0,l=t.childNodes;i<l.length;i++){var c=l[i],u=g(c,r,n);u?o.appendChild(u):console.warn("Failed to rebuild",c)}return o}return e.snapshot=function(e){n();var t={};return[f(e,e,t),t]},e.serializeNodeWithId=f,e.resetId=n,e.rebuild=function(e,t){var r={};return[g(e,t,r),r]},e.buildNodeWithSN=g,e}({});
//# sourceMappingURL=rrweb-snapshot.min.js.map

@@ -43,7 +43,8 @@ var NodeType;

}
var URL_IN_CSS_REF = /url\((['"]|)([^'"]*)\1\)/gm;
var URL_IN_CSS_REF = /url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm;
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
var DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
function absoluteToStylesheet(cssText, href) {
return cssText.replace(URL_IN_CSS_REF, function (_1, _2, filePath) {
return cssText.replace(URL_IN_CSS_REF, function (_1, path1, path2, path3) {
var filePath = path1 || path2 || path3;
if (!RELATIVE_PATH.test(filePath)) {

@@ -108,2 +109,5 @@ return "url('" + filePath + "')";

}
else if (name === 'style') {
attributes_1[name] = absoluteToStylesheet(value, location.href);
}
else {

@@ -110,0 +114,0 @@ attributes_1[name] = value;

@@ -1,2 +0,2 @@

var NodeType;!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(NodeType||(NodeType={}));var _id=1;function genId(){return _id++}function resetId(){_id=1}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).reduce(function(e,t){return e+t.cssText},""):null}catch(e){return null}}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((['"]|)([^'"]*)\1\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/,DATA_URI=/^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;function absoluteToStylesheet(e,t){return e.replace(URL_IN_CSS_REF,function(e,r,n){if(!RELATIVE_PATH.test(n))return"url('"+n+"')";if(DATA_URI.test(n))return"url("+n+")";if("/"===n[0])return"url('"+(extractOrigin(t)+n)+"')";var a=t.split("/"),o=n.split("/");a.pop();for(var i=0,l=o;i<l.length;i++){var s=l[i];"."!==s&&(".."===s?a.pop():a.push(s))}return"url('"+a.join("/")+"')"})}function absoluteToDoc(e,t){var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}var BLOCK_CLASS="rr-block";function serializeNode(e,t){switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId};case e.ELEMENT_NODE:for(var r=e.classList.contains(BLOCK_CLASS),n=e.tagName.toLowerCase(),a={},o=0,i=Array.from(e.attributes);o<i.length;o++){var l=i[o],s=l.name,u=l.value;a[s]="src"===s||"href"===s?absoluteToDoc(t,u):u}if("link"===n){var c=Array.from(t.styleSheets).find(function(t){return t.href===e.href}),d=getCssRulesString(c);d&&(a={_cssText:absoluteToStylesheet(d,c.href)})}if("input"===n||"textarea"===n||"select"===n){u=e.value;"radio"!==a.type&&"checkbox"!==a.type&&u?a.value=u:e.checked&&(a.checked=e.checked)}if("option"===n){var f=e.parentElement;a.value===f.value&&(a.selected=e.selected)}if(r){var p=e.getBoundingClientRect(),h=p.width,m=p.height;a.rr_width=h+"px",a.rr_height=m+"px"}return{type:NodeType.Element,tagName:n,attributes:a,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:r};case e.TEXT_NODE:var T=e.parentNode&&e.parentNode.tagName,g=e.textContent,y="STYLE"===T||void 0;return y&&g&&(g=absoluteToStylesheet(g,location.href)),"SCRIPT"===T&&(g="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:g||"",isStyle:y};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:""};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||""};default:return!1}}function serializeNodeWithId(e,t,r,n){void 0===n&&(n=!1);var a=serializeNode(e,t);if(!a)return console.warn(e,"not serialized"),null;var o=Object.assign(a,{id:genId()});e.__sn=o,r[o.id]=e;var i=!n;if(o.type===NodeType.Element&&(i=i&&!o.needBlock,delete o.needBlock),(o.type===NodeType.Document||o.type===NodeType.Element)&&i)for(var l=0,s=Array.from(e.childNodes);l<s.length;l++){var u=serializeNodeWithId(s[l],t,r);u&&o.childNodes.push(u)}return o}function snapshot(e){resetId();var t={};return[serializeNodeWithId(e,e,t),t]}var tagMap={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}var CSS_SELECTOR=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,HOVER_SELECTOR=/([^\\]):hover/g;function addHoverClass(e){return e.replace(CSS_SELECTOR,function(e,t,r){if(HOVER_SELECTOR.test(t)){var n=t.replace(HOVER_SELECTOR,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+n.replace(/^\s*/,"")+r}return e})}function buildNode(e,t){switch(e.type){case NodeType.Document:return t.implementation.createDocument(null,"",null);case NodeType.DocumentType:return t.implementation.createDocumentType(e.name,e.publicId,e.systemId);case NodeType.Element:var r=getTagName(e),n=void 0;for(var a in n=e.isSVG?t.createElementNS("http://www.w3.org/2000/svg",r):t.createElement(r),e.attributes)if(e.attributes.hasOwnProperty(a)&&!a.startsWith("rr_")){var o=e.attributes[a];o="boolean"==typeof o?"":o;var i="textarea"===r&&"value"===a,l="style"===r&&"_cssText"===a;if(l&&(o=addHoverClass(o)),i||l){var s=t.createTextNode(o);n.appendChild(s);continue}if("iframe"===r&&"src"===a)continue;try{n.setAttribute(a,o)}catch(e){}}else e.attributes.rr_width&&(n.style.width=e.attributes.rr_width),e.attributes.rr_height&&(n.style.height=e.attributes.rr_height);return n;case NodeType.Text:return t.createTextNode(e.isStyle?addHoverClass(e.textContent):e.textContent);case NodeType.CDATA:return t.createCDATASection(e.textContent);case NodeType.Comment:return t.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t,r,n){void 0===n&&(n=!1);var a=buildNode(e,t);if(!a)return null;if(e.type===NodeType.Document&&(t.close(),t.open(),a=t),a.__sn=e,r[e.id]=a,(e.type===NodeType.Document||e.type===NodeType.Element)&&!n)for(var o=0,i=e.childNodes;o<i.length;o++){var l=i[o],s=buildNodeWithSN(l,t,r);s?a.appendChild(s):console.warn("Failed to rebuild",l)}return a}function rebuild(e,t){var r={};return[buildNodeWithSN(e,t,r),r]}export{snapshot,serializeNodeWithId,resetId,rebuild,buildNodeWithSN,NodeType};
var NodeType;!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(NodeType||(NodeType={}));var _id=1;function genId(){return _id++}function resetId(){_id=1}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).reduce(function(e,t){return e+t.cssText},""):null}catch(e){return null}}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/,DATA_URI=/^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;function absoluteToStylesheet(e,t){return e.replace(URL_IN_CSS_REF,function(e,r,n,a){var o=r||n||a;if(!RELATIVE_PATH.test(o))return"url('"+o+"')";if(DATA_URI.test(o))return"url("+o+")";if("/"===o[0])return"url('"+(extractOrigin(t)+o)+"')";var i=t.split("/"),l=o.split("/");i.pop();for(var s=0,u=l;s<u.length;s++){var c=u[s];"."!==c&&(".."===c?i.pop():i.push(c))}return"url('"+i.join("/")+"')"})}function absoluteToDoc(e,t){var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}var BLOCK_CLASS="rr-block";function serializeNode(e,t){switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId};case e.ELEMENT_NODE:for(var r=e.classList.contains(BLOCK_CLASS),n=e.tagName.toLowerCase(),a={},o=0,i=Array.from(e.attributes);o<i.length;o++){var l=i[o],s=l.name,u=l.value;a[s]="src"===s||"href"===s?absoluteToDoc(t,u):"style"===s?absoluteToStylesheet(u,location.href):u}if("link"===n){var c=Array.from(t.styleSheets).find(function(t){return t.href===e.href}),d=getCssRulesString(c);d&&(a={_cssText:absoluteToStylesheet(d,c.href)})}if("input"===n||"textarea"===n||"select"===n){u=e.value;"radio"!==a.type&&"checkbox"!==a.type&&u?a.value=u:e.checked&&(a.checked=e.checked)}if("option"===n){var f=e.parentElement;a.value===f.value&&(a.selected=e.selected)}if(r){var p=e.getBoundingClientRect(),h=p.width,m=p.height;a.rr_width=h+"px",a.rr_height=m+"px"}return{type:NodeType.Element,tagName:n,attributes:a,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:r};case e.TEXT_NODE:var T=e.parentNode&&e.parentNode.tagName,y=e.textContent,g="STYLE"===T||void 0;return g&&y&&(y=absoluteToStylesheet(y,location.href)),"SCRIPT"===T&&(y="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:y||"",isStyle:g};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:""};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||""};default:return!1}}function serializeNodeWithId(e,t,r,n){void 0===n&&(n=!1);var a=serializeNode(e,t);if(!a)return console.warn(e,"not serialized"),null;var o=Object.assign(a,{id:genId()});e.__sn=o,r[o.id]=e;var i=!n;if(o.type===NodeType.Element&&(i=i&&!o.needBlock,delete o.needBlock),(o.type===NodeType.Document||o.type===NodeType.Element)&&i)for(var l=0,s=Array.from(e.childNodes);l<s.length;l++){var u=serializeNodeWithId(s[l],t,r);u&&o.childNodes.push(u)}return o}function snapshot(e){resetId();var t={};return[serializeNodeWithId(e,e,t),t]}var tagMap={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}var CSS_SELECTOR=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,HOVER_SELECTOR=/([^\\]):hover/g;function addHoverClass(e){return e.replace(CSS_SELECTOR,function(e,t,r){if(HOVER_SELECTOR.test(t)){var n=t.replace(HOVER_SELECTOR,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+n.replace(/^\s*/,"")+r}return e})}function buildNode(e,t){switch(e.type){case NodeType.Document:return t.implementation.createDocument(null,"",null);case NodeType.DocumentType:return t.implementation.createDocumentType(e.name,e.publicId,e.systemId);case NodeType.Element:var r=getTagName(e),n=void 0;for(var a in n=e.isSVG?t.createElementNS("http://www.w3.org/2000/svg",r):t.createElement(r),e.attributes)if(e.attributes.hasOwnProperty(a)&&!a.startsWith("rr_")){var o=e.attributes[a];o="boolean"==typeof o?"":o;var i="textarea"===r&&"value"===a,l="style"===r&&"_cssText"===a;if(l&&(o=addHoverClass(o)),i||l){var s=t.createTextNode(o);n.appendChild(s);continue}if("iframe"===r&&"src"===a)continue;try{n.setAttribute(a,o)}catch(e){}}else e.attributes.rr_width&&(n.style.width=e.attributes.rr_width),e.attributes.rr_height&&(n.style.height=e.attributes.rr_height);return n;case NodeType.Text:return t.createTextNode(e.isStyle?addHoverClass(e.textContent):e.textContent);case NodeType.CDATA:return t.createCDATASection(e.textContent);case NodeType.Comment:return t.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t,r,n){void 0===n&&(n=!1);var a=buildNode(e,t);if(!a)return null;if(e.type===NodeType.Document&&(t.close(),t.open(),a=t),a.__sn=e,r[e.id]=a,(e.type===NodeType.Document||e.type===NodeType.Element)&&!n)for(var o=0,i=e.childNodes;o<i.length;o++){var l=i[o],s=buildNodeWithSN(l,t,r);s?a.appendChild(s):console.warn("Failed to rebuild",l)}return a}function rebuild(e,t){var r={};return[buildNodeWithSN(e,t,r),r]}export{snapshot,serializeNodeWithId,resetId,rebuild,buildNodeWithSN,NodeType};
//# sourceMappingURL=rrweb-snapshot.min.js.map

@@ -46,7 +46,8 @@ 'use strict';

}
var URL_IN_CSS_REF = /url\((['"]|)([^'"]*)\1\)/gm;
var URL_IN_CSS_REF = /url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm;
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
var DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
function absoluteToStylesheet(cssText, href) {
return cssText.replace(URL_IN_CSS_REF, function (_1, _2, filePath) {
return cssText.replace(URL_IN_CSS_REF, function (_1, path1, path2, path3) {
var filePath = path1 || path2 || path3;
if (!RELATIVE_PATH.test(filePath)) {

@@ -111,2 +112,5 @@ return "url('" + filePath + "')";

}
else if (name === 'style') {
attributes_1[name] = absoluteToStylesheet(value, location.href);
}
else {

@@ -113,0 +117,0 @@ attributes_1[name] = value;

{
"name": "rrweb-snapshot",
"version": "0.7.1",
"version": "0.7.2",
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc