@appsurify-testmap/rrweb 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.
package/dist/rrweb.cjs CHANGED
@@ -12377,6 +12377,8 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
12377
12377
  }
12378
12378
  const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
12379
12379
  const lastInputValueMap = /* @__PURE__ */ new WeakMap();
12380
+ const FINALIZING_KEYS = ["Enter", "Tab", "Escape", "ArrowDown", "ArrowUp", "Delete"];
12381
+ const lastKeyInputValueMap = /* @__PURE__ */ new WeakMap();
12380
12382
  function initInputObserver({
12381
12383
  inputCb,
12382
12384
  doc,
@@ -12449,6 +12451,22 @@ function initInputObserver({
12449
12451
  const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12450
12452
  const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12451
12453
  if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
12454
+ console.debug(
12455
+ `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
12456
+ {
12457
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
12458
+ node: index.describeNode(el),
12459
+ tag: el.tagName,
12460
+ nodeType: el.nodeType,
12461
+ attribute: el.attributes,
12462
+ value: el.value,
12463
+ isLikelyPhantom,
12464
+ isRenderDrivenTextInput,
12465
+ isValueFromDefault,
12466
+ isPhantomCheckbox,
12467
+ isPhantomRadio
12468
+ }
12469
+ );
12452
12470
  return;
12453
12471
  }
12454
12472
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
@@ -12464,6 +12482,61 @@ function initInputObserver({
12464
12482
  const handlers = events.map(
12465
12483
  (eventName) => on(eventName, callbackWrapper(eventHandler), doc)
12466
12484
  );
12485
+ const keyboardHandler = (event) => {
12486
+ const target = getEventTarget(event);
12487
+ if (!target || !target.tagName) return;
12488
+ if (sampling.input === "all") {
12489
+ eventHandler(event);
12490
+ return;
12491
+ }
12492
+ const tag = target.tagName;
12493
+ const key = event.key;
12494
+ const isFinalizingKey = FINALIZING_KEYS.includes(key);
12495
+ const isTextarea = tag === "TEXTAREA";
12496
+ const isFocused = doc.activeElement === target;
12497
+ const valueNow = target.value;
12498
+ const valueBefore = lastKeyInputValueMap.get(target);
12499
+ lastKeyInputValueMap.set(target, valueNow);
12500
+ if (!isFocused) {
12501
+ eventHandler(event);
12502
+ return;
12503
+ }
12504
+ if (isFinalizingKey) {
12505
+ if (!isTextarea) {
12506
+ eventHandler(event);
12507
+ return;
12508
+ }
12509
+ let lastValue = valueBefore ?? "";
12510
+ let unchangedCount = 0;
12511
+ const REQUIRED_STABLE_FRAMES = 2;
12512
+ const checkFinal = () => {
12513
+ const currentValue = target.value;
12514
+ const stillFocused = doc.activeElement === target;
12515
+ const changed = currentValue !== lastValue;
12516
+ if (!stillFocused) {
12517
+ eventHandler(event);
12518
+ return;
12519
+ }
12520
+ if (!changed) {
12521
+ unchangedCount++;
12522
+ if (unchangedCount >= REQUIRED_STABLE_FRAMES) {
12523
+ eventHandler(event);
12524
+ return;
12525
+ }
12526
+ } else {
12527
+ unchangedCount = 0;
12528
+ lastValue = currentValue;
12529
+ }
12530
+ requestAnimationFrame(checkFinal);
12531
+ };
12532
+ requestAnimationFrame(checkFinal);
12533
+ return;
12534
+ }
12535
+ };
12536
+ handlers.push(
12537
+ on("keydown", callbackWrapper(keyboardHandler), doc)
12538
+ // on('keypress', callbackWrapper(keyboardHandler), doc),
12539
+ );
12467
12540
  const currentWindow = doc.defaultView;
12468
12541
  if (!currentWindow) {
12469
12542
  return () => {
@@ -14437,13 +14510,14 @@ class VisibilityManager {
14437
14510
  if (this.rafId) cancelAnimationFrame(this.rafId);
14438
14511
  }
14439
14512
  }
14513
+ const version$1 = "2.1.2-alpha.1";
14440
14514
  let wrappedEmit;
14441
14515
  let takeFullSnapshot$1;
14442
14516
  let canvasManager;
14443
14517
  let visibilityManager;
14444
14518
  let recording = false;
14445
14519
  const customEventQueue = [];
14446
- let flushCustomEventQueue;
14520
+ let flushCustomEventQueue$1;
14447
14521
  function waitForDOMStabilization(win) {
14448
14522
  const maxWaitMs = 5e3;
14449
14523
  return new Promise((resolve2) => {
@@ -14813,7 +14887,7 @@ function record(options = {}) {
14813
14887
  mirror.getId(document)
14814
14888
  );
14815
14889
  };
14816
- flushCustomEventQueue = () => {
14890
+ flushCustomEventQueue$1 = () => {
14817
14891
  for (const e2 of customEventQueue) {
14818
14892
  wrappedEmit(e2);
14819
14893
  }
@@ -14956,37 +15030,34 @@ function record(options = {}) {
14956
15030
  });
14957
15031
  const init = () => {
14958
15032
  if (flushCustomEvent === "before") {
14959
- flushCustomEventQueue();
15033
+ flushCustomEventQueue$1();
14960
15034
  }
14961
15035
  takeFullSnapshot$1();
14962
15036
  handlers.push(observe(document));
14963
15037
  recording = true;
14964
15038
  if (flushCustomEvent === "after") {
14965
- flushCustomEventQueue();
15039
+ flushCustomEventQueue$1();
14966
15040
  }
14967
15041
  };
14968
15042
  const runInit = async () => {
14969
15043
  if (flushCustomEvent === "before") {
14970
- flushCustomEventQueue();
15044
+ flushCustomEventQueue$1();
14971
15045
  }
14972
15046
  if (recordAfter === "DOMContentStabilized") {
14973
- console.log(`[rrweb] 🟢 Waiting for DOM stabilization...`);
15047
+ console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
14974
15048
  await waitForDOMStabilization(window);
14975
- console.log(`[rrweb] ✅ DOM stabilized, starting recording`);
15049
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
14976
15050
  }
15051
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
14977
15052
  takeFullSnapshot$1();
14978
15053
  handlers.push(observe(document));
14979
15054
  recording = true;
14980
15055
  if (flushCustomEvent === "after") {
14981
- flushCustomEventQueue();
15056
+ flushCustomEventQueue$1();
14982
15057
  }
14983
15058
  };
14984
15059
  if (document.readyState === "interactive" || document.readyState === "complete") {
14985
- if (recordAfter === "DOMContentStabilized") {
14986
- void runInit();
14987
- } else {
14988
- init();
14989
- }
15060
+ init();
14990
15061
  } else {
14991
15062
  handlers.push(
14992
15063
  on("DOMContentLoaded", () => {
@@ -14994,9 +15065,7 @@ function record(options = {}) {
14994
15065
  type: EventType.DomContentLoaded,
14995
15066
  data: {}
14996
15067
  });
14997
- if (recordAfter === "DOMContentLoaded" || recordAfter === "DOMContentStabilized") {
14998
- void runInit();
14999
- }
15068
+ if (recordAfter === "DOMContentLoaded") init();
15000
15069
  })
15001
15070
  );
15002
15071
  handlers.push(
@@ -15007,14 +15076,14 @@ function record(options = {}) {
15007
15076
  type: EventType.Load,
15008
15077
  data: {}
15009
15078
  });
15010
- if (recordAfter === "load") void runInit();
15079
+ if (recordAfter === "load") init();
15011
15080
  },
15012
15081
  window
15013
15082
  )
15014
15083
  );
15015
15084
  }
15016
15085
  return () => {
15017
- flushCustomEventQueue();
15086
+ flushCustomEventQueue$1();
15018
15087
  handlers.forEach((h) => h());
15019
15088
  processedNodeManager.destroy();
15020
15089
  recording = false;
@@ -15024,10 +15093,11 @@ function record(options = {}) {
15024
15093
  console.warn(error);
15025
15094
  }
15026
15095
  }
15096
+ record.getVersion = () => version$1;
15027
15097
  record.isRecording = () => recording;
15028
15098
  record.flushCustomEventQueue = () => {
15029
15099
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
15030
- flushCustomEventQueue();
15100
+ flushCustomEventQueue$1();
15031
15101
  };
15032
15102
  record.addCustomEvent = (tag, payload) => {
15033
15103
  const customEvent = {
@@ -17939,6 +18009,10 @@ class Replayer {
17939
18009
  this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
17940
18010
  }
17941
18011
  }
18012
+ const version = "2.1.2-alpha.1";
18013
+ const { getVersion } = record;
18014
+ const { isRecording } = record;
18015
+ const { flushCustomEventQueue } = record;
17942
18016
  const { addCustomEvent } = record;
17943
18017
  const { freezePage } = record;
17944
18018
  const { takeFullSnapshot } = record;
@@ -17949,8 +18023,12 @@ exports.Replayer = Replayer;
17949
18023
  exports.ReplayerEvents = ReplayerEvents;
17950
18024
  exports.addCustomEvent = addCustomEvent;
17951
18025
  exports.canvasMutation = canvasMutation;
18026
+ exports.flushCustomEventQueue = flushCustomEventQueue;
17952
18027
  exports.freezePage = freezePage;
18028
+ exports.getVersion = getVersion;
18029
+ exports.isRecording = isRecording;
17953
18030
  exports.record = record;
17954
18031
  exports.takeFullSnapshot = takeFullSnapshot;
17955
18032
  exports.utils = utils;
18033
+ exports.version = version;
17956
18034
  //# sourceMappingURL=rrweb.cjs.map