node-mac-recorder 2.22.18 → 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.
@@ -37,6 +37,31 @@ 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
+
50
+ function packDisplayInfoForExport(di) {
51
+ if (!di) return {};
52
+ return {
53
+ displayId: di.displayId,
54
+ displayX: Number.isFinite(Number(di.displayX))
55
+ ? Number(di.displayX)
56
+ : Number(di.x) || 0,
57
+ displayY: Number.isFinite(Number(di.displayY))
58
+ ? Number(di.displayY)
59
+ : Number(di.y) || 0,
60
+ width: di.displayWidth ?? di.width,
61
+ height: di.displayHeight ?? di.height,
62
+ };
63
+ }
64
+
40
65
  function transformGlobalToVideo(globalX, globalY, d) {
41
66
  if (!d || !d.videoRelative) {
42
67
  return {
@@ -80,28 +105,29 @@ function transformInputFrameGlobal(ifr, d) {
80
105
  };
81
106
  }
82
107
 
108
+ /** @returns {boolean} Dosyaya textInput satırı yazıldı mı */
83
109
  function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestamp) {
84
110
  if (!IS_ELECTRON) {
85
- return;
111
+ return false;
86
112
  }
87
113
  const ct = cursorData.cursorType || "";
88
114
  if (ct !== "text" && ct !== "vertical-text") {
89
- return;
115
+ return false;
90
116
  }
91
117
  if (timestamp < ELECTRON_SYNTH_GRACE_MS) {
92
- return;
118
+ return false;
93
119
  }
94
120
  const wall = Date.now();
95
121
  if (
96
122
  wall - (recorder._electronSynthWallMs || 0) <
97
123
  ELECTRON_SYNTH_THROTTLE_MS
98
124
  ) {
99
- return;
125
+ return false;
100
126
  }
101
127
  const vx = cursorData.x;
102
128
  const vy = cursorData.y;
103
129
  if (!Number.isFinite(vx) || !Number.isFinite(vy)) {
104
- return;
130
+ return false;
105
131
  }
106
132
 
107
133
  const tiRow = {
@@ -152,7 +178,7 @@ function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestam
152
178
  Math.abs(le.caretY - tiRow.caretY) < 0.75 &&
153
179
  timestamp - le.timestamp < 220
154
180
  ) {
155
- return;
181
+ return false;
156
182
  }
157
183
  recorder._lastTextInputEmitted = {
158
184
  caretX: tiRow.caretX,
@@ -161,13 +187,8 @@ function tryAppendSyntheticTextInputRow(recorder, filepath, cursorData, timestam
161
187
  };
162
188
  recorder._electronSynthWallMs = wall;
163
189
 
164
- const jsonString = JSON.stringify(tiRow);
165
- if (recorder.cursorCaptureFirstWrite) {
166
- fs.appendFileSync(filepath, jsonString);
167
- recorder.cursorCaptureFirstWrite = false;
168
- } else {
169
- fs.appendFileSync(filepath, "," + jsonString);
170
- }
190
+ appendCursorJsonLine(recorder, filepath, tiRow);
191
+ return true;
171
192
  }
172
193
 
173
194
  function tryAppendTextInput(
@@ -241,13 +262,7 @@ function tryAppendTextInput(
241
262
  offsetY: d.videoOffsetY,
242
263
  }
243
264
  : {},
244
- displayInfo: d
245
- ? {
246
- displayId: d.displayId,
247
- width: d.displayWidth,
248
- height: d.displayHeight,
249
- }
250
- : {},
265
+ displayInfo: packDisplayInfoForExport(d),
251
266
  };
252
267
 
253
268
  if (
@@ -434,13 +449,7 @@ async function startCursorCapture(recorder, nativeBinding, intervalOrFilepath, o
434
449
  offsetY: di.videoOffsetY,
435
450
  }
436
451
  : {},
437
- displayInfo: di
438
- ? {
439
- displayId: di.displayId,
440
- width: di.displayWidth,
441
- height: di.displayHeight,
442
- }
443
- : {},
452
+ displayInfo: packDisplayInfoForExport(di),
444
453
  };
445
454
 
446
455
  if (di?.multiWindowBounds && di.multiWindowBounds.length > 0) {
@@ -498,24 +507,24 @@ async function startCursorCapture(recorder, nativeBinding, intervalOrFilepath, o
498
507
  };
499
508
  }
500
509
 
510
+ let wroteMoveSample = false;
501
511
  if (shouldCaptureCursorSample(recorder.lastCapturedData, cursorData)) {
502
- const jsonString = JSON.stringify(cursorData);
503
- if (recorder.cursorCaptureFirstWrite) {
504
- fs.appendFileSync(filepath, jsonString);
505
- recorder.cursorCaptureFirstWrite = false;
506
- } else {
507
- fs.appendFileSync(filepath, "," + jsonString);
508
- }
512
+ appendCursorJsonLine(recorder, filepath, cursorData);
509
513
  recorder.lastCapturedData = { ...cursorData };
514
+ wroteMoveSample = true;
510
515
  }
511
516
 
512
517
  if (IS_ELECTRON) {
513
- tryAppendSyntheticTextInputRow(
518
+ const textInputWritten = tryAppendSyntheticTextInputRow(
514
519
  recorder,
515
520
  filepath,
516
521
  cursorData,
517
522
  timestamp,
518
523
  );
524
+ if (textInputWritten && !wroteMoveSample) {
525
+ appendCursorJsonLine(recorder, filepath, cursorData);
526
+ recorder.lastCapturedData = { ...cursorData };
527
+ }
519
528
  } else {
520
529
  queueDeferredTextInputSample(
521
530
  recorder,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.22.18",
3
+ "version": "2.22.20",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [