react-native-macos 0.79.1 → 0.79.4

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.
@@ -16,6 +16,6 @@ export const version: $ReadOnly<{
16
16
  }> = {
17
17
  major: 0,
18
18
  minor: 79,
19
- patch: 1,
19
+ patch: 4,
20
20
  prerelease: null,
21
21
  };
@@ -64,6 +64,7 @@ UIKIT_STATIC_INLINE CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path)
64
64
  #define RCTPlatformView UIView
65
65
  #define RCTUIView UIView
66
66
  #define RCTUIScrollView UIScrollView
67
+ #define RCTUIPanGestureRecognizer UIPanGestureRecognizer
67
68
 
68
69
  UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
69
70
  {
@@ -337,6 +338,7 @@ NS_INLINE NSEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat botto
337
338
  // UIGestureRecognizer
338
339
  #define UIGestureRecognizer NSGestureRecognizer
339
340
  #define UIGestureRecognizerDelegate NSGestureRecognizerDelegate
341
+ #define RCTUIPanGestureRecognizer NSPanGestureRecognizer
340
342
 
341
343
  // UIApplication
342
344
  #define UIApplication NSApplication
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(79),
26
- RCTVersionPatch: @(1),
26
+ RCTVersionPatch: @(4),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -128,33 +128,21 @@ RCT_EXPORT_MODULE()
128
128
  self->_window = [[UIWindow alloc] initWithWindowScene:mainWindow.windowScene];
129
129
  self->_window.windowLevel = UIWindowLevelStatusBar + 1;
130
130
  self->_window.rootViewController = [UIViewController new];
131
- #else // [macOS
132
- self->_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 375, 20)
133
- styleMask:NSWindowStyleMaskBorderless | NSWindowStyleMaskFullSizeContentView
134
- backing:NSBackingStoreBuffered
135
- defer:YES];
136
- [self->_window setIdentifier:sRCTDevLoadingViewWindowIdentifier];
137
- #endif // macOS]
138
131
 
139
- self->_container = [[RCTUIView alloc] init]; // [macOS]
132
+ self->_container = [[UIView alloc] init];
140
133
  self->_container.backgroundColor = backgroundColor;
141
134
  self->_container.translatesAutoresizingMaskIntoConstraints = NO;
142
135
 
143
- self->_label = [[RCTUILabel alloc] init]; // [macOS]
136
+ self->_label = [[UILabel alloc] init];
144
137
  self->_label.translatesAutoresizingMaskIntoConstraints = NO;
145
138
  self->_label.font = [UIFont monospacedDigitSystemFontOfSize:12.0 weight:UIFontWeightRegular];
146
139
  self->_label.textAlignment = NSTextAlignmentCenter;
147
140
  self->_label.textColor = color;
148
141
  self->_label.text = message;
149
142
 
150
- #if !TARGET_OS_OSX // [macOS]
151
143
  [self->_window.rootViewController.view addSubview:self->_container];
152
- #else // [macOS
153
- [self->_window.contentView addSubview:self->_container];
154
- #endif // macOS]
155
144
  [self->_container addSubview:self->_label];
156
145
 
157
- #if !TARGET_OS_OSX // [macOS]
158
146
  CGFloat topSafeAreaHeight = mainWindow.safeAreaInsets.top;
159
147
  CGFloat height = topSafeAreaHeight + 25;
160
148
  self->_window.frame = CGRectMake(0, 0, mainWindow.frame.size.width, height);
@@ -175,6 +163,31 @@ RCT_EXPORT_MODULE()
175
163
  [self->_label.bottomAnchor constraintEqualToAnchor:self->_container.bottomAnchor constant:-5],
176
164
  ]];
177
165
  #else // [macOS
166
+ if (!self->_label) {
167
+ self->_label = [[RCTUILabel alloc] init]; // [macOS]
168
+ self->_label.translatesAutoresizingMaskIntoConstraints = NO;
169
+ self->_label.font = [UIFont monospacedDigitSystemFontOfSize:12.0 weight:UIFontWeightRegular];
170
+ self->_label.textAlignment = NSTextAlignmentCenter;
171
+ }
172
+ self->_label.textColor = color;
173
+ self->_label.text = message;
174
+
175
+ if (!self->_container) {
176
+ self->_container = [[RCTUIView alloc] init]; // [macOS]
177
+ self->_container.translatesAutoresizingMaskIntoConstraints = NO;
178
+ [self->_container addSubview:self->_label];
179
+ }
180
+ self->_container.backgroundColor = backgroundColor;
181
+
182
+ if (!self->_window) {
183
+ self->_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 375, 20)
184
+ styleMask:NSWindowStyleMaskBorderless | NSWindowStyleMaskFullSizeContentView
185
+ backing:NSBackingStoreBuffered
186
+ defer:YES];
187
+ [self->_window setIdentifier:sRCTDevLoadingViewWindowIdentifier];
188
+ [self->_window.contentView addSubview:self->_container];
189
+ }
190
+
178
191
  // Container constraints
179
192
  [NSLayoutConstraint activateConstraints:@[
180
193
  [self->_container.topAnchor constraintEqualToAnchor:self->_window.contentView.topAnchor],
@@ -326,14 +326,12 @@ RCT_EXPORT_MODULE()
326
326
  }]];
327
327
  }
328
328
 
329
- #if !TARGET_OS_OSX // [macOS]
330
329
  id perfMonitorItemOpaque = [_moduleRegistry moduleForName:"PerfMonitor"];
331
330
  SEL devMenuItem = @selector(devMenuItem);
332
331
  if ([perfMonitorItemOpaque respondsToSelector:devMenuItem]) {
333
332
  RCTDevMenuItem *perfMonitorItem = [perfMonitorItemOpaque devMenuItem];
334
333
  [items addObject:perfMonitorItem];
335
334
  }
336
- #endif // [macOS]
337
335
 
338
336
  [items
339
337
  addObject:[RCTDevMenuItem
@@ -5,24 +5,26 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #if !TARGET_OS_OSX // [macOS
9
-
10
8
  #import <React/RCTFPSGraph.h>
11
9
 
12
10
  #import <React/RCTAssert.h>
11
+ #import <React/RCTUIKit.h> // [macOS]
12
+ #if TARGET_OS_OSX // [macOS
13
+ #import <QuartzCore/QuartzCore.h>
14
+ #endif // macOS]
13
15
 
14
16
  #if RCT_DEV
15
17
 
16
18
  @interface RCTFPSGraph ()
17
19
 
18
20
  @property (nonatomic, strong, readonly) CAShapeLayer *graph;
19
- @property (nonatomic, strong, readonly) UILabel *label;
21
+ @property (nonatomic, strong, readonly) RCTUILabel *label; // [macOS]
20
22
 
21
23
  @end
22
24
 
23
25
  @implementation RCTFPSGraph {
24
26
  CAShapeLayer *_graph;
25
- UILabel *_label;
27
+ RCTUILabel *_label; // [macOS]
26
28
 
27
29
  CGFloat *_frames;
28
30
  RCTUIColor *_color; // [macOS]
@@ -40,6 +42,9 @@
40
42
  - (instancetype)initWithFrame:(CGRect)frame color:(RCTUIColor *)color // [macOS]
41
43
  {
42
44
  if ((self = [super initWithFrame:frame])) {
45
+ #if TARGET_OS_OSX // [macOS
46
+ self.wantsLayer = YES;
47
+ #endif // macOS]
43
48
  _frameCount = -1;
44
49
  _prevTime = -1;
45
50
  _maxFPS = 0;
@@ -76,10 +81,10 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
76
81
  return _graph;
77
82
  }
78
83
 
79
- - (UILabel *)label
84
+ - (RCTUILabel *)label // [macOS]
80
85
  {
81
86
  if (!_label) {
82
- _label = [[UILabel alloc] initWithFrame:self.bounds];
87
+ _label = [[RCTUILabel alloc] initWithFrame:self.bounds];
83
88
  _label.font = [UIFont boldSystemFontOfSize:13];
84
89
  _label.textAlignment = NSTextAlignmentCenter;
85
90
  }
@@ -128,5 +133,3 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
128
133
  @end
129
134
 
130
135
  #endif
131
-
132
- #endif // macOS]
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #if !TARGET_OS_OSX // [macOS]
9
-
10
8
  #import <React/RCTDefines.h>
11
9
 
12
10
  #import "CoreModulesPlugins.h"
@@ -30,6 +28,8 @@
30
28
  #import <React/RCTRootView.h>
31
29
  #import <React/RCTUIManager.h>
32
30
  #import <React/RCTUtils.h>
31
+ #import <React/RCTPlatformDisplayLink.h> // [macOS]
32
+ #import <React/RCTUIKit.h> // [macOS]
33
33
  #import <ReactCommon/RCTTurboModule.h>
34
34
 
35
35
  #if __has_include(<React/RCTDevMenu.h>)
@@ -62,22 +62,30 @@ static vm_size_t RCTGetResidentMemorySize(void)
62
62
  return memoryUsageInByte;
63
63
  }
64
64
 
65
+ #if !TARGET_OS_OSX // [macOS]
65
66
  @interface RCTPerfMonitor
66
67
  : NSObject <RCTBridgeModule, RCTTurboModule, RCTInvalidating, UITableViewDataSource, UITableViewDelegate>
68
+ #else // [macOS
69
+ @interface RCTPerfMonitor
70
+ : NSObject <RCTBridgeModule, RCTTurboModule, RCTInvalidating, NSTableViewDataSource, NSTableViewDelegate>
71
+ #endif // macOS]
67
72
 
68
73
  #if __has_include(<React/RCTDevMenu.h>)
69
74
  @property (nonatomic, strong, readonly) RCTDevMenuItem *devMenuItem;
70
75
  #endif
71
- @property (nonatomic, strong, readonly) UIPanGestureRecognizer *gestureRecognizer;
72
- @property (nonatomic, strong, readonly) UIView *container;
73
- @property (nonatomic, strong, readonly) UILabel *memory;
74
- @property (nonatomic, strong, readonly) UILabel *heap;
75
- @property (nonatomic, strong, readonly) UILabel *views;
76
- @property (nonatomic, strong, readonly) UITableView *metrics;
76
+ @property (nonatomic, strong, readonly) RCTUIPanGestureRecognizer *gestureRecognizer; // [macOS]
77
+ @property (nonatomic, strong, readonly) RCTPlatformView *container; // [macOS]
78
+ #if TARGET_OS_OSX // [macOS
79
+ @property (nonatomic, strong, readonly) NSWindow *containerWindow;
80
+ @property (nonatomic, strong, readonly) NSScrollView *metricsScrollView;
81
+ #endif // macOS]
82
+ @property (nonatomic, strong, readonly) RCTUILabel *memory; // [macOS]
83
+ @property (nonatomic, strong, readonly) RCTUILabel *heap; // [macOS]
84
+ @property (nonatomic, strong, readonly) RCTUILabel *views; // [macOS]
77
85
  @property (nonatomic, strong, readonly) RCTFPSGraph *jsGraph;
78
86
  @property (nonatomic, strong, readonly) RCTFPSGraph *uiGraph;
79
- @property (nonatomic, strong, readonly) UILabel *jsGraphLabel;
80
- @property (nonatomic, strong, readonly) UILabel *uiGraphLabel;
87
+ @property (nonatomic, strong, readonly) RCTUILabel *jsGraphLabel; // [macOS]
88
+ @property (nonatomic, strong, readonly) RCTUILabel *uiGraphLabel; // [macOS]
81
89
 
82
90
  @end
83
91
 
@@ -85,20 +93,26 @@ static vm_size_t RCTGetResidentMemorySize(void)
85
93
  #if __has_include(<React/RCTDevMenu.h>)
86
94
  RCTDevMenuItem *_devMenuItem;
87
95
  #endif
88
- UIPanGestureRecognizer *_gestureRecognizer;
89
- UIView *_container;
90
- UILabel *_memory;
91
- UILabel *_heap;
92
- UILabel *_views;
93
- UILabel *_uiGraphLabel;
94
- UILabel *_jsGraphLabel;
96
+ RCTUIPanGestureRecognizer *_gestureRecognizer; // [macOS]
97
+ RCTPlatformView *_container; // [macOS]
98
+ #if !TARGET_OS_OSX // [macOS]
95
99
  UITableView *_metrics;
100
+ #else // [macOS
101
+ NSWindow *_containerWindow;
102
+ NSScrollView *_metricsScrollView;
103
+ NSTableView *_metrics;
104
+ #endif // macOS]
105
+ RCTUILabel *_memory; // [macOS]
106
+ RCTUILabel *_heap; // [macOS]
107
+ RCTUILabel *_views; // [macOS]
108
+ RCTUILabel *_uiGraphLabel; // [macOS]
109
+ RCTUILabel *_jsGraphLabel; // [macOS]
96
110
 
97
111
  RCTFPSGraph *_uiGraph;
98
112
  RCTFPSGraph *_jsGraph;
99
113
 
100
- CADisplayLink *_uiDisplayLink;
101
- CADisplayLink *_jsDisplayLink;
114
+ RCTPlatformDisplayLink *_uiDisplayLink; // [macOS]
115
+ RCTPlatformDisplayLink *_jsDisplayLink; // [macOS]
102
116
 
103
117
  NSUInteger _heapSize;
104
118
 
@@ -161,37 +175,24 @@ RCT_EXPORT_MODULE()
161
175
  }
162
176
  #endif
163
177
 
164
- - (UIPanGestureRecognizer *)gestureRecognizer
178
+ - (RCTUIPanGestureRecognizer *)gestureRecognizer // [macOS]
165
179
  {
166
180
  if (!_gestureRecognizer) {
167
- _gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(gesture:)];
181
+ _gestureRecognizer = [[RCTUIPanGestureRecognizer alloc] initWithTarget:self action:@selector(gesture:)];
168
182
  }
169
183
 
170
184
  return _gestureRecognizer;
171
185
  }
172
186
 
173
- - (UIView *)container
174
- {
175
- if (!_container) {
176
- UIEdgeInsets safeInsets = RCTKeyWindow().safeAreaInsets;
177
-
178
- _container =
179
- [[UIView alloc] initWithFrame:CGRectMake(safeInsets.left, safeInsets.top, 180, RCTPerfMonitorBarHeight)];
180
- _container.layer.borderWidth = 2;
181
- _container.layer.borderColor = [UIColor lightGrayColor].CGColor;
182
- [_container addGestureRecognizer:self.gestureRecognizer];
183
- [_container addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)]];
184
-
185
- _container.backgroundColor = [UIColor systemBackgroundColor];
186
- }
187
-
188
- return _container;
189
- }
190
-
191
- - (UILabel *)memory
187
+ - (RCTUILabel *)memory // [macOS]
192
188
  {
193
189
  if (!_memory) {
194
- _memory = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 44, RCTPerfMonitorBarHeight)];
190
+ #if !TARGET_OS_OSX // [macOS]
191
+ _memory = [[RCTUILabel alloc] initWithFrame:CGRectMake(0, 0, 44, RCTPerfMonitorBarHeight)];
192
+ #else // [macOS
193
+ _memory = [[RCTUILabel alloc] initWithFrame:CGRectMake(2, 0, 58, RCTPerfMonitorBarHeight)];
194
+ _memory.autoresizingMask = NSViewMinYMargin;
195
+ #endif // macOS]
195
196
  _memory.font = [UIFont systemFontOfSize:12];
196
197
  _memory.numberOfLines = 3;
197
198
  _memory.textAlignment = NSTextAlignmentCenter;
@@ -200,10 +201,15 @@ RCT_EXPORT_MODULE()
200
201
  return _memory;
201
202
  }
202
203
 
203
- - (UILabel *)heap
204
+ - (RCTUILabel *)heap // [macOS]
204
205
  {
205
206
  if (!_heap) {
206
- _heap = [[UILabel alloc] initWithFrame:CGRectMake(44, 0, 44, RCTPerfMonitorBarHeight)];
207
+ #if !TARGET_OS_OSX // [macOS]
208
+ _heap = [[RCTUILabel alloc] initWithFrame:CGRectMake(44, 0, 44, RCTPerfMonitorBarHeight)];
209
+ #else // [macOS
210
+ _heap = [[RCTUILabel alloc] initWithFrame:CGRectMake(60, 0, 58, RCTPerfMonitorBarHeight)];
211
+ _heap.autoresizingMask = NSViewMinYMargin;
212
+ #endif // macOS]
207
213
  _heap.font = [UIFont systemFontOfSize:12];
208
214
  _heap.numberOfLines = 3;
209
215
  _heap.textAlignment = NSTextAlignmentCenter;
@@ -212,10 +218,15 @@ RCT_EXPORT_MODULE()
212
218
  return _heap;
213
219
  }
214
220
 
215
- - (UILabel *)views
221
+ - (RCTUILabel *)views // [macOS]
216
222
  {
217
223
  if (!_views) {
218
- _views = [[UILabel alloc] initWithFrame:CGRectMake(88, 0, 44, RCTPerfMonitorBarHeight)];
224
+ #if !TARGET_OS_OSX // [macOS]
225
+ _views = [[RCTUILabel alloc] initWithFrame:CGRectMake(88, 0, 44, RCTPerfMonitorBarHeight)];
226
+ #else // [macOS
227
+ _views = [[RCTUILabel alloc] initWithFrame:CGRectMake(118, 0, 52, RCTPerfMonitorBarHeight)];
228
+ _views.autoresizingMask = NSViewMinYMargin;
229
+ #endif // macOS]
219
230
  _views.font = [UIFont systemFontOfSize:12];
220
231
  _views.numberOfLines = 3;
221
232
  _views.textAlignment = NSTextAlignmentCenter;
@@ -227,7 +238,12 @@ RCT_EXPORT_MODULE()
227
238
  - (RCTFPSGraph *)uiGraph
228
239
  {
229
240
  if (!_uiGraph) {
230
- _uiGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(134, 14, 40, 30) color:[UIColor lightGrayColor]];
241
+ #if !TARGET_OS_OSX // [macOS]
242
+ _uiGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(134, 14, 40, 30) color:[RCTUIColor lightGrayColor]];
243
+ #else // [macOS
244
+ _uiGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(175, 14, 46, 30) color:[RCTUIColor lightGrayColor]];
245
+ _uiGraph.autoresizingMask = NSViewMinYMargin;
246
+ #endif // macOS]
231
247
  }
232
248
  return _uiGraph;
233
249
  }
@@ -235,15 +251,25 @@ RCT_EXPORT_MODULE()
235
251
  - (RCTFPSGraph *)jsGraph
236
252
  {
237
253
  if (!_jsGraph) {
238
- _jsGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(178, 14, 40, 30) color:[UIColor lightGrayColor]];
254
+ #if !TARGET_OS_OSX // [macOS]
255
+ _jsGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(178, 14, 40, 30) color:[RCTUIColor lightGrayColor]];
256
+ #else // [macOS
257
+ _jsGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(226, 14, 46, 30) color:[RCTUIColor lightGrayColor]];
258
+ _jsGraph.autoresizingMask = NSViewMinYMargin;
259
+ #endif // macOS]
239
260
  }
240
261
  return _jsGraph;
241
262
  }
242
263
 
243
- - (UILabel *)uiGraphLabel
264
+ - (RCTUILabel *)uiGraphLabel // [macOS]
244
265
  {
245
266
  if (!_uiGraphLabel) {
246
- _uiGraphLabel = [[UILabel alloc] initWithFrame:CGRectMake(134, 3, 40, 10)];
267
+ #if !TARGET_OS_OSX // [macOS]
268
+ _uiGraphLabel = [[RCTUILabel alloc] initWithFrame:CGRectMake(134, 3, 40, 10)];
269
+ #else // [macOS
270
+ _uiGraphLabel = [[RCTUILabel alloc] initWithFrame:CGRectMake(175, 3, 46, 12)];
271
+ _uiGraphLabel.autoresizingMask = NSViewMinYMargin;
272
+ #endif // macOS]
247
273
  _uiGraphLabel.font = [UIFont systemFontOfSize:11];
248
274
  _uiGraphLabel.textAlignment = NSTextAlignmentCenter;
249
275
  _uiGraphLabel.text = @"UI";
@@ -252,10 +278,15 @@ RCT_EXPORT_MODULE()
252
278
  return _uiGraphLabel;
253
279
  }
254
280
 
255
- - (UILabel *)jsGraphLabel
281
+ - (RCTUILabel *)jsGraphLabel // [macOS]
256
282
  {
257
283
  if (!_jsGraphLabel) {
258
- _jsGraphLabel = [[UILabel alloc] initWithFrame:CGRectMake(178, 3, 38, 10)];
284
+ #if !TARGET_OS_OSX // [macOS]
285
+ _jsGraphLabel = [[RCTUILabel alloc] initWithFrame:CGRectMake(178, 3, 38, 10)];
286
+ #else // [macOS
287
+ _jsGraphLabel = [[RCTUILabel alloc] initWithFrame:CGRectMake(226, 3, 46, 12)];
288
+ _jsGraphLabel.autoresizingMask = NSViewMinYMargin;
289
+ #endif // macOS]
259
290
  _jsGraphLabel.font = [UIFont systemFontOfSize:11];
260
291
  _jsGraphLabel.textAlignment = NSTextAlignmentCenter;
261
292
  _jsGraphLabel.text = @"JS";
@@ -264,6 +295,25 @@ RCT_EXPORT_MODULE()
264
295
  return _jsGraphLabel;
265
296
  }
266
297
 
298
+ #if !TARGET_OS_OSX // [macOS]
299
+ - (RCTPlatformView *)container // [macOS]
300
+ {
301
+ if (!_container) {
302
+ UIEdgeInsets safeInsets = RCTKeyWindow().safeAreaInsets;
303
+
304
+ _container =
305
+ [[RCTPlatformView alloc] initWithFrame:CGRectMake(safeInsets.left, safeInsets.top, 180, RCTPerfMonitorBarHeight)]; // [macOS]
306
+ _container.layer.borderWidth = 2;
307
+ _container.layer.borderColor = [UIColor lightGrayColor].CGColor;
308
+ [_container addGestureRecognizer:self.gestureRecognizer];
309
+ [_container addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)]];
310
+
311
+ _container.backgroundColor = [UIColor systemBackgroundColor];
312
+ }
313
+
314
+ return _container;
315
+ }
316
+
267
317
  - (UITableView *)metrics
268
318
  {
269
319
  if (!_metrics) {
@@ -301,7 +351,7 @@ RCT_EXPORT_MODULE()
301
351
 
302
352
  [RCTKeyWindow() addSubview:self.container];
303
353
 
304
- _uiDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(threadUpdate:)];
354
+ _uiDisplayLink = [RCTPlatformDisplayLink displayLinkWithTarget:self selector:@selector(threadUpdate:)]; // [macOS]
305
355
  [_uiDisplayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
306
356
 
307
357
  self.container.frame =
@@ -311,7 +361,7 @@ RCT_EXPORT_MODULE()
311
361
 
312
362
  [_bridge
313
363
  dispatchBlock:^{
314
- self->_jsDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(threadUpdate:)];
364
+ self->_jsDisplayLink = [RCTPlatformDisplayLink displayLinkWithTarget:self selector:@selector(threadUpdate:)]; // [macOS]
315
365
  [self->_jsDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
316
366
  }
317
367
  queue:RCTJSThread];
@@ -339,6 +389,161 @@ RCT_EXPORT_MODULE()
339
389
  _jsDisplayLink = nil;
340
390
  }
341
391
 
392
+ #else // [macOS
393
+
394
+ - (NSWindow *)containerWindow
395
+ {
396
+ if (!_containerWindow) {
397
+ CGFloat windowWidth = 300;
398
+ // Initial frame - will be repositioned when attached to parent
399
+ NSRect frame = NSMakeRect(0, 0, windowWidth, RCTPerfMonitorBarHeight);
400
+ _containerWindow = [[NSWindow alloc] initWithContentRect:frame
401
+ styleMask:NSWindowStyleMaskBorderless
402
+ backing:NSBackingStoreBuffered
403
+ defer:NO];
404
+ _containerWindow.level = NSFloatingWindowLevel;
405
+ _containerWindow.backgroundColor = [NSColor windowBackgroundColor];
406
+ _containerWindow.opaque = NO;
407
+ _containerWindow.hasShadow = YES;
408
+ _containerWindow.movableByWindowBackground = YES;
409
+ }
410
+ return _containerWindow;
411
+ }
412
+
413
+ - (RCTPlatformView *)container
414
+ {
415
+ if (!_container) {
416
+ _container = self.containerWindow.contentView;
417
+ _container.wantsLayer = YES;
418
+ _container.layer.borderWidth = 2;
419
+ _container.layer.borderColor = [NSColor lightGrayColor].CGColor;
420
+
421
+ NSClickGestureRecognizer *clickRecognizer = [[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
422
+ [_container addGestureRecognizer:clickRecognizer];
423
+ }
424
+
425
+ return _container;
426
+ }
427
+
428
+ - (NSScrollView *)metricsScrollView
429
+ {
430
+ if (!_metricsScrollView) {
431
+ // Use expanded height since this is only added when expanding
432
+ CGFloat expandedHeight = RCTPerfMonitorExpandHeight - RCTPerfMonitorBarHeight;
433
+ _metricsScrollView = [[NSScrollView alloc] initWithFrame:CGRectMake(
434
+ 0,
435
+ 0,
436
+ 300,
437
+ expandedHeight)];
438
+ _metricsScrollView.hasVerticalScroller = YES;
439
+ _metricsScrollView.autoresizingMask = NSViewWidthSizable; // Only resize width, not height - leave room for bar at top
440
+ _metricsScrollView.documentView = self.metrics;
441
+
442
+ // Add click recognizer so tapping on scroll view also toggles expand/collapse
443
+ NSClickGestureRecognizer *clickRecognizer = [[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];
444
+ [_metricsScrollView addGestureRecognizer:clickRecognizer];
445
+ }
446
+ return _metricsScrollView;
447
+ }
448
+
449
+ - (NSTableView *)metrics
450
+ {
451
+ if (!_metrics) {
452
+ _metrics = [[NSTableView alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
453
+
454
+ NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:RCTPerfMonitorCellIdentifier];
455
+ column.width = 300;
456
+ [_metrics addTableColumn:column];
457
+
458
+ _metrics.dataSource = self;
459
+ _metrics.delegate = self;
460
+ _metrics.headerView = nil;
461
+ _metrics.rowHeight = 20;
462
+ }
463
+
464
+ return _metrics;
465
+ }
466
+
467
+ - (void)show
468
+ {
469
+ if (_containerWindow.isVisible) {
470
+ return;
471
+ }
472
+
473
+ [self.container addSubview:self.memory];
474
+ [self.container addSubview:self.heap];
475
+ [self.container addSubview:self.views];
476
+ [self.container addSubview:self.uiGraph];
477
+ [self.container addSubview:self.uiGraphLabel];
478
+ [self.container addSubview:self.jsGraph];
479
+ [self.container addSubview:self.jsGraphLabel];
480
+
481
+ [self redirectLogs];
482
+
483
+ RCTJSCSetOption("logGC=1");
484
+
485
+ [self updateStats];
486
+
487
+ // Attach to the key window
488
+ NSWindow *parentWindow = RCTKeyWindow();
489
+ if (parentWindow) {
490
+ // Position at top-left of parent window's content area
491
+ NSRect parentFrame = parentWindow.frame;
492
+ NSRect contentRect = [parentWindow contentRectForFrameRect:parentFrame];
493
+ CGFloat xPos = contentRect.origin.x + 10;
494
+ CGFloat yPos = contentRect.origin.y + contentRect.size.height - RCTPerfMonitorBarHeight - 10;
495
+ NSRect perfFrame = self.containerWindow.frame;
496
+ perfFrame.origin = NSMakePoint(xPos, yPos);
497
+ [self.containerWindow setFrame:perfFrame display:YES];
498
+
499
+ // Add as child window so it moves with parent
500
+ [parentWindow addChildWindow:self.containerWindow ordered:NSWindowAbove];
501
+ }
502
+
503
+ [self.containerWindow orderFront:nil];
504
+
505
+ _uiDisplayLink = [RCTPlatformDisplayLink displayLinkWithTarget:self selector:@selector(threadUpdate:)];
506
+ [_uiDisplayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
507
+
508
+ [_bridge
509
+ dispatchBlock:^{
510
+ self->_jsDisplayLink = [RCTPlatformDisplayLink displayLinkWithTarget:self selector:@selector(threadUpdate:)];
511
+ [self->_jsDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
512
+ }
513
+ queue:RCTJSThread];
514
+ }
515
+
516
+ - (void)hide
517
+ {
518
+ if (!_containerWindow.isVisible) {
519
+ return;
520
+ }
521
+
522
+ // Remove from parent window if attached
523
+ NSWindow *parentWindow = _containerWindow.parentWindow;
524
+ if (parentWindow) {
525
+ [parentWindow removeChildWindow:_containerWindow];
526
+ }
527
+
528
+ [self.containerWindow orderOut:nil];
529
+ _containerWindow = nil;
530
+ _container = nil;
531
+ _jsGraph = nil;
532
+ _uiGraph = nil;
533
+
534
+ RCTJSCSetOption("logGC=0");
535
+
536
+ [self stopLogs];
537
+
538
+ [_uiDisplayLink invalidate];
539
+ [_jsDisplayLink invalidate];
540
+
541
+ _uiDisplayLink = nil;
542
+ _jsDisplayLink = nil;
543
+ }
544
+
545
+ #endif // macOS]
546
+
342
547
  - (void)redirectLogs
343
548
  {
344
549
  _stderr = dup(STDERR_FILENO);
@@ -415,6 +620,7 @@ RCT_EXPORT_MODULE()
415
620
 
416
621
  - (void)updateStats
417
622
  {
623
+ #if !TARGET_OS_OSX // [macOS]
418
624
  NSDictionary<NSNumber *, UIView *> *views = [_bridge.uiManager valueForKey:@"viewRegistry"];
419
625
  NSUInteger viewCount = views.count;
420
626
  NSUInteger visibleViewCount = 0;
@@ -442,18 +648,48 @@ RCT_EXPORT_MODULE()
442
648
  [strongSelf updateStats];
443
649
  }
444
650
  });
651
+ #else // [macOS
652
+ NSDictionary<NSNumber *, NSView *> *views = [_bridge.uiManager valueForKey:@"viewRegistry"];
653
+ NSUInteger viewCount = views.count;
654
+ NSUInteger visibleViewCount = 0;
655
+ for (NSView *view in views.allValues) {
656
+ if (view.window || view.superview.window) {
657
+ visibleViewCount++;
658
+ }
659
+ }
660
+
661
+ double mem = (double)RCTGetResidentMemorySize() / 1024 / 1024;
662
+ self.memory.text = [NSString stringWithFormat:@"RAM\n%.1lfMB", mem];
663
+ self.heap.text = [NSString stringWithFormat:@"JSC\n%.1lfMB", (double)_heapSize / 1024];
664
+ self.views.text =
665
+ [NSString stringWithFormat:@"Views\n%lu/%lu", (unsigned long)visibleViewCount, (unsigned long)viewCount];
666
+
667
+ __weak __typeof__(self) weakSelf = self;
668
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
669
+ __strong __typeof__(weakSelf) strongSelf = weakSelf;
670
+ if (strongSelf && strongSelf->_containerWindow.isVisible) {
671
+ [strongSelf updateStats];
672
+ }
673
+ });
674
+ #endif // macOS]
445
675
  }
446
676
 
447
- - (void)gesture:(UIPanGestureRecognizer *)gestureRecognizer
677
+ - (void)gesture:(RCTUIPanGestureRecognizer *)gestureRecognizer // [macOS]
448
678
  {
679
+ #if !TARGET_OS_OSX // [macOS]
449
680
  CGPoint translation = [gestureRecognizer translationInView:self.container.superview];
450
681
  self.container.center = CGPointMake(self.container.center.x + translation.x, self.container.center.y + translation.y);
451
682
  [gestureRecognizer setTranslation:CGPointMake(0, 0) inView:self.container.superview];
683
+ #else // [macOS
684
+ // Window dragging is handled by movableByWindowBackground on macOS
685
+ (void)gestureRecognizer;
686
+ #endif // macOS]
452
687
  }
453
688
 
454
689
  - (void)tap
455
690
  {
456
691
  [self loadPerformanceLoggerData];
692
+ #if !TARGET_OS_OSX // [macOS]
457
693
  if (CGRectIsEmpty(_storedMonitorFrame)) {
458
694
  UIEdgeInsets safeInsets = RCTKeyWindow().safeAreaInsets;
459
695
  _storedMonitorFrame =
@@ -469,9 +705,47 @@ RCT_EXPORT_MODULE()
469
705
  self.container.frame = self->_storedMonitorFrame;
470
706
  self->_storedMonitorFrame = tmp;
471
707
  }];
708
+ #else // [macOS
709
+ if (CGRectIsEmpty(_storedMonitorFrame)) {
710
+ // First tap: expand
711
+ // Save current collapsed frame
712
+ NSRect collapsedFrame = self.containerWindow.frame;
713
+ _storedMonitorFrame = collapsedFrame;
714
+
715
+ // Calculate expanded frame - keep top-left corner fixed, expand downward
716
+ // In macOS coords, origin is bottom-left, so we need to move origin.y down
717
+ CGFloat heightDelta = RCTPerfMonitorExpandHeight - collapsedFrame.size.height;
718
+ NSRect expandedFrame = NSMakeRect(
719
+ collapsedFrame.origin.x,
720
+ collapsedFrame.origin.y - heightDelta,
721
+ 300,
722
+ RCTPerfMonitorExpandHeight);
723
+
724
+ [self.container addSubview:self.metricsScrollView];
725
+
726
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
727
+ context.duration = 0.25;
728
+ [self.containerWindow.animator setFrame:expandedFrame display:YES];
729
+ }];
730
+ } else {
731
+ // Second tap: collapse
732
+ [_metrics reloadData];
733
+
734
+ // Hide the scroll view when collapsing
735
+ [_metricsScrollView removeFromSuperview];
736
+
737
+ NSRect collapsedFrame = _storedMonitorFrame;
738
+ _storedMonitorFrame = CGRectZero; // Reset so next tap expands again
739
+
740
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
741
+ context.duration = 0.25;
742
+ [self.containerWindow.animator setFrame:collapsedFrame display:YES];
743
+ }];
744
+ }
745
+ #endif // macOS]
472
746
  }
473
747
 
474
- - (void)threadUpdate:(CADisplayLink *)displayLink
748
+ - (void)threadUpdate:(RCTPlatformDisplayLink *)displayLink // [macOS]
475
749
  {
476
750
  RCTFPSGraph *graph = displayLink == _jsDisplayLink ? _jsGraph : _uiGraph;
477
751
  [graph onTick:displayLink.timestamp];
@@ -497,6 +771,7 @@ RCT_EXPORT_MODULE()
497
771
  _perfLoggerMarks = [data copy];
498
772
  }
499
773
 
774
+ #if !TARGET_OS_OSX // [macOS]
500
775
  #pragma mark - UITableViewDataSource
501
776
 
502
777
  - (NSInteger)numberOfSectionsInTableView:(__unused UITableView *)tableView
@@ -532,6 +807,39 @@ RCT_EXPORT_MODULE()
532
807
  return 20;
533
808
  }
534
809
 
810
+ #else // [macOS
811
+ #pragma mark - NSTableViewDataSource
812
+
813
+ - (NSInteger)numberOfRowsInTableView:(__unused NSTableView *)tableView
814
+ {
815
+ return _perfLoggerMarks.count;
816
+ }
817
+
818
+ #pragma mark - NSTableViewDelegate
819
+
820
+ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
821
+ {
822
+ NSTextField *cell = [tableView makeViewWithIdentifier:RCTPerfMonitorCellIdentifier owner:self];
823
+ if (!cell) {
824
+ cell = [[NSTextField alloc] initWithFrame:NSZeroRect];
825
+ cell.identifier = RCTPerfMonitorCellIdentifier;
826
+ cell.bezeled = NO;
827
+ cell.drawsBackground = NO;
828
+ cell.editable = NO;
829
+ cell.selectable = NO;
830
+ }
831
+ cell.stringValue = _perfLoggerMarks[row];
832
+ cell.font = [NSFont systemFontOfSize:12];
833
+ return cell;
834
+ }
835
+
836
+ - (CGFloat)tableView:(__unused NSTableView *)tableView heightOfRow:(__unused NSInteger)row
837
+ {
838
+ return 20;
839
+ }
840
+
841
+ #endif // macOS]
842
+
535
843
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
536
844
  (const facebook::react::ObjCTurboModule::InitParams &)params
537
845
  {
@@ -559,5 +867,3 @@ Class RCTPerfMonitorCls(void)
559
867
  return nil;
560
868
  #endif
561
869
  }
562
-
563
- #endif // [macOS]
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.79.1
1
+ VERSION_NAME=0.79.4
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 79,
20
- "patch", 1,
20
+ "patch", 4,
21
21
  "prerelease", null);
22
22
  }
@@ -14,14 +14,14 @@
14
14
 
15
15
  #define REACT_NATIVE_VERSION_MAJOR 0
16
16
  #define REACT_NATIVE_VERSION_MINOR 79
17
- #define REACT_NATIVE_VERSION_PATCH 1
17
+ #define REACT_NATIVE_VERSION_PATCH 4
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
21
  constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 79;
24
- int32_t Patch = 1;
24
+ int32_t Patch = 4;
25
25
  std::string_view Prerelease = "";
26
26
  } ReactNativeVersion;
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.79.1",
3
+ "version": "0.79.4",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  "dependencies": {
115
115
  "@jest/create-cache-key-function": "^29.7.0",
116
- "@react-native-macos/virtualized-lists": "0.79.1",
116
+ "@react-native-macos/virtualized-lists": "0.79.4",
117
117
  "@react-native/assets-registry": "0.79.6",
118
118
  "@react-native/codegen": "0.79.6",
119
119
  "@react-native/community-cli-plugin": "0.79.6",