node-mac-recorder 2.22.19 → 2.22.20
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/lib/cursorCapture/polling.js +27 -21
- package/package.json +1 -1
|
@@ -37,6 +37,16 @@ function shouldCaptureCursorSample(lastCapturedData, currentData) {
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function appendCursorJsonLine(recorder, filepath, obj) {
|
|
41
|
+
const jsonString = JSON.stringify(obj);
|
|
42
|
+
if (recorder.cursorCaptureFirstWrite) {
|
|
43
|
+
fs.appendFileSync(filepath, jsonString);
|
|
44
|
+
recorder.cursorCaptureFirstWrite = false;
|
|
45
|
+
} else {
|
|
46
|
+
fs.appendFileSync(filepath, "," + jsonString);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
function packDisplayInfoForExport(di) {
|
|
41
51
|
if (!di) return {};
|
|
42
52
|
return {
|
|
@@ -95,28 +105,29 @@ function transformInputFrameGlobal(ifr, d) {
|
|
|
95
105
|
};
|
|
96
106
|
}
|
|
97
107
|
|
|
108
|
+
/** @returns {boolean} Dosyaya textInput satırı yazıldı mı */
|
|
98
109
|
function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestamp) {
|
|
99
110
|
if (!IS_ELECTRON) {
|
|
100
|
-
return;
|
|
111
|
+
return false;
|
|
101
112
|
}
|
|
102
113
|
const ct = cursorData.cursorType || "";
|
|
103
114
|
if (ct !== "text" && ct !== "vertical-text") {
|
|
104
|
-
return;
|
|
115
|
+
return false;
|
|
105
116
|
}
|
|
106
117
|
if (timestamp < ELECTRON_SYNTH_GRACE_MS) {
|
|
107
|
-
return;
|
|
118
|
+
return false;
|
|
108
119
|
}
|
|
109
120
|
const wall = Date.now();
|
|
110
121
|
if (
|
|
111
122
|
wall - (recorder._electronSynthWallMs || 0) <
|
|
112
123
|
ELECTRON_SYNTH_THROTTLE_MS
|
|
113
124
|
) {
|
|
114
|
-
return;
|
|
125
|
+
return false;
|
|
115
126
|
}
|
|
116
127
|
const vx = cursorData.x;
|
|
117
128
|
const vy = cursorData.y;
|
|
118
129
|
if (!Number.isFinite(vx) || !Number.isFinite(vy)) {
|
|
119
|
-
return;
|
|
130
|
+
return false;
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
const tiRow = {
|
|
@@ -167,7 +178,7 @@ function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestam
|
|
|
167
178
|
Math.abs(le.caretY - tiRow.caretY) < 0.75 &&
|
|
168
179
|
timestamp - le.timestamp < 220
|
|
169
180
|
) {
|
|
170
|
-
return;
|
|
181
|
+
return false;
|
|
171
182
|
}
|
|
172
183
|
recorder._lastTextInputEmitted = {
|
|
173
184
|
caretX: tiRow.caretX,
|
|
@@ -176,13 +187,8 @@ function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestam
|
|
|
176
187
|
};
|
|
177
188
|
recorder._electronSynthWallMs = wall;
|
|
178
189
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
fs.appendFileSync(filepath, jsonString);
|
|
182
|
-
recorder.cursorCaptureFirstWrite = false;
|
|
183
|
-
} else {
|
|
184
|
-
fs.appendFileSync(filepath, "," + jsonString);
|
|
185
|
-
}
|
|
190
|
+
appendCursorJsonLine(recorder, filepath, tiRow);
|
|
191
|
+
return true;
|
|
186
192
|
}
|
|
187
193
|
|
|
188
194
|
function tryAppendTextInput(
|
|
@@ -501,24 +507,24 @@ async function startCursorCapture(recorder, nativeBinding, intervalOrFilepath, o
|
|
|
501
507
|
};
|
|
502
508
|
}
|
|
503
509
|
|
|
510
|
+
let wroteMoveSample = false;
|
|
504
511
|
if (shouldCaptureCursorSample(recorder.lastCapturedData, cursorData)) {
|
|
505
|
-
|
|
506
|
-
if (recorder.cursorCaptureFirstWrite) {
|
|
507
|
-
fs.appendFileSync(filepath, jsonString);
|
|
508
|
-
recorder.cursorCaptureFirstWrite = false;
|
|
509
|
-
} else {
|
|
510
|
-
fs.appendFileSync(filepath, "," + jsonString);
|
|
511
|
-
}
|
|
512
|
+
appendCursorJsonLine(recorder, filepath, cursorData);
|
|
512
513
|
recorder.lastCapturedData = { ...cursorData };
|
|
514
|
+
wroteMoveSample = true;
|
|
513
515
|
}
|
|
514
516
|
|
|
515
517
|
if (IS_ELECTRON) {
|
|
516
|
-
tryAppendSyntheticTextInputRow(
|
|
518
|
+
const textInputWritten = tryAppendSyntheticTextInputRow(
|
|
517
519
|
recorder,
|
|
518
520
|
filepath,
|
|
519
521
|
cursorData,
|
|
520
522
|
timestamp,
|
|
521
523
|
);
|
|
524
|
+
if (textInputWritten && !wroteMoveSample) {
|
|
525
|
+
appendCursorJsonLine(recorder, filepath, cursorData);
|
|
526
|
+
recorder.lastCapturedData = { ...cursorData };
|
|
527
|
+
}
|
|
522
528
|
} else {
|
|
523
529
|
queueDeferredTextInputSample(
|
|
524
530
|
recorder,
|