@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.
@@ -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,27 +526,59 @@ 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
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
520
- const originalAddEventListener = EventTarget.prototype.addEventListener;
521
- EventTarget.prototype.addEventListener = function(type, listener, options) {
522
- originalAddEventListener.call(this, type, listener, options);
523
- if (this instanceof Element) {
524
- const eventType = type.toLowerCase();
525
- if (interactiveEvents$1.includes(eventType)) {
526
- interactiveElementsRegistry$1.add(this);
527
- }
554
+ const originalAddEventListener$1 = EventTarget.prototype.addEventListener;
555
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
556
+ originalAddEventListener$1.call(this, type, listener, options);
557
+ if (this instanceof Element) {
558
+ const eventType = type.toLowerCase();
559
+ if (interactiveEvents$1.includes(eventType)) {
560
+ interactiveElementsRegistry$1.add(this);
528
561
  }
529
- };
562
+ }
563
+ };
564
+ const originalRemoveEventListener$1 = EventTarget.prototype.removeEventListener;
565
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
566
+ originalRemoveEventListener$1.call(this, type, listener, options);
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
+ });
530
577
  }
531
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
532
- const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
533
- EventTarget.prototype.removeEventListener = function(type, listener, options) {
534
- originalRemoveEventListener.call(this, type, listener, options);
535
- if (this instanceof Element) {
536
- type.toLowerCase();
537
- }
538
- };
578
+ if (document.readyState === "complete" || document.readyState === "interactive") {
579
+ inspectInlineEventHandlers$1();
580
+ } else {
581
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
539
582
  }
540
583
  const MEDIA_SELECTOR = /(max|min)-device-(width|height)/;
541
584
  const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g");
@@ -4170,11 +4213,16 @@ function getTagName(n2) {
4170
4213
  function adaptCssForReplay(cssText, cache) {
4171
4214
  const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
4172
4215
  if (cachedStyle) return cachedStyle;
4173
- const ast = postcss$1$1([
4174
- mediaSelectorPlugin,
4175
- pseudoClassPlugin
4176
- ]).process(cssText);
4177
- 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
+ }
4178
4226
  cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2);
4179
4227
  return result2;
4180
4228
  }
@@ -4195,11 +4243,39 @@ function applyCssSplits(n2, cssText, hackCss, cache) {
4195
4243
  while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
4196
4244
  cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
4197
4245
  }
4246
+ let adaptedCss = "";
4247
+ if (hackCss) {
4248
+ adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
4249
+ }
4250
+ let startIndex = 0;
4198
4251
  for (let i2 = 0; i2 < childTextNodes.length; i2++) {
4252
+ if (i2 === cssTextSplits.length) {
4253
+ break;
4254
+ }
4199
4255
  const childTextNode = childTextNodes[i2];
4200
- const cssTextSection = cssTextSplits[i2];
4201
- if (childTextNode && cssTextSection) {
4202
- 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);
4203
4279
  }
4204
4280
  }
4205
4281
  }
@@ -4283,8 +4359,8 @@ function buildNode(n2, options) {
4283
4359
  } else if (tagName === "meta" && n2.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") {
4284
4360
  node2.setAttribute("csp-content", value.toString());
4285
4361
  continue;
4286
- } else if (tagName === "link" && (n2.attributes.rel === "preload" || n2.attributes.rel === "modulepreload") && n2.attributes.as === "script") {
4287
- } 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") {
4288
4364
  } else if (tagName === "img" && n2.attributes.srcset && n2.attributes.rr_dataURL) {
4289
4365
  node2.setAttribute(
4290
4366
  "rrweb-original-srcset",
@@ -4593,27 +4669,59 @@ const interactiveEvents = [
4593
4669
  "touchend",
4594
4670
  "touchcancel"
4595
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
+ ];
4596
4696
  const interactiveElementsRegistry = /* @__PURE__ */ new WeakSet();
4597
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
4598
- const originalAddEventListener = EventTarget.prototype.addEventListener;
4599
- EventTarget.prototype.addEventListener = function(type, listener, options) {
4600
- originalAddEventListener.call(this, type, listener, options);
4601
- if (this instanceof Element) {
4602
- const eventType = type.toLowerCase();
4603
- if (interactiveEvents.includes(eventType)) {
4604
- interactiveElementsRegistry.add(this);
4605
- }
4697
+ const originalAddEventListener = EventTarget.prototype.addEventListener;
4698
+ EventTarget.prototype.addEventListener = function(type, listener, options) {
4699
+ originalAddEventListener.call(this, type, listener, options);
4700
+ if (this instanceof Element) {
4701
+ const eventType = type.toLowerCase();
4702
+ if (interactiveEvents.includes(eventType)) {
4703
+ interactiveElementsRegistry.add(this);
4606
4704
  }
4607
- };
4705
+ }
4706
+ };
4707
+ const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
4708
+ EventTarget.prototype.removeEventListener = function(type, listener, options) {
4709
+ originalRemoveEventListener.call(this, type, listener, options);
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
+ });
4608
4720
  }
4609
- if (typeof Element !== "undefined" && typeof EventTarget !== "undefined") {
4610
- const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
4611
- EventTarget.prototype.removeEventListener = function(type, listener, options) {
4612
- originalRemoveEventListener.call(this, type, listener, options);
4613
- if (this instanceof Element) {
4614
- type.toLowerCase();
4615
- }
4616
- };
4721
+ if (document.readyState === "complete" || document.readyState === "interactive") {
4722
+ inspectInlineEventHandlers();
4723
+ } else {
4724
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
4617
4725
  }
4618
4726
  function getDefaultExportFromCjs(x2) {
4619
4727
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -9565,6 +9673,32 @@ function querySelectorAll(n2, selectors) {
9565
9673
  function mutationObserverCtor() {
9566
9674
  return getUntaintedPrototype("MutationObserver").constructor;
9567
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
+ }
9568
9702
  const index = {
9569
9703
  childNodes,
9570
9704
  parentNode,
@@ -9577,7 +9711,8 @@ const index = {
9577
9711
  shadowRoot,
9578
9712
  querySelector,
9579
9713
  querySelectorAll,
9580
- mutationObserver: mutationObserverCtor
9714
+ mutationObserver: mutationObserverCtor,
9715
+ patch
9581
9716
  };
9582
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.";
9583
9718
  let _mirror = {
@@ -9795,13 +9930,14 @@ var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
9795
9930
  MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
9796
9931
  MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
9797
9932
  MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
9798
- MouseInteractions2[MouseInteractions2["DblClick"] = 3] = "DblClick";
9799
- MouseInteractions2[MouseInteractions2["Focus"] = 4] = "Focus";
9800
- MouseInteractions2[MouseInteractions2["Blur"] = 5] = "Blur";
9801
- MouseInteractions2[MouseInteractions2["TouchStart"] = 6] = "TouchStart";
9802
- MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 7] = "TouchMove_Departed";
9803
- MouseInteractions2[MouseInteractions2["TouchEnd"] = 8] = "TouchEnd";
9804
- 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";
9805
9941
  return MouseInteractions2;
9806
9942
  })(MouseInteractions || {});
9807
9943
  var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {