@appsurify-testmap/rrweb 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.
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,44 @@ 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;
14521
+ function waitForDOMStabilization(win) {
14522
+ const maxWaitMs = 5e3;
14523
+ return new Promise((resolve2) => {
14524
+ const captureAfterPaint = () => {
14525
+ requestAnimationFrame(() => {
14526
+ requestAnimationFrame(() => {
14527
+ resolve2();
14528
+ });
14529
+ });
14530
+ };
14531
+ const safeResolve = /* @__PURE__ */ (() => {
14532
+ let called = false;
14533
+ return () => {
14534
+ if (!called) {
14535
+ called = true;
14536
+ captureAfterPaint();
14537
+ }
14538
+ };
14539
+ })();
14540
+ if (["interactive", "complete"].includes(win.document.readyState)) {
14541
+ safeResolve();
14542
+ } else {
14543
+ win.addEventListener("DOMContentLoaded", safeResolve, { once: true });
14544
+ win.addEventListener("load", safeResolve, { once: true });
14545
+ setTimeout(() => {
14546
+ safeResolve();
14547
+ }, maxWaitMs);
14548
+ }
14549
+ });
14550
+ }
14447
14551
  try {
14448
14552
  if (Array.from([1], (x2) => x2 * 2)[0] !== 2) {
14449
14553
  const cleanFrame = document.createElement("iframe");
@@ -14783,7 +14887,7 @@ function record(options = {}) {
14783
14887
  mirror.getId(document)
14784
14888
  );
14785
14889
  };
14786
- flushCustomEventQueue = () => {
14890
+ flushCustomEventQueue$1 = () => {
14787
14891
  for (const e2 of customEventQueue) {
14788
14892
  wrappedEmit(e2);
14789
14893
  }
@@ -14926,13 +15030,30 @@ function record(options = {}) {
14926
15030
  });
14927
15031
  const init = () => {
14928
15032
  if (flushCustomEvent === "before") {
14929
- flushCustomEventQueue();
15033
+ flushCustomEventQueue$1();
15034
+ }
15035
+ takeFullSnapshot$1();
15036
+ handlers.push(observe(document));
15037
+ recording = true;
15038
+ if (flushCustomEvent === "after") {
15039
+ flushCustomEventQueue$1();
15040
+ }
15041
+ };
15042
+ const runInit = async () => {
15043
+ if (flushCustomEvent === "before") {
15044
+ flushCustomEventQueue$1();
15045
+ }
15046
+ if (recordAfter === "DOMContentStabilized") {
15047
+ console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
15048
+ await waitForDOMStabilization(window);
15049
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
14930
15050
  }
15051
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
14931
15052
  takeFullSnapshot$1();
14932
15053
  handlers.push(observe(document));
14933
15054
  recording = true;
14934
15055
  if (flushCustomEvent === "after") {
14935
- flushCustomEventQueue();
15056
+ flushCustomEventQueue$1();
14936
15057
  }
14937
15058
  };
14938
15059
  if (document.readyState === "interactive" || document.readyState === "complete") {
@@ -14962,7 +15083,7 @@ function record(options = {}) {
14962
15083
  );
14963
15084
  }
14964
15085
  return () => {
14965
- flushCustomEventQueue();
15086
+ flushCustomEventQueue$1();
14966
15087
  handlers.forEach((h) => h());
14967
15088
  processedNodeManager.destroy();
14968
15089
  recording = false;
@@ -14972,9 +15093,11 @@ function record(options = {}) {
14972
15093
  console.warn(error);
14973
15094
  }
14974
15095
  }
15096
+ record.getVersion = () => version$1;
15097
+ record.isRecording = () => recording;
14975
15098
  record.flushCustomEventQueue = () => {
14976
15099
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
14977
- flushCustomEventQueue();
15100
+ flushCustomEventQueue$1();
14978
15101
  };
14979
15102
  record.addCustomEvent = (tag, payload) => {
14980
15103
  const customEvent = {
@@ -17886,6 +18009,10 @@ class Replayer {
17886
18009
  this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
17887
18010
  }
17888
18011
  }
18012
+ const version = "2.1.2-alpha.1";
18013
+ const { getVersion } = record;
18014
+ const { isRecording } = record;
18015
+ const { flushCustomEventQueue } = record;
17889
18016
  const { addCustomEvent } = record;
17890
18017
  const { freezePage } = record;
17891
18018
  const { takeFullSnapshot } = record;
@@ -17896,8 +18023,12 @@ exports.Replayer = Replayer;
17896
18023
  exports.ReplayerEvents = ReplayerEvents;
17897
18024
  exports.addCustomEvent = addCustomEvent;
17898
18025
  exports.canvasMutation = canvasMutation;
18026
+ exports.flushCustomEventQueue = flushCustomEventQueue;
17899
18027
  exports.freezePage = freezePage;
18028
+ exports.getVersion = getVersion;
18029
+ exports.isRecording = isRecording;
17900
18030
  exports.record = record;
17901
18031
  exports.takeFullSnapshot = takeFullSnapshot;
17902
18032
  exports.utils = utils;
18033
+ exports.version = version;
17903
18034
  //# sourceMappingURL=rrweb.cjs.map