@midscene/recorder 0.21.4-beta-20250711063424.0 → 0.21.4-beta-20250714025212.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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
3
+ *
4
+ * @version 0.11.0
5
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
+ * @copyright Chen, Yi-Cyuan 2014-2024
7
+ * @license MIT
8
+ */
@@ -43,6 +43,8 @@ export declare class EventRecorder {
43
43
  private eventCallback;
44
44
  private scrollThrottleTimer;
45
45
  private scrollThrottleDelay;
46
+ private inputThrottleTimer;
47
+ private inputThrottleDelay;
46
48
  private lastViewportScroll;
47
49
  private scrollTargets;
48
50
  private sessionId;
package/dist/recorder.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__midscene_shared_extractor_dbce1f15__ from "@midscene/shared/extractor";
1
2
  const DEBUG = 'true' === localStorage.getItem('DEBUG');
2
3
  function debugLog(...args) {
3
4
  if (DEBUG) console.log('[EventRecorder]', ...args);
@@ -39,6 +40,8 @@ class EventRecorder {
39
40
  eventCallback;
40
41
  scrollThrottleTimer = null;
41
42
  scrollThrottleDelay = 200;
43
+ inputThrottleTimer = null;
44
+ inputThrottleDelay = 300;
42
45
  lastViewportScroll = null;
43
46
  scrollTargets = [];
44
47
  sessionId;
@@ -56,7 +59,7 @@ class EventRecorder {
56
59
  height: window.innerHeight
57
60
  },
58
61
  timestamp: Date.now(),
59
- hashId: 'navigation_0'
62
+ hashId: `navigation_${Date.now()}`
60
63
  };
61
64
  }
62
65
  start() {
@@ -93,6 +96,10 @@ class EventRecorder {
93
96
  clearTimeout(this.scrollThrottleTimer);
94
97
  this.scrollThrottleTimer = null;
95
98
  }
99
+ if (this.inputThrottleTimer) {
100
+ clearTimeout(this.inputThrottleTimer);
101
+ this.inputThrottleTimer = null;
102
+ }
96
103
  document.removeEventListener('click', this.handleClick);
97
104
  document.removeEventListener('input', this.handleInput);
98
105
  this.scrollTargets.forEach((target)=>{
@@ -104,11 +111,18 @@ class EventRecorder {
104
111
  if (!this.isRecording) return;
105
112
  const target = event.target;
106
113
  const { isLabelClick, labelInfo } = this.checkLabelClick(target);
107
- target.getBoundingClientRect();
114
+ const rect = target.getBoundingClientRect();
108
115
  const elementRect = {
109
116
  x: Number(event.clientX.toFixed(2)),
110
117
  y: Number(event.clientY.toFixed(2))
111
118
  };
119
+ console.log('isNotContainerElement', (0, __WEBPACK_EXTERNAL_MODULE__midscene_shared_extractor_dbce1f15__.isNotContainerElement)(target));
120
+ if ((0, __WEBPACK_EXTERNAL_MODULE__midscene_shared_extractor_dbce1f15__.isNotContainerElement)(target)) {
121
+ elementRect.left = Number(rect.left.toFixed(2));
122
+ elementRect.top = Number(rect.top.toFixed(2));
123
+ elementRect.width = Number(rect.width.toFixed(2));
124
+ elementRect.height = Number(rect.height.toFixed(2));
125
+ }
112
126
  const clickEvent = {
113
127
  type: 'click',
114
128
  elementRect,
@@ -182,22 +196,34 @@ class EventRecorder {
182
196
  width: Number(rect.width.toFixed(2)),
183
197
  height: Number(rect.height.toFixed(2))
184
198
  };
185
- const inputEvent = {
186
- type: 'input',
187
- value: 'password' !== target.type ? target.value : '*****',
188
- timestamp: Date.now(),
189
- hashId: generateHashId('input', {
190
- ...elementRect
191
- }),
192
- element: target,
193
- inputType: target.type || 'text',
194
- elementRect,
195
- pageInfo: {
196
- width: window.innerWidth,
197
- height: window.innerHeight
199
+ if (this.inputThrottleTimer) clearTimeout(this.inputThrottleTimer);
200
+ this.inputThrottleTimer = window.setTimeout(()=>{
201
+ if (this.isRecording) {
202
+ const inputEvent = {
203
+ type: 'input',
204
+ value: 'password' !== target.type ? target.value : '*****',
205
+ timestamp: Date.now(),
206
+ hashId: generateHashId('input', {
207
+ ...elementRect
208
+ }),
209
+ element: target,
210
+ inputType: target.type || 'text',
211
+ elementRect,
212
+ pageInfo: {
213
+ width: window.innerWidth,
214
+ height: window.innerHeight
215
+ }
216
+ };
217
+ debugLog('Throttled input event:', {
218
+ value: inputEvent.value,
219
+ timestamp: inputEvent.timestamp,
220
+ target: target.tagName,
221
+ inputType: target.type
222
+ });
223
+ this.eventCallback(inputEvent);
198
224
  }
199
- };
200
- this.eventCallback(inputEvent);
225
+ this.inputThrottleTimer = null;
226
+ }, this.inputThrottleDelay);
201
227
  };
202
228
  checkLabelClick(target) {
203
229
  let isLabelClick = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/recorder",
3
- "version": "0.21.4-beta-20250711063424.0",
3
+ "version": "0.21.4-beta-20250714025212.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -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.21.4-beta-20250711063424.0"
27
+ "@midscene/shared": "0.21.4-beta-20250714025212.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": "18.3.1",
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.