Add metadata.customAttributes field

Summary:
`customAttributes` will be used by the UI Debugger to pass styleID for Bloks model attributes.
(replicating corresponding [Android implementation](https://www.internalfb.com/code/fbsource/[33c33fa7f582]/xplat/sonar/android/src/facebook/java/com/facebook/flipper/uidebugger/bloks/descriptors/BloksDebugComponentDescriptor.kt?lines=138-139%2C170-171))

Reviewed By: antonk52

Differential Revision: D47494013

fbshipit-source-id: 257387d4af94235b23d636047326532d7071e8dd
This commit is contained in:
Ivan Misuno
2023-07-21 14:32:22 -07:00
committed by Facebook GitHub Bot
parent b22ac16c3c
commit 1753581028
5 changed files with 74 additions and 57 deletions

View File

@@ -26,7 +26,15 @@ FOUNDATION_EXPORT NSString* const UIDEBUGGER_METADATA_TYPE_DOCUMENTATION;
- (UIDMetadataId)registerMetadataWithType:(NSString*)type
name:(NSString*)name
isMutable:(bool)isMutable
definedBy:(UIDMetadataId)definedById;
definedBy:(UIDMetadataId)parent;
- (UIDMetadataId)registerMetadataWithType:(NSString*)type
name:(NSString*)name
isMutable:(bool)isMutable
definedBy:(UIDMetadataId)parent
customAttributes:
(nullable NSDictionary<NSString*, id>*)
customAttributes;
- (NSDictionary<UIDMetadataId, UIDMetadata*>*)extractPendingMetadata;

View File

@@ -65,12 +65,34 @@ typedef NSMutableDictionary<NSString*, UIDMetadata*>* UIDNamedMetadata;
name:(NSString*)name
isMutable:(bool)isMutable
definedBy:(UIDMetadataId)parent {
return [self registerMetadataWithType:type
name:name
isMutable:isMutable
definedBy:parent
customAttributes:nil];
}
- (UIDMetadataId)registerMetadataWithType:(NSString*)type
name:(NSString*)name
isMutable:(bool)isMutable
definedBy:(UIDMetadataId)parent
customAttributes:
(nullable NSDictionary<NSString*, id>*)
customAttributes {
if (!parent) {
parent = _rootId;
}
UIDMetadataId identifier = @(++_generator);
UIDMetadata* metadata = [[UIDMetadata alloc] initWithIdentifier:identifier
type:type
name:name
isMutable:isMutable
parent:parent];
UIDMetadata* metadata =
[[UIDMetadata alloc] initWithIdentifier:identifier
type:type
name:name
isMutable:isMutable
parent:parent
possibleValues:nil
tags:nil
customAttributes:customAttributes];
[_lock lock];
if (![_register objectForKey:parent]) {