@appsurify-testmap/rrweb-record 2.1.1-alpha.7 → 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,14 @@ 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;
12520
12594
  function waitForDOMStabilization(win) {
12521
12595
  const maxWaitMs = 5e3;
12522
12596
  return new Promise((resolve2) => {
@@ -12886,7 +12960,7 @@ function record(options = {}) {
12886
12960
  mirror.getId(document)
12887
12961
  );
12888
12962
  };
12889
- flushCustomEventQueue = () => {
12963
+ flushCustomEventQueue$1 = () => {
12890
12964
  for (const e2 of customEventQueue) {
12891
12965
  wrappedEmit(e2);
12892
12966
  }
@@ -13029,37 +13103,34 @@ function record(options = {}) {
13029
13103
  });
13030
13104
  const init = () => {
13031
13105
  if (flushCustomEvent === "before") {
13032
- flushCustomEventQueue();
13106
+ flushCustomEventQueue$1();
13033
13107
  }
13034
13108
  takeFullSnapshot$1();
13035
13109
  handlers.push(observe(document));
13036
13110
  recording = true;
13037
13111
  if (flushCustomEvent === "after") {
13038
- flushCustomEventQueue();
13112
+ flushCustomEventQueue$1();
13039
13113
  }
13040
13114
  };
13041
13115
  const runInit = async () => {
13042
13116
  if (flushCustomEvent === "before") {
13043
- flushCustomEventQueue();
13117
+ flushCustomEventQueue$1();
13044
13118
  }
13045
13119
  if (recordAfter === "DOMContentStabilized") {
13046
- console.log(`[rrweb] 🟢 Waiting for DOM stabilization...`);
13120
+ console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
13047
13121
  await waitForDOMStabilization(window);
13048
- console.log(`[rrweb] ✅ DOM stabilized, starting recording`);
13122
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
13049
13123
  }
13124
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
13050
13125
  takeFullSnapshot$1();
13051
13126
  handlers.push(observe(document));
13052
13127
  recording = true;
13053
13128
  if (flushCustomEvent === "after") {
13054
- flushCustomEventQueue();
13129
+ flushCustomEventQueue$1();
13055
13130
  }
13056
13131
  };
13057
13132
  if (document.readyState === "interactive" || document.readyState === "complete") {
13058
- if (recordAfter === "DOMContentStabilized") {
13059
- void runInit();
13060
- } else {
13061
- init();
13062
- }
13133
+ init();
13063
13134
  } else {
13064
13135
  handlers.push(
13065
13136
  on("DOMContentLoaded", () => {
@@ -13067,9 +13138,7 @@ function record(options = {}) {
13067
13138
  type: EventType.DomContentLoaded,
13068
13139
  data: {}
13069
13140
  });
13070
- if (recordAfter === "DOMContentLoaded" || recordAfter === "DOMContentStabilized") {
13071
- void runInit();
13072
- }
13141
+ if (recordAfter === "DOMContentLoaded") init();
13073
13142
  })
13074
13143
  );
13075
13144
  handlers.push(
@@ -13080,14 +13149,14 @@ function record(options = {}) {
13080
13149
  type: EventType.Load,
13081
13150
  data: {}
13082
13151
  });
13083
- if (recordAfter === "load") void runInit();
13152
+ if (recordAfter === "load") init();
13084
13153
  },
13085
13154
  window
13086
13155
  )
13087
13156
  );
13088
13157
  }
13089
13158
  return () => {
13090
- flushCustomEventQueue();
13159
+ flushCustomEventQueue$1();
13091
13160
  handlers.forEach((h) => h());
13092
13161
  processedNodeManager.destroy();
13093
13162
  recording = false;
@@ -13097,10 +13166,11 @@ function record(options = {}) {
13097
13166
  console.warn(error);
13098
13167
  }
13099
13168
  }
13169
+ record.getVersion = () => version$1;
13100
13170
  record.isRecording = () => recording;
13101
13171
  record.flushCustomEventQueue = () => {
13102
13172
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
13103
- flushCustomEventQueue();
13173
+ flushCustomEventQueue$1();
13104
13174
  };
13105
13175
  record.addCustomEvent = (tag, payload) => {
13106
13176
  const customEvent = {