@appsurify-testmap/rrweb 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.
package/dist/rrweb.cjs CHANGED
@@ -11700,7 +11700,7 @@ class MutationBuffer {
11700
11700
  let value = m.target.getAttribute(attributeName);
11701
11701
  const propValue = target[attributeName];
11702
11702
  const isPhantomAttributeMutation = value === null && !target.hasAttribute(attributeName) && m.oldValue !== null && (propValue === "" || propValue === null || typeof propValue === "undefined");
11703
- if (isPhantomAttributeMutation && !isIncludeAttribute(attributeName, this.includeAttribute)) {
11703
+ if (isPhantomAttributeMutation) {
11704
11704
  return;
11705
11705
  }
11706
11706
  if (isExcludeAttribute(attributeName, this.excludeAttribute)) {
@@ -11748,12 +11748,8 @@ class MutationBuffer {
11748
11748
  toLowerCase(attributeName),
11749
11749
  value
11750
11750
  );
11751
- if (value === item.attributes[attributeName] && !isIncludeAttribute(attributeName, this.includeAttribute)) {
11752
- delete item.attributes[attributeName];
11753
- if (Object.keys(item.attributes).length === 0) {
11754
- this.attributes = this.attributes.filter((a2) => a2 !== item);
11755
- this.attributeMap.delete(m.target);
11756
- }
11751
+ if (value === item.attributes[attributeName]) {
11752
+ console.debug("[rrweb-record] A questionable mutation that needs to be investigated in the future.");
11757
11753
  return;
11758
11754
  }
11759
11755
  if (attributeName === "style") {
@@ -14051,6 +14047,7 @@ let wrappedEmit;
14051
14047
  let takeFullSnapshot$1;
14052
14048
  let canvasManager;
14053
14049
  let recording = false;
14050
+ const preRecordingCustomEvents = [];
14054
14051
  try {
14055
14052
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14056
14053
  const cleanFrame = document.createElement("iframe");
@@ -14090,6 +14087,7 @@ function record(options = {}) {
14090
14087
  recordCanvas = false,
14091
14088
  recordCrossOriginIframes = false,
14092
14089
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
14090
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
14093
14091
  userTriggeredOnInput = false,
14094
14092
  collectFonts = false,
14095
14093
  inlineImages = false,
@@ -14500,9 +14498,15 @@ function record(options = {}) {
14500
14498
  }
14501
14499
  });
14502
14500
  const init = () => {
14501
+ if (flushCustomQueue === "before") {
14502
+ flushPreRecordingEvents();
14503
+ }
14503
14504
  takeFullSnapshot$1();
14504
14505
  handlers.push(observe(document));
14505
14506
  recording = true;
14507
+ if (flushCustomQueue === "after") {
14508
+ flushPreRecordingEvents();
14509
+ }
14506
14510
  };
14507
14511
  if (document.readyState === "interactive" || document.readyState === "complete") {
14508
14512
  init();
@@ -14531,6 +14535,7 @@ function record(options = {}) {
14531
14535
  );
14532
14536
  }
14533
14537
  return () => {
14538
+ flushPreRecordingEvents();
14534
14539
  handlers.forEach((h) => h());
14535
14540
  processedNodeManager.destroy();
14536
14541
  recording = false;
@@ -14540,17 +14545,26 @@ function record(options = {}) {
14540
14545
  console.warn(error);
14541
14546
  }
14542
14547
  }
14543
- record.addCustomEvent = (tag, payload) => {
14544
- if (!recording) {
14545
- throw new Error("please add custom event after start recording");
14548
+ function flushPreRecordingEvents() {
14549
+ for (const e2 of preRecordingCustomEvents) {
14550
+ wrappedEmit(e2);
14546
14551
  }
14547
- wrappedEmit({
14552
+ preRecordingCustomEvents.length = 0;
14553
+ }
14554
+ record.addCustomEvent = (tag, payload) => {
14555
+ const customEvent = {
14548
14556
  type: EventType.Custom,
14549
14557
  data: {
14550
14558
  tag,
14551
14559
  payload
14552
14560
  }
14553
- });
14561
+ };
14562
+ if (!recording) {
14563
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
14564
+ preRecordingCustomEvents.push(customEvent);
14565
+ return;
14566
+ }
14567
+ wrappedEmit(customEvent);
14554
14568
  };
14555
14569
  record.freezePage = () => {
14556
14570
  mutationBuffers.forEach((buf) => buf.freeze());