@midscene/shared 0.11.0 → 0.11.1-beta-20250211002541.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/browser/extractor-debug.js +17 -2
- package/dist/browser/extractor.js +17 -2
- package/dist/es/extractor-debug.js +17 -2
- package/dist/es/extractor.js +17 -2
- package/dist/lib/extractor-debug.js +17 -2
- package/dist/lib/extractor.js +17 -2
- package/dist/script/htmlElement.js +17 -2
- package/dist/script/htmlElementDebug.js +17 -2
- package/package.json +1 -1
- package/src/extractor/util.ts +20 -2
|
@@ -864,6 +864,17 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
864
864
|
return false;
|
|
865
865
|
}
|
|
866
866
|
let parent = el;
|
|
867
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
868
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
869
|
+
while (parent2) {
|
|
870
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
871
|
+
if (style.position !== "static") {
|
|
872
|
+
return parent2;
|
|
873
|
+
}
|
|
874
|
+
parent2 = parent2.parentElement;
|
|
875
|
+
}
|
|
876
|
+
return null;
|
|
877
|
+
};
|
|
867
878
|
while (parent && parent !== currentDocument.body) {
|
|
868
879
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
869
880
|
parent = parent.parentElement;
|
|
@@ -881,10 +892,14 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
881
892
|
return false;
|
|
882
893
|
}
|
|
883
894
|
}
|
|
884
|
-
if (parentStyle.position === "fixed") {
|
|
895
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
885
896
|
break;
|
|
886
897
|
}
|
|
887
|
-
|
|
898
|
+
if (parentStyle.position === "absolute") {
|
|
899
|
+
parent = parentUntilNonStatic(parent);
|
|
900
|
+
} else {
|
|
901
|
+
parent = parent.parentElement;
|
|
902
|
+
}
|
|
888
903
|
}
|
|
889
904
|
return {
|
|
890
905
|
left: Math.round(rect.left),
|
|
@@ -1004,6 +1004,17 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
1004
1004
|
return false;
|
|
1005
1005
|
}
|
|
1006
1006
|
let parent = el;
|
|
1007
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
1008
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
1009
|
+
while (parent2) {
|
|
1010
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
1011
|
+
if (style.position !== "static") {
|
|
1012
|
+
return parent2;
|
|
1013
|
+
}
|
|
1014
|
+
parent2 = parent2.parentElement;
|
|
1015
|
+
}
|
|
1016
|
+
return null;
|
|
1017
|
+
};
|
|
1007
1018
|
while (parent && parent !== currentDocument.body) {
|
|
1008
1019
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
1009
1020
|
parent = parent.parentElement;
|
|
@@ -1021,10 +1032,14 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
1021
1032
|
return false;
|
|
1022
1033
|
}
|
|
1023
1034
|
}
|
|
1024
|
-
if (parentStyle.position === "fixed") {
|
|
1035
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
1025
1036
|
break;
|
|
1026
1037
|
}
|
|
1027
|
-
|
|
1038
|
+
if (parentStyle.position === "absolute") {
|
|
1039
|
+
parent = parentUntilNonStatic(parent);
|
|
1040
|
+
} else {
|
|
1041
|
+
parent = parent.parentElement;
|
|
1042
|
+
}
|
|
1028
1043
|
}
|
|
1029
1044
|
return {
|
|
1030
1045
|
left: Math.round(rect.left),
|
|
@@ -862,6 +862,17 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
862
862
|
return false;
|
|
863
863
|
}
|
|
864
864
|
let parent = el;
|
|
865
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
866
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
867
|
+
while (parent2) {
|
|
868
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
869
|
+
if (style.position !== "static") {
|
|
870
|
+
return parent2;
|
|
871
|
+
}
|
|
872
|
+
parent2 = parent2.parentElement;
|
|
873
|
+
}
|
|
874
|
+
return null;
|
|
875
|
+
};
|
|
865
876
|
while (parent && parent !== currentDocument.body) {
|
|
866
877
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
867
878
|
parent = parent.parentElement;
|
|
@@ -879,10 +890,14 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
879
890
|
return false;
|
|
880
891
|
}
|
|
881
892
|
}
|
|
882
|
-
if (parentStyle.position === "fixed") {
|
|
893
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
883
894
|
break;
|
|
884
895
|
}
|
|
885
|
-
|
|
896
|
+
if (parentStyle.position === "absolute") {
|
|
897
|
+
parent = parentUntilNonStatic(parent);
|
|
898
|
+
} else {
|
|
899
|
+
parent = parent.parentElement;
|
|
900
|
+
}
|
|
886
901
|
}
|
|
887
902
|
return {
|
|
888
903
|
left: Math.round(rect.left),
|
package/dist/es/extractor.js
CHANGED
|
@@ -984,6 +984,17 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
984
984
|
return false;
|
|
985
985
|
}
|
|
986
986
|
let parent = el;
|
|
987
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
988
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
989
|
+
while (parent2) {
|
|
990
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
991
|
+
if (style.position !== "static") {
|
|
992
|
+
return parent2;
|
|
993
|
+
}
|
|
994
|
+
parent2 = parent2.parentElement;
|
|
995
|
+
}
|
|
996
|
+
return null;
|
|
997
|
+
};
|
|
987
998
|
while (parent && parent !== currentDocument.body) {
|
|
988
999
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
989
1000
|
parent = parent.parentElement;
|
|
@@ -1001,10 +1012,14 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
1001
1012
|
return false;
|
|
1002
1013
|
}
|
|
1003
1014
|
}
|
|
1004
|
-
if (parentStyle.position === "fixed") {
|
|
1015
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
1005
1016
|
break;
|
|
1006
1017
|
}
|
|
1007
|
-
|
|
1018
|
+
if (parentStyle.position === "absolute") {
|
|
1019
|
+
parent = parentUntilNonStatic(parent);
|
|
1020
|
+
} else {
|
|
1021
|
+
parent = parent.parentElement;
|
|
1022
|
+
}
|
|
1008
1023
|
}
|
|
1009
1024
|
return {
|
|
1010
1025
|
left: Math.round(rect.left),
|
|
@@ -856,6 +856,17 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
856
856
|
return false;
|
|
857
857
|
}
|
|
858
858
|
let parent = el;
|
|
859
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
860
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
861
|
+
while (parent2) {
|
|
862
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
863
|
+
if (style.position !== "static") {
|
|
864
|
+
return parent2;
|
|
865
|
+
}
|
|
866
|
+
parent2 = parent2.parentElement;
|
|
867
|
+
}
|
|
868
|
+
return null;
|
|
869
|
+
};
|
|
859
870
|
while (parent && parent !== currentDocument.body) {
|
|
860
871
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
861
872
|
parent = parent.parentElement;
|
|
@@ -873,10 +884,14 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
873
884
|
return false;
|
|
874
885
|
}
|
|
875
886
|
}
|
|
876
|
-
if (parentStyle.position === "fixed") {
|
|
887
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
877
888
|
break;
|
|
878
889
|
}
|
|
879
|
-
|
|
890
|
+
if (parentStyle.position === "absolute") {
|
|
891
|
+
parent = parentUntilNonStatic(parent);
|
|
892
|
+
} else {
|
|
893
|
+
parent = parent.parentElement;
|
|
894
|
+
}
|
|
880
895
|
}
|
|
881
896
|
return {
|
|
882
897
|
left: Math.round(rect.left),
|
package/dist/lib/extractor.js
CHANGED
|
@@ -996,6 +996,17 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
996
996
|
return false;
|
|
997
997
|
}
|
|
998
998
|
let parent = el;
|
|
999
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
1000
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
1001
|
+
while (parent2) {
|
|
1002
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
1003
|
+
if (style.position !== "static") {
|
|
1004
|
+
return parent2;
|
|
1005
|
+
}
|
|
1006
|
+
parent2 = parent2.parentElement;
|
|
1007
|
+
}
|
|
1008
|
+
return null;
|
|
1009
|
+
};
|
|
999
1010
|
while (parent && parent !== currentDocument.body) {
|
|
1000
1011
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
1001
1012
|
parent = parent.parentElement;
|
|
@@ -1013,10 +1024,14 @@ function visibleRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
|
|
1013
1024
|
return false;
|
|
1014
1025
|
}
|
|
1015
1026
|
}
|
|
1016
|
-
if (parentStyle.position === "fixed") {
|
|
1027
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
1017
1028
|
break;
|
|
1018
1029
|
}
|
|
1019
|
-
|
|
1030
|
+
if (parentStyle.position === "absolute") {
|
|
1031
|
+
parent = parentUntilNonStatic(parent);
|
|
1032
|
+
} else {
|
|
1033
|
+
parent = parent.parentElement;
|
|
1034
|
+
}
|
|
1020
1035
|
}
|
|
1021
1036
|
return {
|
|
1022
1037
|
left: Math.round(rect.left),
|
|
@@ -1004,6 +1004,17 @@ ${indentStr}${after}`;
|
|
|
1004
1004
|
return false;
|
|
1005
1005
|
}
|
|
1006
1006
|
let parent = el;
|
|
1007
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
1008
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
1009
|
+
while (parent2) {
|
|
1010
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
1011
|
+
if (style.position !== "static") {
|
|
1012
|
+
return parent2;
|
|
1013
|
+
}
|
|
1014
|
+
parent2 = parent2.parentElement;
|
|
1015
|
+
}
|
|
1016
|
+
return null;
|
|
1017
|
+
};
|
|
1007
1018
|
while (parent && parent !== currentDocument.body) {
|
|
1008
1019
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
1009
1020
|
parent = parent.parentElement;
|
|
@@ -1021,10 +1032,14 @@ ${indentStr}${after}`;
|
|
|
1021
1032
|
return false;
|
|
1022
1033
|
}
|
|
1023
1034
|
}
|
|
1024
|
-
if (parentStyle.position === "fixed") {
|
|
1035
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
1025
1036
|
break;
|
|
1026
1037
|
}
|
|
1027
|
-
|
|
1038
|
+
if (parentStyle.position === "absolute") {
|
|
1039
|
+
parent = parentUntilNonStatic(parent);
|
|
1040
|
+
} else {
|
|
1041
|
+
parent = parent.parentElement;
|
|
1042
|
+
}
|
|
1028
1043
|
}
|
|
1029
1044
|
return {
|
|
1030
1045
|
left: Math.round(rect.left),
|
|
@@ -865,6 +865,17 @@ var midscene_element_inspector = (() => {
|
|
|
865
865
|
return false;
|
|
866
866
|
}
|
|
867
867
|
let parent = el;
|
|
868
|
+
const parentUntilNonStatic = (currentNode) => {
|
|
869
|
+
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
|
870
|
+
while (parent2) {
|
|
871
|
+
const style = currentWindow.getComputedStyle(parent2);
|
|
872
|
+
if (style.position !== "static") {
|
|
873
|
+
return parent2;
|
|
874
|
+
}
|
|
875
|
+
parent2 = parent2.parentElement;
|
|
876
|
+
}
|
|
877
|
+
return null;
|
|
878
|
+
};
|
|
868
879
|
while (parent && parent !== currentDocument.body) {
|
|
869
880
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
870
881
|
parent = parent.parentElement;
|
|
@@ -882,10 +893,14 @@ var midscene_element_inspector = (() => {
|
|
|
882
893
|
return false;
|
|
883
894
|
}
|
|
884
895
|
}
|
|
885
|
-
if (parentStyle.position === "fixed") {
|
|
896
|
+
if (parentStyle.position === "fixed" || parentStyle.position === "sticky") {
|
|
886
897
|
break;
|
|
887
898
|
}
|
|
888
|
-
|
|
899
|
+
if (parentStyle.position === "absolute") {
|
|
900
|
+
parent = parentUntilNonStatic(parent);
|
|
901
|
+
} else {
|
|
902
|
+
parent = parent.parentElement;
|
|
903
|
+
}
|
|
889
904
|
}
|
|
890
905
|
return {
|
|
891
906
|
left: Math.round(rect.left),
|
package/package.json
CHANGED
package/src/extractor/util.ts
CHANGED
|
@@ -330,6 +330,19 @@ export function visibleRect(
|
|
|
330
330
|
|
|
331
331
|
// check if the element is hidden by an ancestor
|
|
332
332
|
let parent: HTMLElement | Node | null = el;
|
|
333
|
+
const parentUntilNonStatic = (currentNode: HTMLElement | Node | null) => {
|
|
334
|
+
// find a parent element that is not static
|
|
335
|
+
let parent = currentNode?.parentElement;
|
|
336
|
+
while (parent) {
|
|
337
|
+
const style = currentWindow.getComputedStyle(parent);
|
|
338
|
+
if (style.position !== 'static') {
|
|
339
|
+
return parent;
|
|
340
|
+
}
|
|
341
|
+
parent = parent.parentElement;
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
};
|
|
345
|
+
|
|
333
346
|
while (parent && parent !== currentDocument.body) {
|
|
334
347
|
if (!(parent instanceof currentWindow.HTMLElement)) {
|
|
335
348
|
parent = parent.parentElement;
|
|
@@ -354,10 +367,15 @@ export function visibleRect(
|
|
|
354
367
|
}
|
|
355
368
|
}
|
|
356
369
|
// if the parent is a fixed element, stop the search
|
|
357
|
-
if (parentStyle.position === 'fixed') {
|
|
370
|
+
if (parentStyle.position === 'fixed' || parentStyle.position === 'sticky') {
|
|
358
371
|
break;
|
|
359
372
|
}
|
|
360
|
-
|
|
373
|
+
|
|
374
|
+
if (parentStyle.position === 'absolute') {
|
|
375
|
+
parent = parentUntilNonStatic(parent);
|
|
376
|
+
} else {
|
|
377
|
+
parent = parent.parentElement;
|
|
378
|
+
}
|
|
361
379
|
}
|
|
362
380
|
|
|
363
381
|
return {
|