Extra data send from iOS to Flipper Desktop

Summary: Added `extraInfo` for node descriptor for ios. Analogical to android node descriptor

Reviewed By: cuva, Andrey-Mishanin

Differential Revision: D23105947

fbshipit-source-id: f21541e97d79c0009815f94e733a056320324459
This commit is contained in:
Dominik Wielgórski
2020-08-17 10:18:07 -07:00
committed by Facebook GitHub Bot
parent 939ed27aad
commit 41f1a0b454
5 changed files with 35 additions and 0 deletions

View File

@@ -116,6 +116,20 @@ static std::vector<std::pair<NSString*, SKSubDescriptor>>& subDescriptors() {
return data; return data;
} }
- (NSArray<SKNamed<NSDictionary<NSString*, NSObject*>*>*>*)extraInfoForNode:
(SKComponentLayoutWrapper*)node {
NSMutableArray<SKNamed<NSDictionary<NSString*, NSObject*>*>*>* data =
[NSMutableArray new];
NSMutableDictionary<NSString*, NSObject*>* metaData =
[[NSMutableDictionary alloc] init];
[metaData setObject:node.component.className forKey:@"className"];
[metaData setObject:@"CK" forKey:@"framework"];
[data addObject:[SKNamed newWithName:@"metaData" withValue:metaData]];
return data;
}
- (NSDictionary<NSString*, NSObject*>*)propsForFlexboxChild: - (NSDictionary<NSString*, NSObject*>*)propsForFlexboxChild:
(CKFlexboxComponentChild)child { (CKFlexboxComponentChild)child {
return @{ return @{

View File

@@ -484,6 +484,7 @@
NSMutableArray* attributes = [NSMutableArray new]; NSMutableArray* attributes = [NSMutableArray new];
NSMutableDictionary* data = [NSMutableDictionary new]; NSMutableDictionary* data = [NSMutableDictionary new];
NSMutableDictionary* extraInfo = [NSMutableDictionary new];
const auto* nodeAttributes = [nodeDescriptor attributesForNode:node]; const auto* nodeAttributes = [nodeDescriptor attributesForNode:node];
for (const SKNamed<NSString*>* namedPair in nodeAttributes) { for (const SKNamed<NSString*>* namedPair in nodeAttributes) {
@@ -502,6 +503,11 @@
data[namedPair.name] = namedPair.value; data[namedPair.name] = namedPair.value;
} }
const auto* nodeExtraInfo = [nodeDescriptor extraInfoForNode:node];
for (const SKNamed<NSDictionary*>* namedPair in nodeExtraInfo) {
extraInfo[namedPair.name] = namedPair.value;
}
NSMutableArray* children = [self getChildrenForNode:node NSMutableArray* children = [self getChildrenForNode:node
withDescriptor:nodeDescriptor]; withDescriptor:nodeDescriptor];
@@ -514,6 +520,7 @@
@"attributes" : attributes, @"attributes" : attributes,
@"data" : data, @"data" : data,
@"decoration" : [nodeDescriptor decorationForNode:node] ?: @"(unknown)", @"decoration" : [nodeDescriptor decorationForNode:node] ?: @"(unknown)",
@"extraInfo" : extraInfo,
}; };
return nodeDic; return nodeDic;

View File

@@ -77,6 +77,12 @@ typedef void (^SKNodeUpdateData)(id value);
*/ */
- (NSArray<SKNamed<NSDictionary*>*>*)dataForNode:(T)node; - (NSArray<SKNamed<NSDictionary*>*>*)dataForNode:(T)node;
/**
Get the extra info to pass it back to Sonar application without showing them in
the sidebar.
*/
- (NSArray<SKNamed<NSDictionary*>*>*)extraInfoForNode:(T)node;
/** /**
Get the attributes for this node. Attributes will be showed in the Sonar Get the attributes for this node. Attributes will be showed in the Sonar
application right next to the name of the node. application right next to the name of the node.

View File

@@ -59,6 +59,10 @@
return @[]; return @[];
} }
- (NSArray<SKNamed<NSDictionary*>*>*)extraInfoForNode:(id)node {
return @[];
}
- (NSArray<SKNamed<NSString*>*>*)attributesForNode:(id)node { - (NSArray<SKNamed<NSString*>*>*)attributesForNode:(id)node {
return @[]; return @[];
} }

View File

@@ -54,6 +54,7 @@
@"children" : @[], @"children" : @[],
@"attributes" : @[], @"attributes" : @[],
@"data" : @{}, @"data" : @{},
@"extraInfo" : @{},
@"decoration" : @"", @"decoration" : @"",
}])); }]));
} }
@@ -114,6 +115,7 @@
@"children" : @[], @"children" : @[],
@"attributes" : @[], @"attributes" : @[],
@"data" : @{}, @"data" : @{},
@"extraInfo" : @{},
@"decoration" : @"", @"decoration" : @"",
}, },
@{ @{
@@ -122,6 +124,7 @@
@"children" : @[], @"children" : @[],
@"attributes" : @[], @"attributes" : @[],
@"data" : @{}, @"data" : @{},
@"extraInfo" : @{},
@"decoration" : @"", @"decoration" : @"",
}, },
@{ @{
@@ -130,6 +133,7 @@
@"children" : @[], @"children" : @[],
@"attributes" : @[], @"attributes" : @[],
@"data" : @{}, @"data" : @{},
@"extraInfo" : @{},
@"decoration" : @"", @"decoration" : @"",
}, },
] ]