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.6.11 to 0.7.0

42

dist/rrweb-snapshot.js

@@ -47,2 +47,3 @@ var rrwebSnapshot = (function (exports) {

var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
var DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
function absoluteToStylesheet(cssText, href) {

@@ -53,2 +54,5 @@ return cssText.replace(URL_IN_CSS_REF, function (_1, _2, filePath) {

}
if (DATA_URI.test(filePath)) {
return "url(" + filePath + ")";
}
if (filePath[0] === '/') {

@@ -220,3 +224,39 @@ return "url('" + (extractOrigin(href) + filePath) + "')";

var tagMap = {
script: 'noscript'
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'
};

@@ -223,0 +263,0 @@ function getTagName(n) {

2

dist/rrweb-snapshot.min.js

@@ -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]:\\|\/\/).*/;function i(e,t){return e.replace(a,function(e,r,n){if(!o.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,i=t.split("/"),u=n.split("/");i.pop();for(var c=0,s=u;c<s.length;c++){var l=s[c];"."!==l&&(".."===l?i.pop():i.push(l))}return"url('"+i.join("/")+"')"})}function u(e,t){var r=e.createElement("a");return r.href=t,r.href}var c="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(c),a=t.tagName.toLowerCase(),o={},s=0,l=Array.from(t.attributes);s<l.length;s++){var d=l[s],p=d.name,m=d.value;o[p]="src"===p||"href"===p?u(r,m):m}if("link"===a){var y=Array.from(r.styleSheets).find(function(e){return e.href===t.href}),f=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}}(y);f&&(o={_cssText:i(f,y.href)})}if("input"===a||"textarea"===a||"select"===a){m=t.value;"radio"!==o.type&&"checkbox"!==o.type&&m?o.value=m:t.checked&&(o.checked=t.checked)}if("option"===a){var h=t.parentElement;o.value===h.value&&(o.selected=t.selected)}if(n){var T=t.getBoundingClientRect(),v=T.width,N=T.height;o.rr_width=v+"px",o.rr_height=N+"px"}return{type:e.NodeType.Element,tagName:a,attributes:o,childNodes:[],isSVG:(g=t,"svg"===g.tagName||g instanceof SVGElement||void 0),needBlock:n};case t.TEXT_NODE:var C=t.parentNode&&t.parentNode.tagName,E=t.textContent,D="STYLE"===C||void 0;return D&&E&&(E=i(E,location.href)),"SCRIPT"===C&&(E="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:E||"",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 g}function l(t,n,a,o){void 0===o&&(o=!1);var i=s(t,n);if(!i)return console.warn(t,"not serialized"),null;var u=Object.assign(i,{id:r++});t.__sn=u,a[u.id]=t;var c=!o;if(u.type===e.NodeType.Element&&(c=c&&!u.needBlock,delete u.needBlock),(u.type===e.NodeType.Document||u.type===e.NodeType.Element)&&c)for(var d=0,p=Array.from(t.childNodes);d<p.length;d++){var m=l(p[d],n,a);m&&u.childNodes.push(m)}return u}var d={script:"noscript"};var p=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,m=/([^\\]):hover/g;function y(e){return e.replace(p,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 f(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=d[e.tagName]?d[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 u="textarea"===n&&"value"===o,c="style"===n&&"_cssText"===o;if(c&&(i=y(i)),u||c){var s=r.createTextNode(i);a.appendChild(s);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?y(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 h(t,r,n,a){void 0===a&&(a=!1);var o=f(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,u=t.childNodes;i<u.length;i++){var c=u[i],s=h(c,r,n);s?o.appendChild(s):console.warn("Failed to rebuild",c)}return o}return e.snapshot=function(e){n();var t={};return[l(e,e,t),t]},e.serializeNodeWithId=l,e.resetId=n,e.rebuild=function(e,t){var r={};return[h(e,t,r),r]},e.buildNodeWithSN=h,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\((['"]|)([^'"]*)\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}({});
//# sourceMappingURL=rrweb-snapshot.min.js.map

@@ -45,2 +45,3 @@ var NodeType;

var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
var DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
function absoluteToStylesheet(cssText, href) {

@@ -51,2 +52,5 @@ return cssText.replace(URL_IN_CSS_REF, function (_1, _2, filePath) {

}
if (DATA_URI.test(filePath)) {
return "url(" + filePath + ")";
}
if (filePath[0] === '/') {

@@ -218,3 +222,39 @@ return "url('" + (extractOrigin(href) + filePath) + "')";

var tagMap = {
script: 'noscript'
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'
};

@@ -221,0 +261,0 @@ function getTagName(n) {

@@ -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]:\\|\/\/).*/;function absoluteToStylesheet(e,t){return e.replace(URL_IN_CSS_REF,function(e,r,n){if(!RELATIVE_PATH.test(n))return"url('"+n+"')";if("/"===n[0])return"url('"+(extractOrigin(t)+n)+"')";var o=t.split("/"),a=n.split("/");o.pop();for(var i=0,s=a;i<s.length;i++){var u=s[i];"."!==u&&(".."===u?o.pop():o.push(u))}return"url('"+o.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(),o={},a=0,i=Array.from(e.attributes);a<i.length;a++){var s=i[a],u=s.name,l=s.value;o[u]="src"===u||"href"===u?absoluteToDoc(t,l):l}if("link"===n){var d=Array.from(t.styleSheets).find(function(t){return t.href===e.href}),c=getCssRulesString(d);c&&(o={_cssText:absoluteToStylesheet(c,d.href)})}if("input"===n||"textarea"===n||"select"===n){l=e.value;"radio"!==o.type&&"checkbox"!==o.type&&l?o.value=l:e.checked&&(o.checked=e.checked)}if("option"===n){var p=e.parentElement;o.value===p.value&&(o.selected=e.selected)}if(r){var T=e.getBoundingClientRect(),N=T.width,y=T.height;o.rr_width=N+"px",o.rr_height=y+"px"}return{type:NodeType.Element,tagName:n,attributes:o,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:r};case e.TEXT_NODE:var h=e.parentNode&&e.parentNode.tagName,m=e.textContent,f="STYLE"===h||void 0;return f&&m&&(m=absoluteToStylesheet(m,location.href)),"SCRIPT"===h&&(m="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:m||"",isStyle:f};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 o=serializeNode(e,t);if(!o)return console.warn(e,"not serialized"),null;var a=Object.assign(o,{id:genId()});e.__sn=a,r[a.id]=e;var i=!n;if(a.type===NodeType.Element&&(i=i&&!a.needBlock,delete a.needBlock),(a.type===NodeType.Document||a.type===NodeType.Element)&&i)for(var s=0,u=Array.from(e.childNodes);s<u.length;s++){var l=serializeNodeWithId(u[s],t,r);l&&a.childNodes.push(l)}return a}function snapshot(e){resetId();var t={};return[serializeNodeWithId(e,e,t),t]}var tagMap={script:"noscript"};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 o in n=e.isSVG?t.createElementNS("http://www.w3.org/2000/svg",r):t.createElement(r),e.attributes)if(e.attributes.hasOwnProperty(o)&&!o.startsWith("rr_")){var a=e.attributes[o];a="boolean"==typeof a?"":a;var i="textarea"===r&&"value"===o,s="style"===r&&"_cssText"===o;if(s&&(a=addHoverClass(a)),i||s){var u=t.createTextNode(a);n.appendChild(u);continue}if("iframe"===r&&"src"===o)continue;try{n.setAttribute(o,a)}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 o=buildNode(e,t);if(!o)return null;if(e.type===NodeType.Document&&(t.close(),t.open(),o=t),o.__sn=e,r[e.id]=o,(e.type===NodeType.Document||e.type===NodeType.Element)&&!n)for(var a=0,i=e.childNodes;a<i.length;a++){var s=i[a],u=buildNodeWithSN(s,t,r);u?o.appendChild(u):console.warn("Failed to rebuild",s)}return o}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\((['"]|)([^'"]*)\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};
//# sourceMappingURL=rrweb-snapshot.min.js.map

@@ -48,2 +48,3 @@ 'use strict';

var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
var DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
function absoluteToStylesheet(cssText, href) {

@@ -54,2 +55,5 @@ return cssText.replace(URL_IN_CSS_REF, function (_1, _2, filePath) {

}
if (DATA_URI.test(filePath)) {
return "url(" + filePath + ")";
}
if (filePath[0] === '/') {

@@ -221,3 +225,39 @@ return "url('" + (extractOrigin(href) + filePath) + "')";

var tagMap = {
script: 'noscript'
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'
};

@@ -224,0 +264,0 @@ function getTagName(n) {

{
"name": "rrweb-snapshot",
"version": "0.6.11",
"version": "0.7.0",
"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