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

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.
@@ -12124,6 +12124,7 @@ let wrappedEmit;
12124
12124
  let takeFullSnapshot$1;
12125
12125
  let canvasManager;
12126
12126
  let recording = false;
12127
+ const preRecordingCustomEvents = [];
12127
12128
  try {
12128
12129
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
12129
12130
  const cleanFrame = document.createElement("iframe");
@@ -12163,6 +12164,7 @@ function record(options = {}) {
12163
12164
  recordCanvas = false,
12164
12165
  recordCrossOriginIframes = false,
12165
12166
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
12167
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
12166
12168
  userTriggeredOnInput = false,
12167
12169
  collectFonts = false,
12168
12170
  inlineImages = false,
@@ -12573,9 +12575,15 @@ function record(options = {}) {
12573
12575
  }
12574
12576
  });
12575
12577
  const init = () => {
12578
+ if (flushCustomQueue === "before") {
12579
+ flushPreRecordingEvents();
12580
+ }
12576
12581
  takeFullSnapshot$1();
12577
12582
  handlers.push(observe(document));
12578
12583
  recording = true;
12584
+ if (flushCustomQueue === "after") {
12585
+ flushPreRecordingEvents();
12586
+ }
12579
12587
  };
12580
12588
  if (document.readyState === "interactive" || document.readyState === "complete") {
12581
12589
  init();
@@ -12604,6 +12612,7 @@ function record(options = {}) {
12604
12612
  );
12605
12613
  }
12606
12614
  return () => {
12615
+ flushPreRecordingEvents();
12607
12616
  handlers.forEach((h) => h());
12608
12617
  processedNodeManager.destroy();
12609
12618
  recording = false;
@@ -12613,17 +12622,26 @@ function record(options = {}) {
12613
12622
  console.warn(error);
12614
12623
  }
12615
12624
  }
12616
- record.addCustomEvent = (tag, payload) => {
12617
- if (!recording) {
12618
- throw new Error("please add custom event after start recording");
12625
+ function flushPreRecordingEvents() {
12626
+ for (const e2 of preRecordingCustomEvents) {
12627
+ wrappedEmit(e2);
12619
12628
  }
12620
- wrappedEmit({
12629
+ preRecordingCustomEvents.length = 0;
12630
+ }
12631
+ record.addCustomEvent = (tag, payload) => {
12632
+ const customEvent = {
12621
12633
  type: EventType.Custom,
12622
12634
  data: {
12623
12635
  tag,
12624
12636
  payload
12625
12637
  }
12626
- });
12638
+ };
12639
+ if (!recording) {
12640
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
12641
+ preRecordingCustomEvents.push(customEvent);
12642
+ return;
12643
+ }
12644
+ wrappedEmit(customEvent);
12627
12645
  };
12628
12646
  record.freezePage = () => {
12629
12647
  mutationBuffers.forEach((buf) => buf.freeze());