@checksum-ai/runtime 1.1.30 → 1.1.31

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/checksumlib.js CHANGED
@@ -29510,6 +29510,21 @@
29510
29510
  if (events.length === this.currentTraveledNumberOfEvents) {
29511
29511
  return;
29512
29512
  }
29513
+ const lastCheckoutEventIndex = events.reduce(
29514
+ (lastCheckoutEventIndex2, event, index2) => {
29515
+ return event.isCheckout && event.type === EventType.Meta ? index2 : lastCheckoutEventIndex2;
29516
+ },
29517
+ void 0
29518
+ );
29519
+ if (lastCheckoutEventIndex !== void 0) {
29520
+ console.log(
29521
+ "lastCheckoutEventIndex:",
29522
+ lastCheckoutEventIndex,
29523
+ "number of events to render:",
29524
+ events.length - lastCheckoutEventIndex
29525
+ );
29526
+ events.splice(lastCheckoutEventIndex);
29527
+ }
29513
29528
  this.stop();
29514
29529
  this.events = [];
29515
29530
  this.castedEvents = [];
@@ -32748,21 +32763,23 @@
32748
32763
  }));
32749
32764
  }
32750
32765
  }
32751
- let filteredCandidated = [];
32766
+ let filteredCandidates = [];
32752
32767
  try {
32753
- filteredCandidated = locatorsCandidates.reduce((acc, candidate) => {
32768
+ for (const candidate of locatorsCandidates) {
32754
32769
  this.checkTimeout();
32755
- acc.push(
32756
- ...candidate.elements.length === 1 ? [candidate] : this.reduceMultiCandidates(candidate)
32757
- );
32758
- return acc;
32759
- }, []);
32770
+ if (candidate.elements.length === 1) {
32771
+ filteredCandidates.push(candidate);
32772
+ continue;
32773
+ }
32774
+ await awaitSleep(100);
32775
+ filteredCandidates.push(...this.reduceMultiCandidates(candidate));
32776
+ }
32760
32777
  } catch (error) {
32761
32778
  if (error instanceof TimeoutError) {
32762
32779
  console.log("Timeout error");
32763
32780
  }
32764
32781
  }
32765
- if (!filteredCandidated?.length) {
32782
+ if (!filteredCandidates?.length) {
32766
32783
  console.log("no single element selector found");
32767
32784
  if (!expandCSSKeyElements) {
32768
32785
  return this.generate(element, cssKeyElements, {
@@ -32777,19 +32794,19 @@
32777
32794
  if (addCSSSelectorGenerator) {
32778
32795
  const cssSelection = await this.addCSSSelectorGenerator();
32779
32796
  if (cssSelection) {
32780
- filteredCandidated.unshift(cssSelection);
32797
+ filteredCandidates.unshift(cssSelection);
32781
32798
  }
32782
32799
  }
32783
32800
  if (this.rootNode === document && useTextContent) {
32784
32801
  const { selector, locator } = await new PlaywrightElementSelectorGenerator().getSelectorAndLocator(
32785
32802
  this.targetElement
32786
32803
  );
32787
- filteredCandidated.unshift({
32804
+ filteredCandidates.unshift({
32788
32805
  selector,
32789
32806
  locator
32790
32807
  });
32791
32808
  }
32792
- return filteredCandidated.map(({ selector, locator }) => ({
32809
+ return filteredCandidates.map(({ selector, locator }) => ({
32793
32810
  selector,
32794
32811
  locator
32795
32812
  }));
@@ -32885,25 +32902,33 @@
32885
32902
  ({ name, value }) => value.length < 30 && !COVERED_ATTRIBUTES.includes(name)
32886
32903
  );
32887
32904
  newFeatures.forEach((feature) => {
32888
- if (added.length > limit - 1) {
32889
- return;
32890
- }
32891
- const selector = `[${feature.name}${feature.value ? `="${feature.value}"` : ""}]`;
32892
32905
  try {
32893
- if (element.parentElement?.querySelectorAll(selector).length > 1) {
32906
+ if (added.length > limit - 1) {
32894
32907
  return;
32895
32908
  }
32909
+ const selector = `[${feature.name}${feature.value ? `="${feature.value}"` : ""}]`;
32910
+ try {
32911
+ if (!element.parentElement || element.parentElement.querySelectorAll(selector).length > 1) {
32912
+ return;
32913
+ }
32914
+ } catch (error) {
32915
+ console.warn(`Error checking selector - ${selector}, continuing`);
32916
+ return;
32917
+ }
32918
+ if (!cssKeyElements.some((el) => el.selector.includes(selector)) && this.getLocatorBase(element).locator(selector).element === element) {
32919
+ const newFeature = {
32920
+ element,
32921
+ selector
32922
+ };
32923
+ cssKeyElements.push(newFeature);
32924
+ added.push(newFeature);
32925
+ }
32896
32926
  } catch (error) {
32897
- console.warn(`Error checking selector - ${selector}, continuing`);
32898
- return;
32899
- }
32900
- if (!cssKeyElements.some((el) => el.selector.includes(selector)) && this.getLocatorBase(element).locator(selector).element === element) {
32901
- const newFeature = {
32902
- element,
32903
- selector
32904
- };
32905
- cssKeyElements.push(newFeature);
32906
- added.push(newFeature);
32927
+ console.warn(
32928
+ "Error processing css key feature",
32929
+ { name: feature.name, value: feature.value },
32930
+ error
32931
+ );
32907
32932
  }
32908
32933
  });
32909
32934
  element = element.parentElement;
@@ -34584,7 +34609,8 @@ ${data.locator}`
34584
34609
  this.initialized = true;
34585
34610
  }
34586
34611
  if (initSessionRecorder) {
34587
- this.sessionMirror = new SessionRecorder((event) => {
34612
+ this.sessionMirror = new SessionRecorder((event, isCheckout) => {
34613
+ event.isCheckout = isCheckout;
34588
34614
  window.checksumSendBroadcastMessage?.("rrweb", [event]);
34589
34615
  rrwebEventsStorageManager.onRRwebEvent(event);
34590
34616
  }, config.recordOptions);