node-mac-recorder 2.18.5 → 2.18.6

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.
Files changed (2) hide show
  1. package/index.js +36 -22
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -705,18 +705,10 @@ class MacRecorder extends EventEmitter {
705
705
  // Calculate video offset based on recording type
706
706
  let videoOffsetX = 0;
707
707
  let videoOffsetY = 0;
708
- // CRITICAL FIX: Use physical dimensions for video when scale factor > 1 (AVFoundation)
709
- // AVFoundation records at physical resolution, ScreenCaptureKit at logical resolution
710
- let videoWidth, videoHeight;
711
- if (options.displayInfo.scaleFactor && options.displayInfo.scaleFactor > 1.0) {
712
- // AVFoundation case: use physical dimensions to match actual video size
713
- videoWidth = options.displayInfo.physicalWidth || options.displayInfo.width || options.displayInfo.logicalWidth;
714
- videoHeight = options.displayInfo.physicalHeight || options.displayInfo.height || options.displayInfo.logicalHeight;
715
- } else {
716
- // ScreenCaptureKit case: use logical dimensions
717
- videoWidth = options.displayInfo.width || options.displayInfo.logicalWidth;
718
- videoHeight = options.displayInfo.height || options.displayInfo.logicalHeight;
719
- }
708
+ // UNIFIED CURSOR SYSTEM: Always use logical dimensions for cursor coordinates
709
+ // This ensures cursor tracking works consistently across all recording engines
710
+ let videoWidth = options.displayInfo.width || options.displayInfo.logicalWidth;
711
+ let videoHeight = options.displayInfo.height || options.displayInfo.logicalHeight;
720
712
 
721
713
  if (options.recordingType === 'window' && options.windowId) {
722
714
  // For window recording: offset = window position in display
@@ -749,6 +741,11 @@ class MacRecorder extends EventEmitter {
749
741
  videoOffsetY: videoOffsetY,
750
742
  videoWidth: videoWidth,
751
743
  videoHeight: videoHeight,
744
+ // CRITICAL: Video output size for proper cursor scaling
745
+ videoOutputWidth: (options.displayInfo.scaleFactor > 1.0) ?
746
+ (options.displayInfo.physicalWidth || videoWidth) : videoWidth,
747
+ videoOutputHeight: (options.displayInfo.scaleFactor > 1.0) ?
748
+ (options.displayInfo.physicalHeight || videoHeight) : videoHeight,
752
749
  videoRelative: true,
753
750
  recordingType: options.recordingType || 'display',
754
751
  // Store additional context for debugging
@@ -769,11 +766,14 @@ class MacRecorder extends EventEmitter {
769
766
  scaleFactor: this.recordingDisplayInfo.scaleFactor || 1.0,
770
767
  videoOffsetX: 0,
771
768
  videoOffsetY: 0,
772
- // CRITICAL FIX: Use physical dimensions for video when scale factor > 1 (AVFoundation)
773
- videoWidth: (this.recordingDisplayInfo.scaleFactor > 1.0) ?
769
+ // UNIFIED CURSOR SYSTEM: Always use logical dimensions
770
+ videoWidth: this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth,
771
+ videoHeight: this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight,
772
+ // CRITICAL: Video output size for proper cursor scaling
773
+ videoOutputWidth: (this.recordingDisplayInfo.scaleFactor > 1.0) ?
774
774
  (this.recordingDisplayInfo.physicalWidth || this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth) :
775
775
  (this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth),
776
- videoHeight: (this.recordingDisplayInfo.scaleFactor > 1.0) ?
776
+ videoOutputHeight: (this.recordingDisplayInfo.scaleFactor > 1.0) ?
777
777
  (this.recordingDisplayInfo.physicalHeight || this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight) :
778
778
  (this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight),
779
779
  videoRelative: true,
@@ -828,19 +828,33 @@ class MacRecorder extends EventEmitter {
828
828
  const displayRelativeY = position.y - this.cursorDisplayInfo.displayY;
829
829
 
830
830
  // Step 2: Transform display-relative → video-relative coordinates
831
- // videoWidth/Height already account for physical vs logical dimensions
832
831
  x = displayRelativeX - this.cursorDisplayInfo.videoOffsetX;
833
832
  y = displayRelativeY - this.cursorDisplayInfo.videoOffsetY;
834
- coordinateSystem = "video-relative";
835
833
 
836
- // Bounds check for video area using correct video dimensions
837
- const outsideVideo = x < 0 || y < 0 ||
838
- x >= this.cursorDisplayInfo.videoWidth ||
839
- y >= this.cursorDisplayInfo.videoHeight;
834
+ // Step 3: Scale to match actual video output size (for AVFoundation physical scaling)
835
+ if (this.cursorDisplayInfo.videoOutputWidth && this.cursorDisplayInfo.videoOutputHeight) {
836
+ const scaleX = this.cursorDisplayInfo.videoOutputWidth / this.cursorDisplayInfo.videoWidth;
837
+ const scaleY = this.cursorDisplayInfo.videoOutputHeight / this.cursorDisplayInfo.videoHeight;
838
+
839
+ if (scaleX !== 1.0 || scaleY !== 1.0) {
840
+ x = x * scaleX;
841
+ y = y * scaleY;
842
+ coordinateSystem = "video-output-scaled";
843
+ } else {
844
+ coordinateSystem = "video-relative";
845
+ }
846
+ } else {
847
+ coordinateSystem = "video-relative";
848
+ }
849
+
850
+ // Bounds check for video area using actual video output dimensions
851
+ const checkWidth = this.cursorDisplayInfo.videoOutputWidth || this.cursorDisplayInfo.videoWidth;
852
+ const checkHeight = this.cursorDisplayInfo.videoOutputHeight || this.cursorDisplayInfo.videoHeight;
853
+ const outsideVideo = x < 0 || y < 0 || x >= checkWidth || y >= checkHeight;
840
854
 
841
855
  // For debugging - add metadata if cursor is outside video area
842
856
  if (outsideVideo) {
843
- coordinateSystem = "video-relative-outside";
857
+ coordinateSystem = coordinateSystem + "-outside";
844
858
  }
845
859
  }
846
860
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.18.5",
3
+ "version": "2.18.6",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [