@appsurify-testmap/rrweb-player 2.0.0-alpha.41 → 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.
@@ -412,6 +412,9 @@ var NodeType$3 = /* @__PURE__ */ ((NodeType2) => {
412
412
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
413
413
  return NodeType2;
414
414
  })(NodeType$3 || {});
415
+ function isElement(n2) {
416
+ return n2.nodeType === n2.ELEMENT_NODE;
417
+ }
415
418
  class Mirror {
416
419
  constructor() {
417
420
  __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
@@ -485,8 +488,16 @@ function isNodeMetaEqual(a2, b) {
485
488
  return a2.tagName === b.tagName && JSON.stringify(a2.attributes) === JSON.stringify(b.attributes) && a2.isSVG === b.isSVG && a2.needBlock === b.needBlock;
486
489
  return false;
487
490
  }
488
- function isElement(n2) {
489
- return n2.nodeType === n2.ELEMENT_NODE;
491
+ function extractFileExtension(path, baseURL) {
492
+ let url;
493
+ try {
494
+ url = new URL(path, baseURL ?? window.location.href);
495
+ } catch (err) {
496
+ return null;
497
+ }
498
+ const regex = /\.([0-9a-z]+)(?:$)/i;
499
+ const match = url.pathname.match(regex);
500
+ return (match == null ? void 0 : match[1]) ?? null;
490
501
  }
491
502
  const interactiveEvents$1 = [
492
503
  "change",
@@ -513,27 +524,59 @@ const interactiveEvents$1 = [
513
524
  "touchend",
514
525
  "touchcancel"
515
526
  ];
527
+ const inlineEventAttributes$1 = [
528
+ "onclick",
529
+ "ondblclick",
530
+ "onmousedown",
531
+ "onmouseup",
532
+ "onmouseover",
533
+ "onmouseout",
534
+ "onmousemove",
535
+ "onfocus",
536
+ "onblur",
537
+ "onkeydown",
538
+ "onkeypress",
539
+ "onkeyup",
540
+ "onchange",
541
+ "oninput",
542
+ "onsubmit",
543
+ "onreset",
544
+ "onselect",
545
+ "oncontextmenu",
546
+ "ontouchstart",
547
+ "ontouchmove",
548
+ "ontouchend",
549
+ "ontouchcancel"
550
+ ];
516
551
  const interactiveElementsRegistry$1 = /* @__PURE__ */ new WeakSet();
517
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
518
- const originalAddEventListener = EventTarget.prototype.addEventListener;
519
- EventTarget.prototype.addEventListener = function(type, listener, options) {
520
- originalAddEventListener.call(this, type, listener, options);
521
- if (this instanceof Element) {
522
- const eventType = type.toLowerCase();
523
- if (interactiveEvents$1.includes(eventType)) {
524
- interactiveElementsRegistry$1.add(this);
525
- }
552
+ const originalAddEventListener$1 = EventTarget.prototype.addEventListener;
553
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
554
+ originalAddEventListener$1.call(this, type, listener, options);
555
+ if (this instanceof Element) {
556
+ const eventType = type.toLowerCase();
557
+ if (interactiveEvents$1.includes(eventType)) {
558
+ interactiveElementsRegistry$1.add(this);
526
559
  }
527
- };
560
+ }
561
+ };
562
+ const originalRemoveEventListener$1 = EventTarget.prototype.removeEventListener;
563
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
564
+ originalRemoveEventListener$1.call(this, type, listener, options);
565
+ };
566
+ function inspectInlineEventHandlers$1() {
567
+ const allElements = document.querySelectorAll("*");
568
+ allElements.forEach((el) => {
569
+ inlineEventAttributes$1.forEach((attr2) => {
570
+ if (el.hasAttribute(attr2)) {
571
+ interactiveElementsRegistry$1.add(el);
572
+ }
573
+ });
574
+ });
528
575
  }
529
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
530
- const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
531
- EventTarget.prototype.removeEventListener = function(type, listener, options) {
532
- originalRemoveEventListener.call(this, type, listener, options);
533
- if (this instanceof Element) {
534
- type.toLowerCase();
535
- }
536
- };
576
+ if (document.readyState === "complete" || document.readyState === "interactive") {
577
+ inspectInlineEventHandlers$1();
578
+ } else {
579
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
537
580
  }
538
581
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
539
582
  const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
@@ -4168,11 +4211,16 @@ function getTagName(n2) {
4168
4211
  function adaptCssForReplay(cssText, cache) {
4169
4212
  const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
4170
4213
  if (cachedStyle) return cachedStyle;
4171
- const ast = postcss$1$1([
4172
- mediaSelectorPlugin,
4173
- pseudoClassPlugin
4174
- ]).process(cssText);
4175
- const result2 = ast.css;
4214
+ let result2 = cssText;
4215
+ try {
4216
+ const ast = postcss$1$1([
4217
+ mediaSelectorPlugin,
4218
+ pseudoClassPlugin
4219
+ ]).process(cssText);
4220
+ result2 = ast.css;
4221
+ } catch (error) {
4222
+ console.warn("Failed to adapt css for replay", error);
4223
+ }
4176
4224
  cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
4177
4225
  return result2;
4178
4226
  }
@@ -4193,11 +4241,39 @@ function applyCssSplits(n2, cssText, hackCss, cache) {
4193
4241
  while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
4194
4242
  cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
4195
4243
  }
4244
+ let adaptedCss = "";
4245
+ if (hackCss) {
4246
+ adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
4247
+ }
4248
+ let startIndex = 0;
4196
4249
  for (let i2 = 0; i2 < childTextNodes.length; i2++) {
4250
+ if (i2 === cssTextSplits.length) {
4251
+ break;
4252
+ }
4197
4253
  const childTextNode = childTextNodes[i2];
4198
- const cssTextSection = cssTextSplits[i2];
4199
- if (childTextNode && cssTextSection) {
4200
- childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
4254
+ if (!hackCss) {
4255
+ childTextNode.textContent = cssTextSplits[i2];
4256
+ } else if (i2 < cssTextSplits.length - 1) {
4257
+ let endIndex = startIndex;
4258
+ let endSearch = cssTextSplits[i2 + 1].length;
4259
+ endSearch = Math.min(endSearch, 30);
4260
+ let found = false;
4261
+ for (; endSearch > 2; endSearch--) {
4262
+ const searchBit = cssTextSplits[i2 + 1].substring(0, endSearch);
4263
+ const searchIndex = adaptedCss.substring(startIndex).indexOf(searchBit);
4264
+ found = searchIndex !== -1;
4265
+ if (found) {
4266
+ endIndex += searchIndex;
4267
+ break;
4268
+ }
4269
+ }
4270
+ if (!found) {
4271
+ endIndex += cssTextSplits[i2].length;
4272
+ }
4273
+ childTextNode.textContent = adaptedCss.substring(startIndex, endIndex);
4274
+ startIndex = endIndex;
4275
+ } else {
4276
+ childTextNode.textContent = adaptedCss.substring(startIndex);
4201
4277
  }
4202
4278
  }
4203
4279
  }
@@ -4281,8 +4357,8 @@ function buildNode(n2, options) {
4281
4357
  } else if (tagName === "meta" && n2.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") {
4282
4358
  node2.setAttribute("csp-content", value.toString());
4283
4359
  continue;
4284
- } else if (tagName === "link" && (n2.attributes.rel === "preload" || n2.attributes.rel === "modulepreload") && n2.attributes.as === "script") {
4285
- } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && n2.attributes.href.endsWith(".js")) {
4360
+ } else if (tagName === "link" && (n2.attributes.rel === "preload" && n2.attributes.as === "script" || n2.attributes.rel === "modulepreload")) {
4361
+ } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && extractFileExtension(n2.attributes.href) === "js") {
4286
4362
  } else if (tagName === "img" && n2.attributes.srcset && n2.attributes.rr_dataURL) {
4287
4363
  node2.setAttribute(
4288
4364
  "rrweb-original-srcset",
@@ -4591,27 +4667,59 @@ const interactiveEvents = [
4591
4667
  "touchend",
4592
4668
  "touchcancel"
4593
4669
  ];
4670
+ const inlineEventAttributes = [
4671
+ "onclick",
4672
+ "ondblclick",
4673
+ "onmousedown",
4674
+ "onmouseup",
4675
+ "onmouseover",
4676
+ "onmouseout",
4677
+ "onmousemove",
4678
+ "onfocus",
4679
+ "onblur",
4680
+ "onkeydown",
4681
+ "onkeypress",
4682
+ "onkeyup",
4683
+ "onchange",
4684
+ "oninput",
4685
+ "onsubmit",
4686
+ "onreset",
4687
+ "onselect",
4688
+ "oncontextmenu",
4689
+ "ontouchstart",
4690
+ "ontouchmove",
4691
+ "ontouchend",
4692
+ "ontouchcancel"
4693
+ ];
4594
4694
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
4595
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
4596
- const originalAddEventListener = EventTarget.prototype.addEventListener;
4597
- EventTarget.prototype.addEventListener = function(type, listener, options) {
4598
- originalAddEventListener.call(this, type, listener, options);
4599
- if (this instanceof Element) {
4600
- const eventType = type.toLowerCase();
4601
- if (interactiveEvents.includes(eventType)) {
4602
- interactiveElementsRegistry.add(this);
4603
- }
4695
+ const originalAddEventListener = EventTarget.prototype.addEventListener;
4696
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
4697
+ originalAddEventListener.call(this, type, listener, options);
4698
+ if (this instanceof Element) {
4699
+ const eventType = type.toLowerCase();
4700
+ if (interactiveEvents.includes(eventType)) {
4701
+ interactiveElementsRegistry.add(this);
4604
4702
  }
4605
- };
4703
+ }
4704
+ };
4705
+ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
4706
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
4707
+ originalRemoveEventListener.call(this, type, listener, options);
4708
+ };
4709
+ function inspectInlineEventHandlers() {
4710
+ const allElements = document.querySelectorAll("*");
4711
+ allElements.forEach((el) => {
4712
+ inlineEventAttributes.forEach((attr2) => {
4713
+ if (el.hasAttribute(attr2)) {
4714
+ interactiveElementsRegistry.add(el);
4715
+ }
4716
+ });
4717
+ });
4606
4718
  }
4607
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
4608
- const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
4609
- EventTarget.prototype.removeEventListener = function(type, listener, options) {
4610
- originalRemoveEventListener.call(this, type, listener, options);
4611
- if (this instanceof Element) {
4612
- type.toLowerCase();
4613
- }
4614
- };
4719
+ if (document.readyState === "complete" || document.readyState === "interactive") {
4720
+ inspectInlineEventHandlers();
4721
+ } else {
4722
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
4615
4723
  }
4616
4724
  function getDefaultExportFromCjs(x2) {
4617
4725
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -9563,6 +9671,32 @@ function querySelectorAll(n2, selectors) {
9563
9671
  function mutationObserverCtor() {
9564
9672
  return getUntaintedPrototype("MutationObserver").constructor;
9565
9673
  }
9674
+ function patch(source, name, replacement) {
9675
+ try {
9676
+ if (!(name in source)) {
9677
+ return () => {
9678
+ };
9679
+ }
9680
+ const original = source[name];
9681
+ const wrapped = replacement(original);
9682
+ if (typeof wrapped === "function") {
9683
+ wrapped.prototype = wrapped.prototype || {};
9684
+ Object.defineProperties(wrapped, {
9685
+ __rrweb_original__: {
9686
+ enumerable: false,
9687
+ value: original
9688
+ }
9689
+ });
9690
+ }
9691
+ source[name] = wrapped;
9692
+ return () => {
9693
+ source[name] = original;
9694
+ };
9695
+ } catch {
9696
+ return () => {
9697
+ };
9698
+ }
9699
+ }
9566
9700
  const index = {
9567
9701
  childNodes,
9568
9702
  parentNode,
@@ -9575,7 +9709,8 @@ const index = {
9575
9709
  shadowRoot,
9576
9710
  querySelector,
9577
9711
  querySelectorAll,
9578
- mutationObserver: mutationObserverCtor
9712
+ mutationObserver: mutationObserverCtor,
9713
+ patch
9579
9714
  };
9580
9715
  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.";
9581
9716
  let _mirror = {
@@ -9793,13 +9928,14 @@ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
9793
9928
  MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
9794
9929
  MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
9795
9930
  MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
9796
- MouseInteractions2[MouseInteractions2["DblClick"] = 3] = "DblClick";
9797
- MouseInteractions2[MouseInteractions2["Focus"] = 4] = "Focus";
9798
- MouseInteractions2[MouseInteractions2["Blur"] = 5] = "Blur";
9799
- MouseInteractions2[MouseInteractions2["TouchStart"] = 6] = "TouchStart";
9800
- MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 7] = "TouchMove_Departed";
9801
- MouseInteractions2[MouseInteractions2["TouchEnd"] = 8] = "TouchEnd";
9802
- MouseInteractions2[MouseInteractions2["TouchCancel"] = 9] = "TouchCancel";
9931
+ MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
9932
+ MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
9933
+ MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
9934
+ MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
9935
+ MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
9936
+ MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
9937
+ MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
9938
+ MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
9803
9939
  return MouseInteractions2;
9804
9940
  })(MouseInteractions || {});
9805
9941
  var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {