@checksum-ai/runtime 1.1.34 → 1.1.35

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
@@ -29632,13 +29632,24 @@
29632
29632
  sleepAfter
29633
29633
  });
29634
29634
  }
29635
- getLastEventTimestamps() {
29636
- const lastEvent = this.events[this.events.length - 1];
29635
+ async getLastEventTimestamps(snapshot2 = false) {
29636
+ const lastEvent = snapshot2 ? await this.findLastFullSnapshotEvent() : this.events[this.events.length - 1];
29637
29637
  return {
29638
29638
  timestamp: lastEvent?.timestamp,
29639
29639
  originalTimestamp: lastEvent?.originalTimestamp
29640
29640
  };
29641
29641
  }
29642
+ async findLastFullSnapshotEvent() {
29643
+ const event = this.events.reduce((snapshotEvent, event2) => {
29644
+ return event2.type === EventType.FullSnapshot ? event2 : snapshotEvent;
29645
+ }, void 0);
29646
+ if (event) {
29647
+ return event;
29648
+ }
29649
+ console.log("waiting for full snapshot event...");
29650
+ await (0, import_await_sleep3.default)(1e3);
29651
+ return this.findLastFullSnapshotEvent();
29652
+ }
29642
29653
  };
29643
29654
 
29644
29655
  // ../browser-lib/src/session-record-replay/events-streamer.ts
@@ -31573,7 +31584,8 @@
31573
31584
  clear = true,
31574
31585
  shouldFlipHighlightTextOutsideViewport = true,
31575
31586
  pointerEvents,
31576
- classNames = []
31587
+ classNames = [],
31588
+ renderDocument
31577
31589
  } = {}) {
31578
31590
  if (clear) {
31579
31591
  this.clearHighlights();
@@ -31581,16 +31593,30 @@
31581
31593
  if (!element) {
31582
31594
  return;
31583
31595
  }
31584
- const elementDocument = element.ownerDocument;
31596
+ const iframeOffset = { left: 0, top: 0, right: 0, bottom: 0 };
31597
+ if (renderDocument !== element.ownerDocument) {
31598
+ let iframe = element.ownerDocument.defaultView?.frameElement;
31599
+ while (iframe) {
31600
+ const iframeRect = iframe.getBoundingClientRect();
31601
+ iframeOffset.left += iframeRect.left;
31602
+ iframeOffset.top += iframeRect.top;
31603
+ iframe = iframe.ownerDocument.defaultView?.frameElement;
31604
+ }
31605
+ }
31606
+ const elementDocument = renderDocument ?? element.ownerDocument;
31585
31607
  const isFixed = isAncestorOrSelfFixed(element);
31586
- const rect = element.getBoundingClientRect();
31608
+ const elementBoundingBox = element.getBoundingClientRect();
31609
+ const elementPositionWithOffset = {
31610
+ top: elementBoundingBox.top + iframeOffset.top,
31611
+ left: elementBoundingBox.left + iframeOffset.left
31612
+ };
31587
31613
  const newElement = elementDocument.createElement("div");
31588
31614
  newElement.style.outline = "2px dashed rgba(255,0,0,.75)";
31589
31615
  newElement.style.position = isFixed ? "fixed" : "absolute";
31590
- newElement.style.left = rect.left + "px";
31591
- newElement.style.top = rect.top + "px";
31592
- newElement.style.width = rect.right - rect.left + "px";
31593
- newElement.style.height = rect.bottom - rect.top + "px";
31616
+ newElement.style.left = elementPositionWithOffset.left + "px";
31617
+ newElement.style.top = elementPositionWithOffset.top + "px";
31618
+ newElement.style.width = elementBoundingBox.width + "px";
31619
+ newElement.style.height = elementBoundingBox.height + "px";
31594
31620
  newElement.style.pointerEvents = pointerEvents ?? "none";
31595
31621
  newElement.style.zIndex = "2147483647";
31596
31622
  newElement.className = ["checksum-dom-cache-ignore", ...classNames].join(
@@ -31626,7 +31652,7 @@
31626
31652
  );
31627
31653
  hoverTextEl.innerText = text;
31628
31654
  hoverTextEl.style.fontSize = "12px";
31629
- hoverTextEl.style.width = textWidthType === "rect" ? `${rect.width}px` : "auto";
31655
+ hoverTextEl.style.width = textWidthType === "rect" ? `${elementBoundingBox.width}px` : "auto";
31630
31656
  hoverTextEl.style.background = "#000000a1";
31631
31657
  hoverTextEl.style.color = "white";
31632
31658
  hoverTextEl.style.padding = "5px";
@@ -31634,9 +31660,9 @@
31634
31660
  hoverTextEl.style.pointerEvents = "none";
31635
31661
  hoverTextEl.style.userSelect = "none";
31636
31662
  if (textPosition === "above") {
31637
- hoverTextEl.style.bottom = `${rect.height}px`;
31663
+ hoverTextEl.style.bottom = `${elementBoundingBox.height}px`;
31638
31664
  } else if (textPosition === "below") {
31639
- hoverTextEl.style.top = `${rect.height}px`;
31665
+ hoverTextEl.style.top = `${elementBoundingBox.height}px`;
31640
31666
  }
31641
31667
  this.mergeStyle(hoverTextEl, textStyle);
31642
31668
  newElement.appendChild(hoverTextEl);
@@ -31654,17 +31680,17 @@
31654
31680
  elementDocument.body.appendChild(newElement);
31655
31681
  if (textPosition === "above" && getHeightOfCroppedElementAboveViewport(hoverTextEl) > 0) {
31656
31682
  hoverTextEl.style.bottom = "initial";
31657
- hoverTextEl.style.top = `${rect.height}px`;
31683
+ hoverTextEl.style.top = `${elementBoundingBox.height}px`;
31658
31684
  } else if (textPosition === "below" && getHeightsOfCroppedElementBelowViewport(hoverTextEl) > 0) {
31659
31685
  hoverTextEl.style.top = "initial";
31660
- hoverTextEl.style.bottom = `${rect.height}px`;
31686
+ hoverTextEl.style.bottom = `${elementBoundingBox.height}px`;
31661
31687
  }
31662
31688
  this.lastHighlights.push(newElement);
31663
31689
  if (shouldFlipHighlightTextOutsideViewport) {
31664
31690
  this.flipHighlightTextPositionOutsideViewport(
31665
31691
  hoverTextEl,
31666
31692
  textPosition,
31667
- rect.height
31693
+ elementBoundingBox.height
31668
31694
  );
31669
31695
  }
31670
31696
  }
@@ -34271,7 +34297,7 @@
34271
34297
  return;
34272
34298
  }
34273
34299
  }
34274
- if (target instanceof this.defaultView.HTMLIFrameElement) {
34300
+ if (isNodeInstanceOf(target, "HTMLIFrameElement")) {
34275
34301
  this.handleSubDocument(
34276
34302
  target.contentDocument,
34277
34303
  target.contentDocument.defaultView
@@ -34281,10 +34307,11 @@
34281
34307
  if (this.subDocumentInspector) {
34282
34308
  this.stopSubDocumentInspector(true);
34283
34309
  }
34284
- if (!(target instanceof this.defaultView.Element)) {
34310
+ if (!isNodeInstanceOf(target, "HTMLElement")) {
34285
34311
  return;
34286
34312
  }
34287
- if (target === this.hoveredElement || target.matches(".element-inspector-ignore")) {
34313
+ const targetElement = target;
34314
+ if (targetElement === this.hoveredElement || targetElement.matches(".element-inspector-ignore")) {
34288
34315
  return;
34289
34316
  }
34290
34317
  elementHighlighter.clearHighlights();
@@ -34294,14 +34321,15 @@
34294
34321
  });
34295
34322
  }
34296
34323
  const { locator, selector, parentFramesSelectors } = await this.playwrightElementSelectorGenerator.getSelectorAndLocator(
34297
- target
34324
+ targetElement
34298
34325
  );
34299
- elementHighlighter.highlightElement(target, {
34326
+ elementHighlighter.highlightElement(targetElement, {
34300
34327
  text: locator.replace("frameLocator('iframe').", ""),
34301
34328
  textPosition: "below",
34302
34329
  textWidthType: "auto",
34303
34330
  pointerEvents: "none",
34304
- classNames: ["element-inspector-ignore"]
34331
+ classNames: ["element-inspector-ignore"],
34332
+ renderDocument: this.defaultView.top.document
34305
34333
  });
34306
34334
  const elementByLocator = await this.playwrightElementSelectorGenerator.selector(
34307
34335
  selector,
@@ -34312,10 +34340,11 @@
34312
34340
  // highlightStyle: { outlineColor: "blue" },
34313
34341
  clear: false,
34314
34342
  pointerEvents: "none",
34315
- classNames: ["element-inspector-ignore"]
34343
+ classNames: ["element-inspector-ignore"],
34344
+ renderDocument: this.defaultView.top.document
34316
34345
  });
34317
34346
  }
34318
- this.hoveredElement = target;
34347
+ this.hoveredElement = targetElement;
34319
34348
  this.hoveredElementSelection = { locator, selector, parentFramesSelectors };
34320
34349
  this.wasHoveredElementSelected = false;
34321
34350
  target.addEventListener("click", this.onClick, {
@@ -34471,16 +34500,14 @@ ${data.locator}`
34471
34500
  }
34472
34501
  this.sessionRecorder.addCustomEvent("assertion" /* Assertion */, {
34473
34502
  matcher: `toHaveText("${result2}")`,
34474
- locator: data.locator,
34475
- thought: `Element should have text: ${result2}`
34503
+ locator: data.locator
34476
34504
  });
34477
34505
  }, "toHaveTextHandler");
34478
34506
  this.toBeVisibleHandler = /* @__PURE__ */ __name(() => (messageEvent) => {
34479
34507
  const data = messageEvent?.data?.data;
34480
34508
  this.sessionRecorder.addCustomEvent("assertion" /* Assertion */, {
34481
34509
  matcher: `toBeVisible()`,
34482
- locator: data.locator,
34483
- thought: `Element ${data.locator} should be visible`
34510
+ locator: data.locator
34484
34511
  });
34485
34512
  }, "toBeVisibleHandler");
34486
34513
  this.sessionRecorder = sessionRecorder;
@@ -35557,8 +35584,8 @@ ${data.locator}`
35557
35584
  goLive() {
35558
35585
  return this.sessionReplayer.goLive();
35559
35586
  }
35560
- getLastEventTimestamps() {
35561
- return this.sessionReplayer.getLastEventTimestamps();
35587
+ getLastEventTimestamps(snapshot2 = false) {
35588
+ return this.sessionReplayer.getLastEventTimestamps(snapshot2);
35562
35589
  }
35563
35590
  };
35564
35591