@coralogix/browser
Version:
Official Coralogix SDK for browsers
1,346 lines (1,341 loc) • 70.6 kB
JavaScript
import { __awaiter, __generator, __assign } from 'tslib';
import { C as CxGlobal, r as reportInternalEvent, g as getSdkConfig, S as SESSION_RECORDER_SEGMENTS_MAP, a as getNowTime, b as SESSION_RECORDING_NETWORK_ERR0R_MESSAGE, M as MAX_BATCH_TIME_MS, R as Request, c as SESSION_RECORDING_DEFAULT_HEADERS, d as SESSION_RECORDING_POSTFIX_URL, B as BATCH_TIME_DELAY, e as SESSION_RECORDER_KEY, f as MAX_MUTATIONS_FOR_SESSION_RECORDING, h as SESSION_RECORDING_DEFAULT_ERROR_MESSAGE } from './index.esm2.js';
import { record } from 'rrweb';
import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
import '@opentelemetry/sdk-trace-base';
import '@opentelemetry/sdk-trace-web';
import '@opentelemetry/instrumentation';
import 'error-stack-parser';
import '@opentelemetry/instrumentation-fetch';
import '@opentelemetry/instrumentation-xml-http-request';
import 'web-vitals/attribution';
import '@opentelemetry/api';
import '@opentelemetry/propagator-b3';
import '@opentelemetry/propagator-aws-xray';
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _classCallCheck(a, n) {
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
}
}
function _createClass(e, r, t) {
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
writable: false
}), e;
}
function _createForOfIteratorHelper(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (!t) {
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
t && (r = t);
var n = 0,
F = function () {};
return {
s: F,
n: function () {
return n >= r.length ? {
done: true
} : {
done: false,
value: r[n++]
};
},
e: function (r) {
throw r;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var o,
a = true,
u = false;
return {
s: function () {
t = t.call(r);
},
n: function () {
var r = t.next();
return a = r.done, r;
},
e: function (r) {
u = true, o = r;
},
f: function () {
try {
a || null == t.return || t.return();
} finally {
if (u) throw o;
}
}
};
}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r);
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (String )(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
var EventType = function (EventType2) {
EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
EventType2[EventType2["Load"] = 1] = "Load";
EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
EventType2[EventType2["Meta"] = 4] = "Meta";
EventType2[EventType2["Custom"] = 5] = "Custom";
EventType2[EventType2["Plugin"] = 6] = "Plugin";
return EventType2;
}(EventType || {});
var IncrementalSource = function (IncrementalSource2) {
IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
return IncrementalSource2;
}(IncrementalSource || {});
var MouseInteractions = function (MouseInteractions2) {
MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
return MouseInteractions2;
}(MouseInteractions || {});
var PointerTypes = function (PointerTypes2) {
PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
return PointerTypes2;
}(PointerTypes || {});
var CanvasContext = function (CanvasContext2) {
CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
return CanvasContext2;
}(CanvasContext || {});
var MediaInteractions = function (MediaInteractions2) {
MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
return MediaInteractions2;
}(MediaInteractions || {});
var ReplayerEvents = function (ReplayerEvents2) {
ReplayerEvents2["Start"] = "start";
ReplayerEvents2["Pause"] = "pause";
ReplayerEvents2["Resume"] = "resume";
ReplayerEvents2["Resize"] = "resize";
ReplayerEvents2["Finish"] = "finish";
ReplayerEvents2["FullsnapshotRebuilded"] = "fullsnapshot-rebuilded";
ReplayerEvents2["LoadStylesheetStart"] = "load-stylesheet-start";
ReplayerEvents2["LoadStylesheetEnd"] = "load-stylesheet-end";
ReplayerEvents2["SkipStart"] = "skip-start";
ReplayerEvents2["SkipEnd"] = "skip-end";
ReplayerEvents2["MouseInteraction"] = "mouse-interaction";
ReplayerEvents2["EventCast"] = "event-cast";
ReplayerEvents2["CustomEvent"] = "custom-event";
ReplayerEvents2["Flush"] = "flush";
ReplayerEvents2["StateChange"] = "state-change";
ReplayerEvents2["PlayBack"] = "play-back";
ReplayerEvents2["Destroy"] = "destroy";
return ReplayerEvents2;
}(ReplayerEvents || {});
var __defProp = Object.defineProperty;
var __defNormalProp = function __defNormalProp(obj, key, value) {
return key in obj ? __defProp(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value: value
}) : obj[key] = value;
};
var __publicField = function __publicField(obj, key, value) {
__defNormalProp(obj, _typeof(key) !== "symbol" ? key + "" : key, value);
return value;
};
var NodeType = function (NodeType2) {
NodeType2[NodeType2["Document"] = 0] = "Document";
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
NodeType2[NodeType2["Element"] = 2] = "Element";
NodeType2[NodeType2["Text"] = 3] = "Text";
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
NodeType2[NodeType2["Comment"] = 5] = "Comment";
return NodeType2;
}(NodeType || {});
function isElement(n) {
return n.nodeType === n.ELEMENT_NODE;
}
function isShadowRoot(n) {
var host = n == null ? void 0 : n.host;
return Boolean((host == null ? void 0 : host.shadowRoot) === n);
}
function isNativeShadowDom(shadowRoot) {
return Object.prototype.toString.call(shadowRoot) === "[object ShadowRoot]";
}
function fixBrowserCompatibilityIssuesInCSS(cssText) {
if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
}
return cssText;
}
function escapeImportStatement(rule) {
var cssText = rule.cssText;
if (cssText.split('"').length < 3) return cssText;
var statement = ["@import", "url(".concat(JSON.stringify(rule.href), ")")];
if (rule.layerName === "") {
statement.push("layer");
} else if (rule.layerName) {
statement.push("layer(".concat(rule.layerName, ")"));
}
if (rule.supportsText) {
statement.push("supports(".concat(rule.supportsText, ")"));
}
if (rule.media.length) {
statement.push(rule.media.mediaText);
}
return statement.join(" ") + ";";
}
function stringifyStylesheet(s) {
try {
var rules = s.rules || s.cssRules;
return rules ? fixBrowserCompatibilityIssuesInCSS(Array.from(rules, stringifyRule).join("")) : null;
} catch (error) {
return null;
}
}
function stringifyRule(rule) {
var importStringified;
if (isCSSImportRule(rule)) {
try {
importStringified = stringifyStylesheet(rule.styleSheet) || escapeImportStatement(rule);
} catch (error) {}
} else if (isCSSStyleRule(rule) && rule.selectorText.includes(":")) {
return fixSafariColons(rule.cssText);
}
return importStringified || rule.cssText;
}
function fixSafariColons(cssStringified) {
var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
return cssStringified.replace(regex, "$1\\$2");
}
function isCSSImportRule(rule) {
return "styleSheet" in rule;
}
function isCSSStyleRule(rule) {
return "selectorText" in rule;
}
var Mirror = function () {
function Mirror() {
_classCallCheck(this, Mirror);
__publicField(this, "idNodeMap", new Map());
__publicField(this, "nodeMetaMap", new WeakMap());
}
return _createClass(Mirror, [{
key: "getId",
value: function getId(n) {
var _a;
if (!n) return -1;
var id = (_a = this.getMeta(n)) == null ? void 0 : _a.id;
return id !== null && id !== void 0 ? id : -1;
}
}, {
key: "getNode",
value: function getNode(id) {
return this.idNodeMap.get(id) || null;
}
}, {
key: "getIds",
value: function getIds() {
return Array.from(this.idNodeMap.keys());
}
}, {
key: "getMeta",
value: function getMeta(n) {
return this.nodeMetaMap.get(n) || null;
}
}, {
key: "removeNodeFromMap",
value: function removeNodeFromMap(n) {
var _this = this;
var id = this.getId(n);
this.idNodeMap["delete"](id);
if (n.childNodes) {
n.childNodes.forEach(function (childNode) {
return _this.removeNodeFromMap(childNode);
});
}
}
}, {
key: "has",
value: function has(id) {
return this.idNodeMap.has(id);
}
}, {
key: "hasNode",
value: function hasNode(node) {
return this.nodeMetaMap.has(node);
}
}, {
key: "add",
value: function add(n, meta) {
var id = meta.id;
this.idNodeMap.set(id, n);
this.nodeMetaMap.set(n, meta);
}
}, {
key: "replace",
value: function replace(id, n) {
var oldNode = this.getNode(id);
if (oldNode) {
var meta = this.nodeMetaMap.get(oldNode);
if (meta) this.nodeMetaMap.set(n, meta);
}
this.idNodeMap.set(id, n);
}
}, {
key: "reset",
value: function reset() {
this.idNodeMap = new Map();
this.nodeMetaMap = new WeakMap();
}
}]);
}();
function maskInputValue(_ref) {
var element = _ref.element,
maskInputOptions = _ref.maskInputOptions,
tagName = _ref.tagName,
type = _ref.type,
value = _ref.value,
maskInputFn = _ref.maskInputFn;
var text = value || "";
var actualType = type && toLowerCase(type);
if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
if (maskInputFn) {
text = maskInputFn(text, element);
} else {
text = "*".repeat(text.length);
}
}
return text;
}
function toLowerCase(str) {
return str.toLowerCase();
}
var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
function is2DCanvasBlank(canvas) {
var ctx = canvas.getContext("2d");
if (!ctx) return true;
var chunkSize = 50;
for (var x = 0; x < canvas.width; x += chunkSize) {
for (var y = 0; y < canvas.height; y += chunkSize) {
var getImageData = ctx.getImageData;
var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
if (pixelBuffer.some(function (pixel) {
return pixel !== 0;
})) return false;
}
}
return true;
}
function getInputType(element) {
var type = element.type;
return element.hasAttribute("data-rr-is-password") ? "password" : type ? toLowerCase(type) : null;
}
function extractFileExtension(path, baseURL) {
var _ref2;
var url;
try {
url = new URL(path, baseURL !== null && baseURL !== void 0 ? baseURL : window.location.href);
} catch (err) {
return null;
}
var regex = /\.([0-9a-z]+)(?:$)/i;
var match = url.pathname.match(regex);
return (_ref2 = match == null ? void 0 : match[1]) !== null && _ref2 !== void 0 ? _ref2 : null;
}
var _id = 1;
var tagNameRegex = new RegExp("[^a-z0-9-_:]");
var IGNORED_NODE = -2;
function genId() {
return _id++;
}
function getValidTagName(element) {
if (element instanceof HTMLFormElement) {
return "form";
}
var processedTagName = toLowerCase(element.tagName);
if (tagNameRegex.test(processedTagName)) {
return "div";
}
return processedTagName;
}
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 canvasService;
var canvasCtx;
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
var URL_WWW_MATCH = /^www\..*/i;
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 (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
return "url(".concat(maybeQuote).concat(filePath).concat(maybeQuote, ")");
}
if (DATA_URI.test(filePath)) {
return "url(".concat(maybeQuote).concat(filePath).concat(maybeQuote, ")");
}
if (filePath[0] === "/") {
return "url(".concat(maybeQuote).concat(extractOrigin(href) + filePath).concat(maybeQuote, ")");
}
var stack = href.split("/");
var parts = filePath.split("/");
stack.pop();
var _iterator = _createForOfIteratorHelper(parts),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var part = _step.value;
if (part === ".") {
continue;
} else if (part === "..") {
stack.pop();
} else {
stack.push(part);
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return "url(".concat(maybeQuote).concat(stack.join("/")).concat(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;
var 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(", ");
}
var cachedDocument = new WeakMap();
function absoluteToDoc(doc, attributeValue) {
if (!attributeValue || attributeValue.trim() === "") {
return attributeValue;
}
return getHref(doc, attributeValue);
}
function isSVGElement(el) {
return Boolean(el.tagName === "svg" || el.ownerSVGElement);
}
function getHref(doc, customHref) {
var a = cachedDocument.get(doc);
if (!a) {
a = doc.createElement("a");
cachedDocument.set(doc, a);
}
if (!customHref) {
customHref = "";
} else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
return customHref;
}
a.setAttribute("href", customHref);
return a.href;
}
function transformAttribute(doc, tagName, name, value) {
if (!value) {
return value;
}
if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
return absoluteToDoc(doc, value);
} else if (name === "xlink:href" && value[0] !== "#") {
return absoluteToDoc(doc, value);
} else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
return absoluteToDoc(doc, value);
} else if (name === "srcset") {
return getAbsoluteSrcsetString(doc, value);
} else if (name === "style") {
return absoluteToStylesheet(value, getHref(doc));
} else if (tagName === "object" && name === "data") {
return absoluteToDoc(doc, value);
}
return value;
}
function ignoreAttribute(tagName, name, _value) {
return (tagName === "video" || tagName === "audio") && name === "autoplay";
}
function _isBlockedElement(element, blockClass, blockSelector) {
try {
if (typeof blockClass === "string") {
if (element.classList.contains(blockClass)) {
return true;
}
} else {
for (var eIndex = element.classList.length; eIndex--;) {
var className = element.classList[eIndex];
if (blockClass.test(className)) {
return true;
}
}
}
if (blockSelector) {
return element.matches(blockSelector);
}
} catch (e) {}
return false;
}
function classMatchesRegex(node, regex, checkAncestors) {
if (!node) return false;
if (node.nodeType !== node.ELEMENT_NODE) {
if (!checkAncestors) return false;
return classMatchesRegex(node.parentNode, regex, checkAncestors);
}
for (var eIndex = node.classList.length; eIndex--;) {
var className = node.classList[eIndex];
if (regex.test(className)) {
return true;
}
}
if (!checkAncestors) return false;
return classMatchesRegex(node.parentNode, regex, checkAncestors);
}
function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
try {
var el = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement;
if (el === null) return false;
if (typeof maskTextClass === "string") {
if (checkAncestors) {
if (el.closest(".".concat(maskTextClass))) return true;
} else {
if (el.classList.contains(maskTextClass)) return true;
}
} else {
if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
}
if (maskTextSelector) {
if (checkAncestors) {
if (el.closest(maskTextSelector)) return true;
} else {
if (el.matches(maskTextSelector)) return true;
}
}
} catch (e) {}
return false;
}
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 = setTimeout(function () {
if (!fired) {
listener();
fired = true;
}
}, iframeLoadTimeout);
iframeEl.addEventListener("load", function () {
clearTimeout(timer);
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);
}
iframeEl.addEventListener("load", listener);
}
function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
var fired = false;
var styleSheetLoaded;
try {
styleSheetLoaded = link.sheet;
} catch (error) {
return;
}
if (styleSheetLoaded) return;
var timer = setTimeout(function () {
if (!fired) {
listener();
fired = true;
}
}, styleSheetLoadTimeout);
link.addEventListener("load", function () {
clearTimeout(timer);
fired = true;
listener();
});
}
function serializeNode(n, options) {
var doc = options.doc,
mirror = options.mirror,
blockClass = options.blockClass,
blockSelector = options.blockSelector,
needsMask = options.needsMask,
inlineStylesheet = options.inlineStylesheet,
_options$maskInputOpt = options.maskInputOptions,
maskInputOptions = _options$maskInputOpt === void 0 ? {} : _options$maskInputOpt,
maskTextFn = options.maskTextFn,
maskInputFn = options.maskInputFn,
_options$dataURLOptio = options.dataURLOptions,
dataURLOptions = _options$dataURLOptio === void 0 ? {} : _options$dataURLOptio,
inlineImages = options.inlineImages,
recordCanvas = options.recordCanvas,
keepIframeSrcFn = options.keepIframeSrcFn,
_options$newlyAddedEl = options.newlyAddedElement,
newlyAddedElement = _options$newlyAddedEl === void 0 ? false : _options$newlyAddedEl;
var rootId = getRootId(doc, mirror);
switch (n.nodeType) {
case n.DOCUMENT_NODE:
if (n.compatMode !== "CSS1Compat") {
return {
type: NodeType.Document,
childNodes: [],
compatMode: n.compatMode
};
} else {
return {
type: NodeType.Document,
childNodes: []
};
}
case n.DOCUMENT_TYPE_NODE:
return {
type: NodeType.DocumentType,
name: n.name,
publicId: n.publicId,
systemId: n.systemId,
rootId: rootId
};
case n.ELEMENT_NODE:
return serializeElementNode(n, {
doc: doc,
blockClass: blockClass,
blockSelector: blockSelector,
inlineStylesheet: inlineStylesheet,
maskInputOptions: maskInputOptions,
maskInputFn: maskInputFn,
dataURLOptions: dataURLOptions,
inlineImages: inlineImages,
recordCanvas: recordCanvas,
keepIframeSrcFn: keepIframeSrcFn,
newlyAddedElement: newlyAddedElement,
rootId: rootId
});
case n.TEXT_NODE:
return serializeTextNode(n, {
doc: doc,
needsMask: needsMask,
maskTextFn: maskTextFn,
rootId: rootId
});
case n.CDATA_SECTION_NODE:
return {
type: NodeType.CDATA,
textContent: "",
rootId: rootId
};
case n.COMMENT_NODE:
return {
type: NodeType.Comment,
textContent: n.textContent || "",
rootId: rootId
};
default:
return false;
}
}
function getRootId(doc, mirror) {
if (!mirror.hasNode(doc)) return void 0;
var docId = mirror.getId(doc);
return docId === 1 ? void 0 : docId;
}
function serializeTextNode(n, options) {
var _a;
var needsMask = options.needsMask,
maskTextFn = options.maskTextFn,
rootId = options.rootId;
var parentTagName = n.parentNode && n.parentNode.tagName;
var textContent = n.textContent;
var isStyle = parentTagName === "STYLE" ? true : void 0;
var isScript = parentTagName === "SCRIPT" ? true : void 0;
if (isStyle && textContent) {
try {
if (n.nextSibling || n.previousSibling) {} else if ((_a = n.parentNode.sheet) == null ? void 0 : _a.cssRules) {
textContent = stringifyStylesheet(n.parentNode.sheet);
}
} catch (err) {
console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(err), n);
}
textContent = absoluteToStylesheet(textContent, getHref(options.doc));
}
if (isScript) {
textContent = "SCRIPT_PLACEHOLDER";
}
if (!isStyle && !isScript && textContent && needsMask) {
textContent = maskTextFn ? maskTextFn(textContent, n.parentElement) : textContent.replace(/[\S]/g, "*");
}
return {
type: NodeType.Text,
textContent: textContent || "",
isStyle: isStyle,
rootId: rootId
};
}
function serializeElementNode(n, options) {
var doc = options.doc,
blockClass = options.blockClass,
blockSelector = options.blockSelector,
inlineStylesheet = options.inlineStylesheet,
_options$maskInputOpt2 = options.maskInputOptions,
maskInputOptions = _options$maskInputOpt2 === void 0 ? {} : _options$maskInputOpt2,
maskInputFn = options.maskInputFn,
_options$dataURLOptio2 = options.dataURLOptions,
dataURLOptions = _options$dataURLOptio2 === void 0 ? {} : _options$dataURLOptio2,
inlineImages = options.inlineImages,
recordCanvas = options.recordCanvas,
keepIframeSrcFn = options.keepIframeSrcFn,
_options$newlyAddedEl2 = options.newlyAddedElement,
newlyAddedElement = _options$newlyAddedEl2 === void 0 ? false : _options$newlyAddedEl2,
rootId = options.rootId;
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
var tagName = getValidTagName(n);
var attributes2 = {};
var len = n.attributes.length;
for (var i = 0; i < len; i++) {
var attr = n.attributes[i];
if (!ignoreAttribute(tagName, attr.name, attr.value)) {
attributes2[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
}
}
if (tagName === "link" && inlineStylesheet) {
var stylesheet = Array.from(doc.styleSheets).find(function (s) {
return s.href === n.href;
});
var cssText = null;
if (stylesheet) {
cssText = stringifyStylesheet(stylesheet);
}
if (cssText) {
delete attributes2.rel;
delete attributes2.href;
attributes2._cssText = absoluteToStylesheet(cssText, stylesheet.href);
}
}
if (tagName === "style" && n.sheet && !(n.innerText || n.textContent || "").trim().length) {
var _cssText = stringifyStylesheet(n.sheet);
if (_cssText) {
attributes2._cssText = absoluteToStylesheet(_cssText, getHref(doc));
}
}
if (tagName === "input" || tagName === "textarea" || tagName === "select") {
var value = n.value;
var checked = n.checked;
if (attributes2.type !== "radio" && attributes2.type !== "checkbox" && attributes2.type !== "submit" && attributes2.type !== "button" && value) {
attributes2.value = maskInputValue({
element: n,
type: getInputType(n),
tagName: tagName,
value: value,
maskInputOptions: maskInputOptions,
maskInputFn: maskInputFn
});
} else if (checked) {
attributes2.checked = checked;
}
}
if (tagName === "option") {
if (n.selected && !maskInputOptions["select"]) {
attributes2.selected = true;
} else {
delete attributes2.selected;
}
}
if (tagName === "canvas" && recordCanvas) {
if (n.__context === "2d") {
if (!is2DCanvasBlank(n)) {
attributes2.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
}
} else if (!("__context" in n)) {
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
var blankCanvas = doc.createElement("canvas");
blankCanvas.width = n.width;
blankCanvas.height = n.height;
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
if (canvasDataURL !== blankCanvasDataURL) {
attributes2.rr_dataURL = canvasDataURL;
}
}
}
if (tagName === "img" && inlineImages) {
if (!canvasService) {
canvasService = doc.createElement("canvas");
canvasCtx = canvasService.getContext("2d");
}
var image = n;
var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
var priorCrossOrigin = image.crossOrigin;
var _recordInlineImage = function recordInlineImage() {
image.removeEventListener("load", _recordInlineImage);
try {
canvasService.width = image.naturalWidth;
canvasService.height = image.naturalHeight;
canvasCtx.drawImage(image, 0, 0);
attributes2.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
} catch (err) {
if (image.crossOrigin !== "anonymous") {
image.crossOrigin = "anonymous";
if (image.complete && image.naturalWidth !== 0) _recordInlineImage();else image.addEventListener("load", _recordInlineImage);
return;
} else {
console.warn("Cannot inline img src=".concat(imageSrc, "! Error: ").concat(err));
}
}
if (image.crossOrigin === "anonymous") {
priorCrossOrigin ? attributes2.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
}
};
if (image.complete && image.naturalWidth !== 0) _recordInlineImage();else image.addEventListener("load", _recordInlineImage);
}
if (tagName === "audio" || tagName === "video") {
var mediaAttributes = attributes2;
mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
mediaAttributes.rr_mediaCurrentTime = n.currentTime;
mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
mediaAttributes.rr_mediaMuted = n.muted;
mediaAttributes.rr_mediaLoop = n.loop;
mediaAttributes.rr_mediaVolume = n.volume;
}
if (!newlyAddedElement) {
if (n.scrollLeft) {
attributes2.rr_scrollLeft = n.scrollLeft;
}
if (n.scrollTop) {
attributes2.rr_scrollTop = n.scrollTop;
}
}
if (needBlock) {
var _n$getBoundingClientR = n.getBoundingClientRect(),
width = _n$getBoundingClientR.width,
height = _n$getBoundingClientR.height;
attributes2 = {
"class": attributes2["class"],
rr_width: "".concat(width, "px"),
rr_height: "".concat(height, "px")
};
}
if (tagName === "iframe" && !keepIframeSrcFn(attributes2.src)) {
if (!n.contentDocument) {
attributes2.rr_src = attributes2.src;
}
delete attributes2.src;
}
var isCustomElement;
try {
if (customElements.get(tagName)) isCustomElement = true;
} catch (e) {}
return {
type: NodeType.Element,
tagName: tagName,
attributes: attributes2,
childNodes: [],
isSVG: isSVGElement(n) || void 0,
needBlock: needBlock,
rootId: rootId,
isCustom: isCustomElement
};
}
function lowerIfExists(maybeAttr) {
if (maybeAttr === void 0 || maybeAttr === null) {
return "";
} else {
return maybeAttr.toLowerCase();
}
}
function slimDOMExcluded(sn, slimDOMOptions) {
if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
return true;
} else if (sn.type === NodeType.Element) {
if (slimDOMOptions.script && (sn.tagName === "script" || sn.tagName === "link" && (sn.attributes.rel === "preload" || sn.attributes.rel === "modulepreload") && sn.attributes.as === "script" || sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "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"] !== void 0) {
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,
mirror = options.mirror,
blockClass = options.blockClass,
blockSelector = options.blockSelector,
maskTextClass = options.maskTextClass,
maskTextSelector = options.maskTextSelector,
_options$skipChild = options.skipChild,
skipChild = _options$skipChild === void 0 ? false : _options$skipChild,
_options$inlineStyles = options.inlineStylesheet,
inlineStylesheet = _options$inlineStyles === void 0 ? true : _options$inlineStyles,
_options$maskInputOpt3 = options.maskInputOptions,
maskInputOptions = _options$maskInputOpt3 === void 0 ? {} : _options$maskInputOpt3,
maskTextFn = options.maskTextFn,
maskInputFn = options.maskInputFn,
slimDOMOptions = options.slimDOMOptions,
_options$dataURLOptio3 = options.dataURLOptions,
dataURLOptions = _options$dataURLOptio3 === void 0 ? {} : _options$dataURLOptio3,
_options$inlineImages = options.inlineImages,
inlineImages = _options$inlineImages === void 0 ? false : _options$inlineImages,
_options$recordCanvas = options.recordCanvas,
recordCanvas = _options$recordCanvas === void 0 ? false : _options$recordCanvas,
onSerialize = options.onSerialize,
onIframeLoad = options.onIframeLoad,
_options$iframeLoadTi = options.iframeLoadTimeout,
iframeLoadTimeout = _options$iframeLoadTi === void 0 ? 5e3 : _options$iframeLoadTi,
onStylesheetLoad = options.onStylesheetLoad,
_options$stylesheetLo = options.stylesheetLoadTimeout,
stylesheetLoadTimeout = _options$stylesheetLo === void 0 ? 5e3 : _options$stylesheetLo,
_options$keepIframeSr = options.keepIframeSrcFn,
keepIframeSrcFn = _options$keepIframeSr === void 0 ? function () {
return false;
} : _options$keepIframeSr,
_options$newlyAddedEl3 = options.newlyAddedElement,
newlyAddedElement = _options$newlyAddedEl3 === void 0 ? false : _options$newlyAddedEl3;
var needsMask = options.needsMask;
var _options$preserveWhit = options.preserveWhiteSpace,
preserveWhiteSpace = _options$preserveWhit === void 0 ? true : _options$preserveWhit;
if (!needsMask && n.childNodes) {
var checkAncestors = needsMask === void 0;
needsMask = needMaskingText(n, maskTextClass, maskTextSelector, checkAncestors);
}
var _serializedNode = serializeNode(n, {
doc: doc,
mirror: mirror,
blockClass: blockClass,
blockSelector: blockSelector,
needsMask: needsMask,
inlineStylesheet: inlineStylesheet,
maskInputOptions: maskInputOptions,
maskTextFn: maskTextFn,
maskInputFn: maskInputFn,
dataURLOptions: dataURLOptions,
inlineImages: inlineImages,
recordCanvas: recordCanvas,
keepIframeSrcFn: keepIframeSrcFn,
newlyAddedElement: newlyAddedElement
});
if (!_serializedNode) {
console.warn(n, "not serialized");
return null;
}
var id;
if (mirror.hasNode(n)) {
id = mirror.getId(n);
} else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
id = IGNORED_NODE;
} else {
id = genId();
}
var serializedNode2 = _extends(_serializedNode, {
id: id
});
mirror.add(n, serializedNode2);
if (id === IGNORED_NODE) {
return null;
}
if (onSerialize) {
onSerialize(n);
}
var recordChild = !skipChild;
if (serializedNode2.type === NodeType.Element) {
recordChild = recordChild && !serializedNode2.needBlock;
delete serializedNode2.needBlock;
var shadowRoot = n.shadowRoot;
if (shadowRoot && isNativeShadowDom(shadowRoot)) serializedNode2.isShadowHost = true;
}
if ((serializedNode2.type === NodeType.Document || serializedNode2.type === NodeType.Element) && recordChild) {
if (slimDOMOptions.headWhitespace && serializedNode2.type === NodeType.Element && serializedNode2.tagName === "head") {
preserveWhiteSpace = false;
}
var bypassOptions = {
doc: doc,
mirror: mirror,
blockClass: blockClass,
blockSelector: blockSelector,
needsMask: needsMask,
maskTextClass: maskTextClass,
maskTextSelector: maskTextSelector,
skipChild: skipChild,
inlineStylesheet: inlineStylesheet,
maskInputOptions: maskInputOptions,
maskTextFn: maskTextFn,
maskInputFn: maskInputFn,
slimDOMOptions: slimDOMOptions,
dataURLOptions: dataURLOptions,
inlineImages: inlineImages,
recordCanvas: recordCanvas,
preserveWhiteSpace: preserveWhiteSpace,
onSerialize: onSerialize,
onIframeLoad: onIframeLoad,
iframeLoadTimeout: iframeLoadTimeout,
onStylesheetLoad: onStylesheetLoad,
stylesheetLoadTimeout: stylesheetLoadTimeout,
keepIframeSrcFn: keepIframeSrcFn
};
if (serializedNode2.type === NodeType.Element && serializedNode2.tagName === "textarea" && serializedNode2.attributes.value !== void 0) ;else {
for (var _i = 0, _Array$from = Array.from(n.childNodes); _i < _Array$from.length; _i++) {
var childN = _Array$from[_i];
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
if (serializedChildNode) {
serializedNode2.childNodes.push(serializedChildNode);
}
}
}
if (isElement(n) && n.shadowRoot) {
for (var _i2 = 0, _Array$from2 = Array.from(n.shadowRoot.childNodes); _i2 < _Array$from2.length; _i2++) {
var _childN = _Array$from2[_i2];
var _serializedChildNode = serializeNodeWithId(_childN, bypassOptions);
if (_serializedChildNode) {
isNativeShadowDom(n.shadowRoot) && (_serializedChildNode.isShadow = true);
serializedNode2.childNodes.push(_serializedChildNode);
}
}
}
}
if (n.parentNode && isShadowRoot(n.parentNode) && isNativeShadowDom(n.parentNode)) {
serializedNode2.isShadow = true;
}
if (serializedNode2.type === NodeType.Element && serializedNode2.tagName === "iframe") {
onceIframeLoaded(n, function () {
var iframeDoc = n.contentDocument;
if (iframeDoc && onIframeLoad) {
var serializedIframeNode = serializeNodeWithId(iframeDoc, {
doc: iframeDoc,
mirror: mirror,
blockClass: blockClass,
blockSelector: blockSelector,
needsMask: needsMask,
maskTextClass: maskTextClass,
maskTextSelector: maskTextSelector,
skipChild: false,
inlineStylesheet: inlineStylesheet,
maskInputOptions: maskInputOptions,
maskTextFn: maskTextFn,
maskInputFn: maskInputFn,
slimDOMOptions: slimDOMOptions,
dataURLOptions: dataURLOptions,
inlineImages: inlineImages,
recordCanvas: recordCanvas,
preserveWhiteSpace: preserveWhiteSpace,
onSerialize: onSerialize,
onIframeLoad: onIframeLoad,
iframeLoadTimeout: iframeLoadTimeout,
onStylesheetLoad: onStylesheetLoad,
stylesheetLoadTimeout: stylesheetLoadTimeout,
keepIframeSrcFn: keepIframeSrcFn
});
if (serializedIframeNode) {
onIframeLoad(n, serializedIframeNode);
}
}
}, iframeLoadTimeout);
}
if (serializedNode2.type === NodeType.Element && serializedNode2.tagName === "link" && typeof serializedNode2.attributes.rel === "string" && (serializedNode2.attributes.rel === "stylesheet" || serializedNode2.attributes.rel === "preload" && typeof serializedNode2.attributes.href === "string" && extractFileExtension(serializedNode2.attributes.href) === "css")) {
onceStylesheetLoaded(n, function () {
if (onStylesheetLoad) {
var serializedLinkNode = serializeNodeWithId(n, {
doc: doc,
mirror: mirror,
blockClass: blockClass,
blockSelector: blockSelector,
needsMask: needsMask,
maskTextClass: maskTextClass,
maskTextSelector: maskTextSelector,
skipChild: false,
inlineStylesheet: inlineStylesheet,
maskInputOptions: maskInputOptions,
maskTextFn: maskTextFn,
maskInputFn: maskInputFn,
slimDOMOptions: slimDOMOptions,
dataURLOptions: dataURLOptions,
inlineImages: inlineImages,
recordCanvas: recordCanvas,
preserveWhiteSpace: preserveWhiteSpace,
onSerialize: onSerialize,
onIframeLoad: onIframeLoad,
iframeLoadTimeout: iframeLoadTimeout,
onStylesheetLoad: onStylesheetLoad,
stylesheetLoadTimeout: stylesheetLoadTimeout,
keepIframeSrcFn: keepIframeSrcFn
});
if (serializedLinkNode) {
onStylesheetLoad(n, serializedLinkNode);
}
}
}, stylesheetLoadTimeout);
}
return serializedNode2;
}
function snapshot(n, options) {
var _ref3 = options || {},
_ref3$mirror = _ref3.mirror,
mirror = _ref3$mirror === void 0 ? new Mirror() : _ref3$mirror,
_ref3$blockClass = _ref3.blockClass,
blockClass = _ref3$blockClass === void 0 ? "rr-block" : _ref3$blockClass,
_ref3$blockSelector = _ref3.blockSelector,
blockSelector = _ref3$blockSelector === void 0 ? null : _ref3$blockSelector,
_ref3$maskTextClass = _ref3.maskTextClass,
maskTextClass = _ref3$maskTextClass === void 0 ? "rr-mask" : _ref3$maskTextClass,
_ref3$maskTextSelecto = _ref3.maskTextSelector,
maskTextSelector = _ref3$maskTextSelecto === void 0 ? null : _ref3$maskTextSelecto,
_ref3$inlineStyleshee = _ref3.inlineStylesheet,
inlineStylesheet = _ref3$inlineStyleshee === void 0 ? true : _ref3$inlineStyleshee,
_ref3$inlineImages = _ref3.inlineImages,
inlineImages = _ref3$inlineImages === void 0 ? false : _ref3$inlineImages,
_ref3$recordCanvas = _ref3.recordCanvas,
recordCanvas = _ref3$recordCanvas === void 0 ? false : _ref3$recordCanvas,
_ref3$maskAllInputs = _ref3.maskAllInputs,
maskAllInputs = _ref3$maskAllInputs === void 0 ? false : _ref3$maskAllInputs,
maskTextFn = _ref3.maskTextFn,
maskInputFn = _ref3.maskInputFn,
_ref3$slimDOM = _ref3.slimDOM,
slimDOM = _ref3$slimDOM === void 0 ? false : _ref3$slimDOM,
dataURLOptions = _ref3.dataURLOptions,
preserveWhiteSpace = _ref3.preserveWhiteSpace,
onSerialize = _ref3.onSerialize,
onIframeLoad = _ref3.onIframeLoad,
iframeLoadTimeout = _ref3.iframeLoadTimeout,
onStylesheetLoad = _ref3.onStylesheetLoad,
stylesheetLoadTimeout = _ref3.stylesheetLoadTimeout,
_ref3$keepIframeSrcFn = _ref3.keepIframeSrcFn,
keepIframeSrcFn = _ref3$keepIframeSrcFn === void 0 ? function () {
return false;
} : _ref3$keepIframeSrcFn;
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,
mirror: mirror,
blockClass: blockClass,
blockSelector: blockSelector,
maskTextClass: maskTextClass,
maskTextSelector: maskTextSelector,
skipChild: false,
inlineStylesheet: inlineStylesheet,
maskInputOptions: maskInputOptions,
maskTextFn: maskTextFn,
maskInputFn: maskInputFn,
slimDOMOptions: slimDOMOptions,
dataURLOptions: dataURLOptions,
inlineImages: inlineImages,
recordCanvas: recordCanvas,
preserveWhiteSpace: preserveWhiteSpace,
onSerialize: onSerialize,
onIframeLoad: onIframeLoad,
iframeLoadTimeout: iframeLoadTimeout,
onStylesheetLoad: onStylesheetLoad,
stylesheetLoadTimeout: stylesheetLoadTimeout,
keepIframeSrcFn: keepIframeSrcFn,
newlyAddedElement: false
});
}
function getWorkerString() {
var _this = this;
var MAX_CHUNK_SIZE = 1024 * 1024;
var ERROR_MESSAGE = 'Coralogix Browser SDK - Error from session recording worker:\n';
importScriptWithFallback('https://cdn.rum-ingress-coralogix.com/coralogix/browser/latest/pako_deflate.es5.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako_deflate.es5.min.js');
self.onmessage = function (_a) {
var data = _a.data;
if (!_this.pako) {
console.warn('Coralogix Browser SDK - Web worker not created due to missing pako library');
self.postMessage({
event: 'stopRecording',
});
return;
}
var recordsData;
var isScreenshot = !!data.screenshotId;
if (isScreenshot) {
recordsData = JSON.stringify(data.records);
}
else {
recordsData = omitSquareBrackets(JSON.stringify(data.records));
}
va