@midscene/recorder 0.30.10 → 1.0.0
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/recorder-iife.js +8 -12
- package/package.json +6 -6
package/dist/recorder-iife.js
CHANGED
|
@@ -33,12 +33,10 @@
|
|
|
33
33
|
return isTextElement(node) || isIconfont(node) || isImgElement(node) || isButtonElement(node) || isAElement(node) || isFormElement(node);
|
|
34
34
|
}
|
|
35
35
|
function isTextElement(node) {
|
|
36
|
-
var _node_nodeName_toLowerCase, _node_nodeName;
|
|
37
36
|
if (node instanceof Element) {
|
|
38
|
-
|
|
39
|
-
if ((null == node ? void 0 : null == (_node_childNodes = node.childNodes) ? void 0 : _node_childNodes.length) === 1 && (null == node ? void 0 : node.childNodes[0]) instanceof Text) return true;
|
|
37
|
+
if (node?.childNodes?.length === 1 && node?.childNodes[0] instanceof Text) return true;
|
|
40
38
|
}
|
|
41
|
-
return
|
|
39
|
+
return node.nodeName?.toLowerCase?.() === '#text' && !isIconfont(node);
|
|
42
40
|
}
|
|
43
41
|
function includeBaseElement(node) {
|
|
44
42
|
if (!(node instanceof HTMLElement)) return false;
|
|
@@ -73,11 +71,10 @@
|
|
|
73
71
|
return text.replace(/\s+/g, ' ').trim();
|
|
74
72
|
};
|
|
75
73
|
const buildCurrentElementXpath = (element, isOrderSensitive, isLeafElement)=>{
|
|
76
|
-
var _element_textContent;
|
|
77
74
|
const parentPath = element.parentNode ? getElementXpath(element.parentNode, isOrderSensitive) : '';
|
|
78
75
|
const prefix = parentPath ? `${parentPath}/` : '/';
|
|
79
76
|
const tagName = element.nodeName.toLowerCase();
|
|
80
|
-
const textContent =
|
|
77
|
+
const textContent = element.textContent?.trim();
|
|
81
78
|
if (isOrderSensitive) {
|
|
82
79
|
const index = getElementXpathIndex(element);
|
|
83
80
|
return `${prefix}${tagName}[${index}]`;
|
|
@@ -90,9 +87,8 @@
|
|
|
90
87
|
if (element.nodeType === Node.TEXT_NODE) {
|
|
91
88
|
const parentNode = element.parentNode;
|
|
92
89
|
if (parentNode && parentNode.nodeType === Node.ELEMENT_NODE) {
|
|
93
|
-
var _element_textContent;
|
|
94
90
|
const parentXPath = getElementXpath(parentNode, isOrderSensitive, true);
|
|
95
|
-
const textContent =
|
|
91
|
+
const textContent = element.textContent?.trim();
|
|
96
92
|
if (textContent) return `${parentXPath}/text()[normalize-space()="${normalizeXpathText(textContent)}"]`;
|
|
97
93
|
return `${parentXPath}/text()`;
|
|
98
94
|
}
|
|
@@ -116,7 +112,7 @@
|
|
|
116
112
|
function debugLog(...args) {
|
|
117
113
|
if (DEBUG) console.log('[EventRecorder]', ...args);
|
|
118
114
|
}
|
|
119
|
-
function
|
|
115
|
+
function generateHashId(type, elementRect) {
|
|
120
116
|
const rectStr = elementRect ? `${elementRect.left}_${elementRect.top}_${elementRect.width}_${elementRect.height}${void 0 !== elementRect.x ? `_${elementRect.x}` : ''}${void 0 !== elementRect.y ? `_${elementRect.y}` : ''}` : 'no_rect';
|
|
121
117
|
const combined = `${type}_${rectStr}`;
|
|
122
118
|
let hash = 0;
|
|
@@ -245,7 +241,7 @@
|
|
|
245
241
|
},
|
|
246
242
|
value: '',
|
|
247
243
|
timestamp: Date.now(),
|
|
248
|
-
hashId:
|
|
244
|
+
hashId: generateHashId('click', {
|
|
249
245
|
...elementRect
|
|
250
246
|
}),
|
|
251
247
|
element: target,
|
|
@@ -288,7 +284,7 @@
|
|
|
288
284
|
},
|
|
289
285
|
value: `${scrollXTarget.toFixed(2)},${scrollYTarget.toFixed(2)}`,
|
|
290
286
|
timestamp: Date.now(),
|
|
291
|
-
hashId:
|
|
287
|
+
hashId: generateHashId('scroll', {
|
|
292
288
|
...elementRect
|
|
293
289
|
}),
|
|
294
290
|
element: target
|
|
@@ -316,7 +312,7 @@
|
|
|
316
312
|
type: 'input',
|
|
317
313
|
value: 'password' !== target.type ? target.value : '*****',
|
|
318
314
|
timestamp: Date.now(),
|
|
319
|
-
hashId:
|
|
315
|
+
hashId: generateHashId('input', {
|
|
320
316
|
...elementRect
|
|
321
317
|
}),
|
|
322
318
|
element: target,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/recorder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@rsbuild/plugin-react": "^1.
|
|
17
|
-
"@rslib/core": "^0.
|
|
16
|
+
"@rsbuild/plugin-react": "^1.4.1",
|
|
17
|
+
"@rslib/core": "^0.18.3",
|
|
18
18
|
"@types/react": "^18.3.1",
|
|
19
19
|
"react": "18.3.1",
|
|
20
20
|
"typescript": "^5.8.3"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"antd": "^5.21.6",
|
|
25
25
|
"dayjs": "^1.11.11",
|
|
26
26
|
"react-dom": "18.3.1",
|
|
27
|
-
"@midscene/shared": "0.
|
|
27
|
+
"@midscene/shared": "1.0.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "18.3.1",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "rslib build",
|
|
35
|
-
"dev": "
|
|
36
|
-
"build:watch": "
|
|
35
|
+
"dev": "npm run build:watch",
|
|
36
|
+
"build:watch": "rslib build --watch --no-clean"
|
|
37
37
|
}
|
|
38
38
|
}
|