@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.
@@ -148,7 +148,8 @@ const YHT_STRING_ENV_KEYS = [
148
148
  'domain',
149
149
  'yht_access_token',
150
150
  'model',
151
- 'baseURL'
151
+ 'baseURL',
152
+ 'traceId'
152
153
  ];
153
154
  const YHT_NUMBER_ENV_KEYS = [
154
155
  'chatType',
@@ -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 >= window.innerHeight && rect.width >= window.innerWidth) return null;
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',