node-mac-recorder 2.16.17 โ†’ 2.16.18

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "permissions": {
3
3
  "allow": [
4
- "Bash(FORCE_AVFOUNDATION=1 node -e \"\nconsole.log(''๐Ÿงช Testing per-screen window selector overlay system...'');\nconst WindowSelector = require(''./window-selector.js'');\nconst selector = new WindowSelector();\n\n// Test permission check first\nselector.checkPermissions().then(perms => {\n console.log(''Permissions:'', perms);\n \n // Start window selection to test per-screen overlays\n return selector.startSelection();\n}).then(() => {\n console.log(''โœ… Window selection started - testing per-screen overlays'');\n console.log(''โžก๏ธ Move cursor over windows on different displays to test overlay positioning'');\n \n // Auto-stop after 10 seconds for testing\n setTimeout(() => {\n selector.stopSelection().then(() => {\n console.log(''โœ… Window selection stopped - test complete'');\n });\n }, 10000);\n}).catch(console.error);\n\")"
4
+ "Bash(FORCE_AVFOUNDATION=1 node -e \"\nconsole.log(''๐Ÿงช Testing integrated overlay UI elements...'');\nconst WindowSelector = require(''./window-selector.js'');\nconst selector = new WindowSelector();\n\n// Test permission check first\nselector.checkPermissions().then(perms => {\n console.log(''Permissions:'', perms);\n \n // Start window selection to test integrated overlay elements\n return selector.startSelection();\n}).then(() => {\n console.log(''โœ… Window selection started - UI elements should be integrated into overlay'');\n console.log(''โžก๏ธ Move cursor over windows to test integrated button, logo, and title'');\n \n // Auto-stop after 15 seconds for testing\n setTimeout(() => {\n selector.stopSelection().then(() => {\n console.log(''โœ… Window selection stopped - test complete'');\n });\n }, 15000);\n}).catch(console.error);\n\")"
5
5
  ],
6
6
  "deny": [],
7
7
  "ask": []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mac-recorder",
3
- "version": "2.16.17",
3
+ "version": "2.16.18",
4
4
  "description": "Native macOS screen recording package for Node.js applications",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -21,6 +21,10 @@ static NSMutableArray *g_perScreenOverlays = nil;
21
21
  static NSMutableArray *g_perScreenOverlayViews = nil;
22
22
  static NSInteger g_activeScreenIndex = -1;
23
23
 
24
+ // Forward declaration for delegate
25
+ @class WindowSelectorDelegate;
26
+ static WindowSelectorDelegate *g_delegate = nil;
27
+
24
28
  // Functions to hide/show main overlay window during recording
25
29
  void hideAllOverlayWindows() {
26
30
  if (g_overlayWindow && [g_overlayWindow isVisible]) {
@@ -73,6 +77,9 @@ bool showScreenRecordingPreview(NSDictionary *screenInfo);
73
77
  bool hideScreenRecordingPreview();
74
78
  void updateScreenOverlays();
75
79
 
80
+ // Forward declarations
81
+ @class HoverButton;
82
+
76
83
  // Custom overlay view class
77
84
  @interface WindowSelectorOverlayView : NSView
78
85
  @property (nonatomic, strong) NSDictionary *windowInfo;
@@ -80,7 +87,13 @@ void updateScreenOverlays();
80
87
  @property (nonatomic) BOOL isToggled;
81
88
  @property (nonatomic) NSRect highlightFrame;
82
89
  @property (nonatomic, strong) NSValue *globalOriginOffset; // Store global coordinate offset
90
+ @property (nonatomic, strong) HoverButton *recordButton;
91
+ @property (nonatomic, strong) NSImageView *appIconView;
92
+ @property (nonatomic, strong) NSTextField *infoLabel;
83
93
  - (void)setHighlightFrame:(NSRect)frame;
94
+ - (void)setupUIElements;
95
+ - (void)updateUIElements;
96
+ - (void)positionUIElements;
84
97
  @end
85
98
 
86
99
  // Custom button with hover effects
@@ -115,15 +128,14 @@ void updateScreenOverlays();
115
128
  // Disable focus ring completely
116
129
  [self setFocusRingType:NSFocusRingTypeNone];
117
130
 
118
- // Window selector overlay view created
131
+ // Setup UI elements (button, icon, label)
132
+ [self setupUIElements];
133
+
134
+ NSLog(@"๐ŸŽฏ WindowSelectorOverlayView created with UI elements integrated");
119
135
  }
120
136
  return self;
121
137
  }
122
138
 
123
- - (void)setHighlightFrame:(NSRect)frame {
124
- _highlightFrame = frame;
125
- [self setNeedsDisplay:YES]; // Trigger redraw
126
- }
127
139
 
128
140
  - (void)drawRect:(NSRect)dirtyRect {
129
141
  [super drawRect:dirtyRect];
@@ -218,6 +230,147 @@ void updateScreenOverlays();
218
230
  NSLog(@"๐ŸŽฏ Global toggle state: %s", g_hasToggledWindow ? "HAS_TOGGLED" : "NO_TOGGLE");
219
231
  }
220
232
 
233
+ - (void)setupUIElements {
234
+ NSLog(@"๐Ÿ”ง Setting up integrated UI elements");
235
+
236
+ // Create record button
237
+ self.recordButton = [[HoverButton alloc] initWithFrame:NSMakeRect(0, 0, 200, 60)];
238
+ [self.recordButton setTitle:@"Start Recording"];
239
+ [self.recordButton setFont:[NSFont systemFontOfSize:18.0 weight:NSFontWeightMedium]];
240
+ [self.recordButton setBezelStyle:NSBezelStyleRounded];
241
+ [self.recordButton setTarget:g_delegate];
242
+ [self.recordButton setAction:@selector(selectButtonClicked:)];
243
+
244
+ // Style the button
245
+ self.recordButton.wantsLayer = YES;
246
+ self.recordButton.layer.backgroundColor = [[NSColor colorWithRed:0.2 green:0.6 blue:1.0 alpha:0.9] CGColor];
247
+ self.recordButton.layer.cornerRadius = 8.0;
248
+ self.recordButton.layer.borderWidth = 0.0;
249
+
250
+ [self addSubview:self.recordButton];
251
+
252
+ // Create app icon view
253
+ self.appIconView = [[NSImageView alloc] initWithFrame:NSMakeRect(0, 0, 96, 96)];
254
+ [self.appIconView setImageScaling:NSImageScaleProportionallyUpOrDown];
255
+ [self.appIconView setWantsLayer:YES];
256
+ [self.appIconView.layer setCornerRadius:8.0];
257
+ [self.appIconView.layer setMasksToBounds:YES];
258
+ [self addSubview:self.appIconView];
259
+
260
+ // Create info label
261
+ self.infoLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 400, 60)];
262
+ [self.infoLabel setEditable:NO];
263
+ [self.infoLabel setSelectable:NO];
264
+ [self.infoLabel setBezeled:NO];
265
+ [self.infoLabel setDrawsBackground:NO];
266
+ [self.infoLabel setAlignment:NSTextAlignmentCenter];
267
+ [self.infoLabel setFont:[NSFont systemFontOfSize:23.4 weight:NSFontWeightMedium]];
268
+ [self.infoLabel setTextColor:[NSColor whiteColor]];
269
+ [self addSubview:self.infoLabel];
270
+
271
+ NSLog(@"โœ… UI elements created and added to overlay view");
272
+ }
273
+
274
+ - (void)updateUIElements {
275
+ if (!self.windowInfo) return;
276
+
277
+ NSLog(@"๐Ÿ”„ Updating UI elements for window: %@", [self.windowInfo objectForKey:@"title"]);
278
+
279
+ // Update info label
280
+ NSString *windowTitle = [self.windowInfo objectForKey:@"title"] ?: @"Unknown Window";
281
+ NSString *appName = [self.windowInfo objectForKey:@"appName"] ?: @"Unknown App";
282
+ [self.infoLabel setStringValue:[NSString stringWithFormat:@"%@\n%@", appName, windowTitle]];
283
+
284
+ // Update app icon
285
+ NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
286
+ NSArray *runningApps = [workspace runningApplications];
287
+ NSImage *appIcon = nil;
288
+
289
+ for (NSRunningApplication *app in runningApps) {
290
+ if ([[app localizedName] isEqualToString:appName] || [[app bundleIdentifier] containsString:appName]) {
291
+ appIcon = [app icon];
292
+ break;
293
+ }
294
+ }
295
+
296
+ if (!appIcon) {
297
+ appIcon = [workspace iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)];
298
+ }
299
+
300
+ [self.appIconView setImage:appIcon];
301
+
302
+ // Position elements
303
+ [self positionUIElements];
304
+ }
305
+
306
+ - (void)positionUIElements {
307
+ if (NSEqualRects(self.highlightFrame, NSZeroRect)) {
308
+ // Hide elements when no window is highlighted
309
+ [self.recordButton setHidden:YES];
310
+ [self.appIconView setHidden:YES];
311
+ [self.infoLabel setHidden:YES];
312
+ return;
313
+ }
314
+
315
+ // Show elements
316
+ [self.recordButton setHidden:NO];
317
+ [self.appIconView setHidden:NO];
318
+ [self.infoLabel setHidden:NO];
319
+
320
+ // Calculate window center
321
+ CGFloat windowCenterX = self.highlightFrame.origin.x + (self.highlightFrame.size.width / 2);
322
+ CGFloat windowCenterY = self.highlightFrame.origin.y + (self.highlightFrame.size.height / 2);
323
+
324
+ // Position record button at window center
325
+ NSSize buttonSize = self.recordButton.frame.size;
326
+ [self.recordButton setFrameOrigin:NSMakePoint(
327
+ windowCenterX - (buttonSize.width / 2),
328
+ windowCenterY - (buttonSize.height / 2)
329
+ )];
330
+
331
+ // Position app icon above window center
332
+ [self.appIconView setFrameOrigin:NSMakePoint(
333
+ windowCenterX - 48, // Center horizontally (96/2 = 48)
334
+ windowCenterY + 120 // 120px above window center
335
+ )];
336
+
337
+ // Add floating animation to app icon
338
+ [self.appIconView.layer removeAnimationForKey:@"floatAnimationX"];
339
+ CABasicAnimation *floatAnimationX = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
340
+ floatAnimationX.fromValue = @(-4.0);
341
+ floatAnimationX.toValue = @(4.0);
342
+ floatAnimationX.duration = 1.0;
343
+ floatAnimationX.repeatCount = HUGE_VALF;
344
+ floatAnimationX.autoreverses = YES;
345
+ floatAnimationX.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
346
+ [self.appIconView.layer addAnimation:floatAnimationX forKey:@"floatAnimationX"];
347
+
348
+ // Position info label between icon and button
349
+ NSSize labelSize = self.infoLabel.frame.size;
350
+ [self.infoLabel setFrameOrigin:NSMakePoint(
351
+ windowCenterX - (labelSize.width / 2),
352
+ windowCenterY + 50 // 50px above window center
353
+ )];
354
+
355
+ NSLog(@"๐Ÿ“ UI elements positioned - Button:(%.0f,%.0f) Icon:(%.0f,%.0f) Label:(%.0f,%.0f)",
356
+ self.recordButton.frame.origin.x, self.recordButton.frame.origin.y,
357
+ self.appIconView.frame.origin.x, self.appIconView.frame.origin.y,
358
+ self.infoLabel.frame.origin.x, self.infoLabel.frame.origin.y);
359
+ }
360
+
361
+ // Override setHighlightFrame to trigger UI updates
362
+ - (void)setHighlightFrame:(NSRect)frame {
363
+ _highlightFrame = frame;
364
+ [self positionUIElements]; // Position UI elements when highlight changes
365
+ [self setNeedsDisplay:YES]; // Trigger redraw
366
+ }
367
+
368
+ // Override setWindowInfo to trigger UI updates
369
+ - (void)setWindowInfo:(NSDictionary *)windowInfo {
370
+ _windowInfo = windowInfo;
371
+ [self updateUIElements]; // Update UI elements when window info changes
372
+ }
373
+
221
374
  // Layer-based approach, no custom drawing needed
222
375
 
223
376
  @end
@@ -513,8 +666,6 @@ void updateScreenOverlays();
513
666
  }
514
667
  @end
515
668
 
516
- static WindowSelectorDelegate *g_delegate = nil;
517
-
518
669
  // Bring window to front using Accessibility API
519
670
  bool bringWindowToFront(int windowId) {
520
671
  @autoreleasepool {
@@ -926,191 +1077,19 @@ void updateOverlay() {
926
1077
 
927
1078
  // Only reset toggle state when switching to different window (not for position updates)
928
1079
  if (!g_hasToggledWindow) {
929
- [(WindowSelectorOverlayView *)g_overlayView setIsToggled:NO];
1080
+ [targetOverlayView setIsToggled:NO];
930
1081
  } else {
931
1082
  // Keep toggle state for locked window
932
- [(WindowSelectorOverlayView *)g_overlayView setIsToggled:YES];
933
- }
934
-
935
- // Add/update info label above button
936
- NSTextField *infoLabel = nil;
937
- for (NSView *subview in [g_overlayWindow.contentView subviews]) {
938
- if ([subview isKindOfClass:[NSTextField class]]) {
939
- infoLabel = (NSTextField*)subview;
940
- break;
941
- }
942
- }
943
-
944
- if (!infoLabel) {
945
- infoLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, width - 40, 60)];
946
- [infoLabel setEditable:NO];
947
- [infoLabel setSelectable:NO];
948
- [infoLabel setBezeled:NO];
949
- [infoLabel setDrawsBackground:NO];
950
- [infoLabel setAlignment:NSTextAlignmentCenter];
951
- [infoLabel setFont:[NSFont systemFontOfSize:23.4 weight:NSFontWeightMedium]]; // 18 * 1.3 = 23.4
952
- [infoLabel setTextColor:[NSColor whiteColor]];
953
-
954
- // Force no borders on info label
955
- [infoLabel setWantsLayer:YES];
956
- infoLabel.layer.borderWidth = 1.0;
957
- infoLabel.layer.borderColor = [[NSColor clearColor] CGColor];
958
- infoLabel.layer.cornerRadius = 0.0;
959
- infoLabel.layer.masksToBounds = YES;
960
-
961
- [g_overlayWindow.contentView addSubview:infoLabel];
962
- }
963
-
964
- // Add/update app icon
965
- NSImageView *appIconView = nil;
966
- for (NSView *subview in [g_overlayWindow.contentView subviews]) {
967
- if ([subview isKindOfClass:[NSImageView class]]) {
968
- appIconView = (NSImageView*)subview;
969
- break;
970
- }
971
- }
972
-
973
- if (!appIconView) {
974
- appIconView = [[NSImageView alloc] initWithFrame:NSMakeRect(0, 0, 96, 96)];
975
- [appIconView setImageScaling:NSImageScaleProportionallyUpOrDown];
976
- [appIconView setWantsLayer:YES];
977
- [appIconView.layer setCornerRadius:8.0];
978
- [appIconView.layer setMasksToBounds:YES];
979
- [appIconView.layer setBackgroundColor:[[NSColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.3] CGColor]]; // Debug background
980
-
981
- // Force no borders on app icon view
982
- appIconView.layer.borderWidth = 1.0;
983
- appIconView.layer.borderColor = [[NSColor clearColor] CGColor];
984
- appIconView.layer.shadowOpacity = 0.0;
985
- appIconView.layer.shadowRadius = 0.0;
986
- appIconView.layer.shadowOffset = NSMakeSize(0, 0);
987
-
988
- [g_overlayWindow.contentView addSubview:appIconView];
989
- NSLog(@"๐Ÿ–ผ๏ธ Created app icon view at frame: (%.0f, %.0f, %.0f, %.0f)",
990
- appIconView.frame.origin.x, appIconView.frame.origin.y,
991
- appIconView.frame.size.width, appIconView.frame.size.height);
992
- }
993
-
994
- // Get app icon using NSWorkspace
995
- NSString *iconAppName = [windowUnderCursor objectForKey:@"appName"] ?: @"Unknown";
996
- NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
997
- NSArray *runningApps = [workspace runningApplications];
998
- NSImage *appIcon = nil;
999
-
1000
- for (NSRunningApplication *app in runningApps) {
1001
- if ([[app localizedName] isEqualToString:iconAppName] || [[app bundleIdentifier] containsString:iconAppName]) {
1002
- appIcon = [app icon];
1003
- break;
1004
- }
1005
- }
1006
-
1007
- // Fallback to generic app icon if not found
1008
- if (!appIcon) {
1009
- appIcon = [workspace iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)];
1010
- NSLog(@"โš ๏ธ Using fallback icon for app: %@", iconAppName);
1011
- } else {
1012
- NSLog(@"โœ… Found app icon for: %@", iconAppName);
1013
- }
1014
-
1015
- [appIconView setImage:appIcon];
1016
- NSLog(@"๐Ÿ–ผ๏ธ Set icon image, size: %.0fx%.0f", [appIcon size].width, [appIcon size].height);
1017
-
1018
- // Update label text
1019
- NSString *labelWindowTitle = [windowUnderCursor objectForKey:@"title"] ?: @"Unknown Window";
1020
- NSString *labelAppName = [windowUnderCursor objectForKey:@"appName"] ?: @"Unknown App";
1021
- [infoLabel setStringValue:[NSString stringWithFormat:@"%@\n%@", labelAppName, labelWindowTitle]];
1022
-
1023
- // Position buttons - Start Record in center of selected window
1024
- if (g_selectButton) {
1025
- NSSize buttonSize = [g_selectButton frame].size;
1026
- // Use local window center for positioning
1027
- CGFloat localWindowCenterX = localX + (width / 2);
1028
- CGFloat localWindowCenterY = localY + (height / 2);
1029
- NSPoint buttonCenter = NSMakePoint(
1030
- localWindowCenterX - (buttonSize.width / 2),
1031
- localWindowCenterY - (buttonSize.height / 2) // Perfect center of window
1032
- );
1033
-
1034
- NSLog(@" ButtonCalc: WindowCenter(%.0f, %.0f) -> Button(%.0f, %.0f)",
1035
- localWindowCenterX, localWindowCenterY, buttonCenter.x, buttonCenter.y);
1036
-
1037
- [g_selectButton setFrameOrigin:buttonCenter];
1038
-
1039
- // Position app icon above window center
1040
- NSPoint iconCenter = NSMakePoint(
1041
- localWindowCenterX - (96 / 2), // Center horizontally on window
1042
- localWindowCenterY + 120 // 120px above window center
1043
- );
1044
- [appIconView setFrameOrigin:iconCenter];
1045
- NSLog(@"๐ŸŽฏ Positioning app icon at: (%.0f, %.0f) for window size: (%.0f, %.0f)",
1046
- iconCenter.x, iconCenter.y, (float)width, (float)height);
1047
-
1048
- // Add fast horizontal floating animation after positioning
1049
- [appIconView.layer removeAnimationForKey:@"floatAnimationX"];
1050
- [appIconView.layer removeAnimationForKey:@"floatAnimationY"];
1051
-
1052
- // Faster horizontal float animation only
1053
- CABasicAnimation *floatAnimationX = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
1054
- floatAnimationX.fromValue = @(-4.0);
1055
- floatAnimationX.toValue = @(4.0);
1056
- floatAnimationX.duration = 1.0; // Much faster animation
1057
- floatAnimationX.repeatCount = HUGE_VALF;
1058
- floatAnimationX.autoreverses = YES;
1059
- floatAnimationX.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
1060
- [appIconView.layer addAnimation:floatAnimationX forKey:@"floatAnimationX"];
1061
-
1062
- // Position info label between icon and button relative to window center
1063
- NSPoint labelCenter = NSMakePoint(
1064
- localWindowCenterX - ([infoLabel frame].size.width / 2), // Center horizontally on window
1065
- localWindowCenterY + 50 // 50px above window center, below icon
1066
- );
1067
- [infoLabel setFrameOrigin:labelCenter];
1068
-
1069
- // Position cancel button below the main button
1070
- NSButton *cancelButton = nil;
1071
- for (NSView *subview in [g_overlayWindow.contentView subviews]) {
1072
- if ([subview isKindOfClass:[NSButton class]] &&
1073
- [[(NSButton*)subview title] isEqualToString:@"Cancel"]) {
1074
- cancelButton = (NSButton*)subview;
1075
- break;
1076
- }
1077
- }
1078
-
1079
- if (cancelButton) {
1080
- NSSize cancelButtonSize = [cancelButton frame].size;
1081
- NSPoint cancelButtonCenter = NSMakePoint(
1082
- localWindowCenterX - (cancelButtonSize.width / 2), // Center horizontally on window
1083
- localWindowCenterY - 80 // 80px below window center
1084
- );
1085
- [cancelButton setFrameOrigin:cancelButtonCenter];
1086
- }
1083
+ [targetOverlayView setIsToggled:YES];
1087
1084
  }
1088
1085
 
1089
- [g_overlayWindow orderFront:nil];
1090
- // DON'T make key - prevents focus ring
1091
- // [g_overlayWindow makeKeyAndOrderFront:nil];
1086
+ NSLog(@"โœ… Updated overlay view with integrated UI elements");
1092
1087
 
1093
- // Ensure subviews (except overlay view itself) have no borders after positioning
1094
- for (NSView *subview in [g_overlayWindow.contentView subviews]) {
1095
- // Skip the main overlay view - it handles its own borders
1096
- if ([subview isKindOfClass:[WindowSelectorOverlayView class]]) continue;
1097
-
1098
- if ([subview respondsToSelector:@selector(setWantsLayer:)]) {
1099
- [subview setWantsLayer:YES];
1100
- if (subview.layer) {
1101
- subview.layer.borderWidth = 1.0;
1102
- subview.layer.borderColor = [[NSColor clearColor] CGColor];
1103
- subview.layer.masksToBounds = YES;
1104
- subview.layer.shadowOpacity = 0.0;
1105
- subview.layer.shadowRadius = 0.0;
1106
- subview.layer.shadowOffset = NSMakeSize(0, 0);
1107
- }
1108
- }
1109
- }
1088
+ [targetOverlay orderFront:nil];
1110
1089
 
1111
- NSLog(@" โœ… Overlay Status: Level=%ld, Alpha=%.1f, Visible=%s, Frame Set=YES",
1112
- [g_overlayWindow level], [g_overlayWindow alphaValue],
1113
- [g_overlayWindow isVisible] ? "YES" : "NO");
1090
+ NSLog(@" โœ… Overlay Status: Level=%ld, Alpha=%.1f, Visible=%s",
1091
+ [targetOverlay level], [targetOverlay alphaValue],
1092
+ [targetOverlay isVisible] ? "YES" : "NO");
1114
1093
  } else if (!windowUnderCursor && g_currentWindowUnderCursor) {
1115
1094
  // No window under cursor and no toggle active, hide overlay
1116
1095
  NSString *leftWindowTitle = [g_currentWindowUnderCursor objectForKey:@"title"] ?: @"Untitled";