@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.
@@ -884,10 +884,13 @@ function inspectInlineEventHandlers$1() {
884
884
  });
885
885
  });
886
886
  }
887
- if (document.readyState === "complete" || document.readyState === "interactive") {
888
- inspectInlineEventHandlers$1();
889
- } else {
890
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
887
+ try {
888
+ if (document.readyState === "complete" || document.readyState === "interactive") {
889
+ inspectInlineEventHandlers$1();
890
+ } else {
891
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers$1);
892
+ }
893
+ } catch (error) {
891
894
  }
892
895
  let _id = 1;
893
896
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -6113,10 +6116,13 @@ function inspectInlineEventHandlers() {
6113
6116
  });
6114
6117
  });
6115
6118
  }
6116
- if (document.readyState === "complete" || document.readyState === "interactive") {
6117
- inspectInlineEventHandlers();
6118
- } else {
6119
- document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
6119
+ try {
6120
+ if (document.readyState === "complete" || document.readyState === "interactive") {
6121
+ inspectInlineEventHandlers();
6122
+ } else {
6123
+ document.addEventListener("DOMContentLoaded", inspectInlineEventHandlers);
6124
+ }
6125
+ } catch (error) {
6120
6126
  }
6121
6127
  function getDefaultExportFromCjs(x2) {
6122
6128
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -12789,6 +12795,8 @@ function initViewportResizeObserver({ viewportResizeCb }, { win }) {
12789
12795
  }
12790
12796
  const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
12791
12797
  const lastInputValueMap = /* @__PURE__ */ new WeakMap();
12798
+ const FINALIZING_KEYS = ["Enter", "Tab", "Escape", "ArrowDown", "ArrowUp", "Delete"];
12799
+ const lastKeyInputValueMap = /* @__PURE__ */ new WeakMap();
12792
12800
  function initInputObserver({
12793
12801
  inputCb,
12794
12802
  doc,
@@ -12861,6 +12869,22 @@ function initInputObserver({
12861
12869
  const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12862
12870
  const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12863
12871
  if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
12872
+ console.debug(
12873
+ `[${nowTimestamp()}] [rrweb:record/observer] \u26D4 phantom input ignored`,
12874
+ {
12875
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
12876
+ node: index.describeNode(el),
12877
+ tag: el.tagName,
12878
+ nodeType: el.nodeType,
12879
+ attribute: el.attributes,
12880
+ value: el.value,
12881
+ isLikelyPhantom,
12882
+ isRenderDrivenTextInput,
12883
+ isValueFromDefault,
12884
+ isPhantomCheckbox,
12885
+ isPhantomRadio
12886
+ }
12887
+ );
12864
12888
  return;
12865
12889
  }
12866
12890
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
@@ -12875,6 +12899,62 @@ function initInputObserver({
12875
12899
  const handlers = events.map(
12876
12900
  (eventName) => on(eventName, callbackWrapper(eventHandler), doc)
12877
12901
  );
12902
+ const keyboardHandler = (event) => {
12903
+ const target = getEventTarget(event);
12904
+ if (!target || !target.tagName)
12905
+ return;
12906
+ if (sampling.input === "all") {
12907
+ eventHandler(event);
12908
+ return;
12909
+ }
12910
+ const tag = target.tagName;
12911
+ const key = event.key;
12912
+ const isFinalizingKey = FINALIZING_KEYS.includes(key);
12913
+ const isTextarea = tag === "TEXTAREA";
12914
+ const isFocused = doc.activeElement === target;
12915
+ const valueNow = target.value;
12916
+ const valueBefore = lastKeyInputValueMap.get(target);
12917
+ lastKeyInputValueMap.set(target, valueNow);
12918
+ if (!isFocused) {
12919
+ eventHandler(event);
12920
+ return;
12921
+ }
12922
+ if (isFinalizingKey) {
12923
+ if (!isTextarea) {
12924
+ eventHandler(event);
12925
+ return;
12926
+ }
12927
+ let lastValue = valueBefore != null ? valueBefore : "";
12928
+ let unchangedCount = 0;
12929
+ const REQUIRED_STABLE_FRAMES = 2;
12930
+ const checkFinal = () => {
12931
+ const currentValue = target.value;
12932
+ const stillFocused = doc.activeElement === target;
12933
+ const changed = currentValue !== lastValue;
12934
+ if (!stillFocused) {
12935
+ eventHandler(event);
12936
+ return;
12937
+ }
12938
+ if (!changed) {
12939
+ unchangedCount++;
12940
+ if (unchangedCount >= REQUIRED_STABLE_FRAMES) {
12941
+ eventHandler(event);
12942
+ return;
12943
+ }
12944
+ } else {
12945
+ unchangedCount = 0;
12946
+ lastValue = currentValue;
12947
+ }
12948
+ requestAnimationFrame(checkFinal);
12949
+ };
12950
+ requestAnimationFrame(checkFinal);
12951
+ return;
12952
+ }
12953
+ };
12954
+ handlers.push(
12955
+ on("keydown", callbackWrapper(keyboardHandler), doc)
12956
+ // on('keypress', callbackWrapper(keyboardHandler), doc),
12957
+ );
12878
12958
  const currentWindow = doc.defaultView;
12879
12959
  if (!currentWindow) {
12880
12960
  return () => {
@@ -14882,13 +14962,14 @@ class VisibilityManager {
14882
14962
  cancelAnimationFrame(this.rafId);
14883
14963
  }
14884
14964
  }
14965
+ const version$1 = "2.1.2-alpha.2";
14885
14966
  let wrappedEmit;
14886
14967
  let takeFullSnapshot$1;
14887
14968
  let canvasManager;
14888
14969
  let visibilityManager;
14889
14970
  let recording = false;
14890
14971
  const customEventQueue = [];
14891
- let flushCustomEventQueue;
14972
+ let flushCustomEventQueue$1;
14892
14973
  function waitForDOMStabilization(win) {
14893
14974
  const maxWaitMs = 5e3;
14894
14975
  return new Promise((resolve2) => {
@@ -15253,7 +15334,7 @@ function record(options = {}) {
15253
15334
  mirror.getId(document)
15254
15335
  );
15255
15336
  };
15256
- flushCustomEventQueue = () => {
15337
+ flushCustomEventQueue$1 = () => {
15257
15338
  for (const e2 of customEventQueue) {
15258
15339
  wrappedEmit(e2);
15259
15340
  }
@@ -15387,37 +15468,34 @@ function record(options = {}) {
15387
15468
  });
15388
15469
  const init = () => {
15389
15470
  if (flushCustomEvent === "before") {
15390
- flushCustomEventQueue();
15471
+ flushCustomEventQueue$1();
15391
15472
  }
15392
15473
  takeFullSnapshot$1();
15393
15474
  handlers.push(observe(document));
15394
15475
  recording = true;
15395
15476
  if (flushCustomEvent === "after") {
15396
- flushCustomEventQueue();
15477
+ flushCustomEventQueue$1();
15397
15478
  }
15398
15479
  };
15399
15480
  const runInit = async () => {
15400
15481
  if (flushCustomEvent === "before") {
15401
- flushCustomEventQueue();
15482
+ flushCustomEventQueue$1();
15402
15483
  }
15403
15484
  if (recordAfter === "DOMContentStabilized") {
15404
- console.log(`[rrweb] \u{1F7E2} Waiting for DOM stabilization...`);
15485
+ console.debug(`[${nowTimestamp()}] [rrweb:record] \u{1F7E2} Waiting for DOM stabilization...`);
15405
15486
  await waitForDOMStabilization(window);
15406
- console.log(`[rrweb] \u2705 DOM stabilized, starting recording`);
15487
+ console.debug(`[${nowTimestamp()}] [rrweb:record] \u2705 DOM stabilized, starting recording`);
15407
15488
  }
15489
+ console.debug(`[${nowTimestamp()}] [rrweb:record] \u2705 Init dom and takeFullSnapshot `);
15408
15490
  takeFullSnapshot$1();
15409
15491
  handlers.push(observe(document));
15410
15492
  recording = true;
15411
15493
  if (flushCustomEvent === "after") {
15412
- flushCustomEventQueue();
15494
+ flushCustomEventQueue$1();
15413
15495
  }
15414
15496
  };
15415
15497
  if (document.readyState === "interactive" || document.readyState === "complete") {
15416
- if (recordAfter === "DOMContentStabilized") {
15417
- void runInit();
15418
- } else {
15419
- init();
15420
- }
15498
+ init();
15421
15499
  } else {
15422
15500
  handlers.push(
15423
15501
  on("DOMContentLoaded", () => {
@@ -15425,9 +15503,8 @@ function record(options = {}) {
15425
15503
  type: EventType.DomContentLoaded,
15426
15504
  data: {}
15427
15505
  });
15428
- if (recordAfter === "DOMContentLoaded" || recordAfter === "DOMContentStabilized") {
15429
- void runInit();
15430
- }
15506
+ if (recordAfter === "DOMContentLoaded")
15507
+ init();
15431
15508
  })
15432
15509
  );
15433
15510
  handlers.push(
@@ -15439,14 +15516,14 @@ function record(options = {}) {
15439
15516
  data: {}
15440
15517
  });
15441
15518
  if (recordAfter === "load")
15442
- void runInit();
15519
+ init();
15443
15520
  },
15444
15521
  window
15445
15522
  )
15446
15523
  );
15447
15524
  }
15448
15525
  return () => {
15449
- flushCustomEventQueue();
15526
+ flushCustomEventQueue$1();
15450
15527
  handlers.forEach((h) => h());
15451
15528
  processedNodeManager.destroy();
15452
15529
  recording = false;
@@ -15456,10 +15533,11 @@ function record(options = {}) {
15456
15533
  console.warn(error);
15457
15534
  }
15458
15535
  }
15536
+ record.getVersion = () => version$1;
15459
15537
  record.isRecording = () => recording;
15460
15538
  record.flushCustomEventQueue = () => {
15461
15539
  console.warn(`[rrweb] CustomEvent flushing: ${customEventQueue.length} events`);
15462
- flushCustomEventQueue();
15540
+ flushCustomEventQueue$1();
15463
15541
  };
15464
15542
  record.addCustomEvent = (tag, payload) => {
15465
15543
  const customEvent = {
@@ -18402,6 +18480,10 @@ class Replayer {
18402
18480
  this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
18403
18481
  }
18404
18482
  }
18483
+ const version = "2.1.2-alpha.2";
18484
+ const { getVersion } = record;
18485
+ const { isRecording } = record;
18486
+ const { flushCustomEventQueue } = record;
18405
18487
  const { addCustomEvent } = record;
18406
18488
  const { freezePage } = record;
18407
18489
  const { takeFullSnapshot } = record;
@@ -18412,10 +18494,14 @@ exports.Replayer = Replayer;
18412
18494
  exports.ReplayerEvents = ReplayerEvents;
18413
18495
  exports.addCustomEvent = addCustomEvent;
18414
18496
  exports.canvasMutation = canvasMutation;
18497
+ exports.flushCustomEventQueue = flushCustomEventQueue;
18415
18498
  exports.freezePage = freezePage;
18499
+ exports.getVersion = getVersion;
18500
+ exports.isRecording = isRecording;
18416
18501
  exports.record = record;
18417
18502
  exports.takeFullSnapshot = takeFullSnapshot;
18418
18503
  exports.utils = utils;
18504
+ exports.version = version;
18419
18505
  if (typeof module.exports == "object" && typeof exports == "object") {
18420
18506
  var __cp = (to, from, except, desc) => {
18421
18507
  if ((from && typeof from === "object") || typeof from === "function") {