Comparing version 0.6.4 to 0.6.5
@@ -1006,3 +1006,3 @@ var rrweb = (function (exports) { | ||
root: document.body, | ||
loadTimeout: 10 * 1000 | ||
loadTimeout: 0 | ||
}; | ||
@@ -1061,2 +1061,3 @@ var Replayer = (function () { | ||
this.timer.clear(); | ||
this.emitter.emit('pause'); | ||
}; | ||
@@ -1082,2 +1083,3 @@ Replayer.prototype.resume = function (timeOffset) { | ||
this.timer.start(); | ||
this.emitter.emit('resume'); | ||
}; | ||
@@ -1102,9 +1104,5 @@ Replayer.prototype.setupDom = function () { | ||
event.data.source === IncrementalSource.MouseMove) { | ||
var firstOffset_1 = event.data.positions[0].timeOffset; | ||
var firstTimestamp = event.timestamp + firstOffset_1; | ||
var delay_1 = firstTimestamp - this.baselineTime; | ||
event.data.positions = event.data.positions.map(function (p) { | ||
return __assign({}, p, { timeOffset: p.timeOffset - firstOffset_1 + delay_1 }); | ||
}); | ||
return delay_1; | ||
var firstOffset = event.data.positions[0].timeOffset; | ||
var firstTimestamp = event.timestamp + firstOffset; | ||
return firstTimestamp - this.baselineTime; | ||
} | ||
@@ -1137,3 +1135,3 @@ return event.timestamp - this.baselineTime; | ||
castFn = function () { | ||
_this.applyIncremental(event.data, isSync); | ||
_this.applyIncremental(event, isSync); | ||
}; | ||
@@ -1194,4 +1192,5 @@ break; | ||
}; | ||
Replayer.prototype.applyIncremental = function (d, isSync) { | ||
Replayer.prototype.applyIncremental = function (e, isSync) { | ||
var _this = this; | ||
var d = e.data; | ||
switch (d.source) { | ||
@@ -1279,3 +1278,3 @@ case IncrementalSource.Mutation: { | ||
}, | ||
delay: p.timeOffset | ||
delay: p.timeOffset + e.timestamp - _this.baselineTime | ||
}; | ||
@@ -1301,3 +1300,5 @@ _this.timer.addAction(action); | ||
else if (d.type === MouseInteractions.Focus) { | ||
target.focus(); | ||
target.focus({ | ||
preventScroll: true | ||
}); | ||
} | ||
@@ -1304,0 +1305,0 @@ else { |
@@ -1,2 +0,2 @@ | ||
var rrweb=function(e){"use strict";var t,n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};!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"}(t||(t={}));var r=1;var o=/url\((['"]|)([^'"]*)\1\)/gm,i=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;function a(e,t){return e.replace(o,function(e,n,r){if(!i.test(r))return"url('"+r+"')";if("/"===r[0])return"url('"+(((o=t).indexOf("//")>-1?o.split("/").slice(0,3).join("/"):o.split("/")[0]).split("?")[0]+r)+"')";var o,a=t.split("/"),s=r.split("/");a.pop();for(var u=0,c=s;u<c.length;u++){var d=c[u];"."!==d&&(".."===d?a.pop():a.push(d))}return"url('"+a.join("/")+"')"})}function s(e,t){var n=e.createElement("a");return n.href=t,n.href}var u="rr-block";function c(e,n){switch(e.nodeType){case e.DOCUMENT_NODE:return{type:t.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:t.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId};case e.ELEMENT_NODE:for(var r=e.classList.contains(u),o=e.tagName.toLowerCase(),i={},c=0,d=Array.from(e.attributes);c<d.length;c++){var l=d[c],p=l.name,f=l.value;i[p]="src"===p||"href"===p?s(n,f):f}if("link"===o){var h=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),m=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}}(h);m&&(i={_cssText:a(m,h.href)})}if("input"===o||"textarea"===o||"select"===o){f=e.value;"radio"!==i.type&&"checkbox"!==i.type&&f?i.value=f:e.checked&&(i.checked=e.checked)}if("option"===o){var v=e.parentElement;i.value===v.value&&(i.selected=e.selected)}if(r){var y=e.getBoundingClientRect(),g=y.width,b=y.height;i.rr_width=g+"px",i.rr_height=b+"px"}return{type:t.Element,tagName:o,attributes:i,childNodes:[],isSVG:(I=e,"svg"===I.tagName||I instanceof SVGElement||void 0),needBlock:r};case e.TEXT_NODE:var w=e.parentNode&&e.parentNode.tagName,E=e.textContent,C="STYLE"===w||void 0;return C&&E&&(E=a(E,location.href)),"SCRIPT"===w&&(E="SCRIPT_PLACEHOLDER"),{type:t.Text,textContent:E||"",isStyle:C};case e.CDATA_SECTION_NODE:return{type:t.CDATA,textContent:""};case e.COMMENT_NODE:return{type:t.Comment,textContent:e.textContent||""};default:return!1}var I}function d(e,n,o,i){void 0===i&&(i=!1);var a=c(e,n);if(!a)return console.warn(e,"not serialized"),null;var s=Object.assign(a,{id:r++});e.__sn=s,o[s.id]=e;var u=!i;if(s.type===t.Element&&(u=u&&!s.needBlock,delete s.needBlock),(s.type===t.Document||s.type===t.Element)&&u)for(var l=0,p=Array.from(e.childNodes);l<p.length;l++){var f=d(p[l],n,o);f&&s.childNodes.push(f)}return s}function l(e){r=1;var t={};return[d(e,e,t),t]}var p={script:"noscript"};var f=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,h=/([^\\]):hover/g;function m(e){return e.replace(f,function(e,t,n){if(h.test(t)){var r=t.replace(h,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+r.replace(/^\s*/,"")+n}return e})}function v(e,n){switch(e.type){case t.Document:return n.implementation.createDocument(null,"",null);case t.DocumentType:return n.implementation.createDocumentType(e.name,e.publicId,e.systemId);case t.Element:var r=function(e){var t=p[e.tagName]?p[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(e),o=void 0;for(var i in o=e.isSVG?n.createElementNS("http://www.w3.org/2000/svg",r):n.createElement(r),e.attributes)if(e.attributes.hasOwnProperty(i)&&!i.startsWith("rr_")){var a=e.attributes[i];a="boolean"==typeof a?"":a;var s="textarea"===r&&"value"===i,u="style"===r&&"_cssText"===i;if(u&&(a=m(a)),s||u){var c=n.createTextNode(a);o.appendChild(c);continue}if("iframe"===r&&"src"===i)continue;try{o.setAttribute(i,a)}catch(e){}}else e.attributes.rr_width&&(o.style.width=e.attributes.rr_width),e.attributes.rr_height&&(o.style.height=e.attributes.rr_height);return o;case t.Text:return n.createTextNode(e.isStyle?m(e.textContent):e.textContent);case t.CDATA:return n.createCDATASection(e.textContent);case t.Comment:return n.createComment(e.textContent);default:return null}}function y(e,n,r,o){void 0===o&&(o=!1);var i=v(e,n);if(!i)return null;if(e.type===t.Document&&(n.open(),i=n),i.__sn=e,r[e.id]=i,(e.type===t.Document||e.type===t.Element)&&!o)for(var a=0,s=e.childNodes;a<s.length;a++){var u=s[a],c=y(u,n,r);c?i.appendChild(c):console.warn("Failed to rebuild",u)}return i}function g(e,t,n){void 0===n&&(n=document);var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}var b,w,E,C={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return C.map[e]||null},removeNodeFromMap:function(e){var t=e.__sn&&e.__sn.id;delete C.map[t],e.childNodes&&e.childNodes.forEach(function(e){return C.removeNodeFromMap(e)})},has:function(e){return C.map.hasOwnProperty(e)}};function I(e,t,n){void 0===n&&(n={});var r=null,o=0;return function(){var i=Date.now();o||!1!==n.leading||(o=i);var a=t-(i-o),s=this,u=arguments;a<=0||a>t?(r&&(window.clearTimeout(r),r=null),o=i,e.apply(s,u)):r||!1===n.trailing||(r=window.setTimeout(function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(s,u)},a))}}function N(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function x(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function T(e){var t=[];return Object.keys(E).filter(function(e){return Number.isNaN(Number(e))}).forEach(function(n){var r=n.toLowerCase(),o=function(t){return function(n){var r=C.getId(n.target),o=n.clientX,i=n.clientY;e({type:E[t],id:r,x:o,y:i})}}(n);t.push(g(r,o))}),function(){t.forEach(function(e){return e()})}}!function(e){e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta"}(b||(b={})),function(e){e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input"}(w||(w={})),function(e){e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove=8]="TouchMove",e[e.TouchEnd=9]="TouchEnd"}(E||(E={}));var D=["INPUT","TEXTAREA","SELECT"],S=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"]],M="rr-ignore",A=new WeakMap;function k(e){function t(e){var t=e.target;if(t&&t.tagName&&!(D.indexOf(t.tagName)<0)){var n=t.type;if("password"!==n&&!t.classList.contains(M)){var o=t.value,i=!1;"radio"!==n&&"checkbox"!==n||(i=t.checked),r(t,{text:o,isChecked:i});var a=t.name;"radio"===n&&a&&i&&document.querySelectorAll('input[type="radio"][name="'+a+'"]').forEach(function(e){e!==t&&r(e,{text:e.value,isChecked:!i})})}}}function r(t,r){var o=A.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){A.set(t,r);var i=C.getId(t);e(n({},r,{id:i}))}}var o=["input","change"].map(function(e){return g(e,t)}),i=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");return i&&i.set&&o.push.apply(o,S.map(function(e){return function e(t,n,r){var o=Object.getOwnPropertyDescriptor(t,n);return Object.defineProperty(t,n,{set:function(e){var t=this;setTimeout(function(){r.set.call(t,e)},0),o&&o.set&&o.set.call(this,e)}}),function(){return e(t,n,o||{})}}(e[0],e[1],{set:function(){t({target:this})}})})),function(){o.forEach(function(e){return e()})}}function O(e){var t,n,r=(t=e.mutationCb,(n=new MutationObserver(function(e){var n=[],r=[],o=[],i=[],a=[],s=new Set,u=function(e){s.add(e),e.childNodes.forEach(function(e){return u(e)})};e.forEach(function(e){var t=e.type,i=e.target,c=e.oldValue,d=e.addedNodes,l=e.removedNodes,p=e.attributeName;switch(t){case"characterData":(f=i.textContent)!==c&&n.push({value:f,node:i});break;case"attributes":var f;if((f=i.getAttribute(p))===c)return;var h=r.find(function(e){return e.node===i});h||(h={node:i,attributes:{}},r.push(h)),h.attributes[p]=f;case"childList":d.forEach(function(e){return u(e)}),l.forEach(function(e){s.has(e)?(s.delete(e),a.push(e)):s.has(i)&&!C.getId(e)||o.push({parentId:C.getId(i),id:C.getId(e)}),C.removeNodeFromMap(e)})}}),o=o.map(function(e){return e.parentNode&&(e.parentId=C.getId(e.parentNode),delete e.parentNode),e}),Array.from(s).forEach(function(e){var t=C.getId(e.parentNode);!t||a.some(function(t){return t===e.parentNode})||o.some(function(e){return e.id===t})?a.push(e):i.push({parentId:C.getId(e.parentNode),previousId:e.previousSibling?C.getId(e.previousSibling):e.previousSibling,nextId:e.nextSibling?C.getId(e.nextSibling):e.nextSibling,node:d(e,document,C.map,!0)})}),t({texts:n.map(function(e){return{id:C.getId(e.node),value:e.value}}).filter(function(e){return C.has(e.id)}),attributes:r.map(function(e){return{id:C.getId(e.node),attributes:e.attributes}}).filter(function(e){return C.has(e.id)}),removes:o,adds:i})})).observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n),o=function(e){var t,n=[],r=I(function(){var r=Date.now()-t;e(n.map(function(e){return e.timeOffset-=r,e})),n=[],t=null},500);return g("mousemove",I(function(e){var o=e.clientX,i=e.clientY,a=e.target;t||(t=Date.now()),n.push({x:o,y:i,id:C.getId(a),timeOffset:Date.now()-t}),r()},20,{trailing:!1}))}(e.mousemoveCb),i=T(e.mouseInteractionCb),a=function(e){return g("scroll",I(function(t){if(t.target){var n=C.getId(t.target);t.target===document?e({id:n,x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop}):e({id:n,x:t.target.scrollLeft,y:t.target.scrollTop})}},100))}(e.scrollCb),s=function(e){return g("resize",I(function(){var t=N(),n=x();e({width:Number(n),height:Number(t)})},200),window)}(e.viewportResizeCb),u=k(e.inputCb);return function(){r.disconnect(),o(),i(),a(),s(),u()}}function L(e){return n({},e,{timestamp:Date.now()})}function _(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map(function(e){e(n)}),(e["*"]||[]).slice().map(function(e){e(t,n)})}}}var F=Object.freeze({default:_}),z=function(){function e(e,t){void 0===t&&(t=[]),this.actions=t,this.config=e}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){var t;(t=this.actions).push.apply(t,e)},e.prototype.start=function(){this.actions.sort(function(e,t){return e.delay-t.delay});var e=0,t=performance.now(),n=this.actions,r=this.config;requestAnimationFrame(function o(i){for(e=i-t;n.length;){var a=n[0],s=a.delay/r.speed;if(!(e>=s))break;n.shift(),a.doAction()}n.length>0&&requestAnimationFrame(o)})},e.prototype.clear=function(){this.actions.length=0},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delay<e.delay)t=r+1;else{if(!(this.actions[r].delay>e.delay))return r;n=r-1}}return t},e}(),R=["iframe, .rr-block { background: #ccc }","noscript { display: none !important; }"],j=_||F,P={speed:1,root:document.body,loadTimeout:1e4},B=function(){function e(e,t){if(this.events=[],this.config=P,this.emitter=j(),this.baselineTime=0,e.length<2)throw new Error("Replayer need at least 2 events.");this.events=e,this.handleResize=this.handleResize.bind(this),this.timer=new z(this.config),this.setConfig(Object.assign({},t)),this.setupDom(),this.emitter.on("resize",this.handleResize)}return e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach(function(n){t.config[n]=e[n]})},e.prototype.getMetaData=function(){var e=this.events[0];return{totalTime:this.events[this.events.length-1].timestamp-e.timestamp}},e.prototype.play=function(e){void 0===e&&(e=0),this.baselineTime=this.events[0].timestamp+e;for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n],i=o.timestamp<this.baselineTime,a=this.getCastFn(o,i);i?a():t.push({doAction:a,delay:this.getDelay(o)})}this.timer.addActions(t),this.timer.start()},e.prototype.pause=function(){this.timer.clear()},e.prototype.resume=function(e){void 0===e&&(e=0),this.timer.clear();for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n];if(!(o.timestamp<this.lastPlayedEvent.timestamp||o===this.lastPlayedEvent)){var i=this.getDelay(o),a=this.getCastFn(o);t.push({doAction:a,delay:i-e})}}this.timer.addActions(t),this.timer.start()},e.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin"),this.wrapper.appendChild(this.iframe)},e.prototype.handleResize=function(e){this.iframe.width=e.width+"px",this.iframe.height=e.height+"px"},e.prototype.getDelay=function(e){if(e.type===b.IncrementalSnapshot&&e.data.source===w.MouseMove){var t=e.data.positions[0].timeOffset,r=e.timestamp+t-this.baselineTime;return e.data.positions=e.data.positions.map(function(e){return n({},e,{timeOffset:e.timeOffset-t+r})}),r}return e.timestamp-this.baselineTime},e.prototype.getCastFn=function(e,t){var n,r=this;switch(void 0===t&&(t=!1),e.type){case b.DomContentLoaded:case b.Load:break;case b.Meta:n=function(){return r.emitter.emit("resize",{width:e.data.width,height:e.data.height})};break;case b.FullSnapshot:n=function(){r.rebuildFullSnapshot(e),r.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case b.IncrementalSnapshot:n=function(){r.applyIncremental(e.data,t)}}return function(){n&&n(),r.lastPlayedEvent=e}},e.prototype.rebuildFullSnapshot=function(e){var t,n,r;C.map=(t=e.data.node,n=this.iframe.contentDocument,r={},[y(t,n,r),r])[1];var o=document.createElement("style"),i=this.iframe.contentDocument,a=i.documentElement,s=i.head;a.insertBefore(o,s);for(var u=0;u<R.length;u++)o.sheet.insertRule(R[u],u);this.waitForStylesheetLoad()},e.prototype.waitForStylesheetLoad=function(){var e=this,t=this.iframe.contentDocument.head;if(t){var n,r=new Set;t.querySelectorAll('link[rel="stylesheet"]').forEach(function(t){t.sheet||(0===r.size&&(e.pause(),e.emitter.emit("wait-stylesheet"),n=window.setTimeout(function(){e.resume(),n=-1},e.config.loadTimeout)),r.add(t),t.addEventListener("load",function(){r.delete(t),0===r.size&&-1!==n&&(e.resume(),e.emitter.emit("stylesheet-loaded"),n&&window.clearTimeout(n))}))})}},e.prototype.applyIncremental=function(e,t){var n=this;switch(e.source){case w.Mutation:e.removes.forEach(function(e){var t=C.getNode(e.id);if(t){var n=C.getNode(e.parentId);C.removeNodeFromMap(t),n&&n.removeChild(t)}});var r={};e.adds.forEach(function(e){var t=y(e.node,n.iframe.contentDocument,C.map,!0),o=C.getNode(e.parentId),i=null,a=null;e.previousId&&(i=C.getNode(e.previousId)),e.nextId&&(a=C.getNode(e.nextId)),-1!==e.previousId&&-1!==e.nextId?(i&&i.nextSibling&&i.nextSibling.parentNode?o.insertBefore(t,i.nextSibling):a&&a.parentNode?o.insertBefore(t,a):o.appendChild(t),(e.previousId||e.nextId)&&n.resolveMissingNode(r,o,t,e)):r[e.node.id]={node:t,mutation:e}}),Object.keys(r).length&&console.warn("Found unresolved missing node map",r),e.texts.forEach(function(e){C.getNode(e.id).textContent=e.value}),e.attributes.forEach(function(e){var t=C.getNode(e.id);for(var n in e.attributes)if("string"==typeof n){var r=e.attributes[n];r?t.setAttribute(n,r):t.removeAttribute(n)}});break;case w.MouseMove:t||e.positions.forEach(function(e){var t={doAction:function(){n.mouse.style.left=e.x+"px",n.mouse.style.top=e.y+"px";var t=C.getNode(e.id);t&&n.hoverElements(t)},delay:e.timeOffset};n.timer.addAction(t)});break;case w.MouseInteraction:if(-1===e.id)break;var o=new Event(E[e.type].toLowerCase()),i=C.getNode(e.id);e.type===E.Blur?i.blur():e.type===E.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):e.type===E.Focus?i.focus():i.dispatchEvent(o);break;case w.Scroll:if(-1===e.id)break;(i=C.getNode(e.id))===this.iframe.contentDocument?this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:t?"instant":"smooth"}):(i.scrollTop=e.y,i.scrollLeft=e.x);break;case w.ViewportResize:this.emitter.emit("resize",{width:e.width,height:e.height});break;case w.Input:if(-1===e.id)break;(i=C.getNode(e.id)).checked=e.isChecked,i.value=e.text}},e.prototype.resolveMissingNode=function(e,t,n,r){var o=r.previousId,i=r.nextId,a=o&&e[o],s=i&&e[i];if(a||s){var u=a||s,c=u.node,d=u.mutation;a?t.insertBefore(c,n):t.insertBefore(c,n.nextSibling),delete e[d.node.id],(d.previousId||d.nextId)&&this.resolveMissingNode(e,t,c,d)}},e.prototype.hoverElements=function(e){this.iframe.contentDocument.querySelectorAll(".\\:hover").forEach(function(e){e.classList.remove(":hover")});for(var t=e;t;)t.classList.add(":hover"),t=t.parentElement},e}();return e.record=function(e){void 0===e&&(e={});var t=e.emit;if(!t)throw new Error("emit function is required");try{var r=[];r.push(g("DOMContentLoaded",function(){t(L({type:b.DomContentLoaded,data:{}}))}));var o=function(){t(L({type:b.Meta,data:{href:window.location.href,width:x(),height:N()}}));var e=l(document),o=e[0],i=e[1];if(!o)return console.warn("Failed to snapshot the document");C.map=i,t(L({type:b.FullSnapshot,data:{node:o,initialOffset:{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}}})),r.push(O({mutationCb:function(e){return t(L({type:b.IncrementalSnapshot,data:n({source:w.Mutation},e)}))},mousemoveCb:function(e){return t(L({type:b.IncrementalSnapshot,data:{source:w.MouseMove,positions:e}}))},mouseInteractionCb:function(e){return t(L({type:b.IncrementalSnapshot,data:n({source:w.MouseInteraction},e)}))},scrollCb:function(e){return t(L({type:b.IncrementalSnapshot,data:n({source:w.Scroll},e)}))},viewportResizeCb:function(e){return t(L({type:b.IncrementalSnapshot,data:n({source:w.ViewportResize},e)}))},inputCb:function(e){return t(L({type:b.IncrementalSnapshot,data:n({source:w.Input},e)}))}}))};return"interactive"===document.readyState||"complete"===document.readyState?o():r.push(g("load",function(){t(L({type:b.Load,data:{}})),o()},window)),function(){r.forEach(function(e){return e()})}}catch(e){console.warn(e)}},e.Replayer=B,e.mirror=C,e}({}); | ||
var rrweb=function(e){"use strict";var t,n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};!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"}(t||(t={}));var r=1;var o=/url\((['"]|)([^'"]*)\1\)/gm,i=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;function a(e,t){return e.replace(o,function(e,n,r){if(!i.test(r))return"url('"+r+"')";if("/"===r[0])return"url('"+(((o=t).indexOf("//")>-1?o.split("/").slice(0,3).join("/"):o.split("/")[0]).split("?")[0]+r)+"')";var o,a=t.split("/"),s=r.split("/");a.pop();for(var u=0,c=s;u<c.length;u++){var d=c[u];"."!==d&&(".."===d?a.pop():a.push(d))}return"url('"+a.join("/")+"')"})}function s(e,t){var n=e.createElement("a");return n.href=t,n.href}var u="rr-block";function c(e,n){switch(e.nodeType){case e.DOCUMENT_NODE:return{type:t.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:t.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId};case e.ELEMENT_NODE:for(var r=e.classList.contains(u),o=e.tagName.toLowerCase(),i={},c=0,d=Array.from(e.attributes);c<d.length;c++){var l=d[c],p=l.name,m=l.value;i[p]="src"===p||"href"===p?s(n,m):m}if("link"===o){var h=Array.from(n.styleSheets).find(function(t){return t.href===e.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}}(h);f&&(i={_cssText:a(f,h.href)})}if("input"===o||"textarea"===o||"select"===o){m=e.value;"radio"!==i.type&&"checkbox"!==i.type&&m?i.value=m:e.checked&&(i.checked=e.checked)}if("option"===o){var v=e.parentElement;i.value===v.value&&(i.selected=e.selected)}if(r){var y=e.getBoundingClientRect(),g=y.width,b=y.height;i.rr_width=g+"px",i.rr_height=b+"px"}return{type:t.Element,tagName:o,attributes:i,childNodes:[],isSVG:(I=e,"svg"===I.tagName||I instanceof SVGElement||void 0),needBlock:r};case e.TEXT_NODE:var w=e.parentNode&&e.parentNode.tagName,E=e.textContent,C="STYLE"===w||void 0;return C&&E&&(E=a(E,location.href)),"SCRIPT"===w&&(E="SCRIPT_PLACEHOLDER"),{type:t.Text,textContent:E||"",isStyle:C};case e.CDATA_SECTION_NODE:return{type:t.CDATA,textContent:""};case e.COMMENT_NODE:return{type:t.Comment,textContent:e.textContent||""};default:return!1}var I}function d(e,n,o,i){void 0===i&&(i=!1);var a=c(e,n);if(!a)return console.warn(e,"not serialized"),null;var s=Object.assign(a,{id:r++});e.__sn=s,o[s.id]=e;var u=!i;if(s.type===t.Element&&(u=u&&!s.needBlock,delete s.needBlock),(s.type===t.Document||s.type===t.Element)&&u)for(var l=0,p=Array.from(e.childNodes);l<p.length;l++){var m=d(p[l],n,o);m&&s.childNodes.push(m)}return s}function l(e){r=1;var t={};return[d(e,e,t),t]}var p={script:"noscript"};var m=/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g,h=/([^\\]):hover/g;function f(e){return e.replace(m,function(e,t,n){if(h.test(t)){var r=t.replace(h,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+r.replace(/^\s*/,"")+n}return e})}function v(e,n){switch(e.type){case t.Document:return n.implementation.createDocument(null,"",null);case t.DocumentType:return n.implementation.createDocumentType(e.name,e.publicId,e.systemId);case t.Element:var r=function(e){var t=p[e.tagName]?p[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(e),o=void 0;for(var i in o=e.isSVG?n.createElementNS("http://www.w3.org/2000/svg",r):n.createElement(r),e.attributes)if(e.attributes.hasOwnProperty(i)&&!i.startsWith("rr_")){var a=e.attributes[i];a="boolean"==typeof a?"":a;var s="textarea"===r&&"value"===i,u="style"===r&&"_cssText"===i;if(u&&(a=f(a)),s||u){var c=n.createTextNode(a);o.appendChild(c);continue}if("iframe"===r&&"src"===i)continue;try{o.setAttribute(i,a)}catch(e){}}else e.attributes.rr_width&&(o.style.width=e.attributes.rr_width),e.attributes.rr_height&&(o.style.height=e.attributes.rr_height);return o;case t.Text:return n.createTextNode(e.isStyle?f(e.textContent):e.textContent);case t.CDATA:return n.createCDATASection(e.textContent);case t.Comment:return n.createComment(e.textContent);default:return null}}function y(e,n,r,o){void 0===o&&(o=!1);var i=v(e,n);if(!i)return null;if(e.type===t.Document&&(n.open(),i=n),i.__sn=e,r[e.id]=i,(e.type===t.Document||e.type===t.Element)&&!o)for(var a=0,s=e.childNodes;a<s.length;a++){var u=s[a],c=y(u,n,r);c?i.appendChild(c):console.warn("Failed to rebuild",u)}return i}function g(e,t,n){void 0===n&&(n=document);var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}var b,w,E,C={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return C.map[e]||null},removeNodeFromMap:function(e){var t=e.__sn&&e.__sn.id;delete C.map[t],e.childNodes&&e.childNodes.forEach(function(e){return C.removeNodeFromMap(e)})},has:function(e){return C.map.hasOwnProperty(e)}};function I(e,t,n){void 0===n&&(n={});var r=null,o=0;return function(){var i=Date.now();o||!1!==n.leading||(o=i);var a=t-(i-o),s=this,u=arguments;a<=0||a>t?(r&&(window.clearTimeout(r),r=null),o=i,e.apply(s,u)):r||!1===n.trailing||(r=window.setTimeout(function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(s,u)},a))}}function N(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function T(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function x(e){var t=[];return Object.keys(E).filter(function(e){return Number.isNaN(Number(e))}).forEach(function(n){var r=n.toLowerCase(),o=function(t){return function(n){var r=C.getId(n.target),o=n.clientX,i=n.clientY;e({type:E[t],id:r,x:o,y:i})}}(n);t.push(g(r,o))}),function(){t.forEach(function(e){return e()})}}!function(e){e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta"}(b||(b={})),function(e){e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input"}(w||(w={})),function(e){e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove=8]="TouchMove",e[e.TouchEnd=9]="TouchEnd"}(E||(E={}));var D=["INPUT","TEXTAREA","SELECT"],S=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"]],M="rr-ignore",A=new WeakMap;function k(e){function t(e){var t=e.target;if(t&&t.tagName&&!(D.indexOf(t.tagName)<0)){var n=t.type;if("password"!==n&&!t.classList.contains(M)){var o=t.value,i=!1;"radio"!==n&&"checkbox"!==n||(i=t.checked),r(t,{text:o,isChecked:i});var a=t.name;"radio"===n&&a&&i&&document.querySelectorAll('input[type="radio"][name="'+a+'"]').forEach(function(e){e!==t&&r(e,{text:e.value,isChecked:!i})})}}}function r(t,r){var o=A.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){A.set(t,r);var i=C.getId(t);e(n({},r,{id:i}))}}var o=["input","change"].map(function(e){return g(e,t)}),i=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");return i&&i.set&&o.push.apply(o,S.map(function(e){return function e(t,n,r){var o=Object.getOwnPropertyDescriptor(t,n);return Object.defineProperty(t,n,{set:function(e){var t=this;setTimeout(function(){r.set.call(t,e)},0),o&&o.set&&o.set.call(this,e)}}),function(){return e(t,n,o||{})}}(e[0],e[1],{set:function(){t({target:this})}})})),function(){o.forEach(function(e){return e()})}}function L(e){var t,n,r=(t=e.mutationCb,(n=new MutationObserver(function(e){var n=[],r=[],o=[],i=[],a=[],s=new Set,u=function(e){s.add(e),e.childNodes.forEach(function(e){return u(e)})};e.forEach(function(e){var t=e.type,i=e.target,c=e.oldValue,d=e.addedNodes,l=e.removedNodes,p=e.attributeName;switch(t){case"characterData":(m=i.textContent)!==c&&n.push({value:m,node:i});break;case"attributes":var m;if((m=i.getAttribute(p))===c)return;var h=r.find(function(e){return e.node===i});h||(h={node:i,attributes:{}},r.push(h)),h.attributes[p]=m;case"childList":d.forEach(function(e){return u(e)}),l.forEach(function(e){s.has(e)?(s.delete(e),a.push(e)):s.has(i)&&!C.getId(e)||o.push({parentId:C.getId(i),id:C.getId(e)}),C.removeNodeFromMap(e)})}}),o=o.map(function(e){return e.parentNode&&(e.parentId=C.getId(e.parentNode),delete e.parentNode),e}),Array.from(s).forEach(function(e){var t=C.getId(e.parentNode);!t||a.some(function(t){return t===e.parentNode})||o.some(function(e){return e.id===t})?a.push(e):i.push({parentId:C.getId(e.parentNode),previousId:e.previousSibling?C.getId(e.previousSibling):e.previousSibling,nextId:e.nextSibling?C.getId(e.nextSibling):e.nextSibling,node:d(e,document,C.map,!0)})}),t({texts:n.map(function(e){return{id:C.getId(e.node),value:e.value}}).filter(function(e){return C.has(e.id)}),attributes:r.map(function(e){return{id:C.getId(e.node),attributes:e.attributes}}).filter(function(e){return C.has(e.id)}),removes:o,adds:i})})).observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n),o=function(e){var t,n=[],r=I(function(){var r=Date.now()-t;e(n.map(function(e){return e.timeOffset-=r,e})),n=[],t=null},500);return g("mousemove",I(function(e){var o=e.clientX,i=e.clientY,a=e.target;t||(t=Date.now()),n.push({x:o,y:i,id:C.getId(a),timeOffset:Date.now()-t}),r()},20,{trailing:!1}))}(e.mousemoveCb),i=x(e.mouseInteractionCb),a=function(e){return g("scroll",I(function(t){if(t.target){var n=C.getId(t.target);t.target===document?e({id:n,x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop}):e({id:n,x:t.target.scrollLeft,y:t.target.scrollTop})}},100))}(e.scrollCb),s=function(e){return g("resize",I(function(){var t=N(),n=T();e({width:Number(n),height:Number(t)})},200),window)}(e.viewportResizeCb),u=k(e.inputCb);return function(){r.disconnect(),o(),i(),a(),s(),u()}}function O(e){return n({},e,{timestamp:Date.now()})}function _(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map(function(e){e(n)}),(e["*"]||[]).slice().map(function(e){e(t,n)})}}}var F=Object.freeze({default:_}),z=function(){function e(e,t){void 0===t&&(t=[]),this.actions=t,this.config=e}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){var t;(t=this.actions).push.apply(t,e)},e.prototype.start=function(){this.actions.sort(function(e,t){return e.delay-t.delay});var e=0,t=performance.now(),n=this.actions,r=this.config;requestAnimationFrame(function o(i){for(e=i-t;n.length;){var a=n[0],s=a.delay/r.speed;if(!(e>=s))break;n.shift(),a.doAction()}n.length>0&&requestAnimationFrame(o)})},e.prototype.clear=function(){this.actions.length=0},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delay<e.delay)t=r+1;else{if(!(this.actions[r].delay>e.delay))return r;n=r-1}}return t},e}(),R=["iframe, .rr-block { background: #ccc }","noscript { display: none !important; }"],j=_||F,P={speed:1,root:document.body,loadTimeout:0},B=function(){function e(e,t){if(this.events=[],this.config=P,this.emitter=j(),this.baselineTime=0,e.length<2)throw new Error("Replayer need at least 2 events.");this.events=e,this.handleResize=this.handleResize.bind(this),this.timer=new z(this.config),this.setConfig(Object.assign({},t)),this.setupDom(),this.emitter.on("resize",this.handleResize)}return e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach(function(n){t.config[n]=e[n]})},e.prototype.getMetaData=function(){var e=this.events[0];return{totalTime:this.events[this.events.length-1].timestamp-e.timestamp}},e.prototype.play=function(e){void 0===e&&(e=0),this.baselineTime=this.events[0].timestamp+e;for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n],i=o.timestamp<this.baselineTime,a=this.getCastFn(o,i);i?a():t.push({doAction:a,delay:this.getDelay(o)})}this.timer.addActions(t),this.timer.start()},e.prototype.pause=function(){this.timer.clear(),this.emitter.emit("pause")},e.prototype.resume=function(e){void 0===e&&(e=0),this.timer.clear();for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n];if(!(o.timestamp<this.lastPlayedEvent.timestamp||o===this.lastPlayedEvent)){var i=this.getDelay(o),a=this.getCastFn(o);t.push({doAction:a,delay:i-e})}}this.timer.addActions(t),this.timer.start(),this.emitter.emit("resume")},e.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin"),this.wrapper.appendChild(this.iframe)},e.prototype.handleResize=function(e){this.iframe.width=e.width+"px",this.iframe.height=e.height+"px"},e.prototype.getDelay=function(e){if(e.type===b.IncrementalSnapshot&&e.data.source===w.MouseMove){var t=e.data.positions[0].timeOffset;return e.timestamp+t-this.baselineTime}return e.timestamp-this.baselineTime},e.prototype.getCastFn=function(e,t){var n,r=this;switch(void 0===t&&(t=!1),e.type){case b.DomContentLoaded:case b.Load:break;case b.Meta:n=function(){return r.emitter.emit("resize",{width:e.data.width,height:e.data.height})};break;case b.FullSnapshot:n=function(){r.rebuildFullSnapshot(e),r.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case b.IncrementalSnapshot:n=function(){r.applyIncremental(e,t)}}return function(){n&&n(),r.lastPlayedEvent=e}},e.prototype.rebuildFullSnapshot=function(e){var t,n,r;C.map=(t=e.data.node,n=this.iframe.contentDocument,r={},[y(t,n,r),r])[1];var o=document.createElement("style"),i=this.iframe.contentDocument,a=i.documentElement,s=i.head;a.insertBefore(o,s);for(var u=0;u<R.length;u++)o.sheet.insertRule(R[u],u);this.waitForStylesheetLoad()},e.prototype.waitForStylesheetLoad=function(){var e=this,t=this.iframe.contentDocument.head;if(t){var n,r=new Set;t.querySelectorAll('link[rel="stylesheet"]').forEach(function(t){t.sheet||(0===r.size&&(e.pause(),e.emitter.emit("wait-stylesheet"),n=window.setTimeout(function(){e.resume(),n=-1},e.config.loadTimeout)),r.add(t),t.addEventListener("load",function(){r.delete(t),0===r.size&&-1!==n&&(e.resume(),e.emitter.emit("stylesheet-loaded"),n&&window.clearTimeout(n))}))})}},e.prototype.applyIncremental=function(e,t){var n=this,r=e.data;switch(r.source){case w.Mutation:r.removes.forEach(function(e){var t=C.getNode(e.id);if(t){var n=C.getNode(e.parentId);C.removeNodeFromMap(t),n&&n.removeChild(t)}});var o={};r.adds.forEach(function(e){var t=y(e.node,n.iframe.contentDocument,C.map,!0),r=C.getNode(e.parentId),i=null,a=null;e.previousId&&(i=C.getNode(e.previousId)),e.nextId&&(a=C.getNode(e.nextId)),-1!==e.previousId&&-1!==e.nextId?(i&&i.nextSibling&&i.nextSibling.parentNode?r.insertBefore(t,i.nextSibling):a&&a.parentNode?r.insertBefore(t,a):r.appendChild(t),(e.previousId||e.nextId)&&n.resolveMissingNode(o,r,t,e)):o[e.node.id]={node:t,mutation:e}}),Object.keys(o).length&&console.warn("Found unresolved missing node map",o),r.texts.forEach(function(e){C.getNode(e.id).textContent=e.value}),r.attributes.forEach(function(e){var t=C.getNode(e.id);for(var n in e.attributes)if("string"==typeof n){var r=e.attributes[n];r?t.setAttribute(n,r):t.removeAttribute(n)}});break;case w.MouseMove:t||r.positions.forEach(function(t){var r={doAction:function(){n.mouse.style.left=t.x+"px",n.mouse.style.top=t.y+"px";var e=C.getNode(t.id);e&&n.hoverElements(e)},delay:t.timeOffset+e.timestamp-n.baselineTime};n.timer.addAction(r)});break;case w.MouseInteraction:if(-1===r.id)break;var i=new Event(E[r.type].toLowerCase()),a=C.getNode(r.id);r.type===E.Blur?a.blur():r.type===E.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):r.type===E.Focus?a.focus({preventScroll:!0}):a.dispatchEvent(i);break;case w.Scroll:if(-1===r.id)break;(a=C.getNode(r.id))===this.iframe.contentDocument?this.iframe.contentWindow.scrollTo({top:r.y,left:r.x,behavior:t?"instant":"smooth"}):(a.scrollTop=r.y,a.scrollLeft=r.x);break;case w.ViewportResize:this.emitter.emit("resize",{width:r.width,height:r.height});break;case w.Input:if(-1===r.id)break;(a=C.getNode(r.id)).checked=r.isChecked,a.value=r.text}},e.prototype.resolveMissingNode=function(e,t,n,r){var o=r.previousId,i=r.nextId,a=o&&e[o],s=i&&e[i];if(a||s){var u=a||s,c=u.node,d=u.mutation;a?t.insertBefore(c,n):t.insertBefore(c,n.nextSibling),delete e[d.node.id],(d.previousId||d.nextId)&&this.resolveMissingNode(e,t,c,d)}},e.prototype.hoverElements=function(e){this.iframe.contentDocument.querySelectorAll(".\\:hover").forEach(function(e){e.classList.remove(":hover")});for(var t=e;t;)t.classList.add(":hover"),t=t.parentElement},e}();return e.record=function(e){void 0===e&&(e={});var t=e.emit;if(!t)throw new Error("emit function is required");try{var r=[];r.push(g("DOMContentLoaded",function(){t(O({type:b.DomContentLoaded,data:{}}))}));var o=function(){t(O({type:b.Meta,data:{href:window.location.href,width:T(),height:N()}}));var e=l(document),o=e[0],i=e[1];if(!o)return console.warn("Failed to snapshot the document");C.map=i,t(O({type:b.FullSnapshot,data:{node:o,initialOffset:{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}}})),r.push(L({mutationCb:function(e){return t(O({type:b.IncrementalSnapshot,data:n({source:w.Mutation},e)}))},mousemoveCb:function(e){return t(O({type:b.IncrementalSnapshot,data:{source:w.MouseMove,positions:e}}))},mouseInteractionCb:function(e){return t(O({type:b.IncrementalSnapshot,data:n({source:w.MouseInteraction},e)}))},scrollCb:function(e){return t(O({type:b.IncrementalSnapshot,data:n({source:w.Scroll},e)}))},viewportResizeCb:function(e){return t(O({type:b.IncrementalSnapshot,data:n({source:w.ViewportResize},e)}))},inputCb:function(e){return t(O({type:b.IncrementalSnapshot,data:n({source:w.Input},e)}))}}))};return"interactive"===document.readyState||"complete"===document.readyState?o():r.push(g("load",function(){t(O({type:b.Load,data:{}})),o()},window)),function(){r.forEach(function(e){return e()})}}catch(e){console.warn(e)}},e.Replayer=B,e.mirror=C,e}({}); | ||
//# sourceMappingURL=rrweb.min.js.map |
@@ -1003,3 +1003,3 @@ /*! ***************************************************************************** | ||
root: document.body, | ||
loadTimeout: 10 * 1000 | ||
loadTimeout: 0 | ||
}; | ||
@@ -1058,2 +1058,3 @@ var Replayer = (function () { | ||
this.timer.clear(); | ||
this.emitter.emit('pause'); | ||
}; | ||
@@ -1079,2 +1080,3 @@ Replayer.prototype.resume = function (timeOffset) { | ||
this.timer.start(); | ||
this.emitter.emit('resume'); | ||
}; | ||
@@ -1099,9 +1101,5 @@ Replayer.prototype.setupDom = function () { | ||
event.data.source === IncrementalSource.MouseMove) { | ||
var firstOffset_1 = event.data.positions[0].timeOffset; | ||
var firstTimestamp = event.timestamp + firstOffset_1; | ||
var delay_1 = firstTimestamp - this.baselineTime; | ||
event.data.positions = event.data.positions.map(function (p) { | ||
return __assign({}, p, { timeOffset: p.timeOffset - firstOffset_1 + delay_1 }); | ||
}); | ||
return delay_1; | ||
var firstOffset = event.data.positions[0].timeOffset; | ||
var firstTimestamp = event.timestamp + firstOffset; | ||
return firstTimestamp - this.baselineTime; | ||
} | ||
@@ -1134,3 +1132,3 @@ return event.timestamp - this.baselineTime; | ||
castFn = function () { | ||
_this.applyIncremental(event.data, isSync); | ||
_this.applyIncremental(event, isSync); | ||
}; | ||
@@ -1191,4 +1189,5 @@ break; | ||
}; | ||
Replayer.prototype.applyIncremental = function (d, isSync) { | ||
Replayer.prototype.applyIncremental = function (e, isSync) { | ||
var _this = this; | ||
var d = e.data; | ||
switch (d.source) { | ||
@@ -1276,3 +1275,3 @@ case IncrementalSource.Mutation: { | ||
}, | ||
delay: p.timeOffset | ||
delay: p.timeOffset + e.timestamp - _this.baselineTime | ||
}; | ||
@@ -1298,3 +1297,5 @@ _this.timer.addAction(action); | ||
else if (d.type === MouseInteractions.Focus) { | ||
target.focus(); | ||
target.focus({ | ||
preventScroll: true | ||
}); | ||
} | ||
@@ -1301,0 +1302,0 @@ else { |
@@ -1,2 +0,2 @@ | ||
var NodeType,__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};!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,n,r){if(!RELATIVE_PATH.test(r))return"url('"+r+"')";if("/"===r[0])return"url('"+(extractOrigin(t)+r)+"')";var o=t.split("/"),i=r.split("/");o.pop();for(var a=0,s=i;a<s.length;a++){var u=s[a];"."!==u&&(".."===u?o.pop():o.push(u))}return"url('"+o.join("/")+"')"})}function absoluteToDoc(e,t){var n=e.createElement("a");return n.href=t,n.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 n=e.classList.contains(BLOCK_CLASS),r=e.tagName.toLowerCase(),o={},i=0,a=Array.from(e.attributes);i<a.length;i++){var s=a[i],u=s.name,c=s.value;o[u]="src"===u||"href"===u?absoluteToDoc(t,c):c}if("link"===r){var d=Array.from(t.styleSheets).find(function(t){return t.href===e.href}),l=getCssRulesString(d);l&&(o={_cssText:absoluteToStylesheet(l,d.href)})}if("input"===r||"textarea"===r||"select"===r){c=e.value;"radio"!==o.type&&"checkbox"!==o.type&&c?o.value=c:e.checked&&(o.checked=e.checked)}if("option"===r){var p=e.parentElement;o.value===p.value&&(o.selected=e.selected)}if(n){var m=e.getBoundingClientRect(),h=m.width,f=m.height;o.rr_width=h+"px",o.rr_height=f+"px"}return{type:NodeType.Element,tagName:r,attributes:o,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:n};case e.TEXT_NODE:var v=e.parentNode&&e.parentNode.tagName,y=e.textContent,g="STYLE"===v||void 0;return g&&y&&(y=absoluteToStylesheet(y,location.href)),"SCRIPT"===v&&(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,n,r){void 0===r&&(r=!1);var o=serializeNode(e,t);if(!o)return console.warn(e,"not serialized"),null;var i=Object.assign(o,{id:genId()});e.__sn=i,n[i.id]=e;var a=!r;if(i.type===NodeType.Element&&(a=a&&!i.needBlock,delete i.needBlock),(i.type===NodeType.Document||i.type===NodeType.Element)&&a)for(var s=0,u=Array.from(e.childNodes);s<u.length;s++){var c=serializeNodeWithId(u[s],t,n);c&&i.childNodes.push(c)}return i}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,n){if(HOVER_SELECTOR.test(t)){var r=t.replace(HOVER_SELECTOR,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+r.replace(/^\s*/,"")+n}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 n=getTagName(e),r=void 0;for(var o in r=e.isSVG?t.createElementNS("http://www.w3.org/2000/svg",n):t.createElement(n),e.attributes)if(e.attributes.hasOwnProperty(o)&&!o.startsWith("rr_")){var i=e.attributes[o];i="boolean"==typeof i?"":i;var a="textarea"===n&&"value"===o,s="style"===n&&"_cssText"===o;if(s&&(i=addHoverClass(i)),a||s){var u=t.createTextNode(i);r.appendChild(u);continue}if("iframe"===n&&"src"===o)continue;try{r.setAttribute(o,i)}catch(e){}}else e.attributes.rr_width&&(r.style.width=e.attributes.rr_width),e.attributes.rr_height&&(r.style.height=e.attributes.rr_height);return r;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,n,r){void 0===r&&(r=!1);var o=buildNode(e,t);if(!o)return null;if(e.type===NodeType.Document&&(t.open(),o=t),o.__sn=e,n[e.id]=o,(e.type===NodeType.Document||e.type===NodeType.Element)&&!r)for(var i=0,a=e.childNodes;i<a.length;i++){var s=a[i],u=buildNodeWithSN(s,t,n);u?o.appendChild(u):console.warn("Failed to rebuild",s)}return o}function rebuild(e,t){var n={};return[buildNodeWithSN(e,t,n),n]}function on(e,t,n){void 0===n&&(n=document);var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}var EventType,IncrementalSource,MouseInteractions,mirror={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return mirror.map[e]||null},removeNodeFromMap:function(e){var t=e.__sn&&e.__sn.id;delete mirror.map[t],e.childNodes&&e.childNodes.forEach(function(e){return mirror.removeNodeFromMap(e)})},has:function(e){return mirror.map.hasOwnProperty(e)}};function throttle(e,t,n){void 0===n&&(n={});var r=null,o=0;return function(){var i=Date.now();o||!1!==n.leading||(o=i);var a=t-(i-o),s=this,u=arguments;a<=0||a>t?(r&&(window.clearTimeout(r),r=null),o=i,e.apply(s,u)):r||!1===n.trailing||(r=window.setTimeout(function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(s,u)},a))}}function hookSetter(e,t,n){var r=Object.getOwnPropertyDescriptor(e,t);return Object.defineProperty(e,t,{set:function(e){var t=this;setTimeout(function(){n.set.call(t,e)},0),r&&r.set&&r.set.call(this,e)}}),function(){return hookSetter(e,t,r||{})}}function getWindowHeight(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function getWindowWidth(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function initMutationObserver(e){var t=new MutationObserver(function(t){var n=[],r=[],o=[],i=[],a=[],s=new Set,u=function(e){s.add(e),e.childNodes.forEach(function(e){return u(e)})};t.forEach(function(e){var t=e.type,i=e.target,c=e.oldValue,d=e.addedNodes,l=e.removedNodes,p=e.attributeName;switch(t){case"characterData":(m=i.textContent)!==c&&n.push({value:m,node:i});break;case"attributes":var m;if((m=i.getAttribute(p))===c)return;var h=r.find(function(e){return e.node===i});h||(h={node:i,attributes:{}},r.push(h)),h.attributes[p]=m;case"childList":d.forEach(function(e){return u(e)}),l.forEach(function(e){s.has(e)?(s.delete(e),a.push(e)):s.has(i)&&!mirror.getId(e)||o.push({parentId:mirror.getId(i),id:mirror.getId(e)}),mirror.removeNodeFromMap(e)})}}),o=o.map(function(e){return e.parentNode&&(e.parentId=mirror.getId(e.parentNode),delete e.parentNode),e}),Array.from(s).forEach(function(e){var t=mirror.getId(e.parentNode);!t||a.some(function(t){return t===e.parentNode})||o.some(function(e){return e.id===t})?a.push(e):i.push({parentId:mirror.getId(e.parentNode),previousId:e.previousSibling?mirror.getId(e.previousSibling):e.previousSibling,nextId:e.nextSibling?mirror.getId(e.nextSibling):e.nextSibling,node:serializeNodeWithId(e,document,mirror.map,!0)})}),e({texts:n.map(function(e){return{id:mirror.getId(e.node),value:e.value}}).filter(function(e){return mirror.has(e.id)}),attributes:r.map(function(e){return{id:mirror.getId(e.node),attributes:e.attributes}}).filter(function(e){return mirror.has(e.id)}),removes:o,adds:i})});return t.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),t}function initMousemoveObserver(e){var t,n=[],r=throttle(function(){var r=Date.now()-t;e(n.map(function(e){return e.timeOffset-=r,e})),n=[],t=null},500);return on("mousemove",throttle(function(e){var o=e.clientX,i=e.clientY,a=e.target;t||(t=Date.now()),n.push({x:o,y:i,id:mirror.getId(a),timeOffset:Date.now()-t}),r()},20,{trailing:!1}))}function initMouseInteractionObserver(e){var t=[];return Object.keys(MouseInteractions).filter(function(e){return Number.isNaN(Number(e))}).forEach(function(n){var r=n.toLowerCase(),o=function(t){return function(n){var r=mirror.getId(n.target),o=n.clientX,i=n.clientY;e({type:MouseInteractions[t],id:r,x:o,y:i})}}(n);t.push(on(r,o))}),function(){t.forEach(function(e){return e()})}}function initScrollObserver(e){return on("scroll",throttle(function(t){if(t.target){var n=mirror.getId(t.target);t.target===document?e({id:n,x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop}):e({id:n,x:t.target.scrollLeft,y:t.target.scrollTop})}},100))}function initViewportResizeObserver(e){return on("resize",throttle(function(){var t=getWindowHeight(),n=getWindowWidth();e({width:Number(n),height:Number(t)})},200),window)}!function(e){e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta"}(EventType||(EventType={})),function(e){e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input"}(IncrementalSource||(IncrementalSource={})),function(e){e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove=8]="TouchMove",e[e.TouchEnd=9]="TouchEnd"}(MouseInteractions||(MouseInteractions={}));var INPUT_TAGS=["INPUT","TEXTAREA","SELECT"],HOOK_PROPERTIES=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"]],IGNORE_CLASS="rr-ignore",lastInputValueMap=new WeakMap;function initInputObserver(e){function t(e){var t=e.target;if(t&&t.tagName&&!(INPUT_TAGS.indexOf(t.tagName)<0)){var r=t.type;if("password"!==r&&!t.classList.contains(IGNORE_CLASS)){var o=t.value,i=!1;"radio"!==r&&"checkbox"!==r||(i=t.checked),n(t,{text:o,isChecked:i});var a=t.name;"radio"===r&&a&&i&&document.querySelectorAll('input[type="radio"][name="'+a+'"]').forEach(function(e){e!==t&&n(e,{text:e.value,isChecked:!i})})}}}function n(t,n){var r=lastInputValueMap.get(t);if(!r||r.text!==n.text||r.isChecked!==n.isChecked){lastInputValueMap.set(t,n);var o=mirror.getId(t);e(__assign({},n,{id:o}))}}var r=["input","change"].map(function(e){return on(e,t)}),o=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");return o&&o.set&&r.push.apply(r,HOOK_PROPERTIES.map(function(e){return hookSetter(e[0],e[1],{set:function(){t({target:this})}})})),function(){r.forEach(function(e){return e()})}}function initObservers(e){var t=initMutationObserver(e.mutationCb),n=initMousemoveObserver(e.mousemoveCb),r=initMouseInteractionObserver(e.mouseInteractionCb),o=initScrollObserver(e.scrollCb),i=initViewportResizeObserver(e.viewportResizeCb),a=initInputObserver(e.inputCb);return function(){t.disconnect(),n(),r(),o(),i(),a()}}function wrapEvent(e){return __assign({},e,{timestamp:Date.now()})}function record(e){void 0===e&&(e={});var t=e.emit;if(!t)throw new Error("emit function is required");try{var n=[];n.push(on("DOMContentLoaded",function(){t(wrapEvent({type:EventType.DomContentLoaded,data:{}}))}));var r=function(){t(wrapEvent({type:EventType.Meta,data:{href:window.location.href,width:getWindowWidth(),height:getWindowHeight()}}));var e=snapshot(document),r=e[0],o=e[1];if(!r)return console.warn("Failed to snapshot the document");mirror.map=o,t(wrapEvent({type:EventType.FullSnapshot,data:{node:r,initialOffset:{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}}})),n.push(initObservers({mutationCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.Mutation},e)}))},mousemoveCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:{source:IncrementalSource.MouseMove,positions:e}}))},mouseInteractionCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.MouseInteraction},e)}))},scrollCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.Scroll},e)}))},viewportResizeCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.ViewportResize},e)}))},inputCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.Input},e)}))}}))};return"interactive"===document.readyState||"complete"===document.readyState?r():n.push(on("load",function(){t(wrapEvent({type:EventType.Load,data:{}})),r()},window)),function(){n.forEach(function(e){return e()})}}catch(e){console.warn(e)}}function mitt(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map(function(e){e(n)}),(e["*"]||[]).slice().map(function(e){e(t,n)})}}}var mittProxy=Object.freeze({default:mitt}),Timer=function(){function e(e,t){void 0===t&&(t=[]),this.actions=t,this.config=e}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){var t;(t=this.actions).push.apply(t,e)},e.prototype.start=function(){this.actions.sort(function(e,t){return e.delay-t.delay});var e=0,t=performance.now(),n=this.actions,r=this.config;requestAnimationFrame(function o(i){for(e=i-t;n.length;){var a=n[0],s=a.delay/r.speed;if(!(e>=s))break;n.shift(),a.doAction()}n.length>0&&requestAnimationFrame(o)})},e.prototype.clear=function(){this.actions.length=0},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delay<e.delay)t=r+1;else{if(!(this.actions[r].delay>e.delay))return r;n=r-1}}return t},e}(),rules=["iframe, .rr-block { background: #ccc }","noscript { display: none !important; }"],mitt$1=mitt||mittProxy,defaultConfig={speed:1,root:document.body,loadTimeout:1e4},Replayer=function(){function e(e,t){if(this.events=[],this.config=defaultConfig,this.emitter=mitt$1(),this.baselineTime=0,e.length<2)throw new Error("Replayer need at least 2 events.");this.events=e,this.handleResize=this.handleResize.bind(this),this.timer=new Timer(this.config),this.setConfig(Object.assign({},t)),this.setupDom(),this.emitter.on("resize",this.handleResize)}return e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach(function(n){t.config[n]=e[n]})},e.prototype.getMetaData=function(){var e=this.events[0];return{totalTime:this.events[this.events.length-1].timestamp-e.timestamp}},e.prototype.play=function(e){void 0===e&&(e=0),this.baselineTime=this.events[0].timestamp+e;for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n],i=o.timestamp<this.baselineTime,a=this.getCastFn(o,i);i?a():t.push({doAction:a,delay:this.getDelay(o)})}this.timer.addActions(t),this.timer.start()},e.prototype.pause=function(){this.timer.clear()},e.prototype.resume=function(e){void 0===e&&(e=0),this.timer.clear();for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n];if(!(o.timestamp<this.lastPlayedEvent.timestamp||o===this.lastPlayedEvent)){var i=this.getDelay(o),a=this.getCastFn(o);t.push({doAction:a,delay:i-e})}}this.timer.addActions(t),this.timer.start()},e.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin"),this.wrapper.appendChild(this.iframe)},e.prototype.handleResize=function(e){this.iframe.width=e.width+"px",this.iframe.height=e.height+"px"},e.prototype.getDelay=function(e){if(e.type===EventType.IncrementalSnapshot&&e.data.source===IncrementalSource.MouseMove){var t=e.data.positions[0].timeOffset,n=e.timestamp+t-this.baselineTime;return e.data.positions=e.data.positions.map(function(e){return __assign({},e,{timeOffset:e.timeOffset-t+n})}),n}return e.timestamp-this.baselineTime},e.prototype.getCastFn=function(e,t){var n,r=this;switch(void 0===t&&(t=!1),e.type){case EventType.DomContentLoaded:case EventType.Load:break;case EventType.Meta:n=function(){return r.emitter.emit("resize",{width:e.data.width,height:e.data.height})};break;case EventType.FullSnapshot:n=function(){r.rebuildFullSnapshot(e),r.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case EventType.IncrementalSnapshot:n=function(){r.applyIncremental(e.data,t)}}return function(){n&&n(),r.lastPlayedEvent=e}},e.prototype.rebuildFullSnapshot=function(e){mirror.map=rebuild(e.data.node,this.iframe.contentDocument)[1];var t=document.createElement("style"),n=this.iframe.contentDocument,r=n.documentElement,o=n.head;r.insertBefore(t,o);for(var i=0;i<rules.length;i++)t.sheet.insertRule(rules[i],i);this.waitForStylesheetLoad()},e.prototype.waitForStylesheetLoad=function(){var e=this,t=this.iframe.contentDocument.head;if(t){var n,r=new Set;t.querySelectorAll('link[rel="stylesheet"]').forEach(function(t){t.sheet||(0===r.size&&(e.pause(),e.emitter.emit("wait-stylesheet"),n=window.setTimeout(function(){e.resume(),n=-1},e.config.loadTimeout)),r.add(t),t.addEventListener("load",function(){r.delete(t),0===r.size&&-1!==n&&(e.resume(),e.emitter.emit("stylesheet-loaded"),n&&window.clearTimeout(n))}))})}},e.prototype.applyIncremental=function(e,t){var n=this;switch(e.source){case IncrementalSource.Mutation:e.removes.forEach(function(e){var t=mirror.getNode(e.id);if(t){var n=mirror.getNode(e.parentId);mirror.removeNodeFromMap(t),n&&n.removeChild(t)}});var r={};e.adds.forEach(function(e){var t=buildNodeWithSN(e.node,n.iframe.contentDocument,mirror.map,!0),o=mirror.getNode(e.parentId),i=null,a=null;e.previousId&&(i=mirror.getNode(e.previousId)),e.nextId&&(a=mirror.getNode(e.nextId)),-1!==e.previousId&&-1!==e.nextId?(i&&i.nextSibling&&i.nextSibling.parentNode?o.insertBefore(t,i.nextSibling):a&&a.parentNode?o.insertBefore(t,a):o.appendChild(t),(e.previousId||e.nextId)&&n.resolveMissingNode(r,o,t,e)):r[e.node.id]={node:t,mutation:e}}),Object.keys(r).length&&console.warn("Found unresolved missing node map",r),e.texts.forEach(function(e){mirror.getNode(e.id).textContent=e.value}),e.attributes.forEach(function(e){var t=mirror.getNode(e.id);for(var n in e.attributes)if("string"==typeof n){var r=e.attributes[n];r?t.setAttribute(n,r):t.removeAttribute(n)}});break;case IncrementalSource.MouseMove:t||e.positions.forEach(function(e){var t={doAction:function(){n.mouse.style.left=e.x+"px",n.mouse.style.top=e.y+"px";var t=mirror.getNode(e.id);t&&n.hoverElements(t)},delay:e.timeOffset};n.timer.addAction(t)});break;case IncrementalSource.MouseInteraction:if(-1===e.id)break;var o=new Event(MouseInteractions[e.type].toLowerCase()),i=mirror.getNode(e.id);e.type===MouseInteractions.Blur?i.blur():e.type===MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):e.type===MouseInteractions.Focus?i.focus():i.dispatchEvent(o);break;case IncrementalSource.Scroll:if(-1===e.id)break;(i=mirror.getNode(e.id))===this.iframe.contentDocument?this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:t?"instant":"smooth"}):(i.scrollTop=e.y,i.scrollLeft=e.x);break;case IncrementalSource.ViewportResize:this.emitter.emit("resize",{width:e.width,height:e.height});break;case IncrementalSource.Input:if(-1===e.id)break;(i=mirror.getNode(e.id)).checked=e.isChecked,i.value=e.text}},e.prototype.resolveMissingNode=function(e,t,n,r){var o=r.previousId,i=r.nextId,a=o&&e[o],s=i&&e[i];if(a||s){var u=a||s,c=u.node,d=u.mutation;a?t.insertBefore(c,n):t.insertBefore(c,n.nextSibling),delete e[d.node.id],(d.previousId||d.nextId)&&this.resolveMissingNode(e,t,c,d)}},e.prototype.hoverElements=function(e){this.iframe.contentDocument.querySelectorAll(".\\:hover").forEach(function(e){e.classList.remove(":hover")});for(var t=e;t;)t.classList.add(":hover"),t=t.parentElement},e}();export{record,Replayer,mirror}; | ||
var NodeType,__assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};!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,n,r){if(!RELATIVE_PATH.test(r))return"url('"+r+"')";if("/"===r[0])return"url('"+(extractOrigin(t)+r)+"')";var o=t.split("/"),i=r.split("/");o.pop();for(var a=0,s=i;a<s.length;a++){var u=s[a];"."!==u&&(".."===u?o.pop():o.push(u))}return"url('"+o.join("/")+"')"})}function absoluteToDoc(e,t){var n=e.createElement("a");return n.href=t,n.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 n=e.classList.contains(BLOCK_CLASS),r=e.tagName.toLowerCase(),o={},i=0,a=Array.from(e.attributes);i<a.length;i++){var s=a[i],u=s.name,c=s.value;o[u]="src"===u||"href"===u?absoluteToDoc(t,c):c}if("link"===r){var d=Array.from(t.styleSheets).find(function(t){return t.href===e.href}),l=getCssRulesString(d);l&&(o={_cssText:absoluteToStylesheet(l,d.href)})}if("input"===r||"textarea"===r||"select"===r){c=e.value;"radio"!==o.type&&"checkbox"!==o.type&&c?o.value=c:e.checked&&(o.checked=e.checked)}if("option"===r){var p=e.parentElement;o.value===p.value&&(o.selected=e.selected)}if(n){var m=e.getBoundingClientRect(),h=m.width,f=m.height;o.rr_width=h+"px",o.rr_height=f+"px"}return{type:NodeType.Element,tagName:r,attributes:o,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:n};case e.TEXT_NODE:var v=e.parentNode&&e.parentNode.tagName,y=e.textContent,g="STYLE"===v||void 0;return g&&y&&(y=absoluteToStylesheet(y,location.href)),"SCRIPT"===v&&(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,n,r){void 0===r&&(r=!1);var o=serializeNode(e,t);if(!o)return console.warn(e,"not serialized"),null;var i=Object.assign(o,{id:genId()});e.__sn=i,n[i.id]=e;var a=!r;if(i.type===NodeType.Element&&(a=a&&!i.needBlock,delete i.needBlock),(i.type===NodeType.Document||i.type===NodeType.Element)&&a)for(var s=0,u=Array.from(e.childNodes);s<u.length;s++){var c=serializeNodeWithId(u[s],t,n);c&&i.childNodes.push(c)}return i}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,n){if(HOVER_SELECTOR.test(t)){var r=t.replace(HOVER_SELECTOR,"$1.\\:hover");return t.replace(/\s*$/,"")+", "+r.replace(/^\s*/,"")+n}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 n=getTagName(e),r=void 0;for(var o in r=e.isSVG?t.createElementNS("http://www.w3.org/2000/svg",n):t.createElement(n),e.attributes)if(e.attributes.hasOwnProperty(o)&&!o.startsWith("rr_")){var i=e.attributes[o];i="boolean"==typeof i?"":i;var a="textarea"===n&&"value"===o,s="style"===n&&"_cssText"===o;if(s&&(i=addHoverClass(i)),a||s){var u=t.createTextNode(i);r.appendChild(u);continue}if("iframe"===n&&"src"===o)continue;try{r.setAttribute(o,i)}catch(e){}}else e.attributes.rr_width&&(r.style.width=e.attributes.rr_width),e.attributes.rr_height&&(r.style.height=e.attributes.rr_height);return r;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,n,r){void 0===r&&(r=!1);var o=buildNode(e,t);if(!o)return null;if(e.type===NodeType.Document&&(t.open(),o=t),o.__sn=e,n[e.id]=o,(e.type===NodeType.Document||e.type===NodeType.Element)&&!r)for(var i=0,a=e.childNodes;i<a.length;i++){var s=a[i],u=buildNodeWithSN(s,t,n);u?o.appendChild(u):console.warn("Failed to rebuild",s)}return o}function rebuild(e,t){var n={};return[buildNodeWithSN(e,t,n),n]}function on(e,t,n){void 0===n&&(n=document);var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}var EventType,IncrementalSource,MouseInteractions,mirror={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return mirror.map[e]||null},removeNodeFromMap:function(e){var t=e.__sn&&e.__sn.id;delete mirror.map[t],e.childNodes&&e.childNodes.forEach(function(e){return mirror.removeNodeFromMap(e)})},has:function(e){return mirror.map.hasOwnProperty(e)}};function throttle(e,t,n){void 0===n&&(n={});var r=null,o=0;return function(){var i=Date.now();o||!1!==n.leading||(o=i);var a=t-(i-o),s=this,u=arguments;a<=0||a>t?(r&&(window.clearTimeout(r),r=null),o=i,e.apply(s,u)):r||!1===n.trailing||(r=window.setTimeout(function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(s,u)},a))}}function hookSetter(e,t,n){var r=Object.getOwnPropertyDescriptor(e,t);return Object.defineProperty(e,t,{set:function(e){var t=this;setTimeout(function(){n.set.call(t,e)},0),r&&r.set&&r.set.call(this,e)}}),function(){return hookSetter(e,t,r||{})}}function getWindowHeight(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function getWindowWidth(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function initMutationObserver(e){var t=new MutationObserver(function(t){var n=[],r=[],o=[],i=[],a=[],s=new Set,u=function(e){s.add(e),e.childNodes.forEach(function(e){return u(e)})};t.forEach(function(e){var t=e.type,i=e.target,c=e.oldValue,d=e.addedNodes,l=e.removedNodes,p=e.attributeName;switch(t){case"characterData":(m=i.textContent)!==c&&n.push({value:m,node:i});break;case"attributes":var m;if((m=i.getAttribute(p))===c)return;var h=r.find(function(e){return e.node===i});h||(h={node:i,attributes:{}},r.push(h)),h.attributes[p]=m;case"childList":d.forEach(function(e){return u(e)}),l.forEach(function(e){s.has(e)?(s.delete(e),a.push(e)):s.has(i)&&!mirror.getId(e)||o.push({parentId:mirror.getId(i),id:mirror.getId(e)}),mirror.removeNodeFromMap(e)})}}),o=o.map(function(e){return e.parentNode&&(e.parentId=mirror.getId(e.parentNode),delete e.parentNode),e}),Array.from(s).forEach(function(e){var t=mirror.getId(e.parentNode);!t||a.some(function(t){return t===e.parentNode})||o.some(function(e){return e.id===t})?a.push(e):i.push({parentId:mirror.getId(e.parentNode),previousId:e.previousSibling?mirror.getId(e.previousSibling):e.previousSibling,nextId:e.nextSibling?mirror.getId(e.nextSibling):e.nextSibling,node:serializeNodeWithId(e,document,mirror.map,!0)})}),e({texts:n.map(function(e){return{id:mirror.getId(e.node),value:e.value}}).filter(function(e){return mirror.has(e.id)}),attributes:r.map(function(e){return{id:mirror.getId(e.node),attributes:e.attributes}}).filter(function(e){return mirror.has(e.id)}),removes:o,adds:i})});return t.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),t}function initMousemoveObserver(e){var t,n=[],r=throttle(function(){var r=Date.now()-t;e(n.map(function(e){return e.timeOffset-=r,e})),n=[],t=null},500);return on("mousemove",throttle(function(e){var o=e.clientX,i=e.clientY,a=e.target;t||(t=Date.now()),n.push({x:o,y:i,id:mirror.getId(a),timeOffset:Date.now()-t}),r()},20,{trailing:!1}))}function initMouseInteractionObserver(e){var t=[];return Object.keys(MouseInteractions).filter(function(e){return Number.isNaN(Number(e))}).forEach(function(n){var r=n.toLowerCase(),o=function(t){return function(n){var r=mirror.getId(n.target),o=n.clientX,i=n.clientY;e({type:MouseInteractions[t],id:r,x:o,y:i})}}(n);t.push(on(r,o))}),function(){t.forEach(function(e){return e()})}}function initScrollObserver(e){return on("scroll",throttle(function(t){if(t.target){var n=mirror.getId(t.target);t.target===document?e({id:n,x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop}):e({id:n,x:t.target.scrollLeft,y:t.target.scrollTop})}},100))}function initViewportResizeObserver(e){return on("resize",throttle(function(){var t=getWindowHeight(),n=getWindowWidth();e({width:Number(n),height:Number(t)})},200),window)}!function(e){e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta"}(EventType||(EventType={})),function(e){e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input"}(IncrementalSource||(IncrementalSource={})),function(e){e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove=8]="TouchMove",e[e.TouchEnd=9]="TouchEnd"}(MouseInteractions||(MouseInteractions={}));var INPUT_TAGS=["INPUT","TEXTAREA","SELECT"],HOOK_PROPERTIES=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"]],IGNORE_CLASS="rr-ignore",lastInputValueMap=new WeakMap;function initInputObserver(e){function t(e){var t=e.target;if(t&&t.tagName&&!(INPUT_TAGS.indexOf(t.tagName)<0)){var r=t.type;if("password"!==r&&!t.classList.contains(IGNORE_CLASS)){var o=t.value,i=!1;"radio"!==r&&"checkbox"!==r||(i=t.checked),n(t,{text:o,isChecked:i});var a=t.name;"radio"===r&&a&&i&&document.querySelectorAll('input[type="radio"][name="'+a+'"]').forEach(function(e){e!==t&&n(e,{text:e.value,isChecked:!i})})}}}function n(t,n){var r=lastInputValueMap.get(t);if(!r||r.text!==n.text||r.isChecked!==n.isChecked){lastInputValueMap.set(t,n);var o=mirror.getId(t);e(__assign({},n,{id:o}))}}var r=["input","change"].map(function(e){return on(e,t)}),o=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");return o&&o.set&&r.push.apply(r,HOOK_PROPERTIES.map(function(e){return hookSetter(e[0],e[1],{set:function(){t({target:this})}})})),function(){r.forEach(function(e){return e()})}}function initObservers(e){var t=initMutationObserver(e.mutationCb),n=initMousemoveObserver(e.mousemoveCb),r=initMouseInteractionObserver(e.mouseInteractionCb),o=initScrollObserver(e.scrollCb),i=initViewportResizeObserver(e.viewportResizeCb),a=initInputObserver(e.inputCb);return function(){t.disconnect(),n(),r(),o(),i(),a()}}function wrapEvent(e){return __assign({},e,{timestamp:Date.now()})}function record(e){void 0===e&&(e={});var t=e.emit;if(!t)throw new Error("emit function is required");try{var n=[];n.push(on("DOMContentLoaded",function(){t(wrapEvent({type:EventType.DomContentLoaded,data:{}}))}));var r=function(){t(wrapEvent({type:EventType.Meta,data:{href:window.location.href,width:getWindowWidth(),height:getWindowHeight()}}));var e=snapshot(document),r=e[0],o=e[1];if(!r)return console.warn("Failed to snapshot the document");mirror.map=o,t(wrapEvent({type:EventType.FullSnapshot,data:{node:r,initialOffset:{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}}})),n.push(initObservers({mutationCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.Mutation},e)}))},mousemoveCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:{source:IncrementalSource.MouseMove,positions:e}}))},mouseInteractionCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.MouseInteraction},e)}))},scrollCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.Scroll},e)}))},viewportResizeCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.ViewportResize},e)}))},inputCb:function(e){return t(wrapEvent({type:EventType.IncrementalSnapshot,data:__assign({source:IncrementalSource.Input},e)}))}}))};return"interactive"===document.readyState||"complete"===document.readyState?r():n.push(on("load",function(){t(wrapEvent({type:EventType.Load,data:{}})),r()},window)),function(){n.forEach(function(e){return e()})}}catch(e){console.warn(e)}}function mitt(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map(function(e){e(n)}),(e["*"]||[]).slice().map(function(e){e(t,n)})}}}var mittProxy=Object.freeze({default:mitt}),Timer=function(){function e(e,t){void 0===t&&(t=[]),this.actions=t,this.config=e}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){var t;(t=this.actions).push.apply(t,e)},e.prototype.start=function(){this.actions.sort(function(e,t){return e.delay-t.delay});var e=0,t=performance.now(),n=this.actions,r=this.config;requestAnimationFrame(function o(i){for(e=i-t;n.length;){var a=n[0],s=a.delay/r.speed;if(!(e>=s))break;n.shift(),a.doAction()}n.length>0&&requestAnimationFrame(o)})},e.prototype.clear=function(){this.actions.length=0},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delay<e.delay)t=r+1;else{if(!(this.actions[r].delay>e.delay))return r;n=r-1}}return t},e}(),rules=["iframe, .rr-block { background: #ccc }","noscript { display: none !important; }"],mitt$1=mitt||mittProxy,defaultConfig={speed:1,root:document.body,loadTimeout:0},Replayer=function(){function e(e,t){if(this.events=[],this.config=defaultConfig,this.emitter=mitt$1(),this.baselineTime=0,e.length<2)throw new Error("Replayer need at least 2 events.");this.events=e,this.handleResize=this.handleResize.bind(this),this.timer=new Timer(this.config),this.setConfig(Object.assign({},t)),this.setupDom(),this.emitter.on("resize",this.handleResize)}return e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach(function(n){t.config[n]=e[n]})},e.prototype.getMetaData=function(){var e=this.events[0];return{totalTime:this.events[this.events.length-1].timestamp-e.timestamp}},e.prototype.play=function(e){void 0===e&&(e=0),this.baselineTime=this.events[0].timestamp+e;for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n],i=o.timestamp<this.baselineTime,a=this.getCastFn(o,i);i?a():t.push({doAction:a,delay:this.getDelay(o)})}this.timer.addActions(t),this.timer.start()},e.prototype.pause=function(){this.timer.clear(),this.emitter.emit("pause")},e.prototype.resume=function(e){void 0===e&&(e=0),this.timer.clear();for(var t=new Array,n=0,r=this.events;n<r.length;n++){var o=r[n];if(!(o.timestamp<this.lastPlayedEvent.timestamp||o===this.lastPlayedEvent)){var i=this.getDelay(o),a=this.getCastFn(o);t.push({doAction:a,delay:i-e})}}this.timer.addActions(t),this.timer.start(),this.emitter.emit("resume")},e.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin"),this.wrapper.appendChild(this.iframe)},e.prototype.handleResize=function(e){this.iframe.width=e.width+"px",this.iframe.height=e.height+"px"},e.prototype.getDelay=function(e){if(e.type===EventType.IncrementalSnapshot&&e.data.source===IncrementalSource.MouseMove){var t=e.data.positions[0].timeOffset;return e.timestamp+t-this.baselineTime}return e.timestamp-this.baselineTime},e.prototype.getCastFn=function(e,t){var n,r=this;switch(void 0===t&&(t=!1),e.type){case EventType.DomContentLoaded:case EventType.Load:break;case EventType.Meta:n=function(){return r.emitter.emit("resize",{width:e.data.width,height:e.data.height})};break;case EventType.FullSnapshot:n=function(){r.rebuildFullSnapshot(e),r.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case EventType.IncrementalSnapshot:n=function(){r.applyIncremental(e,t)}}return function(){n&&n(),r.lastPlayedEvent=e}},e.prototype.rebuildFullSnapshot=function(e){mirror.map=rebuild(e.data.node,this.iframe.contentDocument)[1];var t=document.createElement("style"),n=this.iframe.contentDocument,r=n.documentElement,o=n.head;r.insertBefore(t,o);for(var i=0;i<rules.length;i++)t.sheet.insertRule(rules[i],i);this.waitForStylesheetLoad()},e.prototype.waitForStylesheetLoad=function(){var e=this,t=this.iframe.contentDocument.head;if(t){var n,r=new Set;t.querySelectorAll('link[rel="stylesheet"]').forEach(function(t){t.sheet||(0===r.size&&(e.pause(),e.emitter.emit("wait-stylesheet"),n=window.setTimeout(function(){e.resume(),n=-1},e.config.loadTimeout)),r.add(t),t.addEventListener("load",function(){r.delete(t),0===r.size&&-1!==n&&(e.resume(),e.emitter.emit("stylesheet-loaded"),n&&window.clearTimeout(n))}))})}},e.prototype.applyIncremental=function(e,t){var n=this,r=e.data;switch(r.source){case IncrementalSource.Mutation:r.removes.forEach(function(e){var t=mirror.getNode(e.id);if(t){var n=mirror.getNode(e.parentId);mirror.removeNodeFromMap(t),n&&n.removeChild(t)}});var o={};r.adds.forEach(function(e){var t=buildNodeWithSN(e.node,n.iframe.contentDocument,mirror.map,!0),r=mirror.getNode(e.parentId),i=null,a=null;e.previousId&&(i=mirror.getNode(e.previousId)),e.nextId&&(a=mirror.getNode(e.nextId)),-1!==e.previousId&&-1!==e.nextId?(i&&i.nextSibling&&i.nextSibling.parentNode?r.insertBefore(t,i.nextSibling):a&&a.parentNode?r.insertBefore(t,a):r.appendChild(t),(e.previousId||e.nextId)&&n.resolveMissingNode(o,r,t,e)):o[e.node.id]={node:t,mutation:e}}),Object.keys(o).length&&console.warn("Found unresolved missing node map",o),r.texts.forEach(function(e){mirror.getNode(e.id).textContent=e.value}),r.attributes.forEach(function(e){var t=mirror.getNode(e.id);for(var n in e.attributes)if("string"==typeof n){var r=e.attributes[n];r?t.setAttribute(n,r):t.removeAttribute(n)}});break;case IncrementalSource.MouseMove:t||r.positions.forEach(function(t){var r={doAction:function(){n.mouse.style.left=t.x+"px",n.mouse.style.top=t.y+"px";var e=mirror.getNode(t.id);e&&n.hoverElements(e)},delay:t.timeOffset+e.timestamp-n.baselineTime};n.timer.addAction(r)});break;case IncrementalSource.MouseInteraction:if(-1===r.id)break;var i=new Event(MouseInteractions[r.type].toLowerCase()),a=mirror.getNode(r.id);r.type===MouseInteractions.Blur?a.blur():r.type===MouseInteractions.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):r.type===MouseInteractions.Focus?a.focus({preventScroll:!0}):a.dispatchEvent(i);break;case IncrementalSource.Scroll:if(-1===r.id)break;(a=mirror.getNode(r.id))===this.iframe.contentDocument?this.iframe.contentWindow.scrollTo({top:r.y,left:r.x,behavior:t?"instant":"smooth"}):(a.scrollTop=r.y,a.scrollLeft=r.x);break;case IncrementalSource.ViewportResize:this.emitter.emit("resize",{width:r.width,height:r.height});break;case IncrementalSource.Input:if(-1===r.id)break;(a=mirror.getNode(r.id)).checked=r.isChecked,a.value=r.text}},e.prototype.resolveMissingNode=function(e,t,n,r){var o=r.previousId,i=r.nextId,a=o&&e[o],s=i&&e[i];if(a||s){var u=a||s,c=u.node,d=u.mutation;a?t.insertBefore(c,n):t.insertBefore(c,n.nextSibling),delete e[d.node.id],(d.previousId||d.nextId)&&this.resolveMissingNode(e,t,c,d)}},e.prototype.hoverElements=function(e){this.iframe.contentDocument.querySelectorAll(".\\:hover").forEach(function(e){e.classList.remove(":hover")});for(var t=e;t;)t.classList.add(":hover"),t=t.parentElement},e}();export{record,Replayer,mirror}; | ||
//# sourceMappingURL=rrweb.min.js.map |
@@ -7,24 +7,1 @@ // TODO: remove this when mitt updated | ||
} | ||
declare module 'delegated-events' { | ||
type EventHandler = (event: Event) => any; | ||
type EventListenerOptions = { | ||
capture?: boolean; | ||
document?: Document; | ||
}; | ||
export function on( | ||
name: string, | ||
selector: string, | ||
handler: EventHandler, | ||
options?: EventListenerOptions, | ||
): void; | ||
export function off( | ||
name: string, | ||
selector: string, | ||
handler: EventHandler, | ||
options?: EventListenerOptions, | ||
): void; | ||
export function fire(target: EventTarget, name: string, detail?: any): void; | ||
} |
@@ -1007,3 +1007,3 @@ 'use strict'; | ||
root: document.body, | ||
loadTimeout: 10 * 1000 | ||
loadTimeout: 0 | ||
}; | ||
@@ -1062,2 +1062,3 @@ var Replayer = (function () { | ||
this.timer.clear(); | ||
this.emitter.emit('pause'); | ||
}; | ||
@@ -1083,2 +1084,3 @@ Replayer.prototype.resume = function (timeOffset) { | ||
this.timer.start(); | ||
this.emitter.emit('resume'); | ||
}; | ||
@@ -1103,9 +1105,5 @@ Replayer.prototype.setupDom = function () { | ||
event.data.source === IncrementalSource.MouseMove) { | ||
var firstOffset_1 = event.data.positions[0].timeOffset; | ||
var firstTimestamp = event.timestamp + firstOffset_1; | ||
var delay_1 = firstTimestamp - this.baselineTime; | ||
event.data.positions = event.data.positions.map(function (p) { | ||
return __assign({}, p, { timeOffset: p.timeOffset - firstOffset_1 + delay_1 }); | ||
}); | ||
return delay_1; | ||
var firstOffset = event.data.positions[0].timeOffset; | ||
var firstTimestamp = event.timestamp + firstOffset; | ||
return firstTimestamp - this.baselineTime; | ||
} | ||
@@ -1138,3 +1136,3 @@ return event.timestamp - this.baselineTime; | ||
castFn = function () { | ||
_this.applyIncremental(event.data, isSync); | ||
_this.applyIncremental(event, isSync); | ||
}; | ||
@@ -1195,4 +1193,5 @@ break; | ||
}; | ||
Replayer.prototype.applyIncremental = function (d, isSync) { | ||
Replayer.prototype.applyIncremental = function (e, isSync) { | ||
var _this = this; | ||
var d = e.data; | ||
switch (d.source) { | ||
@@ -1280,3 +1279,3 @@ case IncrementalSource.Mutation: { | ||
}, | ||
delay: p.timeOffset | ||
delay: p.timeOffset + e.timestamp - _this.baselineTime | ||
}; | ||
@@ -1302,3 +1301,5 @@ _this.timer.addAction(action); | ||
else if (d.type === MouseInteractions.Focus) { | ||
target.focus(); | ||
target.focus({ | ||
preventScroll: true | ||
}); | ||
} | ||
@@ -1305,0 +1306,0 @@ else { |
{ | ||
"name": "rrweb", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "record and replay the web", | ||
@@ -40,3 +40,2 @@ "scripts": { | ||
"@types/puppeteer": "^1.9.0", | ||
"@types/rewire": "^2.5.28", | ||
"chai": "^4.2.0", | ||
@@ -43,0 +42,0 @@ "jest-snapshot": "^23.6.0", |
Sorry, the diff of this file is not supported yet
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
17
575275
6719