node-mac-recorder 2.17.2 → 2.17.3

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
@@ -376,7 +376,8 @@ class MacRecorder extends EventEmitter {
376
376
  width: targetWindow.width,
377
377
  height: targetWindow.height,
378
378
  displayId: this.options.displayId,
379
- originalWindow: targetWindow
379
+ originalWindow: targetWindow,
380
+ captureArea: this.options.captureArea
380
381
  }
381
382
  }).catch(cursorError => {
382
383
  console.warn('Cursor tracking failed to restart:', cursorError.message);
@@ -393,7 +394,8 @@ class MacRecorder extends EventEmitter {
393
394
  width: targetWindow.width,
394
395
  height: targetWindow.height,
395
396
  displayId: this.options.displayId,
396
- originalWindow: targetWindow
397
+ originalWindow: targetWindow,
398
+ captureArea: this.options.captureArea
397
399
  }
398
400
  }).catch(cursorError => {
399
401
  console.warn('Cursor tracking failed to start:', cursorError.message);
@@ -715,17 +717,31 @@ class MacRecorder extends EventEmitter {
715
717
 
716
718
  // Koordinat sistemi belirle: window-relative, display-relative veya global
717
719
  if (options.windowRelative && options.windowInfo) {
718
- // Window-relative koordinatlar için pencere bilgilerini kullan
719
- // Cursor pozisyonu için Y dönüşümü YAPMA - sadece window offset'ini çıkar
720
- this.cursorDisplayInfo = {
721
- displayId: options.windowInfo.displayId || null,
722
- x: options.windowInfo.x || 0,
723
- y: options.windowInfo.y || 0,
724
- width: options.windowInfo.width,
725
- height: options.windowInfo.height,
726
- windowRelative: true,
727
- windowInfo: options.windowInfo
728
- };
720
+ // Window recording için display'e relative captureArea koordinatlarını kullan
721
+ const captureArea = options.windowInfo.captureArea;
722
+ if (captureArea) {
723
+ // captureArea zaten display-relative koordinatlar
724
+ this.cursorDisplayInfo = {
725
+ displayId: options.windowInfo.displayId || null,
726
+ x: captureArea.x, // Display-relative X
727
+ y: captureArea.y, // Display-relative Y
728
+ width: captureArea.width,
729
+ height: captureArea.height,
730
+ windowRelative: true,
731
+ windowInfo: options.windowInfo
732
+ };
733
+ } else {
734
+ // Fallback: orijinal window koordinatları
735
+ this.cursorDisplayInfo = {
736
+ displayId: options.windowInfo.displayId || null,
737
+ x: options.windowInfo.x || 0,
738
+ y: options.windowInfo.y || 0,
739
+ width: options.windowInfo.width,
740
+ height: options.windowInfo.height,
741
+ windowRelative: true,
742
+ windowInfo: options.windowInfo
743
+ };
744
+ }
729
745
  } else if (this.recordingDisplayInfo) {
730
746
  // Recording başlatılmışsa o display'i kullan
731
747
  this.cursorDisplayInfo = this.recordingDisplayInfo;
@@ -772,9 +788,27 @@ class MacRecorder extends EventEmitter {
772
788
  let coordinateSystem = "global";
773
789
 
774
790
  if (this.cursorDisplayInfo) {
775
- // Offset'leri çıkar (display veya window)
776
- x = position.x - this.cursorDisplayInfo.x;
777
- y = position.y - this.cursorDisplayInfo.y;
791
+ if (this.cursorDisplayInfo.windowRelative) {
792
+ // Window recording: cursor'ı önce target display'e relative yap, sonra captureArea'ya relative yap
793
+ const targetDisplay = this.recordingDisplayInfo;
794
+ if (targetDisplay) {
795
+ // 1. Global -> Display-relative
796
+ const displayRelativeX = position.x - targetDisplay.x;
797
+ const displayRelativeY = position.y - targetDisplay.y;
798
+
799
+ // 2. Display-relative -> CaptureArea-relative (window-relative)
800
+ x = displayRelativeX - this.cursorDisplayInfo.x;
801
+ y = displayRelativeY - this.cursorDisplayInfo.y;
802
+ } else {
803
+ // Fallback: doğrudan offset çıkar
804
+ x = position.x - this.cursorDisplayInfo.x;
805
+ y = position.y - this.cursorDisplayInfo.y;
806
+ }
807
+ } else {
808
+ // Display recording: doğrudan offset çıkar
809
+ x = position.x - this.cursorDisplayInfo.x;
810
+ y = position.y - this.cursorDisplayInfo.y;
811
+ }
778
812
 
779
813
  if (this.cursorDisplayInfo.windowRelative) {
780
814
  // Window-relative koordinatlar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.17.2",
3
+ "version": "2.17.3",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -70,16 +70,69 @@ NSString* getCursorType() {
70
70
  (hotSpot.x >= 12 && hotSpot.x <= 14 && hotSpot.y >= 7 && hotSpot.y <= 9)) {
71
71
  return @"pointer";
72
72
  } else if ([currentCursor isEqual:[NSCursor IBeamCursor]] ||
73
- (hotSpot.x >= 3 && hotSpot.x <= 5 && hotSpot.y >= 8 && hotSpot.y <= 10 &&
73
+ (hotSpot.x >= 3 && hotSpot.x <= 5 && hotSpot.y >= 8 && hotSpot.y <= 10 &&
74
74
  imageSize.width <= 10 && imageSize.height >= 16)) {
75
75
  return @"text";
76
76
  } else if ([currentCursor isEqual:[NSCursor resizeLeftRightCursor]]) {
77
- return @"ew-resize";
77
+ return @"col-resize";
78
78
  } else if ([currentCursor isEqual:[NSCursor resizeUpDownCursor]]) {
79
- return @"ns-resize";
80
- } else if ([currentCursor isEqual:[NSCursor openHandCursor]] ||
81
- [currentCursor isEqual:[NSCursor closedHandCursor]]) {
79
+ return @"row-resize";
80
+ } else if ([currentCursor isEqual:[NSCursor openHandCursor]]) {
81
+ return @"grab";
82
+ } else if ([currentCursor isEqual:[NSCursor closedHandCursor]]) {
82
83
  return @"grabbing";
84
+ } else if ([currentCursor isEqual:[NSCursor crosshairCursor]]) {
85
+ return @"crosshair";
86
+ } else if ([currentCursor isEqual:[NSCursor disappearingItemCursor]]) {
87
+ return @"alias";
88
+ } else if ([currentCursor isEqual:[NSCursor dragCopyCursor]]) {
89
+ return @"copy";
90
+ } else if ([currentCursor isEqual:[NSCursor operationNotAllowedCursor]]) {
91
+ return @"not-allowed";
92
+ } else if ([currentCursor isEqual:[NSCursor contextualMenuCursor]]) {
93
+ return @"help";
94
+ }
95
+
96
+ // Additional cursor type detection by image characteristics
97
+ if (imageSize.width > 0 && imageSize.height > 0) {
98
+ // Progress cursor (spinning wheel or hourglass)
99
+ if (imageSize.width >= 16 && imageSize.height >= 16 &&
100
+ imageSize.width <= 32 && imageSize.height <= 32 &&
101
+ hotSpot.x >= imageSize.width/2 - 4 && hotSpot.x <= imageSize.width/2 + 4 &&
102
+ hotSpot.y >= imageSize.height/2 - 4 && hotSpot.y <= imageSize.height/2 + 4) {
103
+ return @"progress";
104
+ }
105
+
106
+ // Zoom cursors (magnifying glass)
107
+ if ((imageSize.width >= 20 && imageSize.width <= 28) &&
108
+ (imageSize.height >= 20 && imageSize.height <= 28)) {
109
+ // Try to differentiate zoom-in vs zoom-out by hotspot position
110
+ if (hotSpot.x < imageSize.width/2) {
111
+ return @"zoom-out";
112
+ } else {
113
+ return @"zoom-in";
114
+ }
115
+ }
116
+
117
+ // All-scroll cursor (four arrows)
118
+ if (imageSize.width >= 16 && imageSize.height >= 16 &&
119
+ hotSpot.x >= imageSize.width/2 - 2 && hotSpot.x <= imageSize.width/2 + 2 &&
120
+ hotSpot.y >= imageSize.height/2 - 2 && hotSpot.y <= imageSize.height/2 + 2) {
121
+ return @"all-scroll";
122
+ }
123
+
124
+ // Diagonal resize cursors
125
+ if (imageSize.width >= 14 && imageSize.width <= 20 &&
126
+ imageSize.height >= 14 && imageSize.height <= 20) {
127
+ // NW-SE resize (top-left to bottom-right)
128
+ if (hotSpot.x >= 7 && hotSpot.x <= 13 && hotSpot.y >= 7 && hotSpot.y <= 13) {
129
+ return @"nwse-resize";
130
+ }
131
+ // NE-SW resize (top-right to bottom-left)
132
+ if (hotSpot.x >= 7 && hotSpot.x <= 13 && hotSpot.y >= 7 && hotSpot.y <= 13) {
133
+ return @"nesw-resize";
134
+ }
135
+ }
83
136
  }
84
137
 
85
138
  // Check if we're in a drag operation