node-mac-recorder 2.18.2 → 2.18.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 +57 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -252,6 +252,12 @@ class MacRecorder extends EventEmitter {
|
|
|
252
252
|
|
|
253
253
|
// Recording için display bilgisini sakla (cursor capture için)
|
|
254
254
|
const targetDisplay = displays.find(d => d.id === targetDisplayId);
|
|
255
|
+
|
|
256
|
+
// CRITICAL FIX: Get actual physical dimensions for proper cursor scaling
|
|
257
|
+
// This fixes cursor coordinate issues on Retina displays during AVFoundation recording
|
|
258
|
+
const cursorPosition = nativeBinding.getCursorPosition();
|
|
259
|
+
const displayScalingInfo = cursorPosition.displayInfo;
|
|
260
|
+
|
|
255
261
|
this.recordingDisplayInfo = {
|
|
256
262
|
displayId: targetDisplayId,
|
|
257
263
|
x: targetDisplay.x,
|
|
@@ -261,6 +267,10 @@ class MacRecorder extends EventEmitter {
|
|
|
261
267
|
// Add scaling information for cursor coordinate transformation
|
|
262
268
|
logicalWidth: parseInt(targetDisplay.resolution.split("x")[0]),
|
|
263
269
|
logicalHeight: parseInt(targetDisplay.resolution.split("x")[1]),
|
|
270
|
+
// CRITICAL: Add physical dimensions for proper cursor scaling
|
|
271
|
+
physicalWidth: displayScalingInfo ? displayScalingInfo.physicalWidth : parseInt(targetDisplay.resolution.split("x")[0]),
|
|
272
|
+
physicalHeight: displayScalingInfo ? displayScalingInfo.physicalHeight : parseInt(targetDisplay.resolution.split("x")[1]),
|
|
273
|
+
scaleFactor: displayScalingInfo ? displayScalingInfo.scaleFactor : 1.0,
|
|
264
274
|
};
|
|
265
275
|
}
|
|
266
276
|
|
|
@@ -298,6 +308,11 @@ class MacRecorder extends EventEmitter {
|
|
|
298
308
|
}
|
|
299
309
|
|
|
300
310
|
if (targetDisplay) {
|
|
311
|
+
// CRITICAL FIX: Get actual physical dimensions for proper cursor scaling
|
|
312
|
+
// This fixes cursor coordinate issues on Retina displays during AVFoundation recording
|
|
313
|
+
const cursorPosition = nativeBinding.getCursorPosition();
|
|
314
|
+
const displayScalingInfo = cursorPosition.displayInfo;
|
|
315
|
+
|
|
301
316
|
this.recordingDisplayInfo = {
|
|
302
317
|
displayId: targetDisplay.id,
|
|
303
318
|
x: targetDisplay.x || 0,
|
|
@@ -307,6 +322,10 @@ class MacRecorder extends EventEmitter {
|
|
|
307
322
|
// Add scaling information for cursor coordinate transformation
|
|
308
323
|
logicalWidth: parseInt(targetDisplay.resolution.split("x")[0]),
|
|
309
324
|
logicalHeight: parseInt(targetDisplay.resolution.split("x")[1]),
|
|
325
|
+
// CRITICAL: Add physical dimensions for proper cursor scaling
|
|
326
|
+
physicalWidth: displayScalingInfo ? displayScalingInfo.physicalWidth : parseInt(targetDisplay.resolution.split("x")[0]),
|
|
327
|
+
physicalHeight: displayScalingInfo ? displayScalingInfo.physicalHeight : parseInt(targetDisplay.resolution.split("x")[1]),
|
|
328
|
+
scaleFactor: displayScalingInfo ? displayScalingInfo.scaleFactor : 1.0,
|
|
310
329
|
};
|
|
311
330
|
}
|
|
312
331
|
} catch (error) {
|
|
@@ -712,6 +731,10 @@ class MacRecorder extends EventEmitter {
|
|
|
712
731
|
displayY: options.displayInfo.y || 0,
|
|
713
732
|
displayWidth: options.displayInfo.width || options.displayInfo.logicalWidth,
|
|
714
733
|
displayHeight: options.displayInfo.height || options.displayInfo.logicalHeight,
|
|
734
|
+
// CRITICAL: Add physical dimensions for proper cursor scaling
|
|
735
|
+
physicalWidth: options.displayInfo.physicalWidth || options.displayInfo.width || options.displayInfo.logicalWidth,
|
|
736
|
+
physicalHeight: options.displayInfo.physicalHeight || options.displayInfo.height || options.displayInfo.logicalHeight,
|
|
737
|
+
scaleFactor: options.displayInfo.scaleFactor || 1.0,
|
|
715
738
|
videoOffsetX: videoOffsetX,
|
|
716
739
|
videoOffsetY: videoOffsetY,
|
|
717
740
|
videoWidth: videoWidth,
|
|
@@ -730,6 +753,10 @@ class MacRecorder extends EventEmitter {
|
|
|
730
753
|
displayY: this.recordingDisplayInfo.y || 0,
|
|
731
754
|
displayWidth: this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth,
|
|
732
755
|
displayHeight: this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight,
|
|
756
|
+
// CRITICAL: Include physical dimensions from recording display info
|
|
757
|
+
physicalWidth: this.recordingDisplayInfo.physicalWidth || this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth,
|
|
758
|
+
physicalHeight: this.recordingDisplayInfo.physicalHeight || this.recordingDisplayInfo.height || this.recordingDisplayInfo.logicalHeight,
|
|
759
|
+
scaleFactor: this.recordingDisplayInfo.scaleFactor || 1.0,
|
|
733
760
|
videoOffsetX: 0,
|
|
734
761
|
videoOffsetY: 0,
|
|
735
762
|
videoWidth: this.recordingDisplayInfo.width || this.recordingDisplayInfo.logicalWidth,
|
|
@@ -785,19 +812,32 @@ class MacRecorder extends EventEmitter {
|
|
|
785
812
|
const displayRelativeX = position.x - this.cursorDisplayInfo.displayX;
|
|
786
813
|
const displayRelativeY = position.y - this.cursorDisplayInfo.displayY;
|
|
787
814
|
|
|
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
|
+
|
|
788
827
|
// Step 2: Transform display-relative → video-relative coordinates
|
|
789
|
-
x =
|
|
790
|
-
y =
|
|
791
|
-
coordinateSystem = "video-relative";
|
|
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;
|
|
792
835
|
|
|
793
|
-
|
|
794
|
-
const outsideVideo = x < 0 || y < 0 ||
|
|
795
|
-
x >= this.cursorDisplayInfo.videoWidth ||
|
|
796
|
-
y >= this.cursorDisplayInfo.videoHeight;
|
|
836
|
+
const outsideVideo = x < 0 || y < 0 || x >= videoWidth || y >= videoHeight;
|
|
797
837
|
|
|
798
838
|
// For debugging - add metadata if cursor is outside video area
|
|
799
839
|
if (outsideVideo) {
|
|
800
|
-
coordinateSystem = "
|
|
840
|
+
coordinateSystem = coordinateSystem + "-outside";
|
|
801
841
|
}
|
|
802
842
|
}
|
|
803
843
|
|
|
@@ -815,12 +855,19 @@ class MacRecorder extends EventEmitter {
|
|
|
815
855
|
width: this.cursorDisplayInfo.videoWidth,
|
|
816
856
|
height: this.cursorDisplayInfo.videoHeight,
|
|
817
857
|
offsetX: this.cursorDisplayInfo.videoOffsetX,
|
|
818
|
-
offsetY: this.cursorDisplayInfo.videoOffsetY
|
|
858
|
+
offsetY: this.cursorDisplayInfo.videoOffsetY,
|
|
859
|
+
// CRITICAL: Add physical dimensions for debugging
|
|
860
|
+
physicalWidth: this.cursorDisplayInfo.physicalWidth,
|
|
861
|
+
physicalHeight: this.cursorDisplayInfo.physicalHeight
|
|
819
862
|
} : null,
|
|
820
863
|
displayInfo: this.cursorDisplayInfo ? {
|
|
821
864
|
displayId: this.cursorDisplayInfo.displayId,
|
|
822
865
|
width: this.cursorDisplayInfo.displayWidth,
|
|
823
|
-
height: this.cursorDisplayInfo.displayHeight
|
|
866
|
+
height: this.cursorDisplayInfo.displayHeight,
|
|
867
|
+
// CRITICAL: Add scaling info for debugging AVFoundation cursor issues
|
|
868
|
+
physicalWidth: this.cursorDisplayInfo.physicalWidth,
|
|
869
|
+
physicalHeight: this.cursorDisplayInfo.physicalHeight,
|
|
870
|
+
scaleFactor: this.cursorDisplayInfo.scaleFactor
|
|
824
871
|
} : null
|
|
825
872
|
};
|
|
826
873
|
|