@appsurify-testmap/rrweb-record 3.5.0-alpha.1 → 3.10.0-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.
@@ -13901,7 +13901,8 @@ function initInputObserver({
13901
13901
  maskInputOptions,
13902
13902
  maskInputFn,
13903
13903
  sampling,
13904
- userTriggeredOnInput
13904
+ userTriggeredOnInput,
13905
+ trustSyntheticInput
13905
13906
  }) {
13906
13907
  function eventHandler(event) {
13907
13908
  let target = getEventTarget(event);
@@ -13951,34 +13952,53 @@ function initInputObserver({
13951
13952
  function cbWithDedup(target, v2) {
13952
13953
  const lastInputValue = lastInputValueMap.get(target);
13953
13954
  const el = target;
13954
- const hasPlaceholder = el.hasAttribute("placeholder");
13955
- const isEmpty = el.value === "";
13956
- const isDefaultEmpty = typeof el.defaultValue === "string" ? el.defaultValue === "" : true;
13957
- const isNonUser = !v2.userTriggered;
13958
- const isRepeatEmpty = !lastInputValue || lastInputValue.text === "";
13959
- const isLikelyPhantom = hasPlaceholder && isEmpty && isDefaultEmpty && isRepeatEmpty && isNonUser && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
13960
- const isRenderDrivenTextInput = el.tagName === "INPUT" && el.type === "text" && !v2.userTriggered && v2.text === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder");
13961
- const isValueFromDefault = !v2.userTriggered && el.value === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder") && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
13962
- const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
13963
- const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
13964
- if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
13965
- console.debug(
13966
- `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
13967
- {
13968
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
13969
- node: index.describeNode(el),
13970
- tag: el.tagName,
13971
- nodeType: el.nodeType,
13972
- attribute: el.attributes,
13973
- value: el.value,
13974
- isLikelyPhantom,
13975
- isRenderDrivenTextInput,
13976
- isValueFromDefault,
13977
- isPhantomCheckbox,
13978
- isPhantomRadio
13979
- }
13980
- );
13981
- return;
13955
+ if (trustSyntheticInput) {
13956
+ const isInitialEmpty = !v2.userTriggered && el.value === "" && !v2.isChecked && !lastInputValue;
13957
+ const isSelectDefaultSelection = el.tagName === "SELECT" && !v2.userTriggered && !lastInputValue && el.selectedIndex === 0;
13958
+ if (isInitialEmpty || isSelectDefaultSelection) {
13959
+ console.debug(
13960
+ `[${nowTimestamp()}] [rrweb:record/observer] phantom input ignored (trust mode)`,
13961
+ {
13962
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
13963
+ node: index.describeNode(el),
13964
+ tag: el.tagName,
13965
+ value: el.value,
13966
+ isInitialEmpty,
13967
+ isSelectDefaultSelection
13968
+ }
13969
+ );
13970
+ return;
13971
+ }
13972
+ } else {
13973
+ const hasPlaceholder = el.hasAttribute("placeholder");
13974
+ const isEmpty = el.value === "";
13975
+ const isDefaultEmpty = typeof el.defaultValue === "string" ? el.defaultValue === "" : true;
13976
+ const isNonUser = !v2.userTriggered;
13977
+ const isRepeatEmpty = !lastInputValue || lastInputValue.text === "";
13978
+ const isLikelyPhantom = hasPlaceholder && isEmpty && isDefaultEmpty && isRepeatEmpty && isNonUser && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
13979
+ const isRenderDrivenTextInput = el.tagName === "INPUT" && el.type === "text" && !v2.userTriggered && v2.text === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder");
13980
+ const isValueFromDefault = !v2.userTriggered && el.value === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder") && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
13981
+ const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
13982
+ const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
13983
+ if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
13984
+ console.debug(
13985
+ `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
13986
+ {
13987
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
13988
+ node: index.describeNode(el),
13989
+ tag: el.tagName,
13990
+ nodeType: el.nodeType,
13991
+ attribute: el.attributes,
13992
+ value: el.value,
13993
+ isLikelyPhantom,
13994
+ isRenderDrivenTextInput,
13995
+ isValueFromDefault,
13996
+ isPhantomCheckbox,
13997
+ isPhantomRadio
13998
+ }
13999
+ );
14000
+ return;
14001
+ }
13982
14002
  }
13983
14003
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
13984
14004
  lastInputValueMap.set(target, v2);
@@ -16009,8 +16029,15 @@ class NavigationManager {
16009
16029
  handleNavigation(data) {
16010
16030
  if (this.disabled) return;
16011
16031
  if (this.locked) return;
16012
- this.cancelTimers();
16013
- this.disconnectSettlingObserver();
16032
+ if (this.pendingNavigation) {
16033
+ this.cancelTimers();
16034
+ this.disconnectSettlingObserver();
16035
+ this.pendingNavigation = null;
16036
+ this.onSnapshot(true);
16037
+ } else {
16038
+ this.cancelTimers();
16039
+ this.disconnectSettlingObserver();
16040
+ }
16014
16041
  this.pendingNavigation = data;
16015
16042
  if (this.frozen) {
16016
16043
  return;
@@ -16217,7 +16244,7 @@ class ProcessedNodeManager {
16217
16244
  destroy() {
16218
16245
  }
16219
16246
  }
16220
- const version$1 = "3.5.0-alpha.1";
16247
+ const version$1 = "3.10.0-alpha.1";
16221
16248
  let wrappedEmit;
16222
16249
  let takeFullSnapshot$1;
16223
16250
  let canvasManager;
@@ -16266,6 +16293,7 @@ function record(options = {}) {
16266
16293
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
16267
16294
  flushCustomEvent = options.flushCustomEvent !== void 0 ? options.flushCustomEvent : "after",
16268
16295
  userTriggeredOnInput = false,
16296
+ trustSyntheticInput = false,
16269
16297
  collectFonts = false,
16270
16298
  inlineImages = false,
16271
16299
  plugins,
@@ -16340,6 +16368,11 @@ function record(options = {}) {
16340
16368
  let checkoutPending = false;
16341
16369
  let checkoutDebounceTimer = null;
16342
16370
  let checkoutFreezeTimestamp = null;
16371
+ let lastScrollEmitTime = 0;
16372
+ const scrollSettleTime = (sampling.scroll || 100) * 2;
16373
+ let lastSignificantMutationTime = 0;
16374
+ const mutationGracePeriod = 500;
16375
+ let hadVisibilityCheckoutInGrace = false;
16343
16376
  const eventProcessor = (e2) => {
16344
16377
  for (const plugin3 of plugins || []) {
16345
16378
  if (plugin3.eventProcessor) {
@@ -16430,6 +16463,12 @@ function record(options = {}) {
16430
16463
  }
16431
16464
  };
16432
16465
  const wrappedMutationEmit = (m) => {
16466
+ var _a2, _b;
16467
+ const totalChanges = (((_a2 = m.adds) == null ? void 0 : _a2.length) ?? 0) + (((_b = m.removes) == null ? void 0 : _b.length) ?? 0);
16468
+ if (totalChanges > 10) {
16469
+ lastSignificantMutationTime = nowTimestamp();
16470
+ hadVisibilityCheckoutInGrace = false;
16471
+ }
16433
16472
  wrappedEmit({
16434
16473
  type: EventType.IncrementalSnapshot,
16435
16474
  data: {
@@ -16447,13 +16486,16 @@ function record(options = {}) {
16447
16486
  }
16448
16487
  });
16449
16488
  };
16450
- const wrappedScrollEmit = (p) => wrappedEmit({
16451
- type: EventType.IncrementalSnapshot,
16452
- data: {
16453
- source: IncrementalSource.Scroll,
16454
- ...p
16455
- }
16456
- });
16489
+ const wrappedScrollEmit = (p) => {
16490
+ lastScrollEmitTime = nowTimestamp();
16491
+ wrappedEmit({
16492
+ type: EventType.IncrementalSnapshot,
16493
+ data: {
16494
+ source: IncrementalSource.Scroll,
16495
+ ...p
16496
+ }
16497
+ });
16498
+ };
16457
16499
  const wrappedCanvasMutationEmit = (p) => wrappedEmit({
16458
16500
  type: EventType.IncrementalSnapshot,
16459
16501
  data: {
@@ -16537,9 +16579,19 @@ function record(options = {}) {
16537
16579
  mutationCb: recordVisibility ? wrappedVisibilityEmit : () => {
16538
16580
  },
16539
16581
  notifyActivity: checkoutEveryNvm != null ? (count) => {
16582
+ const now = nowTimestamp();
16583
+ const scrollRecent = now - lastScrollEmitTime < scrollSettleTime;
16584
+ const mutationRecent = now - lastSignificantMutationTime < mutationGracePeriod;
16585
+ if (scrollRecent && !mutationRecent) {
16586
+ return;
16587
+ }
16588
+ if (mutationRecent && hadVisibilityCheckoutInGrace) {
16589
+ return;
16590
+ }
16540
16591
  visibilityMutationCount += count;
16541
16592
  if (visibilityMutationCount >= checkoutEveryNvm) {
16542
16593
  visibilityMutationCount = 0;
16594
+ hadVisibilityCheckoutInGrace = true;
16543
16595
  if (checkoutDebounce) {
16544
16596
  if (!checkoutPending) {
16545
16597
  checkoutPending = true;
@@ -16781,6 +16833,7 @@ function record(options = {}) {
16781
16833
  recordCanvas,
16782
16834
  inlineImages,
16783
16835
  userTriggeredOnInput,
16836
+ trustSyntheticInput,
16784
16837
  collectFonts,
16785
16838
  doc,
16786
16839
  maskInputFn,
@@ -16857,6 +16910,43 @@ function record(options = {}) {
16857
16910
  );
16858
16911
  }
16859
16912
  return () => {
16913
+ if (recording) {
16914
+ const activeEl = document.activeElement;
16915
+ if (activeEl && INPUT_TAGS.includes(activeEl.tagName)) {
16916
+ const inputEl = activeEl;
16917
+ const id = mirror.getId(inputEl);
16918
+ if (id !== -1) {
16919
+ const lastValue = lastInputValueMap.get(inputEl);
16920
+ let text = inputEl.value;
16921
+ let isChecked = false;
16922
+ const type = getInputType(inputEl) || "";
16923
+ if (type === "radio" || type === "checkbox") {
16924
+ isChecked = inputEl.checked;
16925
+ } else if (maskInputOptions[inputEl.tagName.toLowerCase()] || maskInputOptions[type]) {
16926
+ text = maskInputValue({
16927
+ element: inputEl,
16928
+ maskInputOptions,
16929
+ tagName: inputEl.tagName,
16930
+ type,
16931
+ value: text,
16932
+ maskInputFn
16933
+ });
16934
+ }
16935
+ if (!lastValue || lastValue.text !== text || lastValue.isChecked !== isChecked) {
16936
+ const inputData = userTriggeredOnInput ? { text, isChecked, userTriggered: false } : { text, isChecked };
16937
+ lastInputValueMap.set(inputEl, inputData);
16938
+ wrappedEmit({
16939
+ type: EventType.IncrementalSnapshot,
16940
+ data: {
16941
+ source: IncrementalSource.Input,
16942
+ ...inputData,
16943
+ id
16944
+ }
16945
+ });
16946
+ }
16947
+ }
16948
+ }
16949
+ }
16860
16950
  if (checkoutDebounceTimer) {
16861
16951
  clearTimeout(checkoutDebounceTimer);
16862
16952
  checkoutDebounceTimer = null;