react-native-macos 0.0.0-0c343d926 → 0.0.0-0ce8502c1

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.
Files changed (29) hide show
  1. package/Libraries/Core/ReactNativeVersion.js +1 -5
  2. package/Libraries/Image/RCTImageLoader.mm +19 -13
  3. package/Libraries/Image/RCTImageView.h +0 -8
  4. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +7 -3
  5. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +7 -1
  6. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +2 -2
  7. package/React/Base/RCTUIKit.h +18 -4
  8. package/React/Base/RCTVersion.m +1 -5
  9. package/React/Base/macOS/RCTUIKit.m +13 -2
  10. package/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +10 -0
  11. package/React/Fabric/Mounting/ComponentViews/Slider/RCTSliderComponentView.mm +14 -0
  12. package/React/Fabric/Mounting/ComponentViews/Text/RCTAccessibilityElement.h +4 -0
  13. package/React/Fabric/Mounting/ComponentViews/Text/RCTAccessibilityElement.mm +2 -0
  14. package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.h +2 -0
  15. package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm +4 -0
  16. package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +20 -2
  17. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +10 -0
  18. package/React/Fabric/Mounting/RCTMountingManager.mm +2 -0
  19. package/React/Fabric/RCTConversions.h +2 -0
  20. package/React/Fabric/Surface/RCTFabricSurface.mm +2 -0
  21. package/ReactAndroid/gradle.properties +1 -1
  22. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -5
  23. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -5
  24. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm +5 -0
  25. package/package.json +1 -1
  26. package/template/Gemfile +1 -1
  27. package/template/Gemfile.lock +3 -3
  28. package/template/_ruby-version +1 -1
  29. package/template/package.json +1 -1
@@ -9,13 +9,9 @@
9
9
  * @flow strict
10
10
  */
11
11
 
12
- // [TODO(macOS GH#944)
13
- // Note: Be careful not to override these version numbers
14
- // when we merge upstream stable branches into main
15
- // TODO(macOS GH#944)]
16
12
  exports.version = {
17
13
  major: 0,
18
14
  minor: 0,
19
15
  patch: 0,
20
- prerelease: '0c343d926',
16
+ prerelease: '0ce8502c1',
21
17
  };
@@ -22,7 +22,6 @@
22
22
  #import <React/RCTLog.h>
23
23
  #import <React/RCTNetworking.h>
24
24
  #import <React/RCTUtils.h>
25
- #import <React/RCTUIKit.h> // TODO(macOS GH#774)
26
25
 
27
26
  #import "RCTImagePlugins.h"
28
27
 
@@ -54,7 +53,13 @@ static NSInteger RCTImageBytesForImage(UIImage *image)
54
53
  #endif // [TODO(macOS GH#774)
55
54
  }
56
55
 
57
- #if TARGET_OS_OSX
56
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
57
+
58
+ /**
59
+ * Github #1611 - We can't depend on RCTUIKit here, because this file's podspec (React-RCTImage) doesn't
60
+ * take a dependency on RCTUIKit's pod `React-Core`. Let's just copy the methods we want to shim here
61
+ */
62
+
58
63
  static NSData *NSImageDataForFileType(NSImage *image, NSBitmapImageFileType fileType, NSDictionary<NSString *, id> *properties)
59
64
  {
60
65
  RCTAssert(image.representations.count == 1, @"Expected only a single representation since UIImage only supports one.");
@@ -67,7 +72,18 @@ static NSData *NSImageDataForFileType(NSImage *image, NSBitmapImageFileType file
67
72
 
68
73
  return [imageRep representationUsingType:fileType properties:properties];
69
74
  }
70
- #endif // TARGET_OS_OSX
75
+
76
+
77
+ NSData *UIImagePNGRepresentation(NSImage *image) {
78
+ return NSImageDataForFileType(image, NSBitmapImageFileTypePNG, @{});
79
+ }
80
+
81
+ NSData *UIImageJPEGRepresentation(NSImage *image, CGFloat compressionQuality) {
82
+ return NSImageDataForFileType(image,
83
+ NSBitmapImageFileTypeJPEG,
84
+ @{NSImageCompressionFactor: @(compressionQuality)});
85
+ }
86
+ #endif // ]TODO(macOS GH#774)
71
87
 
72
88
  static uint64_t monotonicTimeGetCurrentNanoseconds(void)
73
89
  {
@@ -1145,20 +1161,10 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
1145
1161
  NSData *imageData = nil;
1146
1162
  if (RCTUIImageHasAlpha(image)) { // TODO(macOS GH#774)
1147
1163
  mimeType = @"image/png";
1148
- #if TARGET_OS_OSX
1149
- imageData = NSImageDataForFileType(image, NSBitmapImageFileTypePNG, @{});
1150
- #else
1151
1164
  imageData = UIImagePNGRepresentation(image);
1152
- #endif // !TARGET_OS_OSX
1153
1165
  } else {
1154
1166
  mimeType = @"image/jpeg";
1155
- #if TARGET_OS_OSX
1156
- imageData = NSImageDataForFileType(image,
1157
- NSBitmapImageFileTypeJPEG,
1158
- @{NSImageCompressionFactor : @(1.0)});
1159
- #else
1160
1167
  imageData = UIImageJPEGRepresentation(image, 1.0);
1161
- #endif // !TARGET_OS_OSX
1162
1168
  }
1163
1169
 
1164
1170
  NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL
@@ -6,14 +6,6 @@
6
6
  */
7
7
 
8
8
  #import <React/RCTUIKit.h> // TODO(macOS GH#774)
9
- #if !TARGET_OS_OSX // [TODO(macOS GH#774)
10
- #import <UIKit/UIKit.h>
11
- #else // [TODO(macOS GH#774)
12
- typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
13
- UIImageRenderingModeAlwaysOriginal,
14
- UIImageRenderingModeAlwaysTemplate,
15
- };
16
- #endif // ]TODO(macOS GH#774)
17
9
  #import <React/RCTView.h>
18
10
  #import <React/RCTResizeMode.h>
19
11
 
@@ -212,8 +212,12 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
212
212
 
213
213
  - (BOOL)resignFirstResponder
214
214
  {
215
- BOOL success = [super resignFirstResponder];
215
+ if (self.selectable) {
216
+ self.selectedRange = NSMakeRange(NSNotFound, 0);
217
+ }
216
218
 
219
+ BOOL success = [super resignFirstResponder];
220
+
217
221
  if (success) {
218
222
  // Break undo coalescing when losing focus.
219
223
  [self breakUndoCoalescing];
@@ -436,13 +440,13 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
436
440
  {
437
441
  [super selectAll:sender];
438
442
 
439
- #if !TARGET_OS_OSX // TODO(macOS GH#774) For `selectTextOnFocus` prop, which isn't supported on macOS atm.
443
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
440
444
  // `selectAll:` does not work for UITextView when it's being called inside UITextView's delegate methods.
441
445
  dispatch_async(dispatch_get_main_queue(), ^{
442
446
  UITextRange *selectionRange = [self textRangeFromPosition:self.beginningOfDocument toPosition:self.endOfDocument];
443
447
  [self setSelectedTextRange:selectionRange notifyDelegate:NO];
444
448
  });
445
- #endif
449
+ #endif // TODO(macOS GH#774)
446
450
  }
447
451
 
448
452
  #pragma mark - Layout
@@ -379,7 +379,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)decoder)
379
379
  }
380
380
 
381
381
  if (_selectTextOnFocus) {
382
- [self.backedTextInputView selectAll:nil];
382
+ if ([self.backedTextInputView respondsToSelector:@selector(selectAll:)]) {
383
+ [self.backedTextInputView selectAll:nil];
384
+ }
385
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
386
+ } else {
387
+ [self.backedTextInputView setSelectedTextRange:NSMakeRange(NSNotFound, 0) notifyDelegate:NO];
388
+ #endif // ]TODO(macOS GH#774)
383
389
  }
384
390
 
385
391
  [_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus
@@ -56,11 +56,11 @@ RCT_REMAP_NOT_OSX_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButton
56
56
  RCT_REMAP_NOT_OSX_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) // TODO(macOS GH#774)
57
57
  RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL)
58
58
  RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
59
- RCT_EXPORT_NOT_OSX_VIEW_PROPERTY(clearTextOnFocus, BOOL) // TODO(macOS GH#774)
59
+ RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
60
60
  RCT_REMAP_NOT_OSX_VIEW_PROPERTY(keyboardType, backedTextInputView.keyboardType, UIKeyboardType) // TODO(macOS GH#774)
61
61
  RCT_EXPORT_NOT_OSX_VIEW_PROPERTY(showSoftInputOnFocus, BOOL) // TODO(macOS GH#774)
62
62
  RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber)
63
- RCT_EXPORT_NOT_OSX_VIEW_PROPERTY(selectTextOnFocus, BOOL) // TODO(macOS GH#774)
63
+ RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
64
64
  RCT_EXPORT_VIEW_PROPERTY(selection, RCTTextSelection)
65
65
  RCT_EXPORT_VIEW_PROPERTY(inputAccessoryViewID, NSString)
66
66
  RCT_EXPORT_VIEW_PROPERTY(textContentType, NSString)
@@ -206,8 +206,7 @@ enum : NSUInteger
206
206
  };
207
207
 
208
208
  // UIView/NSView.h
209
- enum : NSInteger
210
- {
209
+ typedef NS_ENUM(NSInteger, UIViewContentMode) {
211
210
  UIViewContentModeScaleAspectFill = NSViewLayerContentsPlacementScaleProportionallyToFill,
212
211
  UIViewContentModeScaleAspectFit = NSViewLayerContentsPlacementScaleProportionallyToFit,
213
212
  UIViewContentModeScaleToFill = NSViewLayerContentsPlacementScaleAxesIndependently,
@@ -322,6 +321,11 @@ NS_INLINE NSEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat botto
322
321
  // UIImage
323
322
  @compatibility_alias UIImage NSImage;
324
323
 
324
+ typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
325
+ UIImageRenderingModeAlwaysOriginal,
326
+ UIImageRenderingModeAlwaysTemplate,
327
+ };
328
+
325
329
  #ifdef __cplusplus
326
330
  extern "C"
327
331
  #endif
@@ -476,11 +480,21 @@ NS_INLINE CGRect CGRectValue(NSValue *value)
476
480
  // RCTUISlider
477
481
 
478
482
  #if !TARGET_OS_OSX // [TODO(macOS GH#774)
479
- #define RCTUISlider UISlider
483
+ typedef UISlider RCTUISlider;
480
484
  #else
481
485
  @interface RCTUISlider : NSSlider
486
+
487
+ @property (nonatomic, readonly) BOOL pressed;
488
+ @property (nonatomic, assign) float value;
489
+ @property (nonatomic, assign) float minimumValue;
490
+ @property (nonatomic, assign) float maximumValue;
491
+ @property (nonatomic, strong) NSColor *minimumTrackTintColor;
492
+ @property (nonatomic, strong) NSColor *maximumTrackTintColor;
493
+
494
+ - (void)setValue:(float)value animated:(BOOL)animated;
495
+
482
496
  @end
483
- #endif // ]TODO(macOS GH#774)n
497
+ #endif // ]TODO(macOS GH#774)
484
498
 
485
499
  // RCTUILabel
486
500
 
@@ -15,10 +15,6 @@ NSString* const RCTVersionPatch = @"patch";
15
15
  NSString* const RCTVersionPrerelease = @"prerelease";
16
16
 
17
17
 
18
- // [TODO(macOS GH#944)
19
- // Note: Be careful not to override these version numbers
20
- // when we merge upstream stable branches into main
21
- // TODO(macOS GH#944)]
22
18
  NSDictionary* RCTGetReactNativeVersion(void)
23
19
  {
24
20
  static NSDictionary* __rnVersion;
@@ -28,7 +24,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
28
24
  RCTVersionMajor: @(0),
29
25
  RCTVersionMinor: @(0),
30
26
  RCTVersionPatch: @(0),
31
- RCTVersionPrerelease: @"0c343d926",
27
+ RCTVersionPrerelease: @"0ce8502c1",
32
28
  };
33
29
  });
34
30
  return __rnVersion;
@@ -131,7 +131,7 @@ NSData *UIImagePNGRepresentation(NSImage *image) {
131
131
  NSData *UIImageJPEGRepresentation(NSImage *image, CGFloat compressionQuality) {
132
132
  return NSImageDataForFileType(image,
133
133
  NSBitmapImageFileTypeJPEG,
134
- @{NSImageCompressionFactor: @(1.0)});
134
+ @{NSImageCompressionFactor: @(compressionQuality)});
135
135
  }
136
136
 
137
137
  // UIBezierPath
@@ -551,7 +551,6 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
551
551
  self.verticalScrollElasticity = alwaysBounceVertical ? NSScrollElasticityAllowed : NSScrollElasticityNone;
552
552
  }
553
553
 
554
-
555
554
  @end
556
555
 
557
556
  BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
@@ -591,6 +590,18 @@ BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
591
590
 
592
591
  @end
593
592
 
593
+ // RCTUISlider
594
+
595
+ @implementation RCTUISlider {} // [TODO(macOS GH#774)
596
+
597
+ - (void)setValue:(float)value animated:(__unused BOOL)animated
598
+ {
599
+ self.animator.floatValue = value;
600
+ }
601
+
602
+ @end // ]TODO(macOS GH#774)
603
+
604
+
594
605
  // RCTUILabel
595
606
 
596
607
  @implementation RCTUILabel {} // [TODO(macOS GH#774)
@@ -38,12 +38,14 @@ using namespace facebook::react;
38
38
  return UIEdgeInsetsZero;
39
39
  }
40
40
 
41
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
41
42
  - (void)safeAreaInsetsDidChange
42
43
  {
43
44
  [super safeAreaInsetsDidChange];
44
45
 
45
46
  [self _updateStateIfNecessary];
46
47
  }
48
+ #endif // TODO(macOS GH#774)
47
49
 
48
50
  - (void)_updateStateIfNecessary
49
51
  {
@@ -52,10 +54,18 @@ using namespace facebook::react;
52
54
  }
53
55
 
54
56
  UIEdgeInsets insets = [self _safeAreaInsets];
57
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
55
58
  insets.left = RCTRoundPixelValue(insets.left);
56
59
  insets.top = RCTRoundPixelValue(insets.top);
57
60
  insets.right = RCTRoundPixelValue(insets.right);
58
61
  insets.bottom = RCTRoundPixelValue(insets.bottom);
62
+ #else // [TODO(macOS GH#774)
63
+ CGFloat scale = [[NSScreen mainScreen] backingScaleFactor];;
64
+ insets.left = RCTRoundPixelValue(insets.left, scale);
65
+ insets.top = RCTRoundPixelValue(insets.top, scale);
66
+ insets.right = RCTRoundPixelValue(insets.right, scale);
67
+ insets.bottom = RCTRoundPixelValue(insets.bottom, scale);
68
+ #endif // ]TODO(macOS GH#774)
59
69
 
60
70
  auto newPadding = RCTEdgeInsetsFromUIEdgeInsets(insets);
61
71
  auto threshold = 1.0 / RCTScreenScale() + 0.01; // Size of a pixel plus some small threshold.
@@ -50,10 +50,12 @@ using namespace facebook::react;
50
50
 
51
51
  _sliderView = [[RCTUISlider alloc] initWithFrame:self.bounds]; // TODO(macOS GH#774)
52
52
 
53
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
53
54
  [_sliderView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged];
54
55
  [_sliderView addTarget:self
55
56
  action:@selector(sliderTouchEnd:)
56
57
  forControlEvents:(UIControlEventTouchUpInside | UIControlEventTouchUpOutside | UIControlEventTouchCancel)];
58
+ #endif // TODO(macOS GH#774)
57
59
 
58
60
  _sliderView.value = (float)defaultProps->value;
59
61
 
@@ -79,6 +81,7 @@ using namespace facebook::react;
79
81
  self.maximumTrackImageCoordinator = nullptr;
80
82
  self.thumbImageCoordinator = nullptr;
81
83
 
84
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
82
85
  // Tint colors will be taken care of when props are set again - we just
83
86
  // need to make sure that image properties are reset here
84
87
  [_sliderView setMinimumTrackImage:nil forState:UIControlStateNormal];
@@ -87,6 +90,7 @@ using namespace facebook::react;
87
90
  if (_thumbImage) {
88
91
  [_sliderView setThumbImage:nil forState:UIControlStateNormal];
89
92
  }
93
+ #endif // TODO(macOS GH#774)
90
94
 
91
95
  _trackImage = nil;
92
96
  _minimumTrackImage = nil;
@@ -131,10 +135,12 @@ using namespace facebook::react;
131
135
  _sliderView.enabled = !newSliderProps.disabled;
132
136
  }
133
137
 
138
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
134
139
  // `thumbTintColor`
135
140
  if (oldSliderProps.thumbTintColor != newSliderProps.thumbTintColor) {
136
141
  _sliderView.thumbTintColor = RCTUIColorFromSharedColor(newSliderProps.thumbTintColor);
137
142
  }
143
+ #endif // TODO(macOS GH#774)
138
144
 
139
145
  // `minimumTrackTintColor`
140
146
  if (oldSliderProps.minimumTrackTintColor != newSliderProps.minimumTrackTintColor) {
@@ -237,6 +243,7 @@ using namespace facebook::react;
237
243
  _trackImage = trackImage;
238
244
  _minimumTrackImage = nil;
239
245
  _maximumTrackImage = nil;
246
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
240
247
  CGFloat width = trackImage.size.width / 2;
241
248
  UIImage *minimumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){0, width, 0, width}
242
249
  resizingMode:UIImageResizingModeStretch];
@@ -244,6 +251,7 @@ using namespace facebook::react;
244
251
  resizingMode:UIImageResizingModeStretch];
245
252
  [_sliderView setMinimumTrackImage:minimumTrackImage forState:UIControlStateNormal];
246
253
  [_sliderView setMaximumTrackImage:maximumTrackImage forState:UIControlStateNormal];
254
+ #endif // TODO(macOS GH#774)
247
255
  }
248
256
 
249
257
  - (void)setMinimumTrackImage:(UIImage *)minimumTrackImage
@@ -254,10 +262,12 @@ using namespace facebook::react;
254
262
 
255
263
  _trackImage = nil;
256
264
  _minimumTrackImage = minimumTrackImage;
265
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
257
266
  _minimumTrackImage =
258
267
  [_minimumTrackImage resizableImageWithCapInsets:(UIEdgeInsets){0, _minimumTrackImage.size.width, 0, 0}
259
268
  resizingMode:UIImageResizingModeStretch];
260
269
  [_sliderView setMinimumTrackImage:_minimumTrackImage forState:UIControlStateNormal];
270
+ #endif // TODO(macOS GH#774)
261
271
  }
262
272
 
263
273
  - (void)setMaximumTrackImage:(UIImage *)maximumTrackImage
@@ -268,10 +278,12 @@ using namespace facebook::react;
268
278
 
269
279
  _trackImage = nil;
270
280
  _maximumTrackImage = maximumTrackImage;
281
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
271
282
  _maximumTrackImage =
272
283
  [_maximumTrackImage resizableImageWithCapInsets:(UIEdgeInsets){0, 0, 0, _maximumTrackImage.size.width}
273
284
  resizingMode:UIImageResizingModeStretch];
274
285
  [_sliderView setMaximumTrackImage:_maximumTrackImage forState:UIControlStateNormal];
286
+ #endif // TODO(macOS GH#774)
275
287
  }
276
288
 
277
289
  - (void)setThumbImage:(UIImage *)thumbImage
@@ -281,7 +293,9 @@ using namespace facebook::react;
281
293
  }
282
294
 
283
295
  _thumbImage = thumbImage;
296
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
284
297
  [_sliderView setThumbImage:thumbImage forState:UIControlStateNormal];
298
+ #endif // TODO(macOS GH#774)
285
299
  }
286
300
 
287
301
  - (void)onChange:(RCTUISlider *)sender // TODO(macOS GH#774)
@@ -9,7 +9,11 @@
9
9
 
10
10
  NS_ASSUME_NONNULL_BEGIN
11
11
 
12
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
12
13
  @interface RCTAccessibilityElement : UIAccessibilityElement
14
+ #else // [TODO(macOS GH#774)
15
+ @interface RCTAccessibilityElement : NSAccessibilityElement
16
+ #endif // ]TODO(macOS GH#774)
13
17
 
14
18
  /*
15
19
  * Frame of the accessibility element in parent coordinate system.
@@ -9,6 +9,7 @@
9
9
 
10
10
  @implementation RCTAccessibilityElement
11
11
 
12
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
12
13
  - (CGRect)accessibilityFrame
13
14
  {
14
15
  RCTUIView *container = (RCTUIView *)self.accessibilityContainer; // TODO(macOS GH#774)
@@ -18,5 +19,6 @@
18
19
  return UIAccessibilityConvertFrameToScreenCoordinates(_frame, container);
19
20
  }
20
21
  }
22
+ #endif // TODO(macOS GH#774)
21
23
 
22
24
  @end
@@ -21,10 +21,12 @@
21
21
  frame:(CGRect)frame
22
22
  view:(RCTUIView *)view; // TODO(macOS GH#774)
23
23
 
24
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
24
25
  /*
25
26
  * Returns an array of `UIAccessibilityElement`s to be used for `UIAccessibilityContainer` implementation.
26
27
  */
27
28
  - (NSArray<UIAccessibilityElement *> *)accessibilityElements;
29
+ #endif // TODO(macOS GH#774)
28
30
 
29
31
  /**
30
32
  @abstract To make sure the provider is up to date.
@@ -21,7 +21,9 @@
21
21
  using namespace facebook::react;
22
22
 
23
23
  @implementation RCTParagraphComponentAccessibilityProvider {
24
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
24
25
  NSMutableArray<UIAccessibilityElement *> *_accessibilityElements;
26
+ #endif // TODO(macOS GH#774)
25
27
  AttributedString _attributedString;
26
28
  RCTTextLayoutManager *_layoutManager;
27
29
  ParagraphAttributes _paragraphAttributes;
@@ -45,6 +47,7 @@ using namespace facebook::react;
45
47
  return self;
46
48
  }
47
49
 
50
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
48
51
  - (NSArray<UIAccessibilityElement *> *)accessibilityElements
49
52
  {
50
53
  if (_accessibilityElements) {
@@ -171,6 +174,7 @@ using namespace facebook::react;
171
174
  _accessibilityElements = elements;
172
175
  return _accessibilityElements;
173
176
  }
177
+ #endif // TODO(macOS GH#774)
174
178
 
175
179
  - (BOOL)isUpToDate:(facebook::react::AttributedString)currentAttributedString
176
180
  {
@@ -8,9 +8,9 @@
8
8
  #import "RCTParagraphComponentView.h"
9
9
  #import "RCTParagraphComponentAccessibilityProvider.h"
10
10
 
11
- #if !TARGET_OS_OSX // [TODO(macOS GH#774)
11
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
12
12
  #import <MobileCoreServices/UTCoreTypes.h>
13
- #endif // ]TODO(macOS GH#774)
13
+ #endif // TODO(macOS GH#774)
14
14
 
15
15
  #import <react/renderer/components/text/ParagraphComponentDescriptor.h>
16
16
  #import <react/renderer/components/text/ParagraphProps.h>
@@ -32,7 +32,9 @@ using namespace facebook::react;
32
32
  ParagraphShadowNode::ConcreteState::Shared _state;
33
33
  ParagraphAttributes _paragraphAttributes;
34
34
  RCTParagraphComponentAccessibilityProvider *_accessibilityProvider;
35
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
35
36
  UILongPressGestureRecognizer *_longPressGestureRecognizer;
37
+ #endif // TODO(macOS GH#774)
36
38
  }
37
39
 
38
40
  - (instancetype)initWithFrame:(CGRect)frame
@@ -42,7 +44,9 @@ using namespace facebook::react;
42
44
  _props = defaultProps;
43
45
 
44
46
  self.opaque = NO;
47
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
45
48
  self.contentMode = UIViewContentModeRedraw;
49
+ #endif // TODO(macOS GH#774)
46
50
  }
47
51
 
48
52
  return self;
@@ -91,11 +95,13 @@ using namespace facebook::react;
91
95
  _paragraphAttributes = newParagraphProps.paragraphAttributes;
92
96
 
93
97
  if (newParagraphProps.isSelectable != oldParagraphProps.isSelectable) {
98
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
94
99
  if (newParagraphProps.isSelectable) {
95
100
  [self enableContextMenu];
96
101
  } else {
97
102
  [self disableContextMenu];
98
103
  }
104
+ #endif // TODO(macOS GH#774)
99
105
  }
100
106
 
101
107
  [super updateProps:props oldProps:oldProps];
@@ -151,6 +157,7 @@ using namespace facebook::react;
151
157
  return NO;
152
158
  }
153
159
 
160
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
154
161
  - (NSArray *)accessibilityElements
155
162
  {
156
163
  auto const &paragraphProps = *std::static_pointer_cast<ParagraphProps const>(_props);
@@ -186,6 +193,7 @@ using namespace facebook::react;
186
193
  {
187
194
  return [super accessibilityTraits] | UIAccessibilityTraitStaticText;
188
195
  }
196
+ #endif // TODO(macOS GH#774)
189
197
 
190
198
  #pragma mark - RCTTouchableComponentViewProtocol
191
199
 
@@ -220,6 +228,7 @@ using namespace facebook::react;
220
228
 
221
229
  #pragma mark - Context Menu
222
230
 
231
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
223
232
  - (void)enableContextMenu
224
233
  {
225
234
  _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
@@ -251,6 +260,7 @@ using namespace facebook::react;
251
260
  [menuController setMenuVisible:YES animated:YES];
252
261
  #endif
253
262
  }
263
+ #endif // TODO(macOS GH#774)
254
264
 
255
265
  - (BOOL)canBecomeFirstResponder
256
266
  {
@@ -258,6 +268,7 @@ using namespace facebook::react;
258
268
  return paragraphProps.isSelectable;
259
269
  }
260
270
 
271
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
261
272
  - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
262
273
  {
263
274
  auto const &paragraphProps = *std::static_pointer_cast<ParagraphProps const>(_props);
@@ -268,6 +279,7 @@ using namespace facebook::react;
268
279
 
269
280
  return [self.nextResponder canPerformAction:action withSender:sender];
270
281
  }
282
+ #endif // TODO(macOS GH#774)
271
283
 
272
284
  - (void)copy:(id)sender
273
285
  {
@@ -285,8 +297,14 @@ using namespace facebook::react;
285
297
 
286
298
  [item setObject:attributedText.string forKey:(id)kUTTypeUTF8PlainText];
287
299
 
300
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
288
301
  UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
289
302
  pasteboard.items = @[ item ];
303
+ #else // [TODO(macOS GH#774)
304
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
305
+ [pasteboard clearContents];
306
+ [pasteboard setData:rtf forType:NSPasteboardTypeRTFD];
307
+ #endif // ]TODO(macOS GH#774)
290
308
  }
291
309
 
292
310
  @end
@@ -38,7 +38,9 @@ using namespace facebook::react;
38
38
  static auto const defaultProps = std::make_shared<ViewProps const>();
39
39
  _props = defaultProps;
40
40
  _reactSubviews = [NSMutableArray new];
41
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
41
42
  self.multipleTouchEnabled = YES;
43
+ #endif // TODO(macOS GH#774)
42
44
  }
43
45
  return self;
44
46
  }
@@ -246,7 +248,11 @@ using namespace facebook::react;
246
248
  // `shouldRasterize`
247
249
  if (oldViewProps.shouldRasterize != newViewProps.shouldRasterize) {
248
250
  self.layer.shouldRasterize = newViewProps.shouldRasterize;
251
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
249
252
  self.layer.rasterizationScale = newViewProps.shouldRasterize ? [UIScreen mainScreen].scale : 1.0;
253
+ #else // [TODO(macOS GH#774)
254
+ self.layer.rasterizationScale = 1.0;
255
+ #endif // ]TODO(macOS GH#774)
250
256
  }
251
257
 
252
258
  // `pointerEvents`
@@ -287,6 +293,7 @@ using namespace facebook::react;
287
293
  self.nativeId = RCTNSStringFromStringNilIfEmpty(newViewProps.nativeId);
288
294
  }
289
295
 
296
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
290
297
  // `accessible`
291
298
  if (oldViewProps.accessible != newViewProps.accessible) {
292
299
  self.accessibilityElement.isAccessibilityElement = newViewProps.accessible;
@@ -351,6 +358,7 @@ using namespace facebook::react;
351
358
  self.accessibilityElement.accessibilityValue = nil;
352
359
  }
353
360
  }
361
+ #endif // TODO(macOS GH#774)
354
362
 
355
363
  // `testId`
356
364
  if (oldViewProps.testId != newViewProps.testId) {
@@ -695,6 +703,7 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS G
695
703
  auto const &props = *std::static_pointer_cast<ViewProps const>(_props);
696
704
 
697
705
  // Handle Switch.
706
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
698
707
  if ((self.accessibilityTraits & AccessibilityTraitSwitch) == AccessibilityTraitSwitch) {
699
708
  if (props.accessibilityState.checked == AccessibilityState::Checked) {
700
709
  return @"1";
@@ -702,6 +711,7 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS G
702
711
  return @"0";
703
712
  }
704
713
  }
714
+ #endif // TODO(macOS GH#774)
705
715
 
706
716
  // Handle states which haven't already been handled.
707
717
  if (props.accessibilityState.checked == AccessibilityState::Checked) {
@@ -340,7 +340,9 @@ static void RCTPerformMountInstructions(
340
340
  {
341
341
  if ([@"focus" isEqualToString:eventType]) {
342
342
  RCTUIView<RCTComponentViewProtocol> *componentView = [_componentViewRegistry findComponentViewWithTag:reactTag]; // TODO(macOS GH#774)
343
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
343
344
  UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, componentView);
345
+ #endif // TODO(macOS GH#774)
344
346
  }
345
347
  }
346
348
 
@@ -83,6 +83,7 @@ inline UIEdgeInsets RCTUIEdgeInsetsFromEdgeInsets(const facebook::react::EdgeIns
83
83
  return {edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right};
84
84
  }
85
85
 
86
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
86
87
  UIAccessibilityTraits const AccessibilityTraitSwitch = 0x20000000000001;
87
88
 
88
89
  inline UIAccessibilityTraits RCTUIAccessibilityTraitsFromAccessibilityTraits(
@@ -146,6 +147,7 @@ inline UIAccessibilityTraits RCTUIAccessibilityTraitsFromAccessibilityTraits(
146
147
  }
147
148
  return result;
148
149
  };
150
+ #endif // TODO(macOS GH#774)
149
151
 
150
152
  inline CATransform3D RCTCATransform3DFromTransformMatrix(const facebook::react::Transform &transformMatrix)
151
153
  {
@@ -66,10 +66,12 @@ using namespace facebook::react;
66
66
 
67
67
  [self _updateLayoutContext];
68
68
 
69
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
69
70
  [[NSNotificationCenter defaultCenter] addObserver:self
70
71
  selector:@selector(handleContentSizeCategoryDidChangeNotification:)
71
72
  name:UIContentSizeCategoryDidChangeNotification
72
73
  object:nil];
74
+ #endif // TODO(macOS GH#774)
73
75
  }
74
76
 
75
77
  return self;
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.0.0-0c343d926
1
+ VERSION_NAME=0.0.0-0ce8502c1
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -13,14 +13,10 @@ import com.facebook.react.common.MapBuilder;
13
13
 
14
14
  import java.util.Map;
15
15
 
16
- // [TODO(macOS GH#944)
17
- // Note: Be careful not to override these version numbers
18
- // when we merge upstream stable branches into main
19
- // TODO(macOS GH#944)]
20
16
  public class ReactNativeVersion {
21
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
22
18
  "major", 0,
23
19
  "minor", 0,
24
20
  "patch", 0,
25
- "prerelease", "0c343d926");
21
+ "prerelease", "0ce8502c1");
26
22
  }
@@ -14,15 +14,11 @@
14
14
 
15
15
  namespace facebook::react {
16
16
 
17
- // [TODO(macOS GH#944)
18
- // Note: Be careful not to override these version numbers
19
- // when we merge upstream stable branches into main
20
- // TODO(macOS GH#944)]
21
17
  constexpr struct {
22
18
  int32_t Major = 0;
23
19
  int32_t Minor = 0;
24
20
  int32_t Patch = 0;
25
- std::string_view Prerelease = "0c343d926";
21
+ std::string_view Prerelease = "0ce8502c1";
26
22
  } ReactNativeVersion;
27
23
 
28
24
  } // namespace facebook::react
@@ -57,7 +57,12 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
57
57
 
58
58
  CGSize size = [layoutManager usedRectForTextContainer:textContainer].size;
59
59
 
60
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
60
61
  size = (CGSize){RCTCeilPixelValue(size.width), RCTCeilPixelValue(size.height)};
62
+ #else // [TODO(macOS GH#774)
63
+ CGFloat scale = [[NSScreen mainScreen] backingScaleFactor];
64
+ size = (CGSize){RCTCeilPixelValue(size.width, scale), RCTCeilPixelValue(size.height, scale)};
65
+ #endif // ]TODO(macOS GH#774)
61
66
 
62
67
  __block auto attachments = TextMeasurement::Attachments{};
63
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.0.0-0c343d926",
3
+ "version": "0.0.0-0ce8502c1",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",
package/template/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4
- ruby '3.0.4'
4
+ ruby '3.0.5'
5
5
 
6
6
  gem 'cocoapods', '~> 1.11', '>= 1.11.2'
@@ -66,7 +66,7 @@ GEM
66
66
  i18n (1.12.0)
67
67
  concurrent-ruby (~> 1.0)
68
68
  json (2.6.3)
69
- minitest (5.16.3)
69
+ minitest (5.17.0)
70
70
  molinillo (0.8.0)
71
71
  nanaimo (0.3.0)
72
72
  nap (1.1.0)
@@ -94,7 +94,7 @@ DEPENDENCIES
94
94
  cocoapods (~> 1.11, >= 1.11.2)
95
95
 
96
96
  RUBY VERSION
97
- ruby 3.0.4p208
97
+ ruby 3.0.5p211
98
98
 
99
99
  BUNDLED WITH
100
- 2.3.24
100
+ 2.3.26
@@ -1 +1 @@
1
- 3.0.4
1
+ 3.0.5
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "react": "17.0.2",
15
15
  "react-native-macos": "1000.0.0",
16
- "react-native": "0.0.0-0c343d926"
16
+ "react-native": "0.0.0-0ce8502c1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@babel/core": "^7.12.9",