react-native-macos 0.0.0-fdcec4d55 → 0.0.0-fe1f016b6

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 (129) 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 +118 -1
  4. package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
  5. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  6. package/Libraries/Components/View/ReactNativeViewViewConfig.js +1 -0
  7. package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +3 -3
  8. package/Libraries/Components/View/View.js +0 -7
  9. package/Libraries/Components/View/ViewPropTypes.js +10 -6
  10. package/Libraries/Core/ReactNativeVersion.js +1 -1
  11. package/Libraries/Image/RCTImageCache.m +1 -1
  12. package/Libraries/Image/RCTImageView.mm +14 -10
  13. package/Libraries/LinkingIOS/RCTLinkingManager.h +1 -0
  14. package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +12 -5
  15. package/Libraries/Lists/FlatList.js +25 -1
  16. package/Libraries/Lists/VirtualizedList.js +118 -113
  17. package/Libraries/Lists/VirtualizedSectionList.js +9 -5
  18. package/Libraries/StyleSheet/StyleSheetTypes.js +25 -0
  19. package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
  20. package/Libraries/Text/RCTTextAttributes.h +2 -0
  21. package/Libraries/Text/RCTTextAttributes.m +14 -5
  22. package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
  23. package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
  24. package/Libraries/Text/Text/RCTTextView.m +118 -47
  25. package/Libraries/Text/Text.js +0 -8
  26. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
  27. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -2
  28. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
  29. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
  30. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +88 -3
  31. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +13 -1
  32. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +12 -3
  33. package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
  34. package/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m +12 -0
  35. package/Libraries/Text/TextInput/RCTBaseTextInputView.h +9 -1
  36. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +120 -2
  37. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +12 -1
  38. package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +40 -0
  39. package/Libraries/Text/TextNativeComponent.js +2 -0
  40. package/Libraries/Text/TextProps.js +29 -0
  41. package/Libraries/Types/CoreEventTypes.js +0 -1
  42. package/Libraries/Utilities/codegenNativeComponent.js +1 -0
  43. package/React/Base/RCTAssert.h +4 -3
  44. package/React/Base/RCTAssert.m +11 -2
  45. package/React/Base/RCTBridge.m +1 -1
  46. package/React/Base/RCTConstants.h +3 -3
  47. package/React/Base/RCTConstants.m +6 -6
  48. package/React/Base/RCTConvert.m +8 -4
  49. package/React/Base/RCTEventDispatcherProtocol.h +5 -0
  50. package/React/Base/RCTRootView.m +0 -9
  51. package/React/Base/RCTTouchHandler.m +4 -0
  52. package/React/Base/RCTUIKit.h +8 -13
  53. package/React/Base/RCTUtils.m +33 -3
  54. package/React/Base/RCTVersion.m +1 -1
  55. package/React/Base/macOS/RCTUIKit.m +40 -0
  56. package/React/CoreModules/RCTAppearance.mm +21 -5
  57. package/React/CoreModules/RCTEventDispatcher.mm +6 -1
  58. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  59. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h +1 -0
  60. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +76 -19
  61. package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +2 -1
  62. package/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +0 -1
  63. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
  64. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +35 -9
  65. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
  66. package/React/Fabric/Mounting/RCTComponentViewFactory.mm +2 -9
  67. package/React/Fabric/Mounting/RCTComponentViewRegistry.h +0 -5
  68. package/React/Fabric/Mounting/RCTComponentViewRegistry.mm +0 -39
  69. package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
  70. package/React/Fabric/Mounting/RCTMountingManager.mm +10 -9
  71. package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.h +5 -3
  72. package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.mm +10 -8
  73. package/React/Fabric/Mounting/RCTMountingTransactionObserving.h +5 -3
  74. package/React/Fabric/RCTConversions.h +9 -1
  75. package/React/Fabric/RCTImageResponseObserverProxy.h +1 -0
  76. package/React/Fabric/RCTLocalizationProvider.mm +10 -4
  77. package/React/Fabric/RCTScheduler.h +7 -0
  78. package/React/Fabric/RCTScheduler.mm +15 -0
  79. package/React/Fabric/RCTSurfacePresenter.h +2 -0
  80. package/React/Fabric/RCTSurfacePresenter.mm +44 -23
  81. package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
  82. package/React/Modules/RCTUIManager.m +2 -1
  83. package/React/React-RCTFabric.podspec +1 -1
  84. package/React/Tests/Mounting/RCTComponentViewRegistryTests.mm +1 -0
  85. package/React/Views/RCTActivityIndicatorView.m +2 -1
  86. package/React/Views/RCTCursor.h +39 -0
  87. package/React/Views/RCTCursor.m +105 -0
  88. package/React/Views/RCTView.h +16 -0
  89. package/React/Views/RCTView.m +141 -191
  90. package/React/Views/RCTViewKeyboardEvent.h +6 -28
  91. package/React/Views/RCTViewKeyboardEvent.m +66 -61
  92. package/React/Views/RCTViewManager.m +18 -13
  93. package/React/Views/ScrollView/RCTScrollContentView.h +4 -0
  94. package/React/Views/ScrollView/RCTScrollContentView.m +18 -0
  95. package/React/Views/ScrollView/RCTScrollContentViewManager.m +2 -0
  96. package/React/Views/ScrollView/RCTScrollView.h +2 -1
  97. package/React/Views/ScrollView/RCTScrollView.m +70 -63
  98. package/React/Views/ScrollView/RCTScrollViewManager.m +1 -1
  99. package/React/Views/UIView+React.h +2 -0
  100. package/React/Views/UIView+React.m +23 -14
  101. package/ReactAndroid/gradle.properties +1 -1
  102. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  103. package/ReactCommon/React-Fabric.podspec +1 -1
  104. package/ReactCommon/React-rncore.podspec +1 -1
  105. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  106. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +5 -0
  107. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +4 -2
  108. package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
  109. package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
  110. package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
  111. package/ReactCommon/react/renderer/core/EventListener.h +44 -0
  112. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  113. package/ReactCommon/react/renderer/mounting/TelemetryController.cpp +6 -9
  114. package/ReactCommon/react/renderer/mounting/TelemetryController.h +7 -7
  115. package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +18 -0
  116. package/ReactCommon/react/renderer/scheduler/Scheduler.h +9 -0
  117. package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
  118. package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
  119. package/package.json +1 -1
  120. package/scripts/generate-artifacts.js +21 -17
  121. package/scripts/react_native_pods.rb +0 -3
  122. package/template/Gemfile.lock +7 -7
  123. package/template/android/gradlew.bat +89 -89
  124. package/template/ios/HelloWorldTests/HelloWorldTests.m +1 -0
  125. package/template/package.json +1 -1
  126. package/Libraries/Types/RootTagTypes.js~merged +0 -23
  127. package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp +0 -12
  128. package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h +0 -32
  129. package/third-party-podspecs/boost-for-react-native.podspec +0 -20
@@ -423,12 +423,28 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
423
423
  }
424
424
  }
425
425
 
426
+ // We purposely don't use RCTCursor for the parameter type here because it would introduce an import cycle:
427
+ // RCTUIKit > RCTCursor > RCTConvert > RCTUIKit
428
+ - (void)setCursor:(NSInteger)cursor
429
+ {
430
+ // This method is required to be defined due to [RCTVirtualTextViewManager view] returning a RCTUIView.
431
+ }
432
+
426
433
  @end
427
434
 
428
435
  // RCTUIScrollView
429
436
 
430
437
  @implementation RCTUIScrollView // TODO(macOS ISS#3536887)
431
438
 
439
+ - (instancetype)initWithFrame:(CGRect)frame
440
+ {
441
+ if (self = [super initWithFrame:frame]) {
442
+ self.scrollEnabled = YES;
443
+ }
444
+
445
+ return self;
446
+ }
447
+
432
448
  - (void)setEnableFocusRing:(BOOL)enableFocusRing {
433
449
  if (_enableFocusRing != enableFocusRing) {
434
450
  _enableFocusRing = enableFocusRing;
@@ -535,6 +551,7 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
535
551
  self.verticalScrollElasticity = alwaysBounceVertical ? NSScrollElasticityAllowed : NSScrollElasticityNone;
536
552
  }
537
553
 
554
+
538
555
  @end
539
556
 
540
557
  BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
@@ -550,3 +567,26 @@ BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
550
567
 
551
568
  return clipsToBounds;
552
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
@@ -137,21 +137,26 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
137
137
  return _currentColorScheme;
138
138
  }
139
139
 
140
+ #if !TARGET_OS_OSX // TODO(macOS GH#774)
140
141
  - (void)appearanceChanged:(NSNotification *)notification
141
142
  {
142
143
  NSDictionary *userInfo = [notification userInfo];
143
- #if !TARGET_OS_OSX // TODO(macOS GH#774)
144
144
  UITraitCollection *traitCollection = nil;
145
145
  if (userInfo) {
146
146
  traitCollection = userInfo[RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey];
147
147
  }
148
148
  NSString *newColorScheme = RCTColorSchemePreference(traitCollection);
149
149
  #else // [TODO(macOS GH#774)
150
- NSAppearance *appearance = nil;
151
- if (userInfo) {
152
- appearance = userInfo[RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey];
150
+ - (void)observeValueForKeyPath:(NSString *)keyPath
151
+ ofObject:(id)object
152
+ change:(NSDictionary *)change
153
+ context:(void *)context
154
+ {
155
+ if (object != NSApp || ![keyPath isEqualToString:@"effectiveAppearance"]) {
156
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
157
+ return;
153
158
  }
154
- NSString *newColorScheme = RCTColorSchemePreference(appearance);
159
+ NSString *newColorScheme = RCTColorSchemePreference(nil);
155
160
  #endif // ]TODO(macOS GH#774)
156
161
  if (![_currentColorScheme isEqualToString:newColorScheme]) {
157
162
  _currentColorScheme = newColorScheme;
@@ -168,19 +173,30 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
168
173
 
169
174
  - (void)startObserving
170
175
  {
176
+ #if !TARGET_OS_OSX // [TODO(macOS GH#774)
171
177
  if (@available(iOS 13.0, *)) {
172
178
  [[NSNotificationCenter defaultCenter] addObserver:self
173
179
  selector:@selector(appearanceChanged:)
174
180
  name:RCTUserInterfaceStyleDidChangeNotification
175
181
  object:nil];
176
182
  }
183
+ #else
184
+ [NSApp addObserver:self
185
+ forKeyPath:@"effectiveAppearance"
186
+ options:NSKeyValueObservingOptionNew
187
+ context:nil];
188
+ #endif // ]TODO(macOS GH#774)
177
189
  }
178
190
 
179
191
  - (void)stopObserving
180
192
  {
193
+ #if !TARGET_OS_OSX // [TODO(macOS GH#774)
181
194
  if (@available(iOS 13.0, *)) {
182
195
  [[NSNotificationCenter defaultCenter] removeObserver:self];
183
196
  }
197
+ #else
198
+ [NSApp removeObserver:self forKeyPath:@"effectiveAppearance" context:nil];
199
+ #endif // ]TODO(macOS GH#774)
184
200
  }
185
201
 
186
202
  @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,46 @@ 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
+ RCTLogNotAllowedForNewArchitecture(
113
+ self,
114
+ [NSString
115
+ stringWithFormat:
116
+ @"Legacy ViewManagers should be migrated to Fabric ComponentViews in the new architecture to reduce risk. Component using interop layer: %@",
117
+ componentName]);
118
+
119
+ // Step 1: check if ViewManager with specified name is supported.
120
+ BOOL isComponentNameSupported =
121
+ [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] containsObject:componentName];
122
+ if (isComponentNameSupported) {
123
+ return YES;
124
+ }
125
+
126
+ // Step 2: check if component has supported prefix.
127
+ for (NSString *item in [RCTLegacyViewManagerInteropComponentView supportedViewManagersPrefixes]) {
128
+ if ([componentName hasPrefix:item]) {
129
+ return YES;
130
+ }
131
+ }
132
+
133
+ return NO;
76
134
  }
77
135
 
78
- - (RCTLegacyViewManagerInteropCoordinator *)coordinator
136
+ + (void)supportLegacyViewManagersWithPrefix:(NSString *)prefix
79
137
  {
80
- if (_state != nullptr) {
81
- const auto &state = _state->getData();
82
- return unwrapManagedObject(state.coordinator);
83
- } else {
84
- return nil;
85
- }
138
+ [[RCTLegacyViewManagerInteropComponentView supportedViewManagersPrefixes] addObject:prefix];
86
139
  }
87
140
 
88
- - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
141
+ + (void)supportLegacyViewManagerWithName:(NSString *)componentName
89
142
  {
90
- const auto &state = _state->getData();
91
- RCTLegacyViewManagerInteropCoordinator *coordinator = unwrapManagedObject(state.coordinator);
92
- return coordinator.componentViewName;
143
+ [[RCTLegacyViewManagerInteropComponentView supportedViewManagers] addObject:componentName];
93
144
  }
94
145
 
95
146
  #pragma mark - RCTComponentViewProtocol
@@ -101,6 +152,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
101
152
  [_viewsToBeUnmounted removeAllObjects];
102
153
  _state.reset();
103
154
  self.contentView = nil;
155
+ _hasInvokedForwardingWarning = NO;
104
156
  [super prepareForRecycle];
105
157
  }
106
158
 
@@ -136,7 +188,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
136
188
  [super finalizeUpdates:updateMask];
137
189
 
138
190
  if (!_adapter) {
139
- _adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:self.coordinator
191
+ _adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:[self _coordinator]
140
192
  reactTag:self.tag];
141
193
  __weak __typeof(self) weakSelf = self;
142
194
  _adapter.eventInterceptor = ^(std::string eventName, folly::dynamic event) {
@@ -153,7 +205,12 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
153
205
  for (NSDictionary *mountInstruction in _viewsToBeMounted) {
154
206
  NSNumber *index = mountInstruction[kRCTLegacyInteropChildIndexKey];
155
207
  UIView *childView = mountInstruction[kRCTLegacyInteropChildComponentKey];
156
- [_adapter.paperView insertReactSubview:childView atIndex:index.integerValue];
208
+ if ([childView isKindOfClass:[RCTLegacyViewManagerInteropComponentView class]]) {
209
+ UIView *target = ((RCTLegacyViewManagerInteropComponentView *)childView).contentView;
210
+ [_adapter.paperView insertReactSubview:target atIndex:index.integerValue];
211
+ } else {
212
+ [_adapter.paperView insertReactSubview:childView atIndex:index.integerValue];
213
+ }
157
214
  }
158
215
 
159
216
  [_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) {
@@ -591,6 +591,12 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
591
591
 
592
592
  RCTBorderColors borderColors = RCTCreateRCTBorderColorsFromBorderColors(borderMetrics.borderColors);
593
593
 
594
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
595
+ CGFloat scaleFactor = self.window.backingScaleFactor;
596
+ #else
597
+ // On iOS setting the scaleFactor to 0.0 will default to the device's native scale factor.
598
+ CGFloat scaleFactor = 0.0;
599
+ #endif // ]TODO(macOS GH#774)
594
600
  UIImage *image = RCTGetBorderImage(
595
601
  RCTBorderStyleFromBorderStyle(borderMetrics.borderStyles.left),
596
602
  layer.bounds.size,
@@ -598,7 +604,8 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
598
604
  RCTUIEdgeInsetsFromEdgeInsets(borderMetrics.borderWidths),
599
605
  borderColors,
600
606
  _backgroundColor.CGColor,
601
- self.clipsToBounds);
607
+ self.clipsToBounds,
608
+ scaleFactor); // TODO(macOS GH#774)
602
609
 
603
610
  RCTReleaseRCTBorderColors(borderColors);
604
611
 
@@ -71,13 +71,6 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
71
71
  dispatch_once(&onceToken, ^{
72
72
  componentViewFactory = [RCTComponentViewFactory new];
73
73
  [componentViewFactory registerComponentViewClass:[RCTRootComponentView class]];
74
- [componentViewFactory registerComponentViewClass:[RCTViewComponentView class]];
75
- [componentViewFactory registerComponentViewClass:[RCTParagraphComponentView class]];
76
- [componentViewFactory registerComponentViewClass:[RCTTextInputComponentView class]];
77
-
78
- Class<RCTComponentViewProtocol> imageClass = RCTComponentViewClassWithName("Image");
79
- [componentViewFactory registerComponentViewClass:imageClass];
80
-
81
74
  componentViewFactory->_providerRegistry.setComponentDescriptorProviderRequest(
82
75
  [](ComponentName requestedComponentName) {
83
76
  [componentViewFactory registerComponentIfPossible:requestedComponentName];
@@ -95,9 +88,9 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
95
88
  {
96
89
  .viewClass = viewClass,
97
90
  .observesMountingTransactionWillMount =
98
- (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionWillMountWithMetadata:)),
91
+ (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionWillMount:withSurfaceTelemetry:)),
99
92
  .observesMountingTransactionDidMount =
100
- (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionDidMountWithMetadata:)),
93
+ (bool)class_respondsToSelector(viewClass, @selector(mountingTransactionDidMount:withSurfaceTelemetry:)),
101
94
  };
102
95
  #pragma clang diagnostic pop
103
96
  }
@@ -50,11 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
50
50
  */
51
51
  - (nullable UIView<RCTComponentViewProtocol> *)findComponentViewWithTag:(facebook::react::Tag)tag;
52
52
 
53
- /**
54
- * Creates a component view with a given type and puts it to the recycle pool.
55
- */
56
- - (void)optimisticallyCreateComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle;
57
-
58
53
  @end
59
54
 
60
55
  NS_ASSUME_NONNULL_END
@@ -35,42 +35,11 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
35
35
  selector:@selector(handleApplicationDidReceiveMemoryWarningNotification)
36
36
  name:UIApplicationDidReceiveMemoryWarningNotification
37
37
  object:nil];
38
-
39
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
40
- // Calling this a bit later, when the main thread is probably idle while JavaScript thread is busy.
41
- [self preallocateViewComponents];
42
- });
43
38
  }
44
39
 
45
40
  return self;
46
41
  }
47
42
 
48
- - (void)preallocateViewComponents
49
- {
50
- if (RCTExperimentGetPreemptiveViewAllocationDisabled()) {
51
- return;
52
- }
53
-
54
- // This data is based on empirical evidence which should represent the reality pretty well.
55
- // Regular `<View>` has magnitude equals to `1` by definition.
56
- std::vector<std::pair<ComponentHandle, float>> componentMagnitudes = {
57
- {[RCTViewComponentView componentDescriptorProvider].handle, 1},
58
- {[RCTImageComponentView componentDescriptorProvider].handle, 0.3},
59
- {[RCTParagraphComponentView componentDescriptorProvider].handle, 0.3},
60
- };
61
-
62
- // `complexity` represents the complexity of a typical surface in a number of `<View>` components (with Flattening
63
- // enabled).
64
- float complexity = 100;
65
-
66
- // The whole process should not take more than 10ms in the worst case, so there is no need to split it up.
67
- for (const auto &componentMagnitude : componentMagnitudes) {
68
- for (int i = 0; i < complexity * componentMagnitude.second; i++) {
69
- [self optimisticallyCreateComponentViewWithComponentHandle:componentMagnitude.first];
70
- }
71
- }
72
- }
73
-
74
43
  - (RCTComponentViewDescriptor const &)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
75
44
  tag:(Tag)tag
76
45
  {
@@ -100,14 +69,6 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
100
69
  [self _enqueueComponentViewWithComponentHandle:componentHandle componentViewDescriptor:componentViewDescriptor];
101
70
  }
102
71
 
103
- - (void)optimisticallyCreateComponentViewWithComponentHandle:(ComponentHandle)componentHandle
104
- {
105
- RCTAssertMainQueue();
106
- [self _enqueueComponentViewWithComponentHandle:componentHandle
107
- componentViewDescriptor:[self.componentViewFactory
108
- createComponentViewWithComponentHandle:componentHandle]];
109
- }
110
-
111
72
  - (RCTComponentViewDescriptor const &)componentViewDescriptorWithTag:(Tag)tag
112
73
  {
113
74
  RCTAssertMainQueue();
@@ -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
@@ -265,26 +265,27 @@ static void RCTPerformMountInstructions(
265
265
  auto surfaceId = mountingCoordinator->getSurfaceId();
266
266
 
267
267
  mountingCoordinator->getTelemetryController().pullTransaction(
268
- [&](MountingTransactionMetadata metadata) {
268
+ [&](MountingTransaction const &transaction, SurfaceTelemetry const &surfaceTelemetry) {
269
269
  [self.delegate mountingManager:self willMountComponentsWithRootTag:surfaceId];
270
- _observerCoordinator.notifyObserversMountingTransactionWillMount(metadata);
270
+ _observerCoordinator.notifyObserversMountingTransactionWillMount(transaction, surfaceTelemetry);
271
271
  },
272
- [&](ShadowViewMutationList const &mutations) {
273
- RCTPerformMountInstructions(mutations, _componentViewRegistry, _observerCoordinator, surfaceId);
272
+ [&](MountingTransaction const &transaction, SurfaceTelemetry const &surfaceTelemetry) {
273
+ RCTPerformMountInstructions(
274
+ transaction.getMutations(), _componentViewRegistry, _observerCoordinator, surfaceId);
274
275
  },
275
- [&](MountingTransactionMetadata metadata) {
276
- _observerCoordinator.notifyObserversMountingTransactionDidMount(metadata);
276
+ [&](MountingTransaction const &transaction, SurfaceTelemetry const &surfaceTelemetry) {
277
+ _observerCoordinator.notifyObserversMountingTransactionDidMount(transaction, surfaceTelemetry);
277
278
  [self.delegate mountingManager:self didMountComponentsWithRootTag:surfaceId];
278
279
  });
279
280
  }
280
281
 
281
282
  - (void)setIsJSResponder:(BOOL)isJSResponder
282
283
  blockNativeResponder:(BOOL)blockNativeResponder
283
- forShadowView:(facebook::react::ShadowView)shadowView
284
+ forShadowView:(facebook::react::ShadowView const &)shadowView
284
285
  {
286
+ ReactTag reactTag = shadowView.tag;
285
287
  RCTExecuteOnMainQueue(^{
286
- UIView<RCTComponentViewProtocol> *componentView =
287
- [self->_componentViewRegistry findComponentViewWithTag:shadowView.tag];
288
+ UIView<RCTComponentViewProtocol> *componentView = [self->_componentViewRegistry findComponentViewWithTag:reactTag];
288
289
  [componentView setIsJSResponder:isJSResponder];
289
290
  });
290
291
  }