diff --git a/PortForwardingMacApp/main.m b/PortForwardingMacApp/main.m index 7d9a53edf..2025c1739 100644 --- a/PortForwardingMacApp/main.m +++ b/PortForwardingMacApp/main.m @@ -12,24 +12,25 @@ static const char kPortForwardParamPrefix[] = "-portForward="; static const char kMultiplexChannelPortParamPrefix[] = "-multiplexChannelPort="; -static BOOL prefix(const char *pre, const char *str) { - return strncmp(pre, str, strlen(pre)) == 0; +static BOOL prefix(const char* pre, const char* str) { + return strncmp(pre, str, strlen(pre)) == 0; } -int main(int argc, char *argv[]) -{ +int main(int argc, char* argv[]) { long connectionsPort = 8081; long multiplexPort = 8025; for (int i = 1; i < argc; ++i) { if (prefix(kPortForwardParamPrefix, argv[i])) { - connectionsPort = strtol(argv[i] + strlen(kPortForwardParamPrefix), NULL, 10); + connectionsPort = + strtol(argv[i] + strlen(kPortForwardParamPrefix), NULL, 10); } else if (prefix(kMultiplexChannelPortParamPrefix, argv[i])) { - multiplexPort = strtol(argv[i] + strlen(kMultiplexChannelPortParamPrefix), NULL, 10); + multiplexPort = + strtol(argv[i] + strlen(kMultiplexChannelPortParamPrefix), NULL, 10); } } - FKPortForwardingClient *client = [FKPortForwardingClient new]; + FKPortForwardingClient* client = [FKPortForwardingClient new]; [client forwardConnectionsToPort:connectionsPort]; [client connectToMultiplexingChannelOnPort:multiplexPort]; diff --git a/libs/jni-hack/real/jni.h b/libs/jni-hack/real/jni.h index 5dd7fe3fb..4bbfc0a49 100644 --- a/libs/jni-hack/real/jni.h +++ b/libs/jni-hack/real/jni.h @@ -12,6 +12,8 @@ * Everything here is expected to be VM-neutral. */ +// clang-format off + #ifndef JNI_H_ #define JNI_H_ diff --git a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.h b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.h index 4f03d9b5a..7280d47c4 100644 --- a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.h +++ b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.h @@ -8,8 +8,8 @@ #import #import -@interface AppDelegate : UIResponder +@interface AppDelegate : UIResponder -@property (nonatomic, strong) UIWindow *window; +@property(nonatomic, strong) UIWindow* window; @end diff --git a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.m b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.m index 636b87759..232b3d5d3 100644 --- a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.m +++ b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/AppDelegate.m @@ -14,51 +14,61 @@ #if DEBUG #import #import -#import #import -#import #import +#import +#import #endif @implementation AppDelegate -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ +- (BOOL)application:(UIApplication*)application + didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { [AppDelegate initializeFlipper:application]; - - RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge - moduleName:@"ReactNativeFlipperExample" - initialProperties:nil]; - rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; + RCTBridge* bridge = [[RCTBridge alloc] initWithDelegate:self + launchOptions:launchOptions]; + RCTRootView* rootView = + [[RCTRootView alloc] initWithBridge:bridge + moduleName:@"ReactNativeFlipperExample" + initialProperties:nil]; + + rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f + green:1.0f + blue:1.0f + alpha:1]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [UIViewController new]; + UIViewController* rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; } -- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge -{ +- (NSURL*)sourceURLForBridge:(RCTBridge*)bridge { #if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; + return + [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" + fallbackResource:nil]; #else - return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; + return [[NSBundle mainBundle] URLForResource:@"main" + withExtension:@"jsbundle"]; #endif } -+ (void) initializeFlipper:(UIApplication *)application -{ ++ (void)initializeFlipper:(UIApplication*)application { #if DEBUG - FlipperClient *client = [FlipperClient sharedClient]; - SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; - [client addPlugin: [[FlipperKitLayoutPlugin alloc] initWithRootNode: application withDescriptorMapper: layoutDescriptorMapper]]; - [client addPlugin: [[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; - [client addPlugin: [FlipperKitReactPlugin new]]; - [client addPlugin: [[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; + FlipperClient* client = [FlipperClient sharedClient]; + SKDescriptorMapper* layoutDescriptorMapper = + [[SKDescriptorMapper alloc] initWithDefaults]; + [client addPlugin:[[FlipperKitLayoutPlugin alloc] + initWithRootNode:application + withDescriptorMapper:layoutDescriptorMapper]]; + [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; + [client addPlugin:[FlipperKitReactPlugin new]]; + [client addPlugin:[[FlipperKitNetworkPlugin alloc] + initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; [client start]; #endif } diff --git a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/main.m b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/main.m index d4a376908..b4c2c2c3f 100644 --- a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/main.m +++ b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExample/main.m @@ -9,8 +9,9 @@ #import "AppDelegate.h" -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + return UIApplicationMain( + argc, argv, nil, NSStringFromClass([AppDelegate class])); } } diff --git a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExampleTests/ReactNativeFlipperExampleTests.m b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExampleTests/ReactNativeFlipperExampleTests.m index cd76aff11..a281a0eae 100644 --- a/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExampleTests/ReactNativeFlipperExampleTests.m +++ b/react-native/ReactNativeFlipperExample/ios/ReactNativeFlipperExampleTests/ReactNativeFlipperExampleTests.m @@ -20,12 +20,11 @@ @implementation ReactNativeFlipperExampleTests -- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test -{ +- (BOOL)findSubviewInView:(UIView*)view matching:(BOOL (^)(UIView* view))test { if (test(view)) { return YES; } - for (UIView *subview in [view subviews]) { + for (UIView* subview in [view subviews]) { if ([self findSubviewInView:subview matching:test]) { return YES; } @@ -33,31 +32,40 @@ return NO; } -- (void)testRendersWelcomeScreen -{ - UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; - NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; +- (void)testRendersWelcomeScreen { + UIViewController* vc = + [[[RCTSharedApplication() delegate] window] rootViewController]; + NSDate* date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; BOOL foundElement = NO; - __block NSString *redboxError = nil; + __block NSString* redboxError = nil; #ifdef DEBUG - RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { - if (level >= RCTLogLevelError) { - redboxError = message; - } - }); + RCTSetLogFunction( + ^(RCTLogLevel level, + RCTLogSource source, + NSString* fileName, + NSNumber* lineNumber, + NSString* message) { + if (level >= RCTLogLevelError) { + redboxError = message; + } + }); #endif while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { - [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode + beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes + beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { - if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { - return YES; - } - return NO; - }]; + foundElement = [self findSubviewInView:vc.view + matching:^BOOL(UIView* view) { + if ([view.accessibilityLabel + isEqualToString:TEXT_TO_LOOK_FOR]) { + return YES; + } + return NO; + }]; } #ifdef DEBUG @@ -65,8 +73,11 @@ #endif XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); - XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); + XCTAssertTrue( + foundElement, + @"Couldn't find element with text '%@' in %d seconds", + TEXT_TO_LOOK_FOR, + TIMEOUT_SECONDS); } - @end diff --git a/react-native/react-native-flipper/ios/FlipperModule.m b/react-native/react-native-flipper/ios/FlipperModule.m index b5d5edb9c..467ecf6ba 100644 --- a/react-native/react-native-flipper/ios/FlipperModule.m +++ b/react-native/react-native-flipper/ios/FlipperModule.m @@ -9,18 +9,17 @@ #import "FlipperReactNativeJavaScriptPluginManager.h" -@implementation FlipperModule -{ - __weak FlipperReactNativeJavaScriptPluginManager *_manager; +@implementation FlipperModule { + __weak FlipperReactNativeJavaScriptPluginManager* _manager; } -- (instancetype)init -{ - return [self initWithManager:[FlipperReactNativeJavaScriptPluginManager sharedInstance]]; +- (instancetype)init { + return [self initWithManager:[FlipperReactNativeJavaScriptPluginManager + sharedInstance]]; } -- (instancetype)initWithManager:(FlipperReactNativeJavaScriptPluginManager *)manager -{ +- (instancetype)initWithManager: + (FlipperReactNativeJavaScriptPluginManager*)manager { if (self = [super init]) { _manager = manager; } @@ -29,13 +28,11 @@ RCT_EXPORT_MODULE(Flipper) -+ (BOOL)requiresMainQueueSetup -{ ++ (BOOL)requiresMainQueueSetup { return NO; } -- (NSArray *)supportedEvents -{ +- (NSArray*)supportedEvents { return @[ @"react-native-flipper-plugin-connect", @"react-native-flipper-plugin-disconnect", @@ -43,55 +40,55 @@ RCT_EXPORT_MODULE(Flipper) ]; } -- (void)startObserving -{ - +- (void)startObserving { } -- (void)stopObserving -{ - +- (void)stopObserving { } -RCT_EXPORT_METHOD(registerPlugin:(NSString *)pluginId - inBackground:(BOOL)inBackground - statusCallback:(RCTResponseSenderBlock)statusCallback) -{ +RCT_EXPORT_METHOD(registerPlugin + : (NSString*)pluginId inBackground + : (BOOL)inBackground statusCallback + : (RCTResponseSenderBlock)statusCallback) { [_manager registerPluginWithModule:self pluginId:pluginId inBackground:inBackground statusCallback:statusCallback]; } -RCT_EXPORT_METHOD(send:(NSString *)pluginId method:(NSString *)method data:(NSString *)data) -{ +RCT_EXPORT_METHOD(send + : (NSString*)pluginId method + : (NSString*)method data + : (NSString*)data) { [_manager sendWithPluginId:pluginId method:method data:data]; } -RCT_EXPORT_METHOD(reportErrorWithMetadata:(NSString *)pluginId - reason:(NSString *)reason - stackTrace:(NSString *)stackTrace) -{ - [_manager reportErrorWithMetadata:reason stackTrace:stackTrace pluginId:pluginId]; +RCT_EXPORT_METHOD(reportErrorWithMetadata + : (NSString*)pluginId reason + : (NSString*)reason stackTrace + : (NSString*)stackTrace) { + [_manager reportErrorWithMetadata:reason + stackTrace:stackTrace + pluginId:pluginId]; } -RCT_EXPORT_METHOD(reportError:(NSString *)pluginId error:(NSString *)error) -{ +RCT_EXPORT_METHOD(reportError : (NSString*)pluginId error : (NSString*)error) { [_manager reportError:error pluginId:pluginId]; } -RCT_EXPORT_METHOD(subscribe:(NSString *)pluginId method:(NSString *)method) -{ +RCT_EXPORT_METHOD(subscribe : (NSString*)pluginId method : (NSString*)method) { [_manager subscribeWithModule:self pluginId:pluginId method:method]; } -RCT_EXPORT_METHOD(respondSuccess:(NSString *)responderId data:(NSString *)data) -{ +RCT_EXPORT_METHOD(respondSuccess + : (NSString*)responderId data + : (NSString*)data) { [_manager respondSuccessWithResponderId:responderId data:data]; } -RCT_EXPORT_METHOD(respondError:(NSString *)responderId data:(NSString *)data) -{ +RCT_EXPORT_METHOD(respondError + : (NSString*)responderId data + : (NSString*)data) { [_manager respondErrorWithResponderId:responderId data:data]; } diff --git a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.h b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.h index 3c596ec63..0aeb95eea 100644 --- a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.h +++ b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.h @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -#import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -14,11 +14,11 @@ NS_ASSUME_NONNULL_BEGIN @interface FlipperReactNativeJavaScriptPlugin : NSObject -@property (nonatomic, weak) FlipperModule *module; -@property (nonatomic, strong, readonly) id connection; +@property(nonatomic, weak) FlipperModule* module; +@property(nonatomic, strong, readonly) id connection; -- (instancetype)initWithFlipperModule:(FlipperModule *)module - pluginId:(NSString *)pluginId +- (instancetype)initWithFlipperModule:(FlipperModule*)module + pluginId:(NSString*)pluginId inBackground:(BOOL)inBackground; - (BOOL)isConnected; diff --git a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.m b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.m index 43b5b279f..03394b7e2 100644 --- a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.m +++ b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPlugin.m @@ -12,16 +12,14 @@ #import "FlipperModule.h" -@implementation FlipperReactNativeJavaScriptPlugin -{ - NSString *_pluginId; +@implementation FlipperReactNativeJavaScriptPlugin { + NSString* _pluginId; BOOL _inBackground; } -- (instancetype)initWithFlipperModule:(FlipperModule *)module - pluginId:(NSString *)pluginId - inBackground:(BOOL)inBackground -{ +- (instancetype)initWithFlipperModule:(FlipperModule*)module + pluginId:(NSString*)pluginId + inBackground:(BOOL)inBackground { if (self = [super init]) { _module = module; _pluginId = pluginId; @@ -30,43 +28,36 @@ return self; } -- (NSString *)identifier -{ +- (NSString*)identifier { return _pluginId; } -- (BOOL)runInBackground -{ +- (BOOL)runInBackground { return _inBackground; } -- (void)didConnect:(id)connection -{ +- (void)didConnect:(id)connection { _connection = connection; [self fireOnConnect]; } -- (void)didDisconnect -{ +- (void)didDisconnect { _connection = nil; [_module sendEventWithName:@"react-native-flipper-plugin-disconnect" body:[self pluginParams]]; } -- (BOOL)isConnected -{ +- (BOOL)isConnected { return _connection != nil; } -- (void)fireOnConnect -{ +- (void)fireOnConnect { [_module sendEventWithName:@"react-native-flipper-plugin-connect" body:[self pluginParams]]; } -- (id)pluginParams -{ - return @{@"plugin": _pluginId}; +- (id)pluginParams { + return @{@"plugin" : _pluginId}; } @end diff --git a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h index 0a39a2dd5..a16d0dca6 100644 --- a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h +++ b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h @@ -17,26 +17,29 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)sharedInstance; -- (void)registerPluginWithModule:(FlipperModule *)module - pluginId:(NSString *)pluginId +- (void)registerPluginWithModule:(FlipperModule*)module + pluginId:(NSString*)pluginId inBackground:(BOOL)inBackground statusCallback:(RCTResponseSenderBlock)statusCallback; -- (void)sendWithPluginId:(NSString *)pluginId method:(NSString *)method data:(NSString *)data; +- (void)sendWithPluginId:(NSString*)pluginId + method:(NSString*)method + data:(NSString*)data; -- (void)reportErrorWithMetadata:(NSString *)reason - stackTrace:(NSString *)stackTrace - pluginId:(NSString *)pluginId; +- (void)reportErrorWithMetadata:(NSString*)reason + stackTrace:(NSString*)stackTrace + pluginId:(NSString*)pluginId; -- (void)reportError:(NSString *)error pluginId:(NSString *)pluginId; +- (void)reportError:(NSString*)error pluginId:(NSString*)pluginId; -- (void)subscribeWithModule:(FlipperModule *)module - pluginId:(NSString *)pluginId - method:(NSString *)method; +- (void)subscribeWithModule:(FlipperModule*)module + pluginId:(NSString*)pluginId + method:(NSString*)method; -- (void)respondSuccessWithResponderId:(NSString *)responderId data:(NSString *)data; +- (void)respondSuccessWithResponderId:(NSString*)responderId + data:(NSString*)data; -- (void)respondErrorWithResponderId:(NSString *)responderId data:(NSString *)data; +- (void)respondErrorWithResponderId:(NSString*)responderId data:(NSString*)data; @end diff --git a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.m b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.m index 2427d2812..a62f7a481 100644 --- a/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.m +++ b/react-native/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.m @@ -5,34 +5,30 @@ * LICENSE file in the root directory of this source tree. */ - #import "FlipperReactNativeJavaScriptPluginManager.h" -#import #import +#import #import #import "FlipperModule.h" #import "FlipperReactNativeJavaScriptPlugin.h" static uint32_t FlipperResponderKeyGenerator = 0; -@implementation FlipperReactNativeJavaScriptPluginManager -{ - __weak FlipperClient *_flipperClient; - NSMutableDictionary> *_responders; +@implementation FlipperReactNativeJavaScriptPluginManager { + __weak FlipperClient* _flipperClient; + NSMutableDictionary>* _responders; } -+ (instancetype)sharedInstance -{ - static FlipperReactNativeJavaScriptPluginManager *sharedInstance = nil; ++ (instancetype)sharedInstance { + static FlipperReactNativeJavaScriptPluginManager* sharedInstance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - sharedInstance = [self new]; + sharedInstance = [self new]; }); return sharedInstance; } -- (instancetype)init -{ +- (instancetype)init { if (self = [super init]) { _flipperClient = [FlipperClient sharedClient]; _responders = [NSMutableDictionary new]; @@ -40,18 +36,18 @@ static uint32_t FlipperResponderKeyGenerator = 0; return self; } -- (void)registerPluginWithModule:(FlipperModule *)module - pluginId:(NSString *)pluginId +- (void)registerPluginWithModule:(FlipperModule*)module + pluginId:(NSString*)pluginId inBackground:(BOOL)inBackground - statusCallback:(RCTResponseSenderBlock)statusCallback -{ + statusCallback:(RCTResponseSenderBlock)statusCallback { if (_flipperClient == nil) { // Flipper is not available in this build - statusCallback(@[@"noflipper"]); + statusCallback(@[ @"noflipper" ]); return; } - FlipperReactNativeJavaScriptPlugin *existingPlugin = [self jsPluginWithIdentifier:pluginId]; + FlipperReactNativeJavaScriptPlugin* existingPlugin = + [self jsPluginWithIdentifier:pluginId]; if (existingPlugin != nil) { existingPlugin.module = module; @@ -59,86 +55,95 @@ static uint32_t FlipperResponderKeyGenerator = 0; [existingPlugin fireOnConnect]; } - statusCallback(@[@"ok"]); + statusCallback(@[ @"ok" ]); return; } - FlipperReactNativeJavaScriptPlugin *newPlugin = - [[FlipperReactNativeJavaScriptPlugin alloc] initWithFlipperModule:module - pluginId:pluginId - inBackground:inBackground]; + FlipperReactNativeJavaScriptPlugin* newPlugin = + [[FlipperReactNativeJavaScriptPlugin alloc] + initWithFlipperModule:module + pluginId:pluginId + inBackground:inBackground]; [_flipperClient addPlugin:newPlugin]; - statusCallback(@[@"ok"]); + statusCallback(@[ @"ok" ]); } -- (void)sendWithPluginId:(NSString *)pluginId method:(NSString *)method data:(NSString *)data -{ - [[self jsPluginWithIdentifier:pluginId].connection send:method - withParams:RCTJSONParse(data, NULL)]; +- (void)sendWithPluginId:(NSString*)pluginId + method:(NSString*)method + data:(NSString*)data { + [[self jsPluginWithIdentifier:pluginId].connection + send:method + withParams:RCTJSONParse(data, NULL)]; } -- (void)reportErrorWithMetadata:(NSString *)reason - stackTrace:(NSString *)stackTrace - pluginId:(NSString *)pluginId -{ - [[self jsPluginWithIdentifier:pluginId].connection errorWithMessage:reason stackTrace:stackTrace]; +- (void)reportErrorWithMetadata:(NSString*)reason + stackTrace:(NSString*)stackTrace + pluginId:(NSString*)pluginId { + [[self jsPluginWithIdentifier:pluginId].connection + errorWithMessage:reason + stackTrace:stackTrace]; } -- (void)reportError:(NSString *)error pluginId:(NSString *)pluginId -{ - +- (void)reportError:(NSString*)error pluginId:(NSString*)pluginId { // Stacktrace - NSMutableArray *callstack = NSThread.callStackSymbols.mutableCopy; - NSMutableString *callstackString = callstack.firstObject.mutableCopy; + NSMutableArray* callstack = NSThread.callStackSymbols.mutableCopy; + NSMutableString* callstackString = callstack.firstObject.mutableCopy; [callstack removeObject:callstack.firstObject]; - for (NSString *stack in callstack) { + for (NSString* stack in callstack) { [callstackString appendFormat:@"\n %@", stack]; } - - [[self jsPluginWithIdentifier:pluginId].connection errorWithMessage:error stackTrace:callstackString]; + + [[self jsPluginWithIdentifier:pluginId].connection + errorWithMessage:error + stackTrace:callstackString]; } -- (void)subscribeWithModule:(FlipperModule *)module - pluginId:(NSString *)pluginId - method:(NSString *)method -{ +- (void)subscribeWithModule:(FlipperModule*)module + pluginId:(NSString*)pluginId + method:(NSString*)method { __weak __typeof(self) weakSelf = self; - [[self jsPluginWithIdentifier: pluginId].connection receive:method withBlock:^(NSDictionary * params, id responder) { - __typeof(self) strongSelf = weakSelf; + [[self jsPluginWithIdentifier:pluginId].connection + receive:method + withBlock:^(NSDictionary* params, id responder) { + __typeof(self) strongSelf = weakSelf; - NSMutableDictionary *body = [NSMutableDictionary dictionaryWithDictionary:@{ - @"plugin": pluginId, - @"method": method, - @"params": RCTJSONStringify(params, NULL), - }]; + NSMutableDictionary* body = + [NSMutableDictionary dictionaryWithDictionary:@{ + @"plugin" : pluginId, + @"method" : method, + @"params" : RCTJSONStringify(params, NULL), + }]; - if (responder != nil) { - NSString *responderId = [NSString stringWithFormat:@"%d", FlipperResponderKeyGenerator++]; - strongSelf->_responders[responderId] = responder; - body[@"responderId"] = responderId; - } + if (responder != nil) { + NSString* responderId = + [NSString stringWithFormat:@"%d", FlipperResponderKeyGenerator++]; + strongSelf->_responders[responderId] = responder; + body[@"responderId"] = responderId; + } - [module sendEventWithName:@"react-native-flipper-receive-event" body:body]; - }]; + [module sendEventWithName:@"react-native-flipper-receive-event" + body:body]; + }]; } -- (void)respondSuccessWithResponderId:(NSString *)responderId data:(NSString *)data -{ +- (void)respondSuccessWithResponderId:(NSString*)responderId + data:(NSString*)data { id responder = _responders[responderId]; [responder success:RCTJSONParse(data, NULL)]; [_responders removeObjectForKey:responderId]; } -- (void)respondErrorWithResponderId:(NSString *)responderId data:(NSString *)data -{ +- (void)respondErrorWithResponderId:(NSString*)responderId + data:(NSString*)data { id responder = _responders[responderId]; [responder error:RCTJSONParse(data, NULL)]; [_responders removeObjectForKey:responderId]; } -- (FlipperReactNativeJavaScriptPlugin *)jsPluginWithIdentifier:(NSString *)pluginId -{ - return (FlipperReactNativeJavaScriptPlugin *)[_flipperClient pluginWithIdentifier:pluginId]; +- (FlipperReactNativeJavaScriptPlugin*)jsPluginWithIdentifier: + (NSString*)pluginId { + return (FlipperReactNativeJavaScriptPlugin*)[_flipperClient + pluginWithIdentifier:pluginId]; } @end