react-native-macos 0.0.0-96be39d8c → 0.0.0-96f71c939

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 (111) hide show
  1. package/Libraries/Components/ScrollView/ScrollView.js +11 -45
  2. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  3. package/Libraries/Components/TextInput/TextInput.js +79 -1
  4. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  5. package/Libraries/Components/View/ViewPropTypes.js +10 -6
  6. package/Libraries/Core/ReactNativeVersion.js +1 -1
  7. package/Libraries/Image/RCTImageView.mm +14 -10
  8. package/Libraries/Lists/FlatList.js +25 -2
  9. package/Libraries/Lists/VirtualizedList.js +118 -113
  10. package/Libraries/Lists/VirtualizedSectionList.js +9 -5
  11. package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
  12. package/Libraries/Text/RCTTextAttributes.h +2 -0
  13. package/Libraries/Text/RCTTextAttributes.m +9 -0
  14. package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
  15. package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
  16. package/Libraries/Text/Text/RCTTextView.m +123 -54
  17. package/Libraries/Text/Text.js +0 -8
  18. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
  19. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -4
  20. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
  21. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
  22. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +69 -2
  23. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +7 -1
  24. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
  25. package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
  26. package/Libraries/Text/TextInput/RCTBaseTextInputView.h +4 -1
  27. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +97 -2
  28. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +6 -1
  29. package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
  30. package/Libraries/Text/TextNativeComponent.js +2 -0
  31. package/Libraries/Text/TextProps.js +29 -0
  32. package/Libraries/Types/CoreEventTypes.js +0 -1
  33. package/React/Base/RCTAssert.h +30 -15
  34. package/React/Base/RCTAssert.m +59 -19
  35. package/React/Base/RCTBridge.m +5 -3
  36. package/React/Base/RCTConstants.h +6 -0
  37. package/React/Base/RCTConstants.m +15 -0
  38. package/React/Base/RCTConvert.m +7 -4
  39. package/React/Base/RCTEventDispatcherProtocol.h +5 -0
  40. package/React/Base/RCTTouchHandler.m +4 -0
  41. package/React/Base/RCTUIKit.h +8 -13
  42. package/React/Base/RCTUtils.m +6 -3
  43. package/React/Base/RCTVersion.m +1 -1
  44. package/React/Base/macOS/RCTUIKit.m +33 -0
  45. package/React/CoreModules/RCTEventDispatcher.mm +6 -1
  46. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  47. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h +1 -0
  48. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +69 -19
  49. package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +2 -1
  50. package/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +0 -1
  51. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
  52. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +35 -9
  53. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +9 -1
  54. package/React/Fabric/Mounting/RCTComponentViewFactory.mm +12 -3
  55. package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
  56. package/React/Fabric/Mounting/RCTMountingManager.mm +11 -9
  57. package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.h +5 -3
  58. package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.mm +10 -8
  59. package/React/Fabric/Mounting/RCTMountingTransactionObserving.h +5 -3
  60. package/React/Fabric/RCTConversions.h +9 -1
  61. package/React/Fabric/RCTLocalizationProvider.mm +10 -4
  62. package/React/Fabric/RCTScheduler.h +7 -0
  63. package/React/Fabric/RCTScheduler.mm +15 -0
  64. package/React/Fabric/RCTSurfacePresenter.h +2 -0
  65. package/React/Fabric/RCTSurfacePresenter.mm +45 -21
  66. package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
  67. package/React/Modules/RCTUIManager.m +4 -2
  68. package/React/React-RCTFabric.podspec +1 -1
  69. package/React/Views/RCTActivityIndicatorView.m +2 -1
  70. package/React/Views/RCTView.h +1 -0
  71. package/React/Views/RCTView.m +51 -17
  72. package/React/Views/RCTViewKeyboardEvent.m +9 -1
  73. package/React/Views/RCTViewManager.m +5 -14
  74. package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
  75. package/React/Views/ScrollView/RCTScrollContentView.m +6 -0
  76. package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
  77. package/React/Views/ScrollView/RCTScrollView.h +2 -1
  78. package/React/Views/ScrollView/RCTScrollView.m +65 -63
  79. package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
  80. package/React/Views/UIView+React.h +2 -0
  81. package/React/Views/UIView+React.m +22 -13
  82. package/ReactAndroid/gradle.properties +1 -1
  83. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  84. package/ReactCommon/React-Fabric.podspec +1 -1
  85. package/ReactCommon/React-rncore.podspec +1 -1
  86. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  87. package/ReactCommon/react/debug/react_native_assert.h +1 -1
  88. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +5 -0
  89. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +4 -2
  90. package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
  91. package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
  92. package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
  93. package/ReactCommon/react/renderer/core/EventListener.h +44 -0
  94. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  95. package/ReactCommon/react/renderer/mounting/StubViewTree.cpp +1 -1
  96. package/ReactCommon/react/renderer/mounting/TelemetryController.cpp +6 -9
  97. package/ReactCommon/react/renderer/mounting/TelemetryController.h +7 -7
  98. package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +3 -2
  99. package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h +7 -1
  100. package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +18 -0
  101. package/ReactCommon/react/renderer/scheduler/Scheduler.h +9 -0
  102. package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
  103. package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
  104. package/package.json +1 -1
  105. package/scripts/generate-artifacts.js +21 -17
  106. package/scripts/react_native_pods.rb +0 -3
  107. package/template/Gemfile.lock +4 -4
  108. package/template/package.json +1 -1
  109. package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp +0 -12
  110. package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h +0 -32
  111. package/third-party-podspecs/boost-for-react-native.podspec +0 -20
@@ -436,6 +436,15 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
436
436
 
437
437
  @implementation RCTUIScrollView // TODO(macOS ISS#3536887)
438
438
 
439
+ - (instancetype)initWithFrame:(CGRect)frame
440
+ {
441
+ if (self = [super initWithFrame:frame]) {
442
+ self.scrollEnabled = YES;
443
+ }
444
+
445
+ return self;
446
+ }
447
+
439
448
  - (void)setEnableFocusRing:(BOOL)enableFocusRing {
440
449
  if (_enableFocusRing != enableFocusRing) {
441
450
  _enableFocusRing = enableFocusRing;
@@ -542,6 +551,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
542
551
  self.verticalScrollElasticity = alwaysBounceVertical ? NSScrollElasticityAllowed : NSScrollElasticityNone;
543
552
  }
544
553
 
554
+
545
555
  @end
546
556
 
547
557
  BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
@@ -557,3 +567,26 @@ BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
557
567
 
558
568
  return clipsToBounds;
559
569
  }
570
+
571
+ @implementation RCTClipView
572
+
573
+ - (instancetype)initWithFrame:(NSRect)frameRect
574
+ {
575
+ if (self = [super initWithFrame:frameRect]) {
576
+ self.constrainScrolling = NO;
577
+ self.drawsBackground = NO;
578
+ }
579
+
580
+ return self;
581
+ }
582
+
583
+ - (NSRect)constrainBoundsRect:(NSRect)proposedBounds
584
+ {
585
+ if (self.constrainScrolling) {
586
+ return NSMakeRect(0, 0, 0, 0);
587
+ }
588
+
589
+ return [super constrainBoundsRect:proposedBounds];
590
+ }
591
+
592
+ @end
@@ -110,7 +110,7 @@ RCT_EXPORT_MODULE()
110
110
  [self sendEvent:event];
111
111
  }
112
112
 
113
- - (void)sendEvent:(id<RCTEvent>)event
113
+ - (void)notifyObserversOfEvent:(id<RCTEvent>)event
114
114
  {
115
115
  [_observersLock lock];
116
116
 
@@ -119,6 +119,11 @@ RCT_EXPORT_MODULE()
119
119
  }
120
120
 
121
121
  [_observersLock unlock];
122
+ }
123
+
124
+ - (void)sendEvent:(id<RCTEvent>)event
125
+ {
126
+ [self notifyObserversOfEvent:event];
122
127
 
123
128
  [_eventQueueLock lock];
124
129
 
@@ -176,7 +176,7 @@ RCT_EXPORT_MODULE()
176
176
  {
177
177
  if (!_devMenuItem) {
178
178
  __weak __typeof__(self) weakSelf = self;
179
- __weak RCTDevSettings *devSettings = [self->_moduleRegistry moduleForName:"DevSettings"];
179
+ __weak RCTDevSettings *devSettings = [[self bridge] devSettings]; // TODO(macOS GH#774)
180
180
  if (devSettings.isPerfMonitorShown) {
181
181
  [weakSelf show];
182
182
  }
@@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
19
19
  + (BOOL)isSupported:(NSString *)componentName;
20
20
 
21
21
  + (void)supportLegacyViewManagerWithName:(NSString *)componentName;
22
+ + (void)supportLegacyViewManagersWithPrefix:(NSString *)prefix;
22
23
 
23
24
  @end
24
25
 
@@ -8,6 +8,7 @@
8
8
  #import "RCTLegacyViewManagerInteropComponentView.h"
9
9
 
10
10
  #import <React/RCTAssert.h>
11
+ #import <React/RCTConstants.h>
11
12
  #import <React/UIView+React.h>
12
13
  #import <react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.h>
13
14
  #import <react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropViewProps.h>
@@ -24,17 +25,17 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
24
25
  NSMutableArray<UIView *> *_viewsToBeUnmounted;
25
26
  RCTLegacyViewManagerInteropCoordinatorAdapter *_adapter;
26
27
  LegacyViewManagerInteropShadowNode::ConcreteState::Shared _state;
28
+ BOOL _hasInvokedForwardingWarning;
27
29
  }
28
30
 
29
31
  - (instancetype)initWithFrame:(CGRect)frame
30
32
  {
31
33
  if (self = [super initWithFrame:frame]) {
32
- RCTWarnNotAllowedForNewArchitecture(
33
- self, @"ViewManager with interop layer is not allowed in the new architecture.");
34
34
  static const auto defaultProps = std::make_shared<const LegacyViewManagerInteropViewProps>();
35
35
  _props = defaultProps;
36
36
  _viewsToBeMounted = [NSMutableArray new];
37
37
  _viewsToBeUnmounted = [NSMutableArray new];
38
+ _hasInvokedForwardingWarning = NO;
38
39
  }
39
40
 
40
41
  return self;
@@ -51,6 +52,41 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
51
52
  return result;
52
53
  }
53
54
 
55
+ - (RCTLegacyViewManagerInteropCoordinator *)_coordinator
56
+ {
57
+ if (_state != nullptr) {
58
+ const auto &state = _state->getData();
59
+ return unwrapManagedObject(state.coordinator);
60
+ } else {
61
+ return nil;
62
+ }
63
+ }
64
+
65
+ - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
66
+ {
67
+ const auto &state = _state->getData();
68
+ RCTLegacyViewManagerInteropCoordinator *coordinator = unwrapManagedObject(state.coordinator);
69
+ return coordinator.componentViewName;
70
+ }
71
+
72
+ #pragma mark - Method forwarding
73
+
74
+ - (void)forwardInvocation:(NSInvocation *)anInvocation
75
+ {
76
+ if (!_hasInvokedForwardingWarning) {
77
+ _hasInvokedForwardingWarning = YES;
78
+ NSLog(
79
+ @"Invoked unsupported method on RCTLegacyViewManagerInteropComponentView. Resulting to noop instead of a crash.");
80
+ }
81
+ }
82
+
83
+ - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
84
+ {
85
+ return [super methodSignatureForSelector:aSelector] ?: [self.contentView methodSignatureForSelector:aSelector];
86
+ }
87
+
88
+ #pragma mark - Supported ViewManagers
89
+
54
90
  + (NSMutableSet<NSString *> *)supportedViewManagers
55
91
  {
56
92
  static NSMutableSet<NSString *> *supported = [NSMutableSet setWithObjects:@"DatePicker",
@@ -65,31 +101,39 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
65
101
  return supported;
66
102
  }
67
103
 
68
- + (BOOL)isSupported:(NSString *)componentName
104
+ + (NSMutableSet<NSString *> *)supportedViewManagersPrefixes
69
105
  {
70
- return [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] containsObject:componentName];
106
+ static NSMutableSet<NSString *> *supported = [NSMutableSet new];
107
+ return supported;
71
108
  }
72
109
 
73
- + (void)supportLegacyViewManagerWithName:(NSString *)componentName
110
+ + (BOOL)isSupported:(NSString *)componentName
74
111
  {
75
- [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] addObject:componentName];
112
+ // Step 1: check if ViewManager with specified name is supported.
113
+ BOOL isComponentNameSupported =
114
+ [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] containsObject:componentName];
115
+ if (isComponentNameSupported) {
116
+ return YES;
117
+ }
118
+
119
+ // Step 2: check if component has supported prefix.
120
+ for (NSString *item in [RCTLegacyViewManagerInteropComponentView supportedViewManagersPrefixes]) {
121
+ if ([componentName hasPrefix:item]) {
122
+ return YES;
123
+ }
124
+ }
125
+
126
+ return NO;
76
127
  }
77
128
 
78
- - (RCTLegacyViewManagerInteropCoordinator *)coordinator
129
+ + (void)supportLegacyViewManagersWithPrefix:(NSString *)prefix
79
130
  {
80
- if (_state != nullptr) {
81
- const auto &state = _state->getData();
82
- return unwrapManagedObject(state.coordinator);
83
- } else {
84
- return nil;
85
- }
131
+ [[RCTLegacyViewManagerInteropComponentView supportedViewManagersPrefixes] addObject:prefix];
86
132
  }
87
133
 
88
- - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
134
+ + (void)supportLegacyViewManagerWithName:(NSString *)componentName
89
135
  {
90
- const auto &state = _state->getData();
91
- RCTLegacyViewManagerInteropCoordinator *coordinator = unwrapManagedObject(state.coordinator);
92
- return coordinator.componentViewName;
136
+ [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] addObject:componentName];
93
137
  }
94
138
 
95
139
  #pragma mark - RCTComponentViewProtocol
@@ -101,6 +145,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
101
145
  [_viewsToBeUnmounted removeAllObjects];
102
146
  _state.reset();
103
147
  self.contentView = nil;
148
+ _hasInvokedForwardingWarning = NO;
104
149
  [super prepareForRecycle];
105
150
  }
106
151
 
@@ -136,7 +181,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
136
181
  [super finalizeUpdates:updateMask];
137
182
 
138
183
  if (!_adapter) {
139
- _adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:self.coordinator
184
+ _adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:[self _coordinator]
140
185
  reactTag:self.tag];
141
186
  __weak __typeof(self) weakSelf = self;
142
187
  _adapter.eventInterceptor = ^(std::string eventName, folly::dynamic event) {
@@ -153,7 +198,12 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
153
198
  for (NSDictionary *mountInstruction in _viewsToBeMounted) {
154
199
  NSNumber *index = mountInstruction[kRCTLegacyInteropChildIndexKey];
155
200
  UIView *childView = mountInstruction[kRCTLegacyInteropChildComponentKey];
156
- [_adapter.paperView insertReactSubview:childView atIndex:index.integerValue];
201
+ if ([childView isKindOfClass:[RCTLegacyViewManagerInteropComponentView class]]) {
202
+ UIView *target = ((RCTLegacyViewManagerInteropComponentView *)childView).contentView;
203
+ [_adapter.paperView insertReactSubview:target atIndex:index.integerValue];
204
+ } else {
205
+ [_adapter.paperView insertReactSubview:childView atIndex:index.integerValue];
206
+ }
157
207
  }
158
208
 
159
209
  [_viewsToBeMounted removeAllObjects];
@@ -192,7 +192,8 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct(
192
192
 
193
193
  #pragma mark - RCTMountingTransactionObserving
194
194
 
195
- - (void)mountingTransactionWillMountWithMetadata:(MountingTransactionMetadata const &)metadata
195
+ - (void)mountingTransactionWillMount:(MountingTransaction const &)transaction
196
+ withSurfaceTelemetry:(facebook::react::SurfaceTelemetry const &)surfaceTelemetry
196
197
  {
197
198
  _modalContentsSnapshot = [self.viewController.view snapshotViewAfterScreenUpdates:NO];
198
199
  }
@@ -24,7 +24,6 @@ using namespace facebook::react;
24
24
  if (self = [super initWithFrame:frame]) {
25
25
  static auto const defaultProps = std::make_shared<SafeAreaViewProps const>();
26
26
  _props = defaultProps;
27
- self.clipsToBounds = YES;
28
27
  }
29
28
 
30
29
  return self;
@@ -25,7 +25,7 @@ using namespace facebook::react;
25
25
 
26
26
  @implementation RCTPullToRefreshViewComponentView {
27
27
  UIRefreshControl *_refreshControl;
28
- RCTScrollViewComponentView *_scrollViewComponentView;
28
+ RCTScrollViewComponentView *__weak _scrollViewComponentView;
29
29
  }
30
30
 
31
31
  - (instancetype)initWithFrame:(CGRect)frame
@@ -52,7 +52,11 @@ static UIScrollViewIndicatorStyle RCTUIScrollViewIndicatorStyleFromProps(ScrollV
52
52
  }
53
53
  }
54
54
 
55
- static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteger tag)
55
+ // Once Fabric implements proper NativeAnimationDriver, this should be removed.
56
+ // This is just a workaround to allow animations based on onScroll event.
57
+ // This is only used to animate sticky headers in ScrollViews, and only the contentOffset and tag is used.
58
+ // TODO: T116850910 [Fabric][iOS] Make Fabric not use legacy RCTEventDispatcher for native-driven AnimatedEvents
59
+ static void RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrollView, NSInteger tag)
56
60
  {
57
61
  static uint16_t coalescingKey = 0;
58
62
  RCTScrollEvent *scrollEvent = [[RCTScrollEvent alloc] initWithEventName:@"onScroll"
@@ -64,7 +68,15 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
64
68
  scrollViewZoomScale:scrollView.zoomScale
65
69
  userData:nil
66
70
  coalescingKey:coalescingKey];
67
- [[RCTBridge currentBridge].eventDispatcher sendEvent:scrollEvent];
71
+ RCTBridge *bridge = [RCTBridge currentBridge];
72
+ if (bridge) {
73
+ [bridge.eventDispatcher sendEvent:scrollEvent];
74
+ } else {
75
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:scrollEvent, @"event", nil];
76
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"
77
+ object:nil
78
+ userInfo:userInfo];
79
+ }
68
80
  }
69
81
 
70
82
  @interface RCTScrollViewComponentView () <
@@ -85,6 +97,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
85
97
  // This helps to only update state from `scrollViewDidScroll` in case
86
98
  // some other part of the system scrolls scroll view.
87
99
  BOOL _isUserTriggeredScrolling;
100
+ BOOL _shouldUpdateContentInsetAdjustmentBehavior;
88
101
 
89
102
  CGPoint _contentOffsetWhenClipped;
90
103
  }
@@ -108,6 +121,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
108
121
  _scrollView.delaysContentTouches = NO;
109
122
  ((RCTEnhancedScrollView *)_scrollView).overridingDelegate = self;
110
123
  _isUserTriggeredScrolling = NO;
124
+ _shouldUpdateContentInsetAdjustmentBehavior = YES;
111
125
  [self addSubview:_scrollView];
112
126
 
113
127
  _containerView = [[UIView alloc] initWithFrame:CGRectZero];
@@ -135,7 +149,8 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
135
149
 
136
150
  #pragma mark - RCTMountingTransactionObserving
137
151
 
138
- - (void)mountingTransactionDidMountWithMetadata:(MountingTransactionMetadata const &)metadata
152
+ - (void)mountingTransactionDidMount:(MountingTransaction const &)transaction
153
+ withSurfaceTelemetry:(facebook::react::SurfaceTelemetry const &)surfaceTelemetry
139
154
  {
140
155
  [self _remountChildren];
141
156
  }
@@ -253,7 +268,8 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
253
268
  }
254
269
  }
255
270
 
256
- if (oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) {
271
+ if ((oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) ||
272
+ _shouldUpdateContentInsetAdjustmentBehavior) {
257
273
  auto const contentInsetAdjustmentBehavior = newScrollViewProps.contentInsetAdjustmentBehavior;
258
274
  if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Never) {
259
275
  scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
@@ -264,6 +280,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
264
280
  } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Always) {
265
281
  scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
266
282
  }
283
+ _shouldUpdateContentInsetAdjustmentBehavior = NO;
267
284
  }
268
285
 
269
286
  MAP_SCROLL_VIEW_PROP(disableIntervalMomentum);
@@ -377,8 +394,16 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
377
394
  {
378
395
  const auto &props = *std::static_pointer_cast<const ScrollViewProps>(_props);
379
396
  _scrollView.contentOffset = RCTCGPointFromPoint(props.contentOffset);
397
+ // We set the default behavior to "never" so that iOS
398
+ // doesn't do weird things to UIScrollView insets automatically
399
+ // and keeps it as an opt-in behavior.
400
+ _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
401
+ _shouldUpdateContentInsetAdjustmentBehavior = YES;
380
402
  _state.reset();
381
403
  _isUserTriggeredScrolling = NO;
404
+ CGRect oldFrame = self.frame;
405
+ self.frame = CGRectZero;
406
+ self.frame = oldFrame;
382
407
  [super prepareForRecycle];
383
408
  }
384
409
 
@@ -403,9 +428,8 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
403
428
  if (_eventEmitter) {
404
429
  std::static_pointer_cast<ScrollViewEventEmitter const>(_eventEmitter)->onScroll([self _scrollViewMetrics]);
405
430
  }
406
- // Once Fabric implements proper NativeAnimationDriver, this should be removed.
407
- // This is just a workaround to allow animations based on onScroll event.
408
- RCTSendPaperScrollEvent_DEPRECATED(scrollView, self.tag);
431
+
432
+ RCTSendScrollEventForNativeAnimations_DEPRECATED(scrollView, self.tag);
409
433
  }
410
434
 
411
435
  [self _remountChildrenIfNeeded];
@@ -566,7 +590,6 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
566
590
  offset = CGPointMake(localX, localY);
567
591
  }
568
592
 
569
- [self _forceDispatchNextScrollEvent];
570
593
  [self scrollToOffset:offset animated:animated];
571
594
  }
572
595
 
@@ -621,12 +644,15 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
621
644
 
622
645
  - (void)scrollToOffset:(CGPoint)offset
623
646
  {
624
- [self _forceDispatchNextScrollEvent];
625
647
  [self scrollToOffset:offset animated:YES];
626
648
  }
627
649
 
628
650
  - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
629
651
  {
652
+ if (CGPointEqualToPoint(_scrollView.contentOffset, offset)) {
653
+ return;
654
+ }
655
+
630
656
  [self _forceDispatchNextScrollEvent];
631
657
 
632
658
  if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
@@ -8,6 +8,7 @@
8
8
  #import "RCTViewComponentView.h"
9
9
 
10
10
  #import <CoreGraphics/CoreGraphics.h>
11
+ #import <QuartzCore/QuartzCore.h>
11
12
  #import <objc/runtime.h>
12
13
 
13
14
  #import <React/RCTAssert.h>
@@ -591,6 +592,12 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
591
592
 
592
593
  RCTBorderColors borderColors = RCTCreateRCTBorderColorsFromBorderColors(borderMetrics.borderColors);
593
594
 
595
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
596
+ CGFloat scaleFactor = self.window.backingScaleFactor;
597
+ #else
598
+ // On iOS setting the scaleFactor to 0.0 will default to the device's native scale factor.
599
+ CGFloat scaleFactor = 0.0;
600
+ #endif // ]TODO(macOS GH#774)
594
601
  UIImage *image = RCTGetBorderImage(
595
602
  RCTBorderStyleFromBorderStyle(borderMetrics.borderStyles.left),
596
603
  layer.bounds.size,
@@ -598,7 +605,8 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
598
605
  RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths),
599
606
  borderColors,
600
607
  _backgroundColor.CGColor,
601
- self.clipsToBounds);
608
+ self.clipsToBounds,
609
+ scaleFactor); // TODO(macOS GH#774)
602
610
 
603
611
  RCTReleaseRCTBorderColors(borderColors);
604
612
 
@@ -95,9 +95,9 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
95
95
  {
96
96
  .viewClass = viewClass,
97
97
  .observesMountingTransactionWillMount =
98
- (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionWillMountWithMetadata:)),
98
+ (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionWillMount:withSurfaceTelemetry:)),
99
99
  .observesMountingTransactionDidMount =
100
- (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionDidMountWithMetadata:)),
100
+ (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionDidMount:withSurfaceTelemetry:)),
101
101
  };
102
102
  #pragma clang diagnostic pop
103
103
  }
@@ -117,7 +117,16 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
117
117
  }
118
118
 
119
119
  // Fallback 2: Try to use Paper Interop.
120
- if ([RCTLegacyViewManagerInteropComponentView isSupported:RCTNSStringFromString(name)]) {
120
+ NSString *componentNameString = RCTNSStringFromString(name);
121
+ if ([RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]) {
122
+ RCTLogNewArchitectureValidation(
123
+ RCTNotAllowedInBridgeless,
124
+ self,
125
+ [NSString
126
+ stringWithFormat:
127
+ @"Legacy ViewManagers should be migrated to Fabric ComponentViews in the new architecture to reduce risk. Component using interop layer: %@",
128
+ componentNameString]);
129
+
121
130
  auto flavor = std::make_shared<std::string const>(name);
122
131
  auto componentName = ComponentName{flavor->c_str()};
123
132
  auto componentHandle = reinterpret_cast<ComponentHandle>(componentName);
@@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
63
63
 
64
64
  - (void)setIsJSResponder:(BOOL)isJSResponder
65
65
  blockNativeResponder:(BOOL)blockNativeResponder
66
- forShadowView:(facebook::react::ShadowView)shadowView;
66
+ forShadowView:(facebook::react::ShadowView const &)shadowView;
67
67
 
68
68
  - (void)synchronouslyUpdateViewOnUIThread:(ReactTag)reactTag
69
69
  changedProps:(NSDictionary *)props
@@ -7,6 +7,7 @@
7
7
 
8
8
  #import "RCTMountingManager.h"
9
9
 
10
+ #import <QuartzCore/QuartzCore.h>
10
11
  #import <butter/map.h>
11
12
 
12
13
  #import <React/RCTAssert.h>
@@ -265,26 +266,27 @@ static void RCTPerformMountInstructions(
265
266
  auto surfaceId = mountingCoordinator->getSurfaceId();
266
267
 
267
268
  mountingCoordinator->getTelemetryController().pullTransaction(
268
- [&](MountingTransactionMetadata metadata) {
269
+ [&](MountingTransaction const &transaction, SurfaceTelemetry const &surfaceTelemetry) {
269
270
  [self.delegate mountingManager:self willMountComponentsWithRootTag:surfaceId];
270
- _observerCoordinator.notifyObserversMountingTransactionWillMount(metadata);
271
+ _observerCoordinator.notifyObserversMountingTransactionWillMount(transaction, surfaceTelemetry);
271
272
  },
272
- [&](ShadowViewMutationList const &mutations) {
273
- RCTPerformMountInstructions(mutations, _componentViewRegistry, _observerCoordinator, surfaceId);
273
+ [&](MountingTransaction const &transaction, SurfaceTelemetry const &surfaceTelemetry) {
274
+ RCTPerformMountInstructions(
275
+ transaction.getMutations(), _componentViewRegistry, _observerCoordinator, surfaceId);
274
276
  },
275
- [&](MountingTransactionMetadata metadata) {
276
- _observerCoordinator.notifyObserversMountingTransactionDidMount(metadata);
277
+ [&](MountingTransaction const &transaction, SurfaceTelemetry const &surfaceTelemetry) {
278
+ _observerCoordinator.notifyObserversMountingTransactionDidMount(transaction, surfaceTelemetry);
277
279
  [self.delegate mountingManager:self didMountComponentsWithRootTag:surfaceId];
278
280
  });
279
281
  }
280
282
 
281
283
  - (void)setIsJSResponder:(BOOL)isJSResponder
282
284
  blockNativeResponder:(BOOL)blockNativeResponder
283
- forShadowView:(facebook::react::ShadowView)shadowView
285
+ forShadowView:(facebook::react::ShadowView const &)shadowView
284
286
  {
287
+ ReactTag reactTag = shadowView.tag;
285
288
  RCTExecuteOnMainQueue(^{
286
- UIView<RCTComponentViewProtocol> *componentView =
287
- [self->_componentViewRegistry findComponentViewWithTag:shadowView.tag];
289
+ UIView<RCTComponentViewProtocol> *componentView = [self->_componentViewRegistry findComponentViewWithTag:reactTag];
288
290
  [componentView setIsJSResponder:isJSResponder];
289
291
  });
290
292
  }
@@ -11,7 +11,7 @@
11
11
  #import <butter/map.h>
12
12
  #import <butter/set.h>
13
13
 
14
- #import <react/renderer/mounting/MountingTransactionMetadata.h>
14
+ #include <react/renderer/mounting/MountingTransaction.h>
15
15
 
16
16
  class RCTMountingTransactionObserverCoordinator final {
17
17
  public:
@@ -31,9 +31,11 @@ class RCTMountingTransactionObserverCoordinator final {
31
31
  * To be called from `RCTMountingManager`.
32
32
  */
33
33
  void notifyObserversMountingTransactionWillMount(
34
- facebook::react::MountingTransactionMetadata const &metadata) const;
34
+ facebook::react::MountingTransaction const &transaction,
35
+ facebook::react::SurfaceTelemetry const &surfaceTelemetry) const;
35
36
  void notifyObserversMountingTransactionDidMount(
36
- facebook::react::MountingTransactionMetadata const &metadata) const;
37
+ facebook::react::MountingTransaction const &transaction,
38
+ facebook::react::SurfaceTelemetry const &surfaceTelemetry) const;
37
39
 
38
40
  private:
39
41
  facebook::butter::map<
@@ -40,9 +40,10 @@ void RCTMountingTransactionObserverCoordinator::unregisterViewComponentDescripto
40
40
  }
41
41
 
42
42
  void RCTMountingTransactionObserverCoordinator::notifyObserversMountingTransactionWillMount(
43
- MountingTransactionMetadata const &metadata) const
43
+ MountingTransaction const &transaction,
44
+ SurfaceTelemetry const &surfaceTelemetry) const
44
45
  {
45
- auto surfaceId = metadata.surfaceId;
46
+ auto surfaceId = transaction.getSurfaceId();
46
47
  auto surfaceRegistryIterator = registry_.find(surfaceId);
47
48
  if (surfaceRegistryIterator == registry_.end()) {
48
49
  return;
@@ -50,16 +51,17 @@ void RCTMountingTransactionObserverCoordinator::notifyObserversMountingTransacti
50
51
  auto &surfaceRegistry = surfaceRegistryIterator->second;
51
52
  for (auto const &componentViewDescriptor : surfaceRegistry) {
52
53
  if (componentViewDescriptor.observesMountingTransactionWillMount) {
53
- [(id<RCTMountingTransactionObserving>)componentViewDescriptor.view
54
- mountingTransactionWillMountWithMetadata:metadata];
54
+ [(id<RCTMountingTransactionObserving>)componentViewDescriptor.view mountingTransactionWillMount:transaction
55
+ withSurfaceTelemetry:surfaceTelemetry];
55
56
  }
56
57
  }
57
58
  }
58
59
 
59
60
  void RCTMountingTransactionObserverCoordinator::notifyObserversMountingTransactionDidMount(
60
- MountingTransactionMetadata const &metadata) const
61
+ MountingTransaction const &transaction,
62
+ SurfaceTelemetry const &surfaceTelemetry) const
61
63
  {
62
- auto surfaceId = metadata.surfaceId;
64
+ auto surfaceId = transaction.getSurfaceId();
63
65
  auto surfaceRegistryIterator = registry_.find(surfaceId);
64
66
  if (surfaceRegistryIterator == registry_.end()) {
65
67
  return;
@@ -67,8 +69,8 @@ void RCTMountingTransactionObserverCoordinator::notifyObserversMountingTransacti
67
69
  auto &surfaceRegistry = surfaceRegistryIterator->second;
68
70
  for (auto const &componentViewDescriptor : surfaceRegistry) {
69
71
  if (componentViewDescriptor.observesMountingTransactionDidMount) {
70
- [(id<RCTMountingTransactionObserving>)componentViewDescriptor.view
71
- mountingTransactionDidMountWithMetadata:metadata];
72
+ [(id<RCTMountingTransactionObserving>)componentViewDescriptor.view mountingTransactionDidMount:transaction
73
+ withSurfaceTelemetry:surfaceTelemetry];
72
74
  }
73
75
  }
74
76
  }
@@ -7,7 +7,7 @@
7
7
 
8
8
  #import <UIKit/UIKit.h>
9
9
 
10
- #import <react/renderer/mounting/MountingTransactionMetadata.h>
10
+ #include <react/renderer/mounting/MountingTransaction.h>
11
11
 
12
12
  NS_ASSUME_NONNULL_BEGIN
13
13
 
@@ -50,14 +50,16 @@ NS_ASSUME_NONNULL_BEGIN
50
50
  * Is not being called for a component view which is being mounted as part of the transaction (because the view is not
51
51
  * registered as an observer yet).
52
52
  */
53
- - (void)mountingTransactionWillMountWithMetadata:(facebook::react::MountingTransactionMetadata const &)metadata;
53
+ - (void)mountingTransactionWillMount:(facebook::react::MountingTransaction const &)transaction
54
+ withSurfaceTelemetry:(facebook::react::SurfaceTelemetry const &)surfaceTelemetry;
54
55
 
55
56
  /*
56
57
  * Called right after the last mutation instruction is executed.
57
58
  * Is not being called for a component view which was being unmounted as part of the transaction (because the view is
58
59
  * not registered as an observer already).
59
60
  */
60
- - (void)mountingTransactionDidMountWithMetadata:(facebook::react::MountingTransactionMetadata const &)metadata;
61
+ - (void)mountingTransactionDidMount:(facebook::react::MountingTransaction const &)transaction
62
+ withSurfaceTelemetry:(facebook::react::SurfaceTelemetry const &)surfaceTelemetry;
61
63
 
62
64
  @end
63
65
 
@@ -173,9 +173,17 @@ inline facebook::react::Point RCTPointFromCGPoint(const CGPoint &point)
173
173
  return {point.x, point.y};
174
174
  }
175
175
 
176
+ inline facebook::react::Float RCTFloatFromCGFloat(CGFloat value)
177
+ {
178
+ if (value == CGFLOAT_MAX) {
179
+ return std::numeric_limits<facebook::react::Float>::infinity();
180
+ }
181
+ return value;
182
+ }
183
+
176
184
  inline facebook::react::Size RCTSizeFromCGSize(const CGSize &size)
177
185
  {
178
- return {size.width, size.height};
186
+ return {RCTFloatFromCGFloat(size.width), RCTFloatFromCGFloat(size.height)};
179
187
  }
180
188
 
181
189
  inline facebook::react::Rect RCTRectFromCGRect(const CGRect &rect)
@@ -26,15 +26,21 @@ void setLocalizationLanguagePack(NSDictionary<NSString *, NSString *> *pack)
26
26
 
27
27
  + (NSString *)RCTLocalizedString:(NSString *)oldString withDescription:(NSString *)description
28
28
  {
29
+ NSString *candidate = nil;
30
+
29
31
  if (_delegate != nil) {
30
- return [_delegate localizedString:oldString withDescription:description];
32
+ candidate = [_delegate localizedString:oldString withDescription:description];
33
+ }
34
+
35
+ if (candidate == nil && _languagePack != nil) {
36
+ candidate = _languagePack[oldString];
31
37
  }
32
38
 
33
- if (_languagePack != nil) {
34
- return _languagePack[oldString];
39
+ if (candidate == nil) {
40
+ candidate = oldString;
35
41
  }
36
42
 
37
- return oldString;
43
+ return candidate;
38
44
  }
39
45
 
40
46
  @end