Socket
Socket
Sign inDemoInstall

rrweb

Package Overview
Dependencies
8
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5

es/rrweb/packages/rrweb/src/record/processed-node-manager.js

2

dist/plugins/canvas-webrtc-record.js

@@ -1362,3 +1362,3 @@ var rrwebCanvasWebRTCRecord = (function (exports) {

isCrossOriginIframeMessageEventContent(event) {
return Boolean("type" in event.data && "data" in event.data && event.data.type === "rrweb-canvas-webrtc" && event.data.data);
return Boolean(event.data && typeof event.data === "object" && "type" in event.data && "data" in event.data && event.data.type === "rrweb-canvas-webrtc" && event.data.data);
}

@@ -1365,0 +1365,0 @@ windowPostMessageHandler(event) {

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

var rrwebCanvasWebRTCRecord=function(_){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */function g(d){const e=new Uint8Array(d);for(let t=0;t<d;t++)e[t]=Math.random()*256|0;return e}function f(){if(typeof globalThis>"u")return null;const d={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return d.RTCPeerConnection?d:null}function r(d,e){return Object.defineProperty(d,"code",{value:e,enumerable:!0,configurable:!0}),d}function p(d){return d.replace(/a=ice-options:trickle\s\n/g,"")}function y(d){console.warn(d)}class l{constructor(e={}){if(this._map=new Map,this._id=g(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||g(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||l.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},l.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:f(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(s=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(s,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(s){this.destroy(r(s,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const s=this._senderMap.get(e)||new Map;let i=s.get(t);if(!i)i=this._pc.addTrack(e,t),s.set(t,i),this._senderMap.set(e,s),this._needsNegotiation();else throw i.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,s){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const i=this._senderMap.get(e),n=i?i.get(s):null;if(!n)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),n.replaceTrack!=null?n.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const s=this._senderMap.get(e),i=s?s.get(t):null;if(!i)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(n){n.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(i):this.destroy(r(n,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=s=>{this._onChannelMessage(s)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=s=>{this.destroy(r(s,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp})},s=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp}),this.initiator||this._requestMissingTransceivers()},s=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=s=>(Object.prototype.toString.call(s.values)==="[object Array]"&&s.values.forEach(i=>{Object.assign(s,i)}),s);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(s=>{const i=[];s.forEach(n=>{i.push(t(n))}),e(null,i)},s=>e(s)):this._pc.getStats.length>0?this._pc.getStats(s=>{if(this.destroyed)return;const i=[];s.result().forEach(n=>{const o={};n.names().forEach(u=>{o[u]=n.stat(u)}),o.id=n.id,o.type=n.type,o.timestamp=n.timestamp,i.push(t(o))}),e(null,i)},s=>e(s)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,s)=>{if(this.destroyed)return;t&&(s=[]);const i={},n={},o={};let u=!1;s.forEach(a=>{(a.type==="remotecandidate"||a.type==="remote-candidate")&&(i[a.id]=a),(a.type==="localcandidate"||a.type==="local-candidate")&&(n[a.id]=a),(a.type==="candidatepair"||a.type==="candidate-pair")&&(o[a.id]=a)});const R=a=>{u=!0;let h=n[a.localCandidateId];h&&(h.ip||h.address)?(this.localAddress=h.ip||h.address,this.localPort=Number(h.port)):h&&h.ipAddress?(this.localAddress=h.ipAddress,this.localPort=Number(h.portNumber)):typeof a.googLocalAddress=="string"&&(h=a.googLocalAddress.split(":"),this.localAddress=h[0],this.localPort=Number(h[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let c=i[a.remoteCandidateId];c&&(c.ip||c.address)?(this.remoteAddress=c.ip||c.address,this.remotePort=Number(c.port)):c&&c.ipAddress?(this.remoteAddress=c.ipAddress,this.remotePort=Number(c.portNumber)):typeof a.googRemoteAddress=="string"&&(c=a.googRemoteAddress.split(":"),this.remoteAddress=c[0],this.remotePort=Number(c[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(s.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&R(o[a.selectedCandidatePairId]),(a.type==="googCandidatePair"&&a.googActiveConnection==="true"||(a.type==="candidatepair"||a.type==="candidate-pair")&&a.selected)&&R(a)}),!u&&(!Object.keys(o).length||Object.keys(n).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(h){return this.destroy(r(h,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const a=this._cb;this._cb=null,a(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(s=>s.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const s=this._map;s.has(e)||s.set(e,new Set),s.get(e).add(t)}off(e,t){const s=this._map,i=s.get(e);!i||(i.delete(t),i.size===0&&s.delete(e))}once(e,t){const s=(...i)=>{this.off(e,s),t(...i)};this.on(e,s)}emit(e,...t){const s=this._map;if(!!s.has(e))for(const i of s.get(e))try{i(...t)}catch(n){console.error(n)}}}l.WEBRTC_SUPPORT=!!f(),l.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},l.channelConfig={};const m="rrweb/canvas-webrtc@1";class C{constructor({signalSendCallback:e,peer:t}){this.peer=null,this.streamMap=new Map,this.incomingStreams=new Set,this.outgoingStreams=new Set,this.streamNodeMap=new Map,this.canvasWindowMap=new Map,this.windowPeerMap=new WeakMap,this.peerWindowMap=new WeakMap,this.signalSendCallback=e,window.addEventListener("message",this.windowPostMessageHandler.bind(this)),t&&(this.peer=t)}initPlugin(){return{name:m,getMirror:({nodeMirror:e,crossOriginIframeMirror:t})=>{this.mirror=e,this.crossOriginIframeMirror=t},options:{}}}signalReceive(e){var t;this.peer||this.setupPeer(),(t=this.peer)==null||t.signal(e)}signalReceiveFromCrossOriginIframe(e,t){this.setupPeer(t).signal(e)}startStream(e,t){var s,i;this.peer||this.setupPeer();const n={nodeId:e,streamId:t.id};(s=this.peer)==null||s.send(JSON.stringify(n)),this.outgoingStreams.has(t)||(i=this.peer)==null||i.addStream(t),this.outgoingStreams.add(t)}setupPeer(e){let t;if(e){const i=this.windowPeerMap.get(e);if(i)return i;t=new l({initiator:!1}),this.windowPeerMap.set(e,t),this.peerWindowMap.set(t,e)}else{if(this.peer)return this.peer;t=this.peer=new l({initiator:!0})}const s=i=>{if(!i)return this.peer=null;this.windowPeerMap.delete(i),this.peerWindowMap.delete(t)};return t.on("error",i=>{s(e),console.log("error",i)}),t.on("close",()=>{s(e),console.log("closing")}),t.on("signal",i=>{var n,o;this.inRootFrame()?t===this.peer?this.signalSendCallback(i):(n=this.peerWindowMap.get(t))==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*"):(o=window.top)==null||o.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*")}),t.on("connect",()=>{if(!(this.inRootFrame()&&t!==this.peer))for(const[i,n]of this.streamMap)this.startStream(i,n)}),this.inRootFrame()&&(t.on("data",i=>{try{const n=JSON.parse(i);this.streamNodeMap.set(n.streamId,n.nodeId)}catch(n){console.error("Could not parse data",n)}this.flushStreams()}),t.on("stream",i=>{this.incomingStreams.add(i),this.flushStreams()})),t}setupStream(e,t){var s;if(e===-1)return!1;let i=this.streamMap.get(t||e);if(i)return i;const n=this.mirror.getNode(e);return!n||!("captureStream"in n)?this.setupStreamInCrossOriginIframe(e,t||e):(this.inRootFrame()||(s=window.top)==null||s.postMessage({type:"rrweb-canvas-webrtc",data:{type:"i-have-canvas",rootId:t||e}},"*"),i=n.captureStream(),this.streamMap.set(t||e,i),this.setupPeer(),i)}flushStreams(){this.incomingStreams.forEach(e=>{const t=this.streamNodeMap.get(e.id);!t||this.startStream(t,e)})}inRootFrame(){return Boolean(window.top&&window.top===window)}setupStreamInCrossOriginIframe(e,t){let s=!1;return document.querySelectorAll("iframe").forEach(i=>{var n;if(s)return;const o=this.crossOriginIframeMirror.getRemoteId(i,e);o!==-1&&(s=!0,(n=i.contentWindow)==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"who-has-canvas",id:o,rootId:t}},"*"))}),s}isCrossOriginIframeMessageEventContent(e){return Boolean("type"in e.data&&"data"in e.data&&e.data.type==="rrweb-canvas-webrtc"&&e.data.data)}windowPostMessageHandler(e){if(!this.isCrossOriginIframeMessageEventContent(e))return;const{type:t}=e.data.data;if(t==="who-has-canvas"){const{id:s,rootId:i}=e.data.data;this.setupStream(s,i)}else if(t==="signal"){const{signal:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.inRootFrame()?this.signalReceiveFromCrossOriginIframe(s,i):this.signalReceive(s)}else if(t==="i-have-canvas"){const{rootId:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.canvasWindowMap.set(s,i)}}}return _.PLUGIN_NAME=m,_.RRWebPluginCanvasWebRTCRecord=C,Object.defineProperty(_,"__esModule",{value:!0}),_}({});
var rrwebCanvasWebRTCRecord=function(_){"use strict";/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */function g(d){const e=new Uint8Array(d);for(let t=0;t<d;t++)e[t]=Math.random()*256|0;return e}function f(){if(typeof globalThis>"u")return null;const d={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return d.RTCPeerConnection?d:null}function r(d,e){return Object.defineProperty(d,"code",{value:e,enumerable:!0,configurable:!0}),d}function p(d){return d.replace(/a=ice-options:trickle\s\n/g,"")}function y(d){console.warn(d)}class l{constructor(e={}){if(this._map=new Map,this._id=g(4).toString("hex").slice(0,7),this._doDebug=e.debug,this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||g(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||l.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},l.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(t=>t),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=e.trickle!==void 0?e.trickle:!0,this.allowHalfTrickle=e.allowHalfTrickle!==void 0?e.allowHalfTrickle:!1,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&typeof e.wrtc=="object"?e.wrtc:f(),!this._wrtc)throw r(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(t){this.destroy(r(t,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=t=>{this._onIceCandidate(t)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(t=>{this.destroy(r(t,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=t=>{this._setupData(t)},this.streams&&this.streams.forEach(t=>{this.addStream(t)}),this._pc.ontrack=t=>{this._onTrack(t)},this._debug("initial negotiation"),this._needsNegotiation()}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof e=="string")try{e=JSON.parse(e)}catch{e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(t=>{this._addIceCandidate(t)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(t=>{this.destroy(r(t,"ERR_SET_REMOTE_DESCRIPTION"))}),!e.sdp&&!e.candidate&&!e.renegotiate&&!e.transceiverRequest&&this.destroy(r(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(e){const t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch(s=>{!t.address||t.address.endsWith(".local")?y("Ignoring unsupported ICE candidate."):this.destroy(r(s,"ERR_ADD_ICE_CANDIDATE"))})}send(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(e)}}addTransceiver(e,t){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(s){this.destroy(r(s,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:e,init:t}})}}addStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),e.getTracks().forEach(t=>{this.addTrack(t,e)})}}addTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const s=this._senderMap.get(e)||new Map;let i=s.get(t);if(!i)i=this._pc.addTrack(e,t),s.set(t,i),this._senderMap.set(e,s),this._needsNegotiation();else throw i.removed?r(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):r(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(e,t,s){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const i=this._senderMap.get(e),n=i?i.get(s):null;if(!n)throw r(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),n.replaceTrack!=null?n.replaceTrack(t):this.destroy(r(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){if(this.destroying)return;if(this.destroyed)throw r(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const s=this._senderMap.get(e),i=s?s.get(t):null;if(!i)throw r(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(n){n.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(i):this.destroy(r(n,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),e.getTracks().forEach(t=>{this.removeTrack(t,e)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,queueMicrotask(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw r(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(e){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",e&&(e.message||e)),queueMicrotask(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",e&&(e.message||e)),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}))}_setupData(e){if(!e.channel)return this.destroy(r(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=65536),this.channelName=this._channel.label,this._channel.onmessage=s=>{this._onChannelMessage(s)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=s=>{this.destroy(r(s,"ERR_DATA_CHANNEL"))};let t=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(t&&this._onChannelClose(),t=!0):t=!1},5e3)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp})},s=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(e=>{!e.mid&&e.sender.track&&!e.requested&&(e.requested=!0,this.addTransceiver(e.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(e=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(e.sdp=p(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(this.destroyed)return;const n=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:n.type,sdp:n.sdp}),this.initiator||this._requestMissingTransceivers()},s=()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))},i=n=>{this.destroy(r(n,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(e).then(s).catch(i)}).catch(e=>{this.destroy(r(e,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(r(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),(e==="connected"||e==="completed")&&(this._pcReady=!0,this._maybeReady()),e==="failed"&&this.destroy(r(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),e==="closed"&&this.destroy(r(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(e){const t=s=>(Object.prototype.toString.call(s.values)==="[object Array]"&&s.values.forEach(i=>{Object.assign(s,i)}),s);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(s=>{const i=[];s.forEach(n=>{i.push(t(n))}),e(null,i)},s=>e(s)):this._pc.getStats.length>0?this._pc.getStats(s=>{if(this.destroyed)return;const i=[];s.result().forEach(n=>{const o={};n.names().forEach(u=>{o[u]=n.stat(u)}),o.id=n.id,o.type=n.type,o.timestamp=n.timestamp,i.push(t(o))}),e(null,i)},s=>e(s)):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats((t,s)=>{if(this.destroyed)return;t&&(s=[]);const i={},n={},o={};let u=!1;s.forEach(a=>{(a.type==="remotecandidate"||a.type==="remote-candidate")&&(i[a.id]=a),(a.type==="localcandidate"||a.type==="local-candidate")&&(n[a.id]=a),(a.type==="candidatepair"||a.type==="candidate-pair")&&(o[a.id]=a)});const R=a=>{u=!0;let h=n[a.localCandidateId];h&&(h.ip||h.address)?(this.localAddress=h.ip||h.address,this.localPort=Number(h.port)):h&&h.ipAddress?(this.localAddress=h.ipAddress,this.localPort=Number(h.portNumber)):typeof a.googLocalAddress=="string"&&(h=a.googLocalAddress.split(":"),this.localAddress=h[0],this.localPort=Number(h[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let c=i[a.remoteCandidateId];c&&(c.ip||c.address)?(this.remoteAddress=c.ip||c.address,this.remotePort=Number(c.port)):c&&c.ipAddress?(this.remoteAddress=c.ipAddress,this.remotePort=Number(c.portNumber)):typeof a.googRemoteAddress=="string"&&(c=a.googRemoteAddress.split(":"),this.remoteAddress=c[0],this.remotePort=Number(c[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(s.forEach(a=>{a.type==="transport"&&a.selectedCandidatePairId&&R(o[a.selectedCandidatePairId]),(a.type==="googCandidatePair"&&a.googActiveConnection==="true"||(a.type==="candidatepair"||a.type==="candidate-pair")&&a.selected)&&R(a)}),!u&&(!Object.keys(o).length||Object.keys(n).length)){setTimeout(e,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(h){return this.destroy(r(h,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const a=this._cb;this._cb=null,a(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.emit("data",t)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach(t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),!this._remoteStreams.some(s=>s.id===t.id)&&(this._remoteStreams.push(t),queueMicrotask(()=>{this._debug("on stream"),this.emit("stream",t)}))})}_debug(...e){!this._doDebug||(e[0]="["+this._id+"] "+e[0],console.log(...e))}on(e,t){const s=this._map;s.has(e)||s.set(e,new Set),s.get(e).add(t)}off(e,t){const s=this._map,i=s.get(e);!i||(i.delete(t),i.size===0&&s.delete(e))}once(e,t){const s=(...i)=>{this.off(e,s),t(...i)};this.on(e,s)}emit(e,...t){const s=this._map;if(!!s.has(e))for(const i of s.get(e))try{i(...t)}catch(n){console.error(n)}}}l.WEBRTC_SUPPORT=!!f(),l.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},l.channelConfig={};const m="rrweb/canvas-webrtc@1";class C{constructor({signalSendCallback:e,peer:t}){this.peer=null,this.streamMap=new Map,this.incomingStreams=new Set,this.outgoingStreams=new Set,this.streamNodeMap=new Map,this.canvasWindowMap=new Map,this.windowPeerMap=new WeakMap,this.peerWindowMap=new WeakMap,this.signalSendCallback=e,window.addEventListener("message",this.windowPostMessageHandler.bind(this)),t&&(this.peer=t)}initPlugin(){return{name:m,getMirror:({nodeMirror:e,crossOriginIframeMirror:t})=>{this.mirror=e,this.crossOriginIframeMirror=t},options:{}}}signalReceive(e){var t;this.peer||this.setupPeer(),(t=this.peer)==null||t.signal(e)}signalReceiveFromCrossOriginIframe(e,t){this.setupPeer(t).signal(e)}startStream(e,t){var s,i;this.peer||this.setupPeer();const n={nodeId:e,streamId:t.id};(s=this.peer)==null||s.send(JSON.stringify(n)),this.outgoingStreams.has(t)||(i=this.peer)==null||i.addStream(t),this.outgoingStreams.add(t)}setupPeer(e){let t;if(e){const i=this.windowPeerMap.get(e);if(i)return i;t=new l({initiator:!1}),this.windowPeerMap.set(e,t),this.peerWindowMap.set(t,e)}else{if(this.peer)return this.peer;t=this.peer=new l({initiator:!0})}const s=i=>{if(!i)return this.peer=null;this.windowPeerMap.delete(i),this.peerWindowMap.delete(t)};return t.on("error",i=>{s(e),console.log("error",i)}),t.on("close",()=>{s(e),console.log("closing")}),t.on("signal",i=>{var n,o;this.inRootFrame()?t===this.peer?this.signalSendCallback(i):(n=this.peerWindowMap.get(t))==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*"):(o=window.top)==null||o.postMessage({type:"rrweb-canvas-webrtc",data:{type:"signal",signal:i}},"*")}),t.on("connect",()=>{if(!(this.inRootFrame()&&t!==this.peer))for(const[i,n]of this.streamMap)this.startStream(i,n)}),this.inRootFrame()&&(t.on("data",i=>{try{const n=JSON.parse(i);this.streamNodeMap.set(n.streamId,n.nodeId)}catch(n){console.error("Could not parse data",n)}this.flushStreams()}),t.on("stream",i=>{this.incomingStreams.add(i),this.flushStreams()})),t}setupStream(e,t){var s;if(e===-1)return!1;let i=this.streamMap.get(t||e);if(i)return i;const n=this.mirror.getNode(e);return!n||!("captureStream"in n)?this.setupStreamInCrossOriginIframe(e,t||e):(this.inRootFrame()||(s=window.top)==null||s.postMessage({type:"rrweb-canvas-webrtc",data:{type:"i-have-canvas",rootId:t||e}},"*"),i=n.captureStream(),this.streamMap.set(t||e,i),this.setupPeer(),i)}flushStreams(){this.incomingStreams.forEach(e=>{const t=this.streamNodeMap.get(e.id);!t||this.startStream(t,e)})}inRootFrame(){return Boolean(window.top&&window.top===window)}setupStreamInCrossOriginIframe(e,t){let s=!1;return document.querySelectorAll("iframe").forEach(i=>{var n;if(s)return;const o=this.crossOriginIframeMirror.getRemoteId(i,e);o!==-1&&(s=!0,(n=i.contentWindow)==null||n.postMessage({type:"rrweb-canvas-webrtc",data:{type:"who-has-canvas",id:o,rootId:t}},"*"))}),s}isCrossOriginIframeMessageEventContent(e){return Boolean(e.data&&typeof e.data=="object"&&"type"in e.data&&"data"in e.data&&e.data.type==="rrweb-canvas-webrtc"&&e.data.data)}windowPostMessageHandler(e){if(!this.isCrossOriginIframeMessageEventContent(e))return;const{type:t}=e.data.data;if(t==="who-has-canvas"){const{id:s,rootId:i}=e.data.data;this.setupStream(s,i)}else if(t==="signal"){const{signal:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.inRootFrame()?this.signalReceiveFromCrossOriginIframe(s,i):this.signalReceive(s)}else if(t==="i-have-canvas"){const{rootId:s}=e.data.data,{source:i}=e;if(!i||!("self"in i))return;this.canvasWindowMap.set(s,i)}}}return _.PLUGIN_NAME=m,_.RRWebPluginCanvasWebRTCRecord=C,Object.defineProperty(_,"__esModule",{value:!0}),_}({});
//# sourceMappingURL=canvas-webrtc-record.min.js.map

@@ -383,19 +383,42 @@ var rrwebConsoleRecord = (function (exports) {

if (logOptions.level.includes("error")) {
if (window) {
const errorHandler = (event) => {
const message = event.message, error = event.error;
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
const payload = [stringify(message, logOptions.stringifyOptions)];
cb({
level: "error",
trace,
payload
});
};
window.addEventListener("error", errorHandler);
cancelHandlers.push(() => {
if (window)
window.removeEventListener("error", errorHandler);
const errorHandler = (event) => {
const message = event.message, error = event.error;
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
const payload = [stringify(message, logOptions.stringifyOptions)];
cb({
level: "error",
trace,
payload
});
}
};
win.addEventListener("error", errorHandler);
cancelHandlers.push(() => {
win.removeEventListener("error", errorHandler);
});
const unhandledrejectionHandler = (event) => {
let error;
let payload;
if (event.reason instanceof Error) {
error = event.reason;
payload = [
stringify(`Uncaught (in promise) ${error.name}: ${error.message}`, logOptions.stringifyOptions)
];
} else {
error = new Error();
payload = [
stringify("Uncaught (in promise)", logOptions.stringifyOptions),
stringify(event.reason, logOptions.stringifyOptions)
];
}
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
cb({
level: "error",
trace,
payload
});
};
win.addEventListener("unhandledrejection", unhandledrejectionHandler);
cancelHandlers.push(() => {
win.removeEventListener("unhandledrejection", unhandledrejectionHandler);
});
}

@@ -402,0 +425,0 @@ for (const levelType of logOptions.level) {

@@ -1,13 +0,13 @@

var rrwebConsoleRecord=function(N){"use strict";var y;(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"})(y||(y={}));const m=`Please stop import mirror directly. Instead of that,\r
var rrwebConsoleRecord=function(y){"use strict";var w;(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"})(w||(w={}));const h=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;let b={map:{},getId(){return console.error(m),-1},getNode(){return console.error(m),null},removeNodeFromMap(){console.error(m)},has(){return console.error(m),!1},reset(){console.error(m)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(b=new Proxy(b,{get(e,r,n){return r==="map"&&console.error(m),Reflect.get(e,r,n)}}));function C(e,r,n){try{if(!(r in e))return()=>{};const t=e[r],o=n(t);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:t}})),e[r]=o,()=>{e[r]=t}}catch{return()=>{}}}class p{constructor(r){this.fileName=r.fileName||"",this.functionName=r.functionName||"",this.lineNumber=r.lineNumber,this.columnNumber=r.columnNumber}toString(){const r=this.lineNumber||"",n=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${r}:${n})`:`${this.fileName}:${r}:${n}`}}const S=/(^|@)\S+:\d+/,L=/^\s*at .*(\S+:\d+|\(native\))/m,j=/^(eval@)?(\[native code])?$/,E={parse:function(e){if(!e)return[];if(typeof e.stacktrace<"u"||typeof e["opera#sourceloc"]<"u")return this.parseOpera(e);if(e.stack&&e.stack.match(L))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(e.indexOf(":")===-1)return[e];const r=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!r)throw new Error(`Cannot parse given url: ${e}`);return[r[1],r[2]||void 0,r[3]||void 0]},parseV8OrIE:function(e){return e.stack.split(`
`).filter(function(r){return!!r.match(L)},this).map(function(r){r.indexOf("(eval ")>-1&&(r=r.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let n=r.replace(/^\s+/,"").replace(/\(eval code/g,"(");const t=n.match(/ (\((.+):(\d+):(\d+)\)$)/);n=t?n.replace(t[0],""):n;const o=n.split(/\s+/).slice(1),c=this.extractLocation(t?t[1]:o.pop()),s=o.join(" ")||void 0,l=["eval","<anonymous>"].indexOf(c[0])>-1?void 0:c[0];return new p({functionName:s,fileName:l,lineNumber:c[1],columnNumber:c[2]})},this)},parseFFOrSafari:function(e){return e.stack.split(`
`).filter(function(r){return!r.match(j)},this).map(function(r){if(r.indexOf(" > eval")>-1&&(r=r.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),r.indexOf("@")===-1&&r.indexOf(":")===-1)return new p({functionName:r});{const n=/((.*".+"[^@]*)?[^@]*)(?:@)/,t=r.match(n),o=t&&t[1]?t[1]:void 0,c=this.extractLocation(r.replace(n,""));return new p({functionName:o,fileName:c[0],lineNumber:c[1],columnNumber:c[2]})}},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf(`
or you can use record.mirror to access the mirror instance during recording.`;let L={map:{},getId(){return console.error(h),-1},getNode(){return console.error(h),null},removeNodeFromMap(){console.error(h)},has(){return console.error(h),!1},reset(){console.error(h)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(L=new Proxy(L,{get(e,r,n){return r==="map"&&console.error(h),Reflect.get(e,r,n)}}));function S(e,r,n){try{if(!(r in e))return()=>{};const t=e[r],o=n(t);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:t}})),e[r]=o,()=>{e[r]=t}}catch{return()=>{}}}class g{constructor(r){this.fileName=r.fileName||"",this.functionName=r.functionName||"",this.lineNumber=r.lineNumber,this.columnNumber=r.columnNumber}toString(){const r=this.lineNumber||"",n=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${r}:${n})`:`${this.fileName}:${r}:${n}`}}const j=/(^|@)\S+:\d+/,E=/^\s*at .*(\S+:\d+|\(native\))/m,C=/^(eval@)?(\[native code])?$/,O={parse:function(e){if(!e)return[];if(typeof e.stacktrace<"u"||typeof e["opera#sourceloc"]<"u")return this.parseOpera(e);if(e.stack&&e.stack.match(E))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(e.indexOf(":")===-1)return[e];const r=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!r)throw new Error(`Cannot parse given url: ${e}`);return[r[1],r[2]||void 0,r[3]||void 0]},parseV8OrIE:function(e){return e.stack.split(`
`).filter(function(r){return!!r.match(E)},this).map(function(r){r.indexOf("(eval ")>-1&&(r=r.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let n=r.replace(/^\s+/,"").replace(/\(eval code/g,"(");const t=n.match(/ (\((.+):(\d+):(\d+)\)$)/);n=t?n.replace(t[0],""):n;const o=n.split(/\s+/).slice(1),s=this.extractLocation(t?t[1]:o.pop()),c=o.join(" ")||void 0,l=["eval","<anonymous>"].indexOf(s[0])>-1?void 0:s[0];return new g({functionName:c,fileName:l,lineNumber:s[1],columnNumber:s[2]})},this)},parseFFOrSafari:function(e){return e.stack.split(`
`).filter(function(r){return!r.match(C)},this).map(function(r){if(r.indexOf(" > eval")>-1&&(r=r.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),r.indexOf("@")===-1&&r.indexOf(":")===-1)return new g({functionName:r});{const n=/((.*".+"[^@]*)?[^@]*)(?:@)/,t=r.match(n),o=t&&t[1]?t[1]:void 0,s=this.extractLocation(r.replace(n,""));return new g({functionName:o,fileName:s[0],lineNumber:s[1],columnNumber:s[2]})}},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf(`
`)>-1&&e.message.split(`
`).length>e.stacktrace.split(`
`).length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){const r=/Line (\d+).*script (?:in )?(\S+)/i,n=e.message.split(`
`),t=[];for(let o=2,c=n.length;o<c;o+=2){const s=r.exec(n[o]);s&&t.push(new p({fileName:s[2],lineNumber:parseFloat(s[1])}))}return t},parseOpera10:function(e){const r=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,n=e.stacktrace.split(`
`),t=[];for(let o=0,c=n.length;o<c;o+=2){const s=r.exec(n[o]);s&&t.push(new p({functionName:s[3]||void 0,fileName:s[2],lineNumber:parseFloat(s[1])}))}return t},parseOpera11:function(e){return e.stack.split(`
`).filter(function(r){return!!r.match(S)&&!r.match(/^Error created at/)},this).map(function(r){const n=r.split("@"),t=this.extractLocation(n.pop()),o=(n.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new p({functionName:o,fileName:t[0],lineNumber:t[1],columnNumber:t[2]})},this)}};function T(e){if(!e||!e.outerHTML)return"";let r="";for(;e.parentElement;){let n=e.localName;if(!n)break;n=n.toLowerCase();const t=e.parentElement,o=[];if(t.children&&t.children.length>0)for(let c=0;c<t.children.length;c++){const s=t.children[c];s.localName&&s.localName.toLowerCase&&s.localName.toLowerCase()===n&&o.push(s)}o.length>1&&(n+=`:eq(${o.indexOf(e)})`),r=n+(r?">"+r:""),e=t}return r}function v(e){return Object.prototype.toString.call(e)==="[object Object]"}function k(e,r){if(r===0)return!0;const n=Object.keys(e);for(const t of n)if(v(e[t])&&k(e[t],r-1))return!0;return!1}function w(e,r){const n={numOfKeysLimit:50,depthOfLimit:4};Object.assign(n,r);const t=[],o=[];return JSON.stringify(e,function(l,i){if(t.length>0){const a=t.indexOf(this);~a?t.splice(a+1):t.push(this),~a?o.splice(a,1/0,l):o.push(l),~t.indexOf(i)&&(t[0]===i?i="[Circular ~]":i="[Circular ~."+o.slice(0,t.indexOf(i)).join(".")+"]")}else t.push(i);if(i===null)return i;if(i===void 0)return"undefined";if(c(i))return s(i);if(i instanceof Event){const a={};for(const u in i){const f=i[u];Array.isArray(f)?a[u]=T(f.length?f[0]:null):a[u]=f}return a}else{if(i instanceof Node)return i instanceof HTMLElement?i?i.outerHTML:"":i.nodeName;if(i instanceof Error)return i.stack?i.stack+`
End of stack for Error object`:i.name+": "+i.message}return i});function c(l){return!!(v(l)&&Object.keys(l).length>n.numOfKeysLimit||typeof l=="function"||v(l)&&k(l,n.depthOfLimit))}function s(l){let i=l.toString();return n.stringLengthLimit&&i.length>n.stringLengthLimit&&(i=`${i.slice(0,n.stringLengthLimit)}...`),i}}const x={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function P(e,r,n){const t=n?Object.assign({},x,n):x,o=t.logger;if(!o)return()=>{};let c;typeof o=="string"?c=r[o]:c=o;let s=0;const l=[];if(t.level.includes("error")&&window){const a=u=>{const f=u.message,d=u.error,h=E.parse(d).map(g=>g.toString()),O=[w(f,t.stringifyOptions)];e({level:"error",trace:h,payload:O})};window.addEventListener("error",a),l.push(()=>{window&&window.removeEventListener("error",a)})}for(const a of t.level)l.push(i(c,a));return()=>{l.forEach(a=>a())};function i(a,u){return a[u]?C(a,u,f=>(...d)=>{f.apply(this,d);try{const h=E.parse(new Error).map(g=>g.toString()).splice(1),O=d.map(g=>w(g,t.stringifyOptions));s++,s<t.lengthThreshold?e({level:u,trace:h,payload:O}):s===t.lengthThreshold&&e({level:"warn",trace:[],payload:[w("The number of log records reached the threshold.")]})}catch(h){f("rrweb logger error:",h,...d)}}):()=>{}}}const $="rrweb/console@1",_=e=>({name:$,observer:P,options:e});return N.PLUGIN_NAME=$,N.getRecordConsolePlugin=_,Object.defineProperty(N,"__esModule",{value:!0}),N}({});
`),t=[];for(let o=2,s=n.length;o<s;o+=2){const c=r.exec(n[o]);c&&t.push(new g({fileName:c[2],lineNumber:parseFloat(c[1])}))}return t},parseOpera10:function(e){const r=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,n=e.stacktrace.split(`
`),t=[];for(let o=0,s=n.length;o<s;o+=2){const c=r.exec(n[o]);c&&t.push(new g({functionName:c[3]||void 0,fileName:c[2],lineNumber:parseFloat(c[1])}))}return t},parseOpera11:function(e){return e.stack.split(`
`).filter(function(r){return!!r.match(j)&&!r.match(/^Error created at/)},this).map(function(r){const n=r.split("@"),t=this.extractLocation(n.pop()),o=(n.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new g({functionName:o,fileName:t[0],lineNumber:t[1],columnNumber:t[2]})},this)}};function T(e){if(!e||!e.outerHTML)return"";let r="";for(;e.parentElement;){let n=e.localName;if(!n)break;n=n.toLowerCase();const t=e.parentElement,o=[];if(t.children&&t.children.length>0)for(let s=0;s<t.children.length;s++){const c=t.children[s];c.localName&&c.localName.toLowerCase&&c.localName.toLowerCase()===n&&o.push(c)}o.length>1&&(n+=`:eq(${o.indexOf(e)})`),r=n+(r?">"+r:""),e=t}return r}function b(e){return Object.prototype.toString.call(e)==="[object Object]"}function x(e,r){if(r===0)return!0;const n=Object.keys(e);for(const t of n)if(b(e[t])&&x(e[t],r-1))return!0;return!1}function N(e,r){const n={numOfKeysLimit:50,depthOfLimit:4};Object.assign(n,r);const t=[],o=[];return JSON.stringify(e,function(l,i){if(t.length>0){const a=t.indexOf(this);~a?t.splice(a+1):t.push(this),~a?o.splice(a,1/0,l):o.push(l),~t.indexOf(i)&&(t[0]===i?i="[Circular ~]":i="[Circular ~."+o.slice(0,t.indexOf(i)).join(".")+"]")}else t.push(i);if(i===null)return i;if(i===void 0)return"undefined";if(s(i))return c(i);if(i instanceof Event){const a={};for(const p in i){const u=i[p];Array.isArray(u)?a[p]=T(u.length?u[0]:null):a[p]=u}return a}else{if(i instanceof Node)return i instanceof HTMLElement?i?i.outerHTML:"":i.nodeName;if(i instanceof Error)return i.stack?i.stack+`
End of stack for Error object`:i.name+": "+i.message}return i});function s(l){return!!(b(l)&&Object.keys(l).length>n.numOfKeysLimit||typeof l=="function"||b(l)&&x(l,n.depthOfLimit))}function c(l){let i=l.toString();return n.stringLengthLimit&&i.length>n.stringLengthLimit&&(i=`${i.slice(0,n.stringLengthLimit)}...`),i}}const $={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function P(e,r,n){const t=n?Object.assign({},$,n):$,o=t.logger;if(!o)return()=>{};let s;typeof o=="string"?s=r[o]:s=o;let c=0;const l=[];if(t.level.includes("error")){const a=u=>{const f=u.message,m=u.error,v=O.parse(m).map(A=>A.toString()),d=[N(f,t.stringifyOptions)];e({level:"error",trace:v,payload:d})};r.addEventListener("error",a),l.push(()=>{r.removeEventListener("error",a)});const p=u=>{let f,m;u.reason instanceof Error?(f=u.reason,m=[N(`Uncaught (in promise) ${f.name}: ${f.message}`,t.stringifyOptions)]):(f=new Error,m=[N("Uncaught (in promise)",t.stringifyOptions),N(u.reason,t.stringifyOptions)]);const v=O.parse(f).map(d=>d.toString());e({level:"error",trace:v,payload:m})};r.addEventListener("unhandledrejection",p),l.push(()=>{r.removeEventListener("unhandledrejection",p)})}for(const a of t.level)l.push(i(s,a));return()=>{l.forEach(a=>a())};function i(a,p){return a[p]?S(a,p,u=>(...f)=>{u.apply(this,f);try{const m=O.parse(new Error).map(d=>d.toString()).splice(1),v=f.map(d=>N(d,t.stringifyOptions));c++,c<t.lengthThreshold?e({level:p,trace:m,payload:v}):c===t.lengthThreshold&&e({level:"warn",trace:[],payload:[N("The number of log records reached the threshold.")]})}catch(m){u("rrweb logger error:",m,...f)}}):()=>{}}}const k="rrweb/console@1",_=e=>({name:k,observer:P,options:e});return y.PLUGIN_NAME=k,y.getRecordConsolePlugin=_,Object.defineProperty(y,"__esModule",{value:!0}),y}({});
//# sourceMappingURL=console-record.min.js.map

@@ -47,2 +47,27 @@ var rrwebRecord = (function (exports) {

class ProcessedNodeManager {
constructor() {
this.nodeMap = /* @__PURE__ */ new WeakMap();
this.periodicallyClear();
}
periodicallyClear() {
requestAnimationFrame(() => {
this.clear();
this.periodicallyClear();
});
}
inOtherBuffer(node, thisBuffer) {
const buffers = this.nodeMap.get(node);
return buffers && Array.from(buffers).some((buffer) => buffer !== thisBuffer);
}
add(node, buffer) {
this.nodeMap.set(node, (this.nodeMap.get(node) || /* @__PURE__ */ new Set()).add(buffer));
}
clear() {
this.nodeMap = /* @__PURE__ */ new WeakMap();
}
}
new ProcessedNodeManager();
/*

@@ -49,0 +74,0 @@ * base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>

var rrwebRecord=function(er){"use strict";var sr;(function(r){r[r.Document=0]="Document",r[r.DocumentType=1]="DocumentType",r[r.Element=2]="Element",r[r.Text=3]="Text",r[r.CDATA=4]="CDATA",r[r.Comment=5]="Comment"})(sr||(sr={}));const N=`Please stop import mirror directly. Instead of that,\r
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
or you can use record.mirror to access the mirror instance during recording.`;let cr={map:{},getId(){return console.error(N),-1},getNode(){return console.error(N),null},removeNodeFromMap(){console.error(N)},has(){return console.error(N),!1},reset(){console.error(N)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(cr=new Proxy(cr,{get(r,e,n){return e==="map"&&console.error(N),Reflect.get(r,e,n)}}));for(var Lr=(r=>(r[r.DomContentLoaded=0]="DomContentLoaded",r[r.Load=1]="Load",r[r.FullSnapshot=2]="FullSnapshot",r[r.IncrementalSnapshot=3]="IncrementalSnapshot",r[r.Meta=4]="Meta",r[r.Custom=5]="Custom",r[r.Plugin=6]="Plugin",r))(Lr||{}),Rr=(r=>(r[r.Mutation=0]="Mutation",r[r.MouseMove=1]="MouseMove",r[r.MouseInteraction=2]="MouseInteraction",r[r.Scroll=3]="Scroll",r[r.ViewportResize=4]="ViewportResize",r[r.Input=5]="Input",r[r.TouchMove=6]="TouchMove",r[r.MediaInteraction=7]="MediaInteraction",r[r.StyleSheetRule=8]="StyleSheetRule",r[r.CanvasMutation=9]="CanvasMutation",r[r.Font=10]="Font",r[r.Log=11]="Log",r[r.Drag=12]="Drag",r[r.StyleDeclaration=13]="StyleDeclaration",r[r.Selection=14]="Selection",r[r.AdoptedStyleSheet=15]="AdoptedStyleSheet",r))(Rr||{}),xr=(r=>(r[r.MouseUp=0]="MouseUp",r[r.MouseDown=1]="MouseDown",r[r.Click=2]="Click",r[r.ContextMenu=3]="ContextMenu",r[r.DblClick=4]="DblClick",r[r.Focus=5]="Focus",r[r.Blur=6]="Blur",r[r.TouchStart=7]="TouchStart",r[r.TouchMove_Departed=8]="TouchMove_Departed",r[r.TouchEnd=9]="TouchEnd",r[r.TouchCancel=10]="TouchCancel",r))(xr||{}),Ir=(r=>(r[r["2D"]=0]="2D",r[r.WebGL=1]="WebGL",r[r.WebGL2=2]="WebGL2",r))(Ir||{}),Er=(r=>(r[r.Play=0]="Play",r[r.Pause=1]="Pause",r[r.Seeked=2]="Seeked",r[r.VolumeChange=3]="VolumeChange",r[r.RateChange=4]="RateChange",r))(Er||{}),Or=(r=>(r.Start="start",r.Pause="pause",r.Resume="resume",r.Resize="resize",r.Finish="finish",r.FullsnapshotRebuilded="fullsnapshot-rebuilded",r.LoadStylesheetStart="load-stylesheet-start",r.LoadStylesheetEnd="load-stylesheet-end",r.SkipStart="skip-start",r.SkipEnd="skip-end",r.MouseInteraction="mouse-interaction",r.EventCast="event-cast",r.CustomEvent="custom-event",r.Flush="flush",r.StateChange="state-change",r.PlayBack="play-back",r.Destroy="destroy",r))(Or||{}),wr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pr=typeof Uint8Array>"u"?[]:new Uint8Array(256),Z=0;Z<wr.length;Z++)pr[wr.charCodeAt(Z)]=Z;var m=Uint8Array,g=Uint16Array,K=Uint32Array,ar=new m([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nr=new m([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),gr=new m([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yr=function(r,e){for(var n=new g(31),a=0;a<31;++a)n[a]=e+=1<<r[a-1];for(var o=new K(n[30]),a=1;a<30;++a)for(var t=n[a];t<n[a+1];++t)o[t]=t-n[a]<<5|a;return[n,o]},Mr=yr(ar,2),Ur=Mr[0],or=Mr[1];Ur[28]=258,or[258]=28;for(var zr=yr(nr,0),Cr=zr[1],tr=new g(32768),s=0;s<32768;++s){var U=(s&43690)>>>1|(s&21845)<<1;U=(U&52428)>>>2|(U&13107)<<2,U=(U&61680)>>>4|(U&3855)<<4,tr[s]=((U&65280)>>>8|(U&255)<<8)>>>1}for(var H=function(r,e,n){for(var a=r.length,o=0,t=new g(e);o<a;++o)++t[r[o]-1];var f=new g(e);for(o=0;o<e;++o)f[o]=f[o-1]+t[o-1]<<1;var i;if(n){i=new g(1<<e);var l=15-e;for(o=0;o<a;++o)if(r[o])for(var c=o<<4|r[o],v=e-r[o],y=f[r[o]-1]++<<v,D=y|(1<<v)-1;y<=D;++y)i[tr[y]>>>l]=c}else for(i=new g(a),o=0;o<a;++o)i[o]=tr[f[r[o]-1]++]>>>15-r[o];return i},V=new m(288),s=0;s<144;++s)V[s]=8;for(var s=144;s<256;++s)V[s]=9;for(var s=256;s<280;++s)V[s]=7;for(var s=280;s<288;++s)V[s]=8;for(var $=new m(32),s=0;s<32;++s)$[s]=5;var jr=H(V,9,0),Gr=H($,5,0),Sr=function(r){return(r/8>>0)+(r&7&&1)},mr=function(r,e,n){(e==null||e<0)&&(e=0),(n==null||n>r.length)&&(n=r.length);var a=new(r instanceof g?g:r instanceof K?K:m)(n-e);return a.set(r.subarray(e,n)),a},p=function(r,e,n){n<<=e&7;var a=e/8>>0;r[a]|=n,r[a+1]|=n>>>8},Q=function(r,e,n){n<<=e&7;var a=e/8>>0;r[a]|=n,r[a+1]|=n>>>8,r[a+2]|=n>>>16},vr=function(r,e){for(var n=[],a=0;a<r.length;++a)r[a]&&n.push({s:a,f:r[a]});var o=n.length,t=n.slice();if(!o)return[new m(0),0];if(o==1){var f=new m(n[0].s+1);return f[n[0].s]=1,[f,1]}n.sort(function(x,k){return x.f-k.f}),n.push({s:-1,f:25001});var i=n[0],l=n[1],c=0,v=1,y=2;for(n[0]={s:-1,f:i.f+l.f,l:i,r:l};v!=o-1;)i=n[n[c].f<n[y].f?c++:y++],l=n[c!=v&&n[c].f<n[y].f?c++:y++],n[v++]={s:-1,f:i.f+l.f,l:i,r:l};for(var D=t[0].s,a=1;a<o;++a)t[a].s>D&&(D=t[a].s);var M=new g(D+1),L=fr(n[v-1],M,0);if(L>e){var a=0,S=0,z=L-e,W=1<<z;for(t.sort(function(k,C){return M[C.s]-M[k.s]||k.f-C.f});a<o;++a){var R=t[a].s;if(M[R]>e)S+=W-(1<<L-M[R]),M[R]=e;else break}for(S>>>=z;S>0;){var _=t[a].s;M[_]<e?S-=1<<e-M[_]++-1:++a}for(;a>=0&&S;--a){var j=t[a].s;M[j]==e&&(--M[j],++S)}L=e}return[new m(M),L]},fr=function(r,e,n){return r.s==-1?Math.max(fr(r.l,e,n+1),fr(r.r,e,n+1)):e[r.s]=n},Dr=function(r){for(var e=r.length;e&&!r[--e];);for(var n=new g(++e),a=0,o=r[0],t=1,f=function(l){n[a++]=l},i=1;i<=e;++i)if(r[i]==o&&i!=e)++t;else{if(!o&&t>2){for(;t>138;t-=138)f(32754);t>2&&(f(t>10?t-11<<5|28690:t-3<<5|12305),t=0)}else if(t>3){for(f(o),--t;t>6;t-=6)f(8304);t>2&&(f(t-3<<5|8208),t=0)}for(;t--;)f(o);t=1,o=r[i]}return[n.subarray(0,a),e]},X=function(r,e){for(var n=0,a=0;a<e.length;++a)n+=r[a]*e[a];return n},h=function(r,e,n){var a=n.length,o=Sr(e+2);r[o]=a&255,r[o+1]=a>>>8,r[o+2]=r[o]^255,r[o+3]=r[o+1]^255;for(var t=0;t<a;++t)r[o+t+4]=n[t];return(o+4+a)*8},br=function(r,e,n,a,o,t,f,i,l,c,v){p(e,v++,n),++o[256];for(var y=vr(o,15),D=y[0],M=y[1],L=vr(t,15),S=L[0],z=L[1],W=Dr(D),R=W[0],_=W[1],j=Dr(S),x=j[0],k=j[1],C=new g(19),u=0;u<R.length;++u)C[R[u]&31]++;for(var u=0;u<x.length;++u)C[x[u]&31]++;for(var B=vr(C,7),A=B[0],rr=B[1],b=19;b>4&&!A[gr[b-1]];--b);var q=c+5<<3,F=X(o,V)+X(t,$)+f,P=X(o,D)+X(t,S)+f+14+3*b+X(C,A)+(2*C[16]+3*C[17]+7*C[18]);if(q<=F&&q<=P)return h(e,v,r.subarray(l,l+c));var I,w,d,G;if(p(e,v,1+(P<F)),v+=2,P<F){I=H(D,M,0),w=D,d=H(S,z,0),G=S;var lr=H(A,rr,0);p(e,v,_-257),p(e,v+5,k-1),p(e,v+10,b-4),v+=14;for(var u=0;u<b;++u)p(e,v+3*u,A[gr[u]]);v+=3*b;for(var E=[R,x],Y=0;Y<2;++Y)for(var J=E[Y],u=0;u<J.length;++u){var O=J[u]&31;p(e,v,lr[O]),v+=A[O],O>15&&(p(e,v,J[u]>>>5&127),v+=J[u]>>>12)}}else I=jr,w=V,d=Gr,G=$;for(var u=0;u<i;++u)if(a[u]>255){var O=a[u]>>>18&31;Q(e,v,I[O+257]),v+=w[O+257],O>7&&(p(e,v,a[u]>>>23&31),v+=ar[O]);var T=a[u]&31;Q(e,v,d[T]),v+=G[T],T>3&&(Q(e,v,a[u]>>>5&8191),v+=nr[T])}else Q(e,v,I[a[u]]),v+=w[a[u]];return Q(e,v,I[256]),v+w[256]},Vr=new K([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Wr=new m(0),Br=function(r,e,n,a,o,t){var f=r.length,i=new m(a+f+5*(1+Math.floor(f/7e3))+o),l=i.subarray(a,i.length-o),c=0;if(!e||f<8)for(var v=0;v<=f;v+=65535){var y=v+65535;y<f?c=h(l,c,r.subarray(v,y)):(l[v]=t,c=h(l,c,r.subarray(v,f)))}else{for(var D=Vr[e-1],M=D>>>13,L=D&8191,S=(1<<n)-1,z=new g(32768),W=new g(S+1),R=Math.ceil(n/3),_=2*R,j=function(ir){return(r[ir]^r[ir+1]<<R^r[ir+2]<<_)&S},x=new K(25e3),k=new g(288),C=new g(32),u=0,B=0,v=0,A=0,rr=0,b=0;v<f;++v){var q=j(v),F=v&32767,P=W[q];if(z[F]=P,W[q]=F,rr<=v){var I=f-v;if((u>7e3||A>24576)&&I>423){c=br(r,l,0,x,k,C,B,A,b,v-b,c),A=u=B=0,b=v;for(var w=0;w<286;++w)k[w]=0;for(var w=0;w<30;++w)C[w]=0}var d=2,G=0,lr=L,E=F-P&32767;if(I>2&&q==j(v-E))for(var Y=Math.min(M,I)-1,J=Math.min(32767,v),O=Math.min(258,I);E<=J&&--lr&&F!=P;){if(r[v+d]==r[v+d-E]){for(var T=0;T<O&&r[v+T]==r[v+T-E];++T);if(T>d){if(d=T,G=E,T>Y)break;for(var oe=Math.min(E,T-2),Ar=0,w=0;w<oe;++w){var ur=v-E+w+32768&32767,te=z[ur],Fr=ur-te+32768&32767;Fr>Ar&&(Ar=Fr,P=ur)}}}F=P,P=z[F],E+=F-P+32768&32767}if(G){x[A++]=268435456|or[d]<<18|Cr[G];var Pr=or[d]&31,dr=Cr[G]&31;B+=ar[Pr]+nr[dr],++k[257+Pr],++C[dr],rr=v+d,++u}else x[A++]=r[v],++k[r[v]]}}c=br(r,l,t,x,k,C,B,A,b,v-b,c),t||(c=h(l,c,Wr))}return mr(i,0,a+Sr(c)+o)},Nr=function(){var r=1,e=0;return{p:function(n){for(var a=r,o=e,t=n.length,f=0;f!=t;){for(var i=Math.min(f+5552,t);f<i;++f)a+=n[f],o+=a;a%=65521,o%=65521}r=a,e=o},d:function(){return(r>>>8<<16|(e&255)<<8|e>>>8)+((r&255)<<23)*2}}},_r=function(r,e,n,a,o){return Br(r,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+e.mem,n,a,!o)},qr=function(r,e,n){for(;n;++e)r[e]=n,n>>>=8},Jr=function(r,e){var n=e.level,a=n==0?0:n<6?1:n==9?3:2;r[0]=120,r[1]=a<<6|(a?32-2*a:1)};function Kr(r,e){e===void 0&&(e={});var n=Nr();n.p(r);var a=_r(r,e,2,4);return Jr(a,e),qr(a,a.length-4,n.d()),a}function Hr(r,e){var n=r.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new m(r.length+(r.length>>>1)),o=0,t=function(c){a[o++]=c},f=0;f<n;++f){if(o+5>a.length){var i=new m(o+8+(n-f<<1));i.set(a),a=i}var l=r.charCodeAt(f);l<128||e?t(l):l<2048?(t(192|l>>>6),t(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|r.charCodeAt(++f)&1023,t(240|l>>>18),t(128|l>>>12&63),t(128|l>>>6&63),t(128|l&63)):(t(224|l>>>12),t(128|l>>>6&63),t(128|l&63))}return mr(a,0,o)}function Qr(r,e){var n="";if(!e&&typeof TextDecoder<"u")return new TextDecoder().decode(r);for(var a=0;a<r.length;){var o=r[a++];o<128||e?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((o&31)<<6|r[a++]&63):o<240?n+=String.fromCharCode((o&15)<<12|(r[a++]&63)<<6|r[a++]&63):(o=((o&15)<<18|(r[a++]&63)<<12|(r[a++]&63)<<6|r[a++]&63)-65536,n+=String.fromCharCode(55296|o>>10,56320|o&1023))}return n}const Xr="v1";var Yr=Object.defineProperty,Zr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,hr=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,kr=(r,e,n)=>e in r?Yr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,ee=(r,e)=>{for(var n in e||(e={}))hr.call(e,n)&&kr(r,n,e[n]);if(Tr)for(var n of Tr(e))re.call(e,n)&&kr(r,n,e[n]);return r},ae=(r,e)=>Zr(r,$r(e));const ne=r=>{const e=ae(ee({},r),{v:Xr});return Qr(Kr(Hr(JSON.stringify(e))),!0)};return er.pack=ne,Object.defineProperty(er,"__esModule",{value:!0}),er}({});
or you can use record.mirror to access the mirror instance during recording.`;let cr={map:{},getId(){return console.error(N),-1},getNode(){return console.error(N),null},removeNodeFromMap(){console.error(N)},has(){return console.error(N),!1},reset(){console.error(N)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(cr=new Proxy(cr,{get(r,e,n){return e==="map"&&console.error(N),Reflect.get(r,e,n)}}));var Pr=(r=>(r[r.DomContentLoaded=0]="DomContentLoaded",r[r.Load=1]="Load",r[r.FullSnapshot=2]="FullSnapshot",r[r.IncrementalSnapshot=3]="IncrementalSnapshot",r[r.Meta=4]="Meta",r[r.Custom=5]="Custom",r[r.Plugin=6]="Plugin",r))(Pr||{}),Lr=(r=>(r[r.Mutation=0]="Mutation",r[r.MouseMove=1]="MouseMove",r[r.MouseInteraction=2]="MouseInteraction",r[r.Scroll=3]="Scroll",r[r.ViewportResize=4]="ViewportResize",r[r.Input=5]="Input",r[r.TouchMove=6]="TouchMove",r[r.MediaInteraction=7]="MediaInteraction",r[r.StyleSheetRule=8]="StyleSheetRule",r[r.CanvasMutation=9]="CanvasMutation",r[r.Font=10]="Font",r[r.Log=11]="Log",r[r.Drag=12]="Drag",r[r.StyleDeclaration=13]="StyleDeclaration",r[r.Selection=14]="Selection",r[r.AdoptedStyleSheet=15]="AdoptedStyleSheet",r))(Lr||{}),Rr=(r=>(r[r.MouseUp=0]="MouseUp",r[r.MouseDown=1]="MouseDown",r[r.Click=2]="Click",r[r.ContextMenu=3]="ContextMenu",r[r.DblClick=4]="DblClick",r[r.Focus=5]="Focus",r[r.Blur=6]="Blur",r[r.TouchStart=7]="TouchStart",r[r.TouchMove_Departed=8]="TouchMove_Departed",r[r.TouchEnd=9]="TouchEnd",r[r.TouchCancel=10]="TouchCancel",r))(Rr||{}),xr=(r=>(r[r["2D"]=0]="2D",r[r.WebGL=1]="WebGL",r[r.WebGL2=2]="WebGL2",r))(xr||{}),Ir=(r=>(r[r.Play=0]="Play",r[r.Pause=1]="Pause",r[r.Seeked=2]="Seeked",r[r.VolumeChange=3]="VolumeChange",r[r.RateChange=4]="RateChange",r))(Ir||{}),Or=(r=>(r.Start="start",r.Pause="pause",r.Resume="resume",r.Resize="resize",r.Finish="finish",r.FullsnapshotRebuilded="fullsnapshot-rebuilded",r.LoadStylesheetStart="load-stylesheet-start",r.LoadStylesheetEnd="load-stylesheet-end",r.SkipStart="skip-start",r.SkipEnd="skip-end",r.MouseInteraction="mouse-interaction",r.EventCast="event-cast",r.CustomEvent="custom-event",r.Flush="flush",r.StateChange="state-change",r.PlayBack="play-back",r.Destroy="destroy",r))(Or||{});class Er{constructor(){this.nodeMap=new WeakMap,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.periodicallyClear()})}inOtherBuffer(e,n){const a=this.nodeMap.get(e);return a&&Array.from(a).some(t=>t!==n)}add(e,n){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(n))}clear(){this.nodeMap=new WeakMap}}new Er;for(var wr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ur=typeof Uint8Array>"u"?[]:new Uint8Array(256),Z=0;Z<wr.length;Z++)Ur[wr.charCodeAt(Z)]=Z;var m=Uint8Array,g=Uint16Array,K=Uint32Array,ar=new m([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nr=new m([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),gr=new m([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mr=function(r,e){for(var n=new g(31),a=0;a<31;++a)n[a]=e+=1<<r[a-1];for(var t=new K(n[30]),a=1;a<30;++a)for(var o=n[a];o<n[a+1];++o)t[o]=o-n[a]<<5|a;return[n,t]},yr=Mr(ar,2),zr=yr[0],tr=yr[1];zr[28]=258,tr[258]=28;for(var Wr=Mr(nr,0),Cr=Wr[1],or=new g(32768),s=0;s<32768;++s){var U=(s&43690)>>>1|(s&21845)<<1;U=(U&52428)>>>2|(U&13107)<<2,U=(U&61680)>>>4|(U&3855)<<4,or[s]=((U&65280)>>>8|(U&255)<<8)>>>1}for(var H=function(r,e,n){for(var a=r.length,t=0,o=new g(e);t<a;++t)++o[r[t]-1];var f=new g(e);for(t=0;t<e;++t)f[t]=f[t-1]+o[t-1]<<1;var i;if(n){i=new g(1<<e);var l=15-e;for(t=0;t<a;++t)if(r[t])for(var c=t<<4|r[t],v=e-r[t],M=f[r[t]-1]++<<v,d=M|(1<<v)-1;M<=d;++M)i[or[M]>>>l]=c}else for(i=new g(a),t=0;t<a;++t)i[t]=or[f[r[t]-1]++]>>>15-r[t];return i},B=new m(288),s=0;s<144;++s)B[s]=8;for(var s=144;s<256;++s)B[s]=9;for(var s=256;s<280;++s)B[s]=7;for(var s=280;s<288;++s)B[s]=8;for(var $=new m(32),s=0;s<32;++s)$[s]=5;var jr=H(B,9,0),Br=H($,5,0),Sr=function(r){return(r/8>>0)+(r&7&&1)},mr=function(r,e,n){(e==null||e<0)&&(e=0),(n==null||n>r.length)&&(n=r.length);var a=new(r instanceof g?g:r instanceof K?K:m)(n-e);return a.set(r.subarray(e,n)),a},E=function(r,e,n){n<<=e&7;var a=e/8>>0;r[a]|=n,r[a+1]|=n>>>8},Q=function(r,e,n){n<<=e&7;var a=e/8>>0;r[a]|=n,r[a+1]|=n>>>8,r[a+2]|=n>>>16},vr=function(r,e){for(var n=[],a=0;a<r.length;++a)r[a]&&n.push({s:a,f:r[a]});var t=n.length,o=n.slice();if(!t)return[new m(0),0];if(t==1){var f=new m(n[0].s+1);return f[n[0].s]=1,[f,1]}n.sort(function(R,k){return R.f-k.f}),n.push({s:-1,f:25001});var i=n[0],l=n[1],c=0,v=1,M=2;for(n[0]={s:-1,f:i.f+l.f,l:i,r:l};v!=t-1;)i=n[n[c].f<n[M].f?c++:M++],l=n[c!=v&&n[c].f<n[M].f?c++:M++],n[v++]={s:-1,f:i.f+l.f,l:i,r:l};for(var d=o[0].s,a=1;a<t;++a)o[a].s>d&&(d=o[a].s);var y=new g(d+1),P=fr(n[v-1],y,0);if(P>e){var a=0,S=0,z=P-e,G=1<<z;for(o.sort(function(k,C){return y[C.s]-y[k.s]||k.f-C.f});a<t;++a){var L=o[a].s;if(y[L]>e)S+=G-(1<<P-y[L]),y[L]=e;else break}for(S>>>=z;S>0;){var q=o[a].s;y[q]<e?S-=1<<e-y[q]++-1:++a}for(;a>=0&&S;--a){var W=o[a].s;y[W]==e&&(--y[W],++S)}P=e}return[new m(y),P]},fr=function(r,e,n){return r.s==-1?Math.max(fr(r.l,e,n+1),fr(r.r,e,n+1)):e[r.s]=n},dr=function(r){for(var e=r.length;e&&!r[--e];);for(var n=new g(++e),a=0,t=r[0],o=1,f=function(l){n[a++]=l},i=1;i<=e;++i)if(r[i]==t&&i!=e)++o;else{if(!t&&o>2){for(;o>138;o-=138)f(32754);o>2&&(f(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(f(t),--o;o>6;o-=6)f(8304);o>2&&(f(o-3<<5|8208),o=0)}for(;o--;)f(t);o=1,t=r[i]}return[n.subarray(0,a),e]},X=function(r,e){for(var n=0,a=0;a<e.length;++a)n+=r[a]*e[a];return n},h=function(r,e,n){var a=n.length,t=Sr(e+2);r[t]=a&255,r[t+1]=a>>>8,r[t+2]=r[t]^255,r[t+3]=r[t+1]^255;for(var o=0;o<a;++o)r[t+o+4]=n[o];return(t+4+a)*8},Dr=function(r,e,n,a,t,o,f,i,l,c,v){E(e,v++,n),++t[256];for(var M=vr(t,15),d=M[0],y=M[1],P=vr(o,15),S=P[0],z=P[1],G=dr(d),L=G[0],q=G[1],W=dr(S),R=W[0],k=W[1],C=new g(19),u=0;u<L.length;++u)C[L[u]&31]++;for(var u=0;u<R.length;++u)C[R[u]&31]++;for(var V=vr(C,7),T=V[0],rr=V[1],D=19;D>4&&!T[gr[D-1]];--D);var _=c+5<<3,A=X(t,B)+X(o,$)+f,F=X(t,d)+X(o,S)+f+14+3*D+X(C,T)+(2*C[16]+3*C[17]+7*C[18]);if(_<=A&&_<=F)return h(e,v,r.subarray(l,l+c));var x,w,p,j;if(E(e,v,1+(F<A)),v+=2,F<A){x=H(d,y,0),w=d,p=H(S,z,0),j=S;var lr=H(T,rr,0);E(e,v,q-257),E(e,v+5,k-1),E(e,v+10,D-4),v+=14;for(var u=0;u<D;++u)E(e,v+3*u,T[gr[u]]);v+=3*D;for(var I=[L,R],Y=0;Y<2;++Y)for(var J=I[Y],u=0;u<J.length;++u){var O=J[u]&31;E(e,v,lr[O]),v+=T[O],O>15&&(E(e,v,J[u]>>>5&127),v+=J[u]>>>12)}}else x=jr,w=B,p=Br,j=$;for(var u=0;u<i;++u)if(a[u]>255){var O=a[u]>>>18&31;Q(e,v,x[O+257]),v+=w[O+257],O>7&&(E(e,v,a[u]>>>23&31),v+=ar[O]);var b=a[u]&31;Q(e,v,p[b]),v+=j[b],b>3&&(Q(e,v,a[u]>>>5&8191),v+=nr[b])}else Q(e,v,x[a[u]]),v+=w[a[u]];return Q(e,v,x[256]),v+w[256]},Gr=new K([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vr=new m(0),Nr=function(r,e,n,a,t,o){var f=r.length,i=new m(a+f+5*(1+Math.floor(f/7e3))+t),l=i.subarray(a,i.length-t),c=0;if(!e||f<8)for(var v=0;v<=f;v+=65535){var M=v+65535;M<f?c=h(l,c,r.subarray(v,M)):(l[v]=o,c=h(l,c,r.subarray(v,f)))}else{for(var d=Gr[e-1],y=d>>>13,P=d&8191,S=(1<<n)-1,z=new g(32768),G=new g(S+1),L=Math.ceil(n/3),q=2*L,W=function(ir){return(r[ir]^r[ir+1]<<L^r[ir+2]<<q)&S},R=new K(25e3),k=new g(288),C=new g(32),u=0,V=0,v=0,T=0,rr=0,D=0;v<f;++v){var _=W(v),A=v&32767,F=G[_];if(z[A]=F,G[_]=A,rr<=v){var x=f-v;if((u>7e3||T>24576)&&x>423){c=Dr(r,l,0,R,k,C,V,T,D,v-D,c),T=u=V=0,D=v;for(var w=0;w<286;++w)k[w]=0;for(var w=0;w<30;++w)C[w]=0}var p=2,j=0,lr=P,I=A-F&32767;if(x>2&&_==W(v-I))for(var Y=Math.min(y,x)-1,J=Math.min(32767,v),O=Math.min(258,x);I<=J&&--lr&&A!=F;){if(r[v+p]==r[v+p-I]){for(var b=0;b<O&&r[v+b]==r[v+b-I];++b);if(b>p){if(p=b,j=I,b>Y)break;for(var oe=Math.min(I,b-2),Tr=0,w=0;w<oe;++w){var ur=v-I+w+32768&32767,ve=z[ur],Ar=ur-ve+32768&32767;Ar>Tr&&(Tr=Ar,F=ur)}}}A=F,F=z[A],I+=A-F+32768&32767}if(j){R[T++]=268435456|tr[p]<<18|Cr[j];var Fr=tr[p]&31,pr=Cr[j]&31;V+=ar[Fr]+nr[pr],++k[257+Fr],++C[pr],rr=v+p,++u}else R[T++]=r[v],++k[r[v]]}}c=Dr(r,l,o,R,k,C,V,T,D,v-D,c),o||(c=h(l,c,Vr))}return mr(i,0,a+Sr(c)+t)},qr=function(){var r=1,e=0;return{p:function(n){for(var a=r,t=e,o=n.length,f=0;f!=o;){for(var i=Math.min(f+5552,o);f<i;++f)a+=n[f],t+=a;a%=65521,t%=65521}r=a,e=t},d:function(){return(r>>>8<<16|(e&255)<<8|e>>>8)+((r&255)<<23)*2}}},_r=function(r,e,n,a,t){return Nr(r,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+e.mem,n,a,!t)},Jr=function(r,e,n){for(;n;++e)r[e]=n,n>>>=8},Kr=function(r,e){var n=e.level,a=n==0?0:n<6?1:n==9?3:2;r[0]=120,r[1]=a<<6|(a?32-2*a:1)};function Hr(r,e){e===void 0&&(e={});var n=qr();n.p(r);var a=_r(r,e,2,4);return Kr(a,e),Jr(a,a.length-4,n.d()),a}function Qr(r,e){var n=r.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new m(r.length+(r.length>>>1)),t=0,o=function(c){a[t++]=c},f=0;f<n;++f){if(t+5>a.length){var i=new m(t+8+(n-f<<1));i.set(a),a=i}var l=r.charCodeAt(f);l<128||e?o(l):l<2048?(o(192|l>>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|r.charCodeAt(++f)&1023,o(240|l>>>18),o(128|l>>>12&63),o(128|l>>>6&63),o(128|l&63)):(o(224|l>>>12),o(128|l>>>6&63),o(128|l&63))}return mr(a,0,t)}function Xr(r,e){var n="";if(!e&&typeof TextDecoder<"u")return new TextDecoder().decode(r);for(var a=0;a<r.length;){var t=r[a++];t<128||e?n+=String.fromCharCode(t):t<224?n+=String.fromCharCode((t&31)<<6|r[a++]&63):t<240?n+=String.fromCharCode((t&15)<<12|(r[a++]&63)<<6|r[a++]&63):(t=((t&15)<<18|(r[a++]&63)<<12|(r[a++]&63)<<6|r[a++]&63)-65536,n+=String.fromCharCode(55296|t>>10,56320|t&1023))}return n}const Yr="v1";var Zr=Object.defineProperty,$r=Object.defineProperties,hr=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,kr=(r,e,n)=>e in r?Zr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,ae=(r,e)=>{for(var n in e||(e={}))re.call(e,n)&&kr(r,n,e[n]);if(br)for(var n of br(e))ee.call(e,n)&&kr(r,n,e[n]);return r},ne=(r,e)=>$r(r,hr(e));const te=r=>{const e=ne(ae({},r),{v:Yr});return Xr(Hr(Qr(JSON.stringify(e))),!0)};return er.pack=te,Object.defineProperty(er,"__esModule",{value:!0}),er}({});
//# sourceMappingURL=rrweb-record-pack.min.js.map

@@ -112,28 +112,31 @@ var NodeType$1;

constructor(..._args) {
this.childNodes = [];
this.parentElement = null;
this.parentNode = null;
this.firstChild = null;
this.lastChild = null;
this.previousSibling = null;
this.nextSibling = null;
this.ELEMENT_NODE = NodeType.ELEMENT_NODE;
this.TEXT_NODE = NodeType.TEXT_NODE;
}
get firstChild() {
return this.childNodes[0] || null;
get childNodes() {
const childNodes = [];
let childIterator = this.firstChild;
while (childIterator) {
childNodes.push(childIterator);
childIterator = childIterator.nextSibling;
}
return childNodes;
}
get lastChild() {
return this.childNodes[this.childNodes.length - 1] || null;
}
get nextSibling() {
const parentNode = this.parentNode;
if (!parentNode)
return null;
const siblings = parentNode.childNodes;
const index = siblings.indexOf(this);
return siblings[index + 1] || null;
}
contains(node) {
if (node === this)
if (!(node instanceof BaseRRNode))
return false;
else if (node.ownerDocument !== this.ownerDocument)
return false;
else if (node === this)
return true;
for (const child of this.childNodes) {
if (child.contains(node))
while (node.parentNode) {
if (node.parentNode === this)
return true;
node = node.parentNode;
}

@@ -157,4 +160,4 @@ return false;

return class BaseRRDocument extends RRNodeClass {
constructor() {
super(...arguments);
constructor(...args) {
super(args);
this.nodeType = NodeType.DOCUMENT_NODE;

@@ -165,2 +168,3 @@ this.nodeName = '#document';

this.textContent = null;
this.ownerDocument = this;
}

@@ -187,4 +191,4 @@ get documentElement() {

}
appendChild(childNode) {
const nodeType = childNode.RRNodeType;
appendChild(newChild) {
const nodeType = newChild.RRNodeType;
if (nodeType === NodeType$1.Element ||

@@ -196,6 +200,5 @@ nodeType === NodeType$1.DocumentType) {

}
childNode.parentElement = null;
childNode.parentNode = this;
this.childNodes.push(childNode);
return childNode;
const child = appendChild(this, newChild);
child.parentElement = null;
return child;
}

@@ -210,23 +213,12 @@ insertBefore(newChild, refChild) {

}
if (refChild === null)
return this.appendChild(newChild);
const childIndex = this.childNodes.indexOf(refChild);
if (childIndex == -1)
throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");
this.childNodes.splice(childIndex, 0, newChild);
newChild.parentElement = null;
newChild.parentNode = this;
return newChild;
const child = insertBefore(this, newChild, refChild);
child.parentElement = null;
return child;
}
removeChild(node) {
const indexOfChild = this.childNodes.indexOf(node);
if (indexOfChild === -1)
throw new Error("Failed to execute 'removeChild' on 'RRDocument': The RRNode to be removed is not a child of this RRNode.");
this.childNodes.splice(indexOfChild, 1);
node.parentElement = null;
node.parentNode = null;
return node;
return removeChild(this, node);
}
open() {
this.childNodes = [];
this.firstChild = null;
this.lastChild = null;
}

@@ -291,3 +283,2 @@ close() {

this.RRNodeType = NodeType$1.DocumentType;
this.textContent = null;
this.name = qualifiedName;

@@ -297,2 +288,3 @@ this.publicId = publicId;

this.nodeName = qualifiedName;
this.textContent = null;
}

@@ -321,3 +313,5 @@ toString() {

set textContent(textContent) {
this.childNodes = [this.ownerDocument.createTextNode(textContent)];
this.firstChild = null;
this.lastChild = null;
this.appendChild(this.ownerDocument.createTextNode(textContent));
}

@@ -336,5 +330,3 @@ get classList() {

get style() {
const style = (this.attributes.style
? parseCSSText(this.attributes.style)
: {});
const style = (this.attributes.style ? parseCSSText(this.attributes.style) : {});
const hyphenateRE = /\B([A-Z])/g;

@@ -377,26 +369,9 @@ style.setProperty = (name, value, priority) => {

appendChild(newChild) {
this.childNodes.push(newChild);
newChild.parentNode = this;
newChild.parentElement = this;
return newChild;
return appendChild(this, newChild);
}
insertBefore(newChild, refChild) {
if (refChild === null)
return this.appendChild(newChild);
const childIndex = this.childNodes.indexOf(refChild);
if (childIndex == -1)
throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");
this.childNodes.splice(childIndex, 0, newChild);
newChild.parentElement = this;
newChild.parentNode = this;
return newChild;
return insertBefore(this, newChild, refChild);
}
removeChild(node) {
const indexOfChild = this.childNodes.indexOf(node);
if (indexOfChild === -1)
throw new Error("Failed to execute 'removeChild' on 'RRElement': The RRNode to be removed is not a child of this RRNode.");
this.childNodes.splice(indexOfChild, 1);
node.parentElement = null;
node.parentNode = null;
return node;
return removeChild(this, node);
}

@@ -516,2 +491,52 @@ attachShadow(_init) {

}
function appendChild(parent, newChild) {
if (parent.lastChild) {
parent.lastChild.nextSibling = newChild;
newChild.previousSibling = parent.lastChild;
}
else {
parent.firstChild = newChild;
newChild.previousSibling = null;
}
parent.lastChild = newChild;
newChild.nextSibling = null;
newChild.parentNode = parent;
newChild.parentElement = parent;
newChild.ownerDocument = parent.ownerDocument;
return newChild;
}
function insertBefore(parent, newChild, refChild) {
if (!refChild)
return appendChild(parent, newChild);
if (refChild.parentNode !== parent)
throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");
newChild.previousSibling = refChild.previousSibling;
refChild.previousSibling = newChild;
newChild.nextSibling = refChild;
if (newChild.previousSibling)
newChild.previousSibling.nextSibling = newChild;
else
parent.firstChild = newChild;
newChild.parentElement = parent;
newChild.parentNode = parent;
newChild.ownerDocument = parent.ownerDocument;
return newChild;
}
function removeChild(parent, child) {
if (child.parentNode !== parent)
throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode.");
if (child.previousSibling)
child.previousSibling.nextSibling = child.nextSibling;
else
parent.firstChild = child.nextSibling;
if (child.nextSibling)
child.nextSibling.previousSibling = child.previousSibling;
else
parent.lastChild = child.previousSibling;
child.previousSibling = null;
child.nextSibling = null;
child.parentElement = null;
child.parentNode = null;
return child;
}
var NodeType;

@@ -576,17 +601,38 @@ (function (NodeType) {

};
function diff(oldTree, newTree, replayer, rrnodeMirror) {
let createdNodeSet = null;
function diff(oldTree, newTree, replayer, rrnodeMirror = newTree.mirror ||
newTree.ownerDocument.mirror) {
oldTree = diffBeforeUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror);
const oldChildren = oldTree.childNodes;
const newChildren = newTree.childNodes;
rrnodeMirror =
rrnodeMirror ||
newTree.mirror ||
newTree.ownerDocument.mirror;
if (oldChildren.length > 0 || newChildren.length > 0) {
diffChildren(Array.from(oldChildren), newChildren, oldTree, replayer, rrnodeMirror);
}
let inputDataToApply = null, scrollDataToApply = null;
diffAfterUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror);
}
function diffBeforeUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror) {
var _a;
if (replayer.afterAppend && !createdNodeSet) {
createdNodeSet = new WeakSet();
setTimeout(() => {
createdNodeSet = null;
}, 0);
}
if (!sameNodeType(oldTree, newTree)) {
const calibratedOldTree = createOrGetNode(newTree, replayer.mirror, rrnodeMirror);
(_a = oldTree.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(calibratedOldTree, oldTree);
oldTree = calibratedOldTree;
}
switch (newTree.RRNodeType) {
case NodeType$1.Document: {
const newRRDocument = newTree;
scrollDataToApply = newRRDocument.scrollData;
if (!nodeMatching(oldTree, newTree, replayer.mirror, rrnodeMirror)) {
const newMeta = rrnodeMirror.getMeta(newTree);
if (newMeta) {
replayer.mirror.removeNodeFromMap(oldTree);
oldTree.close();
oldTree.open();
replayer.mirror.add(oldTree, newMeta);
createdNodeSet === null || createdNodeSet === void 0 ? void 0 : createdNodeSet.add(oldTree);
}
}
break;

@@ -597,5 +643,40 @@ }

const newRRElement = newTree;
switch (newRRElement.tagName) {
case 'IFRAME': {
const oldContentDocument = oldTree
.contentDocument;
if (!oldContentDocument)
break;
diff(oldContentDocument, newTree.contentDocument, replayer, rrnodeMirror);
break;
}
}
if (newRRElement.shadowRoot) {
if (!oldElement.shadowRoot)
oldElement.attachShadow({ mode: 'open' });
const oldChildren = oldElement.shadowRoot.childNodes;
const newChildren = newRRElement.shadowRoot.childNodes;
if (oldChildren.length > 0 || newChildren.length > 0)
diffChildren(Array.from(oldChildren), newChildren, oldElement.shadowRoot, replayer, rrnodeMirror);
}
break;
}
}
return oldTree;
}
function diffAfterUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror) {
var _a;
switch (newTree.RRNodeType) {
case NodeType$1.Document: {
const scrollData = newTree.scrollData;
scrollData && replayer.applyScroll(scrollData, true);
break;
}
case NodeType$1.Element: {
const oldElement = oldTree;
const newRRElement = newTree;
diffProps(oldElement, newRRElement, rrnodeMirror);
scrollDataToApply = newRRElement.scrollData;
inputDataToApply = newRRElement.inputData;
newRRElement.scrollData &&
replayer.applyScroll(newRRElement.scrollData, true);
newRRElement.inputData && replayer.applyInput(newRRElement.inputData);
switch (newRRElement.tagName) {

@@ -620,34 +701,24 @@ case 'AUDIO':

}
case 'CANVAS':
{
const rrCanvasElement = newTree;
if (rrCanvasElement.rr_dataURL !== null) {
const image = document.createElement('img');
image.onload = () => {
const ctx = oldElement.getContext('2d');
if (ctx) {
ctx.drawImage(image, 0, 0, image.width, image.height);
}
};
image.src = rrCanvasElement.rr_dataURL;
}
rrCanvasElement.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree));
case 'CANVAS': {
const rrCanvasElement = newTree;
if (rrCanvasElement.rr_dataURL !== null) {
const image = document.createElement('img');
image.onload = () => {
const ctx = oldElement.getContext('2d');
if (ctx) {
ctx.drawImage(image, 0, 0, image.width, image.height);
}
};
image.src = rrCanvasElement.rr_dataURL;
}
rrCanvasElement.canvasMutations.forEach((canvasMutation) => replayer.applyCanvas(canvasMutation.event, canvasMutation.mutation, oldTree));
break;
case 'STYLE':
{
const styleSheet = oldElement.sheet;
styleSheet &&
newTree.rules.forEach((data) => replayer.applyStyleSheetMutation(data, styleSheet));
}
}
case 'STYLE': {
const styleSheet = oldElement.sheet;
styleSheet &&
newTree.rules.forEach((data) => replayer.applyStyleSheetMutation(data, styleSheet));
break;
}
}
if (newRRElement.shadowRoot) {
if (!oldElement.shadowRoot)
oldElement.attachShadow({ mode: 'open' });
const oldChildren = oldElement.shadowRoot.childNodes;
const newChildren = newRRElement.shadowRoot.childNodes;
if (oldChildren.length > 0 || newChildren.length > 0)
diffChildren(Array.from(oldChildren), newChildren, oldElement.shadowRoot, replayer, rrnodeMirror);
}
break;

@@ -657,3 +728,3 @@ }

case NodeType$1.Comment:
case NodeType$1.CDATA:
case NodeType$1.CDATA: {
if (oldTree.textContent !==

@@ -663,16 +734,8 @@ newTree.data)

break;
}
scrollDataToApply && replayer.applyScroll(scrollDataToApply, true);
inputDataToApply && replayer.applyInput(inputDataToApply);
if (newTree.nodeName === 'IFRAME') {
const oldContentDocument = oldTree.contentDocument;
const newIFrameElement = newTree;
if (oldContentDocument) {
const sn = rrnodeMirror.getMeta(newIFrameElement.contentDocument);
if (sn) {
replayer.mirror.add(oldContentDocument, Object.assign({}, sn));
}
diff(oldContentDocument, newIFrameElement.contentDocument, replayer, rrnodeMirror);
}
}
if (createdNodeSet === null || createdNodeSet === void 0 ? void 0 : createdNodeSet.has(oldTree)) {
createdNodeSet.delete(oldTree);
(_a = replayer.afterAppend) === null || _a === void 0 ? void 0 : _a.call(replayer, oldTree, replayer.mirror.getId(oldTree));
}
}

@@ -685,3 +748,3 @@ function diffProps(oldTree, newTree, rrnodeMirror) {

const sn = rrnodeMirror.getMeta(newTree);
if (sn && 'isSVG' in sn && sn.isSVG && NAMESPACES[name])
if ((sn === null || sn === void 0 ? void 0 : sn.isSVG) && NAMESPACES[name])
oldTree.setAttributeNS(NAMESPACES[name], name, newValue);

@@ -708,11 +771,6 @@ else if (newTree.tagName === 'CANVAS' && name === 'rr_dataURL') {

function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirror) {
var _a;
let oldStartIndex = 0, oldEndIndex = oldChildren.length - 1, newStartIndex = 0, newEndIndex = newChildren.length - 1;
let oldStartNode = oldChildren[oldStartIndex], oldEndNode = oldChildren[oldEndIndex], newStartNode = newChildren[newStartIndex], newEndNode = newChildren[newEndIndex];
let oldIdToIndex = undefined, indexInOld;
let oldIdToIndex = undefined, indexInOld = undefined;
while (oldStartIndex <= oldEndIndex && newStartIndex <= newEndIndex) {
const oldStartId = replayer.mirror.getId(oldStartNode);
const oldEndId = replayer.mirror.getId(oldEndNode);
const newStartId = rrnodeMirror.getId(newStartNode);
const newEndId = rrnodeMirror.getId(newEndNode);
if (oldStartNode === undefined) {

@@ -724,4 +782,3 @@ oldStartNode = oldChildren[++oldStartIndex];

}
else if (oldStartId !== -1 &&
oldStartId === newStartId) {
else if (nodeMatching(oldStartNode, newStartNode, replayer.mirror, rrnodeMirror)) {
diff(oldStartNode, newStartNode, replayer, rrnodeMirror);

@@ -731,4 +788,3 @@ oldStartNode = oldChildren[++oldStartIndex];

}
else if (oldEndId !== -1 &&
oldEndId === newEndId) {
else if (nodeMatching(oldEndNode, newEndNode, replayer.mirror, rrnodeMirror)) {
diff(oldEndNode, newEndNode, replayer, rrnodeMirror);

@@ -738,5 +794,9 @@ oldEndNode = oldChildren[--oldEndIndex];

}
else if (oldStartId !== -1 &&
oldStartId === newEndId) {
parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
else if (nodeMatching(oldStartNode, newEndNode, replayer.mirror, rrnodeMirror)) {
try {
parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
}
catch (e) {
console.warn(e);
}
diff(oldStartNode, newEndNode, replayer, rrnodeMirror);

@@ -746,5 +806,9 @@ oldStartNode = oldChildren[++oldStartIndex];

}
else if (oldEndId !== -1 &&
oldEndId === newStartId) {
parentNode.insertBefore(oldEndNode, oldStartNode);
else if (nodeMatching(oldEndNode, newStartNode, replayer.mirror, rrnodeMirror)) {
try {
parentNode.insertBefore(oldEndNode, oldStartNode);
}
catch (e) {
console.warn(e);
}
diff(oldEndNode, newStartNode, replayer, rrnodeMirror);

@@ -764,5 +828,12 @@ oldEndNode = oldChildren[--oldEndIndex];

indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];
if (indexInOld) {
const nodeToMove = oldChildren[indexInOld];
parentNode.insertBefore(nodeToMove, oldStartNode);
const nodeToMove = oldChildren[indexInOld];
if (indexInOld !== undefined &&
nodeToMove &&
nodeMatching(nodeToMove, newStartNode, replayer.mirror, rrnodeMirror)) {
try {
parentNode.insertBefore(nodeToMove, oldStartNode);
}
catch (e) {
console.warn(e);
}
diff(nodeToMove, newStartNode, replayer, rrnodeMirror);

@@ -774,10 +845,18 @@ oldChildren[indexInOld] = undefined;

if (parentNode.nodeName === '#document' &&
((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Element &&
parentNode.documentElement) {
parentNode.removeChild(parentNode.documentElement);
oldChildren[oldStartIndex] = undefined;
oldStartNode = undefined;
oldStartNode &&
((newNode.nodeType === newNode.DOCUMENT_TYPE_NODE &&
oldStartNode.nodeType === oldStartNode.DOCUMENT_TYPE_NODE) ||
(newNode.nodeType === newNode.ELEMENT_NODE &&
oldStartNode.nodeType === oldStartNode.ELEMENT_NODE))) {
parentNode.removeChild(oldStartNode);
replayer.mirror.removeNodeFromMap(oldStartNode);
oldStartNode = oldChildren[++oldStartIndex];
}
parentNode.insertBefore(newNode, oldStartNode || null);
diff(newNode, newStartNode, replayer, rrnodeMirror);
try {
parentNode.insertBefore(newNode, oldStartNode || null);
diff(newNode, newStartNode, replayer, rrnodeMirror);
}
catch (e) {
console.warn(e);
}
}

@@ -791,10 +870,12 @@ newStartNode = newChildren[++newStartIndex];

if (referenceRRNode)
parentNode.childNodes.forEach((child) => {
if (replayer.mirror.getId(child) === rrnodeMirror.getId(referenceRRNode))
referenceNode = child;
});
referenceNode = replayer.mirror.getNode(rrnodeMirror.getId(referenceRRNode));
for (; newStartIndex <= newEndIndex; ++newStartIndex) {
const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror);
parentNode.insertBefore(newNode, referenceNode);
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
try {
parentNode.insertBefore(newNode, referenceNode);
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
}
catch (e) {
console.warn(e);
}
}

@@ -805,6 +886,11 @@ }

const node = oldChildren[oldStartIndex];
if (node) {
if (!node || !parentNode.contains(node))
continue;
try {
parentNode.removeChild(node);
replayer.mirror.removeNodeFromMap(node);
}
catch (e) {
console.warn(e);
}
}

@@ -819,3 +905,3 @@ }

node = domMirror.getNode(nodeId);
if (node !== null)
if (node !== null && sameNodeType(node, rrNode))
return node;

@@ -851,4 +937,23 @@ switch (rrNode.RRNodeType) {

domMirror.add(node, Object.assign({}, sn));
try {
createdNodeSet === null || createdNodeSet === void 0 ? void 0 : createdNodeSet.add(node);
}
catch (e) {
}
return node;
}
function sameNodeType(node1, node2) {
if (node1.nodeType !== node2.nodeType)
return false;
return (node1.nodeType !== node1.ELEMENT_NODE ||
node1.tagName.toUpperCase() ===
node2.tagName);
}
function nodeMatching(node1, node2, domMirror, rrdomMirror) {
const node1Id = domMirror.getId(node1);
const node2Id = rrdomMirror.getId(node2);
if (node1Id === -1 || node1Id !== node2Id)
return false;
return sameNodeType(node1, node2);
}

@@ -917,3 +1022,4 @@ class RRDocument extends BaseRRDocumentImpl(BaseRRNode) {

destroyTree() {
this.childNodes = [];
this.firstChild = null;
this.lastChild = null;
this.mirror.reset();

@@ -920,0 +1026,0 @@ }

@@ -31,5 +31,3 @@ import { patch } from '../../../utils.js';

function initLogObserver(cb, win, options) {
const logOptions = (options
? Object.assign({}, defaultLogOptions, options)
: defaultLogOptions);
const logOptions = (options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions);
const loggerType = logOptions.logger;

@@ -50,19 +48,43 @@ if (!loggerType) {

if (logOptions.level.includes('error')) {
if (window) {
const errorHandler = (event) => {
const message = event.message, error = event.error;
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
const payload = [stringify(message, logOptions.stringifyOptions)];
cb({
level: 'error',
trace,
payload,
});
};
window.addEventListener('error', errorHandler);
cancelHandlers.push(() => {
if (window)
window.removeEventListener('error', errorHandler);
const errorHandler = (event) => {
const message = event.message, error = event.error;
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
const payload = [stringify(message, logOptions.stringifyOptions)];
cb({
level: 'error',
trace,
payload,
});
}
};
win.addEventListener('error', errorHandler);
cancelHandlers.push(() => {
win.removeEventListener('error', errorHandler);
});
const unhandledrejectionHandler = (event) => {
let error;
let payload;
if (event.reason instanceof Error) {
error = event.reason;
payload = [
stringify(`Uncaught (in promise) ${error.name}: ${error.message}`, logOptions.stringifyOptions),
];
}
else {
error = new Error();
payload = [
stringify('Uncaught (in promise)', logOptions.stringifyOptions),
stringify(event.reason, logOptions.stringifyOptions),
];
}
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
cb({
level: 'error',
trace,
payload,
});
};
win.addEventListener('unhandledrejection', unhandledrejectionHandler);
cancelHandlers.push(() => {
win.removeEventListener('unhandledrejection', unhandledrejectionHandler);
});
}

@@ -69,0 +91,0 @@ for (const levelType of logOptions.level) {

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

import { genId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import { genId, NodeType } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import CrossOriginIframeMirror from './cross-origin-iframe-mirror.js';

@@ -10,2 +10,3 @@ import { EventType, IncrementalSource } from '../../../types/dist/types.js';

this.crossOriginIframeMirror = new CrossOriginIframeMirror(genId);
this.crossOriginIframeRootIdMap = new WeakMap();
this.mutationCb = options.mutationCb;

@@ -51,13 +52,15 @@ this.wrappedEmit = options.wrappedEmit;

handleMessage(message) {
if (message.data.type === 'rrweb') {
const iframeSourceWindow = message.source;
if (!iframeSourceWindow)
return;
const iframeEl = this.crossOriginIframeMap.get(message.source);
if (!iframeEl)
return;
const transformedEvent = this.transformCrossOriginEvent(iframeEl, message.data.event);
if (transformedEvent)
this.wrappedEmit(transformedEvent, message.data.isCheckout);
}
const crossOriginMessageEvent = message;
if (crossOriginMessageEvent.data.type !== 'rrweb' ||
crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin)
return;
const iframeSourceWindow = message.source;
if (!iframeSourceWindow)
return;
const iframeEl = this.crossOriginIframeMap.get(message.source);
if (!iframeEl)
return;
const transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
if (transformedEvent)
this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
}

@@ -71,2 +74,5 @@ transformCrossOriginEvent(iframeEl, e) {

this.replaceIdOnNode(e.data.node, iframeEl);
const rootId = e.data.node.id;
this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
this.patchRootIdOnNode(e.data.node, rootId);
return {

@@ -113,2 +119,4 @@ timestamp: e.timestamp,

this.replaceIdOnNode(n.node, iframeEl);
const rootId = this.crossOriginIframeRootIdMap.get(iframeEl);
rootId && this.patchRootIdOnNode(n.node, rootId);
});

@@ -192,3 +200,3 @@ e.data.removes.forEach((n) => {

replaceIdOnNode(node, iframeEl) {
this.replaceIds(node, iframeEl, ['id']);
this.replaceIds(node, iframeEl, ['id', 'rootId']);
if ('childNodes' in node) {

@@ -200,4 +208,13 @@ node.childNodes.forEach((child) => {

}
patchRootIdOnNode(node, rootId) {
if (node.type !== NodeType.Document && !node.rootId)
node.rootId = rootId;
if ('childNodes' in node) {
node.childNodes.forEach((child) => {
this.patchRootIdOnNode(child, rootId);
});
}
}
}
export { IframeManager };
import { createMirror, snapshot } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import { initObservers, mutationBuffers } from './observer.js';
import { polyfill, on, getWindowWidth, getWindowHeight, isSerializedIframe, isSerializedStylesheet, hasShadowRoot } from '../utils.js';
import { processedNodeManager, initObservers, mutationBuffers } from './observer.js';
import { polyfill, on, getWindowWidth, getWindowHeight, getWindowScroll, isSerializedIframe, isSerializedStylesheet, hasShadowRoot } from '../utils.js';
import { EventType, IncrementalSource } from '../../../types/dist/types.js';

@@ -19,3 +19,5 @@ import { IframeManager } from './iframe-manager.js';

function record(options = {}) {
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, ignoreClass = 'rr-ignore', maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait, recordCanvas = false, recordCrossOriginIframes = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, ignoreCSSAttributes = new Set([]), } = options;
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, ignoreClass = 'rr-ignore', maskTextClass = 'rr-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, dataURLOptions = {}, mousemoveWait, recordCanvas = false, recordCrossOriginIframes = false, recordAfter = options.recordAfter === 'DOMContentLoaded'
? options.recordAfter
: 'load', userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, ignoreCSSAttributes = new Set([]), } = options;
const inEmittingFrame = recordCrossOriginIframes

@@ -88,3 +90,4 @@ ? window.parent === window

}
if (packFn) {
if (packFn &&
!passEmitsToParent) {
e = packFn(e);

@@ -109,2 +112,3 @@ }

event: eventProcessor(e),
origin: window.location.origin,
isCheckout,

@@ -200,2 +204,3 @@ };

keepIframeSrcFn,
processedNodeManager,
},

@@ -205,3 +210,2 @@ mirror,

takeFullSnapshot = (isCheckout = false) => {
var _a, _b, _c, _d, _e, _f;
wrappedEmit(wrapEvent({

@@ -216,2 +220,3 @@ type: EventType.Meta,

stylesheetManager.reset();
shadowDomManager.init();
mutationBuffers.forEach((buf) => buf.lock());

@@ -258,16 +263,3 @@ const node = snapshot(document, {

node,
initialOffset: {
left: window.pageXOffset !== undefined
? window.pageXOffset
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollLeft) ||
((_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
((_c = document === null || document === void 0 ? void 0 : document.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) ||
0,
top: window.pageYOffset !== undefined
? window.pageYOffset
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollTop) ||
((_e = (_d = document === null || document === void 0 ? void 0 : document.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) ||
((_f = document === null || document === void 0 ? void 0 : document.body) === null || _f === void 0 ? void 0 : _f.scrollTop) ||
0,
},
initialOffset: getWindowScroll(window),
},

@@ -281,8 +273,2 @@ }));

const handlers = [];
handlers.push(on('DOMContentLoaded', () => {
wrappedEmit(wrapEvent({
type: EventType.DomContentLoaded,
data: {},
}));
}));
const observe = (doc) => {

@@ -357,2 +343,3 @@ var _a;

shadowDomManager,
processedNodeManager,
canvasManager,

@@ -374,3 +361,8 @@ ignoreCSSAttributes,

iframeManager.addLoadListener((iframeEl) => {
handlers.push(observe(iframeEl.contentDocument));
try {
handlers.push(observe(iframeEl.contentDocument));
}
catch (error) {
console.warn(error);
}
});

@@ -387,2 +379,10 @@ const init = () => {

else {
handlers.push(on('DOMContentLoaded', () => {
wrappedEmit(wrapEvent({
type: EventType.DomContentLoaded,
data: {},
}));
if (recordAfter === 'DOMContentLoaded')
init();
}));
handlers.push(on('load', () => {

@@ -393,3 +393,4 @@ wrappedEmit(wrapEvent({

}));
init();
if (recordAfter === 'load')
init();
}, window));

@@ -396,0 +397,0 @@ }

import { isShadowRoot, isNativeShadowDom, maskInputValue, transformAttribute, needMaskingText, IGNORED_NODE, serializeNodeWithId } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import { isIgnored, isBlocked, isSerialized, isAncestorRemoved, isSerializedIframe, isSerializedStylesheet, hasShadowRoot } from '../utils.js';
import { isIgnored, isBlocked, isSerialized, isAncestorRemoved, hasShadowRoot, inDom, getShadowHost, isSerializedIframe, isSerializedStylesheet } from '../utils.js';

@@ -114,19 +114,7 @@ function isNodeInLinkedList(n) {

const pushAdd = (n) => {
var _a, _b, _c, _d;
let shadowHost = null;
if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE &&
n.getRootNode().host)
shadowHost = n.getRootNode().host;
let rootShadowHost = shadowHost;
while (((_d = (_c = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _c === void 0 ? void 0 : _c.call(rootShadowHost)) === null || _d === void 0 ? void 0 : _d.nodeType) ===
Node.DOCUMENT_FRAGMENT_NODE &&
rootShadowHost.getRootNode().host)
rootShadowHost = rootShadowHost.getRootNode().host;
const notInDoc = !this.doc.contains(n) &&
(!rootShadowHost || !this.doc.contains(rootShadowHost));
if (!n.parentNode || notInDoc) {
if (!n.parentNode || !inDom(n)) {
return;
}
const parentId = isShadowRoot(n.parentNode)
? this.mirror.getId(shadowHost)
? this.mirror.getId(getShadowHost(n))
: this.mirror.getId(n.parentNode);

@@ -411,2 +399,4 @@ const nextId = getNextId(n);

this.genAdds = (n, target) => {
if (this.processedNodeManager.inOtherBuffer(n, this))
return;
if (this.mirror.hasNode(n)) {

@@ -429,4 +419,11 @@ if (isIgnored(n, this.mirror)) {

}
if (!isBlocked(n, this.blockClass, this.blockSelector, false))
if (!isBlocked(n, this.blockClass, this.blockSelector, false)) {
n.childNodes.forEach((childN) => this.genAdds(childN));
if (hasShadowRoot(n)) {
n.shadowRoot.childNodes.forEach((childN) => {
this.processedNodeManager.add(childN, this);
this.genAdds(childN, n);
});
}
}
};

@@ -456,2 +453,3 @@ }

'canvasManager',
'processedNodeManager',
].forEach((key) => {

@@ -458,0 +456,0 @@ this[key] = options[key];

import { maskInputValue } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
import { on, throttle, isBlocked, getWindowHeight, getWindowWidth, hookSetter, patch, isTouchEvent } from '../utils.js';
import { on, throttle, isBlocked, getWindowScroll, getWindowHeight, getWindowWidth, hookSetter, patch, isTouchEvent } from '../utils.js';
import { MouseInteractions, IncrementalSource } from '../../../types/dist/types.js';
import MutationBuffer from './mutation.js';
import ProcessedNodeManager from './processed-node-manager.js';
const mutationBuffers = [];
const isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined';
const isCSSMediaRuleSupported = typeof CSSMediaRule !== 'undefined';
const isCSSSupportsRuleSupported = typeof CSSSupportsRule !== 'undefined';
const isCSSConditionRuleSupported = typeof CSSConditionRule !== 'undefined';
const processedNodeManager = new ProcessedNodeManager();
function getEventTarget(event) {

@@ -152,8 +150,8 @@ try {

const id = mirror.getId(target);
if (target === doc) {
const scrollEl = (doc.scrollingElement || doc.documentElement);
if (target === doc && doc.defaultView) {
const scrollLeftTop = getWindowScroll(doc.defaultView);
scrollCb({
id,
x: scrollEl.scrollLeft,
y: scrollEl.scrollTop,
x: scrollLeftTop.left,
y: scrollLeftTop.top,
});

@@ -284,9 +282,9 @@ }

function recurse(childRule, pos) {
if ((isCSSGroupingRuleSupported &&
if ((hasNestedCSSRule('CSSGroupingRule') &&
childRule.parentRule instanceof CSSGroupingRule) ||
(isCSSMediaRuleSupported &&
(hasNestedCSSRule('CSSMediaRule') &&
childRule.parentRule instanceof CSSMediaRule) ||
(isCSSSupportsRuleSupported &&
(hasNestedCSSRule('CSSSupportsRule') &&
childRule.parentRule instanceof CSSSupportsRule) ||
(isCSSConditionRuleSupported &&
(hasNestedCSSRule('CSSConditionRule') &&
childRule.parentRule instanceof CSSConditionRule)) {

@@ -320,2 +318,6 @@ const rules = Array.from(childRule.parentRule.cssRules);

function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager }, { win }) {
if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
return () => {
};
}
const insertRule = win.CSSStyleSheet.prototype.insertRule;

@@ -376,13 +378,13 @@ win.CSSStyleSheet.prototype.insertRule = function (rule, index) {

const supportedNestedCSSRuleTypes = {};
if (isCSSGroupingRuleSupported) {
if (canMonkeyPatchNestedCSSRule('CSSGroupingRule')) {
supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
}
else {
if (isCSSMediaRuleSupported) {
if (canMonkeyPatchNestedCSSRule('CSSMediaRule')) {
supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
}
if (isCSSConditionRuleSupported) {
if (canMonkeyPatchNestedCSSRule('CSSConditionRule')) {
supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
}
if (isCSSSupportsRuleSupported) {
if (canMonkeyPatchNestedCSSRule('CSSSupportsRule')) {
supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;

@@ -540,3 +542,3 @@ }

}
const { currentTime, volume, muted, playbackRate, } = target;
const { currentTime, volume, muted, playbackRate } = target;
mediaInteractionCb({

@@ -752,3 +754,12 @@ type,

}
function hasNestedCSSRule(prop) {
return typeof window[prop] !== 'undefined';
}
function canMonkeyPatchNestedCSSRule(prop) {
return Boolean(typeof window[prop] !== 'undefined' &&
window[prop].prototype &&
'insertRule' in window[prop].prototype &&
'deleteRule' in window[prop].prototype);
}
export { INPUT_TAGS, initAdoptedStyleSheetObserver, initMutationObserver, initObservers, initScrollObserver, mutationBuffers };
export { INPUT_TAGS, initAdoptedStyleSheetObserver, initMutationObserver, initObservers, initScrollObserver, mutationBuffers, processedNodeManager };
import { initMutationObserver, initScrollObserver, initAdoptedStyleSheetObserver } from './observer.js';
import { patch } from '../utils.js';
import { patch, inDom } from '../utils.js';
import { isNativeShadowDom } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';

@@ -8,3 +8,3 @@

this.shadowDoms = new WeakSet();
this.restorePatches = [];
this.restoreHandlers = [];
this.mutationCb = options.mutationCb;

@@ -14,12 +14,8 @@ this.scrollCb = options.scrollCb;

this.mirror = options.mirror;
const manager = this;
this.restorePatches.push(patch(Element.prototype, 'attachShadow', function (original) {
return function (option) {
const shadowRoot = original.call(this, option);
if (this.shadowRoot)
manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
return shadowRoot;
};
}));
this.init();
}
init() {
this.reset();
this.patchAttachShadow(Element, document);
}
addShadowRoot(shadowRoot, doc) {

@@ -31,4 +27,5 @@ if (!isNativeShadowDom(shadowRoot))

this.shadowDoms.add(shadowRoot);
initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
const observer = initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
this.restoreHandlers.push(() => observer.disconnect());
this.restoreHandlers.push(initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror })));
setTimeout(() => {

@@ -38,23 +35,33 @@ if (shadowRoot.adoptedStyleSheets &&

this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot.adoptedStyleSheets, this.mirror.getId(shadowRoot.host));
initAdoptedStyleSheetObserver({
this.restoreHandlers.push(initAdoptedStyleSheetObserver({
mirror: this.mirror,
stylesheetManager: this.bypassOptions.stylesheetManager,
}, shadowRoot);
}, shadowRoot));
}, 0);
}
observeAttachShadow(iframeElement) {
if (iframeElement.contentWindow) {
const manager = this;
this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, 'attachShadow', function (original) {
return function (option) {
const shadowRoot = original.call(this, option);
if (this.shadowRoot)
manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
return shadowRoot;
};
}));
}
if (!iframeElement.contentWindow || !iframeElement.contentDocument)
return;
this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
}
patchAttachShadow(element, doc) {
const manager = this;
this.restoreHandlers.push(patch(element.prototype, 'attachShadow', function (original) {
return function (option) {
const shadowRoot = original.call(this, option);
if (this.shadowRoot && inDom(this))
manager.addShadowRoot(this.shadowRoot, doc);
return shadowRoot;
};
}));
}
reset() {
this.restorePatches.forEach((restorePatch) => restorePatch());
this.restoreHandlers.forEach((handler) => {
try {
handler();
}
catch (e) {
}
});
this.restoreHandlers = [];
this.shadowDoms = new WeakSet();

@@ -61,0 +68,0 @@ }

@@ -143,3 +143,2 @@ import { interpret as v, createMachine as s, assign as o } from './../../../../ext/@xstate/fsm/es/index.js';

baselineTime: (ctx, event) => {
ctx.timer.toggleLiveMode(true);
ctx.timer.start();

@@ -146,0 +145,0 @@ if (event.type === 'TO_LIVE' && event.payload.baselineTime) {

@@ -9,39 +9,48 @@ import { EventType, IncrementalSource } from '../../../types/dist/types.js';

this.speed = config.speed;
this.liveMode = config.liveMode;
}
addAction(action) {
const rafWasActive = this.raf === true;
if (!this.actions.length ||
this.actions[this.actions.length - 1].delay <= action.delay) {
this.actions.push(action);
return;
}
const index = this.findActionIndex(action);
this.actions.splice(index, 0, action);
else {
const index = this.findActionIndex(action);
this.actions.splice(index, 0, action);
}
if (rafWasActive) {
this.raf = requestAnimationFrame(this.rafCheck.bind(this));
}
}
start() {
this.timeOffset = 0;
let lastTimestamp = performance.now();
const check = () => {
const time = performance.now();
this.timeOffset += (time - lastTimestamp) * this.speed;
lastTimestamp = time;
while (this.actions.length) {
const action = this.actions[0];
if (this.timeOffset >= action.delay) {
this.actions.shift();
action.doAction();
}
else {
break;
}
this.lastTimestamp = performance.now();
this.raf = requestAnimationFrame(this.rafCheck.bind(this));
}
rafCheck() {
const time = performance.now();
this.timeOffset += (time - this.lastTimestamp) * this.speed;
this.lastTimestamp = time;
while (this.actions.length) {
const action = this.actions[0];
if (this.timeOffset >= action.delay) {
this.actions.shift();
action.doAction();
}
if (this.actions.length > 0 || this.liveMode) {
this.raf = requestAnimationFrame(check);
else {
break;
}
};
this.raf = requestAnimationFrame(check);
}
if (this.actions.length > 0) {
this.raf = requestAnimationFrame(this.rafCheck.bind(this));
}
else {
this.raf = true;
}
}
clear() {
if (this.raf) {
cancelAnimationFrame(this.raf);
if (this.raf !== true) {
cancelAnimationFrame(this.raf);
}
this.raf = null;

@@ -54,5 +63,2 @@ }

}
toggleLiveMode(mode) {
this.liveMode = mode;
}
isActive() {

@@ -59,0 +65,0 @@ return this.raf !== null;

@@ -114,2 +114,24 @@ import { classMatchesRegex, IGNORED_NODE, isShadowRoot } from '../../rrweb-snapshot/es/rrweb-snapshot.js';

}
function getWindowScroll(win) {
var _a, _b, _c, _d, _e, _f;
const doc = win.document;
return {
left: doc.scrollingElement
? doc.scrollingElement.scrollLeft
: win.pageXOffset !== undefined
? win.pageXOffset
: (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollLeft) ||
((_b = (_a = doc === null || doc === void 0 ? void 0 : doc.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
((_c = doc === null || doc === void 0 ? void 0 : doc.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) ||
0,
top: doc.scrollingElement
? doc.scrollingElement.scrollTop
: win.pageYOffset !== undefined
? win.pageYOffset
: (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollTop) ||
((_e = (_d = doc === null || doc === void 0 ? void 0 : doc.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) ||
((_f = doc === null || doc === void 0 ? void 0 : doc.body) === null || _f === void 0 ? void 0 : _f.scrollTop) ||
0,
};
}
function getWindowHeight() {

@@ -145,3 +167,3 @@ return (window.innerHeight ||

if (blockSelector) {
if (node.matches(blockSelector))
if (el.matches(blockSelector))
return true;

@@ -344,3 +366,31 @@ if (checkAncestors && el.closest(blockSelector) !== null)

}
function getShadowHost(n) {
var _a, _b;
let shadowHost = null;
if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE &&
n.getRootNode().host)
shadowHost = n.getRootNode().host;
return shadowHost;
}
function getRootShadowHost(n) {
let rootShadowHost = n;
let shadowHost;
while ((shadowHost = getShadowHost(rootShadowHost)))
rootShadowHost = shadowHost;
return rootShadowHost;
}
function shadowHostInDom(n) {
const doc = n.ownerDocument;
if (!doc)
return false;
const shadowHost = getRootShadowHost(n);
return doc.contains(shadowHost);
}
function inDom(n) {
const doc = n.ownerDocument;
if (!doc)
return false;
return doc.contains(n) || shadowHostInDom(n);
}
export { StyleSheetMirror, _mirror, getBaseDimension, getNestedRule, getPositionsAndIndex, getWindowHeight, getWindowWidth, hasShadowRoot, hookSetter, isAncestorRemoved, isBlocked, isIgnored, isSerialized, isSerializedIframe, isSerializedStylesheet, isTouchEvent, iterateResolveTree, on, patch, polyfill, queueToResolveTrees, throttle, uniqueTextMutations };
export { StyleSheetMirror, _mirror, getBaseDimension, getNestedRule, getPositionsAndIndex, getRootShadowHost, getShadowHost, getWindowHeight, getWindowScroll, getWindowWidth, hasShadowRoot, hookSetter, inDom, isAncestorRemoved, isBlocked, isIgnored, isSerialized, isSerializedIframe, isSerializedStylesheet, isTouchEvent, iterateResolveTree, on, patch, polyfill, queueToResolveTrees, shadowHostInDom, throttle, uniqueTextMutations };
{
"name": "rrweb",
"version": "2.0.0-alpha.4",
"version": "2.0.0-alpha.5",
"description": "record and replay the web",

@@ -30,3 +30,3 @@ "scripts": {

],
"main": "lib/rrweb-all.js",
"main": "lib/rrweb-all.cjs",
"module": "es/rrweb/packages/rrweb/src/entries/all.js",

@@ -57,3 +57,2 @@ "unpkg": "dist/rrweb.js",

"@types/offscreencanvas": "^2019.6.4",
"@types/prettier": "^2.3.2",
"@types/puppeteer": "^5.4.4",

@@ -70,3 +69,2 @@ "construct-style-sheets-polyfill": "^3.1.0",

"jest-snapshot": "^23.6.0",
"prettier": "2.2.1",
"puppeteer": "^11.0.0",

@@ -86,3 +84,3 @@ "rollup": "^2.68.0",

"dependencies": {
"@rrweb/types": "^2.0.0-alpha.4",
"@rrweb/types": "^2.0.0-alpha.5",
"@types/css-font-loading-module": "0.0.7",

@@ -93,5 +91,5 @@ "@xstate/fsm": "^1.4.0",

"mitt": "^3.0.0",
"rrdom": "^0.1.7",
"rrweb-snapshot": "^2.0.0-alpha.4"
"rrdom": "^2.0.0-alpha.5",
"rrweb-snapshot": "^2.0.0-alpha.5"
}
}

@@ -6,4 +6,5 @@ import record from './record';

export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents, } from '@rrweb/types';
export type { recordOptions } from './types';
declare const addCustomEvent: <T>(tag: string, payload: T) => void;
declare const freezePage: () => void;
export { record, addCustomEvent, freezePage, Replayer, _mirror as mirror, utils, };

@@ -10,2 +10,3 @@ import type { Mirror, serializedNodeWithId } from 'rrweb-snapshot';

crossOriginIframeStyleMirror: CrossOriginIframeMirror;
crossOriginIframeRootIdMap: WeakMap<HTMLIFrameElement, number>;
private mirror;

@@ -33,2 +34,3 @@ private mutationCb;

private replaceIdOnNode;
private patchRootIdOnNode;
}

@@ -34,2 +34,3 @@ import type { MutationBufferParam } from '../types';

private canvasManager;
private processedNodeManager;
init(options: MutationBufferParam): void;

@@ -36,0 +37,0 @@ freeze(): void;

import type { observerParam, MutationBufferParam } from '../types';
import { listenerHandler, hooksParam } from '@rrweb/types';
import MutationBuffer from './mutation';
import ProcessedNodeManager from './processed-node-manager';
export declare const mutationBuffers: MutationBuffer[];
export declare const processedNodeManager: ProcessedNodeManager;
export declare function initMutationObserver(options: MutationBufferParam, rootEl: Node): MutationObserver;

@@ -6,0 +8,0 @@ export declare function initScrollObserver({ scrollCb, doc, mirror, blockClass, blockSelector, sampling, }: Pick<observerParam, 'scrollCb' | 'doc' | 'mirror' | 'blockClass' | 'blockSelector' | 'sampling'>): listenerHandler;

@@ -13,3 +13,3 @@ import type { MutationBufferParam } from '../types';

private mirror;
private restorePatches;
private restoreHandlers;
constructor(options: {

@@ -21,6 +21,8 @@ mutationCb: mutationCallBack;

});
init(): void;
addShadowRoot(shadowRoot: ShadowRoot, doc: Document): void;
observeAttachShadow(iframeElement: HTMLIFrameElement): void;
private patchAttachShadow;
reset(): void;
}
export {};

@@ -32,2 +32,3 @@ import { Mirror } from 'rrweb-snapshot';

private touchActive;
private lastHoveredRootNode;
private lastSelectionData;

@@ -34,0 +35,0 @@ private constructedStyleMutations;

@@ -7,12 +7,11 @@ import { actionWithDelay, eventWithTime } from '@rrweb/types';

private raf;
private liveMode;
private lastTimestamp;
constructor(actions: actionWithDelay[] | undefined, config: {
speed: number;
liveMode: boolean;
});
addAction(action: actionWithDelay): void;
start(): void;
private rafCheck;
clear(): void;
setSpeed(speed: number): void;
toggleLiveMode(mode: boolean): void;
isActive(): boolean;

@@ -19,0 +18,0 @@ private findActionIndex;

@@ -10,2 +10,3 @@ import type { Mirror, MaskInputOptions, SlimDOMOptions, MaskInputFn, MaskTextFn, DataURLOptions } from 'rrweb-snapshot';

import type { addedNodeMutation, blockClass, canvasMutationCallback, eventWithTime, fontCallback, hooksParam, inputCallback, IWindow, KeepIframeSrcFn, listenerHandler, maskTextClass, mediaInteractionCallback, mouseInteractionCallBack, mousemoveCallBack, mutationCallBack, RecordPlugin, SamplingStrategy, scrollCallback, selectionCallback, styleDeclarationCallback, styleSheetRuleCallback, viewportResizeCallback } from '@rrweb/types';
import type ProcessedNodeManager from './record/processed-node-manager';
export declare type recordOptions<T> = {

@@ -33,2 +34,3 @@ emit?: (e: T, isCheckout?: boolean) => void;

recordCrossOriginIframes?: boolean;
recordAfter?: 'DOMContentLoaded' | 'load';
userTriggeredOnInput?: boolean;

@@ -77,2 +79,3 @@ collectFonts?: boolean;

canvasManager: CanvasManager;
processedNodeManager: ProcessedNodeManager;
ignoreCSSAttributes: Set<string>;

@@ -85,3 +88,3 @@ plugins: Array<{

};
export declare type MutationBufferParam = Pick<observerParam, 'mutationCb' | 'blockClass' | 'blockSelector' | 'maskTextClass' | 'maskTextSelector' | 'inlineStylesheet' | 'maskInputOptions' | 'maskTextFn' | 'maskInputFn' | 'keepIframeSrcFn' | 'recordCanvas' | 'inlineImages' | 'slimDOMOptions' | 'dataURLOptions' | 'doc' | 'mirror' | 'iframeManager' | 'stylesheetManager' | 'shadowDomManager' | 'canvasManager'>;
export declare type MutationBufferParam = Pick<observerParam, 'mutationCb' | 'blockClass' | 'blockSelector' | 'maskTextClass' | 'maskTextSelector' | 'inlineStylesheet' | 'maskInputOptions' | 'maskTextFn' | 'maskInputFn' | 'keepIframeSrcFn' | 'recordCanvas' | 'inlineImages' | 'slimDOMOptions' | 'dataURLOptions' | 'doc' | 'mirror' | 'iframeManager' | 'stylesheetManager' | 'shadowDomManager' | 'canvasManager' | 'processedNodeManager'>;
export declare type ReplayPlugin = {

@@ -121,2 +124,6 @@ handler?: (event: eventWithTime, isSync: boolean, context: {

useVirtualDom: boolean;
logger: {
log: (...args: Parameters<typeof console.log>) => void;
warn: (...args: Parameters<typeof console.warn>) => void;
};
plugins?: ReplayPlugin[];

@@ -139,4 +146,5 @@ };

event: T;
origin: string;
isCheckout?: boolean;
};
export declare type CrossOriginIframeMessageEvent = MessageEvent<CrossOriginIframeMessageEventContent>;

@@ -11,2 +11,6 @@ import type { throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, DocumentDimension, IWindow, DeprecatedMirror, textMutation } from '@rrweb/types';

}, name: string, replacement: (...args: unknown[]) => unknown): () => void;
export declare function getWindowScroll(win: Window): {
left: number;
top: number;
};
export declare function getWindowHeight(): number;

@@ -54,2 +58,6 @@ export declare function getWindowWidth(): number;

}
export declare function getShadowHost(n: Node): Element | null;
export declare function getRootShadowHost(n: Node): Node;
export declare function shadowHostInDom(n: Node): boolean;
export declare function inDom(n: Node): boolean;
export {};

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

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 too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc