@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.
@@ -12176,6 +12176,7 @@ let wrappedEmit;
12176
12176
  let takeFullSnapshot$1;
12177
12177
  let canvasManager;
12178
12178
  let recording = false;
12179
+ const preRecordingCustomEvents = [];
12179
12180
  try {
12180
12181
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
12181
12182
  const cleanFrame = document.createElement("iframe");
@@ -12215,6 +12216,7 @@ function record(options = {}) {
12215
12216
  recordCanvas = false,
12216
12217
  recordCrossOriginIframes = false,
12217
12218
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
12219
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
12218
12220
  userTriggeredOnInput = false,
12219
12221
  collectFonts = false,
12220
12222
  inlineImages = false,
@@ -12612,9 +12614,15 @@ function record(options = {}) {
12612
12614
  }
12613
12615
  });
12614
12616
  const init = () => {
12617
+ if (flushCustomQueue === "before") {
12618
+ flushPreRecordingEvents();
12619
+ }
12615
12620
  takeFullSnapshot$1();
12616
12621
  handlers.push(observe(document));
12617
12622
  recording = true;
12623
+ if (flushCustomQueue === "after") {
12624
+ flushPreRecordingEvents();
12625
+ }
12618
12626
  };
12619
12627
  if (document.readyState === "interactive" || document.readyState === "complete") {
12620
12628
  init();
@@ -12643,6 +12651,7 @@ function record(options = {}) {
12643
12651
  );
12644
12652
  }
12645
12653
  return () => {
12654
+ flushPreRecordingEvents();
12646
12655
  handlers.forEach((h) => h());
12647
12656
  processedNodeManager.destroy();
12648
12657
  recording = false;
@@ -12652,17 +12661,26 @@ function record(options = {}) {
12652
12661
  console.warn(error);
12653
12662
  }
12654
12663
  }
12655
- record.addCustomEvent = (tag, payload) => {
12656
- if (!recording) {
12657
- throw new Error("please add custom event after start recording");
12664
+ function flushPreRecordingEvents() {
12665
+ for (const e2 of preRecordingCustomEvents) {
12666
+ wrappedEmit(e2);
12658
12667
  }
12659
- wrappedEmit({
12668
+ preRecordingCustomEvents.length = 0;
12669
+ }
12670
+ record.addCustomEvent = (tag, payload) => {
12671
+ const customEvent = {
12660
12672
  type: EventType.Custom,
12661
12673
  data: {
12662
12674
  tag,
12663
12675
  payload
12664
12676
  }
12665
- });
12677
+ };
12678
+ if (!recording) {
12679
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
12680
+ preRecordingCustomEvents.push(customEvent);
12681
+ return;
12682
+ }
12683
+ wrappedEmit(customEvent);
12666
12684
  };
12667
12685
  record.freezePage = () => {
12668
12686
  mutationBuffers.forEach((buf) => buf.freeze());