node-mac-recorder 2.20.9 → 2.20.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.20.9",
3
+ "version": "2.20.10",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -644,36 +644,44 @@ static NSString* detectSystemCursorType(void) {
644
644
  NSString *description = [currentCursor description];
645
645
  NSLog(@"🖱️ Cursor class: %@, description: %@", className ?: @"nil", description ?: @"nil");
646
646
 
647
- // Try to identify cursor by hotspot and size (more reliable than pointer equality)
647
+ // Use more direct cursor detection approach
648
+ NSImage *cursorImage = [currentCursor image];
648
649
  NSPoint hotspot = [currentCursor hotSpot];
649
- NSSize cursorSize = [[currentCursor image] size];
650
+ NSSize imageSize = [cursorImage size];
650
651
 
651
- NSLog(@"🎯 Cursor hotspot: (%.1f, %.1f), size: %.1fx%.1f",
652
- hotspot.x, hotspot.y, cursorSize.width, cursorSize.height);
652
+ NSLog(@"🎯 Cursor analysis: size=%.1fx%.1f, hotspot=(%.1f,%.1f)",
653
+ imageSize.width, imageSize.height, hotspot.x, hotspot.y);
653
654
 
654
- // Common cursor patterns by hotspot (adjusted for modern macOS cursor sizes)
655
- if ((hotspot.x >= 0.0 && hotspot.x <= 3.0) && (hotspot.y >= 0.0 && hotspot.y <= 3.0)) {
656
- // Arrow cursor typically has hotspot at top-left corner
657
- cursorType = @"default";
658
- NSLog(@"🎯 ARROW CURSOR (by hotspot) -> default");
659
- } else if ((hotspot.x >= 12.0 && hotspot.x <= 16.0) && (hotspot.y >= 6.0 && hotspot.y <= 10.0)) {
660
- // I-beam cursor typically has hotspot around middle
655
+ // Updated pattern recognition based on observed values
656
+ if (imageSize.width >= 8.0 && imageSize.width <= 12.0 &&
657
+ imageSize.height >= 16.0 && imageSize.height <= 20.0 &&
658
+ hotspot.x >= 3.0 && hotspot.x <= 5.0 && hotspot.y >= 8.0 && hotspot.y <= 10.0) {
659
+ // I-beam cursor: narrow and tall, hotspot in middle
661
660
  cursorType = @"text";
662
- NSLog(@"🎯 IBEAM CURSOR (by hotspot) -> text");
663
- } else if ((hotspot.x >= 5.0 && hotspot.x <= 10.0) && (hotspot.y >= 0.0 && hotspot.y <= 4.0)) {
664
- // Pointing hand cursor typically has hotspot at finger tip
661
+ NSLog(@"🎯 DETECTED IBEAM CURSOR -> text");
662
+ }
663
+ else if (imageSize.width <= 20.0 && imageSize.height <= 25.0 &&
664
+ hotspot.x <= 5.0 && hotspot.y <= 5.0) {
665
+ // Arrow cursor: small size, hotspot at top-left
666
+ cursorType = @"default";
667
+ NSLog(@"🎯 DETECTED ARROW CURSOR -> default");
668
+ }
669
+ else if (imageSize.width >= 15.0 && imageSize.width <= 25.0 &&
670
+ imageSize.height >= 15.0 && imageSize.height <= 25.0 &&
671
+ hotspot.x >= 5.0 && hotspot.x <= 10.0 && hotspot.y <= 8.0) {
672
+ // Hand cursor: squarish, hotspot at fingertip
665
673
  cursorType = @"pointer";
666
- NSLog(@"🎯 POINTING HAND CURSOR (by hotspot) -> pointer");
667
- } else {
668
- // Fallback to more detailed analysis
669
- NSString *derivedType = cursorTypeFromNSCursor(currentCursor);
670
- if (derivedType && ![derivedType isEqualToString:@"default"]) {
671
- cursorType = derivedType;
672
- NSLog(@"🎯 SYSTEM CURSOR TYPE (derived): %@", cursorType);
674
+ NSLog(@"🎯 DETECTED HAND CURSOR -> pointer");
675
+ }
676
+ else {
677
+ // Try to use a different approach - cursor name introspection
678
+ NSString *derived = cursorTypeFromNSCursor(currentCursor);
679
+ if (derived && ![derived isEqualToString:@"default"]) {
680
+ cursorType = derived;
681
+ NSLog(@"🎯 DERIVED FROM ANALYSIS: %@", cursorType);
673
682
  } else {
674
- // Use accessibility detection if system cursor is generic
675
683
  cursorType = @"default";
676
- NSLog(@"🎯 SYSTEM CURSOR TYPE -> default (will try AX)");
684
+ NSLog(@"🎯 FALLBACK TO DEFAULT (will check AX)");
677
685
  }
678
686
  }
679
687
  } else {
@@ -730,22 +738,32 @@ NSString* getCursorType() {
730
738
 
731
739
  NSString *finalType = @"default";
732
740
 
733
- // System cursor has priority since it's more accurate for visual state
741
+ // Smart decision logic: AX for special cases, system for normal cases
734
742
  NSLog(@"🎯 CURSOR DECISION: system='%@', ax='%@'", systemCursorType ?: @"nil", axCursorType ?: @"nil");
735
743
 
736
- // Use system cursor if available (it's more accurate for visual appearance)
737
- if (systemCursorType && [systemCursorType length] > 0) {
744
+ // If system cursor detected something specific (not default), use it
745
+ if (systemCursorType && [systemCursorType length] > 0 && ![systemCursorType isEqualToString:@"default"]) {
746
+ finalType = systemCursorType;
747
+ NSLog(@"🎯 Using SYSTEM cursor (specific): %@", finalType);
748
+ }
749
+ // If AX detected something specific and system is default, use AX
750
+ else if (axCursorType && [axCursorType length] > 0 && ![axCursorType isEqualToString:@"default"] &&
751
+ (!systemCursorType || [systemCursorType isEqualToString:@"default"])) {
752
+ finalType = axCursorType;
753
+ NSLog(@"🎯 Using AX cursor (specific over default): %@", finalType);
754
+ }
755
+ // Otherwise use system cursor (including default)
756
+ else if (systemCursorType && [systemCursorType length] > 0) {
738
757
  finalType = systemCursorType;
739
758
  NSLog(@"🎯 Using SYSTEM cursor: %@", finalType);
740
759
  }
741
- // Fallback to AX cursor if system cursor is not available
760
+ // Final fallback to AX or default
742
761
  else if (axCursorType && [axCursorType length] > 0) {
743
762
  finalType = axCursorType;
744
- NSLog(@"🎯 Using AX cursor (fallback): %@", finalType);
763
+ NSLog(@"🎯 Using AX cursor (final fallback): %@", finalType);
745
764
  }
746
- // Final fallback
747
765
  else {
748
- NSLog(@"🎯 Fallback to default cursor");
766
+ NSLog(@"🎯 Ultimate fallback to default");
749
767
  }
750
768
 
751
769
  NSLog(@"🎯 FINAL CURSOR TYPE: %@", finalType);