@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.
@@ -14031,6 +14031,7 @@ let wrappedEmit;
14031
14031
  let takeFullSnapshot$1;
14032
14032
  let canvasManager;
14033
14033
  let recording = false;
14034
+ const preRecordingCustomEvents = [];
14034
14035
  try {
14035
14036
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14036
14037
  const cleanFrame = document.createElement("iframe");
@@ -14070,6 +14071,7 @@ function record(options = {}) {
14070
14071
  recordCanvas = false,
14071
14072
  recordCrossOriginIframes = false,
14072
14073
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
14074
+ flushCustomQueue = options.flushCustomQueue !== void 0 ? options.flushCustomQueue : "after",
14073
14075
  userTriggeredOnInput = false,
14074
14076
  collectFonts = false,
14075
14077
  inlineImages = false,
@@ -14480,9 +14482,15 @@ function record(options = {}) {
14480
14482
  }
14481
14483
  });
14482
14484
  const init = () => {
14485
+ if (flushCustomQueue === "before") {
14486
+ flushPreRecordingEvents();
14487
+ }
14483
14488
  takeFullSnapshot$1();
14484
14489
  handlers.push(observe(document));
14485
14490
  recording = true;
14491
+ if (flushCustomQueue === "after") {
14492
+ flushPreRecordingEvents();
14493
+ }
14486
14494
  };
14487
14495
  if (document.readyState === "interactive" || document.readyState === "complete") {
14488
14496
  init();
@@ -14511,6 +14519,7 @@ function record(options = {}) {
14511
14519
  );
14512
14520
  }
14513
14521
  return () => {
14522
+ flushPreRecordingEvents();
14514
14523
  handlers.forEach((h) => h());
14515
14524
  processedNodeManager.destroy();
14516
14525
  recording = false;
@@ -14520,17 +14529,26 @@ function record(options = {}) {
14520
14529
  console.warn(error);
14521
14530
  }
14522
14531
  }
14523
- record.addCustomEvent = (tag, payload) => {
14524
- if (!recording) {
14525
- throw new Error("please add custom event after start recording");
14532
+ function flushPreRecordingEvents() {
14533
+ for (const e2 of preRecordingCustomEvents) {
14534
+ wrappedEmit(e2);
14526
14535
  }
14527
- wrappedEmit({
14536
+ preRecordingCustomEvents.length = 0;
14537
+ }
14538
+ record.addCustomEvent = (tag, payload) => {
14539
+ const customEvent = {
14528
14540
  type: EventType.Custom,
14529
14541
  data: {
14530
14542
  tag,
14531
14543
  payload
14532
14544
  }
14533
- });
14545
+ };
14546
+ if (!recording) {
14547
+ console.warn(`[rrweb] CustomEvent buffered before recording start: ${tag}`);
14548
+ preRecordingCustomEvents.push(customEvent);
14549
+ return;
14550
+ }
14551
+ wrappedEmit(customEvent);
14534
14552
  };
14535
14553
  record.freezePage = () => {
14536
14554
  mutationBuffers.forEach((buf) => buf.freeze());