@appsurify-testmap/rrweb-record 2.1.0-alpha.5 → 2.1.0-alpha.7

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.
@@ -9796,7 +9796,7 @@ class MutationBuffer {
9796
9796
  let value = m.target.getAttribute(attributeName);
9797
9797
  const propValue = target[attributeName];
9798
9798
  const isPhantomAttributeMutation = value === null && !target.hasAttribute(attributeName) && m.oldValue !== null && (propValue === "" || propValue === null || typeof propValue === "undefined");
9799
- if (isPhantomAttributeMutation && !isIncludeAttribute(attributeName, this.includeAttribute)) {
9799
+ if (isPhantomAttributeMutation) {
9800
9800
  return;
9801
9801
  }
9802
9802
  if (isExcludeAttribute(attributeName, this.excludeAttribute)) {
@@ -9844,12 +9844,8 @@ class MutationBuffer {
9844
9844
  toLowerCase(attributeName),
9845
9845
  value
9846
9846
  );
9847
- if (value === item.attributes[attributeName] && !isIncludeAttribute(attributeName, this.includeAttribute)) {
9848
- delete item.attributes[attributeName];
9849
- if (Object.keys(item.attributes).length === 0) {
9850
- this.attributes = this.attributes.filter((a2) => a2 !== item);
9851
- this.attributeMap.delete(m.target);
9852
- }
9847
+ if (value === item.attributes[attributeName]) {
9848
+ console.debug("[rrweb-record] A questionable mutation that needs to be investigated in the future.");
9853
9849
  return;
9854
9850
  }
9855
9851
  if (attributeName === "style") {
@@ -12124,6 +12120,7 @@ let wrappedEmit;
12124
12120
  let takeFullSnapshot$1;
12125
12121
  let canvasManager;
12126
12122
  let recording = false;
12123
+ const preRecordingCustomEvents = [];
12127
12124
  try {
12128
12125
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
12129
12126
  const cleanFrame = document.createElement("iframe");
@@ -12163,6 +12160,7 @@ function record(options = {}) {
12163
12160
  recordCanvas = false,
12164
12161
  recordCrossOriginIframes = false,
12165
12162
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
12163
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
12166
12164
  userTriggeredOnInput = false,
12167
12165
  collectFonts = false,
12168
12166
  inlineImages = false,
@@ -12573,9 +12571,15 @@ function record(options = {}) {
12573
12571
  }
12574
12572
  });
12575
12573
  const init = () => {
12574
+ if (flushCustomQueue === "before") {
12575
+ flushPreRecordingEvents();
12576
+ }
12576
12577
  takeFullSnapshot$1();
12577
12578
  handlers.push(observe(document));
12578
12579
  recording = true;
12580
+ if (flushCustomQueue === "after") {
12581
+ flushPreRecordingEvents();
12582
+ }
12579
12583
  };
12580
12584
  if (document.readyState === "interactive" || document.readyState === "complete") {
12581
12585
  init();
@@ -12604,6 +12608,7 @@ function record(options = {}) {
12604
12608
  );
12605
12609
  }
12606
12610
  return () => {
12611
+ flushPreRecordingEvents();
12607
12612
  handlers.forEach((h) => h());
12608
12613
  processedNodeManager.destroy();
12609
12614
  recording = false;
@@ -12613,17 +12618,26 @@ function record(options = {}) {
12613
12618
  console.warn(error);
12614
12619
  }
12615
12620
  }
12616
- record.addCustomEvent = (tag, payload) => {
12617
- if (!recording) {
12618
- throw new Error("please add custom event after start recording");
12621
+ function flushPreRecordingEvents() {
12622
+ for (const e2 of preRecordingCustomEvents) {
12623
+ wrappedEmit(e2);
12619
12624
  }
12620
- wrappedEmit({
12625
+ preRecordingCustomEvents.length = 0;
12626
+ }
12627
+ record.addCustomEvent = (tag, payload) => {
12628
+ const customEvent = {
12621
12629
  type: EventType.Custom,
12622
12630
  data: {
12623
12631
  tag,
12624
12632
  payload
12625
12633
  }
12626
- });
12634
+ };
12635
+ if (!recording) {
12636
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
12637
+ preRecordingCustomEvents.push(customEvent);
12638
+ return;
12639
+ }
12640
+ wrappedEmit(customEvent);
12627
12641
  };
12628
12642
  record.freezePage = () => {
12629
12643
  mutationBuffers.forEach((buf) => buf.freeze());