@appsurify-testmap/rrweb-all 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.
@@ -14083,6 +14083,7 @@ let wrappedEmit;
14083
14083
  let takeFullSnapshot$1;
14084
14084
  let canvasManager;
14085
14085
  let recording = false;
14086
+ const preRecordingCustomEvents = [];
14086
14087
  try {
14087
14088
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14088
14089
  const cleanFrame = document.createElement("iframe");
@@ -14122,6 +14123,7 @@ function record(options = {}) {
14122
14123
  recordCanvas = false,
14123
14124
  recordCrossOriginIframes = false,
14124
14125
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
14126
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
14125
14127
  userTriggeredOnInput = false,
14126
14128
  collectFonts = false,
14127
14129
  inlineImages = false,
@@ -14519,9 +14521,15 @@ function record(options = {}) {
14519
14521
  }
14520
14522
  });
14521
14523
  const init = () => {
14524
+ if (flushCustomQueue === "before") {
14525
+ flushPreRecordingEvents();
14526
+ }
14522
14527
  takeFullSnapshot$1();
14523
14528
  handlers.push(observe(document));
14524
14529
  recording = true;
14530
+ if (flushCustomQueue === "after") {
14531
+ flushPreRecordingEvents();
14532
+ }
14525
14533
  };
14526
14534
  if (document.readyState === "interactive" || document.readyState === "complete") {
14527
14535
  init();
@@ -14550,6 +14558,7 @@ function record(options = {}) {
14550
14558
  );
14551
14559
  }
14552
14560
  return () => {
14561
+ flushPreRecordingEvents();
14553
14562
  handlers.forEach((h) => h());
14554
14563
  processedNodeManager.destroy();
14555
14564
  recording = false;
@@ -14559,17 +14568,26 @@ function record(options = {}) {
14559
14568
  console.warn(error);
14560
14569
  }
14561
14570
  }
14562
- record.addCustomEvent = (tag, payload) => {
14563
- if (!recording) {
14564
- throw new Error("please add custom event after start recording");
14571
+ function flushPreRecordingEvents() {
14572
+ for (const e2 of preRecordingCustomEvents) {
14573
+ wrappedEmit(e2);
14565
14574
  }
14566
- wrappedEmit({
14575
+ preRecordingCustomEvents.length = 0;
14576
+ }
14577
+ record.addCustomEvent = (tag, payload) => {
14578
+ const customEvent = {
14567
14579
  type: EventType.Custom,
14568
14580
  data: {
14569
14581
  tag,
14570
14582
  payload
14571
14583
  }
14572
- });
14584
+ };
14585
+ if (!recording) {
14586
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
14587
+ preRecordingCustomEvents.push(customEvent);
14588
+ return;
14589
+ }
14590
+ wrappedEmit(customEvent);
14573
14591
  };
14574
14592
  record.freezePage = () => {
14575
14593
  mutationBuffers.forEach((buf) => buf.freeze());