node-mac-recorder 2.18.4 → 2.18.5

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.
@@ -10,7 +10,9 @@
10
10
  "Bash(timeout:*)",
11
11
  "Bash(grep:*)",
12
12
  "Bash(./test-cleanup.sh:*)",
13
- "Bash(FORCE_AVFOUNDATION=1 node test-avfoundation-dpr.js)"
13
+ "Bash(FORCE_AVFOUNDATION=1 node test-avfoundation-dpr.js)",
14
+ "Bash(FORCE_AVFOUNDATION=1 node test-cursor-fix.js)",
15
+ "Bash(pkill:*)"
14
16
  ],
15
17
  "deny": [],
16
18
  "ask": []
package/index.js CHANGED
@@ -705,8 +705,18 @@ class MacRecorder extends EventEmitter {
705
705
  // Calculate video offset based on recording type
706
706
  let videoOffsetX = 0;
707
707
  let videoOffsetY = 0;
708
- let videoWidth = options.displayInfo.width || options.displayInfo.logicalWidth;
709
- let videoHeight = options.displayInfo.height || options.displayInfo.logicalHeight;
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
+ }
710
720
 
711
721
  if (options.recordingType === 'window' && options.windowId) {
712
722
  // For window recording: offset = window position in display
@@ -759,8 +769,13 @@ class MacRecorder extends EventEmitter {
759
769
  scaleFactor: this.recordingDisplayInfo.scaleFactor || 1.0,
760
770
  videoOffsetX: 0,
761
771
  videoOffsetY: 0,
762
- videoWidth: this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth,
763
- videoHeight: this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight,
772
+ // CRITICAL FIX: Use physical dimensions for video when scale factor > 1 (AVFoundation)
773
+ videoWidth: (this.recordingDisplayInfo.scaleFactor > 1.0) ?
774
+ (this.recordingDisplayInfo.physicalWidth || this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth) :
775
+ (this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth),
776
+ videoHeight: (this.recordingDisplayInfo.scaleFactor > 1.0) ?
777
+ (this.recordingDisplayInfo.physicalHeight || this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight) :
778
+ (this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight),
764
779
  videoRelative: true,
765
780
  recordingType: options.recordingType || 'display'
766
781
  };
@@ -812,32 +827,20 @@ class MacRecorder extends EventEmitter {
812
827
  const displayRelativeX = position.x - this.cursorDisplayInfo.displayX;
813
828
  const displayRelativeY = position.y - this.cursorDisplayInfo.displayY;
814
829
 
815
- // CRITICAL FIX: Apply physical scaling for AVFoundation recording
816
- // AVFoundation records at physical resolution while cursor coordinates are logical
817
- let scaledX = displayRelativeX;
818
- let scaledY = displayRelativeY;
819
-
820
- if (this.cursorDisplayInfo.scaleFactor && this.cursorDisplayInfo.scaleFactor > 1.0) {
821
- // Scale logical cursor coordinates to match physical video dimensions
822
- scaledX = displayRelativeX * this.cursorDisplayInfo.scaleFactor;
823
- scaledY = displayRelativeY * this.cursorDisplayInfo.scaleFactor;
824
- coordinateSystem = "video-relative-scaled";
825
- }
826
-
827
830
  // Step 2: Transform display-relative → video-relative coordinates
828
- x = scaledX - this.cursorDisplayInfo.videoOffsetX;
829
- y = scaledY - this.cursorDisplayInfo.videoOffsetY;
830
- coordinateSystem = this.cursorDisplayInfo.scaleFactor > 1.0 ? "video-relative-scaled" : "video-relative";
831
-
832
- // Bounds check for video area (use physical video dimensions for AVFoundation)
833
- const videoWidth = this.cursorDisplayInfo.physicalWidth || this.cursorDisplayInfo.videoWidth;
834
- const videoHeight = this.cursorDisplayInfo.physicalHeight || this.cursorDisplayInfo.videoHeight;
831
+ // videoWidth/Height already account for physical vs logical dimensions
832
+ x = displayRelativeX - this.cursorDisplayInfo.videoOffsetX;
833
+ y = displayRelativeY - this.cursorDisplayInfo.videoOffsetY;
834
+ coordinateSystem = "video-relative";
835
835
 
836
- const outsideVideo = x < 0 || y < 0 || x >= videoWidth || y >= videoHeight;
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;
837
840
 
838
841
  // For debugging - add metadata if cursor is outside video area
839
842
  if (outsideVideo) {
840
- coordinateSystem = coordinateSystem + "-outside";
843
+ coordinateSystem = "video-relative-outside";
841
844
  }
842
845
  }
843
846
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.18.4",
3
+ "version": "2.18.5",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [