@appsurify-testmap/rrweb 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.
package/dist/rrweb.cjs CHANGED
@@ -820,10 +820,13 @@ function inspectInlineEventHandlers$1() {
820
820
  });
821
821
  });
822
822
  }
823
- if (document.readyState === "complete" || document.readyState === "interactive") {
824
- inspectInlineEventHandlers$1();
825
- } else {
826
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
823
+ try {
824
+ if (document.readyState === "complete" || document.readyState === "interactive") {
825
+ inspectInlineEventHandlers$1();
826
+ } else {
827
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
828
+ }
829
+ } catch (error) {
827
830
  }
828
831
  let _id = 1;
829
832
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -5887,10 +5890,13 @@ function inspectInlineEventHandlers() {
5887
5890
  });
5888
5891
  });
5889
5892
  }
5890
- if (document.readyState === "complete" || document.readyState === "interactive") {
5891
- inspectInlineEventHandlers();
5892
- } else {
5893
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5893
+ try {
5894
+ if (document.readyState === "complete" || document.readyState === "interactive") {
5895
+ inspectInlineEventHandlers();
5896
+ } else {
5897
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
5898
+ }
5899
+ } catch (error) {
5894
5900
  }
5895
5901
  function getDefaultExportFromCjs(x2) {
5896
5902
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -12377,6 +12383,8 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
12377
12383
  }
12378
12384
  const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
12379
12385
  const lastInputValueMap = /* @__PURE__ */ new WeakMap();
12386
+ const FINALIZING_KEYS = ["Enter", "Tab", "Escape", "ArrowDown", "ArrowUp", "Delete"];
12387
+ const lastKeyInputValueMap = /* @__PURE__ */ new WeakMap();
12380
12388
  function initInputObserver({
12381
12389
  inputCb,
12382
12390
  doc,
@@ -12449,6 +12457,22 @@ function initInputObserver({
12449
12457
  const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12450
12458
  const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12451
12459
  if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
12460
+ console.debug(
12461
+ `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
12462
+ {
12463
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
12464
+ node: index.describeNode(el),
12465
+ tag: el.tagName,
12466
+ nodeType: el.nodeType,
12467
+ attribute: el.attributes,
12468
+ value: el.value,
12469
+ isLikelyPhantom,
12470
+ isRenderDrivenTextInput,
12471
+ isValueFromDefault,
12472
+ isPhantomCheckbox,
12473
+ isPhantomRadio
12474
+ }
12475
+ );
12452
12476
  return;
12453
12477
  }
12454
12478
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
@@ -12464,6 +12488,61 @@ function initInputObserver({
12464
12488
  const handlers = events.map(
12465
12489
  (eventName) => on(eventName, callbackWrapper(eventHandler), doc)
12466
12490
  );
12491
+ const keyboardHandler = (event) => {
12492
+ const target = getEventTarget(event);
12493
+ if (!target || !target.tagName) return;
12494
+ if (sampling.input === "all") {
12495
+ eventHandler(event);
12496
+ return;
12497
+ }
12498
+ const tag = target.tagName;
12499
+ const key = event.key;
12500
+ const isFinalizingKey = FINALIZING_KEYS.includes(key);
12501
+ const isTextarea = tag === "TEXTAREA";
12502
+ const isFocused = doc.activeElement === target;
12503
+ const valueNow = target.value;
12504
+ const valueBefore = lastKeyInputValueMap.get(target);
12505
+ lastKeyInputValueMap.set(target, valueNow);
12506
+ if (!isFocused) {
12507
+ eventHandler(event);
12508
+ return;
12509
+ }
12510
+ if (isFinalizingKey) {
12511
+ if (!isTextarea) {
12512
+ eventHandler(event);
12513
+ return;
12514
+ }
12515
+ let lastValue = valueBefore ?? "";
12516
+ let unchangedCount = 0;
12517
+ const REQUIRED_STABLE_FRAMES = 2;
12518
+ const checkFinal = () => {
12519
+ const currentValue = target.value;
12520
+ const stillFocused = doc.activeElement === target;
12521
+ const changed = currentValue !== lastValue;
12522
+ if (!stillFocused) {
12523
+ eventHandler(event);
12524
+ return;
12525
+ }
12526
+ if (!changed) {
12527
+ unchangedCount++;
12528
+ if (unchangedCount >= REQUIRED_STABLE_FRAMES) {
12529
+ eventHandler(event);
12530
+ return;
12531
+ }
12532
+ } else {
12533
+ unchangedCount = 0;
12534
+ lastValue = currentValue;
12535
+ }
12536
+ requestAnimationFrame(checkFinal);
12537
+ };
12538
+ requestAnimationFrame(checkFinal);
12539
+ return;
12540
+ }
12541
+ };
12542
+ handlers.push(
12543
+ on("keydown", callbackWrapper(keyboardHandler), doc)
12544
+ // on('keypress', callbackWrapper(keyboardHandler), doc),
12545
+ );
12467
12546
  const currentWindow = doc.defaultView;
12468
12547
  if (!currentWindow) {
12469
12548
  return () => {
@@ -14437,13 +14516,14 @@ class VisibilityManager {
14437
14516
  if (this.rafId) cancelAnimationFrame(this.rafId);
14438
14517
  }
14439
14518
  }
14519
+ const version$1 = "2.1.2-alpha.2";
14440
14520
  let wrappedEmit;
14441
14521
  let takeFullSnapshot$1;
14442
14522
  let canvasManager;
14443
14523
  let visibilityManager;
14444
14524
  let recording = false;
14445
14525
  const customEventQueue = [];
14446
- let flushCustomEventQueue;
14526
+ let flushCustomEventQueue$1;
14447
14527
  function waitForDOMStabilization(win) {
14448
14528
  const maxWaitMs = 5e3;
14449
14529
  return new Promise((resolve2) => {
@@ -14813,7 +14893,7 @@ function record(options = {}) {
14813
14893
  mirror.getId(document)
14814
14894
  );
14815
14895
  };
14816
- flushCustomEventQueue = () => {
14896
+ flushCustomEventQueue$1 = () => {
14817
14897
  for (const e2 of customEventQueue) {
14818
14898
  wrappedEmit(e2);
14819
14899
  }
@@ -14956,37 +15036,34 @@ function record(options = {}) {
14956
15036
  });
14957
15037
  const init = () => {
14958
15038
  if (flushCustomEvent === "before") {
14959
- flushCustomEventQueue();
15039
+ flushCustomEventQueue$1();
14960
15040
  }
14961
15041
  takeFullSnapshot$1();
14962
15042
  handlers.push(observe(document));
14963
15043
  recording = true;
14964
15044
  if (flushCustomEvent === "after") {
14965
- flushCustomEventQueue();
15045
+ flushCustomEventQueue$1();
14966
15046
  }
14967
15047
  };
14968
15048
  const runInit = async () => {
14969
15049
  if (flushCustomEvent === "before") {
14970
- flushCustomEventQueue();
15050
+ flushCustomEventQueue$1();
14971
15051
  }
14972
15052
  if (recordAfter === "DOMContentStabilized") {
14973
- console.log(`[rrweb] 🟢 Waiting for DOM stabilization...`);
15053
+ console.debug(`[${nowTimestamp()}] [rrweb:record] 🟢 Waiting for DOM stabilization...`);
14974
15054
  await waitForDOMStabilization(window);
14975
- console.log(`[rrweb] ✅ DOM stabilized, starting recording`);
15055
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ DOM stabilized, starting recording`);
14976
15056
  }
15057
+ console.debug(`[${nowTimestamp()}] [rrweb:record] ✅ Init dom and takeFullSnapshot `);
14977
15058
  takeFullSnapshot$1();
14978
15059
  handlers.push(observe(document));
14979
15060
  recording = true;
14980
15061
  if (flushCustomEvent === "after") {
14981
- flushCustomEventQueue();
15062
+ flushCustomEventQueue$1();
14982
15063
  }
14983
15064
  };
14984
15065
  if (document.readyState === "interactive" || document.readyState === "complete") {
14985
- if (recordAfter === "DOMContentStabilized") {
14986
- void runInit();
14987
- } else {
14988
- init();
14989
- }
15066
+ init();
14990
15067
  } else {
14991
15068
  handlers.push(
14992
15069
  on("DOMContentLoaded", () => {
@@ -14994,9 +15071,7 @@ function record(options = {}) {
14994
15071
  type: EventType.DomContentLoaded,
14995
15072
  data: {}
14996
15073
  });
14997
- if (recordAfter === "DOMContentLoaded" || recordAfter === "DOMContentStabilized") {
14998
- void runInit();
14999
- }
15074
+ if (recordAfter === "DOMContentLoaded") init();
15000
15075
  })
15001
15076
  );
15002
15077
  handlers.push(
@@ -15007,14 +15082,14 @@ function record(options = {}) {
15007
15082
  type: EventType.Load,
15008
15083
  data: {}
15009
15084
  });
15010
- if (recordAfter === "load") void runInit();
15085
+ if (recordAfter === "load") init();
15011
15086
  },
15012
15087
  window
15013
15088
  )
15014
15089
  );
15015
15090
  }
15016
15091
  return () => {
15017
- flushCustomEventQueue();
15092
+ flushCustomEventQueue$1();
15018
15093
  handlers.forEach((h) => h());
15019
15094
  processedNodeManager.destroy();
15020
15095
  recording = false;
@@ -15024,10 +15099,11 @@ function record(options = {}) {
15024
15099
  console.warn(error);
15025
15100
  }
15026
15101
  }
15102
+ record.getVersion = () => version$1;
15027
15103
  record.isRecording = () => recording;
15028
15104
  record.flushCustomEventQueue = () => {
15029
15105
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
15030
- flushCustomEventQueue();
15106
+ flushCustomEventQueue$1();
15031
15107
  };
15032
15108
  record.addCustomEvent = (tag, payload) => {
15033
15109
  const customEvent = {
@@ -17939,6 +18015,10 @@ class Replayer {
17939
18015
  this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
17940
18016
  }
17941
18017
  }
18018
+ const version = "2.1.2-alpha.2";
18019
+ const { getVersion } = record;
18020
+ const { isRecording } = record;
18021
+ const { flushCustomEventQueue } = record;
17942
18022
  const { addCustomEvent } = record;
17943
18023
  const { freezePage } = record;
17944
18024
  const { takeFullSnapshot } = record;
@@ -17949,8 +18029,12 @@ exports.Replayer = Replayer;
17949
18029
  exports.ReplayerEvents = ReplayerEvents;
17950
18030
  exports.addCustomEvent = addCustomEvent;
17951
18031
  exports.canvasMutation = canvasMutation;
18032
+ exports.flushCustomEventQueue = flushCustomEventQueue;
17952
18033
  exports.freezePage = freezePage;
18034
+ exports.getVersion = getVersion;
18035
+ exports.isRecording = isRecording;
17953
18036
  exports.record = record;
17954
18037
  exports.takeFullSnapshot = takeFullSnapshot;
17955
18038
  exports.utils = utils;
18039
+ exports.version = version;
17956
18040
  //# sourceMappingURL=rrweb.cjs.map