rrweb-snapshot
Advanced tools
Comparing version 1.1.8 to 1.1.9
var rrwebSnapshot = (function (exports) { | ||
'use strict'; | ||
'use strict'; | ||
(function (NodeType) { | ||
NodeType[NodeType["Document"] = 0] = "Document"; | ||
NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
NodeType[NodeType["Element"] = 2] = "Element"; | ||
NodeType[NodeType["Text"] = 3] = "Text"; | ||
NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
})(exports.NodeType || (exports.NodeType = {})); | ||
exports.NodeType = void 0; | ||
(function (NodeType) { | ||
NodeType[NodeType["Document"] = 0] = "Document"; | ||
NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
NodeType[NodeType["Element"] = 2] = "Element"; | ||
NodeType[NodeType["Text"] = 3] = "Text"; | ||
NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
})(exports.NodeType || (exports.NodeType = {})); | ||
function isElement(n) { | ||
return n.nodeType === n.ELEMENT_NODE; | ||
} | ||
function isShadowRoot(n) { | ||
var _a; | ||
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host; | ||
return Boolean(host && host.shadowRoot && host.shadowRoot === n); | ||
} | ||
function maskInputValue(_a) { | ||
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; | ||
var text = value || ''; | ||
if (maskInputOptions[tagName.toLowerCase()] || | ||
maskInputOptions[type]) { | ||
if (maskInputFn) { | ||
text = maskInputFn(text); | ||
} | ||
else { | ||
text = '*'.repeat(text.length); | ||
} | ||
} | ||
return text; | ||
} | ||
function isElement(n) { | ||
return n.nodeType === n.ELEMENT_NODE; | ||
} | ||
function isShadowRoot(n) { | ||
var _a; | ||
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host; | ||
return Boolean(host && host.shadowRoot && host.shadowRoot === n); | ||
} | ||
function maskInputValue(_a) { | ||
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn; | ||
var text = value || ''; | ||
if (maskInputOptions[tagName.toLowerCase()] || | ||
maskInputOptions[type]) { | ||
if (maskInputFn) { | ||
text = maskInputFn(text); | ||
} | ||
else { | ||
text = '*'.repeat(text.length); | ||
} | ||
} | ||
return text; | ||
} | ||
var _id = 1; | ||
var tagNameRegex = RegExp('[^a-z0-9-_:]'); | ||
var IGNORED_NODE = -2; | ||
function genId() { | ||
return _id++; | ||
} | ||
function getValidTagName(element) { | ||
if (element instanceof HTMLFormElement) { | ||
return 'form'; | ||
} | ||
var processedTagName = element.tagName.toLowerCase().trim(); | ||
if (tagNameRegex.test(processedTagName)) { | ||
return 'div'; | ||
} | ||
return processedTagName; | ||
} | ||
function getCssRulesString(s) { | ||
try { | ||
var rules = s.rules || s.cssRules; | ||
return rules ? Array.from(rules).map(getCssRuleString).join('') : null; | ||
} | ||
catch (error) { | ||
return null; | ||
} | ||
} | ||
function getCssRuleString(rule) { | ||
return isCSSImportRule(rule) | ||
? getCssRulesString(rule.styleSheet) || '' | ||
: rule.cssText; | ||
} | ||
function isCSSImportRule(rule) { | ||
return 'styleSheet' in rule; | ||
} | ||
function extractOrigin(url) { | ||
var origin; | ||
if (url.indexOf('//') > -1) { | ||
origin = url.split('/').slice(0, 3).join('/'); | ||
} | ||
else { | ||
origin = url.split('/')[0]; | ||
} | ||
origin = origin.split('?')[0]; | ||
return origin; | ||
} | ||
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm; | ||
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/; | ||
var DATA_URI = /^(data:)([^,]*),(.*)/i; | ||
function absoluteToStylesheet(cssText, href) { | ||
return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) { | ||
var filePath = path1 || path2 || path3; | ||
var maybeQuote = quote1 || quote2 || ''; | ||
if (!filePath) { | ||
return origin; | ||
} | ||
if (!RELATIVE_PATH.test(filePath)) { | ||
return "url(" + maybeQuote + filePath + maybeQuote + ")"; | ||
} | ||
if (DATA_URI.test(filePath)) { | ||
return "url(" + maybeQuote + filePath + maybeQuote + ")"; | ||
} | ||
if (filePath[0] === '/') { | ||
return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")"; | ||
} | ||
var stack = href.split('/'); | ||
var parts = filePath.split('/'); | ||
stack.pop(); | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
if (part === '.') { | ||
continue; | ||
} | ||
else if (part === '..') { | ||
stack.pop(); | ||
} | ||
else { | ||
stack.push(part); | ||
} | ||
} | ||
return "url(" + maybeQuote + stack.join('/') + maybeQuote + ")"; | ||
}); | ||
} | ||
var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/; | ||
var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/; | ||
function getAbsoluteSrcsetString(doc, attributeValue) { | ||
if (attributeValue.trim() === '') { | ||
return attributeValue; | ||
} | ||
var pos = 0; | ||
function collectCharacters(regEx) { | ||
var chars, match = regEx.exec(attributeValue.substring(pos)); | ||
if (match) { | ||
chars = match[0]; | ||
pos += chars.length; | ||
return chars; | ||
} | ||
return ''; | ||
} | ||
var output = []; | ||
while (true) { | ||
collectCharacters(SRCSET_COMMAS_OR_SPACES); | ||
if (pos >= attributeValue.length) { | ||
break; | ||
} | ||
var url = collectCharacters(SRCSET_NOT_SPACES); | ||
if (url.slice(-1) === ',') { | ||
url = absoluteToDoc(doc, url.substring(0, url.length - 1)); | ||
output.push(url); | ||
} | ||
else { | ||
var descriptorsStr = ''; | ||
url = absoluteToDoc(doc, url); | ||
var inParens = false; | ||
while (true) { | ||
var c = attributeValue.charAt(pos); | ||
if (c === '') { | ||
output.push((url + descriptorsStr).trim()); | ||
break; | ||
} | ||
else if (!inParens) { | ||
if (c === ',') { | ||
pos += 1; | ||
output.push((url + descriptorsStr).trim()); | ||
break; | ||
} | ||
else if (c === '(') { | ||
inParens = true; | ||
} | ||
} | ||
else { | ||
if (c === ')') { | ||
inParens = false; | ||
} | ||
} | ||
descriptorsStr += c; | ||
pos += 1; | ||
} | ||
} | ||
} | ||
return output.join(', '); | ||
} | ||
function absoluteToDoc(doc, attributeValue) { | ||
if (!attributeValue || attributeValue.trim() === '') { | ||
return attributeValue; | ||
} | ||
var a = doc.createElement('a'); | ||
a.href = attributeValue; | ||
return a.href; | ||
} | ||
function isSVGElement(el) { | ||
return el.tagName === 'svg' || el instanceof SVGElement; | ||
} | ||
function getHref() { | ||
var a = document.createElement('a'); | ||
a.href = ''; | ||
return a.href; | ||
} | ||
function transformAttribute(doc, tagName, name, value) { | ||
if (name === 'src' || ((name === 'href' || name === 'xlink:href') && value)) { | ||
return absoluteToDoc(doc, value); | ||
} | ||
else if (name === 'background' && | ||
value && | ||
(tagName === 'table' || tagName === 'td' || tagName === 'th')) { | ||
return absoluteToDoc(doc, value); | ||
} | ||
else if (name === 'srcset' && value) { | ||
return getAbsoluteSrcsetString(doc, value); | ||
} | ||
else if (name === 'style' && value) { | ||
return absoluteToStylesheet(value, getHref()); | ||
} | ||
else { | ||
return value; | ||
} | ||
} | ||
function _isBlockedElement(element, blockClass, blockSelector) { | ||
if (typeof blockClass === 'string') { | ||
if (element.classList.contains(blockClass)) { | ||
return true; | ||
} | ||
} | ||
else { | ||
for (var eIndex = 0; eIndex < element.classList.length; eIndex++) { | ||
var className = element.classList[eIndex]; | ||
if (blockClass.test(className)) { | ||
return true; | ||
} | ||
} | ||
} | ||
if (blockSelector) { | ||
return element.matches(blockSelector); | ||
} | ||
return false; | ||
} | ||
function needMaskingText(node, maskTextClass, maskTextSelector) { | ||
if (!node) { | ||
return false; | ||
} | ||
if (node.nodeType === node.ELEMENT_NODE) { | ||
if (typeof maskTextClass === 'string') { | ||
if (node.classList.contains(maskTextClass)) { | ||
return true; | ||
} | ||
} | ||
else { | ||
node.classList.forEach(function (className) { | ||
if (maskTextClass.test(className)) { | ||
return true; | ||
} | ||
}); | ||
} | ||
if (maskTextSelector) { | ||
if (node.matches(maskTextSelector)) { | ||
return true; | ||
} | ||
} | ||
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); | ||
} | ||
if (node.nodeType === node.TEXT_NODE) { | ||
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); | ||
} | ||
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); | ||
} | ||
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { | ||
var win = iframeEl.contentWindow; | ||
if (!win) { | ||
return; | ||
} | ||
var fired = false; | ||
var readyState; | ||
try { | ||
readyState = win.document.readyState; | ||
} | ||
catch (error) { | ||
return; | ||
} | ||
if (readyState !== 'complete') { | ||
var timer_1 = setTimeout(function () { | ||
if (!fired) { | ||
listener(); | ||
fired = true; | ||
} | ||
}, iframeLoadTimeout); | ||
iframeEl.addEventListener('load', function () { | ||
clearTimeout(timer_1); | ||
fired = true; | ||
listener(); | ||
}); | ||
return; | ||
} | ||
var blankUrl = 'about:blank'; | ||
if (win.location.href !== blankUrl || | ||
iframeEl.src === blankUrl || | ||
iframeEl.src === '') { | ||
setTimeout(listener, 0); | ||
return; | ||
} | ||
iframeEl.addEventListener('load', listener); | ||
} | ||
function serializeNode(n, options) { | ||
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; | ||
var rootId; | ||
if (doc.__sn) { | ||
var docId = doc.__sn.id; | ||
rootId = docId === 1 ? undefined : docId; | ||
} | ||
switch (n.nodeType) { | ||
case n.DOCUMENT_NODE: | ||
return { | ||
type: exports.NodeType.Document, | ||
childNodes: [], | ||
rootId: rootId, | ||
}; | ||
case n.DOCUMENT_TYPE_NODE: | ||
return { | ||
type: exports.NodeType.DocumentType, | ||
name: n.name, | ||
publicId: n.publicId, | ||
systemId: n.systemId, | ||
rootId: rootId, | ||
}; | ||
case n.ELEMENT_NODE: | ||
var needBlock = _isBlockedElement(n, blockClass, blockSelector); | ||
var tagName = getValidTagName(n); | ||
var attributes_1 = {}; | ||
for (var _i = 0, _b = Array.from(n.attributes); _i < _b.length; _i++) { | ||
var _c = _b[_i], name = _c.name, value = _c.value; | ||
attributes_1[name] = transformAttribute(doc, tagName, name, value); | ||
} | ||
if (tagName === 'link' && inlineStylesheet) { | ||
var stylesheet = Array.from(doc.styleSheets).find(function (s) { | ||
return s.href === n.href; | ||
}); | ||
var cssText = getCssRulesString(stylesheet); | ||
if (cssText) { | ||
delete attributes_1.rel; | ||
delete attributes_1.href; | ||
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
} | ||
} | ||
if (tagName === 'style' && | ||
n.sheet && | ||
!(n.innerText || | ||
n.textContent || | ||
'').trim().length) { | ||
var cssText = getCssRulesString(n.sheet); | ||
if (cssText) { | ||
attributes_1._cssText = absoluteToStylesheet(cssText, getHref()); | ||
} | ||
} | ||
if (tagName === 'input' || | ||
tagName === 'textarea' || | ||
tagName === 'select') { | ||
var value = n.value; | ||
if (attributes_1.type !== 'radio' && | ||
attributes_1.type !== 'checkbox' && | ||
attributes_1.type !== 'submit' && | ||
attributes_1.type !== 'button' && | ||
value) { | ||
attributes_1.value = maskInputValue({ | ||
type: attributes_1.type, | ||
tagName: tagName, | ||
value: value, | ||
maskInputOptions: maskInputOptions, | ||
maskInputFn: maskInputFn, | ||
}); | ||
} | ||
else if (n.checked) { | ||
attributes_1.checked = n.checked; | ||
} | ||
} | ||
if (tagName === 'option') { | ||
if (n.selected) { | ||
attributes_1.selected = true; | ||
} | ||
else { | ||
delete attributes_1.selected; | ||
} | ||
} | ||
if (tagName === 'canvas' && recordCanvas) { | ||
attributes_1.rr_dataURL = n.toDataURL(); | ||
} | ||
if (tagName === 'audio' || tagName === 'video') { | ||
attributes_1.rr_mediaState = n.paused | ||
? 'paused' | ||
: 'played'; | ||
attributes_1.rr_mediaCurrentTime = n.currentTime; | ||
} | ||
if (n.scrollLeft) { | ||
attributes_1.rr_scrollLeft = n.scrollLeft; | ||
} | ||
if (n.scrollTop) { | ||
attributes_1.rr_scrollTop = n.scrollTop; | ||
} | ||
if (needBlock) { | ||
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height; | ||
attributes_1 = { | ||
class: attributes_1.class, | ||
rr_width: width + "px", | ||
rr_height: height + "px", | ||
}; | ||
} | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) { | ||
delete attributes_1.src; | ||
} | ||
return { | ||
type: exports.NodeType.Element, | ||
tagName: tagName, | ||
attributes: attributes_1, | ||
childNodes: [], | ||
isSVG: isSVGElement(n) || undefined, | ||
needBlock: needBlock, | ||
rootId: rootId, | ||
}; | ||
case n.TEXT_NODE: | ||
var parentTagName = n.parentNode && n.parentNode.tagName; | ||
var textContent = n.textContent; | ||
var isStyle = parentTagName === 'STYLE' ? true : undefined; | ||
var isScript = parentTagName === 'SCRIPT' ? true : undefined; | ||
if (isStyle && textContent) { | ||
textContent = absoluteToStylesheet(textContent, getHref()); | ||
} | ||
if (isScript) { | ||
textContent = 'SCRIPT_PLACEHOLDER'; | ||
} | ||
if (!isStyle && | ||
!isScript && | ||
needMaskingText(n, maskTextClass, maskTextSelector) && | ||
textContent) { | ||
textContent = maskTextFn | ||
? maskTextFn(textContent) | ||
: textContent.replace(/[\S]/g, '*'); | ||
} | ||
return { | ||
type: exports.NodeType.Text, | ||
textContent: textContent || '', | ||
isStyle: isStyle, | ||
rootId: rootId, | ||
}; | ||
case n.CDATA_SECTION_NODE: | ||
return { | ||
type: exports.NodeType.CDATA, | ||
textContent: '', | ||
rootId: rootId, | ||
}; | ||
case n.COMMENT_NODE: | ||
return { | ||
type: exports.NodeType.Comment, | ||
textContent: n.textContent || '', | ||
rootId: rootId, | ||
}; | ||
default: | ||
return false; | ||
} | ||
} | ||
function lowerIfExists(maybeAttr) { | ||
if (maybeAttr === undefined) { | ||
return ''; | ||
} | ||
else { | ||
return maybeAttr.toLowerCase(); | ||
} | ||
} | ||
function slimDOMExcluded(sn, slimDOMOptions) { | ||
if (slimDOMOptions.comment && sn.type === exports.NodeType.Comment) { | ||
return true; | ||
} | ||
else if (sn.type === exports.NodeType.Element) { | ||
if (slimDOMOptions.script && | ||
(sn.tagName === 'script' || | ||
(sn.tagName === 'link' && | ||
sn.attributes.rel === 'preload' && | ||
sn.attributes.as === 'script') || | ||
(sn.tagName === 'link' && | ||
sn.attributes.rel === 'prefetch' && | ||
typeof sn.attributes.href === 'string' && | ||
sn.attributes.href.endsWith('.js')))) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headFavicon && | ||
((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') || | ||
(sn.tagName === 'meta' && | ||
(lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || | ||
lowerIfExists(sn.attributes.name) === 'application-name' || | ||
lowerIfExists(sn.attributes.rel) === 'icon' || | ||
lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' || | ||
lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) { | ||
return true; | ||
} | ||
else if (sn.tagName === 'meta') { | ||
if (slimDOMOptions.headMetaDescKeywords && | ||
lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaSocial && | ||
(lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || | ||
lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || | ||
lowerIfExists(sn.attributes.name) === 'pinterest')) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaRobots && | ||
(lowerIfExists(sn.attributes.name) === 'robots' || | ||
lowerIfExists(sn.attributes.name) === 'googlebot' || | ||
lowerIfExists(sn.attributes.name) === 'bingbot')) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaHttpEquiv && | ||
sn.attributes['http-equiv'] !== undefined) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaAuthorship && | ||
(lowerIfExists(sn.attributes.name) === 'author' || | ||
lowerIfExists(sn.attributes.name) === 'generator' || | ||
lowerIfExists(sn.attributes.name) === 'framework' || | ||
lowerIfExists(sn.attributes.name) === 'publisher' || | ||
lowerIfExists(sn.attributes.name) === 'progid' || | ||
lowerIfExists(sn.attributes.property).match(/^article:/) || | ||
lowerIfExists(sn.attributes.property).match(/^product:/))) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaVerification && | ||
(lowerIfExists(sn.attributes.name) === 'google-site-verification' || | ||
lowerIfExists(sn.attributes.name) === 'yandex-verification' || | ||
lowerIfExists(sn.attributes.name) === 'csrf-token' || | ||
lowerIfExists(sn.attributes.name) === 'p:domain_verify' || | ||
lowerIfExists(sn.attributes.name) === 'verify-v1' || | ||
lowerIfExists(sn.attributes.name) === 'verification' || | ||
lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
function serializeNodeWithId(n, options) { | ||
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.recordCanvas, recordCanvas = _d === void 0 ? false : _d, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _e = options.iframeLoadTimeout, iframeLoadTimeout = _e === void 0 ? 5000 : _e, _f = options.keepIframeSrcFn, keepIframeSrcFn = _f === void 0 ? function () { return false; } : _f; | ||
var _g = options.preserveWhiteSpace, preserveWhiteSpace = _g === void 0 ? true : _g; | ||
var _serializedNode = serializeNode(n, { | ||
doc: doc, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
recordCanvas: recordCanvas, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
}); | ||
if (!_serializedNode) { | ||
console.warn(n, 'not serialized'); | ||
return null; | ||
} | ||
var id; | ||
if ('__sn' in n) { | ||
id = n.__sn.id; | ||
} | ||
else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || | ||
(!preserveWhiteSpace && | ||
_serializedNode.type === exports.NodeType.Text && | ||
!_serializedNode.isStyle && | ||
!_serializedNode.textContent.replace(/^\s+|\s+$/gm, '').length)) { | ||
id = IGNORED_NODE; | ||
} | ||
else { | ||
id = genId(); | ||
} | ||
var serializedNode = Object.assign(_serializedNode, { id: id }); | ||
n.__sn = serializedNode; | ||
if (id === IGNORED_NODE) { | ||
return null; | ||
} | ||
map[id] = n; | ||
if (onSerialize) { | ||
onSerialize(n); | ||
} | ||
var recordChild = !skipChild; | ||
if (serializedNode.type === exports.NodeType.Element) { | ||
recordChild = recordChild && !serializedNode.needBlock; | ||
delete serializedNode.needBlock; | ||
} | ||
if ((serializedNode.type === exports.NodeType.Document || | ||
serializedNode.type === exports.NodeType.Element) && | ||
recordChild) { | ||
if (slimDOMOptions.headWhitespace && | ||
_serializedNode.type === exports.NodeType.Element && | ||
_serializedNode.tagName === 'head') { | ||
preserveWhiteSpace = false; | ||
} | ||
var bypassOptions = { | ||
doc: doc, | ||
map: map, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
skipChild: skipChild, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
slimDOMOptions: slimDOMOptions, | ||
recordCanvas: recordCanvas, | ||
preserveWhiteSpace: preserveWhiteSpace, | ||
onSerialize: onSerialize, | ||
onIframeLoad: onIframeLoad, | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
}; | ||
for (var _i = 0, _h = Array.from(n.childNodes); _i < _h.length; _i++) { | ||
var childN = _h[_i]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
if (serializedChildNode) { | ||
serializedNode.childNodes.push(serializedChildNode); | ||
} | ||
} | ||
if (isElement(n) && n.shadowRoot) { | ||
serializedNode.isShadowHost = true; | ||
for (var _j = 0, _k = Array.from(n.shadowRoot.childNodes); _j < _k.length; _j++) { | ||
var childN = _k[_j]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
if (serializedChildNode) { | ||
serializedChildNode.isShadow = true; | ||
serializedNode.childNodes.push(serializedChildNode); | ||
} | ||
} | ||
} | ||
} | ||
if (n.parentNode && isShadowRoot(n.parentNode)) { | ||
serializedNode.isShadow = true; | ||
} | ||
if (serializedNode.type === exports.NodeType.Element && | ||
serializedNode.tagName === 'iframe') { | ||
onceIframeLoaded(n, function () { | ||
var iframeDoc = n.contentDocument; | ||
if (iframeDoc && onIframeLoad) { | ||
var serializedIframeNode = serializeNodeWithId(iframeDoc, { | ||
doc: iframeDoc, | ||
map: map, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
skipChild: false, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
slimDOMOptions: slimDOMOptions, | ||
recordCanvas: recordCanvas, | ||
preserveWhiteSpace: preserveWhiteSpace, | ||
onSerialize: onSerialize, | ||
onIframeLoad: onIframeLoad, | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
}); | ||
if (serializedIframeNode) { | ||
onIframeLoad(n, serializedIframeNode); | ||
} | ||
} | ||
}, iframeLoadTimeout); | ||
} | ||
return serializedNode; | ||
} | ||
function snapshot(n, options) { | ||
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.recordCanvas, recordCanvas = _g === void 0 ? false : _g, _h = _a.maskAllInputs, maskAllInputs = _h === void 0 ? false : _h, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _j = _a.slimDOM, slimDOM = _j === void 0 ? false : _j, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _k = _a.keepIframeSrcFn, keepIframeSrcFn = _k === void 0 ? function () { return false; } : _k; | ||
var idNodeMap = {}; | ||
var maskInputOptions = maskAllInputs === true | ||
? { | ||
color: true, | ||
date: true, | ||
'datetime-local': true, | ||
email: true, | ||
month: true, | ||
number: true, | ||
range: true, | ||
search: true, | ||
tel: true, | ||
text: true, | ||
time: true, | ||
url: true, | ||
week: true, | ||
textarea: true, | ||
select: true, | ||
password: true, | ||
} | ||
: maskAllInputs === false | ||
? { | ||
password: true, | ||
} | ||
: maskAllInputs; | ||
var slimDOMOptions = slimDOM === true || slimDOM === 'all' | ||
? | ||
{ | ||
script: true, | ||
comment: true, | ||
headFavicon: true, | ||
headWhitespace: true, | ||
headMetaDescKeywords: slimDOM === 'all', | ||
headMetaSocial: true, | ||
headMetaRobots: true, | ||
headMetaHttpEquiv: true, | ||
headMetaAuthorship: true, | ||
headMetaVerification: true, | ||
} | ||
: slimDOM === false | ||
? {} | ||
: slimDOM; | ||
return [ | ||
serializeNodeWithId(n, { | ||
doc: n, | ||
map: idNodeMap, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
skipChild: false, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
slimDOMOptions: slimDOMOptions, | ||
recordCanvas: recordCanvas, | ||
preserveWhiteSpace: preserveWhiteSpace, | ||
onSerialize: onSerialize, | ||
onIframeLoad: onIframeLoad, | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
}), | ||
idNodeMap, | ||
]; | ||
} | ||
function visitSnapshot(node, onVisit) { | ||
function walk(current) { | ||
onVisit(current); | ||
if (current.type === exports.NodeType.Document || | ||
current.type === exports.NodeType.Element) { | ||
current.childNodes.forEach(walk); | ||
} | ||
} | ||
walk(node); | ||
} | ||
function cleanupSnapshot() { | ||
_id = 1; | ||
} | ||
var _id = 1; | ||
var tagNameRegex = RegExp('[^a-z0-9-_:]'); | ||
var IGNORED_NODE = -2; | ||
function genId() { | ||
return _id++; | ||
} | ||
function getValidTagName(element) { | ||
if (element instanceof HTMLFormElement) { | ||
return 'form'; | ||
} | ||
var processedTagName = element.tagName.toLowerCase().trim(); | ||
if (tagNameRegex.test(processedTagName)) { | ||
return 'div'; | ||
} | ||
return processedTagName; | ||
} | ||
function getCssRulesString(s) { | ||
try { | ||
var rules = s.rules || s.cssRules; | ||
return rules ? Array.from(rules).map(getCssRuleString).join('') : null; | ||
} | ||
catch (error) { | ||
return null; | ||
} | ||
} | ||
function getCssRuleString(rule) { | ||
var cssStringified = rule.cssText; | ||
if (isCSSImportRule(rule)) { | ||
try { | ||
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified; | ||
} | ||
catch (_a) { } | ||
} | ||
return cssStringified; | ||
} | ||
function isCSSImportRule(rule) { | ||
return 'styleSheet' in rule; | ||
} | ||
function extractOrigin(url) { | ||
var origin; | ||
if (url.indexOf('//') > -1) { | ||
origin = url.split('/').slice(0, 3).join('/'); | ||
} | ||
else { | ||
origin = url.split('/')[0]; | ||
} | ||
origin = origin.split('?')[0]; | ||
return origin; | ||
} | ||
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm; | ||
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/; | ||
var DATA_URI = /^(data:)([^,]*),(.*)/i; | ||
function absoluteToStylesheet(cssText, href) { | ||
return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) { | ||
var filePath = path1 || path2 || path3; | ||
var maybeQuote = quote1 || quote2 || ''; | ||
if (!filePath) { | ||
return origin; | ||
} | ||
if (!RELATIVE_PATH.test(filePath)) { | ||
return "url(" + maybeQuote + filePath + maybeQuote + ")"; | ||
} | ||
if (DATA_URI.test(filePath)) { | ||
return "url(" + maybeQuote + filePath + maybeQuote + ")"; | ||
} | ||
if (filePath[0] === '/') { | ||
return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")"; | ||
} | ||
var stack = href.split('/'); | ||
var parts = filePath.split('/'); | ||
stack.pop(); | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
if (part === '.') { | ||
continue; | ||
} | ||
else if (part === '..') { | ||
stack.pop(); | ||
} | ||
else { | ||
stack.push(part); | ||
} | ||
} | ||
return "url(" + maybeQuote + stack.join('/') + maybeQuote + ")"; | ||
}); | ||
} | ||
var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/; | ||
var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/; | ||
function getAbsoluteSrcsetString(doc, attributeValue) { | ||
if (attributeValue.trim() === '') { | ||
return attributeValue; | ||
} | ||
var pos = 0; | ||
function collectCharacters(regEx) { | ||
var chars, match = regEx.exec(attributeValue.substring(pos)); | ||
if (match) { | ||
chars = match[0]; | ||
pos += chars.length; | ||
return chars; | ||
} | ||
return ''; | ||
} | ||
var output = []; | ||
while (true) { | ||
collectCharacters(SRCSET_COMMAS_OR_SPACES); | ||
if (pos >= attributeValue.length) { | ||
break; | ||
} | ||
var url = collectCharacters(SRCSET_NOT_SPACES); | ||
if (url.slice(-1) === ',') { | ||
url = absoluteToDoc(doc, url.substring(0, url.length - 1)); | ||
output.push(url); | ||
} | ||
else { | ||
var descriptorsStr = ''; | ||
url = absoluteToDoc(doc, url); | ||
var inParens = false; | ||
while (true) { | ||
var c = attributeValue.charAt(pos); | ||
if (c === '') { | ||
output.push((url + descriptorsStr).trim()); | ||
break; | ||
} | ||
else if (!inParens) { | ||
if (c === ',') { | ||
pos += 1; | ||
output.push((url + descriptorsStr).trim()); | ||
break; | ||
} | ||
else if (c === '(') { | ||
inParens = true; | ||
} | ||
} | ||
else { | ||
if (c === ')') { | ||
inParens = false; | ||
} | ||
} | ||
descriptorsStr += c; | ||
pos += 1; | ||
} | ||
} | ||
} | ||
return output.join(', '); | ||
} | ||
function absoluteToDoc(doc, attributeValue) { | ||
if (!attributeValue || attributeValue.trim() === '') { | ||
return attributeValue; | ||
} | ||
var a = doc.createElement('a'); | ||
a.href = attributeValue; | ||
return a.href; | ||
} | ||
function isSVGElement(el) { | ||
return el.tagName === 'svg' || el instanceof SVGElement; | ||
} | ||
function getHref() { | ||
var a = document.createElement('a'); | ||
a.href = ''; | ||
return a.href; | ||
} | ||
function transformAttribute(doc, tagName, name, value) { | ||
if (name === 'src' || ((name === 'href' || name === 'xlink:href') && value)) { | ||
return absoluteToDoc(doc, value); | ||
} | ||
else if (name === 'background' && | ||
value && | ||
(tagName === 'table' || tagName === 'td' || tagName === 'th')) { | ||
return absoluteToDoc(doc, value); | ||
} | ||
else if (name === 'srcset' && value) { | ||
return getAbsoluteSrcsetString(doc, value); | ||
} | ||
else if (name === 'style' && value) { | ||
return absoluteToStylesheet(value, getHref()); | ||
} | ||
else { | ||
return value; | ||
} | ||
} | ||
function _isBlockedElement(element, blockClass, blockSelector) { | ||
if (typeof blockClass === 'string') { | ||
if (element.classList.contains(blockClass)) { | ||
return true; | ||
} | ||
} | ||
else { | ||
for (var eIndex = 0; eIndex < element.classList.length; eIndex++) { | ||
var className = element.classList[eIndex]; | ||
if (blockClass.test(className)) { | ||
return true; | ||
} | ||
} | ||
} | ||
if (blockSelector) { | ||
return element.matches(blockSelector); | ||
} | ||
return false; | ||
} | ||
function needMaskingText(node, maskTextClass, maskTextSelector) { | ||
if (!node) { | ||
return false; | ||
} | ||
if (node.nodeType === node.ELEMENT_NODE) { | ||
if (typeof maskTextClass === 'string') { | ||
if (node.classList.contains(maskTextClass)) { | ||
return true; | ||
} | ||
} | ||
else { | ||
node.classList.forEach(function (className) { | ||
if (maskTextClass.test(className)) { | ||
return true; | ||
} | ||
}); | ||
} | ||
if (maskTextSelector) { | ||
if (node.matches(maskTextSelector)) { | ||
return true; | ||
} | ||
} | ||
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); | ||
} | ||
if (node.nodeType === node.TEXT_NODE) { | ||
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); | ||
} | ||
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector); | ||
} | ||
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) { | ||
var win = iframeEl.contentWindow; | ||
if (!win) { | ||
return; | ||
} | ||
var fired = false; | ||
var readyState; | ||
try { | ||
readyState = win.document.readyState; | ||
} | ||
catch (error) { | ||
return; | ||
} | ||
if (readyState !== 'complete') { | ||
var timer_1 = setTimeout(function () { | ||
if (!fired) { | ||
listener(); | ||
fired = true; | ||
} | ||
}, iframeLoadTimeout); | ||
iframeEl.addEventListener('load', function () { | ||
clearTimeout(timer_1); | ||
fired = true; | ||
listener(); | ||
}); | ||
return; | ||
} | ||
var blankUrl = 'about:blank'; | ||
if (win.location.href !== blankUrl || | ||
iframeEl.src === blankUrl || | ||
iframeEl.src === '') { | ||
setTimeout(listener, 0); | ||
return; | ||
} | ||
iframeEl.addEventListener('load', listener); | ||
} | ||
function serializeNode(n, options) { | ||
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn; | ||
var rootId; | ||
if (doc.__sn) { | ||
var docId = doc.__sn.id; | ||
rootId = docId === 1 ? undefined : docId; | ||
} | ||
switch (n.nodeType) { | ||
case n.DOCUMENT_NODE: | ||
if (n.compatMode !== 'CSS1Compat') { | ||
return { | ||
type: exports.NodeType.Document, | ||
childNodes: [], | ||
compatMode: n.compatMode, | ||
rootId: rootId | ||
}; | ||
} | ||
else { | ||
return { | ||
type: exports.NodeType.Document, | ||
childNodes: [], | ||
rootId: rootId | ||
}; | ||
} | ||
case n.DOCUMENT_TYPE_NODE: | ||
return { | ||
type: exports.NodeType.DocumentType, | ||
name: n.name, | ||
publicId: n.publicId, | ||
systemId: n.systemId, | ||
rootId: rootId | ||
}; | ||
case n.ELEMENT_NODE: | ||
var needBlock = _isBlockedElement(n, blockClass, blockSelector); | ||
var tagName = getValidTagName(n); | ||
var attributes = {}; | ||
for (var _i = 0, _b = Array.from(n.attributes); _i < _b.length; _i++) { | ||
var _c = _b[_i], name_1 = _c.name, value = _c.value; | ||
attributes[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
} | ||
if (tagName === 'link' && inlineStylesheet) { | ||
var stylesheet = Array.from(doc.styleSheets).find(function (s) { | ||
return s.href === n.href; | ||
}); | ||
var cssText = getCssRulesString(stylesheet); | ||
if (cssText) { | ||
delete attributes.rel; | ||
delete attributes.href; | ||
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
} | ||
} | ||
if (tagName === 'style' && | ||
n.sheet && | ||
!(n.innerText || | ||
n.textContent || | ||
'').trim().length) { | ||
var cssText = getCssRulesString(n.sheet); | ||
if (cssText) { | ||
attributes._cssText = absoluteToStylesheet(cssText, getHref()); | ||
} | ||
} | ||
if (tagName === 'input' || | ||
tagName === 'textarea' || | ||
tagName === 'select') { | ||
var value = n.value; | ||
if (attributes.type !== 'radio' && | ||
attributes.type !== 'checkbox' && | ||
attributes.type !== 'submit' && | ||
attributes.type !== 'button' && | ||
value) { | ||
attributes.value = maskInputValue({ | ||
type: attributes.type, | ||
tagName: tagName, | ||
value: value, | ||
maskInputOptions: maskInputOptions, | ||
maskInputFn: maskInputFn | ||
}); | ||
} | ||
else if (n.checked) { | ||
attributes.checked = n.checked; | ||
} | ||
} | ||
if (tagName === 'option') { | ||
if (n.selected) { | ||
attributes.selected = true; | ||
} | ||
else { | ||
delete attributes.selected; | ||
} | ||
} | ||
if (tagName === 'canvas' && recordCanvas) { | ||
attributes.rr_dataURL = n.toDataURL(); | ||
} | ||
if (tagName === 'audio' || tagName === 'video') { | ||
attributes.rr_mediaState = n.paused | ||
? 'paused' | ||
: 'played'; | ||
attributes.rr_mediaCurrentTime = n.currentTime; | ||
} | ||
if (n.scrollLeft) { | ||
attributes.rr_scrollLeft = n.scrollLeft; | ||
} | ||
if (n.scrollTop) { | ||
attributes.rr_scrollTop = n.scrollTop; | ||
} | ||
if (needBlock) { | ||
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height; | ||
attributes = { | ||
"class": attributes["class"], | ||
rr_width: width + "px", | ||
rr_height: height + "px" | ||
}; | ||
} | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) { | ||
delete attributes.src; | ||
} | ||
return { | ||
type: exports.NodeType.Element, | ||
tagName: tagName, | ||
attributes: attributes, | ||
childNodes: [], | ||
isSVG: isSVGElement(n) || undefined, | ||
needBlock: needBlock, | ||
rootId: rootId | ||
}; | ||
case n.TEXT_NODE: | ||
var parentTagName = n.parentNode && n.parentNode.tagName; | ||
var textContent = n.textContent; | ||
var isStyle = parentTagName === 'STYLE' ? true : undefined; | ||
var isScript = parentTagName === 'SCRIPT' ? true : undefined; | ||
if (isStyle && textContent) { | ||
textContent = absoluteToStylesheet(textContent, getHref()); | ||
} | ||
if (isScript) { | ||
textContent = 'SCRIPT_PLACEHOLDER'; | ||
} | ||
if (!isStyle && | ||
!isScript && | ||
needMaskingText(n, maskTextClass, maskTextSelector) && | ||
textContent) { | ||
textContent = maskTextFn | ||
? maskTextFn(textContent) | ||
: textContent.replace(/[\S]/g, '*'); | ||
} | ||
return { | ||
type: exports.NodeType.Text, | ||
textContent: textContent || '', | ||
isStyle: isStyle, | ||
rootId: rootId | ||
}; | ||
case n.CDATA_SECTION_NODE: | ||
return { | ||
type: exports.NodeType.CDATA, | ||
textContent: '', | ||
rootId: rootId | ||
}; | ||
case n.COMMENT_NODE: | ||
return { | ||
type: exports.NodeType.Comment, | ||
textContent: n.textContent || '', | ||
rootId: rootId | ||
}; | ||
default: | ||
return false; | ||
} | ||
} | ||
function lowerIfExists(maybeAttr) { | ||
if (maybeAttr === undefined) { | ||
return ''; | ||
} | ||
else { | ||
return maybeAttr.toLowerCase(); | ||
} | ||
} | ||
function slimDOMExcluded(sn, slimDOMOptions) { | ||
if (slimDOMOptions.comment && sn.type === exports.NodeType.Comment) { | ||
return true; | ||
} | ||
else if (sn.type === exports.NodeType.Element) { | ||
if (slimDOMOptions.script && | ||
(sn.tagName === 'script' || | ||
(sn.tagName === 'link' && | ||
sn.attributes.rel === 'preload' && | ||
sn.attributes.as === 'script') || | ||
(sn.tagName === 'link' && | ||
sn.attributes.rel === 'prefetch' && | ||
typeof sn.attributes.href === 'string' && | ||
sn.attributes.href.endsWith('.js')))) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headFavicon && | ||
((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') || | ||
(sn.tagName === 'meta' && | ||
(lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || | ||
lowerIfExists(sn.attributes.name) === 'application-name' || | ||
lowerIfExists(sn.attributes.rel) === 'icon' || | ||
lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' || | ||
lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) { | ||
return true; | ||
} | ||
else if (sn.tagName === 'meta') { | ||
if (slimDOMOptions.headMetaDescKeywords && | ||
lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaSocial && | ||
(lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || | ||
lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || | ||
lowerIfExists(sn.attributes.name) === 'pinterest')) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaRobots && | ||
(lowerIfExists(sn.attributes.name) === 'robots' || | ||
lowerIfExists(sn.attributes.name) === 'googlebot' || | ||
lowerIfExists(sn.attributes.name) === 'bingbot')) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaHttpEquiv && | ||
sn.attributes['http-equiv'] !== undefined) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaAuthorship && | ||
(lowerIfExists(sn.attributes.name) === 'author' || | ||
lowerIfExists(sn.attributes.name) === 'generator' || | ||
lowerIfExists(sn.attributes.name) === 'framework' || | ||
lowerIfExists(sn.attributes.name) === 'publisher' || | ||
lowerIfExists(sn.attributes.name) === 'progid' || | ||
lowerIfExists(sn.attributes.property).match(/^article:/) || | ||
lowerIfExists(sn.attributes.property).match(/^product:/))) { | ||
return true; | ||
} | ||
else if (slimDOMOptions.headMetaVerification && | ||
(lowerIfExists(sn.attributes.name) === 'google-site-verification' || | ||
lowerIfExists(sn.attributes.name) === 'yandex-verification' || | ||
lowerIfExists(sn.attributes.name) === 'csrf-token' || | ||
lowerIfExists(sn.attributes.name) === 'p:domain_verify' || | ||
lowerIfExists(sn.attributes.name) === 'verify-v1' || | ||
lowerIfExists(sn.attributes.name) === 'verification' || | ||
lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
function serializeNodeWithId(n, options) { | ||
var doc = options.doc, map = options.map, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.recordCanvas, recordCanvas = _d === void 0 ? false : _d, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _e = options.iframeLoadTimeout, iframeLoadTimeout = _e === void 0 ? 5000 : _e, _f = options.keepIframeSrcFn, keepIframeSrcFn = _f === void 0 ? function () { return false; } : _f; | ||
var _g = options.preserveWhiteSpace, preserveWhiteSpace = _g === void 0 ? true : _g; | ||
var _serializedNode = serializeNode(n, { | ||
doc: doc, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
recordCanvas: recordCanvas, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}); | ||
if (!_serializedNode) { | ||
console.warn(n, 'not serialized'); | ||
return null; | ||
} | ||
var id; | ||
if ('__sn' in n) { | ||
id = n.__sn.id; | ||
} | ||
else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || | ||
(!preserveWhiteSpace && | ||
_serializedNode.type === exports.NodeType.Text && | ||
!_serializedNode.isStyle && | ||
!_serializedNode.textContent.replace(/^\s+|\s+$/gm, '').length)) { | ||
id = IGNORED_NODE; | ||
} | ||
else { | ||
id = genId(); | ||
} | ||
var serializedNode = Object.assign(_serializedNode, { id: id }); | ||
n.__sn = serializedNode; | ||
if (id === IGNORED_NODE) { | ||
return null; | ||
} | ||
map[id] = n; | ||
if (onSerialize) { | ||
onSerialize(n); | ||
} | ||
var recordChild = !skipChild; | ||
if (serializedNode.type === exports.NodeType.Element) { | ||
recordChild = recordChild && !serializedNode.needBlock; | ||
delete serializedNode.needBlock; | ||
} | ||
if ((serializedNode.type === exports.NodeType.Document || | ||
serializedNode.type === exports.NodeType.Element) && | ||
recordChild) { | ||
if (slimDOMOptions.headWhitespace && | ||
_serializedNode.type === exports.NodeType.Element && | ||
_serializedNode.tagName === 'head') { | ||
preserveWhiteSpace = false; | ||
} | ||
var bypassOptions = { | ||
doc: doc, | ||
map: map, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
skipChild: skipChild, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
slimDOMOptions: slimDOMOptions, | ||
recordCanvas: recordCanvas, | ||
preserveWhiteSpace: preserveWhiteSpace, | ||
onSerialize: onSerialize, | ||
onIframeLoad: onIframeLoad, | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}; | ||
for (var _i = 0, _h = Array.from(n.childNodes); _i < _h.length; _i++) { | ||
var childN = _h[_i]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
if (serializedChildNode) { | ||
serializedNode.childNodes.push(serializedChildNode); | ||
} | ||
} | ||
if (isElement(n) && n.shadowRoot) { | ||
serializedNode.isShadowHost = true; | ||
for (var _j = 0, _k = Array.from(n.shadowRoot.childNodes); _j < _k.length; _j++) { | ||
var childN = _k[_j]; | ||
var serializedChildNode = serializeNodeWithId(childN, bypassOptions); | ||
if (serializedChildNode) { | ||
serializedChildNode.isShadow = true; | ||
serializedNode.childNodes.push(serializedChildNode); | ||
} | ||
} | ||
} | ||
} | ||
if (n.parentNode && isShadowRoot(n.parentNode)) { | ||
serializedNode.isShadow = true; | ||
} | ||
if (serializedNode.type === exports.NodeType.Element && | ||
serializedNode.tagName === 'iframe') { | ||
onceIframeLoaded(n, function () { | ||
var iframeDoc = n.contentDocument; | ||
if (iframeDoc && onIframeLoad) { | ||
var serializedIframeNode = serializeNodeWithId(iframeDoc, { | ||
doc: iframeDoc, | ||
map: map, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
skipChild: false, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
slimDOMOptions: slimDOMOptions, | ||
recordCanvas: recordCanvas, | ||
preserveWhiteSpace: preserveWhiteSpace, | ||
onSerialize: onSerialize, | ||
onIframeLoad: onIframeLoad, | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}); | ||
if (serializedIframeNode) { | ||
onIframeLoad(n, serializedIframeNode); | ||
} | ||
} | ||
}, iframeLoadTimeout); | ||
} | ||
return serializedNode; | ||
} | ||
function snapshot(n, options) { | ||
var _a = options || {}, _b = _a.blockClass, blockClass = _b === void 0 ? 'rr-block' : _b, _c = _a.blockSelector, blockSelector = _c === void 0 ? null : _c, _d = _a.maskTextClass, maskTextClass = _d === void 0 ? 'rr-mask' : _d, _e = _a.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = _a.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, _g = _a.recordCanvas, recordCanvas = _g === void 0 ? false : _g, _h = _a.maskAllInputs, maskAllInputs = _h === void 0 ? false : _h, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _j = _a.slimDOM, slimDOM = _j === void 0 ? false : _j, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, _k = _a.keepIframeSrcFn, keepIframeSrcFn = _k === void 0 ? function () { return false; } : _k; | ||
var idNodeMap = {}; | ||
var maskInputOptions = maskAllInputs === true | ||
? { | ||
color: true, | ||
date: true, | ||
'datetime-local': true, | ||
email: true, | ||
month: true, | ||
number: true, | ||
range: true, | ||
search: true, | ||
tel: true, | ||
text: true, | ||
time: true, | ||
url: true, | ||
week: true, | ||
textarea: true, | ||
select: true, | ||
password: true | ||
} | ||
: maskAllInputs === false | ||
? { | ||
password: true | ||
} | ||
: maskAllInputs; | ||
var slimDOMOptions = slimDOM === true || slimDOM === 'all' | ||
? | ||
{ | ||
script: true, | ||
comment: true, | ||
headFavicon: true, | ||
headWhitespace: true, | ||
headMetaDescKeywords: slimDOM === 'all', | ||
headMetaSocial: true, | ||
headMetaRobots: true, | ||
headMetaHttpEquiv: true, | ||
headMetaAuthorship: true, | ||
headMetaVerification: true | ||
} | ||
: slimDOM === false | ||
? {} | ||
: slimDOM; | ||
return [ | ||
serializeNodeWithId(n, { | ||
doc: n, | ||
map: idNodeMap, | ||
blockClass: blockClass, | ||
blockSelector: blockSelector, | ||
maskTextClass: maskTextClass, | ||
maskTextSelector: maskTextSelector, | ||
skipChild: false, | ||
inlineStylesheet: inlineStylesheet, | ||
maskInputOptions: maskInputOptions, | ||
maskTextFn: maskTextFn, | ||
maskInputFn: maskInputFn, | ||
slimDOMOptions: slimDOMOptions, | ||
recordCanvas: recordCanvas, | ||
preserveWhiteSpace: preserveWhiteSpace, | ||
onSerialize: onSerialize, | ||
onIframeLoad: onIframeLoad, | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}), | ||
idNodeMap, | ||
]; | ||
} | ||
function visitSnapshot(node, onVisit) { | ||
function walk(current) { | ||
onVisit(current); | ||
if (current.type === exports.NodeType.Document || | ||
current.type === exports.NodeType.Element) { | ||
current.childNodes.forEach(walk); | ||
} | ||
} | ||
walk(node); | ||
} | ||
function cleanupSnapshot() { | ||
_id = 1; | ||
} | ||
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; | ||
function parse(css, options) { | ||
if (options === void 0) { options = {}; } | ||
var lineno = 1; | ||
var column = 1; | ||
function updatePosition(str) { | ||
var lines = str.match(/\n/g); | ||
if (lines) { | ||
lineno += lines.length; | ||
} | ||
var i = str.lastIndexOf('\n'); | ||
column = i === -1 ? column + str.length : str.length - i; | ||
} | ||
function position() { | ||
var start = { line: lineno, column: column }; | ||
return function (node) { | ||
node.position = new Position(start); | ||
whitespace(); | ||
return node; | ||
}; | ||
} | ||
var Position = (function () { | ||
function Position(start) { | ||
this.start = start; | ||
this.end = { line: lineno, column: column }; | ||
this.source = options.source; | ||
} | ||
return Position; | ||
}()); | ||
Position.prototype.content = css; | ||
var errorsList = []; | ||
function error(msg) { | ||
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); | ||
err.reason = msg; | ||
err.filename = options.source; | ||
err.line = lineno; | ||
err.column = column; | ||
err.source = css; | ||
if (options.silent) { | ||
errorsList.push(err); | ||
} | ||
else { | ||
throw err; | ||
} | ||
} | ||
function stylesheet() { | ||
var rulesList = rules(); | ||
return { | ||
type: 'stylesheet', | ||
stylesheet: { | ||
source: options.source, | ||
rules: rulesList, | ||
parsingErrors: errorsList, | ||
}, | ||
}; | ||
} | ||
function open() { | ||
return match(/^{\s*/); | ||
} | ||
function close() { | ||
return match(/^}/); | ||
} | ||
function rules() { | ||
var node; | ||
var rules = []; | ||
whitespace(); | ||
comments(rules); | ||
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) { | ||
if (node !== false) { | ||
rules.push(node); | ||
comments(rules); | ||
} | ||
} | ||
return rules; | ||
} | ||
function match(re) { | ||
var m = re.exec(css); | ||
if (!m) { | ||
return; | ||
} | ||
var str = m[0]; | ||
updatePosition(str); | ||
css = css.slice(str.length); | ||
return m; | ||
} | ||
function whitespace() { | ||
match(/^\s*/); | ||
} | ||
function comments(rules) { | ||
if (rules === void 0) { rules = []; } | ||
var c; | ||
while ((c = comment())) { | ||
if (c !== false) { | ||
rules.push(c); | ||
} | ||
c = comment(); | ||
} | ||
return rules; | ||
} | ||
function comment() { | ||
var pos = position(); | ||
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) { | ||
return; | ||
} | ||
var i = 2; | ||
while ('' !== css.charAt(i) && | ||
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) { | ||
++i; | ||
} | ||
i += 2; | ||
if ('' === css.charAt(i - 1)) { | ||
return error('End of comment missing'); | ||
} | ||
var str = css.slice(2, i - 2); | ||
column += 2; | ||
updatePosition(str); | ||
css = css.slice(i); | ||
column += 2; | ||
return pos({ | ||
type: 'comment', | ||
comment: str, | ||
}); | ||
} | ||
function selector() { | ||
var m = match(/^([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
return trim(m[0]) | ||
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') | ||
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) { | ||
return m.replace(/,/g, '\u200C'); | ||
}) | ||
.split(/\s*(?![^(]*\)),\s*/) | ||
.map(function (s) { | ||
return s.replace(/\u200C/g, ','); | ||
}); | ||
} | ||
function declaration() { | ||
var pos = position(); | ||
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); | ||
if (!propMatch) { | ||
return; | ||
} | ||
var prop = trim(propMatch[0]); | ||
if (!match(/^:\s*/)) { | ||
return error("property missing ':'"); | ||
} | ||
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); | ||
var ret = pos({ | ||
type: 'declaration', | ||
property: prop.replace(commentre, ''), | ||
value: val ? trim(val[0]).replace(commentre, '') : '', | ||
}); | ||
match(/^[;\s]*/); | ||
return ret; | ||
} | ||
function declarations() { | ||
var decls = []; | ||
if (!open()) { | ||
return error("missing '{'"); | ||
} | ||
comments(decls); | ||
var decl; | ||
while ((decl = declaration())) { | ||
if (decl !== false) { | ||
decls.push(decl); | ||
comments(decls); | ||
} | ||
decl = declaration(); | ||
} | ||
if (!close()) { | ||
return error("missing '}'"); | ||
} | ||
return decls; | ||
} | ||
function keyframe() { | ||
var m; | ||
var vals = []; | ||
var pos = position(); | ||
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) { | ||
vals.push(m[1]); | ||
match(/^,\s*/); | ||
} | ||
if (!vals.length) { | ||
return; | ||
} | ||
return pos({ | ||
type: 'keyframe', | ||
values: vals, | ||
declarations: declarations(), | ||
}); | ||
} | ||
function atkeyframes() { | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?keyframes\s*/); | ||
if (!m) { | ||
return; | ||
} | ||
var vendor = m[1]; | ||
m = match(/^([-\w]+)\s*/); | ||
if (!m) { | ||
return error('@keyframes missing name'); | ||
} | ||
var name = m[1]; | ||
if (!open()) { | ||
return error("@keyframes missing '{'"); | ||
} | ||
var frame; | ||
var frames = comments(); | ||
while ((frame = keyframe())) { | ||
frames.push(frame); | ||
frames = frames.concat(comments()); | ||
} | ||
if (!close()) { | ||
return error("@keyframes missing '}'"); | ||
} | ||
return pos({ | ||
type: 'keyframes', | ||
name: name, | ||
vendor: vendor, | ||
keyframes: frames, | ||
}); | ||
} | ||
function atsupports() { | ||
var pos = position(); | ||
var m = match(/^@supports *([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
var supports = trim(m[1]); | ||
if (!open()) { | ||
return error("@supports missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@supports missing '}'"); | ||
} | ||
return pos({ | ||
type: 'supports', | ||
supports: supports, | ||
rules: style, | ||
}); | ||
} | ||
function athost() { | ||
var pos = position(); | ||
var m = match(/^@host\s*/); | ||
if (!m) { | ||
return; | ||
} | ||
if (!open()) { | ||
return error("@host missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@host missing '}'"); | ||
} | ||
return pos({ | ||
type: 'host', | ||
rules: style, | ||
}); | ||
} | ||
function atmedia() { | ||
var pos = position(); | ||
var m = match(/^@media *([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
var media = trim(m[1]); | ||
if (!open()) { | ||
return error("@media missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@media missing '}'"); | ||
} | ||
return pos({ | ||
type: 'media', | ||
media: media, | ||
rules: style, | ||
}); | ||
} | ||
function atcustommedia() { | ||
var pos = position(); | ||
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); | ||
if (!m) { | ||
return; | ||
} | ||
return pos({ | ||
type: 'custom-media', | ||
name: trim(m[1]), | ||
media: trim(m[2]), | ||
}); | ||
} | ||
function atpage() { | ||
var pos = position(); | ||
var m = match(/^@page */); | ||
if (!m) { | ||
return; | ||
} | ||
var sel = selector() || []; | ||
if (!open()) { | ||
return error("@page missing '{'"); | ||
} | ||
var decls = comments(); | ||
var decl; | ||
while ((decl = declaration())) { | ||
decls.push(decl); | ||
decls = decls.concat(comments()); | ||
} | ||
if (!close()) { | ||
return error("@page missing '}'"); | ||
} | ||
return pos({ | ||
type: 'page', | ||
selectors: sel, | ||
declarations: decls, | ||
}); | ||
} | ||
function atdocument() { | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?document *([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
var vendor = trim(m[1]); | ||
var doc = trim(m[2]); | ||
if (!open()) { | ||
return error("@document missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@document missing '}'"); | ||
} | ||
return pos({ | ||
type: 'document', | ||
document: doc, | ||
vendor: vendor, | ||
rules: style, | ||
}); | ||
} | ||
function atfontface() { | ||
var pos = position(); | ||
var m = match(/^@font-face\s*/); | ||
if (!m) { | ||
return; | ||
} | ||
if (!open()) { | ||
return error("@font-face missing '{'"); | ||
} | ||
var decls = comments(); | ||
var decl; | ||
while ((decl = declaration())) { | ||
decls.push(decl); | ||
decls = decls.concat(comments()); | ||
} | ||
if (!close()) { | ||
return error("@font-face missing '}'"); | ||
} | ||
return pos({ | ||
type: 'font-face', | ||
declarations: decls, | ||
}); | ||
} | ||
var atimport = _compileAtrule('import'); | ||
var atcharset = _compileAtrule('charset'); | ||
var atnamespace = _compileAtrule('namespace'); | ||
function _compileAtrule(name) { | ||
var re = new RegExp('^@' + name + '\\s*([^;]+);'); | ||
return function () { | ||
var pos = position(); | ||
var m = match(re); | ||
if (!m) { | ||
return; | ||
} | ||
var ret = { type: name }; | ||
ret[name] = m[1].trim(); | ||
return pos(ret); | ||
}; | ||
} | ||
function atrule() { | ||
if (css[0] !== '@') { | ||
return; | ||
} | ||
return (atkeyframes() || | ||
atmedia() || | ||
atcustommedia() || | ||
atsupports() || | ||
atimport() || | ||
atcharset() || | ||
atnamespace() || | ||
atdocument() || | ||
atpage() || | ||
athost() || | ||
atfontface()); | ||
} | ||
function rule() { | ||
var pos = position(); | ||
var sel = selector(); | ||
if (!sel) { | ||
return error('selector missing'); | ||
} | ||
comments(); | ||
return pos({ | ||
type: 'rule', | ||
selectors: sel, | ||
declarations: declarations(), | ||
}); | ||
} | ||
return addParent(stylesheet()); | ||
} | ||
function trim(str) { | ||
return str ? str.replace(/^\s+|\s+$/g, '') : ''; | ||
} | ||
function addParent(obj, parent) { | ||
var isNode = obj && typeof obj.type === 'string'; | ||
var childParent = isNode ? obj : parent; | ||
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { | ||
var k = _a[_i]; | ||
var value = obj[k]; | ||
if (Array.isArray(value)) { | ||
value.forEach(function (v) { | ||
addParent(v, childParent); | ||
}); | ||
} | ||
else if (value && typeof value === 'object') { | ||
addParent(value, childParent); | ||
} | ||
} | ||
if (isNode) { | ||
Object.defineProperty(obj, 'parent', { | ||
configurable: true, | ||
writable: true, | ||
enumerable: false, | ||
value: parent || null, | ||
}); | ||
} | ||
return obj; | ||
} | ||
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; | ||
function parse(css, options) { | ||
if (options === void 0) { options = {}; } | ||
var lineno = 1; | ||
var column = 1; | ||
function updatePosition(str) { | ||
var lines = str.match(/\n/g); | ||
if (lines) { | ||
lineno += lines.length; | ||
} | ||
var i = str.lastIndexOf('\n'); | ||
column = i === -1 ? column + str.length : str.length - i; | ||
} | ||
function position() { | ||
var start = { line: lineno, column: column }; | ||
return function (node) { | ||
node.position = new Position(start); | ||
whitespace(); | ||
return node; | ||
}; | ||
} | ||
var Position = (function () { | ||
function Position(start) { | ||
this.start = start; | ||
this.end = { line: lineno, column: column }; | ||
this.source = options.source; | ||
} | ||
return Position; | ||
}()); | ||
Position.prototype.content = css; | ||
var errorsList = []; | ||
function error(msg) { | ||
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); | ||
err.reason = msg; | ||
err.filename = options.source; | ||
err.line = lineno; | ||
err.column = column; | ||
err.source = css; | ||
if (options.silent) { | ||
errorsList.push(err); | ||
} | ||
else { | ||
throw err; | ||
} | ||
} | ||
function stylesheet() { | ||
var rulesList = rules(); | ||
return { | ||
type: 'stylesheet', | ||
stylesheet: { | ||
source: options.source, | ||
rules: rulesList, | ||
parsingErrors: errorsList | ||
} | ||
}; | ||
} | ||
function open() { | ||
return match(/^{\s*/); | ||
} | ||
function close() { | ||
return match(/^}/); | ||
} | ||
function rules() { | ||
var node; | ||
var rules = []; | ||
whitespace(); | ||
comments(rules); | ||
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) { | ||
if (node !== false) { | ||
rules.push(node); | ||
comments(rules); | ||
} | ||
} | ||
return rules; | ||
} | ||
function match(re) { | ||
var m = re.exec(css); | ||
if (!m) { | ||
return; | ||
} | ||
var str = m[0]; | ||
updatePosition(str); | ||
css = css.slice(str.length); | ||
return m; | ||
} | ||
function whitespace() { | ||
match(/^\s*/); | ||
} | ||
function comments(rules) { | ||
if (rules === void 0) { rules = []; } | ||
var c; | ||
while ((c = comment())) { | ||
if (c !== false) { | ||
rules.push(c); | ||
} | ||
c = comment(); | ||
} | ||
return rules; | ||
} | ||
function comment() { | ||
var pos = position(); | ||
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) { | ||
return; | ||
} | ||
var i = 2; | ||
while ('' !== css.charAt(i) && | ||
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) { | ||
++i; | ||
} | ||
i += 2; | ||
if ('' === css.charAt(i - 1)) { | ||
return error('End of comment missing'); | ||
} | ||
var str = css.slice(2, i - 2); | ||
column += 2; | ||
updatePosition(str); | ||
css = css.slice(i); | ||
column += 2; | ||
return pos({ | ||
type: 'comment', | ||
comment: str | ||
}); | ||
} | ||
function selector() { | ||
var m = match(/^([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
return trim(m[0]) | ||
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') | ||
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) { | ||
return m.replace(/,/g, '\u200C'); | ||
}) | ||
.split(/\s*(?![^(]*\)),\s*/) | ||
.map(function (s) { | ||
return s.replace(/\u200C/g, ','); | ||
}); | ||
} | ||
function declaration() { | ||
var pos = position(); | ||
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); | ||
if (!propMatch) { | ||
return; | ||
} | ||
var prop = trim(propMatch[0]); | ||
if (!match(/^:\s*/)) { | ||
return error("property missing ':'"); | ||
} | ||
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); | ||
var ret = pos({ | ||
type: 'declaration', | ||
property: prop.replace(commentre, ''), | ||
value: val ? trim(val[0]).replace(commentre, '') : '' | ||
}); | ||
match(/^[;\s]*/); | ||
return ret; | ||
} | ||
function declarations() { | ||
var decls = []; | ||
if (!open()) { | ||
return error("missing '{'"); | ||
} | ||
comments(decls); | ||
var decl; | ||
while ((decl = declaration())) { | ||
if (decl !== false) { | ||
decls.push(decl); | ||
comments(decls); | ||
} | ||
decl = declaration(); | ||
} | ||
if (!close()) { | ||
return error("missing '}'"); | ||
} | ||
return decls; | ||
} | ||
function keyframe() { | ||
var m; | ||
var vals = []; | ||
var pos = position(); | ||
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) { | ||
vals.push(m[1]); | ||
match(/^,\s*/); | ||
} | ||
if (!vals.length) { | ||
return; | ||
} | ||
return pos({ | ||
type: 'keyframe', | ||
values: vals, | ||
declarations: declarations() | ||
}); | ||
} | ||
function atkeyframes() { | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?keyframes\s*/); | ||
if (!m) { | ||
return; | ||
} | ||
var vendor = m[1]; | ||
m = match(/^([-\w]+)\s*/); | ||
if (!m) { | ||
return error('@keyframes missing name'); | ||
} | ||
var name = m[1]; | ||
if (!open()) { | ||
return error("@keyframes missing '{'"); | ||
} | ||
var frame; | ||
var frames = comments(); | ||
while ((frame = keyframe())) { | ||
frames.push(frame); | ||
frames = frames.concat(comments()); | ||
} | ||
if (!close()) { | ||
return error("@keyframes missing '}'"); | ||
} | ||
return pos({ | ||
type: 'keyframes', | ||
name: name, | ||
vendor: vendor, | ||
keyframes: frames | ||
}); | ||
} | ||
function atsupports() { | ||
var pos = position(); | ||
var m = match(/^@supports *([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
var supports = trim(m[1]); | ||
if (!open()) { | ||
return error("@supports missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@supports missing '}'"); | ||
} | ||
return pos({ | ||
type: 'supports', | ||
supports: supports, | ||
rules: style | ||
}); | ||
} | ||
function athost() { | ||
var pos = position(); | ||
var m = match(/^@host\s*/); | ||
if (!m) { | ||
return; | ||
} | ||
if (!open()) { | ||
return error("@host missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@host missing '}'"); | ||
} | ||
return pos({ | ||
type: 'host', | ||
rules: style | ||
}); | ||
} | ||
function atmedia() { | ||
var pos = position(); | ||
var m = match(/^@media *([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
var media = trim(m[1]); | ||
if (!open()) { | ||
return error("@media missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@media missing '}'"); | ||
} | ||
return pos({ | ||
type: 'media', | ||
media: media, | ||
rules: style | ||
}); | ||
} | ||
function atcustommedia() { | ||
var pos = position(); | ||
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); | ||
if (!m) { | ||
return; | ||
} | ||
return pos({ | ||
type: 'custom-media', | ||
name: trim(m[1]), | ||
media: trim(m[2]) | ||
}); | ||
} | ||
function atpage() { | ||
var pos = position(); | ||
var m = match(/^@page */); | ||
if (!m) { | ||
return; | ||
} | ||
var sel = selector() || []; | ||
if (!open()) { | ||
return error("@page missing '{'"); | ||
} | ||
var decls = comments(); | ||
var decl; | ||
while ((decl = declaration())) { | ||
decls.push(decl); | ||
decls = decls.concat(comments()); | ||
} | ||
if (!close()) { | ||
return error("@page missing '}'"); | ||
} | ||
return pos({ | ||
type: 'page', | ||
selectors: sel, | ||
declarations: decls | ||
}); | ||
} | ||
function atdocument() { | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?document *([^{]+)/); | ||
if (!m) { | ||
return; | ||
} | ||
var vendor = trim(m[1]); | ||
var doc = trim(m[2]); | ||
if (!open()) { | ||
return error("@document missing '{'"); | ||
} | ||
var style = comments().concat(rules()); | ||
if (!close()) { | ||
return error("@document missing '}'"); | ||
} | ||
return pos({ | ||
type: 'document', | ||
document: doc, | ||
vendor: vendor, | ||
rules: style | ||
}); | ||
} | ||
function atfontface() { | ||
var pos = position(); | ||
var m = match(/^@font-face\s*/); | ||
if (!m) { | ||
return; | ||
} | ||
if (!open()) { | ||
return error("@font-face missing '{'"); | ||
} | ||
var decls = comments(); | ||
var decl; | ||
while ((decl = declaration())) { | ||
decls.push(decl); | ||
decls = decls.concat(comments()); | ||
} | ||
if (!close()) { | ||
return error("@font-face missing '}'"); | ||
} | ||
return pos({ | ||
type: 'font-face', | ||
declarations: decls | ||
}); | ||
} | ||
var atimport = _compileAtrule('import'); | ||
var atcharset = _compileAtrule('charset'); | ||
var atnamespace = _compileAtrule('namespace'); | ||
function _compileAtrule(name) { | ||
var re = new RegExp('^@' + name + '\\s*([^;]+);'); | ||
return function () { | ||
var pos = position(); | ||
var m = match(re); | ||
if (!m) { | ||
return; | ||
} | ||
var ret = { type: name }; | ||
ret[name] = m[1].trim(); | ||
return pos(ret); | ||
}; | ||
} | ||
function atrule() { | ||
if (css[0] !== '@') { | ||
return; | ||
} | ||
return (atkeyframes() || | ||
atmedia() || | ||
atcustommedia() || | ||
atsupports() || | ||
atimport() || | ||
atcharset() || | ||
atnamespace() || | ||
atdocument() || | ||
atpage() || | ||
athost() || | ||
atfontface()); | ||
} | ||
function rule() { | ||
var pos = position(); | ||
var sel = selector(); | ||
if (!sel) { | ||
return error('selector missing'); | ||
} | ||
comments(); | ||
return pos({ | ||
type: 'rule', | ||
selectors: sel, | ||
declarations: declarations() | ||
}); | ||
} | ||
return addParent(stylesheet()); | ||
} | ||
function trim(str) { | ||
return str ? str.replace(/^\s+|\s+$/g, '') : ''; | ||
} | ||
function addParent(obj, parent) { | ||
var isNode = obj && typeof obj.type === 'string'; | ||
var childParent = isNode ? obj : parent; | ||
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { | ||
var k = _a[_i]; | ||
var value = obj[k]; | ||
if (Array.isArray(value)) { | ||
value.forEach(function (v) { | ||
addParent(v, childParent); | ||
}); | ||
} | ||
else if (value && typeof value === 'object') { | ||
addParent(value, childParent); | ||
} | ||
} | ||
if (isNode) { | ||
Object.defineProperty(obj, 'parent', { | ||
configurable: true, | ||
writable: true, | ||
enumerable: false, | ||
value: parent || null | ||
}); | ||
} | ||
return obj; | ||
} | ||
var tagMap = { | ||
script: 'noscript', | ||
altglyph: 'altGlyph', | ||
altglyphdef: 'altGlyphDef', | ||
altglyphitem: 'altGlyphItem', | ||
animatecolor: 'animateColor', | ||
animatemotion: 'animateMotion', | ||
animatetransform: 'animateTransform', | ||
clippath: 'clipPath', | ||
feblend: 'feBlend', | ||
fecolormatrix: 'feColorMatrix', | ||
fecomponenttransfer: 'feComponentTransfer', | ||
fecomposite: 'feComposite', | ||
feconvolvematrix: 'feConvolveMatrix', | ||
fediffuselighting: 'feDiffuseLighting', | ||
fedisplacementmap: 'feDisplacementMap', | ||
fedistantlight: 'feDistantLight', | ||
fedropshadow: 'feDropShadow', | ||
feflood: 'feFlood', | ||
fefunca: 'feFuncA', | ||
fefuncb: 'feFuncB', | ||
fefuncg: 'feFuncG', | ||
fefuncr: 'feFuncR', | ||
fegaussianblur: 'feGaussianBlur', | ||
feimage: 'feImage', | ||
femerge: 'feMerge', | ||
femergenode: 'feMergeNode', | ||
femorphology: 'feMorphology', | ||
feoffset: 'feOffset', | ||
fepointlight: 'fePointLight', | ||
fespecularlighting: 'feSpecularLighting', | ||
fespotlight: 'feSpotLight', | ||
fetile: 'feTile', | ||
feturbulence: 'feTurbulence', | ||
foreignobject: 'foreignObject', | ||
glyphref: 'glyphRef', | ||
lineargradient: 'linearGradient', | ||
radialgradient: 'radialGradient', | ||
}; | ||
function getTagName(n) { | ||
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName; | ||
if (tagName === 'link' && n.attributes._cssText) { | ||
tagName = 'style'; | ||
} | ||
return tagName; | ||
} | ||
function escapeRegExp(str) { | ||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
var HOVER_SELECTOR = /([^\\]):hover/; | ||
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR, 'g'); | ||
function addHoverClass(cssText, cache) { | ||
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText); | ||
if (cachedStyle) | ||
return cachedStyle; | ||
var ast = parse(cssText, { | ||
silent: true, | ||
}); | ||
if (!ast.stylesheet) { | ||
return cssText; | ||
} | ||
var selectors = []; | ||
ast.stylesheet.rules.forEach(function (rule) { | ||
if ('selectors' in rule) { | ||
(rule.selectors || []).forEach(function (selector) { | ||
if (HOVER_SELECTOR.test(selector)) { | ||
selectors.push(selector); | ||
} | ||
}); | ||
} | ||
}); | ||
if (selectors.length === 0) { | ||
return cssText; | ||
} | ||
var selectorMatcher = new RegExp(selectors | ||
.filter(function (selector, index) { return selectors.indexOf(selector) === index; }) | ||
.sort(function (a, b) { return b.length - a.length; }) | ||
.map(function (selector) { | ||
return escapeRegExp(selector); | ||
}) | ||
.join('|'), 'g'); | ||
var result = cssText.replace(selectorMatcher, function (selector) { | ||
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover'); | ||
return selector + ", " + newSelector; | ||
}); | ||
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result); | ||
return result; | ||
} | ||
function createCache() { | ||
var stylesWithHoverClass = new Map(); | ||
return { | ||
stylesWithHoverClass: stylesWithHoverClass, | ||
}; | ||
} | ||
function buildNode(n, options) { | ||
var doc = options.doc, hackCss = options.hackCss, cache = options.cache; | ||
switch (n.type) { | ||
case exports.NodeType.Document: | ||
return doc.implementation.createDocument(null, '', null); | ||
case exports.NodeType.DocumentType: | ||
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId); | ||
case exports.NodeType.Element: | ||
var tagName = getTagName(n); | ||
var node_1; | ||
if (n.isSVG) { | ||
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName); | ||
} | ||
else { | ||
node_1 = doc.createElement(tagName); | ||
} | ||
var _loop_1 = function (name) { | ||
if (!n.attributes.hasOwnProperty(name)) { | ||
return "continue"; | ||
} | ||
var value = n.attributes[name]; | ||
if (tagName === 'option' && name === 'selected' && value === false) { | ||
return "continue"; | ||
} | ||
value = | ||
typeof value === 'boolean' || typeof value === 'number' ? '' : value; | ||
if (!name.startsWith('rr_')) { | ||
var isTextarea = tagName === 'textarea' && name === 'value'; | ||
var isRemoteOrDynamicCss = tagName === 'style' && name === '_cssText'; | ||
if (isRemoteOrDynamicCss && hackCss) { | ||
value = addHoverClass(value, cache); | ||
} | ||
if (isTextarea || isRemoteOrDynamicCss) { | ||
var child = doc.createTextNode(value); | ||
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) { | ||
var c = _a[_i]; | ||
if (c.nodeType === node_1.TEXT_NODE) { | ||
node_1.removeChild(c); | ||
} | ||
} | ||
node_1.appendChild(child); | ||
return "continue"; | ||
} | ||
try { | ||
if (n.isSVG && name === 'xlink:href') { | ||
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name, value); | ||
} | ||
else if (name === 'onload' || | ||
name === 'onclick' || | ||
name.substring(0, 7) === 'onmouse') { | ||
node_1.setAttribute('_' + name, value); | ||
} | ||
else if (tagName === 'meta' && | ||
n.attributes['http-equiv'] === 'Content-Security-Policy' && | ||
name === 'content') { | ||
node_1.setAttribute('csp-content', value); | ||
return "continue"; | ||
} | ||
else if (tagName === 'link' && | ||
n.attributes.rel === 'preload' && | ||
n.attributes.as === 'script') ; | ||
else if (tagName === 'link' && | ||
n.attributes.rel === 'prefetch' && | ||
typeof n.attributes.href === 'string' && | ||
n.attributes.href.endsWith('.js')) ; | ||
else { | ||
node_1.setAttribute(name, value); | ||
} | ||
} | ||
catch (error) { | ||
} | ||
} | ||
else { | ||
if (tagName === 'canvas' && name === 'rr_dataURL') { | ||
var image_1 = document.createElement('img'); | ||
image_1.src = value; | ||
image_1.onload = function () { | ||
var ctx = node_1.getContext('2d'); | ||
if (ctx) { | ||
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height); | ||
} | ||
}; | ||
} | ||
if (name === 'rr_width') { | ||
node_1.style.width = value; | ||
} | ||
if (name === 'rr_height') { | ||
node_1.style.height = value; | ||
} | ||
if (name === 'rr_mediaCurrentTime') { | ||
node_1.currentTime = n.attributes | ||
.rr_mediaCurrentTime; | ||
} | ||
if (name === 'rr_mediaState') { | ||
switch (value) { | ||
case 'played': | ||
node_1 | ||
.play() | ||
.catch(function (e) { return console.warn('media playback error', e); }); | ||
break; | ||
case 'paused': | ||
node_1.pause(); | ||
break; | ||
default: | ||
} | ||
} | ||
} | ||
}; | ||
for (var name in n.attributes) { | ||
_loop_1(name); | ||
} | ||
if (n.isShadowHost) { | ||
if (!node_1.shadowRoot) { | ||
node_1.attachShadow({ mode: 'open' }); | ||
} | ||
else { | ||
while (node_1.shadowRoot.firstChild) { | ||
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild); | ||
} | ||
} | ||
} | ||
return node_1; | ||
case exports.NodeType.Text: | ||
return doc.createTextNode(n.isStyle && hackCss | ||
? addHoverClass(n.textContent, cache) | ||
: n.textContent); | ||
case exports.NodeType.CDATA: | ||
return doc.createCDATASection(n.textContent); | ||
case exports.NodeType.Comment: | ||
return doc.createComment(n.textContent); | ||
default: | ||
return null; | ||
} | ||
} | ||
function buildNodeWithSN(n, options) { | ||
var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache; | ||
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache }); | ||
if (!node) { | ||
return null; | ||
} | ||
if (n.rootId) { | ||
console.assert(map[n.rootId] === doc, 'Target document should has the same root id.'); | ||
} | ||
if (n.type === exports.NodeType.Document) { | ||
doc.close(); | ||
doc.open(); | ||
node = doc; | ||
} | ||
node.__sn = n; | ||
map[n.id] = node; | ||
if ((n.type === exports.NodeType.Document || n.type === exports.NodeType.Element) && | ||
!skipChild) { | ||
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) { | ||
var childN = _c[_i]; | ||
var childNode = buildNodeWithSN(childN, { | ||
doc: doc, | ||
map: map, | ||
skipChild: false, | ||
hackCss: hackCss, | ||
afterAppend: afterAppend, | ||
cache: cache, | ||
}); | ||
if (!childNode) { | ||
console.warn('Failed to rebuild', childN); | ||
continue; | ||
} | ||
if (childN.isShadow && isElement(node) && node.shadowRoot) { | ||
node.shadowRoot.appendChild(childNode); | ||
} | ||
else { | ||
node.appendChild(childNode); | ||
} | ||
if (afterAppend) { | ||
afterAppend(childNode); | ||
} | ||
} | ||
} | ||
return node; | ||
} | ||
function visit(idNodeMap, onVisit) { | ||
function walk(node) { | ||
onVisit(node); | ||
} | ||
for (var key in idNodeMap) { | ||
if (idNodeMap[key]) { | ||
walk(idNodeMap[key]); | ||
} | ||
} | ||
} | ||
function handleScroll(node) { | ||
var n = node.__sn; | ||
if (n.type !== exports.NodeType.Element) { | ||
return; | ||
} | ||
var el = node; | ||
for (var name in n.attributes) { | ||
if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) { | ||
continue; | ||
} | ||
var value = n.attributes[name]; | ||
if (name === 'rr_scrollLeft') { | ||
el.scrollLeft = value; | ||
} | ||
if (name === 'rr_scrollTop') { | ||
el.scrollTop = value; | ||
} | ||
} | ||
} | ||
function rebuild(n, options) { | ||
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache; | ||
var idNodeMap = {}; | ||
var node = buildNodeWithSN(n, { | ||
doc: doc, | ||
map: idNodeMap, | ||
skipChild: false, | ||
hackCss: hackCss, | ||
afterAppend: afterAppend, | ||
cache: cache, | ||
}); | ||
visit(idNodeMap, function (visitedNode) { | ||
if (onVisit) { | ||
onVisit(visitedNode); | ||
} | ||
handleScroll(visitedNode); | ||
}); | ||
return [node, idNodeMap]; | ||
} | ||
var tagMap = { | ||
script: 'noscript', | ||
altglyph: 'altGlyph', | ||
altglyphdef: 'altGlyphDef', | ||
altglyphitem: 'altGlyphItem', | ||
animatecolor: 'animateColor', | ||
animatemotion: 'animateMotion', | ||
animatetransform: 'animateTransform', | ||
clippath: 'clipPath', | ||
feblend: 'feBlend', | ||
fecolormatrix: 'feColorMatrix', | ||
fecomponenttransfer: 'feComponentTransfer', | ||
fecomposite: 'feComposite', | ||
feconvolvematrix: 'feConvolveMatrix', | ||
fediffuselighting: 'feDiffuseLighting', | ||
fedisplacementmap: 'feDisplacementMap', | ||
fedistantlight: 'feDistantLight', | ||
fedropshadow: 'feDropShadow', | ||
feflood: 'feFlood', | ||
fefunca: 'feFuncA', | ||
fefuncb: 'feFuncB', | ||
fefuncg: 'feFuncG', | ||
fefuncr: 'feFuncR', | ||
fegaussianblur: 'feGaussianBlur', | ||
feimage: 'feImage', | ||
femerge: 'feMerge', | ||
femergenode: 'feMergeNode', | ||
femorphology: 'feMorphology', | ||
feoffset: 'feOffset', | ||
fepointlight: 'fePointLight', | ||
fespecularlighting: 'feSpecularLighting', | ||
fespotlight: 'feSpotLight', | ||
fetile: 'feTile', | ||
feturbulence: 'feTurbulence', | ||
foreignobject: 'foreignObject', | ||
glyphref: 'glyphRef', | ||
lineargradient: 'linearGradient', | ||
radialgradient: 'radialGradient' | ||
}; | ||
function getTagName(n) { | ||
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName; | ||
if (tagName === 'link' && n.attributes._cssText) { | ||
tagName = 'style'; | ||
} | ||
return tagName; | ||
} | ||
function escapeRegExp(str) { | ||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
var HOVER_SELECTOR = /([^\\]):hover/; | ||
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR, 'g'); | ||
function addHoverClass(cssText, cache) { | ||
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText); | ||
if (cachedStyle) | ||
return cachedStyle; | ||
var ast = parse(cssText, { | ||
silent: true | ||
}); | ||
if (!ast.stylesheet) { | ||
return cssText; | ||
} | ||
var selectors = []; | ||
ast.stylesheet.rules.forEach(function (rule) { | ||
if ('selectors' in rule) { | ||
(rule.selectors || []).forEach(function (selector) { | ||
if (HOVER_SELECTOR.test(selector)) { | ||
selectors.push(selector); | ||
} | ||
}); | ||
} | ||
}); | ||
if (selectors.length === 0) { | ||
return cssText; | ||
} | ||
var selectorMatcher = new RegExp(selectors | ||
.filter(function (selector, index) { return selectors.indexOf(selector) === index; }) | ||
.sort(function (a, b) { return b.length - a.length; }) | ||
.map(function (selector) { | ||
return escapeRegExp(selector); | ||
}) | ||
.join('|'), 'g'); | ||
var result = cssText.replace(selectorMatcher, function (selector) { | ||
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover'); | ||
return selector + ", " + newSelector; | ||
}); | ||
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result); | ||
return result; | ||
} | ||
function createCache() { | ||
var stylesWithHoverClass = new Map(); | ||
return { | ||
stylesWithHoverClass: stylesWithHoverClass | ||
}; | ||
} | ||
function buildNode(n, options) { | ||
var doc = options.doc, hackCss = options.hackCss, cache = options.cache; | ||
switch (n.type) { | ||
case exports.NodeType.Document: | ||
return doc.implementation.createDocument(null, '', null); | ||
case exports.NodeType.DocumentType: | ||
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId); | ||
case exports.NodeType.Element: | ||
var tagName = getTagName(n); | ||
var node_1; | ||
if (n.isSVG) { | ||
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName); | ||
} | ||
else { | ||
node_1 = doc.createElement(tagName); | ||
} | ||
var _loop_1 = function (name_1) { | ||
if (!n.attributes.hasOwnProperty(name_1)) { | ||
return "continue"; | ||
} | ||
var value = n.attributes[name_1]; | ||
if (tagName === 'option' && name_1 === 'selected' && value === false) { | ||
return "continue"; | ||
} | ||
value = | ||
typeof value === 'boolean' || typeof value === 'number' ? '' : value; | ||
if (!name_1.startsWith('rr_')) { | ||
var isTextarea = tagName === 'textarea' && name_1 === 'value'; | ||
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText'; | ||
if (isRemoteOrDynamicCss && hackCss) { | ||
value = addHoverClass(value, cache); | ||
} | ||
if (isTextarea || isRemoteOrDynamicCss) { | ||
var child = doc.createTextNode(value); | ||
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) { | ||
var c = _a[_i]; | ||
if (c.nodeType === node_1.TEXT_NODE) { | ||
node_1.removeChild(c); | ||
} | ||
} | ||
node_1.appendChild(child); | ||
return "continue"; | ||
} | ||
try { | ||
if (n.isSVG && name_1 === 'xlink:href') { | ||
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value); | ||
} | ||
else if (name_1 === 'onload' || | ||
name_1 === 'onclick' || | ||
name_1.substring(0, 7) === 'onmouse') { | ||
node_1.setAttribute('_' + name_1, value); | ||
} | ||
else if (tagName === 'meta' && | ||
n.attributes['http-equiv'] === 'Content-Security-Policy' && | ||
name_1 === 'content') { | ||
node_1.setAttribute('csp-content', value); | ||
return "continue"; | ||
} | ||
else if (tagName === 'link' && | ||
n.attributes.rel === 'preload' && | ||
n.attributes.as === 'script') { | ||
} | ||
else if (tagName === 'link' && | ||
n.attributes.rel === 'prefetch' && | ||
typeof n.attributes.href === 'string' && | ||
n.attributes.href.endsWith('.js')) { | ||
} | ||
else { | ||
node_1.setAttribute(name_1, value); | ||
} | ||
} | ||
catch (error) { | ||
} | ||
} | ||
else { | ||
if (tagName === 'canvas' && name_1 === 'rr_dataURL') { | ||
var image_1 = document.createElement('img'); | ||
image_1.src = value; | ||
image_1.onload = function () { | ||
var ctx = node_1.getContext('2d'); | ||
if (ctx) { | ||
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height); | ||
} | ||
}; | ||
} | ||
if (name_1 === 'rr_width') { | ||
node_1.style.width = value; | ||
} | ||
if (name_1 === 'rr_height') { | ||
node_1.style.height = value; | ||
} | ||
if (name_1 === 'rr_mediaCurrentTime') { | ||
node_1.currentTime = n.attributes | ||
.rr_mediaCurrentTime; | ||
} | ||
if (name_1 === 'rr_mediaState') { | ||
switch (value) { | ||
case 'played': | ||
node_1 | ||
.play()["catch"](function (e) { return console.warn('media playback error', e); }); | ||
break; | ||
case 'paused': | ||
node_1.pause(); | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
for (var name_1 in n.attributes) { | ||
_loop_1(name_1); | ||
} | ||
if (n.isShadowHost) { | ||
if (!node_1.shadowRoot) { | ||
node_1.attachShadow({ mode: 'open' }); | ||
} | ||
else { | ||
while (node_1.shadowRoot.firstChild) { | ||
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild); | ||
} | ||
} | ||
} | ||
return node_1; | ||
case exports.NodeType.Text: | ||
return doc.createTextNode(n.isStyle && hackCss | ||
? addHoverClass(n.textContent, cache) | ||
: n.textContent); | ||
case exports.NodeType.CDATA: | ||
return doc.createCDATASection(n.textContent); | ||
case exports.NodeType.Comment: | ||
return doc.createComment(n.textContent); | ||
default: | ||
return null; | ||
} | ||
} | ||
function buildNodeWithSN(n, options) { | ||
var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache; | ||
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache }); | ||
if (!node) { | ||
return null; | ||
} | ||
if (n.rootId) { | ||
console.assert(map[n.rootId] === doc, 'Target document should has the same root id.'); | ||
} | ||
if (n.type === exports.NodeType.Document) { | ||
doc.close(); | ||
doc.open(); | ||
if (n.compatMode === 'BackCompat' && | ||
(n.childNodes && n.childNodes[0].type !== exports.NodeType.DocumentType)) { | ||
if (n.childNodes[0].type === exports.NodeType.Element && | ||
'xmlns' in n.childNodes[0].attributes && | ||
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') { | ||
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'); | ||
} | ||
else { | ||
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'); | ||
} | ||
} | ||
node = doc; | ||
} | ||
node.__sn = n; | ||
map[n.id] = node; | ||
if ((n.type === exports.NodeType.Document || n.type === exports.NodeType.Element) && | ||
!skipChild) { | ||
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) { | ||
var childN = _c[_i]; | ||
var childNode = buildNodeWithSN(childN, { | ||
doc: doc, | ||
map: map, | ||
skipChild: false, | ||
hackCss: hackCss, | ||
afterAppend: afterAppend, | ||
cache: cache | ||
}); | ||
if (!childNode) { | ||
console.warn('Failed to rebuild', childN); | ||
continue; | ||
} | ||
if (childN.isShadow && isElement(node) && node.shadowRoot) { | ||
node.shadowRoot.appendChild(childNode); | ||
} | ||
else { | ||
node.appendChild(childNode); | ||
} | ||
if (afterAppend) { | ||
afterAppend(childNode); | ||
} | ||
} | ||
} | ||
return node; | ||
} | ||
function visit(idNodeMap, onVisit) { | ||
function walk(node) { | ||
onVisit(node); | ||
} | ||
for (var key in idNodeMap) { | ||
if (idNodeMap[key]) { | ||
walk(idNodeMap[key]); | ||
} | ||
} | ||
} | ||
function handleScroll(node) { | ||
var n = node.__sn; | ||
if (n.type !== exports.NodeType.Element) { | ||
return; | ||
} | ||
var el = node; | ||
for (var name_2 in n.attributes) { | ||
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) { | ||
continue; | ||
} | ||
var value = n.attributes[name_2]; | ||
if (name_2 === 'rr_scrollLeft') { | ||
el.scrollLeft = value; | ||
} | ||
if (name_2 === 'rr_scrollTop') { | ||
el.scrollTop = value; | ||
} | ||
} | ||
} | ||
function rebuild(n, options) { | ||
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache; | ||
var idNodeMap = {}; | ||
var node = buildNodeWithSN(n, { | ||
doc: doc, | ||
map: idNodeMap, | ||
skipChild: false, | ||
hackCss: hackCss, | ||
afterAppend: afterAppend, | ||
cache: cache | ||
}); | ||
visit(idNodeMap, function (visitedNode) { | ||
if (onVisit) { | ||
onVisit(visitedNode); | ||
} | ||
handleScroll(visitedNode); | ||
}); | ||
return [node, idNodeMap]; | ||
} | ||
exports.snapshot = snapshot; | ||
exports.serializeNodeWithId = serializeNodeWithId; | ||
exports.rebuild = rebuild; | ||
exports.buildNodeWithSN = buildNodeWithSN; | ||
exports.addHoverClass = addHoverClass; | ||
exports.createCache = createCache; | ||
exports.transformAttribute = transformAttribute; | ||
exports.visitSnapshot = visitSnapshot; | ||
exports.cleanupSnapshot = cleanupSnapshot; | ||
exports.needMaskingText = needMaskingText; | ||
exports.IGNORED_NODE = IGNORED_NODE; | ||
exports.isElement = isElement; | ||
exports.isShadowRoot = isShadowRoot; | ||
exports.maskInputValue = maskInputValue; | ||
exports.IGNORED_NODE = IGNORED_NODE; | ||
exports.addHoverClass = addHoverClass; | ||
exports.buildNodeWithSN = buildNodeWithSN; | ||
exports.cleanupSnapshot = cleanupSnapshot; | ||
exports.createCache = createCache; | ||
exports.isElement = isElement; | ||
exports.isShadowRoot = isShadowRoot; | ||
exports.maskInputValue = maskInputValue; | ||
exports.needMaskingText = needMaskingText; | ||
exports.rebuild = rebuild; | ||
exports.serializeNodeWithId = serializeNodeWithId; | ||
exports.snapshot = snapshot; | ||
exports.transformAttribute = transformAttribute; | ||
exports.visitSnapshot = visitSnapshot; | ||
return exports; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return exports; | ||
}({})); |
@@ -1,2 +0,2 @@ | ||
var rrwebSnapshot=function(e){"use strict";var t;function r(e){return e.nodeType===e.ELEMENT_NODE}function n(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function a(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var i=1,o=RegExp("[^a-z0-9-_:]"),s=-2;function c(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(u).join(""):null}catch(e){return null}}function u(e){return function(e){return"styleSheet"in e}(e)?c(e.styleSheet)||"":e.cssText}var l=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,f=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,p=/^(data:)([^,]*),(.*)/i;function d(e,t){return(e||"").replace(l,function(e,r,n,a,i,o){var s,c=n||i||o,u=r||a||"";if(!c)return e;if(!f.test(c))return"url("+u+c+u+")";if(p.test(c))return"url("+u+c+u+")";if("/"===c[0])return"url("+u+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+u+")";var l=t.split("/"),d=c.split("/");l.pop();for(var m=0,h=d;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?l.pop():l.push(v))}return"url("+u+l.join("/")+u+")"})}var m=/^[^ \t\n\r\u000c]+/,h=/^[, \t\n\r\u000c]+/;function v(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function y(){var e=document.createElement("a");return e.href="",e.href}function g(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?v(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(h),!(r>=t.length);){var i=n(m);if(","===i.slice(-1))i=v(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=v(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?d(n,y()):n:v(e,n)}function T(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach(function(e){if(t.test(e))return!0});return!(!r||!e.matches(r))||T(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,T(e.parentNode,t,r)}function b(t,r){var n,i,s=r.doc,u=r.blockClass,l=r.blockSelector,f=r.maskTextClass,p=r.maskTextSelector,m=r.inlineStylesheet,h=r.maskInputOptions,v=void 0===h?{}:h,b=r.maskTextFn,k=r.maskInputFn,C=r.recordCanvas,N=r.keepIframeSrcFn;if(s.__sn){var S=s.__sn.id;n=1===S?void 0:S}switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[],rootId:n};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:n};case t.ELEMENT_NODE:for(var x=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var a=e.classList[n];if(t.test(a))return!0}return!!r&&e.matches(r)}(t,u,l),w=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return o.test(t)?"div":t}(t),E={},I=0,_=Array.from(t.attributes);I<_.length;I++){var D=_[I],O=D.name,A=D.value;E[O]=g(s,w,O,A)}if("link"===w&&m){var L,M=Array.from(s.styleSheets).find(function(e){return e.href===t.href});(L=c(M))&&(delete E.rel,delete E.href,E._cssText=d(L,M.href))}if("style"===w&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(L=c(t.sheet))&&(E._cssText=d(L,y()));if("input"===w||"textarea"===w||"select"===w){A=t.value;"radio"!==E.type&&"checkbox"!==E.type&&"submit"!==E.type&&"button"!==E.type&&A?E.value=a({type:E.type,tagName:w,value:A,maskInputOptions:v,maskInputFn:k}):t.checked&&(E.checked=t.checked)}if("option"===w&&(t.selected?E.selected=!0:delete E.selected),"canvas"===w&&C&&(E.rr_dataURL=t.toDataURL()),"audio"!==w&&"video"!==w||(E.rr_mediaState=t.paused?"paused":"played",E.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(E.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(E.rr_scrollTop=t.scrollTop),x){var F=t.getBoundingClientRect(),R=F.width,W=F.height;E={class:E.class,rr_width:R+"px",rr_height:W+"px"}}return"iframe"!==w||N(E.src)||delete E.src,{type:e.NodeType.Element,tagName:w,attributes:E,childNodes:[],isSVG:(i=t,"svg"===i.tagName||i instanceof SVGElement||void 0),needBlock:x,rootId:n};case t.TEXT_NODE:var j=t.parentNode&&t.parentNode.tagName,G=t.textContent,z="STYLE"===j||void 0,H="SCRIPT"===j||void 0;return z&&G&&(G=d(G,y())),H&&(G="SCRIPT_PLACEHOLDER"),!z&&!H&&T(t,f,p)&&G&&(G=b?b(G):G.replace(/[\S]/g,"*")),{type:e.NodeType.Text,textContent:G||"",isStyle:z,rootId:n};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:n};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:n};default:return!1}}function k(e){return void 0===e?"":e.toLowerCase()}function C(t,a){var o,c=a.doc,u=a.map,l=a.blockClass,f=a.blockSelector,p=a.maskTextClass,d=a.maskTextSelector,m=a.skipChild,h=void 0!==m&&m,v=a.inlineStylesheet,y=void 0===v||v,g=a.maskInputOptions,T=void 0===g?{}:g,N=a.maskTextFn,S=a.maskInputFn,x=a.slimDOMOptions,w=a.recordCanvas,E=void 0!==w&&w,I=a.onSerialize,_=a.onIframeLoad,D=a.iframeLoadTimeout,O=void 0===D?5e3:D,A=a.keepIframeSrcFn,L=void 0===A?function(){return!1}:A,M=a.preserveWhiteSpace,F=void 0===M||M,R=b(t,{doc:c,blockClass:l,blockSelector:f,maskTextClass:p,maskTextSelector:d,inlineStylesheet:y,maskInputOptions:T,maskTextFn:N,maskInputFn:S,recordCanvas:E,keepIframeSrcFn:L});if(!R)return console.warn(t,"not serialized"),null;o="__sn"in t?t.__sn.id:!function(t,r){if(r.comment&&t.type===e.NodeType.Comment)return!0;if(t.type===e.NodeType.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(k(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===k(t.attributes.name)||"icon"===k(t.attributes.rel)||"apple-touch-icon"===k(t.attributes.rel)||"shortcut icon"===k(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&k(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(k(t.attributes.property).match(/^(og|twitter|fb):/)||k(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===k(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===k(t.attributes.name)||"googlebot"===k(t.attributes.name)||"bingbot"===k(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===k(t.attributes.name)||"generator"===k(t.attributes.name)||"framework"===k(t.attributes.name)||"publisher"===k(t.attributes.name)||"progid"===k(t.attributes.name)||k(t.attributes.property).match(/^article:/)||k(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===k(t.attributes.name)||"yandex-verification"===k(t.attributes.name)||"csrf-token"===k(t.attributes.name)||"p:domain_verify"===k(t.attributes.name)||"verify-v1"===k(t.attributes.name)||"verification"===k(t.attributes.name)||"shopify-checkout-api-token"===k(t.attributes.name)))return!0}}return!1}(R,x)&&(F||R.type!==e.NodeType.Text||R.isStyle||R.textContent.replace(/^\s+|\s+$/gm,"").length)?i++:s;var W=Object.assign(R,{id:o});if(t.__sn=W,o===s)return null;u[o]=t,I&&I(t);var j=!h;if(W.type===e.NodeType.Element&&(j=j&&!W.needBlock,delete W.needBlock),(W.type===e.NodeType.Document||W.type===e.NodeType.Element)&&j){x.headWhitespace&&R.type===e.NodeType.Element&&"head"===R.tagName&&(F=!1);for(var G={doc:c,map:u,blockClass:l,blockSelector:f,maskTextClass:p,maskTextSelector:d,skipChild:h,inlineStylesheet:y,maskInputOptions:T,maskTextFn:N,maskInputFn:S,slimDOMOptions:x,recordCanvas:E,preserveWhiteSpace:F,onSerialize:I,onIframeLoad:_,iframeLoadTimeout:O,keepIframeSrcFn:L},z=0,H=Array.from(t.childNodes);z<H.length;z++){(V=C(H[z],G))&&W.childNodes.push(V)}if(r(t)&&t.shadowRoot){W.isShadowHost=!0;for(var P=0,B=Array.from(t.shadowRoot.childNodes);P<B.length;P++){var V;(V=C(B[P],G))&&(V.isShadow=!0,W.childNodes.push(V))}}}return t.parentNode&&n(t.parentNode)&&(W.isShadow=!0),W.type===e.NodeType.Element&&"iframe"===W.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a)"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0);else{var o=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()})}}}(t,function(){var e=t.contentDocument;if(e&&_){var r=C(e,{doc:e,map:u,blockClass:l,blockSelector:f,maskTextClass:p,maskTextSelector:d,skipChild:!1,inlineStylesheet:y,maskInputOptions:T,maskTextFn:N,maskInputFn:S,slimDOMOptions:x,recordCanvas:E,preserveWhiteSpace:F,onSerialize:I,onIframeLoad:_,iframeLoadTimeout:O,keepIframeSrcFn:L});r&&_(t,r)}},O),W}var N=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function S(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function i(){var e={line:r,column:n};return function(t){return t.position=new o(e),d(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return p(/^{\s*/)}function l(){return p(/^}/)}function f(){var t,r=[];for(d(),m(r);e.length&&"}"!==e.charAt(0)&&(t=E()||I());)!1!==t&&(r.push(t),m(r));return r}function p(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function d(){p(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=p(/^([^{]+)/);if(e)return x(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function y(){var e=i(),t=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=x(t[0]);if(!p(/^:\s*/))return c("property missing ':'");var n=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(N,""),value:n?x(n[0]).replace(N,""):""});return p(/^[;\s]*/),a}}function g(){var e,t=[];if(!u())return c("missing '{'");for(m(t);e=y();)!1!==e&&(t.push(e),m(t)),e=y();return l()?t:c("missing '}'")}function T(){for(var e,t=[],r=i();e=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),p(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:g()})}var b,k=w("import"),C=w("charset"),S=w("namespace");function w(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=p(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function E(){if("@"===e[0])return function(){var e=i(),t=p(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=p(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=m();n=T();)o.push(n),o=o.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=p(/^@media *([^{]+)/);if(t){var r=x(t[1]);if(!u())return c("@media missing '{'");var n=m().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=i(),t=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:x(t[1]),media:x(t[2])})}()||function(){var e=i(),t=p(/^@supports *([^{]+)/);if(t){var r=x(t[1]);if(!u())return c("@supports missing '{'");var n=m().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||k()||C()||S()||function(){var e=i(),t=p(/^@([-\w]+)?document *([^{]+)/);if(t){var r=x(t[1]),n=x(t[2]);if(!u())return c("@document missing '{'");var a=m().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=i();if(p(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=m();r=y();)n.push(r),n=n.concat(m());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=i();if(p(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=m().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(p(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=m();t=y();)r.push(t),r=r.concat(m());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function I(){var e=i(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:g()})):c("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var a=n?t:r;for(var i=0,o=Object.keys(t);i<o.length;i++){var s=o[i],c=t[s];Array.isArray(c)?c.forEach(function(t){e(t,a)}):c&&"object"==typeof c&&e(c,a)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}((b=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:b,parsingErrors:s}}))}function x(e){return e?e.replace(/^\s+|\s+$/g,""):""}var w={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var E=/([^\\]):hover/,I=new RegExp(E,"g");function _(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=S(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach(function(e){"selectors"in e&&(e.selectors||[]).forEach(function(e){E.test(e)&&a.push(e)})}),0===a.length)return e;var i=new RegExp(a.filter(function(e,t){return a.indexOf(e)===t}).sort(function(e,t){return t.length-e.length}).map(function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("|"),"g"),o=e.replace(i,function(e){var t=e.replace(I,"$1.\\:hover");return e+", "+t});return null==t||t.stylesWithHoverClass.set(e,o),o}function D(t,r){var n=r.doc,a=r.hackCss,i=r.cache;switch(t.type){case e.NodeType.Document:return n.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.NodeType.Element:var o,s=function(e){var t=w[e.tagName]?w[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);o=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}if("rr_width"===e&&(o.style.width=r),"rr_height"===e&&(o.style.height=r),"rr_mediaCurrentTime"===e&&(o.currentTime=t.attributes.rr_mediaCurrentTime),"rr_mediaState"===e)switch(r){case"played":o.play().catch(function(e){return console.warn("media playback error",e)});break;case"paused":o.pause()}}else{var u="textarea"===s&&"value"===e,l="style"===s&&"_cssText"===e;if(l&&a&&(r=_(r,i)),u||l){for(var f=n.createTextNode(r),p=0,d=Array.from(o.childNodes);p<d.length;p++){var m=d[p];m.nodeType===o.TEXT_NODE&&o.removeChild(m)}return o.appendChild(f),"continue"}try{if(t.isSVG&&"xlink:href"===e)o.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))o.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return o.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||o.setAttribute(e,r)}}catch(e){}}};for(var u in t.attributes)c(u);if(t.isShadowHost)if(o.shadowRoot)for(;o.shadowRoot.firstChild;)o.shadowRoot.removeChild(o.shadowRoot.firstChild);else o.attachShadow({mode:"open"});return o;case e.NodeType.Text:return n.createTextNode(t.isStyle&&a?_(t.textContent,i):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function O(t,n){var a=n.doc,i=n.map,o=n.skipChild,s=void 0!==o&&o,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,p=D(t,{doc:a,hackCss:u,cache:f});if(!p)return null;if(t.rootId&&console.assert(i[t.rootId]===a,"Target document should has the same root id."),t.type===e.NodeType.Document&&(a.close(),a.open(),p=a),p.__sn=t,i[t.id]=p,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var d=0,m=t.childNodes;d<m.length;d++){var h=m[d],v=O(h,{doc:a,map:i,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&r(p)&&p.shadowRoot?p.shadowRoot.appendChild(v):p.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return p}return e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,p=void 0===f||f,d=r.recordCanvas,m=void 0!==d&&d,h=r.maskAllInputs,v=void 0!==h&&h,y=r.maskTextFn,g=r.maskInputFn,T=r.slimDOM,b=void 0!==T&&T,k=r.preserveWhiteSpace,N=r.onSerialize,S=r.onIframeLoad,x=r.iframeLoadTimeout,w=r.keepIframeSrcFn,E={};return[C(e,{doc:e,map:E,blockClass:a,blockSelector:o,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:p,maskInputOptions:!0===v?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===v?{password:!0}:v,maskTextFn:y,maskInputFn:g,slimDOMOptions:!0===b||"all"===b?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===b,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===b?{}:b,recordCanvas:m,preserveWhiteSpace:k,onSerialize:N,onIframeLoad:S,iframeLoadTimeout:x,keepIframeSrcFn:void 0===w?function(){return!1}:w}),E]},e.serializeNodeWithId=C,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=O(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.NodeType.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)}),[s,o]},e.buildNodeWithSN=O,e.addHoverClass=_,e.createCache=function(){return{stylesWithHoverClass:new Map}},e.transformAttribute=g,e.visitSnapshot=function(t,r){!function t(n){r(n),n.type!==e.NodeType.Document&&n.type!==e.NodeType.Element||n.childNodes.forEach(t)}(t)},e.cleanupSnapshot=function(){i=1},e.needMaskingText=T,e.IGNORED_NODE=s,e.isElement=r,e.isShadowRoot=n,e.maskInputValue=a,e}({}); | ||
var rrwebSnapshot=function(e){"use strict";var t;function r(e){return e.nodeType===e.ELEMENT_NODE}function n(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function a(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,o=e.maskInputFn,i=a||"";return(t[r.toLowerCase()]||t[n])&&(i=o?o(i):"*".repeat(i.length)),i}e.NodeType=void 0,(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var o=1,i=RegExp("[^a-z0-9-_:]");function s(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(c).join(""):null}catch(e){return null}}function c(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=s(e.styleSheet)||t}catch(e){}return t}var u=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,l=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,f=/^(data:)([^,]*),(.*)/i;function p(e,t){return(e||"").replace(u,(function(e,r,n,a,o,i){var s,c=n||o||i,u=r||a||"";if(!c)return e;if(!l.test(c))return"url("+u+c+u+")";if(f.test(c))return"url("+u+c+u+")";if("/"===c[0])return"url("+u+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+u+")";var p=t.split("/"),d=c.split("/");p.pop();for(var m=0,h=d;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?p.pop():p.push(v))}return"url("+u+p.join("/")+u+")"}))}var d=/^[^ \t\n\r\u000c]+/,m=/^[, \t\n\r\u000c]+/;function h(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function v(){var e=document.createElement("a");return e.href="",e.href}function y(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?h(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(m),!(r>=t.length);){var o=n(d);if(","===o.slice(-1))o=h(e,o.substring(0,o.length-1)),a.push(o);else{var i="";o=h(e,o);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((o+i).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((o+i).trim());break}"("===c&&(s=!0)}i+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?p(n,v()):n:h(e,n)}function g(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach((function(e){if(t.test(e))return!0}));return!(!r||!e.matches(r))||g(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,g(e.parentNode,t,r)}function T(t,r){var n,o,c=r.doc,u=r.blockClass,l=r.blockSelector,f=r.maskTextClass,d=r.maskTextSelector,m=r.inlineStylesheet,h=r.maskInputOptions,T=void 0===h?{}:h,b=r.maskTextFn,k=r.maskInputFn,C=r.recordCanvas,N=r.keepIframeSrcFn;if(c.__sn){var S=c.__sn.id;n=1===S?void 0:S}switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.NodeType.Document,childNodes:[],compatMode:t.compatMode,rootId:n}:{type:e.NodeType.Document,childNodes:[],rootId:n};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:n};case t.ELEMENT_NODE:for(var w=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var a=e.classList[n];if(t.test(a))return!0}return!!r&&e.matches(r)}(t,u,l),x=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return i.test(t)?"div":t}(t),E={},D=0,I=Array.from(t.attributes);D<I.length;D++){var _=I[D],O=_.name,L=_.value;E[O]=y(c,x,O,L)}if("link"===x&&m){var A,M=Array.from(c.styleSheets).find((function(e){return e.href===t.href}));(A=s(M))&&(delete E.rel,delete E.href,E._cssText=p(A,M.href))}if("style"===x&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(A=s(t.sheet))&&(E._cssText=p(A,v()));if("input"===x||"textarea"===x||"select"===x){L=t.value;"radio"!==E.type&&"checkbox"!==E.type&&"submit"!==E.type&&"button"!==E.type&&L?E.value=a({type:E.type,tagName:x,value:L,maskInputOptions:T,maskInputFn:k}):t.checked&&(E.checked=t.checked)}if("option"===x&&(t.selected?E.selected=!0:delete E.selected),"canvas"===x&&C&&(E.rr_dataURL=t.toDataURL()),"audio"!==x&&"video"!==x||(E.rr_mediaState=t.paused?"paused":"played",E.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(E.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(E.rr_scrollTop=t.scrollTop),w){var F=t.getBoundingClientRect(),R=F.width,W=F.height;E={class:E.class,rr_width:R+"px",rr_height:W+"px"}}return"iframe"!==x||N(E.src)||delete E.src,{type:e.NodeType.Element,tagName:x,attributes:E,childNodes:[],isSVG:(o=t,"svg"===o.tagName||o instanceof SVGElement||void 0),needBlock:w,rootId:n};case t.TEXT_NODE:var P=t.parentNode&&t.parentNode.tagName,j=t.textContent,G="STYLE"===P||void 0,H="SCRIPT"===P||void 0;return G&&j&&(j=p(j,v())),H&&(j="SCRIPT_PLACEHOLDER"),!G&&!H&&g(t,f,d)&&j&&(j=b?b(j):j.replace(/[\S]/g,"*")),{type:e.NodeType.Text,textContent:j||"",isStyle:G,rootId:n};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:n};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:n};default:return!1}}function b(e){return void 0===e?"":e.toLowerCase()}function k(t,a){var i,s=a.doc,c=a.map,u=a.blockClass,l=a.blockSelector,f=a.maskTextClass,p=a.maskTextSelector,d=a.skipChild,m=void 0!==d&&d,h=a.inlineStylesheet,v=void 0===h||h,y=a.maskInputOptions,g=void 0===y?{}:y,C=a.maskTextFn,N=a.maskInputFn,S=a.slimDOMOptions,w=a.recordCanvas,x=void 0!==w&&w,E=a.onSerialize,D=a.onIframeLoad,I=a.iframeLoadTimeout,_=void 0===I?5e3:I,O=a.keepIframeSrcFn,L=void 0===O?function(){return!1}:O,A=a.preserveWhiteSpace,M=void 0===A||A,F=T(t,{doc:s,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:p,inlineStylesheet:v,maskInputOptions:g,maskTextFn:C,maskInputFn:N,recordCanvas:x,keepIframeSrcFn:L});if(!F)return console.warn(t,"not serialized"),null;i="__sn"in t?t.__sn.id:!function(t,r){if(r.comment&&t.type===e.NodeType.Comment)return!0;if(t.type===e.NodeType.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(b(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===b(t.attributes.name)||"icon"===b(t.attributes.rel)||"apple-touch-icon"===b(t.attributes.rel)||"shortcut icon"===b(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&b(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(b(t.attributes.property).match(/^(og|twitter|fb):/)||b(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===b(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===b(t.attributes.name)||"googlebot"===b(t.attributes.name)||"bingbot"===b(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===b(t.attributes.name)||"generator"===b(t.attributes.name)||"framework"===b(t.attributes.name)||"publisher"===b(t.attributes.name)||"progid"===b(t.attributes.name)||b(t.attributes.property).match(/^article:/)||b(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===b(t.attributes.name)||"yandex-verification"===b(t.attributes.name)||"csrf-token"===b(t.attributes.name)||"p:domain_verify"===b(t.attributes.name)||"verify-v1"===b(t.attributes.name)||"verification"===b(t.attributes.name)||"shopify-checkout-api-token"===b(t.attributes.name)))return!0}}return!1}(F,S)&&(M||F.type!==e.NodeType.Text||F.isStyle||F.textContent.replace(/^\s+|\s+$/gm,"").length)?o++:-2;var R=Object.assign(F,{id:i});if(t.__sn=R,-2===i)return null;c[i]=t,E&&E(t);var W=!m;if(R.type===e.NodeType.Element&&(W=W&&!R.needBlock,delete R.needBlock),(R.type===e.NodeType.Document||R.type===e.NodeType.Element)&&W){S.headWhitespace&&F.type===e.NodeType.Element&&"head"===F.tagName&&(M=!1);for(var P={doc:s,map:c,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:p,skipChild:m,inlineStylesheet:v,maskInputOptions:g,maskTextFn:C,maskInputFn:N,slimDOMOptions:S,recordCanvas:x,preserveWhiteSpace:M,onSerialize:E,onIframeLoad:D,iframeLoadTimeout:_,keepIframeSrcFn:L},j=0,G=Array.from(t.childNodes);j<G.length;j++){(B=k(G[j],P))&&R.childNodes.push(B)}if(r(t)&&t.shadowRoot){R.isShadowHost=!0;for(var H=0,z=Array.from(t.shadowRoot.childNodes);H<z.length;H++){var B;(B=k(z[H],P))&&(B.isShadow=!0,R.childNodes.push(B))}}}return t.parentNode&&n(t.parentNode)&&(R.isShadow=!0),R.type===e.NodeType.Element&&"iframe"===R.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,o=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){var i="about:blank";n.location.href===i&&e.src!==i&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var s=setTimeout((function(){o||(t(),o=!0)}),r);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}}(t,(function(){var e=t.contentDocument;if(e&&D){var r=k(e,{doc:e,map:c,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:p,skipChild:!1,inlineStylesheet:v,maskInputOptions:g,maskTextFn:C,maskInputFn:N,slimDOMOptions:S,recordCanvas:x,preserveWhiteSpace:M,onSerialize:E,onIframeLoad:D,iframeLoadTimeout:_,keepIframeSrcFn:L});r&&D(t,r)}}),_),R}var C=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function N(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function o(){var e={line:r,column:n};return function(t){return t.position=new i(e),d(),t}}var i=function(e){this.start=e,this.end={line:r,column:n},this.source=t.source};i.prototype.content=e;var s=[];function c(a){var o=new Error(t.source+":"+r+":"+n+": "+a);if(o.reason=a,o.filename=t.source,o.line=r,o.column=n,o.source=e,!t.silent)throw o;s.push(o)}function u(){return p(/^{\s*/)}function l(){return p(/^}/)}function f(){var t,r=[];for(d(),m(r);e.length&&"}"!==e.charAt(0)&&(t=D()||I());)!1!==t&&(r.push(t),m(r));return r}function p(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function d(){p(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=o();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var i=e.slice(2,r-2);return n+=2,a(i),e=e.slice(r),n+=2,t({type:"comment",comment:i})}}function v(){var e=p(/^([^{]+)/);if(e)return S(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,(function(e){return e.replace(/,/g,"")})).split(/\s*(?![^(]*\)),\s*/).map((function(e){return e.replace(/\u200C/g,",")}))}function y(){var e=o(),t=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=S(t[0]);if(!p(/^:\s*/))return c("property missing ':'");var n=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(C,""),value:n?S(n[0]).replace(C,""):""});return p(/^[;\s]*/),a}}function g(){var e,t=[];if(!u())return c("missing '{'");for(m(t);e=y();)!1!==e&&(t.push(e),m(t)),e=y();return l()?t:c("missing '}'")}function T(){for(var e,t=[],r=o();e=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),p(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:g()})}var b,k=E("import"),N=E("charset"),x=E("namespace");function E(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=o(),n=p(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function D(){if("@"===e[0])return function(){var e=o(),t=p(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=p(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var i=m();n=T();)i.push(n),i=i.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:i}):c("@keyframes missing '}'")}}()||function(){var e=o(),t=p(/^@media *([^{]+)/);if(t){var r=S(t[1]);if(!u())return c("@media missing '{'");var n=m().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=o(),t=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:S(t[1]),media:S(t[2])})}()||function(){var e=o(),t=p(/^@supports *([^{]+)/);if(t){var r=S(t[1]);if(!u())return c("@supports missing '{'");var n=m().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||k()||N()||x()||function(){var e=o(),t=p(/^@([-\w]+)?document *([^{]+)/);if(t){var r=S(t[1]),n=S(t[2]);if(!u())return c("@document missing '{'");var a=m().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=o();if(p(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=m();r=y();)n.push(r),n=n.concat(m());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=o();if(p(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=m().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=o();if(p(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=m();t=y();)r.push(t),r=r.concat(m());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function I(){var e=o(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:g()})):c("selector missing")}return w((b=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:b,parsingErrors:s}}))}function S(e){return e?e.replace(/^\s+|\s+$/g,""):""}function w(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,o=Object.keys(e);a<o.length;a++){var i=e[o[a]];Array.isArray(i)?i.forEach((function(e){w(e,n)})):i&&"object"==typeof i&&w(i,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var x={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var E=/([^\\]):hover/,D=new RegExp(E,"g");function I(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=N(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach((function(e){"selectors"in e&&(e.selectors||[]).forEach((function(e){E.test(e)&&a.push(e)}))})),0===a.length)return e;var o=new RegExp(a.filter((function(e,t){return a.indexOf(e)===t})).sort((function(e,t){return t.length-e.length})).map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})).join("|"),"g"),i=e.replace(o,(function(e){var t=e.replace(D,"$1.\\:hover");return e+", "+t}));return null==t||t.stylesWithHoverClass.set(e,i),i}function _(t,r){var n=r.doc,a=r.hackCss,o=r.cache;switch(t.type){case e.NodeType.Document:return n.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.NodeType.Element:var i,s=function(e){var t=x[e.tagName]?x[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);i=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=i.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}if("rr_width"===e&&(i.style.width=r),"rr_height"===e&&(i.style.height=r),"rr_mediaCurrentTime"===e&&(i.currentTime=t.attributes.rr_mediaCurrentTime),"rr_mediaState"===e)switch(r){case"played":i.play().catch((function(e){return console.warn("media playback error",e)}));break;case"paused":i.pause()}}else{var u="textarea"===s&&"value"===e,l="style"===s&&"_cssText"===e;if(l&&a&&(r=I(r,o)),u||l){for(var f=n.createTextNode(r),p=0,d=Array.from(i.childNodes);p<d.length;p++){var m=d[p];m.nodeType===i.TEXT_NODE&&i.removeChild(m)}return i.appendChild(f),"continue"}try{if(t.isSVG&&"xlink:href"===e)i.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))i.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return i.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||i.setAttribute(e,r)}}catch(e){}}};for(var u in t.attributes)c(u);if(t.isShadowHost)if(i.shadowRoot)for(;i.shadowRoot.firstChild;)i.shadowRoot.removeChild(i.shadowRoot.firstChild);else i.attachShadow({mode:"open"});return i;case e.NodeType.Text:return n.createTextNode(t.isStyle&&a?I(t.textContent,o):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function O(t,n){var a=n.doc,o=n.map,i=n.skipChild,s=void 0!==i&&i,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,p=_(t,{doc:a,hackCss:u,cache:f});if(!p)return null;if(t.rootId&&console.assert(o[t.rootId]===a,"Target document should has the same root id."),t.type===e.NodeType.Document&&(a.close(),a.open(),"BackCompat"===t.compatMode&&t.childNodes&&t.childNodes[0].type!==e.NodeType.DocumentType&&(t.childNodes[0].type===e.NodeType.Element&&"xmlns"in t.childNodes[0].attributes&&"http://www.w3.org/1999/xhtml"===t.childNodes[0].attributes.xmlns?a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),p=a),p.__sn=t,o[t.id]=p,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!s)for(var d=0,m=t.childNodes;d<m.length;d++){var h=m[d],v=O(h,{doc:a,map:o,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&r(p)&&p.shadowRoot?p.shadowRoot.appendChild(v):p.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return p}return e.IGNORED_NODE=-2,e.addHoverClass=I,e.buildNodeWithSN=O,e.cleanupSnapshot=function(){o=1},e.createCache=function(){return{stylesWithHoverClass:new Map}},e.isElement=r,e.isShadowRoot=n,e.maskInputValue=a,e.needMaskingText=g,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,o=r.hackCss,i={},s=O(t,{doc:n,map:i,skipChild:!1,hackCss:void 0===o||o,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(i,(function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.NodeType.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var o=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=o),"rr_scrollTop"===a&&(n.scrollTop=o)}}}(t)})),[s,i]},e.serializeNodeWithId=k,e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,o=r.blockSelector,i=void 0===o?null:o,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,p=void 0===f||f,d=r.recordCanvas,m=void 0!==d&&d,h=r.maskAllInputs,v=void 0!==h&&h,y=r.maskTextFn,g=r.maskInputFn,T=r.slimDOM,b=void 0!==T&&T,C=r.preserveWhiteSpace,N=r.onSerialize,S=r.onIframeLoad,w=r.iframeLoadTimeout,x=r.keepIframeSrcFn,E={};return[k(e,{doc:e,map:E,blockClass:a,blockSelector:i,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:p,maskInputOptions:!0===v?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===v?{password:!0}:v,maskTextFn:y,maskInputFn:g,slimDOMOptions:!0===b||"all"===b?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===b,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===b?{}:b,recordCanvas:m,preserveWhiteSpace:C,onSerialize:N,onIframeLoad:S,iframeLoadTimeout:w,keepIframeSrcFn:void 0===x?function(){return!1}:x}),E]},e.transformAttribute=y,e.visitSnapshot=function(t,r){!function t(n){r(n),n.type!==e.NodeType.Document&&n.type!==e.NodeType.Element||n.childNodes.forEach(t)}(t)},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=rrweb-snapshot.min.js.map |
@@ -60,5 +60,10 @@ var NodeType; | ||
function getCssRuleString(rule) { | ||
return isCSSImportRule(rule) | ||
? getCssRulesString(rule.styleSheet) || '' | ||
: rule.cssText; | ||
var cssStringified = rule.cssText; | ||
if (isCSSImportRule(rule)) { | ||
try { | ||
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified; | ||
} | ||
catch (_a) { } | ||
} | ||
return cssStringified; | ||
} | ||
@@ -303,7 +308,17 @@ function isCSSImportRule(rule) { | ||
case n.DOCUMENT_NODE: | ||
return { | ||
type: NodeType.Document, | ||
childNodes: [], | ||
rootId: rootId, | ||
}; | ||
if (n.compatMode !== 'CSS1Compat') { | ||
return { | ||
type: NodeType.Document, | ||
childNodes: [], | ||
compatMode: n.compatMode, | ||
rootId: rootId | ||
}; | ||
} | ||
else { | ||
return { | ||
type: NodeType.Document, | ||
childNodes: [], | ||
rootId: rootId | ||
}; | ||
} | ||
case n.DOCUMENT_TYPE_NODE: | ||
@@ -315,3 +330,3 @@ return { | ||
systemId: n.systemId, | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -321,6 +336,6 @@ case n.ELEMENT_NODE: | ||
var tagName = getValidTagName(n); | ||
var attributes_1 = {}; | ||
var attributes = {}; | ||
for (var _i = 0, _b = Array.from(n.attributes); _i < _b.length; _i++) { | ||
var _c = _b[_i], name = _c.name, value = _c.value; | ||
attributes_1[name] = transformAttribute(doc, tagName, name, value); | ||
var _c = _b[_i], name_1 = _c.name, value = _c.value; | ||
attributes[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
} | ||
@@ -333,5 +348,5 @@ if (tagName === 'link' && inlineStylesheet) { | ||
if (cssText) { | ||
delete attributes_1.rel; | ||
delete attributes_1.href; | ||
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
delete attributes.rel; | ||
delete attributes.href; | ||
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
} | ||
@@ -346,3 +361,3 @@ } | ||
if (cssText) { | ||
attributes_1._cssText = absoluteToStylesheet(cssText, getHref()); | ||
attributes._cssText = absoluteToStylesheet(cssText, getHref()); | ||
} | ||
@@ -354,17 +369,17 @@ } | ||
var value = n.value; | ||
if (attributes_1.type !== 'radio' && | ||
attributes_1.type !== 'checkbox' && | ||
attributes_1.type !== 'submit' && | ||
attributes_1.type !== 'button' && | ||
if (attributes.type !== 'radio' && | ||
attributes.type !== 'checkbox' && | ||
attributes.type !== 'submit' && | ||
attributes.type !== 'button' && | ||
value) { | ||
attributes_1.value = maskInputValue({ | ||
type: attributes_1.type, | ||
attributes.value = maskInputValue({ | ||
type: attributes.type, | ||
tagName: tagName, | ||
value: value, | ||
maskInputOptions: maskInputOptions, | ||
maskInputFn: maskInputFn, | ||
maskInputFn: maskInputFn | ||
}); | ||
} | ||
else if (n.checked) { | ||
attributes_1.checked = n.checked; | ||
attributes.checked = n.checked; | ||
} | ||
@@ -374,33 +389,33 @@ } | ||
if (n.selected) { | ||
attributes_1.selected = true; | ||
attributes.selected = true; | ||
} | ||
else { | ||
delete attributes_1.selected; | ||
delete attributes.selected; | ||
} | ||
} | ||
if (tagName === 'canvas' && recordCanvas) { | ||
attributes_1.rr_dataURL = n.toDataURL(); | ||
attributes.rr_dataURL = n.toDataURL(); | ||
} | ||
if (tagName === 'audio' || tagName === 'video') { | ||
attributes_1.rr_mediaState = n.paused | ||
attributes.rr_mediaState = n.paused | ||
? 'paused' | ||
: 'played'; | ||
attributes_1.rr_mediaCurrentTime = n.currentTime; | ||
attributes.rr_mediaCurrentTime = n.currentTime; | ||
} | ||
if (n.scrollLeft) { | ||
attributes_1.rr_scrollLeft = n.scrollLeft; | ||
attributes.rr_scrollLeft = n.scrollLeft; | ||
} | ||
if (n.scrollTop) { | ||
attributes_1.rr_scrollTop = n.scrollTop; | ||
attributes.rr_scrollTop = n.scrollTop; | ||
} | ||
if (needBlock) { | ||
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height; | ||
attributes_1 = { | ||
class: attributes_1.class, | ||
attributes = { | ||
"class": attributes["class"], | ||
rr_width: width + "px", | ||
rr_height: height + "px", | ||
rr_height: height + "px" | ||
}; | ||
} | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) { | ||
delete attributes_1.src; | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) { | ||
delete attributes.src; | ||
} | ||
@@ -410,7 +425,7 @@ return { | ||
tagName: tagName, | ||
attributes: attributes_1, | ||
attributes: attributes, | ||
childNodes: [], | ||
isSVG: isSVGElement(n) || undefined, | ||
needBlock: needBlock, | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -440,3 +455,3 @@ case n.TEXT_NODE: | ||
isStyle: isStyle, | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -447,3 +462,3 @@ case n.CDATA_SECTION_NODE: | ||
textContent: '', | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -454,3 +469,3 @@ case n.COMMENT_NODE: | ||
textContent: n.textContent || '', | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -554,3 +569,3 @@ default: | ||
recordCanvas: recordCanvas, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}); | ||
@@ -615,3 +630,3 @@ if (!_serializedNode) { | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}; | ||
@@ -663,3 +678,3 @@ for (var _i = 0, _h = Array.from(n.childNodes); _i < _h.length; _i++) { | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}); | ||
@@ -694,7 +709,7 @@ if (serializedIframeNode) { | ||
select: true, | ||
password: true, | ||
password: true | ||
} | ||
: maskAllInputs === false | ||
? { | ||
password: true, | ||
password: true | ||
} | ||
@@ -714,3 +729,3 @@ : maskAllInputs; | ||
headMetaAuthorship: true, | ||
headMetaVerification: true, | ||
headMetaVerification: true | ||
} | ||
@@ -739,3 +754,3 @@ : slimDOM === false | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}), | ||
@@ -811,4 +826,4 @@ idNodeMap, | ||
rules: rulesList, | ||
parsingErrors: errorsList, | ||
}, | ||
parsingErrors: errorsList | ||
} | ||
}; | ||
@@ -880,3 +895,3 @@ } | ||
type: 'comment', | ||
comment: str, | ||
comment: str | ||
}); | ||
@@ -913,3 +928,3 @@ } | ||
property: prop.replace(commentre, ''), | ||
value: val ? trim(val[0]).replace(commentre, '') : '', | ||
value: val ? trim(val[0]).replace(commentre, '') : '' | ||
}); | ||
@@ -952,3 +967,3 @@ match(/^[;\s]*/); | ||
values: vals, | ||
declarations: declarations(), | ||
declarations: declarations() | ||
}); | ||
@@ -984,3 +999,3 @@ } | ||
vendor: vendor, | ||
keyframes: frames, | ||
keyframes: frames | ||
}); | ||
@@ -1005,3 +1020,3 @@ } | ||
supports: supports, | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1024,3 +1039,3 @@ } | ||
type: 'host', | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1045,3 +1060,3 @@ } | ||
media: media, | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1058,3 +1073,3 @@ } | ||
name: trim(m[1]), | ||
media: trim(m[2]), | ||
media: trim(m[2]) | ||
}); | ||
@@ -1084,3 +1099,3 @@ } | ||
selectors: sel, | ||
declarations: decls, | ||
declarations: decls | ||
}); | ||
@@ -1107,3 +1122,3 @@ } | ||
vendor: vendor, | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1131,3 +1146,3 @@ } | ||
type: 'font-face', | ||
declarations: decls, | ||
declarations: decls | ||
}); | ||
@@ -1177,3 +1192,3 @@ } | ||
selectors: sel, | ||
declarations: declarations(), | ||
declarations: declarations() | ||
}); | ||
@@ -1206,3 +1221,3 @@ } | ||
enumerable: false, | ||
value: parent || null, | ||
value: parent || null | ||
}); | ||
@@ -1250,3 +1265,3 @@ } | ||
lineargradient: 'linearGradient', | ||
radialgradient: 'radialGradient', | ||
radialgradient: 'radialGradient' | ||
}; | ||
@@ -1270,3 +1285,3 @@ function getTagName(n) { | ||
var ast = parse(cssText, { | ||
silent: true, | ||
silent: true | ||
}); | ||
@@ -1306,3 +1321,3 @@ if (!ast.stylesheet) { | ||
return { | ||
stylesWithHoverClass: stylesWithHoverClass, | ||
stylesWithHoverClass: stylesWithHoverClass | ||
}; | ||
@@ -1326,8 +1341,8 @@ } | ||
} | ||
var _loop_1 = function (name) { | ||
if (!n.attributes.hasOwnProperty(name)) { | ||
var _loop_1 = function (name_1) { | ||
if (!n.attributes.hasOwnProperty(name_1)) { | ||
return "continue"; | ||
} | ||
var value = n.attributes[name]; | ||
if (tagName === 'option' && name === 'selected' && value === false) { | ||
var value = n.attributes[name_1]; | ||
if (tagName === 'option' && name_1 === 'selected' && value === false) { | ||
return "continue"; | ||
@@ -1337,5 +1352,5 @@ } | ||
typeof value === 'boolean' || typeof value === 'number' ? '' : value; | ||
if (!name.startsWith('rr_')) { | ||
var isTextarea = tagName === 'textarea' && name === 'value'; | ||
var isRemoteOrDynamicCss = tagName === 'style' && name === '_cssText'; | ||
if (!name_1.startsWith('rr_')) { | ||
var isTextarea = tagName === 'textarea' && name_1 === 'value'; | ||
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText'; | ||
if (isRemoteOrDynamicCss && hackCss) { | ||
@@ -1356,13 +1371,13 @@ value = addHoverClass(value, cache); | ||
try { | ||
if (n.isSVG && name === 'xlink:href') { | ||
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name, value); | ||
if (n.isSVG && name_1 === 'xlink:href') { | ||
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value); | ||
} | ||
else if (name === 'onload' || | ||
name === 'onclick' || | ||
name.substring(0, 7) === 'onmouse') { | ||
node_1.setAttribute('_' + name, value); | ||
else if (name_1 === 'onload' || | ||
name_1 === 'onclick' || | ||
name_1.substring(0, 7) === 'onmouse') { | ||
node_1.setAttribute('_' + name_1, value); | ||
} | ||
else if (tagName === 'meta' && | ||
n.attributes['http-equiv'] === 'Content-Security-Policy' && | ||
name === 'content') { | ||
name_1 === 'content') { | ||
node_1.setAttribute('csp-content', value); | ||
@@ -1373,9 +1388,11 @@ return "continue"; | ||
n.attributes.rel === 'preload' && | ||
n.attributes.as === 'script') ; | ||
n.attributes.as === 'script') { | ||
} | ||
else if (tagName === 'link' && | ||
n.attributes.rel === 'prefetch' && | ||
typeof n.attributes.href === 'string' && | ||
n.attributes.href.endsWith('.js')) ; | ||
n.attributes.href.endsWith('.js')) { | ||
} | ||
else { | ||
node_1.setAttribute(name, value); | ||
node_1.setAttribute(name_1, value); | ||
} | ||
@@ -1387,3 +1404,3 @@ } | ||
else { | ||
if (tagName === 'canvas' && name === 'rr_dataURL') { | ||
if (tagName === 'canvas' && name_1 === 'rr_dataURL') { | ||
var image_1 = document.createElement('img'); | ||
@@ -1398,18 +1415,17 @@ image_1.src = value; | ||
} | ||
if (name === 'rr_width') { | ||
if (name_1 === 'rr_width') { | ||
node_1.style.width = value; | ||
} | ||
if (name === 'rr_height') { | ||
if (name_1 === 'rr_height') { | ||
node_1.style.height = value; | ||
} | ||
if (name === 'rr_mediaCurrentTime') { | ||
if (name_1 === 'rr_mediaCurrentTime') { | ||
node_1.currentTime = n.attributes | ||
.rr_mediaCurrentTime; | ||
} | ||
if (name === 'rr_mediaState') { | ||
if (name_1 === 'rr_mediaState') { | ||
switch (value) { | ||
case 'played': | ||
node_1 | ||
.play() | ||
.catch(function (e) { return console.warn('media playback error', e); }); | ||
.play()["catch"](function (e) { return console.warn('media playback error', e); }); | ||
break; | ||
@@ -1419,3 +1435,2 @@ case 'paused': | ||
break; | ||
default: | ||
} | ||
@@ -1425,4 +1440,4 @@ } | ||
}; | ||
for (var name in n.attributes) { | ||
_loop_1(name); | ||
for (var name_1 in n.attributes) { | ||
_loop_1(name_1); | ||
} | ||
@@ -1464,2 +1479,13 @@ if (n.isShadowHost) { | ||
doc.open(); | ||
if (n.compatMode === 'BackCompat' && | ||
(n.childNodes && n.childNodes[0].type !== NodeType.DocumentType)) { | ||
if (n.childNodes[0].type === NodeType.Element && | ||
'xmlns' in n.childNodes[0].attributes && | ||
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') { | ||
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'); | ||
} | ||
else { | ||
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'); | ||
} | ||
} | ||
node = doc; | ||
@@ -1479,3 +1505,3 @@ } | ||
afterAppend: afterAppend, | ||
cache: cache, | ||
cache: cache | ||
}); | ||
@@ -1515,11 +1541,11 @@ if (!childNode) { | ||
var el = node; | ||
for (var name in n.attributes) { | ||
if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) { | ||
for (var name_2 in n.attributes) { | ||
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) { | ||
continue; | ||
} | ||
var value = n.attributes[name]; | ||
if (name === 'rr_scrollLeft') { | ||
var value = n.attributes[name_2]; | ||
if (name_2 === 'rr_scrollLeft') { | ||
el.scrollLeft = value; | ||
} | ||
if (name === 'rr_scrollTop') { | ||
if (name_2 === 'rr_scrollTop') { | ||
el.scrollTop = value; | ||
@@ -1538,3 +1564,3 @@ } | ||
afterAppend: afterAppend, | ||
cache: cache, | ||
cache: cache | ||
}); | ||
@@ -1550,2 +1576,2 @@ visit(idNodeMap, function (visitedNode) { | ||
export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, createCache, transformAttribute, visitSnapshot, cleanupSnapshot, needMaskingText, IGNORED_NODE, NodeType, isElement, isShadowRoot, maskInputValue }; | ||
export { IGNORED_NODE, NodeType, addHoverClass, buildNodeWithSN, cleanupSnapshot, createCache, isElement, isShadowRoot, maskInputValue, needMaskingText, rebuild, serializeNodeWithId, snapshot, transformAttribute, visitSnapshot }; |
@@ -1,2 +0,2 @@ | ||
var NodeType;function isElement(e){return e.nodeType===e.ELEMENT_NODE}function isShadowRoot(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function maskInputValue(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(NodeType||(NodeType={}));var _id=1,tagNameRegex=RegExp("[^a-z0-9-_:]"),IGNORED_NODE=-2;function genId(){return _id++}function getValidTagName(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return tagNameRegex.test(t)?"div":t}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(getCssRuleString).join(""):null}catch(e){return null}}function getCssRuleString(e){return isCSSImportRule(e)?getCssRulesString(e.styleSheet)||"":e.cssText}function isCSSImportRule(e){return"styleSheet"in e}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,DATA_URI=/^(data:)([^,]*),(.*)/i;function absoluteToStylesheet(e,t){return(e||"").replace(URL_IN_CSS_REF,function(e,r,n,a,i,o){var s=n||i||o,l=r||a||"";if(!s)return e;if(!RELATIVE_PATH.test(s))return"url("+l+s+l+")";if(DATA_URI.test(s))return"url("+l+s+l+")";if("/"===s[0])return"url("+l+(extractOrigin(t)+s)+l+")";var c=t.split("/"),u=s.split("/");c.pop();for(var f=0,d=u;f<d.length;f++){var m=d[f];"."!==m&&(".."===m?c.pop():c.push(m))}return"url("+l+c.join("/")+l+")"})}var SRCSET_NOT_SPACES=/^[^ \t\n\r\u000c]+/,SRCSET_COMMAS_OR_SPACES=/^[, \t\n\r\u000c]+/;function getAbsoluteSrcsetString(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(SRCSET_COMMAS_OR_SPACES),!(r>=t.length);){var i=n(SRCSET_NOT_SPACES);if(","===i.slice(-1))i=absoluteToDoc(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=absoluteToDoc(e,i);for(var s=!1;;){var l=t.charAt(r);if(""===l){a.push((i+o).trim());break}if(s)")"===l&&(s=!1);else{if(","===l){r+=1,a.push((i+o).trim());break}"("===l&&(s=!0)}o+=l,r+=1}}}return a.join(", ")}function absoluteToDoc(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}function getHref(){var e=document.createElement("a");return e.href="",e.href}function transformAttribute(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?absoluteToDoc(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?getAbsoluteSrcsetString(e,n):"style"===r&&n?absoluteToStylesheet(n,getHref()):n:absoluteToDoc(e,n)}function _isBlockedElement(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var a=e.classList[n];if(t.test(a))return!0}return!!r&&e.matches(r)}function needMaskingText(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach(function(e){if(t.test(e))return!0});return!(!r||!e.matches(r))||needMaskingText(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,needMaskingText(e.parentNode,t,r)}function onceIframeLoaded(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var o=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()})}}}function serializeNode(e,t){var r,n=t.doc,a=t.blockClass,i=t.blockSelector,o=t.maskTextClass,s=t.maskTextSelector,l=t.inlineStylesheet,c=t.maskInputOptions,u=void 0===c?{}:c,f=t.maskTextFn,d=t.maskInputFn,m=t.recordCanvas,p=t.keepIframeSrcFn;if(n.__sn){var h=n.__sn.id;r=1===h?void 0:h}switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[],rootId:r};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:r};case e.ELEMENT_NODE:for(var v=_isBlockedElement(e,a,i),g=getValidTagName(e),y={},T=0,E=Array.from(e.attributes);T<E.length;T++){var b=E[T],S=b.name,k=b.value;y[S]=transformAttribute(n,g,S,k)}if("link"===g&&l){var C,N=Array.from(n.styleSheets).find(function(t){return t.href===e.href});(C=getCssRulesString(N))&&(delete y.rel,delete y.href,y._cssText=absoluteToStylesheet(C,N.href))}if("style"===g&&e.sheet&&!(e.innerText||e.textContent||"").trim().length)(C=getCssRulesString(e.sheet))&&(y._cssText=absoluteToStylesheet(C,getHref()));if("input"===g||"textarea"===g||"select"===g){k=e.value;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&k?y.value=maskInputValue({type:y.type,tagName:g,value:k,maskInputOptions:u,maskInputFn:d}):e.checked&&(y.checked=e.checked)}if("option"===g&&(e.selected?y.selected=!0:delete y.selected),"canvas"===g&&m&&(y.rr_dataURL=e.toDataURL()),"audio"!==g&&"video"!==g||(y.rr_mediaState=e.paused?"paused":"played",y.rr_mediaCurrentTime=e.currentTime),e.scrollLeft&&(y.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(y.rr_scrollTop=e.scrollTop),v){var x=e.getBoundingClientRect(),I=x.width,w=x.height;y={class:y.class,rr_width:I+"px",rr_height:w+"px"}}return"iframe"!==g||p(y.src)||delete y.src,{type:NodeType.Element,tagName:g,attributes:y,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:v,rootId:r};case e.TEXT_NODE:var _=e.parentNode&&e.parentNode.tagName,O=e.textContent,R="STYLE"===_||void 0,D="SCRIPT"===_||void 0;return R&&O&&(O=absoluteToStylesheet(O,getHref())),D&&(O="SCRIPT_PLACEHOLDER"),!R&&!D&&needMaskingText(e,o,s)&&O&&(O=f?f(O):O.replace(/[\S]/g,"*")),{type:NodeType.Text,textContent:O||"",isStyle:R,rootId:r};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:"",rootId:r};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||"",rootId:r};default:return!1}}function lowerIfExists(e){return void 0===e?"":e.toLowerCase()}function slimDOMExcluded(e,t){if(t.comment&&e.type===NodeType.Comment)return!0;if(e.type===NodeType.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(lowerIfExists(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===lowerIfExists(e.attributes.name)||"icon"===lowerIfExists(e.attributes.rel)||"apple-touch-icon"===lowerIfExists(e.attributes.rel)||"shortcut icon"===lowerIfExists(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&lowerIfExists(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(lowerIfExists(e.attributes.property).match(/^(og|twitter|fb):/)||lowerIfExists(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===lowerIfExists(e.attributes.name)||"googlebot"===lowerIfExists(e.attributes.name)||"bingbot"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===lowerIfExists(e.attributes.name)||"generator"===lowerIfExists(e.attributes.name)||"framework"===lowerIfExists(e.attributes.name)||"publisher"===lowerIfExists(e.attributes.name)||"progid"===lowerIfExists(e.attributes.name)||lowerIfExists(e.attributes.property).match(/^article:/)||lowerIfExists(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===lowerIfExists(e.attributes.name)||"yandex-verification"===lowerIfExists(e.attributes.name)||"csrf-token"===lowerIfExists(e.attributes.name)||"p:domain_verify"===lowerIfExists(e.attributes.name)||"verify-v1"===lowerIfExists(e.attributes.name)||"verification"===lowerIfExists(e.attributes.name)||"shopify-checkout-api-token"===lowerIfExists(e.attributes.name)))return!0}}return!1}function serializeNodeWithId(e,t){var r,n=t.doc,a=t.map,i=t.blockClass,o=t.blockSelector,s=t.maskTextClass,l=t.maskTextSelector,c=t.skipChild,u=void 0!==c&&c,f=t.inlineStylesheet,d=void 0===f||f,m=t.maskInputOptions,p=void 0===m?{}:m,h=t.maskTextFn,v=t.maskInputFn,g=t.slimDOMOptions,y=t.recordCanvas,T=void 0!==y&&y,E=t.onSerialize,b=t.onIframeLoad,S=t.iframeLoadTimeout,k=void 0===S?5e3:S,C=t.keepIframeSrcFn,N=void 0===C?function(){return!1}:C,x=t.preserveWhiteSpace,I=void 0===x||x,w=serializeNode(e,{doc:n,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:p,maskTextFn:h,maskInputFn:v,recordCanvas:T,keepIframeSrcFn:N});if(!w)return console.warn(e,"not serialized"),null;r="__sn"in e?e.__sn.id:slimDOMExcluded(w,g)||!I&&w.type===NodeType.Text&&!w.isStyle&&!w.textContent.replace(/^\s+|\s+$/gm,"").length?IGNORED_NODE:genId();var _=Object.assign(w,{id:r});if(e.__sn=_,r===IGNORED_NODE)return null;a[r]=e,E&&E(e);var O=!u;if(_.type===NodeType.Element&&(O=O&&!_.needBlock,delete _.needBlock),(_.type===NodeType.Document||_.type===NodeType.Element)&&O){g.headWhitespace&&w.type===NodeType.Element&&"head"===w.tagName&&(I=!1);for(var R={doc:n,map:a,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,skipChild:u,inlineStylesheet:d,maskInputOptions:p,maskTextFn:h,maskInputFn:v,slimDOMOptions:g,recordCanvas:T,preserveWhiteSpace:I,onSerialize:E,onIframeLoad:b,iframeLoadTimeout:k,keepIframeSrcFn:N},D=0,A=Array.from(e.childNodes);D<A.length;D++){(F=serializeNodeWithId(A[D],R))&&_.childNodes.push(F)}if(isElement(e)&&e.shadowRoot){_.isShadowHost=!0;for(var L=0,M=Array.from(e.shadowRoot.childNodes);L<M.length;L++){var F;(F=serializeNodeWithId(M[L],R))&&(F.isShadow=!0,_.childNodes.push(F))}}}return e.parentNode&&isShadowRoot(e.parentNode)&&(_.isShadow=!0),_.type===NodeType.Element&&"iframe"===_.tagName&&onceIframeLoaded(e,function(){var t=e.contentDocument;if(t&&b){var r=serializeNodeWithId(t,{doc:t,map:a,blockClass:i,blockSelector:o,maskTextClass:s,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:h,maskInputFn:v,slimDOMOptions:g,recordCanvas:T,preserveWhiteSpace:I,onSerialize:E,onIframeLoad:b,iframeLoadTimeout:k,keepIframeSrcFn:N});r&&b(e,r)}},k),_}function snapshot(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,l=void 0===s?"rr-mask":s,c=r.maskTextSelector,u=void 0===c?null:c,f=r.inlineStylesheet,d=void 0===f||f,m=r.recordCanvas,p=void 0!==m&&m,h=r.maskAllInputs,v=void 0!==h&&h,g=r.maskTextFn,y=r.maskInputFn,T=r.slimDOM,E=void 0!==T&&T,b=r.preserveWhiteSpace,S=r.onSerialize,k=r.onIframeLoad,C=r.iframeLoadTimeout,N=r.keepIframeSrcFn,x={};return[serializeNodeWithId(e,{doc:e,map:x,blockClass:a,blockSelector:o,maskTextClass:l,maskTextSelector:u,skipChild:!1,inlineStylesheet:d,maskInputOptions:!0===v?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===v?{password:!0}:v,maskTextFn:g,maskInputFn:y,slimDOMOptions:!0===E||"all"===E?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===E,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===E?{}:E,recordCanvas:p,preserveWhiteSpace:b,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:C,keepIframeSrcFn:void 0===N?function(){return!1}:N}),x]}function visitSnapshot(e,t){!function e(r){t(r),r.type!==NodeType.Document&&r.type!==NodeType.Element||r.childNodes.forEach(e)}(e)}function cleanupSnapshot(){_id=1}var commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function parse(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function i(){var e={line:r,column:n};return function(t){return t.position=new o(e),m(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function l(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function c(){return d(/^{\s*/)}function u(){return d(/^}/)}function f(){var t,r=[];for(m(),p(r);e.length&&"}"!==e.charAt(0)&&(t=N()||x());)!1!==t&&(r.push(t),p(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function m(){d(/^\s*/)}function p(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=d(/^([^{]+)/);if(e)return trim(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=i(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=trim(t[0]);if(!d(/^:\s*/))return l("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(commentre,""),value:n?trim(n[0]).replace(commentre,""):""});return d(/^[;\s]*/),a}}function y(){var e,t=[];if(!c())return l("missing '{'");for(p(t);e=g();)!1!==e&&(t.push(e),p(t)),e=g();return u()?t:l("missing '}'")}function T(){for(var e,t=[],r=i();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var E,b=C("import"),S=C("charset"),k=C("namespace");function C(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=d(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function N(){if("@"===e[0])return function(){var e=i(),t=d(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return l("@keyframes missing name");var n,a=t[1];if(!c())return l("@keyframes missing '{'");for(var o=p();n=T();)o.push(n),o=o.concat(p());return u()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):l("@keyframes missing '}'")}}()||function(){var e=i(),t=d(/^@media *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@media missing '{'");var n=p().concat(f());return u()?e({type:"media",media:r,rules:n}):l("@media missing '}'")}}()||function(){var e=i(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:trim(t[1]),media:trim(t[2])})}()||function(){var e=i(),t=d(/^@supports *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@supports missing '{'");var n=p().concat(f());return u()?e({type:"supports",supports:r,rules:n}):l("@supports missing '}'")}}()||b()||S()||k()||function(){var e=i(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=trim(t[1]),n=trim(t[2]);if(!c())return l("@document missing '{'");var a=p().concat(f());return u()?e({type:"document",document:n,vendor:r,rules:a}):l("@document missing '}'")}}()||function(){var e=i();if(d(/^@page */)){var t=v()||[];if(!c())return l("@page missing '{'");for(var r,n=p();r=g();)n.push(r),n=n.concat(p());return u()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}()||function(){var e=i();if(d(/^@host\s*/)){if(!c())return l("@host missing '{'");var t=p().concat(f());return u()?e({type:"host",rules:t}):l("@host missing '}'")}}()||function(){var e=i();if(d(/^@font-face\s*/)){if(!c())return l("@font-face missing '{'");for(var t,r=p();t=g();)r.push(t),r=r.concat(p());return u()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}()}function x(){var e=i(),t=v();return t?(p(),e({type:"rule",selectors:t,declarations:y()})):l("selector missing")}return addParent((E=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:s}}))}function trim(e){return e?e.replace(/^\s+|\s+$/g,""):""}function addParent(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,i=Object.keys(e);a<i.length;a++){var o=e[i[a]];Array.isArray(o)?o.forEach(function(e){addParent(e,n)}):o&&"object"==typeof o&&addParent(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var tagMap={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}function escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var HOVER_SELECTOR=/([^\\]):hover/,HOVER_SELECTOR_GLOBAL=new RegExp(HOVER_SELECTOR,"g");function addHoverClass(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=parse(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach(function(e){"selectors"in e&&(e.selectors||[]).forEach(function(e){HOVER_SELECTOR.test(e)&&a.push(e)})}),0===a.length)return e;var i=new RegExp(a.filter(function(e,t){return a.indexOf(e)===t}).sort(function(e,t){return t.length-e.length}).map(function(e){return escapeRegExp(e)}).join("|"),"g"),o=e.replace(i,function(e){var t=e.replace(HOVER_SELECTOR_GLOBAL,"$1.\\:hover");return e+", "+t});return null==t||t.stylesWithHoverClass.set(e,o),o}function createCache(){return{stylesWithHoverClass:new Map}}function buildNode(e,t){var r=t.doc,n=t.hackCss,a=t.cache;switch(e.type){case NodeType.Document:return r.implementation.createDocument(null,"",null);case NodeType.DocumentType:return r.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case NodeType.Element:var i,o=getTagName(e);i=e.isSVG?r.createElementNS("http://www.w3.org/2000/svg",o):r.createElement(o);var s=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";var s=e.attributes[t];if("option"===o&&"selected"===t&&!1===s)return"continue";if(s="boolean"==typeof s||"number"==typeof s?"":s,t.startsWith("rr_")){if("canvas"===o&&"rr_dataURL"===t){var l=document.createElement("img");l.src=s,l.onload=function(){var e=i.getContext("2d");e&&e.drawImage(l,0,0,l.width,l.height)}}if("rr_width"===t&&(i.style.width=s),"rr_height"===t&&(i.style.height=s),"rr_mediaCurrentTime"===t&&(i.currentTime=e.attributes.rr_mediaCurrentTime),"rr_mediaState"===t)switch(s){case"played":i.play().catch(function(e){return console.warn("media playback error",e)});break;case"paused":i.pause()}}else{var c="textarea"===o&&"value"===t,u="style"===o&&"_cssText"===t;if(u&&n&&(s=addHoverClass(s,a)),c||u){for(var f=r.createTextNode(s),d=0,m=Array.from(i.childNodes);d<m.length;d++){var p=m[d];p.nodeType===i.TEXT_NODE&&i.removeChild(p)}return i.appendChild(f),"continue"}try{if(e.isSVG&&"xlink:href"===t)i.setAttributeNS("http://www.w3.org/1999/xlink",t,s);else if("onload"===t||"onclick"===t||"onmouse"===t.substring(0,7))i.setAttribute("_"+t,s);else{if("meta"===o&&"Content-Security-Policy"===e.attributes["http-equiv"]&&"content"===t)return i.setAttribute("csp-content",s),"continue";"link"===o&&"preload"===e.attributes.rel&&"script"===e.attributes.as||"link"===o&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")||i.setAttribute(t,s)}}catch(e){}}};for(var l in e.attributes)s(l);if(e.isShadowHost)if(i.shadowRoot)for(;i.shadowRoot.firstChild;)i.shadowRoot.removeChild(i.shadowRoot.firstChild);else i.attachShadow({mode:"open"});return i;case NodeType.Text:return r.createTextNode(e.isStyle&&n?addHoverClass(e.textContent,a):e.textContent);case NodeType.CDATA:return r.createCDATASection(e.textContent);case NodeType.Comment:return r.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t){var r=t.doc,n=t.map,a=t.skipChild,i=void 0!==a&&a,o=t.hackCss,s=void 0===o||o,l=t.afterAppend,c=t.cache,u=buildNode(e,{doc:r,hackCss:s,cache:c});if(!u)return null;if(e.rootId&&console.assert(n[e.rootId]===r,"Target document should has the same root id."),e.type===NodeType.Document&&(r.close(),r.open(),u=r),u.__sn=e,n[e.id]=u,(e.type===NodeType.Document||e.type===NodeType.Element)&&!i)for(var f=0,d=e.childNodes;f<d.length;f++){var m=d[f],p=buildNodeWithSN(m,{doc:r,map:n,skipChild:!1,hackCss:s,afterAppend:l,cache:c});p?(m.isShadow&&isElement(u)&&u.shadowRoot?u.shadowRoot.appendChild(p):u.appendChild(p),l&&l(p)):console.warn("Failed to rebuild",m)}return u}function visit(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}function handleScroll(e){var t=e.__sn;if(t.type===NodeType.Element){var r=e;for(var n in t.attributes)if(t.attributes.hasOwnProperty(n)&&n.startsWith("rr_")){var a=t.attributes[n];"rr_scrollLeft"===n&&(r.scrollLeft=a),"rr_scrollTop"===n&&(r.scrollTop=a)}}}function rebuild(e,t){var r=t.doc,n=t.onVisit,a=t.hackCss,i={},o=buildNodeWithSN(e,{doc:r,map:i,skipChild:!1,hackCss:void 0===a||a,afterAppend:t.afterAppend,cache:t.cache});return visit(i,function(e){n&&n(e),handleScroll(e)}),[o,i]}export{snapshot,serializeNodeWithId,rebuild,buildNodeWithSN,addHoverClass,createCache,transformAttribute,visitSnapshot,cleanupSnapshot,needMaskingText,IGNORED_NODE,NodeType,isElement,isShadowRoot,maskInputValue}; | ||
var e;function t(e){return e.nodeType===e.ELEMENT_NODE}function r(e){var t,r=null===(t=e)||void 0===t?void 0:t.host;return Boolean(r&&r.shadowRoot&&r.shadowRoot===e)}function n(e){var t=e.maskInputOptions,r=e.tagName,n=e.type,a=e.value,i=e.maskInputFn,o=a||"";return(t[r.toLowerCase()]||t[n])&&(o=i?i(o):"*".repeat(o.length)),o}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(e||(e={}));var a=1,i=RegExp("[^a-z0-9-_:]"),o=-2;function s(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(c).join(""):null}catch(e){return null}}function c(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=s(e.styleSheet)||t}catch(e){}return t}var u=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,l=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,f=/^(data:)([^,]*),(.*)/i;function m(e,t){return(e||"").replace(u,(function(e,r,n,a,i,o){var s,c=n||i||o,u=r||a||"";if(!c)return e;if(!l.test(c))return"url("+u+c+u+")";if(f.test(c))return"url("+u+c+u+")";if("/"===c[0])return"url("+u+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)+u+")";var m=t.split("/"),p=c.split("/");m.pop();for(var d=0,h=p;d<h.length;d++){var v=h[d];"."!==v&&(".."===v?m.pop():m.push(v))}return"url("+u+m.join("/")+u+")"}))}var p=/^[^ \t\n\r\u000c]+/,d=/^[, \t\n\r\u000c]+/;function h(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function v(){var e=document.createElement("a");return e.href="",e.href}function g(e,t,r,n){return"src"===r||("href"===r||"xlink:href"===r)&&n?h(e,n):"background"!==r||!n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r&&n?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,a=e.exec(t.substring(r));return a?(n=a[0],r+=n.length,n):""}for(var a=[];n(d),!(r>=t.length);){var i=n(p);if(","===i.slice(-1))i=h(e,i.substring(0,i.length-1)),a.push(i);else{var o="";i=h(e,i);for(var s=!1;;){var c=t.charAt(r);if(""===c){a.push((i+o).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){r+=1,a.push((i+o).trim());break}"("===c&&(s=!0)}o+=c,r+=1}}}return a.join(", ")}(e,n):"style"===r&&n?m(n,v()):n:h(e,n)}function y(e,t,r){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach((function(e){if(t.test(e))return!0}));return!(!r||!e.matches(r))||y(e.parentNode,t,r)}return e.nodeType,e.TEXT_NODE,y(e.parentNode,t,r)}function k(t,r){var a,o,c=r.doc,u=r.blockClass,l=r.blockSelector,f=r.maskTextClass,p=r.maskTextSelector,d=r.inlineStylesheet,h=r.maskInputOptions,k=void 0===h?{}:h,b=r.maskTextFn,T=r.maskInputFn,C=r.recordCanvas,w=r.keepIframeSrcFn;if(c.__sn){var x=c.__sn.id;a=1===x?void 0:x}switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:e.Document,childNodes:[],compatMode:t.compatMode,rootId:a}:{type:e.Document,childNodes:[],rootId:a};case t.DOCUMENT_TYPE_NODE:return{type:e.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:a};case t.ELEMENT_NODE:for(var S=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=0;n<e.classList.length;n++){var a=e.classList[n];if(t.test(a))return!0}return!!r&&e.matches(r)}(t,u,l),E=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return i.test(t)?"div":t}(t),N={},D=0,I=Array.from(t.attributes);D<I.length;D++){var _=I[D],L=_.name,O=_.value;N[L]=g(c,E,L,O)}if("link"===E&&d){var A,M=Array.from(c.styleSheets).find((function(e){return e.href===t.href}));(A=s(M))&&(delete N.rel,delete N.href,N._cssText=m(A,M.href))}if("style"===E&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(A=s(t.sheet))&&(N._cssText=m(A,v()));if("input"===E||"textarea"===E||"select"===E){O=t.value;"radio"!==N.type&&"checkbox"!==N.type&&"submit"!==N.type&&"button"!==N.type&&O?N.value=n({type:N.type,tagName:E,value:O,maskInputOptions:k,maskInputFn:T}):t.checked&&(N.checked=t.checked)}if("option"===E&&(t.selected?N.selected=!0:delete N.selected),"canvas"===E&&C&&(N.rr_dataURL=t.toDataURL()),"audio"!==E&&"video"!==E||(N.rr_mediaState=t.paused?"paused":"played",N.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(N.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(N.rr_scrollTop=t.scrollTop),S){var F=t.getBoundingClientRect(),R=F.width,W=F.height;N={class:N.class,rr_width:R+"px",rr_height:W+"px"}}return"iframe"!==E||w(N.src)||delete N.src,{type:e.Element,tagName:E,attributes:N,childNodes:[],isSVG:(o=t,"svg"===o.tagName||o instanceof SVGElement||void 0),needBlock:S,rootId:a};case t.TEXT_NODE:var P=t.parentNode&&t.parentNode.tagName,j=t.textContent,B="STYLE"===P||void 0,G="SCRIPT"===P||void 0;return B&&j&&(j=m(j,v())),G&&(j="SCRIPT_PLACEHOLDER"),!B&&!G&&y(t,f,p)&&j&&(j=b?b(j):j.replace(/[\S]/g,"*")),{type:e.Text,textContent:j||"",isStyle:B,rootId:a};case t.CDATA_SECTION_NODE:return{type:e.CDATA,textContent:"",rootId:a};case t.COMMENT_NODE:return{type:e.Comment,textContent:t.textContent||"",rootId:a};default:return!1}}function b(e){return void 0===e?"":e.toLowerCase()}function T(n,i){var o,s=i.doc,c=i.map,u=i.blockClass,l=i.blockSelector,f=i.maskTextClass,m=i.maskTextSelector,p=i.skipChild,d=void 0!==p&&p,h=i.inlineStylesheet,v=void 0===h||h,g=i.maskInputOptions,y=void 0===g?{}:g,C=i.maskTextFn,w=i.maskInputFn,x=i.slimDOMOptions,S=i.recordCanvas,E=void 0!==S&&S,N=i.onSerialize,D=i.onIframeLoad,I=i.iframeLoadTimeout,_=void 0===I?5e3:I,L=i.keepIframeSrcFn,O=void 0===L?function(){return!1}:L,A=i.preserveWhiteSpace,M=void 0===A||A,F=k(n,{doc:s,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:m,inlineStylesheet:v,maskInputOptions:y,maskTextFn:C,maskInputFn:w,recordCanvas:E,keepIframeSrcFn:O});if(!F)return console.warn(n,"not serialized"),null;o="__sn"in n?n.__sn.id:!function(t,r){if(r.comment&&t.type===e.Comment)return!0;if(t.type===e.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(b(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===b(t.attributes.name)||"icon"===b(t.attributes.rel)||"apple-touch-icon"===b(t.attributes.rel)||"shortcut icon"===b(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&b(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(b(t.attributes.property).match(/^(og|twitter|fb):/)||b(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===b(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===b(t.attributes.name)||"googlebot"===b(t.attributes.name)||"bingbot"===b(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===b(t.attributes.name)||"generator"===b(t.attributes.name)||"framework"===b(t.attributes.name)||"publisher"===b(t.attributes.name)||"progid"===b(t.attributes.name)||b(t.attributes.property).match(/^article:/)||b(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===b(t.attributes.name)||"yandex-verification"===b(t.attributes.name)||"csrf-token"===b(t.attributes.name)||"p:domain_verify"===b(t.attributes.name)||"verify-v1"===b(t.attributes.name)||"verification"===b(t.attributes.name)||"shopify-checkout-api-token"===b(t.attributes.name)))return!0}}return!1}(F,x)&&(M||F.type!==e.Text||F.isStyle||F.textContent.replace(/^\s+|\s+$/gm,"").length)?a++:-2;var R=Object.assign(F,{id:o});if(n.__sn=R,-2===o)return null;c[o]=n,N&&N(n);var W=!d;if(R.type===e.Element&&(W=W&&!R.needBlock,delete R.needBlock),(R.type===e.Document||R.type===e.Element)&&W){x.headWhitespace&&F.type===e.Element&&"head"===F.tagName&&(M=!1);for(var P={doc:s,map:c,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:m,skipChild:d,inlineStylesheet:v,maskInputOptions:y,maskTextFn:C,maskInputFn:w,slimDOMOptions:x,recordCanvas:E,preserveWhiteSpace:M,onSerialize:N,onIframeLoad:D,iframeLoadTimeout:_,keepIframeSrcFn:O},j=0,B=Array.from(n.childNodes);j<B.length;j++){(z=T(B[j],P))&&R.childNodes.push(z)}if(t(n)&&n.shadowRoot){R.isShadowHost=!0;for(var G=0,H=Array.from(n.shadowRoot.childNodes);G<H.length;G++){var z;(z=T(H[G],P))&&(z.isShadow=!0,R.childNodes.push(z))}}}return n.parentNode&&r(n.parentNode)&&(R.isShadow=!0),R.type===e.Element&&"iframe"===R.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a){var o="about:blank";n.location.href===o&&e.src!==o&&""!==e.src?e.addEventListener("load",t):setTimeout(t,0)}else{var s=setTimeout((function(){i||(t(),i=!0)}),r);e.addEventListener("load",(function(){clearTimeout(s),i=!0,t()}))}}}(n,(function(){var e=n.contentDocument;if(e&&D){var t=T(e,{doc:e,map:c,blockClass:u,blockSelector:l,maskTextClass:f,maskTextSelector:m,skipChild:!1,inlineStylesheet:v,maskInputOptions:y,maskTextFn:C,maskInputFn:w,slimDOMOptions:x,recordCanvas:E,preserveWhiteSpace:M,onSerialize:N,onIframeLoad:D,iframeLoadTimeout:_,keepIframeSrcFn:O});t&&D(n,t)}}),_),R}function C(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.blockSelector,o=void 0===i?null:i,s=r.maskTextClass,c=void 0===s?"rr-mask":s,u=r.maskTextSelector,l=void 0===u?null:u,f=r.inlineStylesheet,m=void 0===f||f,p=r.recordCanvas,d=void 0!==p&&p,h=r.maskAllInputs,v=void 0!==h&&h,g=r.maskTextFn,y=r.maskInputFn,k=r.slimDOM,b=void 0!==k&&k,C=r.preserveWhiteSpace,w=r.onSerialize,x=r.onIframeLoad,S=r.iframeLoadTimeout,E=r.keepIframeSrcFn,N={};return[T(e,{doc:e,map:N,blockClass:a,blockSelector:o,maskTextClass:c,maskTextSelector:l,skipChild:!1,inlineStylesheet:m,maskInputOptions:!0===v?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===v?{password:!0}:v,maskTextFn:g,maskInputFn:y,slimDOMOptions:!0===b||"all"===b?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===b,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===b?{}:b,recordCanvas:d,preserveWhiteSpace:C,onSerialize:w,onIframeLoad:x,iframeLoadTimeout:S,keepIframeSrcFn:void 0===E?function(){return!1}:E}),N]}function w(t,r){!function t(n){r(n),n.type!==e.Document&&n.type!==e.Element||n.childNodes.forEach(t)}(t)}function x(){a=1}var S=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function E(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function i(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(e){this.start=e,this.end={line:r,column:n},this.source=t.source};o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return m(/^{\s*/)}function l(){return m(/^}/)}function f(){var t,r=[];for(p(),d(r);e.length&&"}"!==e.charAt(0)&&(t=E()||I());)!1!==t&&(r.push(t),d(r));return r}function m(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function p(){m(/^\s*/)}function d(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=m(/^([^{]+)/);if(e)return N(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,(function(e){return e.replace(/,/g,"")})).split(/\s*(?![^(]*\)),\s*/).map((function(e){return e.replace(/\u200C/g,",")}))}function g(){var e=i(),t=m(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=N(t[0]);if(!m(/^:\s*/))return c("property missing ':'");var n=m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(S,""),value:n?N(n[0]).replace(S,""):""});return m(/^[;\s]*/),a}}function y(){var e,t=[];if(!u())return c("missing '{'");for(d(t);e=g();)!1!==e&&(t.push(e),d(t)),e=g();return l()?t:c("missing '}'")}function k(){for(var e,t=[],r=i();e=m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),m(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var b,T=x("import"),C=x("charset"),w=x("namespace");function x(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=m(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function E(){if("@"===e[0])return function(){var e=i(),t=m(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=m(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=d();n=k();)o.push(n),o=o.concat(d());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=m(/^@media *([^{]+)/);if(t){var r=N(t[1]);if(!u())return c("@media missing '{'");var n=d().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=i(),t=m(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:N(t[1]),media:N(t[2])})}()||function(){var e=i(),t=m(/^@supports *([^{]+)/);if(t){var r=N(t[1]);if(!u())return c("@supports missing '{'");var n=d().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||T()||C()||w()||function(){var e=i(),t=m(/^@([-\w]+)?document *([^{]+)/);if(t){var r=N(t[1]),n=N(t[2]);if(!u())return c("@document missing '{'");var a=d().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=i();if(m(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=d();r=g();)n.push(r),n=n.concat(d());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=i();if(m(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=d().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(m(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=d();t=g();)r.push(t),r=r.concat(d());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function I(){var e=i(),t=v();return t?(d(),e({type:"rule",selectors:t,declarations:y()})):c("selector missing")}return D((b=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:b,parsingErrors:s}}))}function N(e){return e?e.replace(/^\s+|\s+$/g,""):""}function D(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,a=0,i=Object.keys(e);a<i.length;a++){var o=e[i[a]];Array.isArray(o)?o.forEach((function(e){D(e,n)})):o&&"object"==typeof o&&D(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var I={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var _=/([^\\]):hover/,L=new RegExp(_,"g");function O(e,t){var r=null==t?void 0:t.stylesWithHoverClass.get(e);if(r)return r;var n=E(e,{silent:!0});if(!n.stylesheet)return e;var a=[];if(n.stylesheet.rules.forEach((function(e){"selectors"in e&&(e.selectors||[]).forEach((function(e){_.test(e)&&a.push(e)}))})),0===a.length)return e;var i=new RegExp(a.filter((function(e,t){return a.indexOf(e)===t})).sort((function(e,t){return t.length-e.length})).map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})).join("|"),"g"),o=e.replace(i,(function(e){var t=e.replace(L,"$1.\\:hover");return e+", "+t}));return null==t||t.stylesWithHoverClass.set(e,o),o}function A(){return{stylesWithHoverClass:new Map}}function M(t,r){var n=r.doc,a=r.hackCss,i=r.cache;switch(t.type){case e.Document:return n.implementation.createDocument(null,"",null);case e.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.Element:var o,s=function(e){var t=I[e.tagName]?I[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);o=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",s):n.createElement(s);var c=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if("option"===s&&"selected"===e&&!1===r)return"continue";if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===s&&"rr_dataURL"===e){var c=document.createElement("img");c.src=r,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}if("rr_width"===e&&(o.style.width=r),"rr_height"===e&&(o.style.height=r),"rr_mediaCurrentTime"===e&&(o.currentTime=t.attributes.rr_mediaCurrentTime),"rr_mediaState"===e)switch(r){case"played":o.play().catch((function(e){return console.warn("media playback error",e)}));break;case"paused":o.pause()}}else{var u="textarea"===s&&"value"===e,l="style"===s&&"_cssText"===e;if(l&&a&&(r=O(r,i)),u||l){for(var f=n.createTextNode(r),m=0,p=Array.from(o.childNodes);m<p.length;m++){var d=p[m];d.nodeType===o.TEXT_NODE&&o.removeChild(d)}return o.appendChild(f),"continue"}try{if(t.isSVG&&"xlink:href"===e)o.setAttributeNS("http://www.w3.org/1999/xlink",e,r);else if("onload"===e||"onclick"===e||"onmouse"===e.substring(0,7))o.setAttribute("_"+e,r);else{if("meta"===s&&"Content-Security-Policy"===t.attributes["http-equiv"]&&"content"===e)return o.setAttribute("csp-content",r),"continue";"link"===s&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===s&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")||o.setAttribute(e,r)}}catch(e){}}};for(var u in t.attributes)c(u);if(t.isShadowHost)if(o.shadowRoot)for(;o.shadowRoot.firstChild;)o.shadowRoot.removeChild(o.shadowRoot.firstChild);else o.attachShadow({mode:"open"});return o;case e.Text:return n.createTextNode(t.isStyle&&a?O(t.textContent,i):t.textContent);case e.CDATA:return n.createCDATASection(t.textContent);case e.Comment:return n.createComment(t.textContent);default:return null}}function F(r,n){var a=n.doc,i=n.map,o=n.skipChild,s=void 0!==o&&o,c=n.hackCss,u=void 0===c||c,l=n.afterAppend,f=n.cache,m=M(r,{doc:a,hackCss:u,cache:f});if(!m)return null;if(r.rootId&&console.assert(i[r.rootId]===a,"Target document should has the same root id."),r.type===e.Document&&(a.close(),a.open(),"BackCompat"===r.compatMode&&r.childNodes&&r.childNodes[0].type!==e.DocumentType&&(r.childNodes[0].type===e.Element&&"xmlns"in r.childNodes[0].attributes&&"http://www.w3.org/1999/xhtml"===r.childNodes[0].attributes.xmlns?a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):a.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),m=a),m.__sn=r,i[r.id]=m,(r.type===e.Document||r.type===e.Element)&&!s)for(var p=0,d=r.childNodes;p<d.length;p++){var h=d[p],v=F(h,{doc:a,map:i,skipChild:!1,hackCss:u,afterAppend:l,cache:f});v?(h.isShadow&&t(m)&&m.shadowRoot?m.shadowRoot.appendChild(v):m.appendChild(v),l&&l(v)):console.warn("Failed to rebuild",h)}return m}function R(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=F(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend,cache:r.cache});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,(function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)})),[s,o]}export{o as IGNORED_NODE,e as NodeType,O as addHoverClass,F as buildNodeWithSN,x as cleanupSnapshot,A as createCache,t as isElement,r as isShadowRoot,n as maskInputValue,y as needMaskingText,R as rebuild,T as serializeNodeWithId,C as snapshot,g as transformAttribute,w as visitSnapshot}; | ||
//# sourceMappingURL=rrweb-snapshot.min.js.map |
@@ -5,2 +5,3 @@ 'use strict'; | ||
exports.NodeType = void 0; | ||
(function (NodeType) { | ||
@@ -64,5 +65,10 @@ NodeType[NodeType["Document"] = 0] = "Document"; | ||
function getCssRuleString(rule) { | ||
return isCSSImportRule(rule) | ||
? getCssRulesString(rule.styleSheet) || '' | ||
: rule.cssText; | ||
var cssStringified = rule.cssText; | ||
if (isCSSImportRule(rule)) { | ||
try { | ||
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified; | ||
} | ||
catch (_a) { } | ||
} | ||
return cssStringified; | ||
} | ||
@@ -307,7 +313,17 @@ function isCSSImportRule(rule) { | ||
case n.DOCUMENT_NODE: | ||
return { | ||
type: exports.NodeType.Document, | ||
childNodes: [], | ||
rootId: rootId, | ||
}; | ||
if (n.compatMode !== 'CSS1Compat') { | ||
return { | ||
type: exports.NodeType.Document, | ||
childNodes: [], | ||
compatMode: n.compatMode, | ||
rootId: rootId | ||
}; | ||
} | ||
else { | ||
return { | ||
type: exports.NodeType.Document, | ||
childNodes: [], | ||
rootId: rootId | ||
}; | ||
} | ||
case n.DOCUMENT_TYPE_NODE: | ||
@@ -319,3 +335,3 @@ return { | ||
systemId: n.systemId, | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -325,6 +341,6 @@ case n.ELEMENT_NODE: | ||
var tagName = getValidTagName(n); | ||
var attributes_1 = {}; | ||
var attributes = {}; | ||
for (var _i = 0, _b = Array.from(n.attributes); _i < _b.length; _i++) { | ||
var _c = _b[_i], name = _c.name, value = _c.value; | ||
attributes_1[name] = transformAttribute(doc, tagName, name, value); | ||
var _c = _b[_i], name_1 = _c.name, value = _c.value; | ||
attributes[name_1] = transformAttribute(doc, tagName, name_1, value); | ||
} | ||
@@ -337,5 +353,5 @@ if (tagName === 'link' && inlineStylesheet) { | ||
if (cssText) { | ||
delete attributes_1.rel; | ||
delete attributes_1.href; | ||
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
delete attributes.rel; | ||
delete attributes.href; | ||
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href); | ||
} | ||
@@ -350,3 +366,3 @@ } | ||
if (cssText) { | ||
attributes_1._cssText = absoluteToStylesheet(cssText, getHref()); | ||
attributes._cssText = absoluteToStylesheet(cssText, getHref()); | ||
} | ||
@@ -358,17 +374,17 @@ } | ||
var value = n.value; | ||
if (attributes_1.type !== 'radio' && | ||
attributes_1.type !== 'checkbox' && | ||
attributes_1.type !== 'submit' && | ||
attributes_1.type !== 'button' && | ||
if (attributes.type !== 'radio' && | ||
attributes.type !== 'checkbox' && | ||
attributes.type !== 'submit' && | ||
attributes.type !== 'button' && | ||
value) { | ||
attributes_1.value = maskInputValue({ | ||
type: attributes_1.type, | ||
attributes.value = maskInputValue({ | ||
type: attributes.type, | ||
tagName: tagName, | ||
value: value, | ||
maskInputOptions: maskInputOptions, | ||
maskInputFn: maskInputFn, | ||
maskInputFn: maskInputFn | ||
}); | ||
} | ||
else if (n.checked) { | ||
attributes_1.checked = n.checked; | ||
attributes.checked = n.checked; | ||
} | ||
@@ -378,33 +394,33 @@ } | ||
if (n.selected) { | ||
attributes_1.selected = true; | ||
attributes.selected = true; | ||
} | ||
else { | ||
delete attributes_1.selected; | ||
delete attributes.selected; | ||
} | ||
} | ||
if (tagName === 'canvas' && recordCanvas) { | ||
attributes_1.rr_dataURL = n.toDataURL(); | ||
attributes.rr_dataURL = n.toDataURL(); | ||
} | ||
if (tagName === 'audio' || tagName === 'video') { | ||
attributes_1.rr_mediaState = n.paused | ||
attributes.rr_mediaState = n.paused | ||
? 'paused' | ||
: 'played'; | ||
attributes_1.rr_mediaCurrentTime = n.currentTime; | ||
attributes.rr_mediaCurrentTime = n.currentTime; | ||
} | ||
if (n.scrollLeft) { | ||
attributes_1.rr_scrollLeft = n.scrollLeft; | ||
attributes.rr_scrollLeft = n.scrollLeft; | ||
} | ||
if (n.scrollTop) { | ||
attributes_1.rr_scrollTop = n.scrollTop; | ||
attributes.rr_scrollTop = n.scrollTop; | ||
} | ||
if (needBlock) { | ||
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height; | ||
attributes_1 = { | ||
class: attributes_1.class, | ||
attributes = { | ||
"class": attributes["class"], | ||
rr_width: width + "px", | ||
rr_height: height + "px", | ||
rr_height: height + "px" | ||
}; | ||
} | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes_1.src)) { | ||
delete attributes_1.src; | ||
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) { | ||
delete attributes.src; | ||
} | ||
@@ -414,7 +430,7 @@ return { | ||
tagName: tagName, | ||
attributes: attributes_1, | ||
attributes: attributes, | ||
childNodes: [], | ||
isSVG: isSVGElement(n) || undefined, | ||
needBlock: needBlock, | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -444,3 +460,3 @@ case n.TEXT_NODE: | ||
isStyle: isStyle, | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -451,3 +467,3 @@ case n.CDATA_SECTION_NODE: | ||
textContent: '', | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -458,3 +474,3 @@ case n.COMMENT_NODE: | ||
textContent: n.textContent || '', | ||
rootId: rootId, | ||
rootId: rootId | ||
}; | ||
@@ -558,3 +574,3 @@ default: | ||
recordCanvas: recordCanvas, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}); | ||
@@ -619,3 +635,3 @@ if (!_serializedNode) { | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}; | ||
@@ -667,3 +683,3 @@ for (var _i = 0, _h = Array.from(n.childNodes); _i < _h.length; _i++) { | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}); | ||
@@ -698,7 +714,7 @@ if (serializedIframeNode) { | ||
select: true, | ||
password: true, | ||
password: true | ||
} | ||
: maskAllInputs === false | ||
? { | ||
password: true, | ||
password: true | ||
} | ||
@@ -718,3 +734,3 @@ : maskAllInputs; | ||
headMetaAuthorship: true, | ||
headMetaVerification: true, | ||
headMetaVerification: true | ||
} | ||
@@ -743,3 +759,3 @@ : slimDOM === false | ||
iframeLoadTimeout: iframeLoadTimeout, | ||
keepIframeSrcFn: keepIframeSrcFn, | ||
keepIframeSrcFn: keepIframeSrcFn | ||
}), | ||
@@ -815,4 +831,4 @@ idNodeMap, | ||
rules: rulesList, | ||
parsingErrors: errorsList, | ||
}, | ||
parsingErrors: errorsList | ||
} | ||
}; | ||
@@ -884,3 +900,3 @@ } | ||
type: 'comment', | ||
comment: str, | ||
comment: str | ||
}); | ||
@@ -917,3 +933,3 @@ } | ||
property: prop.replace(commentre, ''), | ||
value: val ? trim(val[0]).replace(commentre, '') : '', | ||
value: val ? trim(val[0]).replace(commentre, '') : '' | ||
}); | ||
@@ -956,3 +972,3 @@ match(/^[;\s]*/); | ||
values: vals, | ||
declarations: declarations(), | ||
declarations: declarations() | ||
}); | ||
@@ -988,3 +1004,3 @@ } | ||
vendor: vendor, | ||
keyframes: frames, | ||
keyframes: frames | ||
}); | ||
@@ -1009,3 +1025,3 @@ } | ||
supports: supports, | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1028,3 +1044,3 @@ } | ||
type: 'host', | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1049,3 +1065,3 @@ } | ||
media: media, | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1062,3 +1078,3 @@ } | ||
name: trim(m[1]), | ||
media: trim(m[2]), | ||
media: trim(m[2]) | ||
}); | ||
@@ -1088,3 +1104,3 @@ } | ||
selectors: sel, | ||
declarations: decls, | ||
declarations: decls | ||
}); | ||
@@ -1111,3 +1127,3 @@ } | ||
vendor: vendor, | ||
rules: style, | ||
rules: style | ||
}); | ||
@@ -1135,3 +1151,3 @@ } | ||
type: 'font-face', | ||
declarations: decls, | ||
declarations: decls | ||
}); | ||
@@ -1181,3 +1197,3 @@ } | ||
selectors: sel, | ||
declarations: declarations(), | ||
declarations: declarations() | ||
}); | ||
@@ -1210,3 +1226,3 @@ } | ||
enumerable: false, | ||
value: parent || null, | ||
value: parent || null | ||
}); | ||
@@ -1254,3 +1270,3 @@ } | ||
lineargradient: 'linearGradient', | ||
radialgradient: 'radialGradient', | ||
radialgradient: 'radialGradient' | ||
}; | ||
@@ -1274,3 +1290,3 @@ function getTagName(n) { | ||
var ast = parse(cssText, { | ||
silent: true, | ||
silent: true | ||
}); | ||
@@ -1310,3 +1326,3 @@ if (!ast.stylesheet) { | ||
return { | ||
stylesWithHoverClass: stylesWithHoverClass, | ||
stylesWithHoverClass: stylesWithHoverClass | ||
}; | ||
@@ -1330,8 +1346,8 @@ } | ||
} | ||
var _loop_1 = function (name) { | ||
if (!n.attributes.hasOwnProperty(name)) { | ||
var _loop_1 = function (name_1) { | ||
if (!n.attributes.hasOwnProperty(name_1)) { | ||
return "continue"; | ||
} | ||
var value = n.attributes[name]; | ||
if (tagName === 'option' && name === 'selected' && value === false) { | ||
var value = n.attributes[name_1]; | ||
if (tagName === 'option' && name_1 === 'selected' && value === false) { | ||
return "continue"; | ||
@@ -1341,5 +1357,5 @@ } | ||
typeof value === 'boolean' || typeof value === 'number' ? '' : value; | ||
if (!name.startsWith('rr_')) { | ||
var isTextarea = tagName === 'textarea' && name === 'value'; | ||
var isRemoteOrDynamicCss = tagName === 'style' && name === '_cssText'; | ||
if (!name_1.startsWith('rr_')) { | ||
var isTextarea = tagName === 'textarea' && name_1 === 'value'; | ||
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText'; | ||
if (isRemoteOrDynamicCss && hackCss) { | ||
@@ -1360,13 +1376,13 @@ value = addHoverClass(value, cache); | ||
try { | ||
if (n.isSVG && name === 'xlink:href') { | ||
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name, value); | ||
if (n.isSVG && name_1 === 'xlink:href') { | ||
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value); | ||
} | ||
else if (name === 'onload' || | ||
name === 'onclick' || | ||
name.substring(0, 7) === 'onmouse') { | ||
node_1.setAttribute('_' + name, value); | ||
else if (name_1 === 'onload' || | ||
name_1 === 'onclick' || | ||
name_1.substring(0, 7) === 'onmouse') { | ||
node_1.setAttribute('_' + name_1, value); | ||
} | ||
else if (tagName === 'meta' && | ||
n.attributes['http-equiv'] === 'Content-Security-Policy' && | ||
name === 'content') { | ||
name_1 === 'content') { | ||
node_1.setAttribute('csp-content', value); | ||
@@ -1377,9 +1393,11 @@ return "continue"; | ||
n.attributes.rel === 'preload' && | ||
n.attributes.as === 'script') ; | ||
n.attributes.as === 'script') { | ||
} | ||
else if (tagName === 'link' && | ||
n.attributes.rel === 'prefetch' && | ||
typeof n.attributes.href === 'string' && | ||
n.attributes.href.endsWith('.js')) ; | ||
n.attributes.href.endsWith('.js')) { | ||
} | ||
else { | ||
node_1.setAttribute(name, value); | ||
node_1.setAttribute(name_1, value); | ||
} | ||
@@ -1391,3 +1409,3 @@ } | ||
else { | ||
if (tagName === 'canvas' && name === 'rr_dataURL') { | ||
if (tagName === 'canvas' && name_1 === 'rr_dataURL') { | ||
var image_1 = document.createElement('img'); | ||
@@ -1402,18 +1420,17 @@ image_1.src = value; | ||
} | ||
if (name === 'rr_width') { | ||
if (name_1 === 'rr_width') { | ||
node_1.style.width = value; | ||
} | ||
if (name === 'rr_height') { | ||
if (name_1 === 'rr_height') { | ||
node_1.style.height = value; | ||
} | ||
if (name === 'rr_mediaCurrentTime') { | ||
if (name_1 === 'rr_mediaCurrentTime') { | ||
node_1.currentTime = n.attributes | ||
.rr_mediaCurrentTime; | ||
} | ||
if (name === 'rr_mediaState') { | ||
if (name_1 === 'rr_mediaState') { | ||
switch (value) { | ||
case 'played': | ||
node_1 | ||
.play() | ||
.catch(function (e) { return console.warn('media playback error', e); }); | ||
.play()["catch"](function (e) { return console.warn('media playback error', e); }); | ||
break; | ||
@@ -1423,3 +1440,2 @@ case 'paused': | ||
break; | ||
default: | ||
} | ||
@@ -1429,4 +1445,4 @@ } | ||
}; | ||
for (var name in n.attributes) { | ||
_loop_1(name); | ||
for (var name_1 in n.attributes) { | ||
_loop_1(name_1); | ||
} | ||
@@ -1468,2 +1484,13 @@ if (n.isShadowHost) { | ||
doc.open(); | ||
if (n.compatMode === 'BackCompat' && | ||
(n.childNodes && n.childNodes[0].type !== exports.NodeType.DocumentType)) { | ||
if (n.childNodes[0].type === exports.NodeType.Element && | ||
'xmlns' in n.childNodes[0].attributes && | ||
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') { | ||
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'); | ||
} | ||
else { | ||
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'); | ||
} | ||
} | ||
node = doc; | ||
@@ -1483,3 +1510,3 @@ } | ||
afterAppend: afterAppend, | ||
cache: cache, | ||
cache: cache | ||
}); | ||
@@ -1519,11 +1546,11 @@ if (!childNode) { | ||
var el = node; | ||
for (var name in n.attributes) { | ||
if (!(n.attributes.hasOwnProperty(name) && name.startsWith('rr_'))) { | ||
for (var name_2 in n.attributes) { | ||
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) { | ||
continue; | ||
} | ||
var value = n.attributes[name]; | ||
if (name === 'rr_scrollLeft') { | ||
var value = n.attributes[name_2]; | ||
if (name_2 === 'rr_scrollLeft') { | ||
el.scrollLeft = value; | ||
} | ||
if (name === 'rr_scrollTop') { | ||
if (name_2 === 'rr_scrollTop') { | ||
el.scrollTop = value; | ||
@@ -1542,3 +1569,3 @@ } | ||
afterAppend: afterAppend, | ||
cache: cache, | ||
cache: cache | ||
}); | ||
@@ -1554,15 +1581,15 @@ visit(idNodeMap, function (visitedNode) { | ||
exports.snapshot = snapshot; | ||
exports.serializeNodeWithId = serializeNodeWithId; | ||
exports.rebuild = rebuild; | ||
exports.IGNORED_NODE = IGNORED_NODE; | ||
exports.addHoverClass = addHoverClass; | ||
exports.buildNodeWithSN = buildNodeWithSN; | ||
exports.addHoverClass = addHoverClass; | ||
exports.cleanupSnapshot = cleanupSnapshot; | ||
exports.createCache = createCache; | ||
exports.transformAttribute = transformAttribute; | ||
exports.visitSnapshot = visitSnapshot; | ||
exports.cleanupSnapshot = cleanupSnapshot; | ||
exports.needMaskingText = needMaskingText; | ||
exports.IGNORED_NODE = IGNORED_NODE; | ||
exports.isElement = isElement; | ||
exports.isShadowRoot = isShadowRoot; | ||
exports.maskInputValue = maskInputValue; | ||
exports.needMaskingText = needMaskingText; | ||
exports.rebuild = rebuild; | ||
exports.serializeNodeWithId = serializeNodeWithId; | ||
exports.snapshot = snapshot; | ||
exports.transformAttribute = transformAttribute; | ||
exports.visitSnapshot = visitSnapshot; |
{ | ||
"name": "rrweb-snapshot", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer", | ||
@@ -8,3 +8,3 @@ "scripts": { | ||
"prepack": "npm run bundle && npm run typings", | ||
"test": "cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.ts", | ||
"test": "jest", | ||
"bundle": "rollup --config", | ||
@@ -41,21 +41,22 @@ "bundle:es-only": "cross-env ES_ONLY=true rollup --config", | ||
"devDependencies": { | ||
"@rollup/plugin-typescript": "^8.2.5", | ||
"@types/chai": "^4.1.4", | ||
"@types/jest": "^27.0.2", | ||
"@types/jsdom": "^16.2.4", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.11.3", | ||
"@types/puppeteer": "^1.12.4", | ||
"chai": "^4.1.2", | ||
"cross-env": "^5.2.0", | ||
"jest": "^27.2.4", | ||
"jest-snapshot": "^23.6.0", | ||
"jsdom": "^16.4.0", | ||
"mocha": "^5.2.0", | ||
"puppeteer": "^1.15.0", | ||
"rollup": "^0.66.4", | ||
"rollup-plugin-terser": "^3.0.0", | ||
"rollup-plugin-typescript": "^1.0.0", | ||
"rollup": "^2.45.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^27.0.5", | ||
"ts-node": "^7.0.1", | ||
"tslib": "^1.9.3", | ||
"tslint": "^4.5.1", | ||
"typescript": "^3.4.1" | ||
} | ||
"typescript": "^3.9.7" | ||
}, | ||
"gitHead": "cabd5eb157175dbb6c9fc4e0b60e82cb246f7d3f" | ||
} |
@@ -12,2 +12,3 @@ export declare enum NodeType { | ||
childNodes: serializedNodeWithId[]; | ||
compatMode?: string; | ||
}; | ||
@@ -14,0 +15,0 @@ export declare type documentTypeNode = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
406147
16
5054