react-native-macos 0.77.0 → 0.77.2

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,7 +16,7 @@ const version: $ReadOnly<{
16
16
  }> = {
17
17
  major: 0,
18
18
  minor: 77,
19
- patch: 0,
19
+ patch: 2,
20
20
  prerelease: null,
21
21
  };
22
22
 
@@ -38,8 +38,13 @@ RCT_EXPORT_MODULE()
38
38
  _queue.maxConcurrentOperationCount = 2;
39
39
  }
40
40
 
41
- __weak __block NSBlockOperation *weakOp;
42
- __block NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock:^{
41
+ NSBlockOperation *op = [NSBlockOperation new];
42
+ __weak NSBlockOperation *weakOp = op;
43
+ [op addExecutionBlock:^{
44
+ NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
45
+ if (strongOp == nil || [strongOp isCancelled]) {
46
+ return;
47
+ }
43
48
  // Get mime type
44
49
  NSRange firstSemicolon = [request.URL.resourceSpecifier rangeOfString:@";"];
45
50
  NSString *mimeType =
@@ -51,18 +56,17 @@ RCT_EXPORT_MODULE()
51
56
  expectedContentLength:-1
52
57
  textEncodingName:nil];
53
58
 
54
- [delegate URLRequest:weakOp didReceiveResponse:response];
59
+ [delegate URLRequest:strongOp didReceiveResponse:response];
55
60
 
56
61
  // Load data
57
62
  NSError *error;
58
63
  NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
59
64
  if (data) {
60
- [delegate URLRequest:weakOp didReceiveData:data];
65
+ [delegate URLRequest:strongOp didReceiveData:data];
61
66
  }
62
- [delegate URLRequest:weakOp didCompleteWithError:error];
67
+ [delegate URLRequest:strongOp didCompleteWithError:error];
63
68
  }];
64
69
 
65
- weakOp = op;
66
70
  [_queue addOperation:op];
67
71
  return op;
68
72
  }
@@ -46,14 +46,19 @@ RCT_EXPORT_MODULE()
46
46
  _fileQueue.maxConcurrentOperationCount = 4;
47
47
  }
48
48
 
49
- __weak __block NSBlockOperation *weakOp;
50
- __block NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock:^{
49
+ NSBlockOperation *op = [NSBlockOperation new];
50
+ __weak NSBlockOperation *weakOp = op;
51
+ [op addExecutionBlock:^{
52
+ NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
53
+ if (strongOp == nil || [strongOp isCancelled]) {
54
+ return;
55
+ }
51
56
  // Get content length
52
57
  NSError *error = nil;
53
58
  NSFileManager *fileManager = [NSFileManager new];
54
59
  NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:request.URL.path error:&error];
55
60
  if (!fileAttributes) {
56
- [delegate URLRequest:weakOp didCompleteWithError:error];
61
+ [delegate URLRequest:strongOp didCompleteWithError:error];
57
62
  return;
58
63
  }
59
64
 
@@ -70,17 +75,16 @@ RCT_EXPORT_MODULE()
70
75
  expectedContentLength:[fileAttributes[NSFileSize] ?: @-1 integerValue]
71
76
  textEncodingName:nil];
72
77
 
73
- [delegate URLRequest:weakOp didReceiveResponse:response];
78
+ [delegate URLRequest:strongOp didReceiveResponse:response];
74
79
 
75
80
  // Load data
76
81
  NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
77
82
  if (data) {
78
- [delegate URLRequest:weakOp didReceiveData:data];
83
+ [delegate URLRequest:strongOp didReceiveData:data];
79
84
  }
80
- [delegate URLRequest:weakOp didCompleteWithError:error];
85
+ [delegate URLRequest:strongOp didCompleteWithError:error];
81
86
  }];
82
87
 
83
- weakOp = op;
84
88
  [_fileQueue addOperation:op];
85
89
  return op;
86
90
  }
@@ -84,7 +84,11 @@ const Platform: PlatformType = {
84
84
  },
85
85
  select: <T>(spec: PlatformSelectSpec<T>): T =>
86
86
  // $FlowFixMe[incompatible-return]
87
- 'ios' in spec ? spec.macos : 'native' in spec ? spec.native : spec.default,
87
+ 'macos' in spec
88
+ ? spec.macos
89
+ : 'native' in spec
90
+ ? spec.native
91
+ : spec.default,
88
92
  };
89
93
 
90
94
  module.exports = Platform;
@@ -128,8 +128,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
128
128
  #else // [macOS
129
129
  // -[NSView hitTest:] takes coordinates in a view's superview coordinate system.
130
130
  // The assumption here is that a RCTUIView/RCTSurfaceView will always have a superview.
131
- CGPoint touchLocation = [self.view.superview convertPoint:touch.locationInWindow fromView:nil];
132
- NSView *targetView = [self.view hitTest:touchLocation];
131
+ NSView *superview = [[self view] superview];
132
+ const CGPoint touchLocationInSuperview = [superview convertPoint:touch.locationInWindow fromView:nil];
133
+ NSView *targetView = [self.view hitTest:touchLocationInSuperview];
133
134
  // Don't record clicks on scrollbars.
134
135
  if ([targetView isKindOfClass:[NSScroller class]]) {
135
136
  continue;
@@ -148,8 +149,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
148
149
  } else {
149
150
  _shouldSendMouseUpOnSystemBehalf = NO;
150
151
  }
151
- touchLocation = [targetView convertPoint:touchLocation fromView:self.view.superview];
152
-
152
+
153
153
  while (targetView) {
154
154
  BOOL isUserInteractionEnabled = NO;
155
155
  if ([((RCTUIView*)targetView) respondsToSelector:@selector(isUserInteractionEnabled)]) { // [macOS]
@@ -161,7 +161,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)coder)
161
161
  targetView = targetView.superview;
162
162
  }
163
163
 
164
- NSNumber *reactTag = [targetView reactTagAtPoint:touchLocation];
164
+ const CGPoint touchLocationInSelf = [targetView convertPoint:touchLocationInSuperview fromView:self.view.superview];
165
+ NSNumber *reactTag = [targetView reactTagAtPoint:touchLocationInSelf];
165
166
  BOOL isUserInteractionEnabled = NO;
166
167
  if ([((RCTUIView*)targetView) respondsToSelector:@selector(isUserInteractionEnabled)]) { // [macOS]
167
168
  isUserInteractionEnabled = ((RCTUIView*)targetView).isUserInteractionEnabled; // [macOS]
@@ -484,7 +484,10 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
484
484
 
485
485
  NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
486
486
  {
487
- return [view hitTest:point];
487
+ // [macOS IMPORTANT -- point is in local coordinate space, but OSX expects super coordinate space for hitTest:
488
+ NSView *superview = [view superview];
489
+ NSPoint pointInSuperview = superview != nil ? [view convertPoint:point toView:superview] : point;
490
+ return [view hitTest:pointInSuperview];
488
491
  }
489
492
 
490
493
  BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view);
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(77),
26
- RCTVersionPatch: @(0),
26
+ RCTVersionPatch: @(2),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -454,7 +454,10 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
454
454
 
455
455
  - (NSView *)hitTest:(NSPoint)point
456
456
  {
457
- return [self hitTest:NSPointToCGPoint(point) withEvent:nil];
457
+ // IMPORTANT point is passed in super coordinates by OSX, but expected to be passed in local coordinates
458
+ NSView *superview = [self superview];
459
+ NSPoint pointInSelf = superview != nil ? [self convertPoint:point fromView:superview] : point;
460
+ return [self hitTest:pointInSelf withEvent:nil];
458
461
  }
459
462
 
460
463
  - (BOOL)wantsUpdateLayer
@@ -505,7 +508,11 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
505
508
 
506
509
  - (NSView *)hitTest:(CGPoint)point withEvent:(__unused UIEvent *)event
507
510
  {
508
- return self.userInteractionEnabled ? [super hitTest:NSPointFromCGPoint(point)] : nil;
511
+ // [macOS
512
+ // IMPORTANT point is expected to be passed in local coordinates, but OSX expects point to be super
513
+ NSView *superview = [self superview];
514
+ NSPoint pointInSuperview = superview != nil ? [self convertPoint:point toView:superview] : point;
515
+ return self.userInteractionEnabled ? [super hitTest:pointInSuperview] : nil;
509
516
  }
510
517
 
511
518
  - (BOOL)pointInside:(CGPoint)point withEvent:(__unused UIEvent *)event
@@ -680,17 +680,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
680
680
  }
681
681
 
682
682
  for (RCTUIView *subview in [self.subviews reverseObjectEnumerator]) { // [macOS]
683
- #if !TARGET_OS_OSX // [macOS]
684
683
  RCTUIView *hitView = [subview hitTest:[subview convertPoint:point fromView:self] withEvent:event]; // [macOS]
685
- #else // [macOS
686
- // Native macOS views require the point to be in the super view coordinate space for hit testing.
687
- CGPoint hitTestPoint = point;
688
- // Fabric components use the target view coordinate space for hit testing
689
- if ([subview isKindOfClass:[RCTViewComponentView class]]) {
690
- hitTestPoint = [subview convertPoint:point fromView:self];
691
- }
692
- RCTUIView *hitView = [subview hitTest:hitTestPoint withEvent:event]; // [macOS]
693
- #endif // macOS]
694
684
  if (hitView) {
695
685
  return hitView;
696
686
  }
@@ -1533,4 +1523,4 @@ Class<RCTComponentViewProtocol> RCTViewCls(void);
1533
1523
  Class<RCTComponentViewProtocol> RCTViewCls(void)
1534
1524
  {
1535
1525
  return RCTViewComponentView.class;
1536
- }
1526
+ }
@@ -251,18 +251,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
251
251
  // of the hit view will return YES from -pointInside:withEvent:). See:
252
252
  // - https://developer.apple.com/library/ios/qa/qa2013/qa1812.html
253
253
  for (RCTUIView *subview in [sortedSubviews reverseObjectEnumerator]) { // [macOS]
254
- CGPoint pointForHitTest = CGPointZero; // [macOS
255
- #if !TARGET_OS_OSX // [macOS]
256
- pointForHitTest = [subview convertPoint:point fromView:self];
257
- #else // [macOS
258
- // Paper and Fabric components use the target view coordinate space for hit testing
259
- if ([subview isKindOfClass:[RCTView class]] || [subview respondsToSelector:@selector(updateProps:oldProps:)]) {
260
- pointForHitTest = [subview convertPoint:point fromView:self];
261
- } else {
262
- // Native macOS views require the point to be in the super view coordinate space for hit testing.
263
- pointForHitTest = point;
264
- }
265
- #endif // macOS]
254
+ CGPoint pointForHitTest = [subview convertPoint:point fromView:self];
266
255
  hitSubview = RCTUIViewHitTestWithEvent(subview, pointForHitTest, event); // macOS]
267
256
  if (hitSubview != nil) {
268
257
  break;
@@ -1653,4 +1642,4 @@ NSMutableDictionary<NSNumber *, NSNumber *> *GetEventDispatchStateDictionary(NSE
1653
1642
  }
1654
1643
  #endif // macOS]
1655
1644
 
1656
- @end
1645
+ @end
@@ -562,10 +562,13 @@ static __weak RCTPlatformView *_pendingFocusView; // [macOS]
562
562
 
563
563
  // [macOS
564
564
  #pragma mark - Hit testing
565
- #if TARGET_OS_OSX
565
+ #if TARGET_OS_OSX
566
+ // IMPORTANT -- point is in local coordinate space, unlike the hitTest: version from OSX which is in super's coordinate space
566
567
  - (RCTPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
567
568
  {
568
- return [self hitTest:point];
569
+ NSView *superview = [self superview];
570
+ NSPoint pointInSuper = superview != nil ? [self convertPoint:point toView:superview] : point;
571
+ return [self hitTest:pointInSuper];
569
572
  }
570
573
  #endif // macOS]
571
574
 
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.77.0
1
+ VERSION_NAME=0.77.2
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", 77,
20
- "patch", 0,
20
+ "patch", 2,
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 = 77;
20
- int32_t Patch = 0;
20
+ int32_t Patch = 2;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
@@ -149,7 +149,6 @@ static UIFont *RCTDefaultFontWithFontProperties(RCTFontProperties fontProperties
149
149
  #if TARGET_OS_OSX // [macOS
150
150
  NSArray<NSString *> *RCTFontNamesForFamilyName(NSString *familyName) {
151
151
  NSArray<NSArray *> *fontMembers = [[NSFontManager sharedFontManager] availableMembersOfFontFamily:familyName];
152
- NSLog(@"SAAD");
153
152
  NSMutableArray<NSString *> *fontNames = [NSMutableArray array];
154
153
 
155
154
  for (NSArray *fontMember in fontMembers) {
@@ -107,9 +107,9 @@ inline static NSUnderlineStyle RCTNSUnderlineStyleFromTextDecorationStyle(
107
107
  case facebook::react::TextDecorationStyle::Double:
108
108
  return NSUnderlineStyleDouble;
109
109
  case facebook::react::TextDecorationStyle::Dashed:
110
- return NSUnderlinePatternDash | NSUnderlineStyleSingle;
110
+ return NSUnderlineStylePatternDash | NSUnderlineStyleSingle; // [macOS]
111
111
  case facebook::react::TextDecorationStyle::Dotted:
112
- return NSUnderlinePatternDot | NSUnderlineStyleSingle;
112
+ return NSUnderlineStylePatternDot | NSUnderlineStyleSingle; // [macOS]
113
113
  }
114
114
  }
115
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.77.0",
3
+ "version": "0.77.2",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -110,7 +110,7 @@
110
110
  },
111
111
  "dependencies": {
112
112
  "@jest/create-cache-key-function": "^29.6.3",
113
- "@react-native-mac/virtualized-lists": "0.77.0",
113
+ "@react-native-mac/virtualized-lists": "0.77.2",
114
114
  "@react-native/assets-registry": "0.77.0",
115
115
  "@react-native/codegen": "0.77.0",
116
116
  "@react-native/community-cli-plugin": "0.77.0",
@@ -189,6 +189,6 @@ class NewArchitectureHelper
189
189
  end
190
190
 
191
191
  def self.new_arch_enabled
192
- return ENV["RCT_NEW_ARCH_ENABLED"] == nil || ENV["RCT_NEW_ARCH_ENABLED"] == "1"
192
+ return ENV["RCT_NEW_ARCH_ENABLED"] == "1" # [macOS] Disable Fabric by default till macOS supports it
193
193
  end
194
194
  end
@@ -1,13 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @flow strict-local
9
- */
10
-
11
- import NativeAddressSanitizerCrash from './NativeAddressSanitizerCrash';
12
-
13
- module.exports = NativeAddressSanitizerCrash;
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict-local
8
- * @format
9
- */
10
-
11
- import type {TurboModule} from '../TurboModule/RCTExport';
12
-
13
- import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
14
-
15
- export interface Spec extends TurboModule {}
16
-
17
- export default (TurboModuleRegistry.get<Spec>(
18
- 'RCTAddressSanitizerCrash',
19
- ): ?Spec);
@@ -1,12 +0,0 @@
1
- /*
2
- *
3
- * This source code is licensed under the MIT license found in the
4
- * LICENSE file in the root directory of this source tree.
5
- */
6
-
7
- #import <React/RCTUIKit.h>
8
- #import <React/RCTBridge.h>
9
-
10
- @interface RCTAddressSanitizerCrashManager : NSObject <RCTBridgeModule>
11
-
12
- @end
@@ -1,18 +0,0 @@
1
- //
2
- // RCTAddressSanitizerCrashManager.mm
3
- // Pods
4
- //
5
-
6
- #import "RCTAddressSanitizerCrashManager.h"
7
-
8
- @implementation RCTAddressSanitizerCrashManager
9
-
10
- RCT_EXPORT_MODULE(ASANCrash)
11
-
12
- RCT_EXPORT_METHOD(invokeMemoryCrash) {
13
- char *s = (char*)malloc(100);
14
- free(s);
15
- strcpy(s, "Hello world!"); // AddressSanitizer: heap-use-after-free
16
- }
17
-
18
- @end