@rpascene/shared 0.30.14 → 0.30.15

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.
@@ -63,7 +63,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
63
63
  rect.left += basePoint.left;
64
64
  rect.top += basePoint.top;
65
65
  }
66
- if (rect.height >= window.innerHeight && rect.width >= window.innerWidth) return null;
66
+ if (rect.height >= currentWindow.innerHeight && rect.width >= currentWindow.innerWidth) return null;
67
67
  if ((0, external_dom_util_js_namespaceObject.isFormElement)(node, currentWindow)) {
68
68
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
69
69
  let valueContent = attributes.value || attributes.placeholder || node.textContent || '';
@@ -98,6 +98,10 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
98
98
  if ((0, external_dom_util_js_namespaceObject.isButtonElement)(node, currentWindow)) {
99
99
  const rect = mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom);
100
100
  if (!rect) return null;
101
+ if (0 !== basePoint.left || 0 !== basePoint.top) {
102
+ rect.left += basePoint.left;
103
+ rect.top += basePoint.top;
104
+ }
101
105
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
102
106
  const pseudo = (0, external_util_js_namespaceObject.getPseudoElementContent)(node, currentWindow);
103
107
  const content = node.innerText || pseudo.before || pseudo.after || '';
@@ -287,6 +291,20 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
287
291
  }
288
292
  return nodeInfo;
289
293
  }
294
+ function getCssScale(ele) {
295
+ try {
296
+ const { width, height } = ele.getBoundingClientRect();
297
+ return {
298
+ cssScaleX: Number((width / ele.offsetWidth).toFixed(1)),
299
+ cssScaleY: Number((height / ele.offsetHeight).toFixed(1))
300
+ };
301
+ } catch (error) {
302
+ return {
303
+ cssScaleX: 1,
304
+ cssScaleY: 1
305
+ };
306
+ }
307
+ }
290
308
  const rootNodeInfo = dfs(startNode, window, document, baseZoom, basePoint);
291
309
  if (Array.isArray(rootNodeInfo)) topChildren.push(...rootNodeInfo);
292
310
  else if (rootNodeInfo) topChildren.push(rootNodeInfo);
@@ -295,6 +313,7 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
295
313
  for(let i = 0; i < iframes.length; i++){
296
314
  const iframe = iframes[i];
297
315
  const iframeInfo = collectElementInfo(iframe, window, document, 1);
316
+ const baseZoom = getCssScale(iframe).cssScaleX;
298
317
  if (iframeInfo) {
299
318
  const iframeChildren = await (0, external_cs_postmessage_js_namespaceObject.postWindowMessage)(iframe.contentWindow, window, {
300
319
  action: 'extractTreeNode',