@appsurify-testmap/rrweb 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.
package/dist/rrweb.cjs CHANGED
@@ -15922,7 +15922,8 @@ function initInputObserver({
15922
15922
  maskInputOptions,
15923
15923
  maskInputFn,
15924
15924
  sampling,
15925
- userTriggeredOnInput
15925
+ userTriggeredOnInput,
15926
+ trustSyntheticInput
15926
15927
  }) {
15927
15928
  function eventHandler(event) {
15928
15929
  let target = getEventTarget(event);
@@ -15972,34 +15973,53 @@ function initInputObserver({
15972
15973
  function cbWithDedup(target, v2) {
15973
15974
  const lastInputValue = lastInputValueMap.get(target);
15974
15975
  const el = target;
15975
- const hasPlaceholder = el.hasAttribute("placeholder");
15976
- const isEmpty = el.value === "";
15977
- const isDefaultEmpty = typeof el.defaultValue === "string" ? el.defaultValue === "" : true;
15978
- const isNonUser = !v2.userTriggered;
15979
- const isRepeatEmpty = !lastInputValue || lastInputValue.text === "";
15980
- const isLikelyPhantom = hasPlaceholder && isEmpty && isDefaultEmpty && isRepeatEmpty && isNonUser && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
15981
- const isRenderDrivenTextInput = el.tagName === "INPUT" && el.type === "text" && !v2.userTriggered && v2.text === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder");
15982
- const isValueFromDefault = !v2.userTriggered && el.value === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder") && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
15983
- const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
15984
- const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
15985
- if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
15986
- console.debug(
15987
- `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
15988
- {
15989
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
15990
- node: index.describeNode(el),
15991
- tag: el.tagName,
15992
- nodeType: el.nodeType,
15993
- attribute: el.attributes,
15994
- value: el.value,
15995
- isLikelyPhantom,
15996
- isRenderDrivenTextInput,
15997
- isValueFromDefault,
15998
- isPhantomCheckbox,
15999
- isPhantomRadio
16000
- }
16001
- );
16002
- return;
15976
+ if (trustSyntheticInput) {
15977
+ const isInitialEmpty = !v2.userTriggered && el.value === "" && !v2.isChecked && !lastInputValue;
15978
+ const isSelectDefaultSelection = el.tagName === "SELECT" && !v2.userTriggered && !lastInputValue && el.selectedIndex === 0;
15979
+ if (isInitialEmpty || isSelectDefaultSelection) {
15980
+ console.debug(
15981
+ `[${nowTimestamp()}] [rrweb:record/observer] phantom input ignored (trust mode)`,
15982
+ {
15983
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
15984
+ node: index.describeNode(el),
15985
+ tag: el.tagName,
15986
+ value: el.value,
15987
+ isInitialEmpty,
15988
+ isSelectDefaultSelection
15989
+ }
15990
+ );
15991
+ return;
15992
+ }
15993
+ } else {
15994
+ const hasPlaceholder = el.hasAttribute("placeholder");
15995
+ const isEmpty = el.value === "";
15996
+ const isDefaultEmpty = typeof el.defaultValue === "string" ? el.defaultValue === "" : true;
15997
+ const isNonUser = !v2.userTriggered;
15998
+ const isRepeatEmpty = !lastInputValue || lastInputValue.text === "";
15999
+ const isLikelyPhantom = hasPlaceholder && isEmpty && isDefaultEmpty && isRepeatEmpty && isNonUser && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
16000
+ const isRenderDrivenTextInput = el.tagName === "INPUT" && el.type === "text" && !v2.userTriggered && v2.text === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder");
16001
+ const isValueFromDefault = !v2.userTriggered && el.value === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder") && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
16002
+ const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
16003
+ const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
16004
+ if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
16005
+ console.debug(
16006
+ `[${nowTimestamp()}] [rrweb:record/observer] ⛔ phantom input ignored`,
16007
+ {
16008
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call
16009
+ node: index.describeNode(el),
16010
+ tag: el.tagName,
16011
+ nodeType: el.nodeType,
16012
+ attribute: el.attributes,
16013
+ value: el.value,
16014
+ isLikelyPhantom,
16015
+ isRenderDrivenTextInput,
16016
+ isValueFromDefault,
16017
+ isPhantomCheckbox,
16018
+ isPhantomRadio
16019
+ }
16020
+ );
16021
+ return;
16022
+ }
16003
16023
  }
16004
16024
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
16005
16025
  lastInputValueMap.set(target, v2);
@@ -18050,8 +18070,15 @@ class NavigationManager {
18050
18070
  handleNavigation(data) {
18051
18071
  if (this.disabled) return;
18052
18072
  if (this.locked) return;
18053
- this.cancelTimers();
18054
- this.disconnectSettlingObserver();
18073
+ if (this.pendingNavigation) {
18074
+ this.cancelTimers();
18075
+ this.disconnectSettlingObserver();
18076
+ this.pendingNavigation = null;
18077
+ this.onSnapshot(true);
18078
+ } else {
18079
+ this.cancelTimers();
18080
+ this.disconnectSettlingObserver();
18081
+ }
18055
18082
  this.pendingNavigation = data;
18056
18083
  if (this.frozen) {
18057
18084
  return;
@@ -18258,7 +18285,7 @@ class ProcessedNodeManager {
18258
18285
  destroy() {
18259
18286
  }
18260
18287
  }
18261
- const version$1 = "3.5.0-alpha.1";
18288
+ const version$1 = "3.10.0-alpha.1";
18262
18289
  let wrappedEmit;
18263
18290
  let takeFullSnapshot$1;
18264
18291
  let canvasManager;
@@ -18307,6 +18334,7 @@ function record(options = {}) {
18307
18334
  recordAfter = options.recordAfter === "DOMContentLoaded" ? options.recordAfter : "load",
18308
18335
  flushCustomEvent = options.flushCustomEvent !== void 0 ? options.flushCustomEvent : "after",
18309
18336
  userTriggeredOnInput = false,
18337
+ trustSyntheticInput = false,
18310
18338
  collectFonts = false,
18311
18339
  inlineImages = false,
18312
18340
  plugins,
@@ -18381,6 +18409,11 @@ function record(options = {}) {
18381
18409
  let checkoutPending = false;
18382
18410
  let checkoutDebounceTimer = null;
18383
18411
  let checkoutFreezeTimestamp = null;
18412
+ let lastScrollEmitTime = 0;
18413
+ const scrollSettleTime = (sampling.scroll || 100) * 2;
18414
+ let lastSignificantMutationTime = 0;
18415
+ const mutationGracePeriod = 500;
18416
+ let hadVisibilityCheckoutInGrace = false;
18384
18417
  const eventProcessor = (e2) => {
18385
18418
  for (const plugin3 of plugins || []) {
18386
18419
  if (plugin3.eventProcessor) {
@@ -18471,6 +18504,12 @@ function record(options = {}) {
18471
18504
  }
18472
18505
  };
18473
18506
  const wrappedMutationEmit = (m) => {
18507
+ var _a2, _b;
18508
+ const totalChanges = (((_a2 = m.adds) == null ? void 0 : _a2.length) ?? 0) + (((_b = m.removes) == null ? void 0 : _b.length) ?? 0);
18509
+ if (totalChanges > 10) {
18510
+ lastSignificantMutationTime = nowTimestamp();
18511
+ hadVisibilityCheckoutInGrace = false;
18512
+ }
18474
18513
  wrappedEmit({
18475
18514
  type: EventType.IncrementalSnapshot,
18476
18515
  data: {
@@ -18488,13 +18527,16 @@ function record(options = {}) {
18488
18527
  }
18489
18528
  });
18490
18529
  };
18491
- const wrappedScrollEmit = (p) => wrappedEmit({
18492
- type: EventType.IncrementalSnapshot,
18493
- data: {
18494
- source: IncrementalSource.Scroll,
18495
- ...p
18496
- }
18497
- });
18530
+ const wrappedScrollEmit = (p) => {
18531
+ lastScrollEmitTime = nowTimestamp();
18532
+ wrappedEmit({
18533
+ type: EventType.IncrementalSnapshot,
18534
+ data: {
18535
+ source: IncrementalSource.Scroll,
18536
+ ...p
18537
+ }
18538
+ });
18539
+ };
18498
18540
  const wrappedCanvasMutationEmit = (p) => wrappedEmit({
18499
18541
  type: EventType.IncrementalSnapshot,
18500
18542
  data: {
@@ -18578,9 +18620,19 @@ function record(options = {}) {
18578
18620
  mutationCb: recordVisibility ? wrappedVisibilityEmit : () => {
18579
18621
  },
18580
18622
  notifyActivity: checkoutEveryNvm != null ? (count) => {
18623
+ const now = nowTimestamp();
18624
+ const scrollRecent = now - lastScrollEmitTime < scrollSettleTime;
18625
+ const mutationRecent = now - lastSignificantMutationTime < mutationGracePeriod;
18626
+ if (scrollRecent && !mutationRecent) {
18627
+ return;
18628
+ }
18629
+ if (mutationRecent && hadVisibilityCheckoutInGrace) {
18630
+ return;
18631
+ }
18581
18632
  visibilityMutationCount += count;
18582
18633
  if (visibilityMutationCount >= checkoutEveryNvm) {
18583
18634
  visibilityMutationCount = 0;
18635
+ hadVisibilityCheckoutInGrace = true;
18584
18636
  if (checkoutDebounce) {
18585
18637
  if (!checkoutPending) {
18586
18638
  checkoutPending = true;
@@ -18822,6 +18874,7 @@ function record(options = {}) {
18822
18874
  recordCanvas,
18823
18875
  inlineImages,
18824
18876
  userTriggeredOnInput,
18877
+ trustSyntheticInput,
18825
18878
  collectFonts,
18826
18879
  doc,
18827
18880
  maskInputFn,
@@ -18898,6 +18951,43 @@ function record(options = {}) {
18898
18951
  );
18899
18952
  }
18900
18953
  return () => {
18954
+ if (recording) {
18955
+ const activeEl = document.activeElement;
18956
+ if (activeEl && INPUT_TAGS.includes(activeEl.tagName)) {
18957
+ const inputEl = activeEl;
18958
+ const id = mirror.getId(inputEl);
18959
+ if (id !== -1) {
18960
+ const lastValue = lastInputValueMap.get(inputEl);
18961
+ let text = inputEl.value;
18962
+ let isChecked = false;
18963
+ const type = getInputType(inputEl) || "";
18964
+ if (type === "radio" || type === "checkbox") {
18965
+ isChecked = inputEl.checked;
18966
+ } else if (maskInputOptions[inputEl.tagName.toLowerCase()] || maskInputOptions[type]) {
18967
+ text = maskInputValue({
18968
+ element: inputEl,
18969
+ maskInputOptions,
18970
+ tagName: inputEl.tagName,
18971
+ type,
18972
+ value: text,
18973
+ maskInputFn
18974
+ });
18975
+ }
18976
+ if (!lastValue || lastValue.text !== text || lastValue.isChecked !== isChecked) {
18977
+ const inputData = userTriggeredOnInput ? { text, isChecked, userTriggered: false } : { text, isChecked };
18978
+ lastInputValueMap.set(inputEl, inputData);
18979
+ wrappedEmit({
18980
+ type: EventType.IncrementalSnapshot,
18981
+ data: {
18982
+ source: IncrementalSource.Input,
18983
+ ...inputData,
18984
+ id
18985
+ }
18986
+ });
18987
+ }
18988
+ }
18989
+ }
18990
+ }
18901
18991
  if (checkoutDebounceTimer) {
18902
18992
  clearTimeout(checkoutDebounceTimer);
18903
18993
  checkoutDebounceTimer = null;
@@ -21837,7 +21927,7 @@ class Replayer {
21837
21927
  this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
21838
21928
  }
21839
21929
  }
21840
- const version = "3.5.0-alpha.1";
21930
+ const version = "3.10.0-alpha.1";
21841
21931
  const { getVersion } = record;
21842
21932
  const { isRecording } = record;
21843
21933
  const { flushCustomEventQueue } = record;