@midscene/shared 0.17.4-beta-20250528162713.0 → 0.17.4

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.
@@ -253,7 +253,7 @@ var isElementCovered = (el, rect, currentWindow) => {
253
253
  });
254
254
  return true;
255
255
  };
256
- function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOnly = true) {
256
+ function elementRect(el, currentWindow, currentDocument, baseZoom = 1) {
257
257
  if (!el) {
258
258
  logger(el, "Element is not in the DOM hierarchy");
259
259
  return false;
@@ -277,21 +277,11 @@ function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOn
277
277
  if (baseZoom === 1 && isElementCovered(el, rect, currentWindow)) {
278
278
  return false;
279
279
  }
280
- const scrollLeft = currentWindow.pageXOffset || currentDocument.documentElement.scrollLeft;
281
- const scrollTop = currentWindow.pageYOffset || currentDocument.documentElement.scrollTop;
282
- const viewportWidth = currentWindow.innerWidth || currentDocument.documentElement.clientWidth;
283
- const viewportHeight = currentWindow.innerHeight || currentDocument.documentElement.clientHeight;
284
- const isPartiallyInViewport = visibleOnly ? isElementPartiallyInViewport(rect, currentWindow, currentDocument) : true;
285
- if (!isPartiallyInViewport) {
286
- logger(el, "Element is completely outside the viewport", {
287
- rect,
288
- viewportHeight,
289
- viewportWidth,
290
- scrollTop,
291
- scrollLeft
292
- });
293
- return false;
294
- }
280
+ const isVisible = isElementPartiallyInViewport(
281
+ rect,
282
+ currentWindow,
283
+ currentDocument
284
+ );
295
285
  let parent = el;
296
286
  const parentUntilNonStatic = (currentNode) => {
297
287
  let parent2 = currentNode?.parentElement;
@@ -335,7 +325,8 @@ function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOn
335
325
  top: Math.round(rect.top),
336
326
  width: Math.round(rect.width),
337
327
  height: Math.round(rect.height),
338
- zoom: rect.zoom
328
+ zoom: rect.zoom,
329
+ isVisible
339
330
  };
340
331
  }
341
332
  function getNodeAttributes(node, currentWindow) {
@@ -412,25 +403,20 @@ function tagNameOfNode(node) {
412
403
  let tagName = "";
413
404
  if (node instanceof HTMLElement) {
414
405
  tagName = node.tagName.toLowerCase();
415
- }
416
- const parentElement = node.parentElement;
417
- if (parentElement && parentElement instanceof HTMLElement) {
418
- tagName = parentElement.tagName.toLowerCase();
406
+ } else {
407
+ const parentElement = node.parentElement;
408
+ if (parentElement && parentElement instanceof HTMLElement) {
409
+ tagName = parentElement.tagName.toLowerCase();
410
+ }
419
411
  }
420
412
  return tagName ? `<${tagName}>` : "";
421
413
  }
422
- function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }, visibleOnly = true) {
423
- const rect = elementRect(
424
- node,
425
- currentWindow,
426
- currentDocument,
427
- baseZoom,
428
- visibleOnly
429
- );
414
+ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }) {
415
+ const rect = elementRect(node, currentWindow, currentDocument, baseZoom);
430
416
  if (!rect) {
431
417
  return null;
432
418
  }
433
- if (visibleOnly && (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT)) {
419
+ if (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT) {
434
420
  return null;
435
421
  }
436
422
  if (basePoint.left !== 0 || basePoint.top !== 0) {
@@ -470,7 +456,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
470
456
  Math.round(rect.left + rect.width / 2),
471
457
  Math.round(rect.top + rect.height / 2)
472
458
  ],
473
- zoom: rect.zoom
459
+ zoom: rect.zoom,
460
+ isVisible: rect.isVisible
474
461
  };
475
462
  return elementInfo;
476
463
  }
@@ -479,8 +466,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
479
466
  node,
480
467
  currentWindow,
481
468
  currentDocument,
482
- baseZoom,
483
- visibleOnly
469
+ baseZoom
484
470
  );
485
471
  if (!rect2) {
486
472
  return null;
@@ -507,7 +493,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
507
493
  Math.round(rect2.left + rect2.width / 2),
508
494
  Math.round(rect2.top + rect2.height / 2)
509
495
  ],
510
- zoom: rect2.zoom
496
+ zoom: rect2.zoom,
497
+ isVisible: rect2.isVisible
511
498
  };
512
499
  return elementInfo;
513
500
  }
@@ -535,7 +522,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
535
522
  Math.round(rect.left + rect.width / 2),
536
523
  Math.round(rect.top + rect.height / 2)
537
524
  ],
538
- zoom: rect.zoom
525
+ zoom: rect.zoom,
526
+ isVisible: rect.isVisible
539
527
  };
540
528
  return elementInfo;
541
529
  }
@@ -568,7 +556,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
568
556
  ],
569
557
  content: text,
570
558
  rect,
571
- zoom: rect.zoom
559
+ zoom: rect.zoom,
560
+ isVisible: rect.isVisible
572
561
  };
573
562
  return elementInfo;
574
563
  }
@@ -595,7 +584,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
595
584
  Math.round(rect.left + rect.width / 2),
596
585
  Math.round(rect.top + rect.height / 2)
597
586
  ],
598
- zoom: rect.zoom
587
+ zoom: rect.zoom,
588
+ isVisible: rect.isVisible
599
589
  };
600
590
  return elementInfo;
601
591
  }
@@ -620,7 +610,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
620
610
  Math.round(rect.left + rect.width / 2),
621
611
  Math.round(rect.top + rect.height / 2)
622
612
  ],
623
- zoom: rect.zoom
613
+ zoom: rect.zoom,
614
+ isVisible: rect.isVisible
624
615
  };
625
616
  return elementInfo;
626
617
  }
@@ -669,7 +660,7 @@ function extractTreeNode(initNode, debugMode2 = false) {
669
660
  node: elementInfo,
670
661
  children: []
671
662
  };
672
- if (elementInfo?.nodeType === "BUTTON Node" /* BUTTON */ || elementInfo?.nodeType === "IMG Node" /* IMG */ || elementInfo?.nodeType === "TEXT Node" /* TEXT */ || elementInfo?.nodeType === "Anchor Node" /* A */ || elementInfo?.nodeType === "FORM_ITEM Node" /* FORM_ITEM */ || elementInfo?.nodeType === "CONTAINER Node" /* CONTAINER */) {
663
+ if (elementInfo?.nodeType === "BUTTON Node" /* BUTTON */ || elementInfo?.nodeType === "IMG Node" /* IMG */ || elementInfo?.nodeType === "TEXT Node" /* TEXT */ || elementInfo?.nodeType === "FORM_ITEM Node" /* FORM_ITEM */ || elementInfo?.nodeType === "CONTAINER Node" /* CONTAINER */) {
673
664
  return nodeInfo;
674
665
  }
675
666
  const rect = getRect(node, baseZoom, currentWindow);
@@ -724,14 +715,8 @@ function extractTreeNode(initNode, debugMode2 = false) {
724
715
  children: topChildren
725
716
  };
726
717
  }
727
- function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1, visibleOnly = true) {
728
- const selfRect = elementRect(
729
- node,
730
- currentWindow,
731
- currentDocument,
732
- baseZoom,
733
- visibleOnly
734
- );
718
+ function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1) {
719
+ const selfRect = elementRect(node, currentWindow, currentDocument, baseZoom);
735
720
  if (!selfRect)
736
721
  return null;
737
722
  let minLeft = selfRect.left;
@@ -742,13 +727,7 @@ function mergeElementAndChildrenRects(node, currentWindow, currentDocument, base
742
727
  for (let i = 0; i < child.childNodes.length; i++) {
743
728
  const sub = child.childNodes[i];
744
729
  if (sub.nodeType === 1) {
745
- const rect = elementRect(
746
- sub,
747
- currentWindow,
748
- currentDocument,
749
- baseZoom,
750
- visibleOnly
751
- );
730
+ const rect = elementRect(sub, currentWindow, currentDocument, baseZoom);
752
731
  if (rect) {
753
732
  minLeft = Math.min(minLeft, rect.left);
754
733
  minTop = Math.min(minTop, rect.top);
@@ -1,2 +1,2 @@
1
1
  import './constants.js';
2
- export { E as ElementInfo, a as ElementNode, d as descriptionOfTree, k as generateElementByPosition, j as getElementInfoByXpath, g as getNodeFromCacheList, i as getNodeInfoByXpath, h as getXpathsById, s as setNodeHashCacheListOnWindow, t as traverseTree, b as treeToList, c as webExtractNodeTree, f as webExtractNodeTreeAsString, e as webExtractTextWithPosition } from './index-113807ee.js';
2
+ export { E as ElementInfo, a as ElementNode, d as descriptionOfTree, m as generateElementByPosition, l as getElementInfoByXpath, i as getNodeFromCacheList, k as getNodeInfoByXpath, j as getXpathsById, s as setNodeHashCacheListOnWindow, t as traverseTree, b as treeToList, e as trimAttributes, c as truncateText, g as webExtractNodeTree, h as webExtractNodeTreeAsString, f as webExtractTextWithPosition } from './index-a171e36c.js';
@@ -21,7 +21,7 @@ function trimAttributes(attributes, truncateTextLength) {
21
21
  const tailorAttributes = Object.keys(attributes).reduce(
22
22
  (res, currentKey) => {
23
23
  const attributeVal = attributes[currentKey];
24
- if (currentKey === "style" || currentKey === "src" || currentKey === "htmlTagName" || currentKey === "nodeType") {
24
+ if (currentKey === "style" || currentKey === "htmlTagName" || currentKey === "nodeType") {
25
25
  return res;
26
26
  }
27
27
  res[currentKey] = truncateText(attributeVal, truncateTextLength);
@@ -32,13 +32,13 @@ function trimAttributes(attributes, truncateTextLength) {
32
32
  return tailorAttributes;
33
33
  }
34
34
  var nodeSizeThreshold = 4;
35
- function descriptionOfTree(tree, truncateTextLength, filterNonTextContent = false) {
35
+ function descriptionOfTree(tree, truncateTextLength, filterNonTextContent = false, visibleOnly = true) {
36
36
  const attributesString = (kv) => {
37
37
  return Object.entries(kv).map(
38
38
  ([key, value]) => `${key}="${truncateText(value, truncateTextLength)}"`
39
39
  ).join(" ");
40
40
  };
41
- function buildContentTree(node, indent = 0) {
41
+ function buildContentTree(node, indent = 0, visibleOnly2 = true) {
42
42
  let before = "";
43
43
  let contentWithIndent = "";
44
44
  let after = "";
@@ -46,13 +46,17 @@ function descriptionOfTree(tree, truncateTextLength, filterNonTextContent = fals
46
46
  const indentStr = " ".repeat(indent);
47
47
  let children = "";
48
48
  for (let i = 0; i < (node.children || []).length; i++) {
49
- const childContent = buildContentTree(node.children[i], indent + 1);
49
+ const childContent = buildContentTree(
50
+ node.children[i],
51
+ indent + 1,
52
+ visibleOnly2
53
+ );
50
54
  if (childContent) {
51
55
  children += `
52
56
  ${childContent}`;
53
57
  }
54
58
  }
55
- if (node.node && node.node.rect.width > nodeSizeThreshold && node.node.rect.height > nodeSizeThreshold && (!filterNonTextContent || filterNonTextContent && node.node.content)) {
59
+ if (node.node && node.node.rect.width > nodeSizeThreshold && node.node.rect.height > nodeSizeThreshold && (!filterNonTextContent || filterNonTextContent && node.node.content) && (!visibleOnly2 || visibleOnly2 && node.node.isVisible)) {
56
60
  emptyNode = false;
57
61
  let nodeTypeString;
58
62
  if (node.node.attributes?.htmlTagName) {
@@ -90,7 +94,7 @@ ${indentStr}${after}`;
90
94
  }
91
95
  return "";
92
96
  }
93
- const result = buildContentTree(tree);
97
+ const result = buildContentTree(tree, 0, visibleOnly);
94
98
  return result.replace(/^\s*\n/gm, "");
95
99
  }
96
100
  function treeToList(tree) {
@@ -391,7 +395,7 @@ var isElementCovered = (el, rect, currentWindow) => {
391
395
  });
392
396
  return true;
393
397
  };
394
- function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOnly = true) {
398
+ function elementRect(el, currentWindow, currentDocument, baseZoom = 1) {
395
399
  if (!el) {
396
400
  logger(el, "Element is not in the DOM hierarchy");
397
401
  return false;
@@ -415,21 +419,11 @@ function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOn
415
419
  if (baseZoom === 1 && isElementCovered(el, rect, currentWindow)) {
416
420
  return false;
417
421
  }
418
- const scrollLeft = currentWindow.pageXOffset || currentDocument.documentElement.scrollLeft;
419
- const scrollTop = currentWindow.pageYOffset || currentDocument.documentElement.scrollTop;
420
- const viewportWidth = currentWindow.innerWidth || currentDocument.documentElement.clientWidth;
421
- const viewportHeight = currentWindow.innerHeight || currentDocument.documentElement.clientHeight;
422
- const isPartiallyInViewport = visibleOnly ? isElementPartiallyInViewport(rect, currentWindow, currentDocument) : true;
423
- if (!isPartiallyInViewport) {
424
- logger(el, "Element is completely outside the viewport", {
425
- rect,
426
- viewportHeight,
427
- viewportWidth,
428
- scrollTop,
429
- scrollLeft
430
- });
431
- return false;
432
- }
422
+ const isVisible = isElementPartiallyInViewport(
423
+ rect,
424
+ currentWindow,
425
+ currentDocument
426
+ );
433
427
  let parent = el;
434
428
  const parentUntilNonStatic = (currentNode) => {
435
429
  let parent2 = currentNode?.parentElement;
@@ -473,7 +467,8 @@ function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOn
473
467
  top: Math.round(rect.top),
474
468
  width: Math.round(rect.width),
475
469
  height: Math.round(rect.height),
476
- zoom: rect.zoom
470
+ zoom: rect.zoom,
471
+ isVisible
477
472
  };
478
473
  }
479
474
  function getNodeAttributes(node, currentWindow) {
@@ -540,25 +535,20 @@ function tagNameOfNode(node) {
540
535
  let tagName = "";
541
536
  if (node instanceof HTMLElement) {
542
537
  tagName = node.tagName.toLowerCase();
543
- }
544
- const parentElement = node.parentElement;
545
- if (parentElement && parentElement instanceof HTMLElement) {
546
- tagName = parentElement.tagName.toLowerCase();
538
+ } else {
539
+ const parentElement = node.parentElement;
540
+ if (parentElement && parentElement instanceof HTMLElement) {
541
+ tagName = parentElement.tagName.toLowerCase();
542
+ }
547
543
  }
548
544
  return tagName ? `<${tagName}>` : "";
549
545
  }
550
- function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }, visibleOnly = true) {
551
- const rect = elementRect(
552
- node,
553
- currentWindow,
554
- currentDocument,
555
- baseZoom,
556
- visibleOnly
557
- );
546
+ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }) {
547
+ const rect = elementRect(node, currentWindow, currentDocument, baseZoom);
558
548
  if (!rect) {
559
549
  return null;
560
550
  }
561
- if (visibleOnly && (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT)) {
551
+ if (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT) {
562
552
  return null;
563
553
  }
564
554
  if (basePoint.left !== 0 || basePoint.top !== 0) {
@@ -598,7 +588,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
598
588
  Math.round(rect.left + rect.width / 2),
599
589
  Math.round(rect.top + rect.height / 2)
600
590
  ],
601
- zoom: rect.zoom
591
+ zoom: rect.zoom,
592
+ isVisible: rect.isVisible
602
593
  };
603
594
  return elementInfo;
604
595
  }
@@ -607,8 +598,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
607
598
  node,
608
599
  currentWindow,
609
600
  currentDocument,
610
- baseZoom,
611
- visibleOnly
601
+ baseZoom
612
602
  );
613
603
  if (!rect2) {
614
604
  return null;
@@ -635,7 +625,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
635
625
  Math.round(rect2.left + rect2.width / 2),
636
626
  Math.round(rect2.top + rect2.height / 2)
637
627
  ],
638
- zoom: rect2.zoom
628
+ zoom: rect2.zoom,
629
+ isVisible: rect2.isVisible
639
630
  };
640
631
  return elementInfo;
641
632
  }
@@ -663,7 +654,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
663
654
  Math.round(rect.left + rect.width / 2),
664
655
  Math.round(rect.top + rect.height / 2)
665
656
  ],
666
- zoom: rect.zoom
657
+ zoom: rect.zoom,
658
+ isVisible: rect.isVisible
667
659
  };
668
660
  return elementInfo;
669
661
  }
@@ -696,7 +688,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
696
688
  ],
697
689
  content: text,
698
690
  rect,
699
- zoom: rect.zoom
691
+ zoom: rect.zoom,
692
+ isVisible: rect.isVisible
700
693
  };
701
694
  return elementInfo;
702
695
  }
@@ -723,7 +716,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
723
716
  Math.round(rect.left + rect.width / 2),
724
717
  Math.round(rect.top + rect.height / 2)
725
718
  ],
726
- zoom: rect.zoom
719
+ zoom: rect.zoom,
720
+ isVisible: rect.isVisible
727
721
  };
728
722
  return elementInfo;
729
723
  }
@@ -748,7 +742,8 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
748
742
  Math.round(rect.left + rect.width / 2),
749
743
  Math.round(rect.top + rect.height / 2)
750
744
  ],
751
- zoom: rect.zoom
745
+ zoom: rect.zoom,
746
+ isVisible: rect.isVisible
752
747
  };
753
748
  return elementInfo;
754
749
  }
@@ -768,9 +763,9 @@ function extractTextWithPosition(initNode, debugMode2 = false) {
768
763
  dfsTopChildren({ children: elementNode.children, node: elementNode.node });
769
764
  return elementInfoArray;
770
765
  }
771
- function extractTreeNodeAsString(initNode, debugMode2 = false) {
766
+ function extractTreeNodeAsString(initNode, visibleOnly = false, debugMode2 = false) {
772
767
  const elementNode = extractTreeNode(initNode, debugMode2);
773
- return descriptionOfTree(elementNode);
768
+ return descriptionOfTree(elementNode, void 0, false, visibleOnly);
774
769
  }
775
770
  function extractTreeNode(initNode, debugMode2 = false) {
776
771
  setDebugMode(debugMode2);
@@ -801,7 +796,7 @@ function extractTreeNode(initNode, debugMode2 = false) {
801
796
  node: elementInfo,
802
797
  children: []
803
798
  };
804
- if (elementInfo?.nodeType === "BUTTON Node" /* BUTTON */ || elementInfo?.nodeType === "IMG Node" /* IMG */ || elementInfo?.nodeType === "TEXT Node" /* TEXT */ || elementInfo?.nodeType === "Anchor Node" /* A */ || elementInfo?.nodeType === "FORM_ITEM Node" /* FORM_ITEM */ || elementInfo?.nodeType === "CONTAINER Node" /* CONTAINER */) {
799
+ if (elementInfo?.nodeType === "BUTTON Node" /* BUTTON */ || elementInfo?.nodeType === "IMG Node" /* IMG */ || elementInfo?.nodeType === "TEXT Node" /* TEXT */ || elementInfo?.nodeType === "FORM_ITEM Node" /* FORM_ITEM */ || elementInfo?.nodeType === "CONTAINER Node" /* CONTAINER */) {
805
800
  return nodeInfo;
806
801
  }
807
802
  const rect = getRect(node, baseZoom, currentWindow);
@@ -856,14 +851,8 @@ function extractTreeNode(initNode, debugMode2 = false) {
856
851
  children: topChildren
857
852
  };
858
853
  }
859
- function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1, visibleOnly = true) {
860
- const selfRect = elementRect(
861
- node,
862
- currentWindow,
863
- currentDocument,
864
- baseZoom,
865
- visibleOnly
866
- );
854
+ function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1) {
855
+ const selfRect = elementRect(node, currentWindow, currentDocument, baseZoom);
867
856
  if (!selfRect)
868
857
  return null;
869
858
  let minLeft = selfRect.left;
@@ -874,13 +863,7 @@ function mergeElementAndChildrenRects(node, currentWindow, currentDocument, base
874
863
  for (let i = 0; i < child.childNodes.length; i++) {
875
864
  const sub = child.childNodes[i];
876
865
  if (sub.nodeType === 1) {
877
- const rect = elementRect(
878
- sub,
879
- currentWindow,
880
- currentDocument,
881
- baseZoom,
882
- visibleOnly
883
- );
866
+ const rect = elementRect(sub, currentWindow, currentDocument, baseZoom);
884
867
  if (rect) {
885
868
  minLeft = Math.min(minLeft, rect.left);
886
869
  minTop = Math.min(minTop, rect.top);
@@ -997,17 +980,10 @@ function getElementInfoByXpath(xpath) {
997
980
  node.scrollIntoView({ behavior: "instant", block: "center" });
998
981
  }
999
982
  }
1000
- return collectElementInfo(
1001
- node,
1002
- window,
1003
- document,
1004
- 1,
1005
- {
1006
- left: 0,
1007
- top: 0
1008
- },
1009
- false
1010
- );
983
+ return collectElementInfo(node, window, document, 1, {
984
+ left: 0,
985
+ top: 0
986
+ });
1011
987
  }
1012
988
  export {
1013
989
  descriptionOfTree,
@@ -1019,6 +995,8 @@ export {
1019
995
  setNodeHashCacheListOnWindow,
1020
996
  traverseTree,
1021
997
  treeToList,
998
+ trimAttributes,
999
+ truncateText,
1022
1000
  extractTreeNode as webExtractNodeTree,
1023
1001
  extractTreeNodeAsString as webExtractNodeTreeAsString,
1024
1002
  extractTextWithPosition as webExtractTextWithPosition
package/dist/es/img.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import Jimp from 'jimp';
3
- import { R as Rect, B as BaseElement } from './index-113807ee.js';
3
+ import { R as Rect, B as BaseElement } from './index-a171e36c.js';
4
4
  import './constants.js';
5
5
 
6
6
  interface Size {
@@ -1,6 +1,11 @@
1
1
  import { NodeType } from './constants.js';
2
2
 
3
- declare function descriptionOfTree<ElementType extends BaseElement = BaseElement>(tree: ElementTreeNode<ElementType>, truncateTextLength?: number, filterNonTextContent?: boolean): string;
3
+ declare function truncateText(text: string | number | object | undefined, maxLength?: number): string;
4
+ declare function trimAttributes(attributes: Record<string, any>, truncateTextLength?: number): {
5
+ [key: string]: string;
6
+ nodeType: NodeType;
7
+ };
8
+ declare function descriptionOfTree<ElementType extends BaseElement = BaseElement>(tree: ElementTreeNode<ElementType>, truncateTextLength?: number, filterNonTextContent?: boolean, visibleOnly?: boolean): string;
4
9
  declare function treeToList<T extends BaseElement>(tree: ElementTreeNode<T>): T[];
5
10
  declare function traverseTree<T extends BaseElement, ReturnNodeType extends BaseElement>(tree: ElementTreeNode<T>, onNode: (node: T) => ReturnNodeType): ElementTreeNode<ReturnNodeType>;
6
11
 
@@ -9,7 +14,7 @@ interface WebElementNode {
9
14
  children: WebElementNode[];
10
15
  }
11
16
  declare function extractTextWithPosition(initNode: globalThis.Node, debugMode?: boolean): WebElementInfo[];
12
- declare function extractTreeNodeAsString(initNode: globalThis.Node, debugMode?: boolean): string;
17
+ declare function extractTreeNodeAsString(initNode: globalThis.Node, visibleOnly?: boolean, debugMode?: boolean): string;
13
18
  declare function extractTreeNode(initNode: globalThis.Node, debugMode?: boolean): WebElementNode;
14
19
 
15
20
  declare function setNodeHashCacheListOnWindow(): void;
@@ -56,6 +61,7 @@ interface ElementInfo {
56
61
  height: number;
57
62
  };
58
63
  center: [number, number];
64
+ isVisible: boolean;
59
65
  }
60
66
  interface ElementNode {
61
67
  node: ElementInfo | null;
@@ -85,6 +91,8 @@ declare abstract class BaseElement {
85
91
  abstract rect: Rect;
86
92
  abstract center: [number, number];
87
93
  abstract locator?: string;
94
+ abstract xpaths?: string[];
95
+ abstract isVisible: boolean;
88
96
  }
89
97
  interface ElementTreeNode<ElementType extends BaseElement = BaseElement> {
90
98
  node: ElementType | null;
@@ -94,4 +102,4 @@ interface WebElementInfo extends ElementInfo {
94
102
  zoom: number;
95
103
  }
96
104
 
97
- export { BaseElement as B, type ElementInfo as E, type Point as P, type Rect as R, type Size as S, type WebElementInfo as W, type ElementNode as a, treeToList as b, extractTreeNode as c, descriptionOfTree as d, extractTextWithPosition as e, extractTreeNodeAsString as f, getNodeFromCacheList as g, getXpathsById as h, getNodeInfoByXpath as i, getElementInfoByXpath as j, generateElementByPosition as k, type ElementTreeNode as l, setNodeHashCacheListOnWindow as s, traverseTree as t };
105
+ export { BaseElement as B, type ElementInfo as E, type Point as P, type Rect as R, type Size as S, type WebElementInfo as W, type ElementNode as a, treeToList as b, truncateText as c, descriptionOfTree as d, trimAttributes as e, extractTextWithPosition as f, extractTreeNode as g, extractTreeNodeAsString as h, getNodeFromCacheList as i, getXpathsById as j, getNodeInfoByXpath as k, getElementInfoByXpath as l, generateElementByPosition as m, type ElementTreeNode as n, setNodeHashCacheListOnWindow as s, traverseTree as t };
@@ -1,2 +1,2 @@
1
1
  import './constants.js';
2
- export { B as BaseElement, l as ElementTreeNode, P as Point, R as Rect, S as Size, W as WebElementInfo } from './index-113807ee.js';
2
+ export { B as BaseElement, n as ElementTreeNode, P as Point, R as Rect, S as Size, W as WebElementInfo } from './index-a171e36c.js';