@appsurify-testmap/rrweb 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.
package/dist/rrweb.cjs CHANGED
@@ -14051,6 +14051,7 @@ let wrappedEmit;
14051
14051
  let takeFullSnapshot$1;
14052
14052
  let canvasManager;
14053
14053
  let recording = false;
14054
+ const preRecordingCustomEvents = [];
14054
14055
  try {
14055
14056
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14056
14057
  const cleanFrame = document.createElement("iframe");
@@ -14090,6 +14091,7 @@ function record(options = {}) {
14090
14091
  recordCanvas = false,
14091
14092
  recordCrossOriginIframes = false,
14092
14093
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
14094
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
14093
14095
  userTriggeredOnInput = false,
14094
14096
  collectFonts = false,
14095
14097
  inlineImages = false,
@@ -14500,9 +14502,15 @@ function record(options = {}) {
14500
14502
  }
14501
14503
  });
14502
14504
  const init = () => {
14505
+ if (flushCustomQueue === "before") {
14506
+ flushPreRecordingEvents();
14507
+ }
14503
14508
  takeFullSnapshot$1();
14504
14509
  handlers.push(observe(document));
14505
14510
  recording = true;
14511
+ if (flushCustomQueue === "after") {
14512
+ flushPreRecordingEvents();
14513
+ }
14506
14514
  };
14507
14515
  if (document.readyState === "interactive" || document.readyState === "complete") {
14508
14516
  init();
@@ -14531,6 +14539,7 @@ function record(options = {}) {
14531
14539
  );
14532
14540
  }
14533
14541
  return () => {
14542
+ flushPreRecordingEvents();
14534
14543
  handlers.forEach((h) => h());
14535
14544
  processedNodeManager.destroy();
14536
14545
  recording = false;
@@ -14540,17 +14549,26 @@ function record(options = {}) {
14540
14549
  console.warn(error);
14541
14550
  }
14542
14551
  }
14543
- record.addCustomEvent = (tag, payload) => {
14544
- if (!recording) {
14545
- throw new Error("please add custom event after start recording");
14552
+ function flushPreRecordingEvents() {
14553
+ for (const e2 of preRecordingCustomEvents) {
14554
+ wrappedEmit(e2);
14546
14555
  }
14547
- wrappedEmit({
14556
+ preRecordingCustomEvents.length = 0;
14557
+ }
14558
+ record.addCustomEvent = (tag, payload) => {
14559
+ const customEvent = {
14548
14560
  type: EventType.Custom,
14549
14561
  data: {
14550
14562
  tag,
14551
14563
  payload
14552
14564
  }
14553
- });
14565
+ };
14566
+ if (!recording) {
14567
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
14568
+ preRecordingCustomEvents.push(customEvent);
14569
+ return;
14570
+ }
14571
+ wrappedEmit(customEvent);
14554
14572
  };
14555
14573
  record.freezePage = () => {
14556
14574
  mutationBuffers.forEach((buf) => buf.freeze());