@rpascene/shared 0.30.13 → 0.30.14
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,12 +253,9 @@ async function extractTreeNodeAsString(initNode, visibleOnly = false, debugMode
|
|
|
253
253
|
async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
254
254
|
left: 0,
|
|
255
255
|
top: 0
|
|
256
|
-
}, baseZoom = 1
|
|
256
|
+
}, baseZoom = 1) {
|
|
257
257
|
(0, external_util_js_namespaceObject.setDebugMode)(debugMode);
|
|
258
258
|
indexId = 0;
|
|
259
|
-
let containerPathClone = [
|
|
260
|
-
...containerPaths
|
|
261
|
-
];
|
|
262
259
|
const topDocument = (0, external_util_js_namespaceObject.getTopDocument)();
|
|
263
260
|
const startNode = initNode || topDocument;
|
|
264
261
|
const topChildren = [];
|
|
@@ -269,11 +266,6 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
|
269
266
|
if (!node) return null;
|
|
270
267
|
if (node.nodeType && 10 === node.nodeType) return null;
|
|
271
268
|
const elementInfo = collectElementInfo(node, currentWindow, currentDocument, baseZoom, basePoint, false);
|
|
272
|
-
if (elementInfo) {
|
|
273
|
-
const allPaths = (0, external_customLocator_js_namespaceObject.getLocators)(node);
|
|
274
|
-
elementInfo.allPaths = allPaths;
|
|
275
|
-
elementInfo.containerPaths = containerPathClone;
|
|
276
|
-
}
|
|
277
269
|
if (node instanceof currentWindow.HTMLIFrameElement) {
|
|
278
270
|
if (node.contentWindow && node.contentWindow) return null;
|
|
279
271
|
}
|
|
@@ -295,20 +287,6 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
|
295
287
|
}
|
|
296
288
|
return nodeInfo;
|
|
297
289
|
}
|
|
298
|
-
function getCssScale(ele) {
|
|
299
|
-
try {
|
|
300
|
-
const { width, height } = ele.getBoundingClientRect();
|
|
301
|
-
return {
|
|
302
|
-
cssScaleX: Number((width / ele.offsetWidth).toFixed(1)),
|
|
303
|
-
cssScaleY: Number((height / ele.offsetHeight).toFixed(1))
|
|
304
|
-
};
|
|
305
|
-
} catch (error) {
|
|
306
|
-
return {
|
|
307
|
-
cssScaleX: 1,
|
|
308
|
-
cssScaleY: 1
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
290
|
const rootNodeInfo = dfs(startNode, window, document, baseZoom, basePoint);
|
|
313
291
|
if (Array.isArray(rootNodeInfo)) topChildren.push(...rootNodeInfo);
|
|
314
292
|
else if (rootNodeInfo) topChildren.push(rootNodeInfo);
|
|
@@ -317,19 +295,7 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
|
317
295
|
for(let i = 0; i < iframes.length; i++){
|
|
318
296
|
const iframe = iframes[i];
|
|
319
297
|
const iframeInfo = collectElementInfo(iframe, window, document, 1);
|
|
320
|
-
|
|
321
|
-
const containerPath = (0, external_customLocator_js_namespaceObject.getContainerPath)(iframe);
|
|
322
|
-
containerPathClone = containerPathClone.concat(containerPath);
|
|
323
|
-
if (iframeInfo) if (iframe.contentDocument && iframe.contentWindow) {
|
|
324
|
-
console.log("iframe\u540C\u57DF");
|
|
325
|
-
const iframeChildren = dfs(iframe.contentDocument.body, iframe.contentWindow, iframe.contentDocument, baseZoom, {
|
|
326
|
-
left: iframeInfo.rect.left,
|
|
327
|
-
top: iframeInfo.rect.top
|
|
328
|
-
});
|
|
329
|
-
if (Array.isArray(iframeChildren)) topChildren.push(...iframeChildren);
|
|
330
|
-
else if (iframeChildren) topChildren.push(iframeChildren);
|
|
331
|
-
} else {
|
|
332
|
-
console.log(iframeInfo, "iframe\u8DE8\u57DF\u4E86");
|
|
298
|
+
if (iframeInfo) {
|
|
333
299
|
const iframeChildren = await (0, external_cs_postmessage_js_namespaceObject.postWindowMessage)(iframe.contentWindow, window, {
|
|
334
300
|
action: 'extractTreeNode',
|
|
335
301
|
data: {
|
|
@@ -337,8 +303,7 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
|
|
|
337
303
|
left: iframeInfo.rect.left,
|
|
338
304
|
top: iframeInfo.rect.top
|
|
339
305
|
},
|
|
340
|
-
baseZoom
|
|
341
|
-
containerPaths: containerPathClone
|
|
306
|
+
baseZoom
|
|
342
307
|
}
|
|
343
308
|
});
|
|
344
309
|
if (Array.isArray(iframeChildren)) topChildren.push(...iframeChildren);
|
|
@@ -384,7 +349,7 @@ function mergeElementAndChildrenRects(node, currentWindow, currentDocument, base
|
|
|
384
349
|
}
|
|
385
350
|
if ('undefined' != typeof window) (0, external_cs_postmessage_js_namespaceObject.onWindowMessage)(window, async ({ action, data }, { source })=>{
|
|
386
351
|
if ('extractTreeNode' === action) try {
|
|
387
|
-
return await extractTreeNode(document.body, false, data.basePoint, data.baseZoom
|
|
352
|
+
return await extractTreeNode(document.body, false, data.basePoint, data.baseZoom);
|
|
388
353
|
} catch (error) {
|
|
389
354
|
return {
|
|
390
355
|
error: 'error message'
|