node-mac-recorder 1.2.1 → 1.2.2
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/README.md +97 -97
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -234,61 +234,47 @@ const thumbnail = await recorder.getDisplayThumbnail(0, {
|
|
|
234
234
|
|
|
235
235
|
### Cursor Tracking Methods
|
|
236
236
|
|
|
237
|
-
#### `
|
|
237
|
+
#### `startCursorCapture(outputPath)`
|
|
238
238
|
|
|
239
|
-
Starts
|
|
239
|
+
Starts automatic cursor tracking and saves data to JSON file in real-time.
|
|
240
240
|
|
|
241
241
|
```javascript
|
|
242
|
-
await recorder.
|
|
243
|
-
// Cursor tracking started -
|
|
242
|
+
await recorder.startCursorCapture("./cursor-data.json");
|
|
243
|
+
// Cursor tracking started - automatically writing to file
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
#### `
|
|
246
|
+
#### `stopCursorCapture()`
|
|
247
247
|
|
|
248
|
-
Stops cursor tracking and
|
|
248
|
+
Stops cursor tracking and closes the output file.
|
|
249
249
|
|
|
250
250
|
```javascript
|
|
251
|
-
await recorder.
|
|
252
|
-
//
|
|
251
|
+
await recorder.stopCursorCapture();
|
|
252
|
+
// Tracking stopped, file closed
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
**JSON Output Format:**
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const status = recorder.getCursorTrackingStatus();
|
|
275
|
-
console.log(status);
|
|
276
|
-
// {
|
|
277
|
-
// isTracking: true,
|
|
278
|
-
// dataCount: 1250,
|
|
279
|
-
// hasEventTap: true,
|
|
280
|
-
// hasRunLoopSource: true
|
|
281
|
-
// }
|
|
257
|
+
```json
|
|
258
|
+
[
|
|
259
|
+
{
|
|
260
|
+
"x": 851,
|
|
261
|
+
"y": 432,
|
|
262
|
+
"timestamp": 201,
|
|
263
|
+
"cursorType": "default",
|
|
264
|
+
"type": "move"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"x": 851,
|
|
268
|
+
"y": 432,
|
|
269
|
+
"timestamp": 220,
|
|
270
|
+
"cursorType": "pointer",
|
|
271
|
+
"type": "mousedown"
|
|
272
|
+
}
|
|
273
|
+
]
|
|
282
274
|
```
|
|
283
275
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
Manually saves current cursor data to file.
|
|
287
|
-
|
|
288
|
-
```javascript
|
|
289
|
-
await recorder.saveCursorData("./cursor-backup.json");
|
|
290
|
-
// Data saved to file
|
|
291
|
-
```
|
|
276
|
+
**Cursor Types:** `default`, `pointer`, `text`, `grab`, `grabbing`, `ew-resize`, `ns-resize`, `crosshair`
|
|
277
|
+
**Event Types:** `move`, `mousedown`, `mouseup`, `rightmousedown`, `rightmouseup`
|
|
292
278
|
|
|
293
279
|
## Usage Examples
|
|
294
280
|
|
|
@@ -466,56 +452,51 @@ async function createDisplaySelector() {
|
|
|
466
452
|
### Cursor Tracking Usage
|
|
467
453
|
|
|
468
454
|
```javascript
|
|
469
|
-
const
|
|
455
|
+
const MacRecorder = require("node-mac-recorder");
|
|
470
456
|
|
|
471
457
|
async function trackUserInteraction() {
|
|
472
|
-
|
|
473
|
-
await recorder.startCursorTracking("./user-interactions.json");
|
|
474
|
-
console.log("Cursor tracking started...");
|
|
475
|
-
|
|
476
|
-
// Monitor real-time cursor position
|
|
477
|
-
const monitorInterval = setInterval(() => {
|
|
478
|
-
const position = recorder.getCursorPosition();
|
|
479
|
-
console.log(
|
|
480
|
-
`Cursor: ${position.x}, ${position.y} (${position.cursorType})`
|
|
481
|
-
);
|
|
458
|
+
const recorder = new MacRecorder();
|
|
482
459
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
460
|
+
try {
|
|
461
|
+
// Start cursor tracking - automatically writes to file
|
|
462
|
+
await recorder.startCursorCapture("./user-interactions.json");
|
|
463
|
+
console.log("✅ Cursor tracking started...");
|
|
486
464
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
465
|
+
// Track for 5 seconds
|
|
466
|
+
console.log("📱 Move mouse and click for 5 seconds...");
|
|
467
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
490
468
|
|
|
491
|
-
// Stop tracking
|
|
492
|
-
await recorder.
|
|
493
|
-
console.log("Cursor tracking completed!");
|
|
469
|
+
// Stop tracking
|
|
470
|
+
await recorder.stopCursorCapture();
|
|
471
|
+
console.log("✅ Cursor tracking completed!");
|
|
494
472
|
|
|
495
|
-
//
|
|
473
|
+
// Analyze the data
|
|
496
474
|
const fs = require("fs");
|
|
497
475
|
const data = JSON.parse(
|
|
498
476
|
fs.readFileSync("./user-interactions.json", "utf8")
|
|
499
477
|
);
|
|
500
478
|
|
|
501
|
-
console.log(
|
|
479
|
+
console.log(`📄 ${data.length} events recorded`);
|
|
480
|
+
|
|
481
|
+
// Count clicks
|
|
482
|
+
const clicks = data.filter((d) => d.type === "mousedown").length;
|
|
483
|
+
if (clicks > 0) {
|
|
484
|
+
console.log(`🖱️ ${clicks} clicks detected`);
|
|
485
|
+
}
|
|
502
486
|
|
|
503
|
-
//
|
|
487
|
+
// Most used cursor type
|
|
504
488
|
const cursorTypes = {};
|
|
505
489
|
data.forEach((item) => {
|
|
506
490
|
cursorTypes[item.cursorType] = (cursorTypes[item.cursorType] || 0) + 1;
|
|
507
491
|
});
|
|
508
492
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
console.log("Event types distribution:", eventTypes);
|
|
518
|
-
}, 10000);
|
|
493
|
+
const mostUsed = Object.keys(cursorTypes).reduce((a, b) =>
|
|
494
|
+
cursorTypes[a] > cursorTypes[b] ? a : b
|
|
495
|
+
);
|
|
496
|
+
console.log(`🎯 Most used cursor: ${mostUsed}`);
|
|
497
|
+
} catch (error) {
|
|
498
|
+
console.error("❌ Error:", error.message);
|
|
499
|
+
}
|
|
519
500
|
}
|
|
520
501
|
|
|
521
502
|
trackUserInteraction();
|
|
@@ -524,33 +505,37 @@ trackUserInteraction();
|
|
|
524
505
|
### Combined Screen Recording + Cursor Tracking
|
|
525
506
|
|
|
526
507
|
```javascript
|
|
527
|
-
const
|
|
508
|
+
const MacRecorder = require("node-mac-recorder");
|
|
528
509
|
|
|
529
510
|
async function recordWithCursorTracking() {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
includeSystemAudio: true,
|
|
535
|
-
quality: "high",
|
|
536
|
-
}),
|
|
537
|
-
recorder.startCursorTracking("./cursor-data.json"),
|
|
538
|
-
]);
|
|
539
|
-
|
|
540
|
-
console.log("Recording screen and tracking cursor...");
|
|
541
|
-
|
|
542
|
-
// Record for 30 seconds
|
|
543
|
-
setTimeout(async () => {
|
|
511
|
+
const recorder = new MacRecorder();
|
|
512
|
+
|
|
513
|
+
try {
|
|
514
|
+
// Start both screen recording and cursor tracking
|
|
544
515
|
await Promise.all([
|
|
545
|
-
recorder.
|
|
546
|
-
|
|
516
|
+
recorder.startRecording("./screen-recording.mov", {
|
|
517
|
+
captureCursor: false, // Don't show cursor in video
|
|
518
|
+
includeSystemAudio: true,
|
|
519
|
+
quality: "high",
|
|
520
|
+
}),
|
|
521
|
+
recorder.startCursorCapture("./cursor-data.json"),
|
|
547
522
|
]);
|
|
548
523
|
|
|
549
|
-
console.log("
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
524
|
+
console.log("✅ Recording screen and tracking cursor...");
|
|
525
|
+
|
|
526
|
+
// Record for 10 seconds
|
|
527
|
+
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
528
|
+
|
|
529
|
+
// Stop both
|
|
530
|
+
await Promise.all([recorder.stopRecording(), recorder.stopCursorCapture()]);
|
|
531
|
+
|
|
532
|
+
console.log("✅ Recording completed!");
|
|
533
|
+
console.log("📁 Files created:");
|
|
534
|
+
console.log(" - screen-recording.mov");
|
|
535
|
+
console.log(" - cursor-data.json");
|
|
536
|
+
} catch (error) {
|
|
537
|
+
console.error("❌ Error:", error.message);
|
|
538
|
+
}
|
|
554
539
|
}
|
|
555
540
|
|
|
556
541
|
recordWithCursorTracking();
|
|
@@ -651,6 +636,21 @@ The `getWindows()` method automatically filters out:
|
|
|
651
636
|
- **Memory Efficient** - Proper memory management in native layer
|
|
652
637
|
- **Quality Presets** - Balanced quality/performance options
|
|
653
638
|
|
|
639
|
+
## Testing
|
|
640
|
+
|
|
641
|
+
Run the included demo to test cursor tracking:
|
|
642
|
+
|
|
643
|
+
```bash
|
|
644
|
+
node cursor-test.js
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
This will:
|
|
648
|
+
|
|
649
|
+
- ✅ Start cursor tracking for 5 seconds
|
|
650
|
+
- 📱 Capture mouse movements and clicks
|
|
651
|
+
- 📄 Save data to `cursor-data.json`
|
|
652
|
+
- 🖱️ Report clicks detected
|
|
653
|
+
|
|
654
654
|
## Troubleshooting
|
|
655
655
|
|
|
656
656
|
### Permission Issues
|