@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.
- package/dist/es/env/types.mjs +2 -1
- package/dist/es/extractor/web-extractor.mjs +20 -1
- package/dist/es/node/fs.mjs +1 -1
- package/dist/lib/env/types.js +2 -1
- package/dist/lib/extractor/web-extractor.js +20 -1
- package/dist/lib/node/fs.js +1 -1
- package/dist/types/env/types.d.ts +3 -3
- package/package.json +1 -1
- package/src/env/types.ts +2 -1
- package/src/extractor/web-extractor.ts +8 -3
package/dist/es/env/types.mjs
CHANGED
|
@@ -30,7 +30,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
|
|
|
30
30
|
rect.left += basePoint.left;
|
|
31
31
|
rect.top += basePoint.top;
|
|
32
32
|
}
|
|
33
|
-
if (rect.height >=
|
|
33
|
+
if (rect.height >= currentWindow.innerHeight && rect.width >= currentWindow.innerWidth) return null;
|
|
34
34
|
if (isFormElement(node, currentWindow)) {
|
|
35
35
|
const attributes = getNodeAttributes(node, currentWindow);
|
|
36
36
|
let valueContent = attributes.value || attributes.placeholder || node.textContent || '';
|
|
@@ -65,6 +65,10 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
|
|
|
65
65
|
if (isButtonElement(node, currentWindow)) {
|
|
66
66
|
const rect = mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom);
|
|
67
67
|
if (!rect) return null;
|
|
68
|
+
if (0 !== basePoint.left || 0 !== basePoint.top) {
|
|
69
|
+
rect.left += basePoint.left;
|
|
70
|
+
rect.top += basePoint.top;
|
|
71
|
+
}
|
|
68
72
|
const attributes = getNodeAttributes(node, currentWindow);
|
|
69
73
|
const pseudo = getPseudoElementContent(node, currentWindow);
|
|
70
74
|
const content = node.innerText || pseudo.before || pseudo.after || '';
|
|
@@ -254,6 +258,20 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
|
254
258
|
}
|
|
255
259
|
return nodeInfo;
|
|
256
260
|
}
|
|
261
|
+
function getCssScale(ele) {
|
|
262
|
+
try {
|
|
263
|
+
const { width, height } = ele.getBoundingClientRect();
|
|
264
|
+
return {
|
|
265
|
+
cssScaleX: Number((width / ele.offsetWidth).toFixed(1)),
|
|
266
|
+
cssScaleY: Number((height / ele.offsetHeight).toFixed(1))
|
|
267
|
+
};
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return {
|
|
270
|
+
cssScaleX: 1,
|
|
271
|
+
cssScaleY: 1
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
257
275
|
const rootNodeInfo = dfs(startNode, window, document, baseZoom, basePoint);
|
|
258
276
|
if (Array.isArray(rootNodeInfo)) topChildren.push(...rootNodeInfo);
|
|
259
277
|
else if (rootNodeInfo) topChildren.push(rootNodeInfo);
|
|
@@ -262,6 +280,7 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
|
262
280
|
for(let i = 0; i < iframes.length; i++){
|
|
263
281
|
const iframe = iframes[i];
|
|
264
282
|
const iframeInfo = collectElementInfo(iframe, window, document, 1);
|
|
283
|
+
const baseZoom = getCssScale(iframe).cssScaleX;
|
|
265
284
|
if (iframeInfo) {
|
|
266
285
|
const iframeChildren = await postWindowMessage(iframe.contentWindow, window, {
|
|
267
286
|
action: 'extractTreeNode',
|