iOS: Revert RCT->RN prefix renaming to avoid confusion

Summary: The previous rename from RCT->RN prefix ended up causing some confusions on which prefix to use for which files and under what circumstances. To avoid further confusion before we're done with the re-architecture project, let's keep them as RCT.

Reviewed By: mdvacca

Differential Revision: D16705566

fbshipit-source-id: 395bff771c84e5ded6b2261a84c7549df1e6c5e5
This commit is contained in:
Kevin Gozali 2019-08-08 07:13:22 -07:00 коммит произвёл Facebook Github Bot
Родитель 93f4f9d9c9
Коммит d2e18a1c5c
65 изменённых файлов: 421 добавлений и 415 удалений

Просмотреть файл

@ -8,7 +8,7 @@
#import <React/RCTPropsAnimatedNode.h> #import <React/RCTPropsAnimatedNode.h>
#import <React/RCTLog.h> #import <React/RCTLog.h>
#import <React/RNSurfacePresenterStub.h> #import <React/RCTSurfacePresenterStub.h>
#import <React/RCTUIManager.h> #import <React/RCTUIManager.h>
#import <React/RCTAnimationUtils.h> #import <React/RCTAnimationUtils.h>

Просмотреть файл

@ -8,13 +8,13 @@
#import <React/RCTBridgeModule.h> #import <React/RCTBridgeModule.h>
#import <React/RCTEventDispatcher.h> #import <React/RCTEventDispatcher.h>
#import <React/RCTEventEmitter.h> #import <React/RCTEventEmitter.h>
#import <React/RNSurfacePresenterStub.h> #import <React/RCTSurfacePresenterStub.h>
#import <React/RCTUIManager.h> #import <React/RCTUIManager.h>
#import <React/RCTUIManagerObserverCoordinator.h> #import <React/RCTUIManagerObserverCoordinator.h>
#import <React/RCTUIManagerUtils.h> #import <React/RCTUIManagerUtils.h>
#import "RCTValueAnimatedNode.h" #import "RCTValueAnimatedNode.h"
@interface RCTNativeAnimatedModule : RCTEventEmitter <RCTBridgeModule, RCTValueAnimatedNodeObserver, RCTEventDispatcherObserver, RCTUIManagerObserver, RNSurfacePresenterObserver> @interface RCTNativeAnimatedModule : RCTEventEmitter <RCTBridgeModule, RCTValueAnimatedNodeObserver, RCTEventDispatcherObserver, RCTUIManagerObserver, RCTSurfacePresenterObserver>
@end @end

Просмотреть файл

@ -231,7 +231,7 @@ RCT_EXPORT_METHOD(removeAnimatedEventFromView:(nonnull NSNumber *)viewTag
}); });
} }
#pragma mark - RNSurfacePresenterObserver #pragma mark - RCTSurfacePresenterObserver
- (void)willMountComponentsWithRootTag:(NSInteger)rootTag - (void)willMountComponentsWithRootTag:(NSInteger)rootTag
{ {

Просмотреть файл

@ -23,8 +23,8 @@
#endif #endif
#ifdef RN_FABRIC_ENABLED #ifdef RN_FABRIC_ENABLED
#import <React/RNSurfacePresenter.h> #import <React/RCTSurfacePresenter.h>
#import <React/RNFabricSurfaceHostingProxyRootView.h> #import <React/RCTFabricSurfaceHostingProxyRootView.h>
#endif #endif
#import <ReactCommon/RCTTurboModuleManager.h> #import <ReactCommon/RCTTurboModuleManager.h>
@ -34,7 +34,7 @@
@interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>{ @interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>{
#ifdef RN_FABRIC_ENABLED #ifdef RN_FABRIC_ENABLED
RNSurfacePresenter *_surfacePresenter; RCTSurfacePresenter *_surfacePresenter;
#endif #endif
RCTTurboModuleManager *_turboModuleManager; RCTTurboModuleManager *_turboModuleManager;
@ -58,10 +58,10 @@
} }
#ifdef RN_FABRIC_ENABLED #ifdef RN_FABRIC_ENABLED
_surfacePresenter = [[RNSurfacePresenter alloc] initWithBridge:_bridge config:nil]; _surfacePresenter = [[RCTSurfacePresenter alloc] initWithBridge:_bridge config:nil];
_bridge.surfacePresenter = _surfacePresenter; _bridge.surfacePresenter = _surfacePresenter;
UIView *rootView = [[RNFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps];
#else #else
UIView *rootView = [[RCTRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; UIView *rootView = [[RCTRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps];
#endif #endif

Просмотреть файл

@ -7,14 +7,14 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for root <ActivityIndicator> component. * UIView class for root <ActivityIndicator> component.
*/ */
@interface RNActivityIndicatorViewComponentView : RNViewComponentView @interface RCTActivityIndicatorViewComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNActivityIndicatorViewComponentView.h" #import "RCTActivityIndicatorViewComponentView.h"
#import <react/components/rncore/ComponentDescriptors.h> #import <react/components/rncore/ComponentDescriptors.h>
#import <react/components/rncore/EventEmitters.h> #import <react/components/rncore/EventEmitters.h>
@ -23,11 +23,11 @@ static UIActivityIndicatorViewStyle convertActivityIndicatorViewStyle(const Acti
} }
} }
@implementation RNActivityIndicatorViewComponentView { @implementation RCTActivityIndicatorViewComponentView {
UIActivityIndicatorView *_activityIndicatorView; UIActivityIndicatorView *_activityIndicatorView;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {

Просмотреть файл

@ -5,15 +5,15 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import <React/RNImageResponseDelegate.h> #import <React/RCTImageResponseDelegate.h>
#import "RNViewComponentView.h" #import "RCTViewComponentView.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for root <Image> component. * UIView class for root <Image> component.
*/ */
@interface RNImageComponentView : RNViewComponentView <RNImageResponseDelegate> @interface RCTImageComponentView : RCTViewComponentView <RCTImageResponseDelegate>
@end @end

Просмотреть файл

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNImageComponentView.h" #import "RCTImageComponentView.h"
#import <React/RNImageResponseObserverProxy.h> #import <React/RCTImageResponseObserverProxy.h>
#import <react/components/image/ImageComponentDescriptor.h> #import <react/components/image/ImageComponentDescriptor.h>
#import <react/components/image/ImageEventEmitter.h> #import <react/components/image/ImageEventEmitter.h>
#import <react/components/image/ImageLocalData.h> #import <react/components/image/ImageLocalData.h>
@ -15,13 +15,13 @@
#import <react/imagemanager/ImageRequest.h> #import <react/imagemanager/ImageRequest.h>
#import <react/imagemanager/RCTImagePrimitivesConversions.h> #import <react/imagemanager/RCTImagePrimitivesConversions.h>
#import "RNConversions.h" #import "RCTConversions.h"
@implementation RNImageComponentView { @implementation RCTImageComponentView {
UIImageView *_imageView; UIImageView *_imageView;
SharedImageLocalData _imageLocalData; SharedImageLocalData _imageLocalData;
const ImageResponseObserverCoordinator *_coordinator; const ImageResponseObserverCoordinator *_coordinator;
std::unique_ptr<RNImageResponseObserverProxy> _imageResponseObserverProxy; std::unique_ptr<RCTImageResponseObserverProxy> _imageResponseObserverProxy;
} }
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
@ -35,7 +35,7 @@
_imageView.contentMode = (UIViewContentMode)RCTResizeModeFromImageResizeMode(defaultProps->resizeMode); _imageView.contentMode = (UIViewContentMode)RCTResizeModeFromImageResizeMode(defaultProps->resizeMode);
_imageResponseObserverProxy = std::make_unique<RNImageResponseObserverProxy>((__bridge void *)self); _imageResponseObserverProxy = std::make_unique<RCTImageResponseObserverProxy>((__bridge void *)self);
self.contentView = _imageView; self.contentView = _imageView;
} }
@ -43,7 +43,7 @@
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
@ -125,7 +125,7 @@
_imageResponseObserverProxy.reset(); _imageResponseObserverProxy.reset();
} }
#pragma mark - RNImageResponseDelegate #pragma mark - RCTImageResponseDelegate
- (void)didReceiveImage:(UIImage *)image fromObserver:(void *)observer - (void)didReceiveImage:(UIImage *)image fromObserver:(void *)observer
{ {

Просмотреть файл

@ -7,13 +7,13 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol RNModalHostViewControllerDelegate <NSObject> @protocol RCTFabricModalHostViewControllerDelegate <NSObject>
- (void)boundsDidChange:(CGRect)newBounds; - (void)boundsDidChange:(CGRect)newBounds;
@end @end
@interface RNModalHostViewController : UIViewController @interface RCTFabricModalHostViewController : UIViewController
@property (nonatomic, weak) id<RNModalHostViewControllerDelegate> delegate; @property (nonatomic, weak) id<RCTFabricModalHostViewControllerDelegate> delegate;
#if !TARGET_OS_TV #if !TARGET_OS_TV
@property (nonatomic, assign) UIInterfaceOrientationMask supportedInterfaceOrientations; @property (nonatomic, assign) UIInterfaceOrientationMask supportedInterfaceOrientations;

Просмотреть файл

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNModalHostViewController.h" #import "RCTFabricModalHostViewController.h"
#import <React/RCTLog.h> #import <React/RCTLog.h>
#import <React/RNSurfaceTouchHandler.h> #import <React/RCTSurfaceTouchHandler.h>
@implementation RNModalHostViewController { @implementation RCTFabricModalHostViewController {
CGRect _lastViewBounds; CGRect _lastViewBounds;
RNSurfaceTouchHandler *_touchHandler; RCTSurfaceTouchHandler *_touchHandler;
} }
- (instancetype)init - (instancetype)init
@ -20,7 +20,7 @@
if (!(self = [super init])) { if (!(self = [super init])) {
return nil; return nil;
} }
_touchHandler = [RNSurfaceTouchHandler new]; _touchHandler = [RCTSurfaceTouchHandler new];
return self; return self;
} }

Просмотреть файл

@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
/** /**
* UIView class for root <ModalHostView> component. * UIView class for root <ModalHostView> component.
*/ */
@interface RNModalHostViewComponentView : RNViewComponentView @interface RCTModalHostViewComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,15 +5,16 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNModalHostViewComponentView.h" #import "RCTModalHostViewComponentView.h"
#import "RNModalHostViewController.h"
#import <React/UIView+React.h> #import <React/UIView+React.h>
#import <react/components/modal/ModalHostViewComponentDescriptor.h> #import <react/components/modal/ModalHostViewComponentDescriptor.h>
#import <react/components/modal/ModalHostViewState.h> #import <react/components/modal/ModalHostViewState.h>
#import <react/components/rncore/EventEmitters.h> #import <react/components/rncore/EventEmitters.h>
#import <react/components/rncore/Props.h> #import <react/components/rncore/Props.h>
#import "RNConversions.h"
#import "RCTConversions.h"
#import "RCTFabricModalHostViewController.h"
using namespace facebook::react; using namespace facebook::react;
@ -90,12 +91,12 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
return {orientation}; return {orientation};
} }
@interface RNModalHostViewComponentView () <RNModalHostViewControllerDelegate> @interface RCTModalHostViewComponentView () <RCTFabricModalHostViewControllerDelegate>
@end @end
@implementation RNModalHostViewComponentView { @implementation RCTModalHostViewComponentView {
RNModalHostViewController *_viewController; RCTFabricModalHostViewController *_viewController;
ModalHostViewShadowNode::ConcreteState::Shared _state; ModalHostViewShadowNode::ConcreteState::Shared _state;
BOOL _shouldAnimatePresentation; BOOL _shouldAnimatePresentation;
} }
@ -106,7 +107,7 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
static const auto defaultProps = std::make_shared<const ModalHostViewProps>(); static const auto defaultProps = std::make_shared<const ModalHostViewProps>();
_props = defaultProps; _props = defaultProps;
_shouldAnimatePresentation = YES; _shouldAnimatePresentation = YES;
_viewController = [RNModalHostViewController new]; _viewController = [RCTFabricModalHostViewController new];
_viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; _viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
_viewController.delegate = self; _viewController.delegate = self;
} }
@ -151,7 +152,7 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
[self ensurePresentedOnlyIfNeeded]; [self ensurePresentedOnlyIfNeeded];
} }
#pragma mark - RNModalHostViewControllerDelegate #pragma mark - RCTFabricModalHostViewControllerDelegate
- (void)boundsDidChange:(CGRect)newBounds - (void)boundsDidChange:(CGRect)newBounds
{ {
@ -164,7 +165,7 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
} }
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
@ -194,12 +195,12 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
_state = std::static_pointer_cast<const ModalHostViewShadowNode::ConcreteState>(state); _state = std::static_pointer_cast<const ModalHostViewShadowNode::ConcreteState>(state);
} }
- (void)mountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{ {
[_viewController.view insertSubview:childComponentView atIndex:index]; [_viewController.view insertSubview:childComponentView atIndex:index];
} }
- (void)unmountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{ {
[childComponentView removeFromSuperview]; [childComponentView removeFromSuperview];
} }

Просмотреть файл

@ -7,14 +7,14 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for root <View> component. * UIView class for root <View> component.
*/ */
@interface RNRootComponentView : RNViewComponentView @interface RCTRootComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNRootComponentView.h" #import "RCTRootComponentView.h"
#import <react/components/root/RootComponentDescriptor.h> #import <react/components/root/RootComponentDescriptor.h>
#import <react/components/root/RootProps.h> #import <react/components/root/RootProps.h>
using namespace facebook::react; using namespace facebook::react;
@implementation RNRootComponentView @implementation RCTRootComponentView
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
@ -24,7 +24,7 @@ using namespace facebook::react;
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {

Просмотреть файл

@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
* `UIScrollView` subclass which has some improvements and tweaks * `UIScrollView` subclass which has some improvements and tweaks
* which are not directly related to React. * which are not directly related to React.
*/ */
@interface RNEnhancedScrollView : UIScrollView @interface RCTEnhancedScrollView : UIScrollView
@property (nonatomic, assign) BOOL pinchGestureEnabled; @property (nonatomic, assign) BOOL pinchGestureEnabled;
@property (nonatomic, assign) BOOL centerContent; @property (nonatomic, assign) BOOL centerContent;

Просмотреть файл

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNEnhancedScrollView.h" #import "RCTEnhancedScrollView.h"
@implementation RNEnhancedScrollView @implementation RCTEnhancedScrollView
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {

Просмотреть файл

@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
* This view is designed to only serve ViewController-like purpose for the actual `UIRefreshControl` view which is being * This view is designed to only serve ViewController-like purpose for the actual `UIRefreshControl` view which is being
* attached to some `UIScrollView` (not to this view). * attached to some `UIScrollView` (not to this view).
*/ */
@interface RNPullToRefreshViewComponentView : RNViewComponentView @interface RCTPullToRefreshViewComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,20 +5,20 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNPullToRefreshViewComponentView.h" #import "RCTPullToRefreshViewComponentView.h"
#import <react/components/rncore/ComponentDescriptors.h> #import <react/components/rncore/ComponentDescriptors.h>
#import <react/components/rncore/EventEmitters.h> #import <react/components/rncore/EventEmitters.h>
#import <react/components/rncore/Props.h> #import <react/components/rncore/Props.h>
#import <React/RNConversions.h> #import <React/RCTConversions.h>
#import <React/RNScrollViewComponentView.h> #import <React/RCTScrollViewComponentView.h>
using namespace facebook::react; using namespace facebook::react;
@implementation RNPullToRefreshViewComponentView { @implementation RCTPullToRefreshViewComponentView {
UIRefreshControl *_refreshControl; UIRefreshControl *_refreshControl;
RNScrollViewComponentView *_scrollViewComponentView; RCTScrollViewComponentView *_scrollViewComponentView;
} }
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
@ -41,7 +41,7 @@ using namespace facebook::react;
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
@ -120,7 +120,7 @@ using namespace facebook::react;
[self _detach]; [self _detach];
} }
_scrollViewComponentView = [RNScrollViewComponentView findScrollViewComponentViewForView:self]; _scrollViewComponentView = [RCTScrollViewComponentView findScrollViewComponentViewForView:self];
if (!_scrollViewComponentView) { if (!_scrollViewComponentView) {
return; return;
} }

Просмотреть файл

@ -7,9 +7,9 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RCTGenericDelegateSplitter.h>
#import <React/RCTScrollableProtocol.h> #import <React/RCTScrollableProtocol.h>
#import <React/RNGenericDelegateSplitter.h> #import <React/RCTViewComponentView.h>
#import <React/RNViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -21,12 +21,12 @@ NS_ASSUME_NONNULL_BEGIN
* keyboard-avoiding functionality and so on. All that complexity must be implemented inside those components in order * keyboard-avoiding functionality and so on. All that complexity must be implemented inside those components in order
* to keep the complexity of this component manageable. * to keep the complexity of this component manageable.
*/ */
@interface RNScrollViewComponentView : RNViewComponentView @interface RCTScrollViewComponentView : RCTViewComponentView
/* /*
* Finds and returns the closet RNScrollViewComponentView component to the given view * Finds and returns the closet RCTScrollViewComponentView component to the given view
*/ */
+ (RNScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view; + (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view;
/* /*
* Returns an actual UIScrollView that this component uses under the hood. * Returns an actual UIScrollView that this component uses under the hood.
@ -43,7 +43,8 @@ NS_ASSUME_NONNULL_BEGIN
/* /*
* Returns a delegate splitter that can be used to subscribe for UIScrollView delegate. * Returns a delegate splitter that can be used to subscribe for UIScrollView delegate.
*/ */
@property (nonatomic, strong, readonly) RNGenericDelegateSplitter<id<UIScrollViewDelegate>> *scrollViewDelegateSplitter; @property (nonatomic, strong, readonly)
RCTGenericDelegateSplitter<id<UIScrollViewDelegate>> *scrollViewDelegateSplitter;
@end @end
@ -52,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
* Until Fabric has own command-execution pipeline we have to support that to some extent. The implementation shouldn't * Until Fabric has own command-execution pipeline we have to support that to some extent. The implementation shouldn't
* be perfect though because very soon we will migrate that to the new commands infra and get rid of this. * be perfect though because very soon we will migrate that to the new commands infra and get rid of this.
*/ */
@interface RNScrollViewComponentView (ScrollableProtocol) <RCTScrollableProtocol> @interface RCTScrollViewComponentView (ScrollableProtocol) <RCTScrollableProtocol>
@end @end

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNScrollViewComponentView.h" #import "RCTScrollViewComponentView.h"
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
@ -15,28 +15,28 @@
#import <react/components/scrollview/ScrollViewState.h> #import <react/components/scrollview/ScrollViewState.h>
#import <react/graphics/Geometry.h> #import <react/graphics/Geometry.h>
#import "RNConversions.h" #import "RCTConversions.h"
#import "RNEnhancedScrollView.h" #import "RCTEnhancedScrollView.h"
using namespace facebook::react; using namespace facebook::react;
@interface RNScrollViewComponentView () <UIScrollViewDelegate> @interface RCTScrollViewComponentView () <UIScrollViewDelegate>
@property (nonatomic, assign) CGFloat scrollEventThrottle; @property (nonatomic, assign) CGFloat scrollEventThrottle;
@end @end
@implementation RNScrollViewComponentView { @implementation RCTScrollViewComponentView {
ScrollViewShadowNode::ConcreteState::Shared _state; ScrollViewShadowNode::ConcreteState::Shared _state;
CGSize _contentSize; CGSize _contentSize;
} }
+ (RNScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view + (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view
{ {
do { do {
view = view.superview; view = view.superview;
} while (view != nil && ![view isKindOfClass:[RNScrollViewComponentView class]]); } while (view != nil && ![view isKindOfClass:[RCTScrollViewComponentView class]]);
return (RNScrollViewComponentView *)view; return (RCTScrollViewComponentView *)view;
} }
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
@ -45,7 +45,7 @@ using namespace facebook::react;
static const auto defaultProps = std::make_shared<const ScrollViewProps>(); static const auto defaultProps = std::make_shared<const ScrollViewProps>();
_props = defaultProps; _props = defaultProps;
_scrollView = [[RNEnhancedScrollView alloc] initWithFrame:self.bounds]; _scrollView = [[RCTEnhancedScrollView alloc] initWithFrame:self.bounds];
_scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_scrollView.delaysContentTouches = NO; _scrollView.delaysContentTouches = NO;
[self addSubview:_scrollView]; [self addSubview:_scrollView];
@ -54,7 +54,7 @@ using namespace facebook::react;
[_scrollView addSubview:_containerView]; [_scrollView addSubview:_containerView];
__weak __typeof(self) weakSelf = self; __weak __typeof(self) weakSelf = self;
_scrollViewDelegateSplitter = [[RNGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) { _scrollViewDelegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) {
weakSelf.scrollView.delegate = delegate; weakSelf.scrollView.delegate = delegate;
}]; }];
@ -64,7 +64,7 @@ using namespace facebook::react;
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
@ -84,7 +84,7 @@ using namespace facebook::react;
#define REMAP_VIEW_PROP(reactName, localName) REMAP_PROP(reactName, localName, self) #define REMAP_VIEW_PROP(reactName, localName) REMAP_PROP(reactName, localName, self)
#define MAP_VIEW_PROP(name) REMAP_VIEW_PROP(name, name) #define MAP_VIEW_PROP(name) REMAP_VIEW_PROP(name, name)
#define REMAP_SCROLL_VIEW_PROP(reactName, localName) \ #define REMAP_SCROLL_VIEW_PROP(reactName, localName) \
REMAP_PROP(reactName, localName, ((RNEnhancedScrollView *)_scrollView)) REMAP_PROP(reactName, localName, ((RCTEnhancedScrollView *)_scrollView))
#define MAP_SCROLL_VIEW_PROP(name) REMAP_SCROLL_VIEW_PROP(name, name) #define MAP_SCROLL_VIEW_PROP(name) REMAP_SCROLL_VIEW_PROP(name, name)
// FIXME: Commented props are not supported yet. // FIXME: Commented props are not supported yet.
@ -137,12 +137,12 @@ using namespace facebook::react;
_scrollView.contentSize = contentSize; _scrollView.contentSize = contentSize;
} }
- (void)mountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{ {
[_containerView insertSubview:childComponentView atIndex:index]; [_containerView insertSubview:childComponentView atIndex:index];
} }
- (void)unmountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{ {
RCTAssert(childComponentView.superview == _containerView, @"Attempt to unmount improperly mounted component view."); RCTAssert(childComponentView.superview == _containerView, @"Attempt to unmount improperly mounted component view.");
[childComponentView removeFromSuperview]; [childComponentView removeFromSuperview];
@ -267,7 +267,7 @@ using namespace facebook::react;
@end @end
@implementation RNScrollViewComponentView (ScrollableProtocol) @implementation RCTScrollViewComponentView (ScrollableProtocol)
- (CGSize)contentSize - (CGSize)contentSize
{ {

Просмотреть файл

@ -7,14 +7,14 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for root <Slider> component. * UIView class for root <Slider> component.
*/ */
@interface RNSliderComponentView : RNViewComponentView @interface RCTSliderComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSliderComponentView.h" #import "RCTSliderComponentView.h"
#import <React/RNImageResponseObserverProxy.h> #import <React/RCTImageResponseObserverProxy.h>
#import <react/components/rncore/EventEmitters.h> #import <react/components/rncore/EventEmitters.h>
#import <react/components/rncore/Props.h> #import <react/components/rncore/Props.h>
#import <react/components/slider/SliderComponentDescriptor.h> #import <react/components/slider/SliderComponentDescriptor.h>
@ -15,7 +15,7 @@
using namespace facebook::react; using namespace facebook::react;
@implementation RNSliderComponentView { @implementation RCTSliderComponentView {
UISlider *_sliderView; UISlider *_sliderView;
float _previousValue; float _previousValue;
SharedSliderLocalData _sliderLocalData; SharedSliderLocalData _sliderLocalData;
@ -30,10 +30,10 @@ using namespace facebook::react;
const ImageResponseObserverCoordinator *_maximumTrackImageCoordinator; const ImageResponseObserverCoordinator *_maximumTrackImageCoordinator;
const ImageResponseObserverCoordinator *_thumbImageCoordinator; const ImageResponseObserverCoordinator *_thumbImageCoordinator;
std::unique_ptr<RNImageResponseObserverProxy> _trackImageResponseObserverProxy; std::unique_ptr<RCTImageResponseObserverProxy> _trackImageResponseObserverProxy;
std::unique_ptr<RNImageResponseObserverProxy> _minimumTrackImageResponseObserverProxy; std::unique_ptr<RCTImageResponseObserverProxy> _minimumTrackImageResponseObserverProxy;
std::unique_ptr<RNImageResponseObserverProxy> _maximumTrackImageResponseObserverProxy; std::unique_ptr<RCTImageResponseObserverProxy> _maximumTrackImageResponseObserverProxy;
std::unique_ptr<RNImageResponseObserverProxy> _thumbImageResponseObserverProxy; std::unique_ptr<RCTImageResponseObserverProxy> _thumbImageResponseObserverProxy;
} }
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
@ -51,10 +51,10 @@ using namespace facebook::react;
_sliderView.value = defaultProps->value; _sliderView.value = defaultProps->value;
_trackImageResponseObserverProxy = std::make_unique<RNImageResponseObserverProxy>((__bridge void *)self); _trackImageResponseObserverProxy = std::make_unique<RCTImageResponseObserverProxy>((__bridge void *)self);
_minimumTrackImageResponseObserverProxy = std::make_unique<RNImageResponseObserverProxy>((__bridge void *)self); _minimumTrackImageResponseObserverProxy = std::make_unique<RCTImageResponseObserverProxy>((__bridge void *)self);
_maximumTrackImageResponseObserverProxy = std::make_unique<RNImageResponseObserverProxy>((__bridge void *)self); _maximumTrackImageResponseObserverProxy = std::make_unique<RCTImageResponseObserverProxy>((__bridge void *)self);
_thumbImageResponseObserverProxy = std::make_unique<RNImageResponseObserverProxy>((__bridge void *)self); _thumbImageResponseObserverProxy = std::make_unique<RCTImageResponseObserverProxy>((__bridge void *)self);
self.contentView = _sliderView; self.contentView = _sliderView;
} }
@ -100,7 +100,7 @@ using namespace facebook::react;
_thumbImageResponseObserverProxy.reset(); _thumbImageResponseObserverProxy.reset();
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
@ -310,7 +310,7 @@ using namespace facebook::react;
_previousValue = value; _previousValue = value;
} }
#pragma mark - RNImageResponseDelegate #pragma mark - RCTImageResponseDelegate
- (void)didReceiveImage:(UIImage *)image fromObserver:(void *)observer - (void)didReceiveImage:(UIImage *)image fromObserver:(void *)observer
{ {

Просмотреть файл

@ -7,14 +7,14 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for root <Switch> component. * UIView class for root <Switch> component.
*/ */
@interface RNSwitchComponentView : RNViewComponentView @interface RCTSwitchComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSwitchComponentView.h" #import "RCTSwitchComponentView.h"
#import <react/components/rncore/ComponentDescriptors.h> #import <react/components/rncore/ComponentDescriptors.h>
#import <react/components/rncore/EventEmitters.h> #import <react/components/rncore/EventEmitters.h>
@ -13,7 +13,7 @@
using namespace facebook::react; using namespace facebook::react;
@implementation RNSwitchComponentView { @implementation RCTSwitchComponentView {
UISwitch *_switchView; UISwitch *_switchView;
BOOL _wasOn; BOOL _wasOn;
} }
@ -36,7 +36,7 @@ using namespace facebook::react;
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {

Просмотреть файл

@ -7,14 +7,14 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for <Paragraph> component. * UIView class for <Paragraph> component.
*/ */
@interface RNParagraphComponentView : RNViewComponentView @interface RCTParagraphComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNParagraphComponentView.h" #import "RCTParagraphComponentView.h"
#import <react/components/text/ParagraphComponentDescriptor.h> #import <react/components/text/ParagraphComponentDescriptor.h>
#import <react/components/text/ParagraphProps.h> #import <react/components/text/ParagraphProps.h>
@ -16,11 +16,11 @@
#import <react/graphics/Geometry.h> #import <react/graphics/Geometry.h>
#import <react/textlayoutmanager/RCTTextLayoutManager.h> #import <react/textlayoutmanager/RCTTextLayoutManager.h>
#import <react/textlayoutmanager/TextLayoutManager.h> #import <react/textlayoutmanager/TextLayoutManager.h>
#import "RNConversions.h" #import "RCTConversions.h"
using namespace facebook::react; using namespace facebook::react;
@implementation RNParagraphComponentView { @implementation RCTParagraphComponentView {
ParagraphShadowNode::ConcreteState::Shared _state; ParagraphShadowNode::ConcreteState::Shared _state;
ParagraphAttributes _paragraphAttributes; ParagraphAttributes _paragraphAttributes;
} }
@ -40,7 +40,7 @@ using namespace facebook::react;
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {

Просмотреть файл

@ -7,11 +7,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface RNUnimplementedNativeComponentView : RNViewComponentView @interface RCTUnimplementedNativeComponentView : RCTViewComponentView
@end @end

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNUnimplementedNativeComponentView.h" #import "RCTUnimplementedNativeComponentView.h"
#import <react/components/rncore/ComponentDescriptors.h> #import <react/components/rncore/ComponentDescriptors.h>
#import <react/components/rncore/EventEmitters.h> #import <react/components/rncore/EventEmitters.h>
@ -13,7 +13,7 @@
using namespace facebook::react; using namespace facebook::react;
@implementation RNUnimplementedNativeComponentView { @implementation RCTUnimplementedNativeComponentView {
UILabel *_label; UILabel *_label;
} }
@ -38,7 +38,7 @@ using namespace facebook::react;
return self; return self;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {

Просмотреть файл

@ -7,8 +7,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNComponentViewProtocol.h> #import <React/RCTComponentViewProtocol.h>
#import <React/RNTouchableComponentViewProtocol.h> #import <React/RCTTouchableComponentViewProtocol.h>
#import <React/UIView+ComponentViewProtocol.h> #import <React/UIView+ComponentViewProtocol.h>
#import <react/components/view/ViewEventEmitter.h> #import <react/components/view/ViewEventEmitter.h>
#import <react/components/view/ViewProps.h> #import <react/components/view/ViewProps.h>
@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
/** /**
* UIView class for <View> component. * UIView class for <View> component.
*/ */
@interface RNViewComponentView : UIView <RNComponentViewProtocol, RNTouchableComponentViewProtocol> { @interface RCTViewComponentView : UIView <RCTComponentViewProtocol, RCTTouchableComponentViewProtocol> {
@protected @protected
facebook::react::LayoutMetrics _layoutMetrics; facebook::react::LayoutMetrics _layoutMetrics;
facebook::react::SharedViewProps _props; facebook::react::SharedViewProps _props;
@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets; @property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
/** /**
* Enforcing `call super` semantic for overridden methods from `RNComponentViewProtocol`. * Enforcing `call super` semantic for overridden methods from `RCTComponentViewProtocol`.
* The methods update the instance variables. * The methods update the instance variables.
*/ */
- (void)updateProps:(facebook::react::Props::Shared const &)props - (void)updateProps:(facebook::react::Props::Shared const &)props

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNViewComponentView.h" #import "RCTViewComponentView.h"
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
#import <React/RCTBorderDrawing.h> #import <React/RCTBorderDrawing.h>
@ -14,11 +14,11 @@
#import <react/components/view/ViewEventEmitter.h> #import <react/components/view/ViewEventEmitter.h>
#import <react/components/view/ViewProps.h> #import <react/components/view/ViewProps.h>
#import "RNConversions.h" #import "RCTConversions.h"
using namespace facebook::react; using namespace facebook::react;
@implementation RNViewComponentView { @implementation RCTViewComponentView {
UIColor *_backgroundColor; UIColor *_backgroundColor;
CALayer *_borderLayer; CALayer *_borderLayer;
BOOL _needsInvalidateLayer; BOOL _needsInvalidateLayer;
@ -83,13 +83,13 @@ using namespace facebook::react;
_backgroundColor = backgroundColor; _backgroundColor = backgroundColor;
} }
#pragma mark - RNComponentViewProtocol #pragma mark - RCTComponentViewProtocol
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
RCTAssert( RCTAssert(
self == [RNViewComponentView class], self == [RCTViewComponentView class],
@"`+[RNComponentViewProtocol componentDescriptorProvider]` must be implemented for all subclasses (and `%@` particularly).", @"`+[RCTComponentViewProtocol componentDescriptorProvider]` must be implemented for all subclasses (and `%@` particularly).",
NSStringFromClass([self class])); NSStringFromClass([self class]));
return concreteComponentDescriptorProvider<ViewComponentDescriptor>(); return concreteComponentDescriptorProvider<ViewComponentDescriptor>();
} }
@ -100,9 +100,9 @@ using namespace facebook::react;
auto propsRawPtr = _props.get(); auto propsRawPtr = _props.get();
RCTAssert( RCTAssert(
propsRawPtr && propsRawPtr &&
([self class] == [RNViewComponentView class] || ([self class] == [RCTViewComponentView class] ||
typeid(*propsRawPtr).hash_code() != typeid(ViewProps const).hash_code()), typeid(*propsRawPtr).hash_code() != typeid(ViewProps const).hash_code()),
@"`RNViewComponentView` subclasses (and `%@` particularly) must setup `_props`" @"`RCTViewComponentView` subclasses (and `%@` particularly) must setup `_props`"
" instance variable with a default value in the constructor.", " instance variable with a default value in the constructor.",
NSStringFromClass([self class])); NSStringFromClass([self class]));
#endif #endif

Просмотреть файл

@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNComponentViewProtocol.h> #import <React/RCTComponentViewProtocol.h>
#import <react/uimanager/ComponentDescriptorRegistry.h> #import <react/uimanager/ComponentDescriptorRegistry.h>
@ -17,27 +17,27 @@ NS_ASSUME_NONNULL_BEGIN
* Registry of supported component view classes that can instantiate * Registry of supported component view classes that can instantiate
* view component instances by given component handle. * view component instances by given component handle.
*/ */
@interface RNComponentViewFactory : NSObject @interface RCTComponentViewFactory : NSObject
/** /**
* Constructs and returns an instance of the class with a bunch of already registered standard components. * Constructs and returns an instance of the class with a bunch of already registered standard components.
*/ */
+ (RNComponentViewFactory *)standardComponentViewFactory; + (RCTComponentViewFactory *)standardComponentViewFactory;
/** /**
* Registers a component view class in the factory. * Registers a component view class in the factory.
*/ */
- (void)registerComponentViewClass:(Class<RNComponentViewProtocol>)componentViewClass; - (void)registerComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass;
/** /**
* Unregisters a component view class in the factory. * Unregisters a component view class in the factory.
*/ */
- (void)unregisterComponentViewClass:(Class<RNComponentViewProtocol>)componentViewClass; - (void)unregisterComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass;
/** /**
* Creates a component view with given component handle. * Creates a component view with given component handle.
*/ */
- (UIView<RNComponentViewProtocol> *)createComponentViewWithComponentHandle: - (UIView<RCTComponentViewProtocol> *)createComponentViewWithComponentHandle:
(facebook::react::ComponentHandle)componentHandle; (facebook::react::ComponentHandle)componentHandle;
/** /**

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNComponentViewFactory.h" #import "RCTComponentViewFactory.h"
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
#import <better/map.h> #import <better/map.h>
@ -14,46 +14,46 @@
#import <react/core/ReactPrimitives.h> #import <react/core/ReactPrimitives.h>
#import <react/uimanager/ComponentDescriptorProviderRegistry.h> #import <react/uimanager/ComponentDescriptorProviderRegistry.h>
#import "RNActivityIndicatorViewComponentView.h" #import "RCTActivityIndicatorViewComponentView.h"
#import "RNImageComponentView.h" #import "RCTImageComponentView.h"
#import "RNModalHostViewComponentView.h" #import "RCTModalHostViewComponentView.h"
#import "RNParagraphComponentView.h" #import "RCTParagraphComponentView.h"
#import "RNPullToRefreshViewComponentView.h" #import "RCTPullToRefreshViewComponentView.h"
#import "RNRootComponentView.h" #import "RCTRootComponentView.h"
#import "RNScrollViewComponentView.h" #import "RCTScrollViewComponentView.h"
#import "RNSliderComponentView.h" #import "RCTSliderComponentView.h"
#import "RNSwitchComponentView.h" #import "RCTSwitchComponentView.h"
#import "RNUnimplementedNativeComponentView.h" #import "RCTUnimplementedNativeComponentView.h"
#import "RNViewComponentView.h" #import "RCTViewComponentView.h"
using namespace facebook::react; using namespace facebook::react;
@implementation RNComponentViewFactory { @implementation RCTComponentViewFactory {
better::map<ComponentHandle, Class<RNComponentViewProtocol>> _componentViewClasses; better::map<ComponentHandle, Class<RCTComponentViewProtocol>> _componentViewClasses;
ComponentDescriptorProviderRegistry _providerRegistry; ComponentDescriptorProviderRegistry _providerRegistry;
better::shared_mutex _mutex; better::shared_mutex _mutex;
} }
+ (RNComponentViewFactory *)standardComponentViewFactory + (RCTComponentViewFactory *)standardComponentViewFactory
{ {
RNComponentViewFactory *componentViewFactory = [[RNComponentViewFactory alloc] init]; RCTComponentViewFactory *componentViewFactory = [[RCTComponentViewFactory alloc] init];
[componentViewFactory registerComponentViewClass:[RNViewComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTViewComponentView class]];
[componentViewFactory registerComponentViewClass:[RNRootComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTRootComponentView class]];
[componentViewFactory registerComponentViewClass:[RNScrollViewComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTScrollViewComponentView class]];
[componentViewFactory registerComponentViewClass:[RNPullToRefreshViewComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTPullToRefreshViewComponentView class]];
[componentViewFactory registerComponentViewClass:[RNImageComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTImageComponentView class]];
[componentViewFactory registerComponentViewClass:[RNParagraphComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTParagraphComponentView class]];
[componentViewFactory registerComponentViewClass:[RNActivityIndicatorViewComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTActivityIndicatorViewComponentView class]];
[componentViewFactory registerComponentViewClass:[RNSliderComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTSliderComponentView class]];
[componentViewFactory registerComponentViewClass:[RNSwitchComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTSwitchComponentView class]];
[componentViewFactory registerComponentViewClass:[RNUnimplementedNativeComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTUnimplementedNativeComponentView class]];
[componentViewFactory registerComponentViewClass:[RNModalHostViewComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTModalHostViewComponentView class]];
return componentViewFactory; return componentViewFactory;
} }
- (void)registerComponentViewClass:(Class<RNComponentViewProtocol>)componentViewClass - (void)registerComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass
{ {
std::unique_lock<better::shared_mutex> lock(_mutex); std::unique_lock<better::shared_mutex> lock(_mutex);
@ -67,7 +67,7 @@ using namespace facebook::react;
} }
} }
- (void)unregisterComponentViewClass:(Class<RNComponentViewProtocol>)componentViewClass - (void)unregisterComponentViewClass:(Class<RCTComponentViewProtocol>)componentViewClass
{ {
std::unique_lock<better::shared_mutex> lock(_mutex); std::unique_lock<better::shared_mutex> lock(_mutex);
@ -76,7 +76,7 @@ using namespace facebook::react;
_providerRegistry.remove(componentDescriptorProvider); _providerRegistry.remove(componentDescriptorProvider);
} }
- (UIView<RNComponentViewProtocol> *)createComponentViewWithComponentHandle: - (UIView<RCTComponentViewProtocol> *)createComponentViewWithComponentHandle:
(facebook::react::ComponentHandle)componentHandle (facebook::react::ComponentHandle)componentHandle
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();

Просмотреть файл

@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNPrimitives.h> #import <React/RCTPrimitives.h>
#import <react/core/EventEmitter.h> #import <react/core/EventEmitter.h>
#import <react/core/LayoutMetrics.h> #import <react/core/LayoutMetrics.h>
#import <react/core/LocalData.h> #import <react/core/LocalData.h>
@ -38,7 +38,7 @@ typedef NS_OPTIONS(NSInteger, RNComponentViewUpdateMask) {
* `UIView+ComponentViewProtocol` category provides default implementation * `UIView+ComponentViewProtocol` category provides default implementation
* for all of them. * for all of them.
*/ */
@protocol RNComponentViewProtocol <NSObject> @protocol RCTComponentViewProtocol <NSObject>
/* /*
* Returns a `ComponentDescriptorProvider` of a particular `ComponentDescriptor` which this component view * Returns a `ComponentDescriptorProvider` of a particular `ComponentDescriptor` which this component view
@ -57,14 +57,14 @@ typedef NS_OPTIONS(NSInteger, RNComponentViewUpdateMask) {
* component view. * component view.
* Receiver must add `childComponentView` as a subview. * Receiver must add `childComponentView` as a subview.
*/ */
- (void)mountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index; - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
/* /*
* Called for unmounting (detaching) a child component view from `self` * Called for unmounting (detaching) a child component view from `self`
* component view. * component view.
* Receiver must remove `childComponentView` as a subview. * Receiver must remove `childComponentView` as a subview.
*/ */
- (void)unmountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index; - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
/* /*
* Called for updating component's props. * Called for updating component's props.

Просмотреть файл

@ -7,8 +7,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNComponentViewFactory.h> #import <React/RCTComponentViewFactory.h>
#import <React/RNComponentViewProtocol.h> #import <React/RCTComponentViewProtocol.h>
#import <react/core/ReactPrimitives.h> #import <react/core/ReactPrimitives.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -17,18 +17,18 @@ NS_ASSUME_NONNULL_BEGIN
* Registry of native component views. * Registry of native component views.
* Provides basic functionality for allocation, recycling, and querying (by tag) native view instances. * Provides basic functionality for allocation, recycling, and querying (by tag) native view instances.
*/ */
@interface RNComponentViewRegistry : NSObject @interface RCTComponentViewRegistry : NSObject
@property (nonatomic, strong, readonly) RNComponentViewFactory *componentViewFactory; @property (nonatomic, strong, readonly) RCTComponentViewFactory *componentViewFactory;
/** /**
* Returns a native view instance from the recycle pool (or create) * Returns a native view instance from the recycle pool (or create)
* for given `componentHandle` and with given `tag`. * for given `componentHandle` and with given `tag`.
* #RefuseSingleUse * #RefuseSingleUse
*/ */
- (UIView<RNComponentViewProtocol> *)dequeueComponentViewWithComponentHandle: - (UIView<RCTComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:
(facebook::react::ComponentHandle)componentHandle (facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag; tag:(ReactTag)tag;
/** /**
* Puts a given native component view to the recycle pool. * Puts a given native component view to the recycle pool.
@ -36,17 +36,17 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)enqueueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle - (void)enqueueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag tag:(ReactTag)tag
componentView:(UIView<RNComponentViewProtocol> *)componentView; componentView:(UIView<RCTComponentViewProtocol> *)componentView;
/** /**
* Returns a native component view by given `tag`. * Returns a native component view by given `tag`.
*/ */
- (UIView<RNComponentViewProtocol> *)componentViewByTag:(ReactTag)tag; - (UIView<RCTComponentViewProtocol> *)componentViewByTag:(ReactTag)tag;
/** /**
* Returns `tag` associated with given `componentView`. * Returns `tag` associated with given `componentView`.
*/ */
- (ReactTag)tagByComponentView:(UIView<RNComponentViewProtocol> *)componentView; - (ReactTag)tagByComponentView:(UIView<RCTComponentViewProtocol> *)componentView;
/** /**
* Creates a component view with a given type and puts it to the recycle pool. * Creates a component view with a given type and puts it to the recycle pool.

Просмотреть файл

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNComponentViewRegistry.h" #import "RCTComponentViewRegistry.h"
#import <Foundation/NSMapTable.h> #import <Foundation/NSMapTable.h>
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
#import "RNImageComponentView.h" #import "RCTImageComponentView.h"
#import "RNParagraphComponentView.h" #import "RCTParagraphComponentView.h"
#import "RNViewComponentView.h" #import "RCTViewComponentView.h"
using namespace facebook::react; using namespace facebook::react;
@ -70,11 +70,11 @@ using namespace facebook::react;
#endif #endif
const NSInteger RNComponentViewRegistryRecyclePoolMaxSize = 1024; const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
@implementation RNComponentViewRegistry { @implementation RCTComponentViewRegistry {
NSMapTable<id /* ReactTag */, UIView<RNComponentViewProtocol> *> *_registry; NSMapTable<id /* ReactTag */, UIView<RCTComponentViewProtocol> *> *_registry;
NSMapTable<id /* ComponentHandle */, NSHashTable<UIView<RNComponentViewProtocol> *> *> *_recyclePool; NSMapTable<id /* ComponentHandle */, NSHashTable<UIView<RCTComponentViewProtocol> *> *> *_recyclePool;
} }
- (instancetype)init - (instancetype)init
@ -85,7 +85,7 @@ const NSInteger RNComponentViewRegistryRecyclePoolMaxSize = 1024;
_recyclePool = _recyclePool =
[NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaquePersonality | NSPointerFunctionsOpaqueMemory [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaquePersonality | NSPointerFunctionsOpaqueMemory
valueOptions:NSPointerFunctionsObjectPersonality]; valueOptions:NSPointerFunctionsObjectPersonality];
_componentViewFactory = [RNComponentViewFactory standardComponentViewFactory]; _componentViewFactory = [RCTComponentViewFactory standardComponentViewFactory];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleApplicationDidReceiveMemoryWarningNotification) selector:@selector(handleApplicationDidReceiveMemoryWarningNotification)
@ -106,9 +106,9 @@ const NSInteger RNComponentViewRegistryRecyclePoolMaxSize = 1024;
// This data is based on empirical evidence which should represent the reality pretty well. // This data is based on empirical evidence which should represent the reality pretty well.
// Regular `<View>` has magnitude equals to `1` by definition. // Regular `<View>` has magnitude equals to `1` by definition.
std::vector<std::pair<ComponentHandle, float>> componentMagnitudes = { std::vector<std::pair<ComponentHandle, float>> componentMagnitudes = {
{[RNViewComponentView componentDescriptorProvider].handle, 1}, {[RCTViewComponentView componentDescriptorProvider].handle, 1},
{[RNImageComponentView componentDescriptorProvider].handle, 0.3}, {[RCTImageComponentView componentDescriptorProvider].handle, 0.3},
{[RNParagraphComponentView componentDescriptorProvider].handle, 0.3}, {[RCTParagraphComponentView componentDescriptorProvider].handle, 0.3},
}; };
// `complexity` represents the complexity of a typical surface in a number of `<View>` components (with Flattening // `complexity` represents the complexity of a typical surface in a number of `<View>` components (with Flattening
@ -128,16 +128,16 @@ const NSInteger RNComponentViewRegistryRecyclePoolMaxSize = 1024;
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
} }
- (UIView<RNComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle - (UIView<RCTComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
tag:(ReactTag)tag tag:(ReactTag)tag
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
RCTAssert( RCTAssert(
![_registry objectForKey:(__bridge id)(void *)tag], ![_registry objectForKey:(__bridge id)(void *)tag],
@"RNComponentViewRegistry: Attempt to dequeue already registered component."); @"RCTComponentViewRegistry: Attempt to dequeue already registered component.");
UIView<RNComponentViewProtocol> *componentView = [self _dequeueComponentViewWithComponentHandle:componentHandle]; UIView<RCTComponentViewProtocol> *componentView = [self _dequeueComponentViewWithComponentHandle:componentHandle];
componentView.tag = tag; componentView.tag = tag;
[_registry setObject:componentView forKey:(__bridge id)(void *)tag]; [_registry setObject:componentView forKey:(__bridge id)(void *)tag];
@ -150,13 +150,13 @@ const NSInteger RNComponentViewRegistryRecyclePoolMaxSize = 1024;
- (void)enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandle - (void)enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
tag:(ReactTag)tag tag:(ReactTag)tag
componentView:(UIView<RNComponentViewProtocol> *)componentView componentView:(UIView<RCTComponentViewProtocol> *)componentView
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
RCTAssert( RCTAssert(
[_registry objectForKey:(__bridge id)(void *)tag], [_registry objectForKey:(__bridge id)(void *)tag],
@"RNComponentViewRegistry: Attempt to enqueue unregistered component."); @"RCTComponentViewRegistry: Attempt to enqueue unregistered component.");
#ifdef LEGACY_UIMANAGER_INTEGRATION_ENABLED #ifdef LEGACY_UIMANAGER_INTEGRATION_ENABLED
[RCTUIManager unregisterView:componentView]; [RCTUIManager unregisterView:componentView];
@ -175,44 +175,44 @@ const NSInteger RNComponentViewRegistryRecyclePoolMaxSize = 1024;
createComponentViewWithComponentHandle:componentHandle]]; createComponentViewWithComponentHandle:componentHandle]];
} }
- (UIView<RNComponentViewProtocol> *)componentViewByTag:(ReactTag)tag - (UIView<RCTComponentViewProtocol> *)componentViewByTag:(ReactTag)tag
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
return [_registry objectForKey:(__bridge id)(void *)tag]; return [_registry objectForKey:(__bridge id)(void *)tag];
} }
- (ReactTag)tagByComponentView:(UIView<RNComponentViewProtocol> *)componentView - (ReactTag)tagByComponentView:(UIView<RCTComponentViewProtocol> *)componentView
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
return componentView.tag; return componentView.tag;
} }
- (nullable UIView<RNComponentViewProtocol> *)_dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle - (nullable UIView<RCTComponentViewProtocol> *)_dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
NSHashTable<UIView<RNComponentViewProtocol> *> *componentViews = NSHashTable<UIView<RCTComponentViewProtocol> *> *componentViews =
[_recyclePool objectForKey:(__bridge id)(void *)componentHandle]; [_recyclePool objectForKey:(__bridge id)(void *)componentHandle];
if (!componentViews || componentViews.count == 0) { if (!componentViews || componentViews.count == 0) {
return [self.componentViewFactory createComponentViewWithComponentHandle:componentHandle]; return [self.componentViewFactory createComponentViewWithComponentHandle:componentHandle];
} }
UIView<RNComponentViewProtocol> *componentView = [componentViews anyObject]; UIView<RCTComponentViewProtocol> *componentView = [componentViews anyObject];
[componentViews removeObject:componentView]; [componentViews removeObject:componentView];
return componentView; return componentView;
} }
- (void)_enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandle - (void)_enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
componentView:(UIView<RNComponentViewProtocol> *)componentView componentView:(UIView<RCTComponentViewProtocol> *)componentView
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
NSHashTable<UIView<RNComponentViewProtocol> *> *componentViews = NSHashTable<UIView<RCTComponentViewProtocol> *> *componentViews =
[_recyclePool objectForKey:(__bridge id)(void *)componentHandle]; [_recyclePool objectForKey:(__bridge id)(void *)componentHandle];
if (!componentViews) { if (!componentViews) {
componentViews = [NSHashTable hashTableWithOptions:NSPointerFunctionsObjectPersonality]; componentViews = [NSHashTable hashTableWithOptions:NSPointerFunctionsObjectPersonality];
[_recyclePool setObject:componentViews forKey:(__bridge id)(void *)componentHandle]; [_recyclePool setObject:componentViews forKey:(__bridge id)(void *)componentHandle];
} }
if (componentViews.count >= RNComponentViewRegistryRecyclePoolMaxSize) { if (componentViews.count >= RCTComponentViewRegistryRecyclePoolMaxSize) {
return; return;
} }

Просмотреть файл

@ -7,8 +7,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNMountingManagerDelegate.h> #import <React/RCTMountingManagerDelegate.h>
#import <React/RNPrimitives.h> #import <React/RCTPrimitives.h>
#import <react/core/ComponentDescriptor.h> #import <react/core/ComponentDescriptor.h>
#import <react/core/ReactPrimitives.h> #import <react/core/ReactPrimitives.h>
#import <react/mounting/MountingCoordinator.h> #import <react/mounting/MountingCoordinator.h>
@ -16,15 +16,15 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RNComponentViewRegistry; @class RCTComponentViewRegistry;
/** /**
* Manages mounting process. * Manages mounting process.
*/ */
@interface RNMountingManager : NSObject @interface RCTMountingManager : NSObject
@property (nonatomic, weak) id<RNMountingManagerDelegate> delegate; @property (nonatomic, weak) id<RCTMountingManagerDelegate> delegate;
@property (nonatomic, strong) RNComponentViewRegistry *componentViewRegistry; @property (nonatomic, strong) RCTComponentViewRegistry *componentViewRegistry;
/** /**
* Schedule a mounting transaction to be performed on the main thread. * Schedule a mounting transaction to be performed on the main thread.

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNMountingManager.h" #import "RCTMountingManager.h"
#import <better/map.h> #import <better/map.h>
@ -16,25 +16,25 @@
#import <react/core/RawProps.h> #import <react/core/RawProps.h>
#import <react/debug/SystraceSection.h> #import <react/debug/SystraceSection.h>
#import "RNComponentViewProtocol.h" #import "RCTComponentViewProtocol.h"
#import "RNComponentViewRegistry.h" #import "RCTComponentViewRegistry.h"
#import "RNConversions.h" #import "RCTConversions.h"
using namespace facebook; using namespace facebook;
using namespace facebook::react; using namespace facebook::react;
// `Create` instruction // `Create` instruction
static void RNCreateMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNCreateMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
[registry dequeueComponentViewWithComponentHandle:mutation.newChildShadowView.componentHandle [registry dequeueComponentViewWithComponentHandle:mutation.newChildShadowView.componentHandle
tag:mutation.newChildShadowView.tag]; tag:mutation.newChildShadowView.tag];
} }
// `Delete` instruction // `Delete` instruction
static void RNDeleteMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNDeleteMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &oldChildShadowView = mutation.oldChildShadowView; auto const &oldChildShadowView = mutation.oldChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:oldChildShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:oldChildShadowView.tag];
assert(componentView != nil && "Attempt to delete unregistered component."); assert(componentView != nil && "Attempt to delete unregistered component.");
@ -44,13 +44,13 @@ static void RNDeleteMountInstruction(ShadowViewMutation const &mutation, RNCompo
} }
// `Insert` instruction // `Insert` instruction
static void RNInsertMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNInsertMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
auto const &parentShadowView = mutation.parentShadowView; auto const &parentShadowView = mutation.parentShadowView;
UIView<RNComponentViewProtocol> *childComponentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *childComponentView = [registry componentViewByTag:newShadowView.tag];
UIView<RNComponentViewProtocol> *parentComponentView = [registry componentViewByTag:parentShadowView.tag]; UIView<RCTComponentViewProtocol> *parentComponentView = [registry componentViewByTag:parentShadowView.tag];
assert(childComponentView != nil && "Attempt to mount unregistered component."); assert(childComponentView != nil && "Attempt to mount unregistered component.");
assert(parentComponentView != nil && "Attempt to mount into unregistered component."); assert(parentComponentView != nil && "Attempt to mount into unregistered component.");
@ -59,13 +59,13 @@ static void RNInsertMountInstruction(ShadowViewMutation const &mutation, RNCompo
} }
// `Remove` instruction // `Remove` instruction
static void RNRemoveMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNRemoveMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &oldShadowView = mutation.oldChildShadowView; auto const &oldShadowView = mutation.oldChildShadowView;
auto const &parentShadowView = mutation.parentShadowView; auto const &parentShadowView = mutation.parentShadowView;
UIView<RNComponentViewProtocol> *childComponentView = [registry componentViewByTag:oldShadowView.tag]; UIView<RCTComponentViewProtocol> *childComponentView = [registry componentViewByTag:oldShadowView.tag];
UIView<RNComponentViewProtocol> *parentComponentView = [registry componentViewByTag:parentShadowView.tag]; UIView<RCTComponentViewProtocol> *parentComponentView = [registry componentViewByTag:parentShadowView.tag];
assert(childComponentView != nil && "Attempt to unmount unregistered component."); assert(childComponentView != nil && "Attempt to unmount unregistered component.");
assert(parentComponentView != nil && "Attempt to unmount from unregistered component."); assert(parentComponentView != nil && "Attempt to unmount from unregistered component.");
@ -74,46 +74,48 @@ static void RNRemoveMountInstruction(ShadowViewMutation const &mutation, RNCompo
} }
// `Update Props` instruction // `Update Props` instruction
static void RNUpdatePropsMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNUpdatePropsMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &oldShadowView = mutation.oldChildShadowView; auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag];
[componentView updateProps:newShadowView.props oldProps:oldShadowView.props]; [componentView updateProps:newShadowView.props oldProps:oldShadowView.props];
} }
// `Update EventEmitter` instruction // `Update EventEmitter` instruction
static void RNUpdateEventEmitterMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNUpdateEventEmitterMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag];
[componentView updateEventEmitter:newShadowView.eventEmitter]; [componentView updateEventEmitter:newShadowView.eventEmitter];
} }
// `Update LayoutMetrics` instruction // `Update LayoutMetrics` instruction
static void RNUpdateLayoutMetricsMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNUpdateLayoutMetricsMountInstruction(
ShadowViewMutation const &mutation,
RCTComponentViewRegistry *registry)
{ {
auto const &oldShadowView = mutation.oldChildShadowView; auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag];
[componentView updateLayoutMetrics:newShadowView.layoutMetrics oldLayoutMetrics:oldShadowView.layoutMetrics]; [componentView updateLayoutMetrics:newShadowView.layoutMetrics oldLayoutMetrics:oldShadowView.layoutMetrics];
} }
// `Update LocalData` instruction // `Update LocalData` instruction
static void RNUpdateLocalDataMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNUpdateLocalDataMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &oldShadowView = mutation.oldChildShadowView; auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag];
[componentView updateLocalData:newShadowView.localData oldLocalData:oldShadowView.localData]; [componentView updateLocalData:newShadowView.localData oldLocalData:oldShadowView.localData];
} }
// `Update State` instruction // `Update State` instruction
static void RNUpdateStateMountInstruction(ShadowViewMutation const &mutation, RNComponentViewRegistry *registry) static void RNUpdateStateMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{ {
auto const &oldShadowView = mutation.oldChildShadowView; auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag];
[componentView updateState:newShadowView.state oldState:oldShadowView.state]; [componentView updateState:newShadowView.state oldState:oldShadowView.state];
} }
@ -121,15 +123,15 @@ static void RNUpdateStateMountInstruction(ShadowViewMutation const &mutation, RN
static void RNFinalizeUpdatesMountInstruction( static void RNFinalizeUpdatesMountInstruction(
ShadowViewMutation const &mutation, ShadowViewMutation const &mutation,
RNComponentViewUpdateMask mask, RNComponentViewUpdateMask mask,
RNComponentViewRegistry *registry) RCTComponentViewRegistry *registry)
{ {
auto const &newShadowView = mutation.newChildShadowView; auto const &newShadowView = mutation.newChildShadowView;
UIView<RNComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag]; UIView<RCTComponentViewProtocol> *componentView = [registry componentViewByTag:newShadowView.tag];
[componentView finalizeUpdates:mask]; [componentView finalizeUpdates:mask];
} }
// `Update` instruction // `Update` instruction
static void RNPerformMountInstructions(ShadowViewMutationList const &mutations, RNComponentViewRegistry *registry) static void RNPerformMountInstructions(ShadowViewMutationList const &mutations, RCTComponentViewRegistry *registry)
{ {
SystraceSection s("RNPerformMountInstructions"); SystraceSection s("RNPerformMountInstructions");
@ -194,12 +196,12 @@ static void RNPerformMountInstructions(ShadowViewMutationList const &mutations,
} }
} }
@implementation RNMountingManager @implementation RCTMountingManager
- (instancetype)init - (instancetype)init
{ {
if (self = [super init]) { if (self = [super init]) {
_componentViewRegistry = [[RNComponentViewRegistry alloc] init]; _componentViewRegistry = [[RCTComponentViewRegistry alloc] init];
} }
return self; return self;
@ -241,7 +243,7 @@ static void RNPerformMountInstructions(ShadowViewMutationList const &mutations,
- (void)mountMutations:(MountingCoordinator::Shared const &)mountingCoordinator - (void)mountMutations:(MountingCoordinator::Shared const &)mountingCoordinator
{ {
SystraceSection s("-[RNMountingManager mountMutations:]"); SystraceSection s("-[RCTMountingManager mountMutations:]");
auto transaction = mountingCoordinator->pullTransaction(); auto transaction = mountingCoordinator->pullTransaction();
if (!transaction.has_value()) { if (!transaction.has_value()) {
@ -261,7 +263,7 @@ static void RNPerformMountInstructions(ShadowViewMutationList const &mutations,
componentDescriptor:(const ComponentDescriptor &)componentDescriptor componentDescriptor:(const ComponentDescriptor &)componentDescriptor
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
UIView<RNComponentViewProtocol> *componentView = [_componentViewRegistry componentViewByTag:reactTag]; UIView<RCTComponentViewProtocol> *componentView = [_componentViewRegistry componentViewByTag:reactTag];
SharedProps oldProps = [componentView props]; SharedProps oldProps = [componentView props];
SharedProps newProps = componentDescriptor.cloneProps(oldProps, RawProps(convertIdToFollyDynamic(props))); SharedProps newProps = componentDescriptor.cloneProps(oldProps, RawProps(convertIdToFollyDynamic(props)));
[componentView updateProps:newProps oldProps:oldProps]; [componentView updateProps:newProps oldProps:oldProps];
@ -272,7 +274,7 @@ static void RNPerformMountInstructions(ShadowViewMutationList const &mutations,
args:(NSArray *)args args:(NSArray *)args
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
UIView<RNComponentViewProtocol> *componentView = [_componentViewRegistry componentViewByTag:reactTag]; UIView<RCTComponentViewProtocol> *componentView = [_componentViewRegistry componentViewByTag:reactTag];
[componentView handleCommand:commandName args:args]; [componentView handleCommand:commandName args:args];
} }

Просмотреть файл

@ -7,30 +7,30 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNPrimitives.h> #import <React/RCTPrimitives.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RNMountingManager; @class RCTMountingManager;
/** /**
* MountingManager's delegate. * MountingManager's delegate.
*/ */
@protocol RNMountingManagerDelegate <NSObject> @protocol RCTMountingManagerDelegate <NSObject>
/* /*
* Called right *before* execution of mount items which affect a Surface with * Called right *before* execution of mount items which affect a Surface with
* given `rootTag`. * given `rootTag`.
* Always called on the main queue. * Always called on the main queue.
*/ */
- (void)mountingManager:(RNMountingManager *)mountingManager willMountComponentsWithRootTag:(ReactTag)MountingManager; - (void)mountingManager:(RCTMountingManager *)mountingManager willMountComponentsWithRootTag:(ReactTag)MountingManager;
/* /*
* Called right *after* execution of mount items which affect a Surface with * Called right *after* execution of mount items which affect a Surface with
* given `rootTag`. * given `rootTag`.
* Always called on the main queue. * Always called on the main queue.
*/ */
- (void)mountingManager:(RNMountingManager *)mountingManager didMountComponentsWithRootTag:(ReactTag)rootTag; - (void)mountingManager:(RCTMountingManager *)mountingManager didMountComponentsWithRootTag:(ReactTag)rootTag;
@end @end

Просмотреть файл

@ -7,20 +7,20 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNComponentViewProtocol.h> #import <React/RCTComponentViewProtocol.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** /**
* Default implementation of RNComponentViewProtocol. * Default implementation of RCTComponentViewProtocol.
*/ */
@interface UIView (ComponentViewProtocol) <RNComponentViewProtocol> @interface UIView (ComponentViewProtocol) <RCTComponentViewProtocol>
+ (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders; + (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders;
- (void)mountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index; - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
- (void)unmountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index; - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
- (void)updateProps:(facebook::react::Props::Shared const &)props - (void)updateProps:(facebook::react::Props::Shared const &)props
oldProps:(facebook::react::Props::Shared const &)oldProps; oldProps:(facebook::react::Props::Shared const &)oldProps;

Просмотреть файл

@ -11,7 +11,7 @@
#import <React/RCTLog.h> #import <React/RCTLog.h>
#import <React/RCTUtils.h> #import <React/RCTUtils.h>
#import "RNConversions.h" #import "RCTConversions.h"
using namespace facebook::react; using namespace facebook::react;
@ -19,7 +19,7 @@ using namespace facebook::react;
+ (ComponentDescriptorProvider)componentDescriptorProvider + (ComponentDescriptorProvider)componentDescriptorProvider
{ {
RCTAssert(NO, @"`-[RNComponentViewProtocol componentDescriptorProvider]` must be implemented in a concrete class."); RCTAssert(NO, @"`-[RCTComponentViewProtocol componentDescriptorProvider]` must be implemented in a concrete class.");
return {}; return {};
} }
@ -28,12 +28,12 @@ using namespace facebook::react;
return {}; return {};
} }
- (void)mountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{ {
[self insertSubview:childComponentView atIndex:index]; [self insertSubview:childComponentView atIndex:index];
} }
- (void)unmountChildComponentView:(UIView<RNComponentViewProtocol> *)childComponentView index:(NSInteger)index - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{ {
RCTAssert(childComponentView.superview == self, @"Attempt to unmount improperly mounted component view."); RCTAssert(childComponentView.superview == self, @"Attempt to unmount improperly mounted component view.");
[childComponentView removeFromSuperview]; [childComponentView removeFromSuperview];
@ -115,7 +115,7 @@ using namespace facebook::react;
- (facebook::react::SharedProps)props - (facebook::react::SharedProps)props
{ {
RCTAssert(NO, @"props access should be implemented by RNViewComponentView."); RCTAssert(NO, @"props access should be implemented by RCTViewComponentView.");
return nullptr; return nullptr;
} }

Просмотреть файл

Просмотреть файл

@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol RNImageResponseDelegate <NSObject> @protocol RCTImageResponseDelegate <NSObject>
- (void)didReceiveImage:(UIImage *)image fromObserver:(void*)observer; - (void)didReceiveImage:(UIImage *)image fromObserver:(void*)observer;
- (void)didReceiveProgress:(float)progress fromObserver:(void*)observer; - (void)didReceiveProgress:(float)progress fromObserver:(void*)observer;

Просмотреть файл

@ -7,7 +7,7 @@
#pragma once #pragma once
#import "RNImageResponseDelegate.h" #import "RCTImageResponseDelegate.h"
#include <react/imagemanager/ImageResponseObserver.h> #include <react/imagemanager/ImageResponseObserver.h>
@ -15,15 +15,15 @@ NS_ASSUME_NONNULL_BEGIN
namespace facebook { namespace facebook {
namespace react { namespace react {
class RNImageResponseObserverProxy : public ImageResponseObserver { class RCTImageResponseObserverProxy : public ImageResponseObserver {
public: public:
RNImageResponseObserverProxy(void *delegate); RCTImageResponseObserverProxy(void *delegate);
void didReceiveImage(const ImageResponse &imageResponse) override; void didReceiveImage(const ImageResponse &imageResponse) override;
void didReceiveProgress(float p) override; void didReceiveProgress(float p) override;
void didReceiveFailure() override; void didReceiveFailure() override;
private: private:
__weak id<RNImageResponseDelegate> delegate_; __weak id<RCTImageResponseDelegate> delegate_;
}; };
} // namespace react } // namespace react
} // namespace facebook } // namespace facebook

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNImageResponseObserverProxy.h" #import "RCTImageResponseObserverProxy.h"
#import <react/imagemanager/ImageResponse.h> #import <react/imagemanager/ImageResponse.h>
#import <react/imagemanager/ImageResponseObserver.h> #import <react/imagemanager/ImageResponseObserver.h>
@ -13,12 +13,12 @@
namespace facebook { namespace facebook {
namespace react { namespace react {
RNImageResponseObserverProxy::RNImageResponseObserverProxy(void *delegate) RCTImageResponseObserverProxy::RCTImageResponseObserverProxy(void *delegate)
: delegate_((__bridge id<RNImageResponseDelegate>)delegate) : delegate_((__bridge id<RCTImageResponseDelegate>)delegate)
{ {
} }
void RNImageResponseObserverProxy::didReceiveImage(const ImageResponse &imageResponse) void RCTImageResponseObserverProxy::didReceiveImage(const ImageResponse &imageResponse)
{ {
UIImage *image = (__bridge UIImage *)imageResponse.getImage().get(); UIImage *image = (__bridge UIImage *)imageResponse.getImage().get();
void *this_ = this; void *this_ = this;
@ -27,7 +27,7 @@ void RNImageResponseObserverProxy::didReceiveImage(const ImageResponse &imageRes
}); });
} }
void RNImageResponseObserverProxy::didReceiveProgress(float p) void RCTImageResponseObserverProxy::didReceiveProgress(float p)
{ {
void *this_ = this; void *this_ = this;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
@ -35,7 +35,7 @@ void RNImageResponseObserverProxy::didReceiveProgress(float p)
}); });
} }
void RNImageResponseObserverProxy::didReceiveFailure() void RCTImageResponseObserverProxy::didReceiveFailure()
{ {
void *this_ = this; void *this_ = this;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{

Просмотреть файл

Просмотреть файл

@ -8,7 +8,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <memory> #import <memory>
#import <React/RNPrimitives.h> #import <React/RCTPrimitives.h>
#import <react/core/ComponentDescriptor.h> #import <react/core/ComponentDescriptor.h>
#import <react/core/LayoutConstraints.h> #import <react/core/LayoutConstraints.h>
#import <react/core/LayoutContext.h> #import <react/core/LayoutContext.h>
@ -19,12 +19,12 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RNMountingManager; @class RCTMountingManager;
/** /**
* Exactly same semantic as `facebook::react::SchedulerDelegate`. * Exactly same semantic as `facebook::react::SchedulerDelegate`.
*/ */
@protocol RNSchedulerDelegate @protocol RCTSchedulerDelegate
- (void)schedulerDidFinishTransaction:(facebook::react::MountingCoordinator::Shared const &)mountingCoordinator; - (void)schedulerDidFinishTransaction:(facebook::react::MountingCoordinator::Shared const &)mountingCoordinator;
@ -37,9 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
/** /**
* `facebook::react::Scheduler` as an Objective-C class. * `facebook::react::Scheduler` as an Objective-C class.
*/ */
@interface RNScheduler : NSObject @interface RCTScheduler : NSObject
@property (atomic, weak, nullable) id<RNSchedulerDelegate> delegate; @property (atomic, weak, nullable) id<RCTSchedulerDelegate> delegate;
- (instancetype)initWithToolbox:(facebook::react::SchedulerToolbox)toolbox; - (instancetype)initWithToolbox:(facebook::react::SchedulerToolbox)toolbox;

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNScheduler.h" #import "RCTScheduler.h"
#import <react/debug/SystraceSection.h> #import <react/debug/SystraceSection.h>
#import <react/uimanager/ComponentDescriptorFactory.h> #import <react/uimanager/ComponentDescriptorFactory.h>
@ -14,7 +14,7 @@
#import <React/RCTFollyConvert.h> #import <React/RCTFollyConvert.h>
#import "RNConversions.h" #import "RCTConversions.h"
using namespace facebook::react; using namespace facebook::react;
@ -24,7 +24,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
void schedulerDidFinishTransaction(MountingCoordinator::Shared const &mountingCoordinator) override void schedulerDidFinishTransaction(MountingCoordinator::Shared const &mountingCoordinator) override
{ {
RNScheduler *scheduler = (__bridge RNScheduler *)scheduler_; RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidFinishTransaction:mountingCoordinator]; [scheduler.delegate schedulerDidFinishTransaction:mountingCoordinator];
} }
@ -39,7 +39,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
const std::string &commandName, const std::string &commandName,
const folly::dynamic args) override const folly::dynamic args) override
{ {
RNScheduler *scheduler = (__bridge RNScheduler *)scheduler_; RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidDispatchCommand:shadowView commandName:commandName args:args]; [scheduler.delegate schedulerDidDispatchCommand:shadowView commandName:commandName args:args];
} }
@ -61,7 +61,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
void *scheduler_; void *scheduler_;
}; };
@implementation RNScheduler { @implementation RCTScheduler {
std::shared_ptr<Scheduler> _scheduler; std::shared_ptr<Scheduler> _scheduler;
std::shared_ptr<SchedulerDelegateProxy> _delegateProxy; std::shared_ptr<SchedulerDelegateProxy> _delegateProxy;
} }
@ -87,7 +87,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
layoutConstraints:(LayoutConstraints)layoutConstraints layoutConstraints:(LayoutConstraints)layoutConstraints
layoutContext:(LayoutContext)layoutContext; layoutContext:(LayoutContext)layoutContext;
{ {
SystraceSection s("-[RNScheduler startSurfaceWithSurfaceId:...]"); SystraceSection s("-[RCTScheduler startSurfaceWithSurfaceId:...]");
auto props = convertIdToFollyDynamic(initialProps); auto props = convertIdToFollyDynamic(initialProps);
_scheduler->startSurface(surfaceId, RCTStringFromNSString(moduleName), props, layoutConstraints, layoutContext); _scheduler->startSurface(surfaceId, RCTStringFromNSString(moduleName), props, layoutConstraints, layoutContext);
@ -97,7 +97,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
- (void)stopSurfaceWithSurfaceId:(SurfaceId)surfaceId - (void)stopSurfaceWithSurfaceId:(SurfaceId)surfaceId
{ {
SystraceSection s("-[RNScheduler stopSurfaceWithSurfaceId:]"); SystraceSection s("-[RCTScheduler stopSurfaceWithSurfaceId:]");
_scheduler->stopSurface(surfaceId); _scheduler->stopSurface(surfaceId);
} }
@ -105,7 +105,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
layoutContext:(LayoutContext)layoutContext layoutContext:(LayoutContext)layoutContext
surfaceId:(SurfaceId)surfaceId surfaceId:(SurfaceId)surfaceId
{ {
SystraceSection s("-[RNScheduler measureSurfaceWithLayoutConstraints:]"); SystraceSection s("-[RCTScheduler measureSurfaceWithLayoutConstraints:]");
return RCTCGSizeFromSize(_scheduler->measureSurface(surfaceId, layoutConstraints, layoutContext)); return RCTCGSizeFromSize(_scheduler->measureSurface(surfaceId, layoutConstraints, layoutContext));
} }
@ -113,7 +113,7 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
layoutContext:(LayoutContext)layoutContext layoutContext:(LayoutContext)layoutContext
surfaceId:(SurfaceId)surfaceId surfaceId:(SurfaceId)surfaceId
{ {
SystraceSection s("-[RNScheduler constraintSurfaceLayoutWithLayoutConstraints:]"); SystraceSection s("-[RCTScheduler constraintSurfaceLayoutWithLayoutConstraints:]");
_scheduler->constraintSurfaceLayout(surfaceId, layoutConstraints, layoutContext); _scheduler->constraintSurfaceLayout(surfaceId, layoutConstraints, layoutContext);
} }

Просмотреть файл

@ -9,16 +9,16 @@
#import <memory> #import <memory>
#import <React/RCTBridge.h> #import <React/RCTBridge.h>
#import <React/RNComponentViewFactory.h> #import <React/RCTComponentViewFactory.h>
#import <React/RNPrimitives.h> #import <React/RCTPrimitives.h>
#import <React/RNSurfacePresenterStub.h> #import <React/RCTSurfacePresenterStub.h>
#import <react/config/ReactNativeConfig.h> #import <react/config/ReactNativeConfig.h>
#import <react/utils/ContextContainer.h> #import <react/utils/ContextContainer.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RNFabricSurface; @class RCTFabricSurface;
@class RNMountingManager; @class RCTMountingManager;
/** /**
* Coordinates presenting of React Native Surfaces and represents application * Coordinates presenting of React Native Surfaces and represents application
@ -26,49 +26,49 @@ NS_ASSUME_NONNULL_BEGIN
* SurfacePresenter incapsulates a bridge object inside and discourage direct * SurfacePresenter incapsulates a bridge object inside and discourage direct
* access to it. * access to it.
*/ */
@interface RNSurfacePresenter : NSObject @interface RCTSurfacePresenter : NSObject
- (instancetype)initWithBridge:(RCTBridge *)bridge - (instancetype)initWithBridge:(RCTBridge *)bridge
config:(std::shared_ptr<const facebook::react::ReactNativeConfig>)config; config:(std::shared_ptr<const facebook::react::ReactNativeConfig>)config;
@property (nonatomic, readonly) RNComponentViewFactory *componentViewFactory; @property (nonatomic, readonly) RCTComponentViewFactory *componentViewFactory;
@property (nonatomic, readonly) facebook::react::ContextContainer::Shared contextContainer; @property (nonatomic, readonly) facebook::react::ContextContainer::Shared contextContainer;
@end @end
@interface RNSurfacePresenter (Surface) <RNSurfacePresenterStub> @interface RCTSurfacePresenter (Surface) <RCTSurfacePresenterStub>
/** /**
* Surface uses these methods to register itself in the Presenter. * Surface uses these methods to register itself in the Presenter.
*/ */
- (void)registerSurface:(RNFabricSurface *)surface; - (void)registerSurface:(RCTFabricSurface *)surface;
/** /**
* Starting initiates running, rendering and mounting processes. * Starting initiates running, rendering and mounting processes.
* Should be called after registerSurface and any other surface-specific setup is done * Should be called after registerSurface and any other surface-specific setup is done
*/ */
- (void)startSurface:(RNFabricSurface *)surface; - (void)startSurface:(RCTFabricSurface *)surface;
- (void)unregisterSurface:(RNFabricSurface *)surface; - (void)unregisterSurface:(RCTFabricSurface *)surface;
- (void)setProps:(NSDictionary *)props surface:(RNFabricSurface *)surface; - (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface;
- (nullable RNFabricSurface *)surfaceForRootTag:(ReactTag)rootTag; - (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag;
/** /**
* Measures the Surface with given constraints. * Measures the Surface with given constraints.
*/ */
- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize - (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize
maximumSize:(CGSize)maximumSize maximumSize:(CGSize)maximumSize
surface:(RNFabricSurface *)surface; surface:(RCTFabricSurface *)surface;
/** /**
* Sets `minimumSize` and `maximumSize` layout constraints for the Surface. * Sets `minimumSize` and `maximumSize` layout constraints for the Surface.
*/ */
- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RNFabricSurface *)surface; - (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface;
- (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props; - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props;
- (void)addObserver:(id<RNSurfacePresenterObserver>)observer; - (void)addObserver:(id<RCTSurfacePresenterObserver>)observer;
- (void)removeObserver:(id<RNSurfacePresenterObserver>)observer; - (void)removeObserver:(id<RCTSurfacePresenterObserver>)observer;
@end @end

Просмотреть файл

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSurfacePresenter.h" #import "RCTSurfacePresenter.h"
#import <cxxreact/MessageQueueThread.h> #import <cxxreact/MessageQueueThread.h>
#import <jsi/jsi.h> #import <jsi/jsi.h>
@ -14,18 +14,18 @@
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
#import <React/RCTBridge+Private.h> #import <React/RCTBridge+Private.h>
#import <React/RCTComponentViewFactory.h>
#import <React/RCTComponentViewRegistry.h>
#import <React/RCTFabricSurface.h>
#import <React/RCTFollyConvert.h> #import <React/RCTFollyConvert.h>
#import <React/RCTImageLoader.h> #import <React/RCTImageLoader.h>
#import <React/RCTMountingManager.h>
#import <React/RCTMountingManagerDelegate.h>
#import <React/RCTScheduler.h>
#import <React/RCTSurfaceRegistry.h>
#import <React/RCTSurfaceView+Internal.h> #import <React/RCTSurfaceView+Internal.h>
#import <React/RCTSurfaceView.h> #import <React/RCTSurfaceView.h>
#import <React/RCTUtils.h> #import <React/RCTUtils.h>
#import <React/RNComponentViewFactory.h>
#import <React/RNComponentViewRegistry.h>
#import <React/RNFabricSurface.h>
#import <React/RNMountingManager.h>
#import <React/RNMountingManagerDelegate.h>
#import <React/RNScheduler.h>
#import <React/RNSurfaceRegistry.h>
#import <react/components/root/RootShadowNode.h> #import <react/components/root/RootShadowNode.h>
#import <react/core/LayoutConstraints.h> #import <react/core/LayoutConstraints.h>
@ -37,7 +37,7 @@
#import <react/utils/RuntimeExecutor.h> #import <react/utils/RuntimeExecutor.h>
#import "MainRunLoopEventBeat.h" #import "MainRunLoopEventBeat.h"
#import "RNConversions.h" #import "RCTConversions.h"
#import "RuntimeEventBeat.h" #import "RuntimeEventBeat.h"
using namespace facebook::react; using namespace facebook::react;
@ -47,21 +47,21 @@ using namespace facebook::react;
- (void)invokeAsync:(std::function<void()> &&)func; - (void)invokeAsync:(std::function<void()> &&)func;
@end @end
@interface RNSurfacePresenter () <RNSchedulerDelegate, RNMountingManagerDelegate> @interface RCTSurfacePresenter () <RCTSchedulerDelegate, RCTMountingManagerDelegate>
@end @end
@implementation RNSurfacePresenter { @implementation RCTSurfacePresenter {
std::mutex _schedulerMutex; std::mutex _schedulerMutex;
std::mutex _contextContainerMutex; std::mutex _contextContainerMutex;
RNScheduler RCTScheduler
*_Nullable _scheduler; // Thread-safe. Mutation of the instance variable is protected by `_schedulerMutex`. *_Nullable _scheduler; // Thread-safe. Mutation of the instance variable is protected by `_schedulerMutex`.
RNMountingManager *_mountingManager; // Thread-safe. RCTMountingManager *_mountingManager; // Thread-safe.
RNSurfaceRegistry *_surfaceRegistry; // Thread-safe. RCTSurfaceRegistry *_surfaceRegistry; // Thread-safe.
RCTBridge *_bridge; // Unsafe. We are moving away from Bridge. RCTBridge *_bridge; // Unsafe. We are moving away from Bridge.
RCTBridge *_batchedBridge; RCTBridge *_batchedBridge;
std::shared_ptr<const ReactNativeConfig> _reactNativeConfig; std::shared_ptr<const ReactNativeConfig> _reactNativeConfig;
better::shared_mutex _observerListMutex; better::shared_mutex _observerListMutex;
NSMutableArray<id<RNSurfacePresenterObserver>> *_observers; NSMutableArray<id<RCTSurfacePresenterObserver>> *_observers;
} }
- (instancetype)initWithBridge:(RCTBridge *)bridge config:(std::shared_ptr<const ReactNativeConfig>)config - (instancetype)initWithBridge:(RCTBridge *)bridge config:(std::shared_ptr<const ReactNativeConfig>)config
@ -71,9 +71,9 @@ using namespace facebook::react;
_batchedBridge = [_bridge batchedBridge] ?: _bridge; _batchedBridge = [_bridge batchedBridge] ?: _bridge;
[_batchedBridge setSurfacePresenter:self]; [_batchedBridge setSurfacePresenter:self];
_surfaceRegistry = [[RNSurfaceRegistry alloc] init]; _surfaceRegistry = [[RCTSurfaceRegistry alloc] init];
_mountingManager = [[RNMountingManager alloc] init]; _mountingManager = [[RCTMountingManager alloc] init];
_mountingManager.delegate = self; _mountingManager.delegate = self;
if (config != nullptr) { if (config != nullptr) {
@ -102,42 +102,44 @@ using namespace facebook::react;
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
} }
- (RNComponentViewFactory *)componentViewFactory - (RCTComponentViewFactory *)componentViewFactory
{ {
return _mountingManager.componentViewRegistry.componentViewFactory; return _mountingManager.componentViewRegistry.componentViewFactory;
} }
#pragma mark - Internal Surface-dedicated Interface #pragma mark - Internal Surface-dedicated Interface
- (void)registerSurface:(RNFabricSurface *)surface - (void)registerSurface:(RCTFabricSurface *)surface
{ {
[_surfaceRegistry registerSurface:surface]; [_surfaceRegistry registerSurface:surface];
} }
- (void)startSurface:(RNFabricSurface *)surface - (void)startSurface:(RCTFabricSurface *)surface
{ {
[self _startSurface:surface]; [self _startSurface:surface];
} }
- (void)unregisterSurface:(RNFabricSurface *)surface - (void)unregisterSurface:(RCTFabricSurface *)surface
{ {
[self _stopSurface:surface]; [self _stopSurface:surface];
[_surfaceRegistry unregisterSurface:surface]; [_surfaceRegistry unregisterSurface:surface];
} }
- (void)setProps:(NSDictionary *)props surface:(RNFabricSurface *)surface - (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface
{ {
// This implementation is suboptimal indeed but still better than nothing for now. // This implementation is suboptimal indeed but still better than nothing for now.
[self _stopSurface:surface]; [self _stopSurface:surface];
[self _startSurface:surface]; [self _startSurface:surface];
} }
- (RNFabricSurface *)surfaceForRootTag:(ReactTag)rootTag - (RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag
{ {
return [_surfaceRegistry surfaceForRootTag:rootTag]; return [_surfaceRegistry surfaceForRootTag:rootTag];
} }
- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RNFabricSurface *)surface - (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize
maximumSize:(CGSize)maximumSize
surface:(RCTFabricSurface *)surface
{ {
LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()};
@ -149,7 +151,7 @@ using namespace facebook::react;
surfaceId:surface.rootTag]; surfaceId:surface.rootTag];
} }
- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RNFabricSurface *)surface - (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface
{ {
LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()}; LayoutContext layoutContext = {.pointScaleFactor = RCTScreenScale()};
@ -164,7 +166,7 @@ using namespace facebook::react;
- (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props
{ {
ReactTag tag = [reactTag integerValue]; ReactTag tag = [reactTag integerValue];
UIView<RNComponentViewProtocol> *componentView = [_mountingManager.componentViewRegistry componentViewByTag:tag]; UIView<RCTComponentViewProtocol> *componentView = [_mountingManager.componentViewRegistry componentViewByTag:tag];
if (componentView == nil) { if (componentView == nil) {
return NO; // This view probably isn't managed by Fabric return NO; // This view probably isn't managed by Fabric
} }
@ -178,7 +180,7 @@ using namespace facebook::react;
#pragma mark - Private #pragma mark - Private
- (RNScheduler *)_scheduler - (RCTScheduler *)_scheduler
{ {
std::lock_guard<std::mutex> lock(_schedulerMutex); std::lock_guard<std::mutex> lock(_schedulerMutex);
@ -189,7 +191,7 @@ using namespace facebook::react;
auto componentRegistryFactory = [factory = wrapManagedObject(self.componentViewFactory)]( auto componentRegistryFactory = [factory = wrapManagedObject(self.componentViewFactory)](
EventDispatcher::Shared const &eventDispatcher, EventDispatcher::Shared const &eventDispatcher,
ContextContainer::Shared const &contextContainer) { ContextContainer::Shared const &contextContainer) {
return [(RNComponentViewFactory *)unwrapManagedObject(factory) return [(RCTComponentViewFactory *)unwrapManagedObject(factory)
createComponentDescriptorRegistryWithParameters:{eventDispatcher, contextContainer}]; createComponentDescriptorRegistryWithParameters:{eventDispatcher, contextContainer}];
}; };
@ -208,7 +210,7 @@ using namespace facebook::react;
return std::make_unique<RuntimeEventBeat>(runtimeExecutor); return std::make_unique<RuntimeEventBeat>(runtimeExecutor);
}; };
_scheduler = [[RNScheduler alloc] initWithToolbox:toolbox]; _scheduler = [[RCTScheduler alloc] initWithToolbox:toolbox];
_scheduler.delegate = self; _scheduler.delegate = self;
return _scheduler; return _scheduler;
@ -247,7 +249,7 @@ using namespace facebook::react;
_contextContainer = std::make_shared<ContextContainer>(); _contextContainer = std::make_shared<ContextContainer>();
// Please do not add stuff here; `SurfacePresenter` must not alter `ContextContainer`. // Please do not add stuff here; `SurfacePresenter` must not alter `ContextContainer`.
// Those two pieces eventually should be moved out there: // Those two pieces eventually should be moved out there:
// * `RCTImageLoader` should be moved to `RNImageComponentView`. // * `RCTImageLoader` should be moved to `RCTImageComponentView`.
// * `ReactNativeConfig` should be set by outside product code. // * `ReactNativeConfig` should be set by outside product code.
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig); _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_contextContainer->insert("RCTImageLoader", wrapManagedObject([_bridge moduleForClass:[RCTImageLoader class]])); _contextContainer->insert("RCTImageLoader", wrapManagedObject([_bridge moduleForClass:[RCTImageLoader class]]));
@ -255,9 +257,9 @@ using namespace facebook::react;
return _contextContainer; return _contextContainer;
} }
- (void)_startSurface:(RNFabricSurface *)surface - (void)_startSurface:(RCTFabricSurface *)surface
{ {
RNMountingManager *mountingManager = _mountingManager; RCTMountingManager *mountingManager = _mountingManager;
RCTExecuteOnMainQueue(^{ RCTExecuteOnMainQueue(^{
[mountingManager.componentViewRegistry dequeueComponentViewWithComponentHandle:RootShadowNode::Handle() [mountingManager.componentViewRegistry dequeueComponentViewWithComponentHandle:RootShadowNode::Handle()
tag:surface.rootTag]; tag:surface.rootTag];
@ -275,13 +277,13 @@ using namespace facebook::react;
layoutContext:layoutContext]; layoutContext:layoutContext];
} }
- (void)_stopSurface:(RNFabricSurface *)surface - (void)_stopSurface:(RCTFabricSurface *)surface
{ {
[self._scheduler stopSurfaceWithSurfaceId:surface.rootTag]; [self._scheduler stopSurfaceWithSurfaceId:surface.rootTag];
RNMountingManager *mountingManager = _mountingManager; RCTMountingManager *mountingManager = _mountingManager;
RCTExecuteOnMainQueue(^{ RCTExecuteOnMainQueue(^{
UIView<RNComponentViewProtocol> *rootView = UIView<RCTComponentViewProtocol> *rootView =
[mountingManager.componentViewRegistry componentViewByTag:surface.rootTag]; [mountingManager.componentViewRegistry componentViewByTag:surface.rootTag];
[mountingManager.componentViewRegistry enqueueComponentViewWithComponentHandle:RootShadowNode::Handle() [mountingManager.componentViewRegistry enqueueComponentViewWithComponentHandle:RootShadowNode::Handle()
tag:surface.rootTag tag:surface.rootTag
@ -293,8 +295,8 @@ using namespace facebook::react;
- (void)_startAllSurfaces - (void)_startAllSurfaces
{ {
[_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RNFabricSurface *> *enumerator) { [_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RCTFabricSurface *> *enumerator) {
for (RNFabricSurface *surface in enumerator) { for (RCTFabricSurface *surface in enumerator) {
[self _startSurface:surface]; [self _startSurface:surface];
} }
}]; }];
@ -302,18 +304,18 @@ using namespace facebook::react;
- (void)_stopAllSurfaces - (void)_stopAllSurfaces
{ {
[_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RNFabricSurface *> *enumerator) { [_surfaceRegistry enumerateWithBlock:^(NSEnumerator<RCTFabricSurface *> *enumerator) {
for (RNFabricSurface *surface in enumerator) { for (RCTFabricSurface *surface in enumerator) {
[self _stopSurface:surface]; [self _stopSurface:surface];
} }
}]; }];
} }
#pragma mark - RNSchedulerDelegate #pragma mark - RCTSchedulerDelegate
- (void)schedulerDidFinishTransaction:(facebook::react::MountingCoordinator::Shared const &)mountingCoordinator - (void)schedulerDidFinishTransaction:(facebook::react::MountingCoordinator::Shared const &)mountingCoordinator
{ {
RNFabricSurface *surface = [_surfaceRegistry surfaceForRootTag:mountingCoordinator->getSurfaceId()]; RCTFabricSurface *surface = [_surfaceRegistry surfaceForRootTag:mountingCoordinator->getSurfaceId()];
[surface _setStage:RCTSurfaceStagePrepared]; [surface _setStage:RCTSurfaceStagePrepared];
@ -331,37 +333,37 @@ using namespace facebook::react;
[self->_mountingManager dispatchCommand:tag commandName:commandStr args:argsArray]; [self->_mountingManager dispatchCommand:tag commandName:commandStr args:argsArray];
} }
- (void)addObserver:(id<RNSurfacePresenterObserver>)observer - (void)addObserver:(id<RCTSurfacePresenterObserver>)observer
{ {
std::unique_lock<better::shared_mutex> lock(_observerListMutex); std::unique_lock<better::shared_mutex> lock(_observerListMutex);
[self->_observers addObject:observer]; [self->_observers addObject:observer];
} }
- (void)removeObserver:(id<RNSurfacePresenterObserver>)observer - (void)removeObserver:(id<RCTSurfacePresenterObserver>)observer
{ {
std::unique_lock<better::shared_mutex> lock(_observerListMutex); std::unique_lock<better::shared_mutex> lock(_observerListMutex);
[self->_observers removeObject:observer]; [self->_observers removeObject:observer];
} }
#pragma mark - RNMountingManagerDelegate #pragma mark - RCTMountingManagerDelegate
- (void)mountingManager:(RNMountingManager *)mountingManager willMountComponentsWithRootTag:(ReactTag)rootTag - (void)mountingManager:(RCTMountingManager *)mountingManager willMountComponentsWithRootTag:(ReactTag)rootTag
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
std::shared_lock<better::shared_mutex> lock(_observerListMutex); std::shared_lock<better::shared_mutex> lock(_observerListMutex);
for (id<RNSurfacePresenterObserver> observer in _observers) { for (id<RCTSurfacePresenterObserver> observer in _observers) {
if ([observer respondsToSelector:@selector(willMountComponentsWithRootTag:)]) { if ([observer respondsToSelector:@selector(willMountComponentsWithRootTag:)]) {
[observer willMountComponentsWithRootTag:rootTag]; [observer willMountComponentsWithRootTag:rootTag];
} }
} }
} }
- (void)mountingManager:(RNMountingManager *)mountingManager didMountComponentsWithRootTag:(ReactTag)rootTag - (void)mountingManager:(RCTMountingManager *)mountingManager didMountComponentsWithRootTag:(ReactTag)rootTag
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
RNFabricSurface *surface = [_surfaceRegistry surfaceForRootTag:rootTag]; RCTFabricSurface *surface = [_surfaceRegistry surfaceForRootTag:rootTag];
RCTSurfaceStage stage = surface.stage; RCTSurfaceStage stage = surface.stage;
if (stage & RCTSurfaceStagePrepared) { if (stage & RCTSurfaceStagePrepared) {
// We have to progress the stage only if the preparing phase is done. // We have to progress the stage only if the preparing phase is done.
@ -372,7 +374,7 @@ using namespace facebook::react;
} }
std::shared_lock<better::shared_mutex> lock(_observerListMutex); std::shared_lock<better::shared_mutex> lock(_observerListMutex);
for (id<RNSurfacePresenterObserver> observer in _observers) { for (id<RCTSurfacePresenterObserver> observer in _observers) {
if ([observer respondsToSelector:@selector(didMountComponentsWithRootTag:)]) { if ([observer respondsToSelector:@selector(didMountComponentsWithRootTag:)]) {
[observer didMountComponentsWithRootTag:rootTag]; [observer didMountComponentsWithRootTag:rootTag];
} }

Просмотреть файл

@ -7,13 +7,13 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <React/RNPrimitives.h> #import <React/RCTPrimitives.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RNFabricSurface; @class RCTFabricSurface;
typedef void (^RCTSurfaceEnumeratorBlock)(NSEnumerator<RNFabricSurface *> *enumerator); typedef void (^RCTSurfaceEnumeratorBlock)(NSEnumerator<RCTFabricSurface *> *enumerator);
/** /**
* Registry of Surfaces. * Registry of Surfaces.
@ -21,7 +21,7 @@ typedef void (^RCTSurfaceEnumeratorBlock)(NSEnumerator<RNFabricSurface *> *enume
* All methods of the registry are thread-safe. * All methods of the registry are thread-safe.
* The registry stores Surface objects as weak references. * The registry stores Surface objects as weak references.
*/ */
@interface RNSurfaceRegistry : NSObject @interface RCTSurfaceRegistry : NSObject
- (void)enumerateWithBlock:(RCTSurfaceEnumeratorBlock)block; - (void)enumerateWithBlock:(RCTSurfaceEnumeratorBlock)block;
@ -29,18 +29,18 @@ typedef void (^RCTSurfaceEnumeratorBlock)(NSEnumerator<RNFabricSurface *> *enume
* Adds Surface object into the registry. * Adds Surface object into the registry.
* The registry does not retain Surface references. * The registry does not retain Surface references.
*/ */
- (void)registerSurface:(RNFabricSurface *)surface; - (void)registerSurface:(RCTFabricSurface *)surface;
/** /**
* Removes Surface object from the registry. * Removes Surface object from the registry.
*/ */
- (void)unregisterSurface:(RNFabricSurface *)surface; - (void)unregisterSurface:(RCTFabricSurface *)surface;
/** /**
* Returns stored Surface object by given root tag. * Returns stored Surface object by given root tag.
* If the registry does not have such Surface registered, returns `nil`. * If the registry does not have such Surface registered, returns `nil`.
*/ */
- (nullable RNFabricSurface *)surfaceForRootTag:(ReactTag)rootTag; - (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag;
@end @end

Просмотреть файл

@ -5,19 +5,19 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSurfaceRegistry.h" #import "RCTSurfaceRegistry.h"
#import <mutex> #import <mutex>
#import <shared_mutex> #import <shared_mutex>
#import <better/mutex.h> #import <better/mutex.h>
#import <React/RNFabricSurface.h> #import <React/RCTFabricSurface.h>
using namespace facebook; using namespace facebook;
@implementation RNSurfaceRegistry { @implementation RCTSurfaceRegistry {
better::shared_mutex _mutex; better::shared_mutex _mutex;
NSMapTable<id, RNFabricSurface *> *_registry; NSMapTable<id, RCTFabricSurface *> *_registry;
} }
- (instancetype)init - (instancetype)init
@ -36,7 +36,7 @@ using namespace facebook;
block([_registry objectEnumerator]); block([_registry objectEnumerator]);
} }
- (void)registerSurface:(RNFabricSurface *)surface - (void)registerSurface:(RCTFabricSurface *)surface
{ {
std::unique_lock<better::shared_mutex> lock(_mutex); std::unique_lock<better::shared_mutex> lock(_mutex);
@ -44,7 +44,7 @@ using namespace facebook;
[_registry setObject:surface forKey:(__bridge id)(void *)rootTag]; [_registry setObject:surface forKey:(__bridge id)(void *)rootTag];
} }
- (void)unregisterSurface:(RNFabricSurface *)surface - (void)unregisterSurface:(RCTFabricSurface *)surface
{ {
std::unique_lock<better::shared_mutex> lock(_mutex); std::unique_lock<better::shared_mutex> lock(_mutex);
@ -52,7 +52,7 @@ using namespace facebook;
[_registry removeObjectForKey:(__bridge id)(void *)rootTag]; [_registry removeObjectForKey:(__bridge id)(void *)rootTag];
} }
- (RNFabricSurface *)surfaceForRootTag:(ReactTag)rootTag - (RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag
{ {
std::shared_lock<better::shared_mutex> lock(_mutex); std::shared_lock<better::shared_mutex> lock(_mutex);

Просмотреть файл

@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface RNSurfaceTouchHandler : UIGestureRecognizer @interface RCTSurfaceTouchHandler : UIGestureRecognizer
- (void)attachToView:(UIView *)view; - (void)attachToView:(UIView *)view;
- (void)detachFromView:(UIView *)view; - (void)detachFromView:(UIView *)view;

Просмотреть файл

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSurfaceTouchHandler.h" #import "RCTSurfaceTouchHandler.h"
#import <React/RCTUtils.h> #import <React/RCTUtils.h>
#import <React/RNViewComponentView.h> #import <React/RCTViewComponentView.h>
#import <UIKit/UIGestureRecognizerSubclass.h> #import <UIKit/UIGestureRecognizerSubclass.h>
#import "RNConversions.h" #import "RCTConversions.h"
#import "RNTouchableComponentViewProtocol.h" #import "RCTTouchableComponentViewProtocol.h"
using namespace facebook::react; using namespace facebook::react;
@ -92,7 +92,7 @@ static ActiveTouch CreateTouchWithUITouch(UITouch *uiTouch, UIView *rootComponen
ActiveTouch activeTouch = {}; ActiveTouch activeTouch = {};
if ([componentView respondsToSelector:@selector(touchEventEmitterAtPoint:)]) { if ([componentView respondsToSelector:@selector(touchEventEmitterAtPoint:)]) {
activeTouch.eventEmitter = [(id<RNTouchableComponentViewProtocol>)componentView activeTouch.eventEmitter = [(id<RCTTouchableComponentViewProtocol>)componentView
touchEventEmitterAtPoint:[uiTouch locationInView:componentView]]; touchEventEmitterAtPoint:[uiTouch locationInView:componentView]];
activeTouch.touch.target = (Tag)componentView.tag; activeTouch.touch.target = (Tag)componentView.tag;
} }
@ -135,10 +135,10 @@ struct PointerHasher {
} }
}; };
@interface RNSurfaceTouchHandler () <UIGestureRecognizerDelegate> @interface RCTSurfaceTouchHandler () <UIGestureRecognizerDelegate>
@end @end
@implementation RNSurfaceTouchHandler { @implementation RCTSurfaceTouchHandler {
std::unordered_map< std::unordered_map<
__unsafe_unretained UITouch *, __unsafe_unretained UITouch *,
ActiveTouch, ActiveTouch,

Просмотреть файл

@ -8,6 +8,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <react/components/view/TouchEventEmitter.h> #import <react/components/view/TouchEventEmitter.h>
@protocol RNTouchableComponentViewProtocol <NSObject> @protocol RCTTouchableComponentViewProtocol <NSObject>
- (facebook::react::SharedTouchEventEmitter)touchEventEmitterAtPoint:(CGPoint)point; - (facebook::react::SharedTouchEventEmitter)touchEventEmitterAtPoint:(CGPoint)point;
@end @end

Просмотреть файл

@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import <React/RCTPrimitives.h>
#import <React/RCTSurfaceStage.h> #import <React/RCTSurfaceStage.h>
#import <React/RNPrimitives.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RCTBridge; @class RCTBridge;
@class RCTSurfaceView; @class RCTSurfaceView;
@class RNSurfacePresenter; @class RCTSurfacePresenter;
@protocol RCTSurfaceDelegate; @protocol RCTSurfaceDelegate;
/** /**
@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
* * ability to create a UIView instance on demand (later); * * ability to create a UIView instance on demand (later);
* * ability to communicate the current stage of the surface granularly. * * ability to communicate the current stage of the surface granularly.
*/ */
@interface RNFabricSurface : NSObject @interface RCTFabricSurface : NSObject
@property (atomic, readonly) RCTSurfaceStage stage; @property (atomic, readonly) RCTSurfaceStage stage;
@property (atomic, readonly) NSString *moduleName; @property (atomic, readonly) NSString *moduleName;
@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (atomic, copy, readwrite) NSDictionary *properties; @property (atomic, copy, readwrite) NSDictionary *properties;
- (instancetype)initWithSurfacePresenter:(RNSurfacePresenter *)surfacePresenter - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter
moduleName:(NSString *)moduleName moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties; initialProperties:(NSDictionary *)initialProperties;
@ -128,7 +128,7 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@interface RNFabricSurface (Internal) @interface RCTFabricSurface (Internal)
/** /**
* Sets and clears given stage flags (bitmask). * Sets and clears given stage flags (bitmask).
@ -139,7 +139,7 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@interface RNFabricSurface (Deprecated) @interface RCTFabricSurface (Deprecated)
/** /**
* Deprecated. Use `initWithSurfacePresenter:moduleName:initialProperties` instead. * Deprecated. Use `initWithSurfacePresenter:moduleName:initialProperties` instead.

Просмотреть файл

@ -5,24 +5,24 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNFabricSurface.h" #import "RCTFabricSurface.h"
#import <mutex> #import <mutex>
#import <React/RCTAssert.h> #import <React/RCTAssert.h>
#import <React/RCTSurfaceDelegate.h> #import <React/RCTSurfaceDelegate.h>
#import <React/RCTSurfaceRootView.h> #import <React/RCTSurfaceRootView.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <React/RCTSurfaceView+Internal.h> #import <React/RCTSurfaceView+Internal.h>
#import <React/RCTSurfaceView.h> #import <React/RCTSurfaceView.h>
#import <React/RCTUIManagerUtils.h> #import <React/RCTUIManagerUtils.h>
#import <React/RCTUtils.h> #import <React/RCTUtils.h>
#import <React/RNSurfaceTouchHandler.h>
#import "RNSurfacePresenter.h" #import "RCTSurfacePresenter.h"
@implementation RNFabricSurface { @implementation RCTFabricSurface {
// Immutable // Immutable
RNSurfacePresenter *_surfacePresenter; RCTSurfacePresenter *_surfacePresenter;
NSString *_moduleName; NSString *_moduleName;
// Protected by the `_mutex` // Protected by the `_mutex`
@ -35,10 +35,10 @@
// The Main thread only // The Main thread only
RCTSurfaceView *_Nullable _view; RCTSurfaceView *_Nullable _view;
RNSurfaceTouchHandler *_Nullable _touchHandler; RCTSurfaceTouchHandler *_Nullable _touchHandler;
} }
- (instancetype)initWithSurfacePresenter:(RNSurfacePresenter *)surfacePresenter - (instancetype)initWithSurfacePresenter:(RCTSurfacePresenter *)surfacePresenter
moduleName:(NSString *)moduleName moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties initialProperties:(NSDictionary *)initialProperties
{ {
@ -52,7 +52,7 @@
// FIXME: Replace with `_maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);`. // FIXME: Replace with `_maximumSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);`.
_maximumSize = RCTScreenSize(); _maximumSize = RCTScreenSize();
_touchHandler = [RNSurfaceTouchHandler new]; _touchHandler = [RCTSurfaceTouchHandler new];
_stage = RCTSurfaceStageSurfaceDidInitialize; _stage = RCTSurfaceStageSurfaceDidInitialize;

Просмотреть файл

@ -10,6 +10,6 @@
/** /**
* Fabric-compatible RCTSurfaceHostingProxyRootView implementation. * Fabric-compatible RCTSurfaceHostingProxyRootView implementation.
*/ */
@interface RNFabricSurfaceHostingProxyRootView : RCTSurfaceHostingProxyRootView @interface RCTFabricSurfaceHostingProxyRootView : RCTSurfaceHostingProxyRootView
@end @end

Просмотреть файл

@ -5,19 +5,19 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNFabricSurfaceHostingProxyRootView.h" #import "RCTFabricSurfaceHostingProxyRootView.h"
#import "RNFabricSurface.h" #import "RCTFabricSurface.h"
@implementation RNFabricSurfaceHostingProxyRootView @implementation RCTFabricSurfaceHostingProxyRootView
+ (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge + (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties initialProperties:(NSDictionary *)initialProperties
{ {
return (RCTSurface *)[[RNFabricSurface alloc] initWithBridge:bridge return (RCTSurface *)[[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName moduleName:moduleName
initialProperties:initialProperties]; initialProperties:initialProperties];
} }
@end @end

Просмотреть файл

@ -10,6 +10,6 @@
/** /**
* Fabric-compatible RCTSurfaceHostingView implementation. * Fabric-compatible RCTSurfaceHostingView implementation.
*/ */
@interface RNFabricSurfaceHostingView : RCTSurfaceHostingView @interface RCTFabricSurfaceHostingView : RCTSurfaceHostingView
@end @end

Просмотреть файл

@ -5,21 +5,21 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNFabricSurfaceHostingView.h" #import "RCTFabricSurfaceHostingView.h"
#import <React/RCTSurface.h> #import <React/RCTSurface.h>
#import "RNFabricSurface.h" #import "RCTFabricSurface.h"
@implementation RNFabricSurfaceHostingView @implementation RCTFabricSurfaceHostingView
- (instancetype)initWithBridge:(RCTBridge *)bridge - (instancetype)initWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName moduleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initialProperties initialProperties:(NSDictionary *)initialProperties
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
{ {
RCTSurface *surface = (RCTSurface *)[[RNFabricSurface alloc] initWithBridge:bridge RCTSurface *surface = (RCTSurface *)[[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName moduleName:moduleName
initialProperties:initialProperties]; initialProperties:initialProperties];
[surface start]; [surface start];
return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode]; return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
} }

Просмотреть файл

@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
* receiver is being subscribed directly. In the case where more than one receiving objects are registered, using * receiver is being subscribed directly. In the case where more than one receiving objects are registered, using
* Splitter introduces some performance overhead. * Splitter introduces some performance overhead.
*/ */
@interface RNGenericDelegateSplitter<DelegateT> : NSObject @interface RCTGenericDelegateSplitter<DelegateT> : NSObject
@property (nonatomic, copy, nullable) void (^delegateUpdateBlock)(DelegateT _Nullable delegate); @property (nonatomic, copy, nullable) void (^delegateUpdateBlock)(DelegateT _Nullable delegate);

Просмотреть файл

@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNGenericDelegateSplitter.h" #import "RCTGenericDelegateSplitter.h"
@implementation RNGenericDelegateSplitter { @implementation RCTGenericDelegateSplitter {
NSHashTable *_delegates; NSHashTable *_delegates;
} }

Просмотреть файл

@ -11,12 +11,12 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
// TODO: Eventually this should go away and files should just include RNSurfacePresenter.h, but // TODO: Eventually this should go away and files should just include RCTSurfacePresenter.h, but
// that pulls in all of fabric which doesn't compile in open source yet, so we mirror the protocol // that pulls in all of fabric which doesn't compile in open source yet, so we mirror the protocol
// and duplicate the category here for now. // and duplicate the category here for now.
@protocol RNSurfacePresenterObserver <NSObject> @protocol RCTSurfacePresenterObserver <NSObject>
@optional @optional
@ -25,18 +25,18 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@protocol RNSurfacePresenterStub <NSObject> @protocol RCTSurfacePresenterStub <NSObject>
- (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props; - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props;
- (void)addObserver:(id<RNSurfacePresenterObserver>)observer; - (void)addObserver:(id<RCTSurfacePresenterObserver>)observer;
- (void)removeObserver:(id<RNSurfacePresenterObserver>)observer; - (void)removeObserver:(id<RCTSurfacePresenterObserver>)observer;
@end @end
@interface RCTBridge (RNSurfacePresenterStub) @interface RCTBridge (RCTSurfacePresenterStub)
- (id<RNSurfacePresenterStub>)surfacePresenter; - (id<RCTSurfacePresenterStub>)surfacePresenter;
- (void)setSurfacePresenter:(id<RNSurfacePresenterStub>)presenter; - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)presenter;
@end @end

Просмотреть файл

@ -5,16 +5,16 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
#import "RNSurfacePresenterStub.h" #import "RCTSurfacePresenterStub.h"
@implementation RCTBridge (RNSurfacePresenterStub) @implementation RCTBridge (RCTSurfacePresenterStub)
- (id<RNSurfacePresenterStub>)surfacePresenter - (id<RCTSurfacePresenterStub>)surfacePresenter
{ {
return objc_getAssociatedObject(self, @selector(surfacePresenter)); return objc_getAssociatedObject(self, @selector(surfacePresenter));
} }
- (void)setSurfacePresenter:(id<RNSurfacePresenterStub>)surfacePresenter - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
{ {
objc_setAssociatedObject(self, @selector(surfacePresenter), surfacePresenter, OBJC_ASSOCIATION_ASSIGN); objc_setAssociatedObject(self, @selector(surfacePresenter), surfacePresenter, OBJC_ASSOCIATION_ASSIGN);
} }

Просмотреть файл

@ -88,7 +88,7 @@ private:
@end @end
// TODO: Consolidate this extension with the one in RNSurfacePresenter. // TODO: Consolidate this extension with the one in RCTSurfacePresenter.
@interface RCTBridge () @interface RCTBridge ()
- (std::weak_ptr<facebook::react::Instance>)reactInstance; - (std::weak_ptr<facebook::react::Instance>)reactInstance;