mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 18:44:25 +00:00
Configure requiresMainQueueSetup for core modules
Reviewed By: fkgozali Differential Revision: D5528305 fbshipit-source-id: f17cad933685be09784b2246f44baf252bfa5a26
This commit is contained in:
parent
d42ccca2e1
commit
220034c4d4
@ -32,6 +32,11 @@ RCT_EXPORT_MODULE(BlobModule)
|
|||||||
|
|
||||||
@synthesize bridge = _bridge;
|
@synthesize bridge = _bridge;
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||||
{
|
{
|
||||||
return @{
|
return @{
|
||||||
|
@ -24,38 +24,40 @@
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)init
|
||||||
|
{
|
||||||
|
return [self initWithUserDefaults:[NSUserDefaults standardUserDefaults]];
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)initWithUserDefaults:(NSUserDefaults *)defaults
|
- (instancetype)initWithUserDefaults:(NSUserDefaults *)defaults
|
||||||
{
|
{
|
||||||
if ((self = [self init])) {
|
if ((self = [self init])) {
|
||||||
_defaults = defaults;
|
_defaults = defaults;
|
||||||
|
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(userDefaultsDidChange:)
|
||||||
|
name:NSUserDefaultsDidChangeNotification
|
||||||
|
object:_defaults];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBridge:(RCTBridge *)bridge
|
|
||||||
{
|
|
||||||
_bridge = bridge;
|
|
||||||
|
|
||||||
if (!_defaults) {
|
|
||||||
_defaults = [NSUserDefaults standardUserDefaults];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
||||||
selector:@selector(userDefaultsDidChange:)
|
|
||||||
name:NSUserDefaultsDidChangeNotification
|
|
||||||
object:_defaults];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
|
||||||
{
|
|
||||||
return @{@"settings": RCTJSONClean([_defaults dictionaryRepresentation])};
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||||
|
{
|
||||||
|
return @{@"settings": RCTJSONClean([_defaults dictionaryRepresentation])};
|
||||||
|
}
|
||||||
|
|
||||||
- (void)userDefaultsDidChange:(NSNotification *)note
|
- (void)userDefaultsDidChange:(NSNotification *)note
|
||||||
{
|
{
|
||||||
if (_ignoringUpdates) {
|
if (_ignoringUpdates) {
|
||||||
|
@ -71,7 +71,6 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface RCTModuleInitNotificationRaceTests : XCTestCase <RCTBridgeDelegate>
|
@interface RCTModuleInitNotificationRaceTests : XCTestCase <RCTBridgeDelegate>
|
||||||
{
|
{
|
||||||
RCTBridge *_bridge;
|
RCTBridge *_bridge;
|
||||||
@ -98,6 +97,10 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
_notificationObserver = [RCTNotificationObserverModule new];
|
_notificationObserver = [RCTNotificationObserverModule new];
|
||||||
_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil];
|
_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil];
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[[self->_bridge uiManager] constantsToExport];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tearDown
|
- (void)tearDown
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
#import "RCTUtils.h"
|
#import "RCTUtils.h"
|
||||||
|
|
||||||
@implementation RCTPlatform
|
|
||||||
|
|
||||||
static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
||||||
switch(idiom) {
|
switch(idiom) {
|
||||||
case UIUserInterfaceIdiomPhone:
|
case UIUserInterfaceIdiomPhone:
|
||||||
@ -30,8 +28,15 @@ static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@implementation RCTPlatform
|
||||||
|
|
||||||
RCT_EXPORT_MODULE(PlatformConstants)
|
RCT_EXPORT_MODULE(PlatformConstants)
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||||
{
|
{
|
||||||
UIDevice *device = [UIDevice currentDevice];
|
UIDevice *device = [UIDevice currentDevice];
|
||||||
|
@ -41,11 +41,9 @@ RCT_EXPORT_MODULE()
|
|||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
+ (BOOL)requiresMainQueueSetup
|
||||||
{
|
{
|
||||||
// We're only overriding this to ensure the module gets created at startup
|
return YES;
|
||||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
|
||||||
return [super init];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBridge:(RCTBridge *)bridge
|
- (void)setBridge:(RCTBridge *)bridge
|
||||||
|
@ -99,6 +99,11 @@ RCT_EXPORT_MODULE()
|
|||||||
RCTSwapInstanceMethods([UIWindow class], @selector(motionEnded:withEvent:), @selector(RCT_motionEnded:withEvent:));
|
RCTSwapInstanceMethods([UIWindow class], @selector(motionEnded:withEvent:), @selector(RCT_motionEnded:withEvent:));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
|
@ -17,21 +17,7 @@
|
|||||||
|
|
||||||
NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAccessibilityManagerDidUpdateMultiplierNotification";
|
NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAccessibilityManagerDidUpdateMultiplierNotification";
|
||||||
|
|
||||||
@interface RCTAccessibilityManager ()
|
static NSString *UIKitCategoryFromJSCategory(NSString *JSCategory)
|
||||||
|
|
||||||
@property (nonatomic, copy) NSString *contentSizeCategory;
|
|
||||||
@property (nonatomic, assign) CGFloat multiplier;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation RCTAccessibilityManager
|
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
|
||||||
@synthesize multipliers = _multipliers;
|
|
||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
|
||||||
|
|
||||||
+ (NSDictionary<NSString *, NSString *> *)JSToUIKitMap
|
|
||||||
{
|
{
|
||||||
static NSDictionary *map = nil;
|
static NSDictionary *map = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
@ -49,12 +35,26 @@ RCT_EXPORT_MODULE()
|
|||||||
@"accessibilityExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraLarge,
|
@"accessibilityExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraLarge,
|
||||||
@"accessibilityExtraExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraExtraLarge};
|
@"accessibilityExtraExtraExtraLarge": UIContentSizeCategoryAccessibilityExtraExtraExtraLarge};
|
||||||
});
|
});
|
||||||
return map;
|
return map[JSCategory];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)UIKitCategoryFromJSCategory:(NSString *)JSCategory
|
@interface RCTAccessibilityManager ()
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *contentSizeCategory;
|
||||||
|
@property (nonatomic, assign) CGFloat multiplier;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation RCTAccessibilityManager
|
||||||
|
|
||||||
|
@synthesize bridge = _bridge;
|
||||||
|
@synthesize multipliers = _multipliers;
|
||||||
|
|
||||||
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
{
|
{
|
||||||
return [self JSToUIKitMap][JSCategory];
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
@ -71,7 +71,7 @@ RCT_EXPORT_MODULE()
|
|||||||
selector:@selector(didReceiveNewVoiceOverStatus:)
|
selector:@selector(didReceiveNewVoiceOverStatus:)
|
||||||
name:UIAccessibilityVoiceOverStatusChanged
|
name:UIAccessibilityVoiceOverStatusChanged
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(accessibilityAnnouncementDidFinish:)
|
selector:@selector(accessibilityAnnouncementDidFinish:)
|
||||||
name:UIAccessibilityAnnouncementDidFinishNotification
|
name:UIAccessibilityAnnouncementDidFinishNotification
|
||||||
@ -112,7 +112,7 @@ RCT_EXPORT_MODULE()
|
|||||||
// Response dictionary to populate the event with.
|
// Response dictionary to populate the event with.
|
||||||
NSDictionary *response = @{@"announcement": userInfo[UIAccessibilityAnnouncementKeyStringValue],
|
NSDictionary *response = @{@"announcement": userInfo[UIAccessibilityAnnouncementKeyStringValue],
|
||||||
@"success": userInfo[UIAccessibilityAnnouncementKeyWasSuccessful]};
|
@"success": userInfo[UIAccessibilityAnnouncementKeyWasSuccessful]};
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"announcementDidFinish"
|
[_bridge.eventDispatcher sendDeviceEventWithName:@"announcementDidFinish"
|
||||||
@ -176,7 +176,7 @@ RCT_EXPORT_METHOD(setAccessibilityContentSizeMultipliers:(NSDictionary *)JSMulti
|
|||||||
NSMutableDictionary<NSString *, NSNumber *> *multipliers = [NSMutableDictionary new];
|
NSMutableDictionary<NSString *, NSNumber *> *multipliers = [NSMutableDictionary new];
|
||||||
for (NSString *__nonnull JSCategory in JSMultipliers) {
|
for (NSString *__nonnull JSCategory in JSMultipliers) {
|
||||||
NSNumber *m = [RCTConvert NSNumber:JSMultipliers[JSCategory]];
|
NSNumber *m = [RCTConvert NSNumber:JSMultipliers[JSCategory]];
|
||||||
NSString *UIKitCategory = [[self class] UIKitCategoryFromJSCategory:JSCategory];
|
NSString *UIKitCategory = UIKitCategoryFromJSCategory(JSCategory);
|
||||||
multipliers[UIKitCategory] = m;
|
multipliers[UIKitCategory] = m;
|
||||||
}
|
}
|
||||||
self.multipliers = multipliers;
|
self.multipliers = multipliers;
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
static NSString *RCTCurrentAppBackgroundState()
|
static NSString *RCTCurrentAppBackgroundState()
|
||||||
{
|
{
|
||||||
RCTAssertMainQueue();
|
|
||||||
|
|
||||||
static NSDictionary *states;
|
static NSDictionary *states;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
@ -41,6 +39,13 @@ static NSString *RCTCurrentAppBackgroundState()
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
// UIApplication.applicationState seems reasonably safe to access from
|
||||||
|
// a background thread.
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (dispatch_queue_t)methodQueue
|
- (dispatch_queue_t)methodQueue
|
||||||
{
|
{
|
||||||
return dispatch_get_main_queue();
|
return dispatch_get_main_queue();
|
||||||
|
@ -132,6 +132,11 @@ static NSString *const kRCTDevSettingsUserDefaultsKey = @"RCTDevMenu";
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return YES; // RCT_DEV-only
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
// default behavior is to use NSUserDefaults
|
// default behavior is to use NSUserDefaults
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (dispatch_queue_t)methodQueue
|
- (dispatch_queue_t)methodQueue
|
||||||
{
|
{
|
||||||
return dispatch_get_main_queue();
|
return dispatch_get_main_queue();
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(allowRTL:(BOOL)value)
|
RCT_EXPORT_METHOD(allowRTL:(BOOL)value)
|
||||||
{
|
{
|
||||||
[[RCTI18nUtil sharedInstance] allowRTL:value];
|
[[RCTI18nUtil sharedInstance] allowRTL:value];
|
||||||
|
@ -17,6 +17,11 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
@synthesize bridge = _bridge;
|
@synthesize bridge = _bridge;
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||||
{
|
{
|
||||||
return @{
|
return @{
|
||||||
|
@ -77,6 +77,11 @@ NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotif
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
|
+ (BOOL)requiresMainQueueSetup
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)invalidate
|
- (void)invalidate
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -131,11 +131,9 @@ static vm_size_t RCTGetResidentMemorySize(void)
|
|||||||
|
|
||||||
RCT_EXPORT_MODULE()
|
RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
- (instancetype)init
|
+ (BOOL)requiresMainQueueSetup
|
||||||
{
|
{
|
||||||
// We're only overriding this to ensure the module gets created at startup
|
return YES;
|
||||||
// TODO (t11106126): Remove once we have more declarative control over module setup.
|
|
||||||
return [super init];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (dispatch_queue_t)methodQueue
|
- (dispatch_queue_t)methodQueue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user