node-mac-recorder 2.17.17 → 2.17.19

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/index.js CHANGED
@@ -359,53 +359,10 @@ class MacRecorder extends EventEmitter {
359
359
  // Start cursor tracking automatically with recording
360
360
  let cursorOptions = {};
361
361
 
362
- // For window recording, use simplified window-relative coordinates
363
- if (this.options.windowId) {
364
- // Use cached window info from the earlier window detection
365
- this.getWindows().then(windows => {
366
- const targetWindow = windows.find(w => w.id === this.options.windowId);
367
- if (targetWindow) {
368
- // Start cursor capture with simplified window-relative tracking
369
- this.startCursorCapture(cursorFilePath, {
370
- windowRelative: true,
371
- windowInfo: {
372
- // Use original global window coordinates for reference
373
- x: targetWindow.x,
374
- y: targetWindow.y,
375
- width: targetWindow.width,
376
- height: targetWindow.height,
377
- displayId: this.options.displayId,
378
- // Persist capture area so we can rebuild global offsets reliably
379
- captureArea: this.options.captureArea,
380
- // Keep a snapshot of the window details for debugging/analytics
381
- originalWindow: targetWindow,
382
- // Store display info for multi-display coordinate fixes
383
- targetDisplay: this.recordingDisplayInfo
384
- }
385
- }).catch(cursorError => {
386
- console.warn('Window cursor tracking failed:', cursorError.message);
387
- // Fallback to display recording
388
- this.startCursorCapture(cursorFilePath).catch(fallbackError => {
389
- console.warn('Fallback cursor tracking failed:', fallbackError.message);
390
- });
391
- });
392
- }
393
- }).catch(error => {
394
- console.warn('Could not get window info for cursor tracking:', error.message);
395
- // Fallback to display cursor tracking
396
- this.startCursorCapture(cursorFilePath).catch(cursorError => {
397
- console.warn('Cursor tracking failed to start:', cursorError.message);
398
- });
399
- });
400
- } else {
401
- // For display recording, use display-relative cursor tracking
402
- this.startCursorCapture(cursorFilePath, {
403
- displayRelative: true,
404
- displayInfo: this.recordingDisplayInfo
405
- }).catch(cursorError => {
406
- console.warn('Display cursor tracking failed:', cursorError.message);
407
- });
408
- }
362
+ // Hem window hem display recording için aynı native cursor tracking kullan
363
+ this.startCursorCapture(cursorFilePath).catch(cursorError => {
364
+ console.warn('Cursor tracking failed to start:', cursorError.message);
365
+ });
409
366
 
410
367
  // Timer başlat (progress tracking için)
411
368
  this.recordingTimer = setInterval(() => {
@@ -916,7 +873,34 @@ class MacRecorder extends EventEmitter {
916
873
  /**
917
874
  * Cursor capture durdurur - dosya yazma işlemini sonlandırır
918
875
  */
919
- async stopCursorCapture() {
876
+ stopCursorCapture() {
877
+ if (!this.cursorCaptureInterval) {
878
+ return false;
879
+ }
880
+
881
+ try {
882
+ // Native cursor tracking'i durdur
883
+ const success = nativeBinding.stopCursorTracking();
884
+
885
+ this.cursorCaptureInterval = null;
886
+ this.cursorCaptureFile = null;
887
+ this.cursorCaptureStartTime = null;
888
+
889
+ this.emit("cursorCaptureStopped", {
890
+ timestamp: Date.now()
891
+ });
892
+
893
+ return success;
894
+ } catch (error) {
895
+ console.warn("Error stopping cursor tracking:", error.message);
896
+ return false;
897
+ }
898
+ }
899
+
900
+ /**
901
+ * LEGACY: Eski JS-based cursor capture durdurmak için geriye uyumluluk
902
+ */
903
+ async _legacyStopCursorCapture() {
920
904
  return new Promise((resolve, reject) => {
921
905
  try {
922
906
  if (!this.cursorCaptureInterval) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.17.17",
3
+ "version": "2.17.19",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -601,13 +601,15 @@ CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef eve
601
601
  }
602
602
 
603
603
  // Cursor data oluştur
604
+ // Cursor data oluştur - global koordinat sistemi kullan
604
605
  NSDictionary *cursorInfo = @{
605
606
  @"x": @((int)location.x),
606
607
  @"y": @((int)location.y),
607
608
  @"timestamp": @(timestamp),
608
609
  @"unixTimeMs": @(unixTimeMs),
609
610
  @"cursorType": cursorType,
610
- @"type": eventType
611
+ @"type": eventType,
612
+ @"coordinateSystem": @"global"
611
613
  };
612
614
 
613
615
  // Direkt dosyaya yaz
@@ -651,13 +653,15 @@ void cursorTimerCallback() {
651
653
  NSString *cursorType = getCursorType();
652
654
 
653
655
  // Cursor data oluştur
656
+ // Cursor data oluştur - global koordinat sistemi kullan
654
657
  NSDictionary *cursorInfo = @{
655
658
  @"x": @((int)location.x),
656
659
  @"y": @((int)location.y),
657
660
  @"timestamp": @(timestamp),
658
661
  @"unixTimeMs": @(unixTimeMs),
659
662
  @"cursorType": cursorType,
660
- @"type": @"move"
663
+ @"type": @"move",
664
+ @"coordinateSystem": @"global"
661
665
  };
662
666
 
663
667
  // Direkt dosyaya yaz
@@ -0,0 +1 @@
1
+ [{"x":702,"y":607,"timestamp":119,"unixTimeMs":1758313640997,"cursorType":"text","type":"move","coordinateSystem":"display-relative"}
@@ -0,0 +1 @@
1
+ [{"x":702,"y":607,"timestamp":132,"unixTimeMs":1758313689604,"cursorType":"text","type":"move","coordinateSystem":"display-relative"}
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ const MacRecorder = require('./index.js');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ async function testUnifiedCursorTracking() {
8
+ const recorder = new MacRecorder();
9
+
10
+ console.log('🎯 Testing unified cursor tracking...');
11
+
12
+ // Create test output directory
13
+ const outputDir = './test-output';
14
+ if (!fs.existsSync(outputDir)) {
15
+ fs.mkdirSync(outputDir);
16
+ }
17
+
18
+ const cursorFilePath = path.join(outputDir, `unified-cursor-${Date.now()}.json`);
19
+
20
+ try {
21
+ console.log('Starting native cursor tracking...');
22
+
23
+ // Test native cursor tracking
24
+ const result = await recorder.startCursorCapture(cursorFilePath);
25
+ console.log('✅ Cursor tracking started:', result);
26
+
27
+ console.log('\n🔥 Move your mouse around for 5 seconds...');
28
+
29
+ // Wait 5 seconds
30
+ await new Promise(resolve => setTimeout(resolve, 5000));
31
+
32
+ console.log('\nStopping cursor tracking...');
33
+ const stopped = recorder.stopCursorCapture();
34
+ console.log('✅ Cursor tracking stopped:', stopped);
35
+
36
+ // Wait a bit for file to be written
37
+ await new Promise(resolve => setTimeout(resolve, 1000));
38
+
39
+ // Check if file exists and has content
40
+ if (fs.existsSync(cursorFilePath)) {
41
+ const fileContent = fs.readFileSync(cursorFilePath, 'utf8');
42
+ console.log('📁 File size:', fileContent.length, 'bytes');
43
+
44
+ try {
45
+ const cursorData = JSON.parse(fileContent);
46
+ console.log('📊 Cursor data points:', cursorData.length);
47
+
48
+ if (cursorData.length > 0) {
49
+ console.log('📍 First point:', cursorData[0]);
50
+ console.log('📍 Last point:', cursorData[cursorData.length - 1]);
51
+
52
+ // Check coordinate system
53
+ const coordinateSystems = [...new Set(cursorData.map(p => p.coordinateSystem))];
54
+ console.log('🔧 Coordinate systems used:', coordinateSystems);
55
+ }
56
+ } catch (parseError) {
57
+ console.log('⚠️ File content (first 500 chars):', fileContent.substring(0, 500));
58
+ }
59
+ } else {
60
+ console.log('❌ Output file not found:', cursorFilePath);
61
+ }
62
+
63
+ } catch (error) {
64
+ console.error('❌ Test failed:', error.message);
65
+ }
66
+ }
67
+
68
+ // Run test
69
+ testUnifiedCursorTracking().then(() => {
70
+ console.log('\n✨ Test completed');
71
+ process.exit(0);
72
+ }).catch(error => {
73
+ console.error('💥 Test error:', error);
74
+ process.exit(1);
75
+ });