@appsurify-testmap/rrweb-record 2.1.1-alpha.7 → 2.1.2-alpha.2

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.
@@ -808,10 +808,13 @@ function inspectInlineEventHandlers$1() {
808
808
  });
809
809
  });
810
810
  }
811
- if (document.readyState === "complete" || document.readyState === "interactive") {
812
- inspectInlineEventHandlers$1();
813
- } else {
814
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
811
+ try {
812
+ if (document.readyState === "complete" || document.readyState === "interactive") {
813
+ inspectInlineEventHandlers$1();
814
+ } else {
815
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
816
+ }
817
+ } catch (error) {
815
818
  }
816
819
  let _id = 1;
817
820
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -5363,10 +5366,13 @@ function inspectInlineEventHandlers() {
5363
5366
  });
5364
5367
  });
5365
5368
  }
5366
- if (document.readyState === "complete" || document.readyState === "interactive") {
5367
- inspectInlineEventHandlers();
5368
- } else {
5369
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5369
+ try {
5370
+ if (document.readyState === "complete" || document.readyState === "interactive") {
5371
+ inspectInlineEventHandlers();
5372
+ } else {
5373
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5374
+ }
5375
+ } catch (error) {
5370
5376
  }
5371
5377
  function getDefaultExportFromCjs(x2) {
5372
5378
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -10470,6 +10476,8 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
10470
10476
  }
10471
10477
  const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
10472
10478
  const lastInputValueMap = /* @__PURE__ */ new WeakMap();
10479
+ const FINALIZING_KEYS = ["Enter", "Tab", "Escape", "ArrowDown", "ArrowUp", "Delete"];
10480
+ const lastKeyInputValueMap = /* @__PURE__ */ new WeakMap();
10473
10481
  function initInputObserver({
10474
10482
  inputCb,
10475
10483
  doc,
@@ -10542,6 +10550,22 @@ function initInputObserver({
10542
10550
  const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
10543
10551
  const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
10544
10552
  if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
10553
+ console.debug(
10554
+ `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
10555
+ {
10556
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
10557
+ node: index.describeNode(el),
10558
+ tag: el.tagName,
10559
+ nodeType: el.nodeType,
10560
+ attribute: el.attributes,
10561
+ value: el.value,
10562
+ isLikelyPhantom,
10563
+ isRenderDrivenTextInput,
10564
+ isValueFromDefault,
10565
+ isPhantomCheckbox,
10566
+ isPhantomRadio
10567
+ }
10568
+ );
10545
10569
  return;
10546
10570
  }
10547
10571
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
@@ -10557,6 +10581,61 @@ function initInputObserver({
10557
10581
  const handlers = events.map(
10558
10582
  (eventName) => on(eventName, callbackWrapper(eventHandler), doc)
10559
10583
  );
10584
+ const keyboardHandler = (event) => {
10585
+ const target = getEventTarget(event);
10586
+ if (!target || !target.tagName) return;
10587
+ if (sampling.input === "all") {
10588
+ eventHandler(event);
10589
+ return;
10590
+ }
10591
+ const tag = target.tagName;
10592
+ const key = event.key;
10593
+ const isFinalizingKey = FINALIZING_KEYS.includes(key);
10594
+ const isTextarea = tag === "TEXTAREA";
10595
+ const isFocused = doc.activeElement === target;
10596
+ const valueNow = target.value;
10597
+ const valueBefore = lastKeyInputValueMap.get(target);
10598
+ lastKeyInputValueMap.set(target, valueNow);
10599
+ if (!isFocused) {
10600
+ eventHandler(event);
10601
+ return;
10602
+ }
10603
+ if (isFinalizingKey) {
10604
+ if (!isTextarea) {
10605
+ eventHandler(event);
10606
+ return;
10607
+ }
10608
+ let lastValue = valueBefore ?? "";
10609
+ let unchangedCount = 0;
10610
+ const REQUIRED_STABLE_FRAMES = 2;
10611
+ const checkFinal = () => {
10612
+ const currentValue = target.value;
10613
+ const stillFocused = doc.activeElement === target;
10614
+ const changed = currentValue !== lastValue;
10615
+ if (!stillFocused) {
10616
+ eventHandler(event);
10617
+ return;
10618
+ }
10619
+ if (!changed) {
10620
+ unchangedCount++;
10621
+ if (unchangedCount >= REQUIRED_STABLE_FRAMES) {
10622
+ eventHandler(event);
10623
+ return;
10624
+ }
10625
+ } else {
10626
+ unchangedCount = 0;
10627
+ lastValue = currentValue;
10628
+ }
10629
+ requestAnimationFrame(checkFinal);
10630
+ };
10631
+ requestAnimationFrame(checkFinal);
10632
+ return;
10633
+ }
10634
+ };
10635
+ handlers.push(
10636
+ on("keydown", callbackWrapper(keyboardHandler), doc)
10637
+ // on('keypress', callbackWrapper(keyboardHandler), doc),
10638
+ );
10560
10639
  const currentWindow = doc.defaultView;
10561
10640
  if (!currentWindow) {
10562
10641
  return () => {
@@ -12510,13 +12589,14 @@ class VisibilityManager {
12510
12589
  if (this.rafId) cancelAnimationFrame(this.rafId);
12511
12590
  }
12512
12591
  }
12592
+ const version$1 = "2.1.2-alpha.2";
12513
12593
  let wrappedEmit;
12514
12594
  let takeFullSnapshot$1;
12515
12595
  let canvasManager;
12516
12596
  let visibilityManager;
12517
12597
  let recording = false;
12518
12598
  const customEventQueue = [];
12519
- let flushCustomEventQueue;
12599
+ let flushCustomEventQueue$1;
12520
12600
  function waitForDOMStabilization(win) {
12521
12601
  const maxWaitMs = 5e3;
12522
12602
  return new Promise((resolve2) => {
@@ -12886,7 +12966,7 @@ function record(options = {}) {
12886
12966
  mirror.getId(document)
12887
12967
  );
12888
12968
  };
12889
- flushCustomEventQueue = () => {
12969
+ flushCustomEventQueue$1 = () => {
12890
12970
  for (const e2 of customEventQueue) {
12891
12971
  wrappedEmit(e2);
12892
12972
  }
@@ -13029,37 +13109,34 @@ function record(options = {}) {
13029
13109
  });
13030
13110
  const init = () => {
13031
13111
  if (flushCustomEvent === "before") {
13032
- flushCustomEventQueue();
13112
+ flushCustomEventQueue$1();
13033
13113
  }
13034
13114
  takeFullSnapshot$1();
13035
13115
  handlers.push(observe(document));
13036
13116
  recording = true;
13037
13117
  if (flushCustomEvent === "after") {
13038
- flushCustomEventQueue();
13118
+ flushCustomEventQueue$1();
13039
13119
  }
13040
13120
  };
13041
13121
  const runInit = async () => {
13042
13122
  if (flushCustomEvent === "before") {
13043
- flushCustomEventQueue();
13123
+ flushCustomEventQueue$1();
13044
13124
  }
13045
13125
  if (recordAfter === "DOMContentStabilized") {
13046
- console.log(`[rrweb] 🟢 Waiting for DOM stabilization...`);
13126
+ console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
13047
13127
  await waitForDOMStabilization(window);
13048
- console.log(`[rrweb] ✅ DOM stabilized, starting recording`);
13128
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
13049
13129
  }
13130
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
13050
13131
  takeFullSnapshot$1();
13051
13132
  handlers.push(observe(document));
13052
13133
  recording = true;
13053
13134
  if (flushCustomEvent === "after") {
13054
- flushCustomEventQueue();
13135
+ flushCustomEventQueue$1();
13055
13136
  }
13056
13137
  };
13057
13138
  if (document.readyState === "interactive" || document.readyState === "complete") {
13058
- if (recordAfter === "DOMContentStabilized") {
13059
- void runInit();
13060
- } else {
13061
- init();
13062
- }
13139
+ init();
13063
13140
  } else {
13064
13141
  handlers.push(
13065
13142
  on("DOMContentLoaded", () => {
@@ -13067,9 +13144,7 @@ function record(options = {}) {
13067
13144
  type: EventType.DomContentLoaded,
13068
13145
  data: {}
13069
13146
  });
13070
- if (recordAfter === "DOMContentLoaded" || recordAfter === "DOMContentStabilized") {
13071
- void runInit();
13072
- }
13147
+ if (recordAfter === "DOMContentLoaded") init();
13073
13148
  })
13074
13149
  );
13075
13150
  handlers.push(
@@ -13080,14 +13155,14 @@ function record(options = {}) {
13080
13155
  type: EventType.Load,
13081
13156
  data: {}
13082
13157
  });
13083
- if (recordAfter === "load") void runInit();
13158
+ if (recordAfter === "load") init();
13084
13159
  },
13085
13160
  window
13086
13161
  )
13087
13162
  );
13088
13163
  }
13089
13164
  return () => {
13090
- flushCustomEventQueue();
13165
+ flushCustomEventQueue$1();
13091
13166
  handlers.forEach((h) => h());
13092
13167
  processedNodeManager.destroy();
13093
13168
  recording = false;
@@ -13097,10 +13172,11 @@ function record(options = {}) {
13097
13172
  console.warn(error);
13098
13173
  }
13099
13174
  }
13175
+ record.getVersion = () => version$1;
13100
13176
  record.isRecording = () => recording;
13101
13177
  record.flushCustomEventQueue = () => {
13102
13178
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
13103
- flushCustomEventQueue();
13179
+ flushCustomEventQueue$1();
13104
13180
  };
13105
13181
  record.addCustomEvent = (tag, payload) => {
13106
13182
  const customEvent = {