react-native-macos 0.73.5 → 0.73.6

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.
@@ -12,6 +12,6 @@
12
12
  exports.version = {
13
13
  major: 0,
14
14
  minor: 73,
15
- patch: 5,
15
+ patch: 6,
16
16
  prerelease: null,
17
17
  };
@@ -37,11 +37,18 @@
37
37
 
38
38
  @end
39
39
 
40
- @interface RCTTextView () <NSTextViewDelegate>
41
- @end
40
+ #endif // macOS]
41
+
42
+ #if !TARGET_OS_OSX // [macOS]
43
+ @interface RCTTextView () <UIEditMenuInteractionDelegate>
42
44
 
45
+ @property (nonatomic, nullable) UIEditMenuInteraction *editMenuInteraction API_AVAILABLE(ios(16.0));
46
+ #else // [macOS
47
+ @interface RCTTextView () <NSTextViewDelegate>
43
48
  #endif // macOS]
44
49
 
50
+ @end
51
+
45
52
  #import <QuartzCore/QuartzCore.h>
46
53
 
47
54
  @implementation RCTTextView {
@@ -351,6 +358,10 @@
351
358
  {
352
359
  _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
353
360
  action:@selector(handleLongPress:)];
361
+ if (@available(iOS 16.0, *)) {
362
+ _editMenuInteraction = [[UIEditMenuInteraction alloc] initWithDelegate:self];
363
+ [self addInteraction:_editMenuInteraction];
364
+ }
354
365
  [self addGestureRecognizer:_longPressGestureRecognizer];
355
366
  }
356
367
 
@@ -362,8 +373,16 @@
362
373
 
363
374
  - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
364
375
  {
365
- // TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
366
376
  #if !TARGET_OS_UIKITFORMAC
377
+ if (@available(iOS 16.0, *)) {
378
+ CGPoint location = [gesture locationInView:self];
379
+ UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
380
+ if (_editMenuInteraction) {
381
+ [_editMenuInteraction presentEditMenuWithConfiguration:config];
382
+ }
383
+ return;
384
+ }
385
+ // TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
367
386
  UIMenuController *menuController = [UIMenuController sharedMenuController];
368
387
 
369
388
  if (menuController.isMenuVisible) {
@@ -305,14 +305,14 @@ static CGFloat screenScale;
305
305
  void RCTComputeScreenScale(void)
306
306
  {
307
307
  dispatch_once(&onceTokenScreenScale, ^{
308
- screenScale = [UIScreen mainScreen].scale;
308
+ screenScale = [UITraitCollection currentTraitCollection].displayScale;
309
309
  });
310
310
  }
311
311
 
312
312
  CGFloat RCTScreenScale(void)
313
313
  {
314
314
  RCTUnsafeExecuteOnMainQueueOnceSync(&onceTokenScreenScale, ^{
315
- screenScale = [UIScreen mainScreen].scale;
315
+ screenScale = [UITraitCollection currentTraitCollection].displayScale;
316
316
  });
317
317
 
318
318
  return screenScale;
@@ -600,12 +600,20 @@ RCTUIWindow *__nullable RCTKeyWindow(void) // [macOS]
600
600
  return nil;
601
601
  }
602
602
 
603
- // TODO: replace with a more robust solution
604
- for (UIWindow *window in RCTSharedApplication().windows) {
605
- if (window.keyWindow) {
606
- return window;
603
+ for (UIScene *scene in RCTSharedApplication().connectedScenes) {
604
+ if (scene.activationState != UISceneActivationStateForegroundActive ||
605
+ ![scene isKindOfClass:[UIWindowScene class]]) {
606
+ continue;
607
+ }
608
+ UIWindowScene *windowScene = (UIWindowScene *)scene;
609
+
610
+ for (UIWindow *window in windowScene.windows) {
611
+ if (window.isKeyWindow) {
612
+ return window;
613
+ }
607
614
  }
608
615
  }
616
+
609
617
  return nil;
610
618
  #else // [macOS
611
619
  return [NSApp keyWindow];
@@ -634,12 +642,10 @@ BOOL RCTForceTouchAvailable(void)
634
642
  static BOOL forceSupported;
635
643
  static dispatch_once_t onceToken;
636
644
  dispatch_once(&onceToken, ^{
637
- forceSupported =
638
- [UITraitCollection class] && [UITraitCollection instancesRespondToSelector:@selector(forceTouchCapability)];
645
+ forceSupported = [UITraitCollection currentTraitCollection].forceTouchCapability == UIForceTouchCapabilityAvailable;
639
646
  });
640
647
 
641
- return forceSupported &&
642
- (RCTKeyWindow() ?: [UIView new]).traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable;
648
+ return forceSupported;
643
649
  }
644
650
  #endif // [macOS]
645
651
 
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(73),
26
- RCTVersionPatch: @(5),
26
+ RCTVersionPatch: @(6),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -23,17 +23,7 @@
23
23
  - (UIWindow *)alertWindow
24
24
  {
25
25
  if (_alertWindow == nil) {
26
- _alertWindow = [self getUIWindowFromScene];
27
-
28
- if (_alertWindow == nil) {
29
- UIWindow *keyWindow = RCTSharedApplication().keyWindow;
30
- if (keyWindow) {
31
- _alertWindow = [[UIWindow alloc] initWithFrame:keyWindow.bounds];
32
- } else {
33
- // keyWindow is nil, so we cannot create and initialize _alertWindow
34
- NSLog(@"Unable to create alert window: keyWindow is nil");
35
- }
36
- }
26
+ _alertWindow = [[UIWindow alloc] initWithWindowScene:RCTKeyWindow().windowScene];
37
27
 
38
28
  if (_alertWindow) {
39
29
  _alertWindow.rootViewController = [UIViewController new];
@@ -67,18 +57,6 @@
67
57
 
68
58
  _alertWindow = nil;
69
59
  }
70
-
71
- - (UIWindow *)getUIWindowFromScene
72
- {
73
- for (UIScene *scene in RCTSharedApplication().connectedScenes) {
74
- if (scene.activationState == UISceneActivationStateForegroundActive &&
75
- [scene isKindOfClass:[UIWindowScene class]]) {
76
- return [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
77
- }
78
- }
79
-
80
- return nil;
81
- }
82
60
  #endif // [macOS]
83
61
 
84
62
  @end
@@ -120,15 +120,15 @@ RCT_EXPORT_MODULE()
120
120
 
121
121
  dispatch_async(dispatch_get_main_queue(), ^{
122
122
  self->_showDate = [NSDate date];
123
+
123
124
  if (!self->_window && !RCTRunningInTestEnvironment()) {
124
125
  #if !TARGET_OS_OSX // [macOS]
125
- CGSize screenSize = [UIScreen mainScreen].bounds.size;
126
+ UIWindow *window = RCTKeyWindow();
127
+ CGFloat windowWidth = window.bounds.size.width;
126
128
 
127
- UIWindow *window = RCTSharedApplication().keyWindow;
128
- self->_window =
129
- [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 10)];
130
- self->_label =
131
- [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, screenSize.width, 20)];
129
+ self->_window = [[UIWindow alloc] initWithWindowScene:window.windowScene];
130
+ self->_window.frame = CGRectMake(0, 0, windowWidth, window.safeAreaInsets.top + 10);
131
+ self->_label = [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, windowWidth, 20)];
132
132
  [self->_window addSubview:self->_label];
133
133
 
134
134
  self->_window.windowLevel = UIWindowLevelStatusBar + 1;
@@ -164,12 +164,10 @@ RCT_EXPORT_MODULE()
164
164
 
165
165
  self->_window.backgroundColor = backgroundColor;
166
166
  self->_window.hidden = NO;
167
-
168
- UIWindowScene *scene = (UIWindowScene *)RCTSharedApplication().connectedScenes.anyObject;
169
- self->_window.windowScene = scene;
170
167
  #else // [macOS
171
168
  self->_label.stringValue = message;
172
169
  self->_label.textColor = color;
170
+
173
171
  self->_label.backgroundColor = backgroundColor;
174
172
  [self->_window orderFront:nil];
175
173
  #endif // macOS]
@@ -27,6 +27,14 @@
27
27
 
28
28
  using namespace facebook::react;
29
29
 
30
+ #if !TARGET_OS_OSX // [macOS]
31
+ @interface RCTParagraphComponentView () <UIEditMenuInteractionDelegate>
32
+
33
+ @property (nonatomic, nullable) UIEditMenuInteraction *editMenuInteraction API_AVAILABLE(ios(16.0));
34
+
35
+ @end
36
+ #endif // [macOS]
37
+
30
38
  @implementation RCTParagraphComponentView {
31
39
  ParagraphShadowNode::ConcreteState::Shared _state;
32
40
  ParagraphAttributes _paragraphAttributes;
@@ -223,19 +231,36 @@ using namespace facebook::react;
223
231
  {
224
232
  _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
225
233
  action:@selector(handleLongPress:)];
234
+
235
+ if (@available(iOS 16.0, *)) {
236
+ _editMenuInteraction = [[UIEditMenuInteraction alloc] initWithDelegate:self];
237
+ [self addInteraction:_editMenuInteraction];
238
+ }
226
239
  [self addGestureRecognizer:_longPressGestureRecognizer];
227
240
  }
228
241
 
229
242
  - (void)disableContextMenu
230
243
  {
231
244
  [self removeGestureRecognizer:_longPressGestureRecognizer];
245
+ if (@available(iOS 16.0, *)) {
246
+ [self removeInteraction:_editMenuInteraction];
247
+ _editMenuInteraction = nil;
248
+ }
232
249
  _longPressGestureRecognizer = nil;
233
250
  }
234
251
 
235
252
  - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
236
253
  {
237
- // TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
238
254
  #if !TARGET_OS_UIKITFORMAC
255
+ if (@available(iOS 16.0, *)) {
256
+ CGPoint location = [gesture locationInView:self];
257
+ UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
258
+ if (_editMenuInteraction) {
259
+ [_editMenuInteraction presentEditMenuWithConfiguration:config];
260
+ }
261
+ return;
262
+ }
263
+ // TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
239
264
  UIMenuController *menuController = [UIMenuController sharedMenuController];
240
265
 
241
266
  if (menuController.isMenuVisible) {
@@ -263,7 +263,7 @@ using namespace facebook::react;
263
263
  if (oldViewProps.shouldRasterize != newViewProps.shouldRasterize) {
264
264
  self.layer.shouldRasterize = newViewProps.shouldRasterize;
265
265
  #if !TARGET_OS_OSX // [macOS]
266
- self.layer.rasterizationScale = newViewProps.shouldRasterize ? [UIScreen mainScreen].scale : 1.0;
266
+ self.layer.rasterizationScale = newViewProps.shouldRasterize ? self.traitCollection.displayScale : 1.0;
267
267
  #else // [macOS
268
268
  self.layer.rasterizationScale = 1.0;
269
269
  #endif // macOS]
@@ -15,8 +15,7 @@ RCTDimensions RCTGetDimensions(CGFloat fontScale)
15
15
  UIScreen *mainScreen = UIScreen.mainScreen;
16
16
  CGSize screenSize = mainScreen.bounds.size;
17
17
 
18
- UIView *mainWindow;
19
- mainWindow = RCTKeyWindow();
18
+ UIView *mainWindow = RCTKeyWindow();
20
19
  // We fallback to screen size if a key window is not found.
21
20
  CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
22
21
  #else // [macOS
@@ -285,7 +285,7 @@ RCT_CUSTOM_VIEW_PROPERTY(shouldRasterizeIOS, BOOL, RCTView)
285
285
  {
286
286
  view.layer.shouldRasterize = json ? [RCTConvert BOOL:json] : defaultView.layer.shouldRasterize;
287
287
  view.layer.rasterizationScale =
288
- view.layer.shouldRasterize ? [UIScreen mainScreen].scale : defaultView.layer.rasterizationScale;
288
+ view.layer.shouldRasterize ? view.traitCollection.displayScale : defaultView.layer.rasterizationScale;
289
289
  }
290
290
  #endif // [macOS]
291
291
 
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.73.5
1
+ VERSION_NAME=0.73.6
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", 73,
20
- "patch", 5,
20
+ "patch", 6,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 73;
20
- int32_t Patch = 5;
20
+ int32_t Patch = 6;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.73.5",
3
+ "version": "0.73.6",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {