@appsurify-testmap/rrweb-player 2.0.0-alpha.40 → 2.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -414,6 +414,9 @@ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
414
414
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
415
415
  return NodeType2;
416
416
  })(NodeType$3 || {});
417
+ function isElement(n2) {
418
+ return n2.nodeType === n2.ELEMENT_NODE;
419
+ }
417
420
  class Mirror {
418
421
  constructor() {
419
422
  __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
@@ -487,8 +490,16 @@ function isNodeMetaEqual(a2, b) {
487
490
  return a2.tagName === b.tagName && JSON.stringify(a2.attributes) === JSON.stringify(b.attributes) && a2.isSVG === b.isSVG && a2.needBlock === b.needBlock;
488
491
  return false;
489
492
  }
490
- function isElement(n2) {
491
- return n2.nodeType === n2.ELEMENT_NODE;
493
+ function extractFileExtension(path, baseURL) {
494
+ let url;
495
+ try {
496
+ url = new URL(path, baseURL ?? window.location.href);
497
+ } catch (err) {
498
+ return null;
499
+ }
500
+ const regex = /\.([0-9a-z]+)(?:$)/i;
501
+ const match = url.pathname.match(regex);
502
+ return (match == null ? void 0 : match[1]) ?? null;
492
503
  }
493
504
  const interactiveEvents$1 = [
494
505
  "change",
@@ -515,6 +526,30 @@ const interactiveEvents$1 = [
515
526
  "touchend",
516
527
  "touchcancel"
517
528
  ];
529
+ const inlineEventAttributes$1 = [
530
+ "onclick",
531
+ "ondblclick",
532
+ "onmousedown",
533
+ "onmouseup",
534
+ "onmouseover",
535
+ "onmouseout",
536
+ "onmousemove",
537
+ "onfocus",
538
+ "onblur",
539
+ "onkeydown",
540
+ "onkeypress",
541
+ "onkeyup",
542
+ "onchange",
543
+ "oninput",
544
+ "onsubmit",
545
+ "onreset",
546
+ "onselect",
547
+ "oncontextmenu",
548
+ "ontouchstart",
549
+ "ontouchmove",
550
+ "ontouchend",
551
+ "ontouchcancel"
552
+ ];
518
553
  const interactiveElementsRegistry$1 = /* @__PURE__ */ new WeakSet();
519
554
  const originalAddEventListener$1 = EventTarget.prototype.addEventListener;
520
555
  EventTarget.prototype.addEventListener = function(type, listener, options) {
@@ -530,6 +565,21 @@ const originalRemoveEventListener$1 = EventTarget.prototype.removeEventListener;
530
565
  EventTarget.prototype.removeEventListener = function(type, listener, options) {
531
566
  originalRemoveEventListener$1.call(this, type, listener, options);
532
567
  };
568
+ function inspectInlineEventHandlers$1() {
569
+ const allElements = document.querySelectorAll("*");
570
+ allElements.forEach((el) => {
571
+ inlineEventAttributes$1.forEach((attr2) => {
572
+ if (el.hasAttribute(attr2)) {
573
+ interactiveElementsRegistry$1.add(el);
574
+ }
575
+ });
576
+ });
577
+ }
578
+ if (document.readyState === "complete" || document.readyState === "interactive") {
579
+ inspectInlineEventHandlers$1();
580
+ } else {
581
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
582
+ }
533
583
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
534
584
  const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
535
585
  const mediaSelectorPlugin = {
@@ -4163,11 +4213,16 @@ function getTagName(n2) {
4163
4213
  function adaptCssForReplay(cssText, cache) {
4164
4214
  const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
4165
4215
  if (cachedStyle) return cachedStyle;
4166
- const ast = postcss$1$1([
4167
- mediaSelectorPlugin,
4168
- pseudoClassPlugin
4169
- ]).process(cssText);
4170
- const result2 = ast.css;
4216
+ let result2 = cssText;
4217
+ try {
4218
+ const ast = postcss$1$1([
4219
+ mediaSelectorPlugin,
4220
+ pseudoClassPlugin
4221
+ ]).process(cssText);
4222
+ result2 = ast.css;
4223
+ } catch (error) {
4224
+ console.warn("Failed to adapt css for replay", error);
4225
+ }
4171
4226
  cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
4172
4227
  return result2;
4173
4228
  }
@@ -4188,11 +4243,39 @@ function applyCssSplits(n2, cssText, hackCss, cache) {
4188
4243
  while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
4189
4244
  cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
4190
4245
  }
4246
+ let adaptedCss = "";
4247
+ if (hackCss) {
4248
+ adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
4249
+ }
4250
+ let startIndex = 0;
4191
4251
  for (let i2 = 0; i2 < childTextNodes.length; i2++) {
4252
+ if (i2 === cssTextSplits.length) {
4253
+ break;
4254
+ }
4192
4255
  const childTextNode = childTextNodes[i2];
4193
- const cssTextSection = cssTextSplits[i2];
4194
- if (childTextNode && cssTextSection) {
4195
- childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
4256
+ if (!hackCss) {
4257
+ childTextNode.textContent = cssTextSplits[i2];
4258
+ } else if (i2 < cssTextSplits.length - 1) {
4259
+ let endIndex = startIndex;
4260
+ let endSearch = cssTextSplits[i2 + 1].length;
4261
+ endSearch = Math.min(endSearch, 30);
4262
+ let found = false;
4263
+ for (; endSearch > 2; endSearch--) {
4264
+ const searchBit = cssTextSplits[i2 + 1].substring(0, endSearch);
4265
+ const searchIndex = adaptedCss.substring(startIndex).indexOf(searchBit);
4266
+ found = searchIndex !== -1;
4267
+ if (found) {
4268
+ endIndex += searchIndex;
4269
+ break;
4270
+ }
4271
+ }
4272
+ if (!found) {
4273
+ endIndex += cssTextSplits[i2].length;
4274
+ }
4275
+ childTextNode.textContent = adaptedCss.substring(startIndex, endIndex);
4276
+ startIndex = endIndex;
4277
+ } else {
4278
+ childTextNode.textContent = adaptedCss.substring(startIndex);
4196
4279
  }
4197
4280
  }
4198
4281
  }
@@ -4276,8 +4359,8 @@ function buildNode(n2, options) {
4276
4359
  } else if (tagName === "meta" && n2.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") {
4277
4360
  node2.setAttribute("csp-content", value.toString());
4278
4361
  continue;
4279
- } else if (tagName === "link" && (n2.attributes.rel === "preload" || n2.attributes.rel === "modulepreload") && n2.attributes.as === "script") {
4280
- } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && n2.attributes.href.endsWith(".js")) {
4362
+ } else if (tagName === "link" && (n2.attributes.rel === "preload" && n2.attributes.as === "script" || n2.attributes.rel === "modulepreload")) {
4363
+ } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && extractFileExtension(n2.attributes.href) === "js") {
4281
4364
  } else if (tagName === "img" && n2.attributes.srcset && n2.attributes.rr_dataURL) {
4282
4365
  node2.setAttribute(
4283
4366
  "rrweb-original-srcset",
@@ -4586,6 +4669,30 @@ const interactiveEvents = [
4586
4669
  "touchend",
4587
4670
  "touchcancel"
4588
4671
  ];
4672
+ const inlineEventAttributes = [
4673
+ "onclick",
4674
+ "ondblclick",
4675
+ "onmousedown",
4676
+ "onmouseup",
4677
+ "onmouseover",
4678
+ "onmouseout",
4679
+ "onmousemove",
4680
+ "onfocus",
4681
+ "onblur",
4682
+ "onkeydown",
4683
+ "onkeypress",
4684
+ "onkeyup",
4685
+ "onchange",
4686
+ "oninput",
4687
+ "onsubmit",
4688
+ "onreset",
4689
+ "onselect",
4690
+ "oncontextmenu",
4691
+ "ontouchstart",
4692
+ "ontouchmove",
4693
+ "ontouchend",
4694
+ "ontouchcancel"
4695
+ ];
4589
4696
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
4590
4697
  const originalAddEventListener = EventTarget.prototype.addEventListener;
4591
4698
  EventTarget.prototype.addEventListener = function(type, listener, options) {
@@ -4601,6 +4708,21 @@ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
4601
4708
  EventTarget.prototype.removeEventListener = function(type, listener, options) {
4602
4709
  originalRemoveEventListener.call(this, type, listener, options);
4603
4710
  };
4711
+ function inspectInlineEventHandlers() {
4712
+ const allElements = document.querySelectorAll("*");
4713
+ allElements.forEach((el) => {
4714
+ inlineEventAttributes.forEach((attr2) => {
4715
+ if (el.hasAttribute(attr2)) {
4716
+ interactiveElementsRegistry.add(el);
4717
+ }
4718
+ });
4719
+ });
4720
+ }
4721
+ if (document.readyState === "complete" || document.readyState === "interactive") {
4722
+ inspectInlineEventHandlers();
4723
+ } else {
4724
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
4725
+ }
4604
4726
  function getDefaultExportFromCjs(x2) {
4605
4727
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
4606
4728
  }
@@ -9551,6 +9673,32 @@ function querySelectorAll(n2, selectors) {
9551
9673
  function mutationObserverCtor() {
9552
9674
  return getUntaintedPrototype("MutationObserver").constructor;
9553
9675
  }
9676
+ function patch(source, name, replacement) {
9677
+ try {
9678
+ if (!(name in source)) {
9679
+ return () => {
9680
+ };
9681
+ }
9682
+ const original = source[name];
9683
+ const wrapped = replacement(original);
9684
+ if (typeof wrapped === "function") {
9685
+ wrapped.prototype = wrapped.prototype || {};
9686
+ Object.defineProperties(wrapped, {
9687
+ __rrweb_original__: {
9688
+ enumerable: false,
9689
+ value: original
9690
+ }
9691
+ });
9692
+ }
9693
+ source[name] = wrapped;
9694
+ return () => {
9695
+ source[name] = original;
9696
+ };
9697
+ } catch {
9698
+ return () => {
9699
+ };
9700
+ }
9701
+ }
9554
9702
  const index = {
9555
9703
  childNodes,
9556
9704
  parentNode,
@@ -9563,7 +9711,8 @@ const index = {
9563
9711
  shadowRoot,
9564
9712
  querySelector,
9565
9713
  querySelectorAll,
9566
- mutationObserver: mutationObserverCtor
9714
+ mutationObserver: mutationObserverCtor,
9715
+ patch
9567
9716
  };
9568
9717
  const DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
9569
9718
  let _mirror = {
@@ -9781,13 +9930,14 @@ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
9781
9930
  MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
9782
9931
  MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
9783
9932
  MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
9784
- MouseInteractions2[MouseInteractions2["DblClick"] = 3] = "DblClick";
9785
- MouseInteractions2[MouseInteractions2["Focus"] = 4] = "Focus";
9786
- MouseInteractions2[MouseInteractions2["Blur"] = 5] = "Blur";
9787
- MouseInteractions2[MouseInteractions2["TouchStart"] = 6] = "TouchStart";
9788
- MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 7] = "TouchMove_Departed";
9789
- MouseInteractions2[MouseInteractions2["TouchEnd"] = 8] = "TouchEnd";
9790
- MouseInteractions2[MouseInteractions2["TouchCancel"] = 9] = "TouchCancel";
9933
+ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
9934
+ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
9935
+ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
9936
+ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
9937
+ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
9938
+ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
9939
+ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
9940
+ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
9791
9941
  return MouseInteractions2;
9792
9942
  })(MouseInteractions || {});
9793
9943
  var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {