@midscene/shared 0.21.3 → 0.21.4-beta-20250714025212.0
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/es/extractor-debug.js +5 -0
- package/dist/es/extractor.d.ts +1 -1
- package/dist/es/extractor.js +9 -0
- package/dist/es/img.d.ts +1 -1
- package/dist/es/{index-59587d83.d.ts → index-290d7698.d.ts} +2 -1
- package/dist/es/types.d.ts +1 -1
- package/dist/lib/extractor-debug.js +5 -0
- package/dist/lib/extractor.d.ts +1 -1
- package/dist/lib/extractor.js +10 -0
- package/dist/lib/img.d.ts +1 -1
- package/dist/lib/{index-59587d83.d.ts → index-290d7698.d.ts} +2 -1
- package/dist/lib/types.d.ts +1 -1
- package/dist/script/htmlElement.js +11 -2
- package/dist/script/htmlElementDebug.js +7 -2
- package/dist/types/extractor.d.ts +1 -1
- package/dist/types/img.d.ts +1 -1
- package/dist/types/{index-59587d83.d.ts → index-290d7698.d.ts} +2 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/extractor/dom-util.ts +16 -0
- package/src/extractor/index.ts +2 -0
|
@@ -64,6 +64,11 @@ function isIconfont(node) {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
function isTextElement(node) {
|
|
67
|
+
if (node instanceof Element) {
|
|
68
|
+
if (node?.childNodes?.length === 1 && node?.childNodes[0] instanceof Text) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
67
72
|
return node.nodeName?.toLowerCase() === "#text" && !isIconfont(node);
|
|
68
73
|
}
|
|
69
74
|
function isContainerElement(node) {
|
package/dist/es/extractor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './constants.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-
|
|
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, n as isNotContainerElement, 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-290d7698.js';
|
package/dist/es/extractor.js
CHANGED
|
@@ -188,7 +188,15 @@ function isIconfont(node) {
|
|
|
188
188
|
}
|
|
189
189
|
return false;
|
|
190
190
|
}
|
|
191
|
+
function isNotContainerElement(node) {
|
|
192
|
+
return isTextElement(node) || isIconfont(node) || isImgElement(node) || isButtonElement(node) || isAElement(node) || isFormElement(node);
|
|
193
|
+
}
|
|
191
194
|
function isTextElement(node) {
|
|
195
|
+
if (node instanceof Element) {
|
|
196
|
+
if (node?.childNodes?.length === 1 && node?.childNodes[0] instanceof Text) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
192
200
|
return node.nodeName?.toLowerCase() === "#text" && !isIconfont(node);
|
|
193
201
|
}
|
|
194
202
|
function isContainerElement(node) {
|
|
@@ -973,6 +981,7 @@ export {
|
|
|
973
981
|
getNodeFromCacheList,
|
|
974
982
|
getNodeInfoByXpath,
|
|
975
983
|
getXpathsById,
|
|
984
|
+
isNotContainerElement,
|
|
976
985
|
setNodeHashCacheListOnWindow,
|
|
977
986
|
traverseTree,
|
|
978
987
|
treeToList,
|
package/dist/es/img.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare function getXpathsById(id: string): string[] | null;
|
|
|
24
24
|
declare function getNodeInfoByXpath(xpath: string): Node | null;
|
|
25
25
|
declare function getElementInfoByXpath(xpath: string): ElementInfo | null;
|
|
26
26
|
|
|
27
|
+
declare function isNotContainerElement(node: globalThis.Node): boolean;
|
|
27
28
|
declare function generateElementByPosition(position: {
|
|
28
29
|
x: number;
|
|
29
30
|
y: number;
|
|
@@ -100,4 +101,4 @@ interface WebElementInfo extends ElementInfo {
|
|
|
100
101
|
zoom: number;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
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
|
|
104
|
+
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, isNotContainerElement as n, type ElementTreeNode as o, setNodeHashCacheListOnWindow as s, traverseTree as t };
|
package/dist/es/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './constants.js';
|
|
2
|
-
export { B as BaseElement,
|
|
2
|
+
export { B as BaseElement, o as ElementTreeNode, P as Point, R as Rect, S as Size, W as WebElementInfo } from './index-290d7698.js';
|
|
@@ -66,6 +66,11 @@ function isIconfont(node) {
|
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
function isTextElement(node) {
|
|
69
|
+
if (node instanceof Element) {
|
|
70
|
+
if (node?.childNodes?.length === 1 && node?.childNodes[0] instanceof Text) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
69
74
|
return node.nodeName?.toLowerCase() === "#text" && !isIconfont(node);
|
|
70
75
|
}
|
|
71
76
|
function isContainerElement(node) {
|
package/dist/lib/extractor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './constants.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-
|
|
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, n as isNotContainerElement, 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-290d7698.js';
|
package/dist/lib/extractor.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(extractor_exports, {
|
|
|
26
26
|
getNodeFromCacheList: () => getNodeFromCacheList,
|
|
27
27
|
getNodeInfoByXpath: () => getNodeInfoByXpath,
|
|
28
28
|
getXpathsById: () => getXpathsById,
|
|
29
|
+
isNotContainerElement: () => isNotContainerElement,
|
|
29
30
|
setNodeHashCacheListOnWindow: () => setNodeHashCacheListOnWindow,
|
|
30
31
|
traverseTree: () => traverseTree,
|
|
31
32
|
treeToList: () => treeToList,
|
|
@@ -227,7 +228,15 @@ function isIconfont(node) {
|
|
|
227
228
|
}
|
|
228
229
|
return false;
|
|
229
230
|
}
|
|
231
|
+
function isNotContainerElement(node) {
|
|
232
|
+
return isTextElement(node) || isIconfont(node) || isImgElement(node) || isButtonElement(node) || isAElement(node) || isFormElement(node);
|
|
233
|
+
}
|
|
230
234
|
function isTextElement(node) {
|
|
235
|
+
if (node instanceof Element) {
|
|
236
|
+
if (node?.childNodes?.length === 1 && node?.childNodes[0] instanceof Text) {
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
231
240
|
return node.nodeName?.toLowerCase() === "#text" && !isIconfont(node);
|
|
232
241
|
}
|
|
233
242
|
function isContainerElement(node) {
|
|
@@ -1013,6 +1022,7 @@ function getElementInfoByXpath(xpath) {
|
|
|
1013
1022
|
getNodeFromCacheList,
|
|
1014
1023
|
getNodeInfoByXpath,
|
|
1015
1024
|
getXpathsById,
|
|
1025
|
+
isNotContainerElement,
|
|
1016
1026
|
setNodeHashCacheListOnWindow,
|
|
1017
1027
|
traverseTree,
|
|
1018
1028
|
treeToList,
|
package/dist/lib/img.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare function getXpathsById(id: string): string[] | null;
|
|
|
24
24
|
declare function getNodeInfoByXpath(xpath: string): Node | null;
|
|
25
25
|
declare function getElementInfoByXpath(xpath: string): ElementInfo | null;
|
|
26
26
|
|
|
27
|
+
declare function isNotContainerElement(node: globalThis.Node): boolean;
|
|
27
28
|
declare function generateElementByPosition(position: {
|
|
28
29
|
x: number;
|
|
29
30
|
y: number;
|
|
@@ -100,4 +101,4 @@ interface WebElementInfo extends ElementInfo {
|
|
|
100
101
|
zoom: number;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
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
|
|
104
|
+
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, isNotContainerElement as n, type ElementTreeNode as o, setNodeHashCacheListOnWindow as s, traverseTree as t };
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './constants.js';
|
|
2
|
-
export { B as BaseElement,
|
|
2
|
+
export { B as BaseElement, o as ElementTreeNode, P as Point, R as Rect, S as Size, W as WebElementInfo } from './index-290d7698.js';
|
|
@@ -584,6 +584,7 @@ var midscene_element_inspector = (() => {
|
|
|
584
584
|
getNodeFromCacheList: () => getNodeFromCacheList,
|
|
585
585
|
getNodeInfoByXpath: () => getNodeInfoByXpath,
|
|
586
586
|
getXpathsById: () => getXpathsById,
|
|
587
|
+
isNotContainerElement: () => isNotContainerElement,
|
|
587
588
|
setNodeHashCacheListOnWindow: () => setNodeHashCacheListOnWindow,
|
|
588
589
|
traverseTree: () => traverseTree,
|
|
589
590
|
treeToList: () => treeToList,
|
|
@@ -785,9 +786,17 @@ ${indentStr}${after}`;
|
|
|
785
786
|
}
|
|
786
787
|
return false;
|
|
787
788
|
}
|
|
789
|
+
function isNotContainerElement(node) {
|
|
790
|
+
return isTextElement(node) || isIconfont(node) || isImgElement(node) || isButtonElement(node) || isAElement(node) || isFormElement(node);
|
|
791
|
+
}
|
|
788
792
|
function isTextElement(node) {
|
|
789
|
-
var _a;
|
|
790
|
-
|
|
793
|
+
var _a, _b;
|
|
794
|
+
if (node instanceof Element) {
|
|
795
|
+
if (((_a = node == null ? void 0 : node.childNodes) == null ? void 0 : _a.length) === 1 && (node == null ? void 0 : node.childNodes[0]) instanceof Text) {
|
|
796
|
+
return true;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return ((_b = node.nodeName) == null ? void 0 : _b.toLowerCase()) === "#text" && !isIconfont(node);
|
|
791
800
|
}
|
|
792
801
|
function isContainerElement(node) {
|
|
793
802
|
if (!(node instanceof HTMLElement))
|
|
@@ -636,8 +636,13 @@ var midscene_element_inspector = (() => {
|
|
|
636
636
|
return false;
|
|
637
637
|
}
|
|
638
638
|
function isTextElement(node) {
|
|
639
|
-
var _a;
|
|
640
|
-
|
|
639
|
+
var _a, _b;
|
|
640
|
+
if (node instanceof Element) {
|
|
641
|
+
if (((_a = node == null ? void 0 : node.childNodes) == null ? void 0 : _a.length) === 1 && (node == null ? void 0 : node.childNodes[0]) instanceof Text) {
|
|
642
|
+
return true;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return ((_b = node.nodeName) == null ? void 0 : _b.toLowerCase()) === "#text" && !isIconfont(node);
|
|
641
646
|
}
|
|
642
647
|
function isContainerElement(node) {
|
|
643
648
|
if (!(node instanceof HTMLElement))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './constants.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-
|
|
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, n as isNotContainerElement, 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-290d7698.js';
|
package/dist/types/img.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare function getXpathsById(id: string): string[] | null;
|
|
|
24
24
|
declare function getNodeInfoByXpath(xpath: string): Node | null;
|
|
25
25
|
declare function getElementInfoByXpath(xpath: string): ElementInfo | null;
|
|
26
26
|
|
|
27
|
+
declare function isNotContainerElement(node: globalThis.Node): boolean;
|
|
27
28
|
declare function generateElementByPosition(position: {
|
|
28
29
|
x: number;
|
|
29
30
|
y: number;
|
|
@@ -100,4 +101,4 @@ interface WebElementInfo extends ElementInfo {
|
|
|
100
101
|
zoom: number;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
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
|
|
104
|
+
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, isNotContainerElement as n, type ElementTreeNode as o, setNodeHashCacheListOnWindow as s, traverseTree as t };
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './constants.js';
|
|
2
|
-
export { B as BaseElement,
|
|
2
|
+
export { B as BaseElement, o as ElementTreeNode, P as Point, R as Rect, S as Size, W as WebElementInfo } from './index-290d7698.js';
|
package/package.json
CHANGED
|
@@ -55,9 +55,25 @@ function isIconfont(node: globalThis.Node): boolean {
|
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export function isNotContainerElement(node: globalThis.Node) {
|
|
59
|
+
return (
|
|
60
|
+
isTextElement(node) ||
|
|
61
|
+
isIconfont(node) ||
|
|
62
|
+
isImgElement(node) ||
|
|
63
|
+
isButtonElement(node) ||
|
|
64
|
+
isAElement(node) ||
|
|
65
|
+
isFormElement(node)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
export function isTextElement(
|
|
59
70
|
node: globalThis.Node,
|
|
60
71
|
): node is globalThis.HTMLTextAreaElement {
|
|
72
|
+
if (node instanceof Element) {
|
|
73
|
+
if (node?.childNodes?.length === 1 && node?.childNodes[0] instanceof Text) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
61
77
|
return node.nodeName?.toLowerCase() === '#text' && !isIconfont(node);
|
|
62
78
|
}
|
|
63
79
|
|