@rpascene/shared 0.30.12 → 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.
- package/dist/es/constants/index.mjs +73 -27
- package/dist/es/extractor/web-extractor.mjs +4 -39
- package/dist/es/node/fs.mjs +1 -1
- package/dist/lib/constants/index.js +79 -27
- package/dist/lib/extractor/web-extractor.js +4 -39
- package/dist/lib/node/fs.js +1 -1
- package/dist/types/constants/index.d.ts +34 -0
- package/dist/types/extractor/web-extractor.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants/index.ts +77 -26
- package/src/extractor/web-extractor.ts +15 -48
|
@@ -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:
|
|
104
|
+
[rpasceneCommand.Tap]: {
|
|
105
|
+
CommandName: rpastudioCommand.SeleniumClickCommand,
|
|
70
106
|
DisplayName: "\u5143\u7D20\u70B9\u51FB"
|
|
71
107
|
},
|
|
72
|
-
RightClick: {
|
|
73
|
-
CommandName:
|
|
108
|
+
[rpasceneCommand.RightClick]: {
|
|
109
|
+
CommandName: rpastudioCommand.SeleniumRightClickCommand,
|
|
74
110
|
DisplayName: "\u5143\u7D20\u53F3\u952E\u70B9\u51FB"
|
|
75
111
|
},
|
|
76
|
-
DoubleClick: {
|
|
77
|
-
CommandName:
|
|
112
|
+
[rpasceneCommand.DoubleClick]: {
|
|
113
|
+
CommandName: rpastudioCommand.SeleniumDoubleClickCommand,
|
|
78
114
|
DisplayName: "\u5143\u7D20\u53CC\u51FB"
|
|
79
115
|
},
|
|
80
|
-
Hover: {
|
|
81
|
-
CommandName:
|
|
116
|
+
[rpasceneCommand.Hover]: {
|
|
117
|
+
CommandName: rpastudioCommand.SeleniumMouseHoverCommand,
|
|
82
118
|
DisplayName: "\u9F20\u6807\u60AC\u505C"
|
|
83
119
|
},
|
|
84
|
-
Input: {
|
|
85
|
-
CommandName:
|
|
120
|
+
[rpasceneCommand.Input]: {
|
|
121
|
+
CommandName: rpastudioCommand.SeleniumSetValueCommand,
|
|
86
122
|
DisplayName: "\u8BBE\u7F6E\u6587\u672C"
|
|
87
123
|
},
|
|
88
|
-
KeyboardPress: {
|
|
89
|
-
CommandName:
|
|
124
|
+
[rpasceneCommand.KeyboardPress]: {
|
|
125
|
+
CommandName: rpastudioCommand.SeleniumElementSendKeysCommand,
|
|
90
126
|
DisplayName: "\u6A21\u62DF\u6309\u952E"
|
|
91
127
|
},
|
|
92
|
-
Scroll: {
|
|
93
|
-
CommandName:
|
|
128
|
+
[rpasceneCommand.Scroll]: {
|
|
129
|
+
CommandName: rpastudioCommand.SeleniumElementScrollCommand,
|
|
94
130
|
DisplayName: "\u5143\u7D20\u6EDA\u52A8"
|
|
95
131
|
},
|
|
96
|
-
DragAndDrop: {
|
|
97
|
-
CommandName:
|
|
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:
|
|
136
|
+
[rpasceneCommand.ClearInput]: {
|
|
137
|
+
CommandName: rpastudioCommand.SeleniumClearValueCommand,
|
|
102
138
|
DisplayName: "\u6E05\u7A7A\u6587\u672C"
|
|
103
139
|
},
|
|
104
|
-
Sleep: {
|
|
105
|
-
CommandName:
|
|
140
|
+
[rpasceneCommand.Sleep]: {
|
|
141
|
+
CommandName: rpastudioCommand.PauseCommand,
|
|
106
142
|
DisplayName: "\u6682\u505C\u811A\u672C"
|
|
107
143
|
},
|
|
108
|
-
LongPress: {
|
|
109
|
-
CommandName: "
|
|
110
|
-
DisplayName: "
|
|
144
|
+
[rpasceneCommand.LongPress]: {
|
|
145
|
+
CommandName: "",
|
|
146
|
+
DisplayName: ""
|
|
111
147
|
},
|
|
112
|
-
Swipe: {
|
|
113
|
-
CommandName: "
|
|
114
|
-
DisplayName: "
|
|
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
|
|
@@ -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'
|