mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7bc2b730a8
Summary: The TurboModule interop layer on iOS will ship with a Bridge proxy. The Bridge proxy is an object that will try to simulate the Bridge's APIs, whenever possible, by delegating to Bridgeless abstractions. ## Changes This diff introduces the Bridge proxy. This diff starts attaching the Bridge proxy on legacy native module objects. ## How did we polyfill the APIs The polyfills can be classified into these categories: - implemented - custom warning - custom error - default error - deleted When there was a sane implementation (e.g: the API belonged to [RCTCallableJSModules](https://www.internalfb.com/code/fbsource/[534223aa13d33b595edcb777189618efe20dd167]/xplat/js/react-native-github/React/Base/RCTCallableJSModules.m?lines=11), [RCTModuleRegistry](https://www.internalfb.com/code/fbsource/[9a3ba2b3176b6d1a1f161e33cec51bf892815311]/xplat/js/react-native-github/React/Base/RCTModuleRegistry.m?lines=13), [RCTBundleManager](https://www.internalfb.com/code/fbsource/[91fa1f7f49731a16aedbcd5a6740647dc21ff727]/xplat/js/react-native-github/React/Base/RCTBundleManager.m?lines=13), or [RCTBundleManager](https://www.internalfb.com/code/fbsource/[91fa1f7f49731a16aedbcd5a6740647dc21ff727]/xplat/js/react-native-github/React/Base/RCTBundleManager.m?lines=13)), it was implemented. When it was safe to no-op the API (e.g: loading), it emit a custom warning. When it was unsafe to call (i.e: we didn't want people calling the API) (e.g: RCTCxxBridge start), it emit a custom error. All other APIs emit default errors. Some APIs cannot emit errors because doing so makes the app not render: I put warnings and nooped those APIs. I think we will have to tune these polyfills based off production crashes/results. Reviewed By: mdvacca Differential Revision: D46084318 fbshipit-source-id: c02535073956597a4bf91c14b1980f653cb6d3df
118 lines
2.7 KiB
Objective-C
118 lines
2.7 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <React/RCTBridge.h>
|
|
#import <React/RCTBridgeModule.h>
|
|
#import <React/RCTBridgeProxy.h>
|
|
#import <React/RCTDefines.h>
|
|
|
|
#if RCT_DEV_MENU
|
|
|
|
RCT_EXTERN NSString *const RCTShowDevMenuNotification;
|
|
|
|
#endif
|
|
|
|
@class RCTDevMenuItem;
|
|
|
|
/**
|
|
* Developer menu, useful for exposing extra functionality when debugging.
|
|
*/
|
|
@interface RCTDevMenu : NSObject
|
|
|
|
/**
|
|
* Deprecated, use RCTDevSettings instead.
|
|
*/
|
|
@property (nonatomic, assign) BOOL shakeToShow DEPRECATED_ATTRIBUTE;
|
|
|
|
/**
|
|
* Deprecated, use RCTDevSettings instead.
|
|
*/
|
|
@property (nonatomic, assign) BOOL profilingEnabled DEPRECATED_ATTRIBUTE;
|
|
|
|
/**
|
|
* Deprecated, use RCTDevSettings instead.
|
|
*/
|
|
@property (nonatomic, assign) BOOL hotLoadingEnabled DEPRECATED_ATTRIBUTE;
|
|
|
|
/**
|
|
* Whether the hotkeys that toggles the developer menu is enabled.
|
|
*/
|
|
@property (nonatomic, assign) BOOL hotkeysEnabled;
|
|
|
|
/**
|
|
* Presented items in development menu
|
|
*/
|
|
@property (nonatomic, copy, readonly) NSArray<RCTDevMenuItem *> *presentedItems;
|
|
|
|
/**
|
|
* Detect if actions sheet (development menu) is shown
|
|
*/
|
|
- (BOOL)isActionSheetShown;
|
|
|
|
/**
|
|
* Manually show the dev menu (can be called from JS).
|
|
*/
|
|
- (void)show;
|
|
|
|
/**
|
|
* Deprecated, use `RCTReloadCommand` instead.
|
|
*/
|
|
- (void)reload DEPRECATED_ATTRIBUTE;
|
|
|
|
/**
|
|
* Deprecated. Use the `-addItem:` method instead.
|
|
*/
|
|
- (void)addItem:(NSString *)title handler:(void (^)(void))handler DEPRECATED_ATTRIBUTE;
|
|
|
|
/**
|
|
* Add custom item to the development menu. The handler will be called
|
|
* when user selects the item.
|
|
*/
|
|
- (void)addItem:(RCTDevMenuItem *)item;
|
|
|
|
@end
|
|
|
|
typedef NSString * (^RCTDevMenuItemTitleBlock)(void);
|
|
|
|
/**
|
|
* Developer menu item, used to expose additional functionality via the menu.
|
|
*/
|
|
@interface RCTDevMenuItem : NSObject
|
|
|
|
/**
|
|
* This creates an item with a simple push-button interface, used to trigger an
|
|
* action.
|
|
*/
|
|
+ (instancetype)buttonItemWithTitle:(NSString *)title handler:(dispatch_block_t)handler;
|
|
|
|
/**
|
|
* This creates an item with a simple push-button interface, used to trigger an
|
|
* action. getTitleForPresentation is called each time the item is about to be
|
|
* presented, and should return the item's title.
|
|
*/
|
|
+ (instancetype)buttonItemWithTitleBlock:(RCTDevMenuItemTitleBlock)titleBlock handler:(dispatch_block_t)handler;
|
|
|
|
@end
|
|
|
|
/**
|
|
* This category makes the developer menu instance available via the
|
|
* RCTBridge, which is useful for any class that needs to access the menu.
|
|
*/
|
|
@interface RCTBridge (RCTDevMenu)
|
|
|
|
@property (nonatomic, readonly) RCTDevMenu *devMenu;
|
|
|
|
@end
|
|
|
|
@interface RCTBridgeProxy (RCTDevMenu)
|
|
|
|
@property (nonatomic, readonly) RCTDevMenu *devMenu;
|
|
|
|
@end
|