OSS
Summary: Move UIDebugger plugin to OSS space. Reviewed By: passy Differential Revision: D47634848 fbshipit-source-id: 90e8c0181a2434d0e5d76bdb99b902051e6d702e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
af5b9532ec
commit
db7aa9eeaf
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIDBounds : NSObject
|
||||
|
||||
@property(nonatomic) NSInteger x;
|
||||
@property(nonatomic) NSInteger y;
|
||||
@property(nonatomic) NSInteger width;
|
||||
@property(nonatomic) NSInteger height;
|
||||
|
||||
- (instancetype)initWithX:(NSInteger)x
|
||||
y:(NSInteger)y
|
||||
width:(NSInteger)width
|
||||
height:(NSInteger)height;
|
||||
|
||||
+ (instancetype)fromRect:(CGRect)rect;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDBounds.h"
|
||||
|
||||
@implementation UIDBounds
|
||||
|
||||
- (instancetype)initWithX:(NSInteger)x
|
||||
y:(NSInteger)y
|
||||
width:(NSInteger)width
|
||||
height:(NSInteger)height {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.width = width;
|
||||
self.height = height;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromRect:(CGRect)rect {
|
||||
return [[UIDBounds alloc] initWithX:rect.origin.x
|
||||
y:rect.origin.y
|
||||
width:rect.size.width
|
||||
height:rect.size.height];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIDEdgeInsets : NSObject
|
||||
|
||||
@property(nonatomic) CGFloat top;
|
||||
@property(nonatomic) CGFloat right;
|
||||
@property(nonatomic) CGFloat bottom;
|
||||
@property(nonatomic) CGFloat left;
|
||||
|
||||
- (instancetype)initWithTop:(CGFloat)top
|
||||
right:(CGFloat)right
|
||||
bottom:(CGFloat)bottom
|
||||
left:(CGFloat)left;
|
||||
|
||||
+ (instancetype)fromUIEdgeInsets:(UIEdgeInsets)edgeInsets;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDEdgeInsets.h"
|
||||
|
||||
@implementation UIDEdgeInsets
|
||||
|
||||
- (instancetype)initWithTop:(CGFloat)top
|
||||
right:(CGFloat)right
|
||||
bottom:(CGFloat)bottom
|
||||
left:(CGFloat)left {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_top = top;
|
||||
_right = right;
|
||||
_bottom = bottom;
|
||||
_left = left;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromUIEdgeInsets:(UIEdgeInsets)edgeInsets {
|
||||
return [[UIDEdgeInsets alloc] initWithTop:edgeInsets.top
|
||||
right:edgeInsets.right
|
||||
bottom:edgeInsets.bottom
|
||||
left:edgeInsets.left];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NSDictionary<NSString*, id>* UIDEventPayload;
|
||||
typedef NSArray<NSString*>* UIDStacktrace;
|
||||
|
||||
@interface UIDFrameworkEvent : NSObject
|
||||
|
||||
@property(nonatomic) NSUInteger nodeIdentifier;
|
||||
@property(nonatomic, strong) NSString* type;
|
||||
@property(nonatomic, strong) NSDate* timestamp;
|
||||
@property(nonatomic, strong) UIDEventPayload payload;
|
||||
@property(nonatomic, strong) UIDStacktrace stacktrace;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDFrameworkEvent.h"
|
||||
|
||||
@implementation UIDFrameworkEvent
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIDFrameworkEventMetadata : NSObject
|
||||
|
||||
@property(nonatomic, strong) NSString* type;
|
||||
@property(nonatomic, strong) NSString* documentation;
|
||||
|
||||
+ (instancetype)newWithType:(NSString*)type
|
||||
documentation:(NSString*)documentation;
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDFrameworkEventMetadata.h"
|
||||
|
||||
@implementation UIDFrameworkEventMetadata
|
||||
|
||||
- (instancetype)initWithType:(NSString*)type
|
||||
documentation:(NSString*)documentation {
|
||||
if (self = [super init]) {
|
||||
self->_type = type;
|
||||
self->_documentation = documentation;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)newWithType:(NSString*)type
|
||||
documentation:(NSString*)documentation {
|
||||
return [[self alloc] initWithType:type documentation:documentation];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <UIKit/UIKit.h>
|
||||
#import "UIDFoundation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIDInspectable : NSObject
|
||||
@end
|
||||
|
||||
/**
|
||||
Lazy inspectables can be used to defer materialisation
|
||||
of the inspectable until a later stage, like for example,
|
||||
during serialisation.
|
||||
*/
|
||||
@interface UIDLazyInspectable : UIDInspectable
|
||||
|
||||
- (UIDInspectable*)value;
|
||||
+ (instancetype)from:(UIDInspectable* (^)(void))loader;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableValue : UIDInspectable
|
||||
|
||||
+ (instancetype)createWithText:(NSString*)text;
|
||||
+ (instancetype)createWithBoolean:(bool)boolean;
|
||||
+ (instancetype)createWithNumber:(NSNumber*)number;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableObject : UIDInspectable
|
||||
|
||||
@property(nonatomic, strong, readonly)
|
||||
NSDictionary<NSNumber*, UIDInspectable*>* fields;
|
||||
|
||||
- (instancetype)initWithFields:
|
||||
(NSDictionary<NSNumber*, UIDInspectable*>*)fields;
|
||||
|
||||
+ (instancetype)fromFields:(NSDictionary<NSNumber*, UIDInspectable*>*)fields;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableArray : UIDInspectable
|
||||
|
||||
@property(nonatomic, strong, readonly) NSArray<UIDInspectable*>* items;
|
||||
|
||||
- (instancetype)initWithItems:(NSArray<UIDInspectable*>*)items;
|
||||
|
||||
+ (instancetype)fromItems:(NSArray<UIDInspectable*>*)items;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableText : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, strong, readonly) NSString* value;
|
||||
|
||||
- (instancetype)initWithValue:(NSString*)value;
|
||||
|
||||
+ (instancetype)fromText:(NSString*)value;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableBoolean : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, readonly) bool value;
|
||||
|
||||
- (instancetype)initWithValue:(bool)value;
|
||||
|
||||
+ (instancetype)fromBoolean:(bool)value;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableNumber : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, strong, readonly) NSNumber* value;
|
||||
|
||||
- (instancetype)initWithValue:(NSNumber*)value;
|
||||
|
||||
+ (instancetype)fromNumber:(NSNumber*)value;
|
||||
+ (instancetype)fromCGFloat:(CGFloat)value;
|
||||
|
||||
@end
|
||||
|
||||
@class UIDBounds;
|
||||
@interface UIDInspectableBounds : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, strong, readonly) UIDBounds* value;
|
||||
|
||||
- (instancetype)initWithValue:(UIDBounds*)value;
|
||||
|
||||
+ (instancetype)fromBounds:(UIDBounds*)value;
|
||||
+ (instancetype)fromRect:(CGRect)rect;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableCoordinate : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, readonly) CGPoint value;
|
||||
|
||||
- (instancetype)initWithValue:(CGPoint)value;
|
||||
|
||||
+ (instancetype)fromPoint:(CGPoint)value;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableSize : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, readonly) CGSize value;
|
||||
|
||||
- (instancetype)initWithValue:(CGSize)value;
|
||||
|
||||
+ (instancetype)fromSize:(CGSize)value;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableUnknown : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, readonly) NSString* value;
|
||||
|
||||
- (instancetype)initWithValue:(NSString*)value;
|
||||
|
||||
+ (instancetype)unknown;
|
||||
+ (instancetype)undefined;
|
||||
+ (instancetype)null;
|
||||
|
||||
@end
|
||||
|
||||
@class UIDEdgeInsets;
|
||||
@interface UIDInspectableEdgeInsets : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, readonly) UIDEdgeInsets* value;
|
||||
|
||||
- (instancetype)initWithValue:(UIDEdgeInsets*)value;
|
||||
|
||||
+ (instancetype)fromEdgeInsets:(UIDEdgeInsets*)value;
|
||||
+ (instancetype)fromUIEdgeInsets:(UIEdgeInsets)value;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableColor : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, strong, readonly) UIColor* value;
|
||||
|
||||
- (instancetype)initWithValue:(UIColor*)value;
|
||||
|
||||
+ (instancetype)fromColor:(UIColor*)value;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIDInspectableEnum : UIDInspectableValue
|
||||
|
||||
@property(nonatomic, readonly) NSString* value;
|
||||
|
||||
- (instancetype)initWithValue:(NSString*)value;
|
||||
|
||||
+ (instancetype)from:(NSString*)value;
|
||||
|
||||
@end
|
||||
|
||||
typedef NSDictionary<NSNumber*, UIDInspectable*> UIDAttributes;
|
||||
typedef NSMutableDictionary<NSNumber*, UIDInspectable*> UIDMutableAttributes;
|
||||
typedef NSDictionary<NSString*, NSString*> UIDInlineAttributes;
|
||||
typedef NSMutableDictionary<NSString*, NSString*> UIDMutableInlineAttributes;
|
||||
typedef NSDictionary<NSString*, id<UIDFoundation>> UIDGenericAttributes;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDInspectable.h"
|
||||
#import "UIDBounds.h"
|
||||
#import "UIDEdgeInsets.h"
|
||||
|
||||
@implementation UIDInspectable
|
||||
@end
|
||||
|
||||
@interface UIDLazyInspectable () {
|
||||
UIDInspectable* _value;
|
||||
UIDInspectable* (^_loader)(void);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDLazyInspectable
|
||||
- (instancetype)initWithLoader:(UIDInspectable* (^)(void))loader {
|
||||
if (self = [super init]) {
|
||||
self->_value = nil;
|
||||
self->_loader = loader;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UIDInspectable*)value {
|
||||
if (!_value && _loader) {
|
||||
_value = _loader();
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
+ (instancetype)from:(UIDInspectable* (^)(void))loader {
|
||||
return [[self alloc] initWithLoader:loader];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableObject
|
||||
|
||||
- (instancetype)initWithFields:
|
||||
(NSDictionary<NSNumber*, UIDInspectable*>*)fields {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_fields = fields;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromFields:(NSDictionary<NSNumber*, UIDInspectable*>*)fields {
|
||||
return [[UIDInspectableObject alloc] initWithFields:fields];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableArray
|
||||
|
||||
- (instancetype)initWithItems:(NSArray<UIDInspectable*>*)items {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_items = items;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromItems:(NSArray<UIDInspectable*>*)items {
|
||||
return [[UIDInspectableArray alloc] initWithItems:items];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableValue
|
||||
|
||||
+ (instancetype)createWithText:(NSString*)text {
|
||||
return [[UIDInspectableText alloc] initWithValue:text];
|
||||
}
|
||||
|
||||
+ (instancetype)createWithBoolean:(bool)boolean {
|
||||
return [[UIDInspectableBoolean alloc] initWithValue:boolean];
|
||||
}
|
||||
|
||||
+ (instancetype)createWithNumber:(NSNumber*)number {
|
||||
return [[UIDInspectableNumber alloc] initWithValue:number];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableText
|
||||
|
||||
- (instancetype)initWithValue:(NSString*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromText:(NSString*)value {
|
||||
return [[UIDInspectableText alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableBoolean
|
||||
|
||||
- (instancetype)initWithValue:(bool)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromBoolean:(bool)value {
|
||||
return [[UIDInspectableBoolean alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableNumber
|
||||
|
||||
- (instancetype)initWithValue:(NSNumber*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromNumber:(NSNumber*)value {
|
||||
return [[UIDInspectableNumber alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
+ (instancetype)fromCGFloat:(CGFloat)value {
|
||||
return [self fromNumber:[NSNumber numberWithFloat:value]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableBounds
|
||||
|
||||
- (instancetype)initWithValue:(UIDBounds*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromBounds:(UIDBounds*)bounds {
|
||||
return [[UIDInspectableBounds alloc] initWithValue:bounds];
|
||||
}
|
||||
|
||||
+ (instancetype)fromRect:(CGRect)rect {
|
||||
return [self fromBounds:[UIDBounds fromRect:rect]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableCoordinate
|
||||
|
||||
- (instancetype)initWithValue:(CGPoint)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromPoint:(CGPoint)value {
|
||||
return [[UIDInspectableCoordinate alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableSize
|
||||
|
||||
- (instancetype)initWithValue:(CGSize)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromSize:(CGSize)value {
|
||||
return [[UIDInspectableSize alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableEdgeInsets
|
||||
|
||||
- (instancetype)initWithValue:(UIDEdgeInsets*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromEdgeInsets:(UIDEdgeInsets*)value {
|
||||
return [[UIDInspectableEdgeInsets alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
+ (instancetype)fromUIEdgeInsets:(UIEdgeInsets)value {
|
||||
return [self fromEdgeInsets:[UIDEdgeInsets fromUIEdgeInsets:value]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableColor
|
||||
|
||||
- (instancetype)initWithValue:(UIColor*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)fromColor:(UIColor*)value {
|
||||
return [[UIDInspectableColor alloc] initWithValue:value];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableUnknown
|
||||
|
||||
- (instancetype)initWithValue:(NSString*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)unknown {
|
||||
return [[UIDInspectableUnknown alloc] initWithValue:@"unknown"];
|
||||
}
|
||||
|
||||
+ (instancetype)undefined {
|
||||
return [[UIDInspectableUnknown alloc] initWithValue:@"undefined"];
|
||||
}
|
||||
|
||||
+ (instancetype)null {
|
||||
return [[UIDInspectableUnknown alloc] initWithValue:@"null"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIDInspectableEnum
|
||||
|
||||
- (instancetype)initWithValue:(NSString*)value {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)from:(NSString*)value {
|
||||
return [[UIDInspectableEnum alloc] initWithValue:value ?: @"UNKNOWN"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NSNumber* UIDMetadataId;
|
||||
|
||||
@class UIDInspectableValue;
|
||||
|
||||
/**
|
||||
Represent metadata associated for an attribute. Metadata identifier is a
|
||||
unique identifier used by attributes to refer to its metadata. Type refers to
|
||||
attribute semantics. It can represent: identity, attributes, layout,
|
||||
documentation, or a custom type.
|
||||
*/
|
||||
@interface UIDMetadata : NSObject
|
||||
|
||||
@property(nonatomic, readonly) UIDMetadataId identifier;
|
||||
@property(nonatomic, strong, readonly) NSString* type;
|
||||
@property(nonatomic, readonly) UIDMetadataId parent;
|
||||
@property(nonatomic, strong, readonly) NSString* name;
|
||||
@property(nonatomic, readonly) bool isMutable;
|
||||
@property(nonatomic, strong, readonly)
|
||||
NSSet<UIDInspectableValue*>* possibleValues;
|
||||
@property(nonatomic, strong, readonly) NSSet<NSString*>* tags;
|
||||
|
||||
- (instancetype)initWithIdentifier:(UIDMetadataId)identifier
|
||||
type:(NSString*)type
|
||||
name:(NSString*)name;
|
||||
|
||||
- (instancetype)initWithIdentifier:(UIDMetadataId)identifier
|
||||
type:(NSString*)type
|
||||
name:(NSString*)name
|
||||
isMutable:(bool)isMutable
|
||||
parent:(UIDMetadataId)parent;
|
||||
|
||||
- (instancetype)initWithIdentifier:(UIDMetadataId)identifier
|
||||
type:(NSString*)type
|
||||
name:(NSString*)name
|
||||
isMutable:(bool)isMutable
|
||||
parent:(UIDMetadataId)parent
|
||||
possibleValues:(NSSet<UIDInspectableValue*>*)possibleValues
|
||||
tags:(NSSet<NSString*>*)tags;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDMetadata.h"
|
||||
#import "UIDInspectable.h"
|
||||
|
||||
@implementation UIDMetadata
|
||||
|
||||
- (instancetype)initWithIdentifier:(UIDMetadataId)identifier
|
||||
type:(NSString*)type
|
||||
name:(NSString*)name {
|
||||
return [self initWithIdentifier:identifier
|
||||
type:type
|
||||
name:name
|
||||
isMutable:false
|
||||
parent:@0
|
||||
possibleValues:[NSSet set]
|
||||
tags:[NSSet set]];
|
||||
}
|
||||
|
||||
- (instancetype)initWithIdentifier:(UIDMetadataId)identifier
|
||||
type:(NSString*)type
|
||||
name:(NSString*)name
|
||||
isMutable:(bool)isMutable
|
||||
parent:(UIDMetadataId)parent {
|
||||
return [self initWithIdentifier:identifier
|
||||
type:type
|
||||
name:name
|
||||
isMutable:isMutable
|
||||
parent:parent
|
||||
possibleValues:[NSSet set]
|
||||
tags:[NSSet set]];
|
||||
}
|
||||
|
||||
- (instancetype)initWithIdentifier:(UIDMetadataId)identifier
|
||||
type:(NSString*)type
|
||||
name:(NSString*)name
|
||||
isMutable:(bool)isMutable
|
||||
parent:(UIDMetadataId)parent
|
||||
possibleValues:(NSSet<UIDInspectableValue*>*)possibleValues
|
||||
tags:(NSSet<NSString*>*)tags {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_identifier = identifier;
|
||||
_type = type;
|
||||
_name = name;
|
||||
_isMutable = isMutable;
|
||||
_parent = parent;
|
||||
_possibleValues = possibleValues;
|
||||
_tags = tags;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 <Foundation/Foundation.h>
|
||||
#import "UIDBounds.h"
|
||||
#import "UIDInspectable.h"
|
||||
#import "UIDMetadata.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIDNode : NSObject
|
||||
|
||||
@property(nonatomic) NSUInteger identifier;
|
||||
@property(nonatomic, strong) NSString* qualifiedName;
|
||||
@property(nonatomic, strong) NSString* name;
|
||||
@property(nonatomic, strong) UIDBounds* bounds;
|
||||
@property(nonatomic, strong) NSSet<NSString*>* tags;
|
||||
@property(nonatomic, strong) UIDAttributes* attributes;
|
||||
@property(nonatomic, strong) UIDInlineAttributes* inlineAttributes;
|
||||
@property(nonatomic, strong) UIDGenericAttributes* hiddenAttributes;
|
||||
@property(nonatomic, nullable) NSNumber* parent;
|
||||
@property(nonatomic, strong) NSArray<NSNumber*>* children;
|
||||
@property(nonatomic) NSNumber* activeChild;
|
||||
|
||||
- (instancetype)initWithIdentifier:(NSUInteger)identifier
|
||||
qualifiedName:(NSString*)qualifiedName
|
||||
name:(NSString*)name
|
||||
bounds:(UIDBounds*)bounds
|
||||
tags:(NSSet<NSString*>*)tags;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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 "UIDNode.h"
|
||||
|
||||
@implementation UIDNode
|
||||
|
||||
- (instancetype)initWithIdentifier:(NSUInteger)identifier
|
||||
qualifiedName:(NSString*)qualifiedName
|
||||
name:(NSString*)name
|
||||
bounds:(UIDBounds*)bounds
|
||||
tags:(NSSet<NSString*>*)tags {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.identifier = identifier;
|
||||
self.qualifiedName = qualifiedName;
|
||||
self.name = name;
|
||||
self.bounds = bounds;
|
||||
self.tags = tags;
|
||||
self.parent = nil;
|
||||
self.children = [NSArray array];
|
||||
self.attributes = [NSDictionary dictionary];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user