@rpascene/shared 0.30.11 → 0.30.13

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.
@@ -33,10 +33,12 @@ __webpack_require__.d(__webpack_exports__, {
33
33
  DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY,
34
34
  DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT,
35
35
  CONTAINER_MINI_WIDTH: ()=>CONTAINER_MINI_WIDTH,
36
+ rpastudioCommand: ()=>rpastudioCommand,
36
37
  CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
37
38
  TEXT_MAX_SIZE: ()=>TEXT_MAX_SIZE,
38
39
  NodeType: ()=>constants_NodeType,
39
40
  WEBDRIVER_ELEMENT_ID_KEY: ()=>WEBDRIVER_ELEMENT_ID_KEY,
41
+ rpasceneCommand: ()=>rpasceneCommand,
40
42
  DEFAULT_WDA_PORT: ()=>DEFAULT_WDA_PORT,
41
43
  DEFAULT_WAIT_FOR_NETWORK_IDLE_TIME: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_TIME,
42
44
  PLAYWRIGHT_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.PLAYWRIGHT_EXAMPLE_CODE
@@ -64,54 +66,100 @@ const DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT = 5000;
64
66
  const DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT = 2000;
65
67
  const DEFAULT_WAIT_FOR_NETWORK_IDLE_TIME = 300;
66
68
  const DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY = 2;
69
+ const rpasceneCommand = {
70
+ Tap: "Tap",
71
+ RightClick: "RightClick",
72
+ DoubleClick: "DoubleClick",
73
+ Hover: "Hover",
74
+ Input: "Input",
75
+ KeyboardPress: "KeyboardPress",
76
+ Scroll: "Scroll",
77
+ DragAndDrop: "DragAndDrop",
78
+ ClearInput: "ClearInput",
79
+ Sleep: "Sleep",
80
+ LongPress: "LongPress",
81
+ Swipe: "Swipe",
82
+ Reload: "Reload",
83
+ GoBack: "GoBack",
84
+ Navigate: 'Navigate'
85
+ };
86
+ const rpastudioCommand = {
87
+ SeleniumClickCommand: "SeleniumClickCommand",
88
+ SeleniumRightClickCommand: "SeleniumRightClickCommand",
89
+ SeleniumDoubleClickCommand: "SeleniumDoubleClickCommand",
90
+ SeleniumMouseHoverCommand: "SeleniumMouseHoverCommand",
91
+ SeleniumSetValueCommand: "SeleniumSetValueCommand",
92
+ SeleniumElementSendKeysCommand: "SeleniumElementSendKeysCommand",
93
+ SeleniumSendKeysCommand: "SeleniumSendKeysCommand",
94
+ SeleniumElementScrollCommand: 'SeleniumElementScrollCommand',
95
+ SeleniumWindowScrollCommand: 'SeleniumWindowScrollCommand',
96
+ SeleniumDragAndDropCommand: 'SeleniumDragAndDropCommand',
97
+ SeleniumClearValueCommand: "SeleniumClearValueCommand",
98
+ PauseCommand: "PauseCommand",
99
+ SeleniumBrowserRefreshCommand: "SeleniumBrowserRefreshCommand",
100
+ SeleniumBrowserNavigateBackCommand: 'SeleniumBrowserNavigateBackCommand',
101
+ SeleniumBrowserNavigateCommand: 'SeleniumBrowserNavigateCommand'
102
+ };
67
103
  const commandMap = {
68
- Tap: {
69
- CommandName: "SeleniumClickCommand",
104
+ [rpasceneCommand.Tap]: {
105
+ CommandName: rpastudioCommand.SeleniumClickCommand,
70
106
  DisplayName: "\u5143\u7D20\u70B9\u51FB"
71
107
  },
72
- RightClick: {
73
- CommandName: "SeleniumRightClickCommand",
108
+ [rpasceneCommand.RightClick]: {
109
+ CommandName: rpastudioCommand.SeleniumRightClickCommand,
74
110
  DisplayName: "\u5143\u7D20\u53F3\u952E\u70B9\u51FB"
75
111
  },
76
- DoubleClick: {
77
- CommandName: "SeleniumDoubleClickCommand",
112
+ [rpasceneCommand.DoubleClick]: {
113
+ CommandName: rpastudioCommand.SeleniumDoubleClickCommand,
78
114
  DisplayName: "\u5143\u7D20\u53CC\u51FB"
79
115
  },
80
- Hover: {
81
- CommandName: "SeleniumMouseHoverCommand",
116
+ [rpasceneCommand.Hover]: {
117
+ CommandName: rpastudioCommand.SeleniumMouseHoverCommand,
82
118
  DisplayName: "\u9F20\u6807\u60AC\u505C"
83
119
  },
84
- Input: {
85
- CommandName: "SeleniumSetValueCommand",
120
+ [rpasceneCommand.Input]: {
121
+ CommandName: rpastudioCommand.SeleniumSetValueCommand,
86
122
  DisplayName: "\u8BBE\u7F6E\u6587\u672C"
87
123
  },
88
- KeyboardPress: {
89
- CommandName: "SeleniumSendKeysCommand",
124
+ [rpasceneCommand.KeyboardPress]: {
125
+ CommandName: rpastudioCommand.SeleniumElementSendKeysCommand,
90
126
  DisplayName: "\u6A21\u62DF\u6309\u952E"
91
127
  },
92
- Scroll: {
93
- CommandName: "SeleniumElementScrollCommand",
128
+ [rpasceneCommand.Scroll]: {
129
+ CommandName: rpastudioCommand.SeleniumElementScrollCommand,
94
130
  DisplayName: "\u5143\u7D20\u6EDA\u52A8"
95
131
  },
96
- DragAndDrop: {
97
- CommandName: "SeleniumDragDropCommand",
132
+ [rpasceneCommand.DragAndDrop]: {
133
+ CommandName: rpastudioCommand.SeleniumDragAndDropCommand,
98
134
  DisplayName: "\u5143\u7D20\u62D6\u62FD\uFF08\u81F3\u6307\u5B9A\u5143\u7D20\uFF09"
99
135
  },
100
- ClearInput: {
101
- CommandName: "SeleniumClearTextCommand",
136
+ [rpasceneCommand.ClearInput]: {
137
+ CommandName: rpastudioCommand.SeleniumClearValueCommand,
102
138
  DisplayName: "\u6E05\u7A7A\u6587\u672C"
103
139
  },
104
- Sleep: {
105
- CommandName: "SeleniumPauseCommand",
140
+ [rpasceneCommand.Sleep]: {
141
+ CommandName: rpastudioCommand.PauseCommand,
106
142
  DisplayName: "\u6682\u505C\u811A\u672C"
107
143
  },
108
- LongPress: {
109
- CommandName: "SeleniumSendKeysCommand",
110
- DisplayName: "\u6A21\u62DF\u6309\u952E"
144
+ [rpasceneCommand.LongPress]: {
145
+ CommandName: "",
146
+ DisplayName: ""
111
147
  },
112
- Swipe: {
113
- CommandName: "SeleniumClickCommand",
114
- DisplayName: "\u5143\u7D20\u70B9\u51FB"
148
+ [rpasceneCommand.Swipe]: {
149
+ CommandName: "",
150
+ DisplayName: ""
151
+ },
152
+ [rpasceneCommand.Reload]: {
153
+ CommandName: rpastudioCommand.SeleniumBrowserRefreshCommand,
154
+ DisplayName: "\u5237\u65B0"
155
+ },
156
+ [rpasceneCommand.GoBack]: {
157
+ CommandName: rpastudioCommand.SeleniumBrowserNavigateBackCommand,
158
+ DisplayName: "\u540E\u9000"
159
+ },
160
+ [rpasceneCommand.Navigate]: {
161
+ CommandName: rpastudioCommand.SeleniumBrowserNavigateCommand,
162
+ DisplayName: "\u6253\u5F00\u9875\u9762"
115
163
  }
116
164
  };
117
165
  exports.CONTAINER_MINI_HEIGHT = __webpack_exports__.CONTAINER_MINI_HEIGHT;
@@ -130,6 +178,8 @@ exports.TEXT_SIZE_THRESHOLD = __webpack_exports__.TEXT_SIZE_THRESHOLD;
130
178
  exports.WEBDRIVER_ELEMENT_ID_KEY = __webpack_exports__.WEBDRIVER_ELEMENT_ID_KEY;
131
179
  exports.YAML_EXAMPLE_CODE = __webpack_exports__.YAML_EXAMPLE_CODE;
132
180
  exports.commandMap = __webpack_exports__.commandMap;
181
+ exports.rpasceneCommand = __webpack_exports__.rpasceneCommand;
182
+ exports.rpastudioCommand = __webpack_exports__.rpastudioCommand;
133
183
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
134
184
  "CONTAINER_MINI_HEIGHT",
135
185
  "CONTAINER_MINI_WIDTH",
@@ -146,7 +196,9 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
146
196
  "TEXT_SIZE_THRESHOLD",
147
197
  "WEBDRIVER_ELEMENT_ID_KEY",
148
198
  "YAML_EXAMPLE_CODE",
149
- "commandMap"
199
+ "commandMap",
200
+ "rpasceneCommand",
201
+ "rpastudioCommand"
150
202
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
151
203
  Object.defineProperty(exports, '__esModule', {
152
204
  value: true
@@ -48,7 +48,16 @@ const VQA_MODEL_CONFIG_KEYS = {
48
48
  azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_INIT_CONFIG_JSON,
49
49
  useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_VQA_USE_ANTHROPIC_SDK,
50
50
  anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_VQA_ANTHROPIC_API_KEY,
51
- vlMode: external_types_js_namespaceObject.MIDSCENE_VQA_VL_MODE
51
+ vlMode: external_types_js_namespaceObject.MIDSCENE_VQA_VL_MODE,
52
+ domain: 'domain',
53
+ yht_access_token: 'yht_access_token',
54
+ model: 'model',
55
+ baseURL: 'baseURL',
56
+ chatType: 'chatType',
57
+ modelCategory: 'modelCategory',
58
+ stream: 'stream',
59
+ temperature: 'temperature',
60
+ top_p: 'top_p'
52
61
  };
53
62
  const GROUNDING_MODEL_CONFIG_KEYS = {
54
63
  modelName: external_types_js_namespaceObject.MIDSCENE_GROUNDING_MODEL_NAME,
@@ -67,7 +76,16 @@ const GROUNDING_MODEL_CONFIG_KEYS = {
67
76
  azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_INIT_CONFIG_JSON,
68
77
  useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_GROUNDING_USE_ANTHROPIC_SDK,
69
78
  anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_ANTHROPIC_API_KEY,
70
- vlMode: external_types_js_namespaceObject.MIDSCENE_GROUNDING_VL_MODE
79
+ vlMode: external_types_js_namespaceObject.MIDSCENE_GROUNDING_VL_MODE,
80
+ domain: 'domain',
81
+ yht_access_token: 'yht_access_token',
82
+ model: 'model',
83
+ baseURL: 'baseURL',
84
+ chatType: 'chatType',
85
+ modelCategory: 'modelCategory',
86
+ stream: 'stream',
87
+ temperature: 'temperature',
88
+ top_p: 'top_p'
71
89
  };
72
90
  const PLANNING_MODEL_CONFIG_KEYS = {
73
91
  modelName: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_NAME,
@@ -86,7 +104,16 @@ const PLANNING_MODEL_CONFIG_KEYS = {
86
104
  azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_INIT_CONFIG_JSON,
87
105
  useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_PLANNING_USE_ANTHROPIC_SDK,
88
106
  anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_ANTHROPIC_API_KEY,
89
- vlMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_VL_MODE
107
+ vlMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_VL_MODE,
108
+ domain: 'domain',
109
+ yht_access_token: 'yht_access_token',
110
+ model: 'model',
111
+ baseURL: 'baseURL',
112
+ chatType: 'chatType',
113
+ modelCategory: 'modelCategory',
114
+ stream: 'stream',
115
+ temperature: 'temperature',
116
+ top_p: 'top_p'
90
117
  };
91
118
  const DEFAULT_MODEL_CONFIG_KEYS = {
92
119
  modelName: external_types_js_namespaceObject.MIDSCENE_MODEL_NAME,
@@ -105,7 +132,16 @@ const DEFAULT_MODEL_CONFIG_KEYS = {
105
132
  azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_INIT_CONFIG_JSON,
106
133
  useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_USE_ANTHROPIC_SDK,
107
134
  anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_ANTHROPIC_API_KEY,
108
- vlMode: external_types_js_namespaceObject.MIDSCENE_VL_MODE
135
+ vlMode: external_types_js_namespaceObject.MIDSCENE_VL_MODE,
136
+ domain: 'domain',
137
+ yht_access_token: 'yht_access_token',
138
+ model: 'model',
139
+ baseURL: 'baseURL',
140
+ chatType: 'chatType',
141
+ modelCategory: 'modelCategory',
142
+ stream: 'stream',
143
+ temperature: 'temperature',
144
+ top_p: 'top_p'
109
145
  };
110
146
  const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
111
147
  modelName: external_types_js_namespaceObject.MIDSCENE_MODEL_NAME,
@@ -124,7 +160,16 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
124
160
  azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_INIT_CONFIG_JSON,
125
161
  useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_USE_ANTHROPIC_SDK,
126
162
  anthropicApiKey: external_types_js_namespaceObject.ANTHROPIC_API_KEY,
127
- vlMode: 'DEFAULT_MODEL_CONFIG_KEYS has no vlMode key'
163
+ vlMode: 'DEFAULT_MODEL_CONFIG_KEYS has no vlMode key',
164
+ domain: 'domain',
165
+ yht_access_token: 'yht_access_token',
166
+ model: 'model',
167
+ baseURL: 'baseURL',
168
+ chatType: 'chatType',
169
+ modelCategory: 'modelCategory',
170
+ stream: 'stream',
171
+ temperature: 'temperature',
172
+ top_p: 'top_p'
128
173
  };
129
174
  exports.DEFAULT_MODEL_CONFIG_KEYS = __webpack_exports__.DEFAULT_MODEL_CONFIG_KEYS;
130
175
  exports.DEFAULT_MODEL_CONFIG_KEYS_LEGACY = __webpack_exports__.DEFAULT_MODEL_CONFIG_KEYS_LEGACY;
@@ -87,6 +87,15 @@ class GlobalConfigManager {
87
87
  }
88
88
  overrideAIConfig(newConfig, extendMode = false) {
89
89
  var _this_override;
90
+ for(const key in newConfig){
91
+ if (![
92
+ ...external_types_js_namespaceObject.GLOBAL_ENV_KEYS,
93
+ ...external_types_js_namespaceObject.MODEL_ENV_KEYS
94
+ ].includes(key)) throw new Error(`Failed to override AI config, invalid key: ${key}`);
95
+ const value = newConfig[key];
96
+ if ('string' != typeof value) throw new Error(`Failed to override AI config, value for key ${key} must be a string, but got with type ${typeof value}`);
97
+ if (this.keysHaveBeenRead[key]) console.warn(`Warning: try to override AI config with key ${key} ,but it has been read.`);
98
+ }
90
99
  const savedNewConfig = extendMode ? {
91
100
  ...null == (_this_override = this.override) ? void 0 : _this_override.newConfig,
92
101
  ...newConfig
@@ -141,7 +141,8 @@ __webpack_require__.d(__webpack_exports__, {
141
141
  UITarsModelVersion: ()=>UITarsModelVersion,
142
142
  UNUSED_ENV_KEYS: ()=>UNUSED_ENV_KEYS,
143
143
  VL_MODE_RAW_VALID_VALUES: ()=>VL_MODE_RAW_VALID_VALUES,
144
- Yht_ENV_KEYS: ()=>Yht_ENV_KEYS
144
+ YHT_NUMBER_ENV_KEYS: ()=>YHT_NUMBER_ENV_KEYS,
145
+ YHT_STRING_ENV_KEYS: ()=>YHT_STRING_ENV_KEYS
145
146
  });
146
147
  const MIDSCENE_OPENAI_INIT_CONFIG_JSON = 'MIDSCENE_OPENAI_INIT_CONFIG_JSON';
147
148
  const MIDSCENE_MODEL_NAME = 'MIDSCENE_MODEL_NAME';
@@ -289,6 +290,19 @@ const GLOBAL_ENV_KEYS = [
289
290
  ...NUMBER_ENV_KEYS,
290
291
  ...STRING_ENV_KEYS
291
292
  ];
293
+ const YHT_STRING_ENV_KEYS = [
294
+ 'domain',
295
+ 'yht_access_token',
296
+ 'model',
297
+ 'baseURL'
298
+ ];
299
+ const YHT_NUMBER_ENV_KEYS = [
300
+ 'chatType',
301
+ 'modelCategory',
302
+ 'stream',
303
+ 'temperature',
304
+ 'top_p'
305
+ ];
292
306
  const MODEL_ENV_KEYS = [
293
307
  MIDSCENE_MODEL_NAME,
294
308
  MIDSCENE_OPENAI_INIT_CONFIG_JSON,
@@ -371,25 +385,15 @@ const MODEL_ENV_KEYS = [
371
385
  MIDSCENE_GROUNDING_AZURE_OPENAI_INIT_CONFIG_JSON,
372
386
  MIDSCENE_GROUNDING_USE_ANTHROPIC_SDK,
373
387
  MIDSCENE_GROUNDING_ANTHROPIC_API_KEY,
374
- MIDSCENE_GROUNDING_VL_MODE
375
- ];
376
- const Yht_ENV_KEYS = [
377
- 'domain',
378
- 'yht_access_token',
379
- 'chatType',
380
- 'model',
381
- 'modelCategory',
382
- 'stream',
383
- 'temperature',
384
- 'top_p',
385
- 'baseURL'
388
+ MIDSCENE_GROUNDING_VL_MODE,
389
+ ...YHT_STRING_ENV_KEYS,
390
+ ...YHT_NUMBER_ENV_KEYS
386
391
  ];
387
392
  const ALL_ENV_KEYS = [
388
393
  ...UNUSED_ENV_KEYS,
389
394
  ...BASIC_ENV_KEYS,
390
395
  ...GLOBAL_ENV_KEYS,
391
- ...MODEL_ENV_KEYS,
392
- ...Yht_ENV_KEYS
396
+ ...MODEL_ENV_KEYS
393
397
  ];
394
398
  var UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
395
399
  UITarsModelVersion["V1_0"] = "1.0";
@@ -524,7 +528,8 @@ exports.STRING_ENV_KEYS = __webpack_exports__.STRING_ENV_KEYS;
524
528
  exports.UITarsModelVersion = __webpack_exports__.UITarsModelVersion;
525
529
  exports.UNUSED_ENV_KEYS = __webpack_exports__.UNUSED_ENV_KEYS;
526
530
  exports.VL_MODE_RAW_VALID_VALUES = __webpack_exports__.VL_MODE_RAW_VALID_VALUES;
527
- exports.Yht_ENV_KEYS = __webpack_exports__.Yht_ENV_KEYS;
531
+ exports.YHT_NUMBER_ENV_KEYS = __webpack_exports__.YHT_NUMBER_ENV_KEYS;
532
+ exports.YHT_STRING_ENV_KEYS = __webpack_exports__.YHT_STRING_ENV_KEYS;
528
533
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
529
534
  "ALL_ENV_KEYS",
530
535
  "ANTHROPIC_API_KEY",
@@ -643,7 +648,8 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
643
648
  "UITarsModelVersion",
644
649
  "UNUSED_ENV_KEYS",
645
650
  "VL_MODE_RAW_VALID_VALUES",
646
- "Yht_ENV_KEYS"
651
+ "YHT_NUMBER_ENV_KEYS",
652
+ "YHT_STRING_ENV_KEYS"
647
653
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
648
654
  Object.defineProperty(exports, '__esModule', {
649
655
  value: true
@@ -44,7 +44,11 @@ const getPreferredLanguage = ()=>{
44
44
  return isChina ? 'Chinese' : 'English';
45
45
  };
46
46
  const overrideAIConfig = (newConfig, extendMode = false)=>{
47
- globalConfigManager.overrideAIConfig(newConfig, extendMode);
47
+ const config = Object.entries(newConfig).reduce((pre, [key, value])=>({
48
+ ...pre,
49
+ [key]: String(value)
50
+ }), {});
51
+ globalConfigManager.overrideAIConfig(config, extendMode);
48
52
  };
49
53
  exports.getPreferredLanguage = __webpack_exports__.getPreferredLanguage;
50
54
  exports.globalConfigManager = __webpack_exports__.globalConfigManager;
@@ -65,6 +65,7 @@ var __webpack_exports__ = {};
65
65
  __webpack_require__.d(__webpack_exports__, {
66
66
  descriptionOfTree: ()=>_tree__WEBPACK_IMPORTED_MODULE_0__.descriptionOfTree,
67
67
  generateElementByPosition: ()=>_dom_util__WEBPACK_IMPORTED_MODULE_4__.generateElementByPosition,
68
+ getElementFromPoint: ()=>_web_extractor__WEBPACK_IMPORTED_MODULE_1__.getElementFromPoint,
68
69
  getElementInfoByXpath: ()=>_locator__WEBPACK_IMPORTED_MODULE_3__.getElementInfoByXpath,
69
70
  getElementXpath: ()=>_locator__WEBPACK_IMPORTED_MODULE_3__.getElementXpath,
70
71
  getNodeFromCacheList: ()=>_util__WEBPACK_IMPORTED_MODULE_2__.getNodeFromCacheList,
@@ -101,6 +102,7 @@ var __webpack_exports__ = {};
101
102
  "truncateText",
102
103
  "webExtractTextWithPosition",
103
104
  "getElementXpath",
105
+ "getElementFromPoint",
104
106
  "webExtractNodeTree",
105
107
  "default",
106
108
  "getXpathsByPoint",
@@ -114,6 +116,7 @@ var __webpack_exports__ = {};
114
116
  })();
115
117
  exports.descriptionOfTree = __webpack_exports__.descriptionOfTree;
116
118
  exports.generateElementByPosition = __webpack_exports__.generateElementByPosition;
119
+ exports.getElementFromPoint = __webpack_exports__.getElementFromPoint;
117
120
  exports.getElementInfoByXpath = __webpack_exports__.getElementInfoByXpath;
118
121
  exports.getElementXpath = __webpack_exports__.getElementXpath;
119
122
  exports.getNodeFromCacheList = __webpack_exports__.getNodeFromCacheList;
@@ -132,6 +135,7 @@ exports.webExtractTextWithPosition = __webpack_exports__.webExtractTextWithPosit
132
135
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
133
136
  "descriptionOfTree",
134
137
  "generateElementByPosition",
138
+ "getElementFromPoint",
135
139
  "getElementInfoByXpath",
136
140
  "getElementXpath",
137
141
  "getNodeFromCacheList",
@@ -26,6 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  collectElementInfo: ()=>collectElementInfo,
28
28
  extractTreeNodeAsString: ()=>extractTreeNodeAsString,
29
+ getElementFromPoint: ()=>getElementFromPoint,
29
30
  extractTreeNode: ()=>extractTreeNode,
30
31
  mergeElementAndChildrenRects: ()=>mergeElementAndChildrenRects,
31
32
  extractTextWithPosition: ()=>extractTextWithPosition
@@ -389,17 +390,79 @@ if ('undefined' != typeof window) (0, external_cs_postmessage_js_namespaceObject
389
390
  error: 'error message'
390
391
  };
391
392
  }
393
+ if ('getElementFromPoint' === action) try {
394
+ return await getElementFromPoint({
395
+ x: data.x,
396
+ y: data.y,
397
+ containerPaths: data.containerPaths
398
+ });
399
+ } catch (error) {
400
+ return {
401
+ error: 'error message'
402
+ };
403
+ }
392
404
  });
405
+ const getElementOffset = (element)=>{
406
+ const pLeft = parseInt(window.getComputedStyle(element, null).getPropertyValue('padding-left'), 10) || 0;
407
+ const pTop = parseInt(window.getComputedStyle(element, null).getPropertyValue('padding-top'), 10) || 0;
408
+ const bLeft = parseInt(window.getComputedStyle(element, null).getPropertyValue('border-left-width'), 10) || 0;
409
+ const bTop = parseInt(window.getComputedStyle(element, null).getPropertyValue('border-top-width'), 10) || 0;
410
+ return {
411
+ x: pLeft + bLeft,
412
+ y: pTop + bTop
413
+ };
414
+ };
415
+ const web_extractor_getCssScale = (element)=>{
416
+ try {
417
+ const { width, height } = element.getBoundingClientRect();
418
+ return {
419
+ cssScaleX: Number((width / element.offsetWidth).toFixed(1)),
420
+ cssScaleY: Number((height / element.offsetHeight).toFixed(1))
421
+ };
422
+ } catch (error) {
423
+ return {
424
+ cssScaleX: 1,
425
+ cssScaleY: 1
426
+ };
427
+ }
428
+ };
429
+ const getElementFromPoint = async (args)=>{
430
+ if (!args.containerPaths) args.containerPaths = [];
431
+ const dom = document.elementFromPoint(args.x, args.y);
432
+ if ((null == dom ? void 0 : dom.nodeName) === 'IFRAME') {
433
+ const containerPath = (0, external_customLocator_js_namespaceObject.getContainerPath)(dom);
434
+ const bounding = dom.getBoundingClientRect();
435
+ const offset = getElementOffset(dom);
436
+ const { cssScaleX, cssScaleY } = web_extractor_getCssScale(dom);
437
+ return await (0, external_cs_postmessage_js_namespaceObject.postWindowMessage)(dom.contentWindow, window, {
438
+ action: 'getElementFromPoint',
439
+ data: {
440
+ x: (args.x - bounding.x - offset.x) / cssScaleX,
441
+ y: (args.y - bounding.y - offset.y) / cssScaleY,
442
+ containerPaths: args.containerPaths.concat(containerPath)
443
+ }
444
+ });
445
+ }
446
+ {
447
+ const elementInfo = {
448
+ allPaths: (0, external_customLocator_js_namespaceObject.getLocators)(dom),
449
+ containerPaths: args.containerPaths
450
+ };
451
+ return elementInfo;
452
+ }
453
+ };
393
454
  exports.collectElementInfo = __webpack_exports__.collectElementInfo;
394
455
  exports.extractTextWithPosition = __webpack_exports__.extractTextWithPosition;
395
456
  exports.extractTreeNode = __webpack_exports__.extractTreeNode;
396
457
  exports.extractTreeNodeAsString = __webpack_exports__.extractTreeNodeAsString;
458
+ exports.getElementFromPoint = __webpack_exports__.getElementFromPoint;
397
459
  exports.mergeElementAndChildrenRects = __webpack_exports__.mergeElementAndChildrenRects;
398
460
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
399
461
  "collectElementInfo",
400
462
  "extractTextWithPosition",
401
463
  "extractTreeNode",
402
464
  "extractTreeNodeAsString",
465
+ "getElementFromPoint",
403
466
  "mergeElementAndChildrenRects"
404
467
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
405
468
  Object.defineProperty(exports, '__esModule', {