@appsurify-testmap/rrweb-record 2.1.1-alpha.6 → 2.1.2-alpha.1

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.
@@ -10470,6 +10470,8 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
10470
10470
  }
10471
10471
  const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
10472
10472
  const lastInputValueMap = /* @__PURE__ */ new WeakMap();
10473
+ const FINALIZING_KEYS = ["Enter", "Tab", "Escape", "ArrowDown", "ArrowUp", "Delete"];
10474
+ const lastKeyInputValueMap = /* @__PURE__ */ new WeakMap();
10473
10475
  function initInputObserver({
10474
10476
  inputCb,
10475
10477
  doc,
@@ -10542,6 +10544,22 @@ function initInputObserver({
10542
10544
  const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
10543
10545
  const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
10544
10546
  if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
10547
+ console.debug(
10548
+ `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
10549
+ {
10550
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
10551
+ node: index.describeNode(el),
10552
+ tag: el.tagName,
10553
+ nodeType: el.nodeType,
10554
+ attribute: el.attributes,
10555
+ value: el.value,
10556
+ isLikelyPhantom,
10557
+ isRenderDrivenTextInput,
10558
+ isValueFromDefault,
10559
+ isPhantomCheckbox,
10560
+ isPhantomRadio
10561
+ }
10562
+ );
10545
10563
  return;
10546
10564
  }
10547
10565
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
@@ -10557,6 +10575,61 @@ function initInputObserver({
10557
10575
  const handlers = events.map(
10558
10576
  (eventName) => on(eventName, callbackWrapper(eventHandler), doc)
10559
10577
  );
10578
+ const keyboardHandler = (event) => {
10579
+ const target = getEventTarget(event);
10580
+ if (!target || !target.tagName) return;
10581
+ if (sampling.input === "all") {
10582
+ eventHandler(event);
10583
+ return;
10584
+ }
10585
+ const tag = target.tagName;
10586
+ const key = event.key;
10587
+ const isFinalizingKey = FINALIZING_KEYS.includes(key);
10588
+ const isTextarea = tag === "TEXTAREA";
10589
+ const isFocused = doc.activeElement === target;
10590
+ const valueNow = target.value;
10591
+ const valueBefore = lastKeyInputValueMap.get(target);
10592
+ lastKeyInputValueMap.set(target, valueNow);
10593
+ if (!isFocused) {
10594
+ eventHandler(event);
10595
+ return;
10596
+ }
10597
+ if (isFinalizingKey) {
10598
+ if (!isTextarea) {
10599
+ eventHandler(event);
10600
+ return;
10601
+ }
10602
+ let lastValue = valueBefore ?? "";
10603
+ let unchangedCount = 0;
10604
+ const REQUIRED_STABLE_FRAMES = 2;
10605
+ const checkFinal = () => {
10606
+ const currentValue = target.value;
10607
+ const stillFocused = doc.activeElement === target;
10608
+ const changed = currentValue !== lastValue;
10609
+ if (!stillFocused) {
10610
+ eventHandler(event);
10611
+ return;
10612
+ }
10613
+ if (!changed) {
10614
+ unchangedCount++;
10615
+ if (unchangedCount >= REQUIRED_STABLE_FRAMES) {
10616
+ eventHandler(event);
10617
+ return;
10618
+ }
10619
+ } else {
10620
+ unchangedCount = 0;
10621
+ lastValue = currentValue;
10622
+ }
10623
+ requestAnimationFrame(checkFinal);
10624
+ };
10625
+ requestAnimationFrame(checkFinal);
10626
+ return;
10627
+ }
10628
+ };
10629
+ handlers.push(
10630
+ on("keydown", callbackWrapper(keyboardHandler), doc)
10631
+ // on('keypress', callbackWrapper(keyboardHandler), doc),
10632
+ );
10560
10633
  const currentWindow = doc.defaultView;
10561
10634
  if (!currentWindow) {
10562
10635
  return () => {
@@ -12510,13 +12583,44 @@ class VisibilityManager {
12510
12583
  if (this.rafId) cancelAnimationFrame(this.rafId);
12511
12584
  }
12512
12585
  }
12586
+ const version$1 = "2.1.2-alpha.1";
12513
12587
  let wrappedEmit;
12514
12588
  let takeFullSnapshot$1;
12515
12589
  let canvasManager;
12516
12590
  let visibilityManager;
12517
12591
  let recording = false;
12518
12592
  const customEventQueue = [];
12519
- let flushCustomEventQueue;
12593
+ let flushCustomEventQueue$1;
12594
+ function waitForDOMStabilization(win) {
12595
+ const maxWaitMs = 5e3;
12596
+ return new Promise((resolve2) => {
12597
+ const captureAfterPaint = () => {
12598
+ requestAnimationFrame(() => {
12599
+ requestAnimationFrame(() => {
12600
+ resolve2();
12601
+ });
12602
+ });
12603
+ };
12604
+ const safeResolve = /* @__PURE__ */ (() => {
12605
+ let called = false;
12606
+ return () => {
12607
+ if (!called) {
12608
+ called = true;
12609
+ captureAfterPaint();
12610
+ }
12611
+ };
12612
+ })();
12613
+ if (["interactive", "complete"].includes(win.document.readyState)) {
12614
+ safeResolve();
12615
+ } else {
12616
+ win.addEventListener("DOMContentLoaded", safeResolve, { once: true });
12617
+ win.addEventListener("load", safeResolve, { once: true });
12618
+ setTimeout(() => {
12619
+ safeResolve();
12620
+ }, maxWaitMs);
12621
+ }
12622
+ });
12623
+ }
12520
12624
  try {
12521
12625
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
12522
12626
  const cleanFrame = document.createElement("iframe");
@@ -12856,7 +12960,7 @@ function record(options = {}) {
12856
12960
  mirror.getId(document)
12857
12961
  );
12858
12962
  };
12859
- flushCustomEventQueue = () => {
12963
+ flushCustomEventQueue$1 = () => {
12860
12964
  for (const e2 of customEventQueue) {
12861
12965
  wrappedEmit(e2);
12862
12966
  }
@@ -12999,13 +13103,30 @@ function record(options = {}) {
12999
13103
  });
13000
13104
  const init = () => {
13001
13105
  if (flushCustomEvent === "before") {
13002
- flushCustomEventQueue();
13106
+ flushCustomEventQueue$1();
13107
+ }
13108
+ takeFullSnapshot$1();
13109
+ handlers.push(observe(document));
13110
+ recording = true;
13111
+ if (flushCustomEvent === "after") {
13112
+ flushCustomEventQueue$1();
13113
+ }
13114
+ };
13115
+ const runInit = async () => {
13116
+ if (flushCustomEvent === "before") {
13117
+ flushCustomEventQueue$1();
13118
+ }
13119
+ if (recordAfter === "DOMContentStabilized") {
13120
+ console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
13121
+ await waitForDOMStabilization(window);
13122
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
13003
13123
  }
13124
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
13004
13125
  takeFullSnapshot$1();
13005
13126
  handlers.push(observe(document));
13006
13127
  recording = true;
13007
13128
  if (flushCustomEvent === "after") {
13008
- flushCustomEventQueue();
13129
+ flushCustomEventQueue$1();
13009
13130
  }
13010
13131
  };
13011
13132
  if (document.readyState === "interactive" || document.readyState === "complete") {
@@ -13035,7 +13156,7 @@ function record(options = {}) {
13035
13156
  );
13036
13157
  }
13037
13158
  return () => {
13038
- flushCustomEventQueue();
13159
+ flushCustomEventQueue$1();
13039
13160
  handlers.forEach((h) => h());
13040
13161
  processedNodeManager.destroy();
13041
13162
  recording = false;
@@ -13045,9 +13166,11 @@ function record(options = {}) {
13045
13166
  console.warn(error);
13046
13167
  }
13047
13168
  }
13169
+ record.getVersion = () => version$1;
13170
+ record.isRecording = () => recording;
13048
13171
  record.flushCustomEventQueue = () => {
13049
13172
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
13050
- flushCustomEventQueue();
13173
+ flushCustomEventQueue$1();
13051
13174
  };
13052
13175
  record.addCustomEvent = (tag, payload) => {
13053
13176
  const customEvent = {