Added NTSubDescriptor files and SKSubDescriptor interface
Summary: Added NTSubDescriptor file which implements the SKSubDescriptor interface to pass all NT specific data to the Layout Component Descriptor. Reviewed By: jknoxville Differential Revision: D12840392 fbshipit-source-id: bff295e13e8531456428424b7e073aefe7e1ced4
This commit is contained in:
committed by
Facebook Github Bot
parent
c6aed22a25
commit
aa979b8abd
@@ -69,6 +69,7 @@ Pod::Spec.new do |spec|
|
|||||||
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/SKInvalidation.h',
|
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/SKInvalidation.h',
|
||||||
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/SKDescriptorMapper.h',
|
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/SKDescriptorMapper.h',
|
||||||
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h',
|
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h',
|
||||||
|
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h',
|
||||||
'iOS/FBDefines/FBMacros.h',
|
'iOS/FBDefines/FBMacros.h',
|
||||||
'iOS/FlipperKit/**/{FlipperDiagnosticsViewController,FlipperStateUpdateListener,FlipperClient,FlipperPlugin,FlipperConnection,FlipperResponder,SKMacros}.h'
|
'iOS/FlipperKit/**/{FlipperDiagnosticsViewController,FlipperStateUpdateListener,FlipperClient,FlipperPlugin,FlipperConnection,FlipperResponder,SKMacros}.h'
|
||||||
header_search_paths = "\"$(PODS_ROOT)/FlipperKit/iOS/FlipperKit\" \"$(PODS_ROOT)\"/Headers/Private/FlipperKit/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\""
|
header_search_paths = "\"$(PODS_ROOT)/FlipperKit/iOS/FlipperKit\" \"$(PODS_ROOT)\"/Headers/Private/FlipperKit/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\""
|
||||||
@@ -108,7 +109,8 @@ Pod::Spec.new do |spec|
|
|||||||
ss.dependency 'FlipperKit/FlipperKitLayoutPlugin'
|
ss.dependency 'FlipperKit/FlipperKitLayoutPlugin'
|
||||||
ss.compiler_flags = folly_compiler_flags
|
ss.compiler_flags = folly_compiler_flags
|
||||||
ss.dependency 'FlipperKit/FlipperKitLayoutPlugin'
|
ss.dependency 'FlipperKit/FlipperKitLayoutPlugin'
|
||||||
ss.public_header_files = 'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h'
|
ss.public_header_files = 'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h',
|
||||||
|
'iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h'
|
||||||
ss.source_files = "iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/**/*.{h,cpp,m,mm}"
|
ss.source_files = "iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/**/*.{h,cpp,m,mm}"
|
||||||
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)\"/Headers/Private/FlipperKit/**" }
|
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)\"/Headers/Private/FlipperKit/**" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,10 +7,14 @@
|
|||||||
*/
|
*/
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#import "SKSubDescriptor.h"
|
||||||
#import <FlipperKitLayoutPlugin/SKDescriptorMapper.h>
|
#import <FlipperKitLayoutPlugin/SKDescriptorMapper.h>
|
||||||
|
|
||||||
@interface FlipperKitLayoutComponentKitSupport : NSObject
|
@interface FlipperKitLayoutComponentKitSupport : NSObject
|
||||||
|
|
||||||
+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper *)mapper;
|
+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper *)mapper;
|
||||||
|
|
||||||
|
+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper *)mapper
|
||||||
|
subDescriptors:(NSArray<SKSubDescriptor *>*)subDescriptors;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -18,9 +18,22 @@
|
|||||||
#import "SKComponentRootViewDescriptor.h"
|
#import "SKComponentRootViewDescriptor.h"
|
||||||
#import "SKComponentLayoutDescriptor.h"
|
#import "SKComponentLayoutDescriptor.h"
|
||||||
#import "SKComponentLayoutWrapper.h"
|
#import "SKComponentLayoutWrapper.h"
|
||||||
|
#import "SKSubDescriptor.h"
|
||||||
|
|
||||||
@implementation FlipperKitLayoutComponentKitSupport
|
@implementation FlipperKitLayoutComponentKitSupport
|
||||||
|
|
||||||
|
+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper *)mapper
|
||||||
|
subDescriptors:(NSArray<SKSubDescriptor *>*)subDescriptors{
|
||||||
|
[mapper registerDescriptor: [[SKComponentHostingViewDescriptor alloc] initWithDescriptorMapper: mapper]
|
||||||
|
forClass: [CKComponentHostingView class]];
|
||||||
|
[mapper registerDescriptor: [[SKComponentRootViewDescriptor alloc] initWithDescriptorMapper: mapper]
|
||||||
|
forClass: [CKComponentRootView class]];
|
||||||
|
SKComponentLayoutDescriptor *layoutDescriptor = [[SKComponentLayoutDescriptor alloc] initWithDescriptorMapper:mapper];
|
||||||
|
[layoutDescriptor addSubDescriptors:subDescriptors];
|
||||||
|
[mapper registerDescriptor: layoutDescriptor
|
||||||
|
forClass: [SKComponentLayoutWrapper class]];
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper *)mapper {
|
+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper *)mapper {
|
||||||
// What we really want here is "forProtocol:@protocol(CKInspectableView)" but no such luck.
|
// What we really want here is "forProtocol:@protocol(CKInspectableView)" but no such luck.
|
||||||
[mapper registerDescriptor: [[SKComponentHostingViewDescriptor alloc] initWithDescriptorMapper: mapper]
|
[mapper registerDescriptor: [[SKComponentHostingViewDescriptor alloc] initWithDescriptorMapper: mapper]
|
||||||
|
|||||||
@@ -7,8 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
#import <FlipperKitLayoutPlugin/SKNodeDescriptor.h>
|
#import <FlipperKitLayoutPlugin/SKNodeDescriptor.h>
|
||||||
|
|
||||||
|
#import "SKSubDescriptor.h"
|
||||||
|
|
||||||
@class SKComponentLayoutWrapper;
|
@class SKComponentLayoutWrapper;
|
||||||
|
|
||||||
@interface SKComponentLayoutDescriptor: SKNodeDescriptor<SKComponentLayoutWrapper *>
|
@interface SKComponentLayoutDescriptor: SKNodeDescriptor<SKComponentLayoutWrapper *>
|
||||||
|
|
||||||
|
- (void)addSubDescriptors:(NSArray<SKSubDescriptor *>*)subDescriptors;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
#import <FlipperKitLayoutPlugin/SKHighlightOverlay.h>
|
#import <FlipperKitLayoutPlugin/SKHighlightOverlay.h>
|
||||||
#import <FlipperKitLayoutPlugin/SKObject.h>
|
#import <FlipperKitLayoutPlugin/SKObject.h>
|
||||||
|
|
||||||
|
#import "SKSubDescriptor.h"
|
||||||
#import "SKComponentLayoutWrapper.h"
|
#import "SKComponentLayoutWrapper.h"
|
||||||
|
#import "NTSubDescriptor.h"
|
||||||
#import "CKComponent+Sonar.h"
|
#import "CKComponent+Sonar.h"
|
||||||
#import "Utils.h"
|
#import "Utils.h"
|
||||||
|
|
||||||
@@ -31,11 +33,16 @@
|
|||||||
{
|
{
|
||||||
NSDictionary<NSNumber *, NSString *> *CKFlexboxAlignSelfEnumMap;
|
NSDictionary<NSNumber *, NSString *> *CKFlexboxAlignSelfEnumMap;
|
||||||
NSDictionary<NSNumber *, NSString *> *CKFlexboxPositionTypeEnumMap;
|
NSDictionary<NSNumber *, NSString *> *CKFlexboxPositionTypeEnumMap;
|
||||||
|
NSArray<SKSubDescriptor *>*_registeredSubdescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setUp {
|
- (void)setUp {
|
||||||
[super setUp];
|
[super setUp];
|
||||||
|
|
||||||
|
if (!_registeredSubdescriptors) {
|
||||||
|
_registeredSubdescriptors = [NSArray new];
|
||||||
|
}
|
||||||
|
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
[self initEnumMaps];
|
[self initEnumMaps];
|
||||||
@@ -91,50 +98,26 @@
|
|||||||
if (node.isFlexboxChild) {
|
if (node.isFlexboxChild) {
|
||||||
[data addObject: [SKNamed newWithName:@"Layout" withValue:[self propsForFlexboxChild:node.flexboxChild]]];
|
[data addObject: [SKNamed newWithName:@"Layout" withValue:[self propsForFlexboxChild:node.flexboxChild]]];
|
||||||
}
|
}
|
||||||
|
NSMutableDictionary<NSString *, NSObject *> *extraData = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
for (SKSubDescriptor *s in _registeredSubdescriptors) {
|
||||||
|
[extraData setObject:[s getDataForNode:node] forKey:[s getName]];
|
||||||
|
}
|
||||||
|
if (extraData.count > 0) {
|
||||||
|
[data addObject: [SKNamed newWithName:@"Extra Sections" withValue:extraData]];
|
||||||
|
}
|
||||||
|
|
||||||
[data addObjectsFromArray:[node.component sonar_getData]];
|
[data addObjectsFromArray:[node.component sonar_getData]];
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(FLIPPER_OSS)
|
- (void)addSubDescriptors:(nonnull NSArray<SKSubDescriptor *>*)subDescriptors{
|
||||||
- (NSDictionary<NSString *, NSString *> *) getNTMetaDataForChild:(CKFlexboxComponentChild)child
|
_registeredSubdescriptors = subDescriptors;
|
||||||
qualifier:(NSString *) qualifier
|
|
||||||
{
|
|
||||||
NSString *str = @"{\"stackTrace\":{\"Content\":\":nt:flexbox :nt:text :nt:flexbox\"},\"unminifiedData\":{\"Content\":\"text\"}, \"graphQLCalls\":{\"Content\":\"text\"}}";
|
|
||||||
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
|
|
||||||
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
|
||||||
if ([qualifier isEqualToString:@"Stack Trace"]) {
|
|
||||||
NSDictionary *trace = [json objectForKey:@"stackTrace"];
|
|
||||||
NSString *traceString = [[trace objectForKey:@"Content"] stringByReplacingOccurrencesOfString:@" " withString:@""];
|
|
||||||
NSArray *listItems = [traceString componentsSeparatedByString:@":nt:"];
|
|
||||||
NSMutableArray *xhpComponents = [NSMutableArray array];;
|
|
||||||
for (NSString *s in listItems) {
|
|
||||||
if (![s isEqualToString:@""]) {
|
|
||||||
NSString *xhpString = [NSString stringWithFormat:@"%@%@%@", @"<nt:", s, @">"];
|
|
||||||
[xhpComponents addObject:xhpString];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return @{@"Content": [xhpComponents componentsJoinedByString:@" "]};
|
|
||||||
} else if ([qualifier isEqualToString:@"Unminified Payload"]) {
|
|
||||||
return [json objectForKey:@"unminifiedData"];
|
|
||||||
} else if ([qualifier isEqualToString:@"GraphQL Calls"]) {
|
|
||||||
return [json objectForKey:@"graphQLCalls"];
|
|
||||||
}
|
|
||||||
return @{};
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
- (NSDictionary<NSString *, NSObject *> *)propsForFlexboxChild:(CKFlexboxComponentChild)child {
|
- (NSDictionary<NSString *, NSObject *> *)propsForFlexboxChild:(CKFlexboxComponentChild)child {
|
||||||
return @{
|
return @{
|
||||||
@"spacingBefore": SKObject(@(child.spacingBefore)),
|
@"spacingBefore": SKObject(@(child.spacingBefore)),
|
||||||
#if !defined(FLIPPER_OSS)
|
|
||||||
@"Native Templates": @{
|
|
||||||
@"Stack Trace": [self getNTMetaDataForChild:child qualifier:@"Stack Trace"],
|
|
||||||
@"Unminified Payload":[self getNTMetaDataForChild:child qualifier:@"Unminified Payload"],
|
|
||||||
@"GraphQL Calls":[self getNTMetaDataForChild:child qualifier:@"GraphQL Calls"],
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
@"spacingAfter": SKObject(@(child.spacingAfter)),
|
@"spacingAfter": SKObject(@(child.spacingAfter)),
|
||||||
@"flexGrow": SKObject(@(child.flexGrow)),
|
@"flexGrow": SKObject(@(child.flexGrow)),
|
||||||
@"flexShrink": SKObject(@(child.flexShrink)),
|
@"flexShrink": SKObject(@(child.flexShrink)),
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
@class SKComponentLayoutWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
A SKSubDescriptor is an object which knows how to expose an Object of type T
|
||||||
|
to the SKLayoutDescriptor. This class is for frameworks wanting to pass data along
|
||||||
|
through the Layout Descriptor.
|
||||||
|
*/
|
||||||
|
@interface SKSubDescriptor : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is the SubDescriptor name.
|
||||||
|
*/
|
||||||
|
- (NSString *) getName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is the data the SubDescriptor wants to pass up to the SKLayoutDescriptor.
|
||||||
|
*/
|
||||||
|
- (NSDictionary<NSString *, NSObject *> *)getDataForNode:(SKComponentLayoutWrapper *)node;
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#if FB_SONARKIT_ENABLED
|
||||||
|
|
||||||
|
#import "SKSubDescriptor.h"
|
||||||
|
#import "SKComponentLayoutWrapper.h"
|
||||||
|
|
||||||
|
@implementation SKSubDescriptor
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary<NSString *, NSObject *> *)getDataForNode:(SKComponentLayoutWrapper *)node {
|
||||||
|
return @{};
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)getName {
|
||||||
|
return @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user