@rpascene/shared 0.30.13 → 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.
@@ -63,7 +63,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
63
63
  rect.left += basePoint.left;
64
64
  rect.top += basePoint.top;
65
65
  }
66
- if (rect.height >= window.innerHeight && rect.width >= window.innerWidth) return null;
66
+ if (rect.height >= currentWindow.innerHeight && rect.width >= currentWindow.innerWidth) return null;
67
67
  if ((0, external_dom_util_js_namespaceObject.isFormElement)(node, currentWindow)) {
68
68
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
69
69
  let valueContent = attributes.value || attributes.placeholder || node.textContent || '';
@@ -98,6 +98,10 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
98
98
  if ((0, external_dom_util_js_namespaceObject.isButtonElement)(node, currentWindow)) {
99
99
  const rect = mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom);
100
100
  if (!rect) return null;
101
+ if (0 !== basePoint.left || 0 !== basePoint.top) {
102
+ rect.left += basePoint.left;
103
+ rect.top += basePoint.top;
104
+ }
101
105
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
102
106
  const pseudo = (0, external_util_js_namespaceObject.getPseudoElementContent)(node, currentWindow);
103
107
  const content = node.innerText || pseudo.before || pseudo.after || '';
@@ -253,12 +257,9 @@ async function extractTreeNodeAsString(initNode, visibleOnly = false, debugMode
253
257
  async function extractTreeNode(initNode, debugMode = false, basePoint = {
254
258
  left: 0,
255
259
  top: 0
256
- }, baseZoom = 1, containerPaths = []) {
260
+ }, baseZoom = 1) {
257
261
  (0, external_util_js_namespaceObject.setDebugMode)(debugMode);
258
262
  indexId = 0;
259
- let containerPathClone = [
260
- ...containerPaths
261
- ];
262
263
  const topDocument = (0, external_util_js_namespaceObject.getTopDocument)();
263
264
  const startNode = initNode || topDocument;
264
265
  const topChildren = [];
@@ -269,11 +270,6 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
269
270
  if (!node) return null;
270
271
  if (node.nodeType && 10 === node.nodeType) return null;
271
272
  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
273
  if (node instanceof currentWindow.HTMLIFrameElement) {
278
274
  if (node.contentWindow && node.contentWindow) return null;
279
275
  }
@@ -318,18 +314,7 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
318
314
  const iframe = iframes[i];
319
315
  const iframeInfo = collectElementInfo(iframe, window, document, 1);
320
316
  const baseZoom = getCssScale(iframe).cssScaleX;
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");
317
+ if (iframeInfo) {
333
318
  const iframeChildren = await (0, external_cs_postmessage_js_namespaceObject.postWindowMessage)(iframe.contentWindow, window, {
334
319
  action: 'extractTreeNode',
335
320
  data: {
@@ -337,8 +322,7 @@ async function extractTreeNode(initNode, debugMode = false, basePoint = {
337
322
  left: iframeInfo.rect.left,
338
323
  top: iframeInfo.rect.top
339
324
  },
340
- baseZoom,
341
- containerPaths: containerPathClone
325
+ baseZoom
342
326
  }
343
327
  });
344
328
  if (Array.isArray(iframeChildren)) topChildren.push(...iframeChildren);
@@ -384,7 +368,7 @@ function mergeElementAndChildrenRects(node, currentWindow, currentDocument, base
384
368
  }
385
369
  if ('undefined' != typeof window) (0, external_cs_postmessage_js_namespaceObject.onWindowMessage)(window, async ({ action, data }, { source })=>{
386
370
  if ('extractTreeNode' === action) try {
387
- return await extractTreeNode(document.body, false, data.basePoint, data.baseZoom, data.containerPaths);
371
+ return await extractTreeNode(document.body, false, data.basePoint, data.baseZoom);
388
372
  } catch (error) {
389
373
  return {
390
374
  error: 'error message'