Summary: Move UIDebugger plugin to OSS space.

Reviewed By: passy

Differential Revision: D47634848

fbshipit-source-id: 90e8c0181a2434d0e5d76bdb99b902051e6d702e
This commit is contained in:
Lorenzo Blasa
2023-07-21 04:47:13 -07:00
committed by Facebook GitHub Bot
parent af5b9532ec
commit db7aa9eeaf
134 changed files with 6368 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(NSArray_Foundation)
@interface NSArray<UIDFoundation>(Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,25 @@
/*
* 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 "NSArray+Foundation.h"
FB_LINKABLE(NSArray_Foundation)
@implementation NSArray (Foundation)
- (id)toFoundation {
NSMutableArray* copy = [NSMutableArray arrayWithCapacity:self.count];
for (id<UIDFoundation> object in self) {
[copy addObject:[object toFoundation]];
}
return copy;
}
@end
#endif

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(NSDictionary_Foundation)
@interface NSDictionary (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,28 @@
/*
* 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 "NSDictionary+Foundation.h"
FB_LINKABLE(NSDictionary_Foundation)
@implementation NSDictionary (Foundation)
- (id)toFoundation {
NSMutableDictionary* copy =
[NSMutableDictionary dictionaryWithCapacity:self.count];
for (id key in self) {
[copy setObject:[self[key] toFoundation] forKey:[key description]];
}
return copy;
}
@end
#endif

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(NSNull_Foundation)
@interface NSNull (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,21 @@
/*
* 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 "NSNull+Foundation.h"
FB_LINKABLE(NSNull_Foundation)
@implementation NSNull (Foundation)
- (id)toFoundation {
return self;
}
@end
#endif

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(NSSet_Foundation)
@interface NSSet<UIDFoundation>(Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,25 @@
/*
* 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 "NSSet+Foundation.h"
FB_LINKABLE(NSSet_Foundation)
@implementation NSSet (Foundation)
- (id)toFoundation {
NSMutableArray* copy = [NSMutableArray arrayWithCapacity:self.count];
for (id<UIDFoundation> object in self) {
[copy addObject:[object toFoundation]];
}
return copy;
}
@end
#endif

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(NSString_Foundation)
@interface NSString (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,21 @@
/*
* 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 "NSString+Foundation.h"
FB_LINKABLE(NSString_Foundation)
@implementation NSString (Foundation)
- (id)toFoundation {
return self;
}
@end
#endif

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(NSValue_Foundation)
@interface NSValue (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,21 @@
/*
* 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 "NSValue+Foundation.h"
FB_LINKABLE(NSValue_Foundation)
@implementation NSValue (Foundation)
- (id)toFoundation {
return self;
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDBounds.h"
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDBounds_Foundation)
@interface UIDBounds (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,26 @@
/*
* 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+Foundation.h"
FB_LINKABLE(UIDBounds_Foundation)
@implementation UIDBounds (Foundation)
- (id)toFoundation {
return @{
@"x" : [NSNumber numberWithInt:self.x],
@"y" : [NSNumber numberWithInt:self.y],
@"width" : [NSNumber numberWithInt:self.width],
@"height" : [NSNumber numberWithInt:self.height],
};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <UIKit/UIKit.h>
#import "UIDEdgeInsets.h"
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDEdgeInsets_Foundation)
@interface UIDEdgeInsets (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,26 @@
/*
* 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+Foundation.h"
FB_LINKABLE(UIDEdgeInsets_Foundation)
@implementation UIDEdgeInsets (Foundation)
- (id)toFoundation {
return @{
@"top" : [NSNumber numberWithFloat:self.top],
@"right" : [NSNumber numberWithFloat:self.right],
@"bottom" : [NSNumber numberWithFloat:self.bottom],
@"left" : [NSNumber numberWithFloat:self.left],
};
}
@end
#endif

View File

@@ -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
@protocol UIDFoundation
- (id)toFoundation;
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDFrameworkEvent.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDFrameworkEvent_Foundation)
@interface UIDFrameworkEvent (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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+Foundation.h"
FB_LINKABLE(UIDFrameworkEvent_Foundation)
@implementation UIDFrameworkEvent (Foundation)
- (id)toFoundation {
NSMutableDictionary* data = [NSMutableDictionary dictionaryWithDictionary:@{
@"nodeId" : [NSNumber numberWithUnsignedInt:self.nodeIdentifier],
@"type" : self.type,
@"timestamp" :
[NSNumber numberWithDouble:self.timestamp.timeIntervalSince1970],
@"payload" : self.payload ?: @{},
}];
if (self.stacktrace) {
[data setObject:@{@"stacktrace" : self.stacktrace, @"type" : @"stacktrace"}
forKey:@"attribution"];
}
return data;
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDFrameworkEventMetadata.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDFrameworkEventMetadata_Foundation)
@interface UIDFrameworkEventMetadata (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,25 @@
/*
* 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 "NSDictionary+Foundation.h"
#import "UIDFrameworkEventMetadata+Foundation.h"
FB_LINKABLE(UIDFrameworkEventMetadata_Foundation)
@implementation UIDFrameworkEventMetadata (Foundation)
- (id)toFoundation {
return @{
@"type" : self.type,
@"documentation" : self.documentation,
};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDInitEvent.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDInitEvent_Foundation)
@interface UIDInitEvent (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,27 @@
/*
* 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 "NSArray+Foundation.h"
#import "UIDInitEvent+Foundation.h"
FB_LINKABLE(UIDInitEvent_Foundation)
@implementation UIDInitEvent (Foundation)
- (id)toFoundation {
return @{
@"rootId" : [NSNumber numberWithUnsignedInt:self.rootId],
@"frameworkEventMetadata" : self.frameworkEventMetadata
? [self.frameworkEventMetadata toFoundation]
: @[],
};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDInspectable.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDInspectable_Foundation)
@interface UIDInspectable (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,21 @@
/*
* 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+Foundation.h"
FB_LINKABLE(UIDInspectable_Foundation)
@implementation UIDInspectable (Foundation)
- (id)toFoundation {
return @{};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDInspectable.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDInspectableArray_Foundation)
@interface UIDInspectableArray (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,27 @@
/*
* 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+Foundation.h"
#import "UIDInspectableArray+Foundation.h"
FB_LINKABLE(UIDInspectableArray_Foundation)
@implementation UIDInspectableArray (Foundation)
- (id)toFoundation {
NSMutableArray* items = [NSMutableArray arrayWithCapacity:self.items.count];
for (UIDInspectable* object in self.items) {
[items addObject:[object toFoundation]];
}
return @{@"type" : @"array", @"items" : items};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDInspectable.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDInspectableObject_Foundation)
@interface UIDInspectableObject (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,22 @@
/*
* 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 "NSDictionary+Foundation.h"
#import "UIDInspectableObject+Foundation.h"
FB_LINKABLE(UIDInspectableObject_Foundation)
@implementation UIDInspectableObject (Foundation)
- (id)toFoundation {
return @{@"type" : @"object", @"fields" : [self.fields toFoundation]};
}
@end
#endif

View File

@@ -0,0 +1,69 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDInspectable.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDInspectableText_Foundation)
@interface UIDInspectableText (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableNumber_Foundation)
@interface UIDInspectableNumber (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableBoolean_Foundation)
@interface UIDInspectableBoolean (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableBounds_Foundation)
@interface UIDInspectableBounds (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableSize_Foundation)
@interface UIDInspectableSize (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableCoordinate_Foundation)
@interface UIDInspectableCoordinate (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableEdgeInsets_Foundation)
@interface UIDInspectableEdgeInsets (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableColor_Foundation)
@interface UIDInspectableColor (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableUnknown_Foundation)
@interface UIDInspectableUnknown (Foundation)<UIDFoundation>
@end
FB_LINK_REQUIRE_CATEGORY(UIDInspectableEnum_Foundation)
@interface UIDInspectableEnum (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,183 @@
/*
* 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 <cmath>
#import "UIDBounds.h"
#import "UIDEdgeInsets+Foundation.h"
#import "UIDInspectableValue+Foundation.h"
static auto CGFloatToNSNumber(CGFloat x) -> NSNumber* {
#if CGFLOAT_IS_DOUBLE
return [NSNumber numberWithDouble:x];
#else
return [NSNumber numberWithFloat:x];
#endif
}
static auto boxedNumber(CGFloat x) -> NSObject* {
if (std::isinf(x)) {
return @"Infinity";
}
if (std::isnan(x)) {
return @"NaN";
}
return CGFloatToNSNumber(x);
}
FB_LINKABLE(UIDInspectableText_Foundation)
@implementation UIDInspectableText (Foundation)
- (id)toFoundation {
return @{
@"type" : @"text",
@"value" : self.value ?: @"null",
};
}
@end
FB_LINKABLE(UIDInspectableNumber_Foundation)
@implementation UIDInspectableNumber (Foundation)
- (id)toFoundation {
return @{
@"type" : @"number",
@"value" : std::isinf([self.value doubleValue]) ? @"Infinity" : self.value,
};
}
@end
FB_LINKABLE(UIDInspectableBoolean_Foundation)
@implementation UIDInspectableBoolean (Foundation)
- (id)toFoundation {
return @{
@"type" : @"boolean",
@"value" : [NSNumber numberWithBool:self.value],
};
}
@end
FB_LINKABLE(UIDInspectableBounds_Foundation)
@implementation UIDInspectableBounds (Foundation)
- (id)toFoundation {
return @{
@"type" : @"bounds",
@"value" : @{
@"x" : CGFloatToNSNumber(self.value.x),
@"y" : CGFloatToNSNumber(self.value.y),
@"width" : CGFloatToNSNumber(self.value.width),
@"height" : CGFloatToNSNumber(self.value.height),
},
};
}
@end
FB_LINKABLE(UIDInspectableSize_Foundation)
@implementation UIDInspectableSize (Foundation)
- (id)toFoundation {
return @{
@"type" : @"size",
@"value" : @{
@"width" : boxedNumber(self.value.width),
@"height" : boxedNumber(self.value.height),
},
};
}
@end
FB_LINKABLE(UIDInspectableCoordinate_Foundation)
@implementation UIDInspectableCoordinate (Foundation)
- (id)toFoundation {
return @{
@"type" : @"coordinate",
@"value" : @{
@"x" : CGFloatToNSNumber(self.value.x),
@"y" : CGFloatToNSNumber(self.value.y),
},
};
}
@end
FB_LINKABLE(UIDInspectableEdgeInsets_Foundation)
@implementation UIDInspectableEdgeInsets (Foundation)
- (id)toFoundation {
return @{
@"type" : @"space",
@"value" : [self.value toFoundation],
};
}
@end
FB_LINKABLE(UIDInspectableColor_Foundation)
@implementation UIDInspectableColor (Foundation)
- (id)toFoundation {
CGFloat red = 0;
CGFloat green = 0;
CGFloat blue = 0;
CGFloat alpha = 0;
[self.value getRed:&red green:&green blue:&blue alpha:&alpha];
red *= 255;
green *= 255;
blue *= 255;
alpha = 0;
return @{
@"type" : @"color",
@"value" : @{
@"r" : [NSNumber numberWithLong:red],
@"g" : [NSNumber numberWithLong:green],
@"b" : [NSNumber numberWithLong:blue],
@"a" : [NSNumber numberWithLong:alpha],
},
};
}
@end
FB_LINKABLE(UIDInspectableUnknown_Foundation)
@implementation UIDInspectableUnknown (Foundation)
- (id)toFoundation {
return @{
@"type" : @"unknown",
@"value" : self.value ?: @"unknown",
};
}
@end
FB_LINKABLE(UIDInspectableEnum_Foundation)
@implementation UIDInspectableEnum (Foundation)
- (id)toFoundation {
return @{
@"type" : @"enum",
@"value" : self.value,
};
}
@end
#endif

View File

@@ -0,0 +1,27 @@
/*
* 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 "UIDFoundation.h"
#import "UIDInitEvent+Foundation.h"
#import "UIDMetadataUpdateEvent+Foundation.h"
#import "UIDPerfStatsEvent+Foundation.h"
#import "UIDSubtreeUpdateEvent+Foundation.h"
#ifdef __cplusplus
extern "C" {
#endif
extern NSString* UID_toJSON(id obj);
extern NSString* UID_FoundationtoJSON(id obj);
extern id UID_toFoundation(id<UIDFoundation> obj);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,68 @@
/*
* 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 "UIDJSONSerializer.h"
#import "NSArray+Foundation.h"
#import "NSDictionary+Foundation.h"
#import "NSSet+Foundation.h"
#import "UIDBounds+Foundation.h"
#import "UIDEdgeInsets+Foundation.h"
#import "UIDInspectable+Foundation.h"
#import "UIDInspectableArray+Foundation.h"
#import "UIDInspectableObject+Foundation.h"
#import "UIDInspectableValue+Foundation.h"
#import "UIDMetadata+Foundation.h"
#import "UIDNode+Foundation.h"
#import "UIDPerformance.h"
#import "UIDTimeUtilities.h"
#import "UIImage+Foundation.h"
#ifdef __cplusplus
extern "C" {
#endif
id UID_toFoundation(id<UIDFoundation> object) {
return [object toFoundation];
}
NSString* UID_FoundationtoJSON(id object) {
NSError* error = NULL;
if (![NSJSONSerialization isValidJSONObject:object]) {
return @"";
}
uint64_t t0 = UIDPerformanceNow();
NSData* data = [NSJSONSerialization dataWithJSONObject:object
options:0
error:&error];
uint64_t t1 = UIDPerformanceNow();
UIDPerformanceAggregate(
@"serialisationBinaryMS", UIDMonotonicTimeConvertMachUnitsToMS(t1 - t0));
NSString* JSON = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
uint64_t t2 = UIDPerformanceNow();
UIDPerformanceAggregate(
@"serialisationEncodingMS",
UIDMonotonicTimeConvertMachUnitsToMS(t2 - t1));
return JSON;
}
NSString* UID_toJSON(id object) {
return UID_FoundationtoJSON(UID_toFoundation(object));
}
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDInspectable.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDLazyInspectable_Foundation)
@interface UIDLazyInspectable (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,31 @@
/*
* 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+Foundation.h"
#import "UIDLazyInspectable+Foundation.h"
FB_LINKABLE(UIDLazyInspectable_Foundation)
@implementation UIDLazyInspectable (Foundation)
/**
Converting a lazy inspectable to its Foundation type
equivalent may trigger materialisation of its value.
If the lazy inspectable was already materialised, then
this value will be returned and serialised.
Otherwise, the loader will be invoked to obtain the value
first.
*/
- (id)toFoundation {
return [[self value] toFoundation];
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDMetadata.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDMetadata_Foundation)
@interface UIDMetadata (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,27 @@
/*
* 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 "NSSet+Foundation.h"
#import "UIDMetadata+Foundation.h"
FB_LINKABLE(UIDMetadata_Foundation)
@implementation UIDMetadata (Foundation)
- (id)toFoundation {
return @{
@"id" : self.identifier,
@"type" : self.type,
@"name" : self.name,
@"mutable" : [NSNumber numberWithBool:self.isMutable],
};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDMetadataUpdateEvent.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDMetadataUpdateEvent_Foundation)
@interface UIDMetadataUpdateEvent (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 "NSDictionary+Foundation.h"
#import "UIDMetadataUpdateEvent+Foundation.h"
FB_LINKABLE(UIDMetadataUpdateEvent_Foundation)
@implementation UIDMetadataUpdateEvent (Foundation)
- (id)toFoundation {
return @{
@"attributeMetadata" : [self.attributeMetadata toFoundation],
};
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDNode.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDNode_Foundation)
@interface UIDNode (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,47 @@
/*
* 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 "NSDictionary+Foundation.h"
#import "UIDBounds+Foundation.h"
#import "UIDNode+Foundation.h"
FB_LINKABLE(UIDNode_Foundation)
@implementation UIDNode (Foundation)
- (id)toFoundation {
NSMutableDictionary* data = [NSMutableDictionary dictionaryWithDictionary:@{
@"id" : [NSNumber numberWithUnsignedInt:self.identifier],
@"qualifiedName" : self.qualifiedName,
@"name" : self.name,
@"bounds" : [self.bounds toFoundation],
@"tags" : self.tags.allObjects,
@"inlineAttributes" : self.inlineAttributes,
@"children" : self.children,
}];
if (self.activeChild) {
[data setObject:self.activeChild forKey:@"activeChild"];
}
if (self.attributes) {
[data setObject:[self.attributes toFoundation] forKey:@"attributes"];
}
if (self.hiddenAttributes) {
[data setObject:[self.hiddenAttributes toFoundation]
forKey:@"hiddenAttributes"];
}
if (self.parent) {
[data setObject:self.parent forKey:@"parent"];
}
return data;
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDPerfStatsEvent.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDPerfStatsEvent_Foundation)
@interface UIDPerfStatsEvent (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,43 @@
/*
* 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 "UIDPerfStatsEvent+Foundation.h"
FB_LINKABLE(UIDPerfStatsEvent_Foundation)
@implementation UIDPerfStatsEvent (Foundation)
- (id)toFoundation {
NSMutableDictionary* data = [NSMutableDictionary dictionaryWithDictionary:@{
@"txId" : [NSNumber numberWithDouble:self.txId],
@"observerType" : self.observerType,
@"nodesCount" : [NSNumber numberWithUnsignedInt:self.nodesCount],
@"eventsCount" : [NSNumber numberWithUnsignedInt:self.eventsCount],
@"start" : [NSNumber numberWithLong:self.start],
@"traversalMS" : [NSNumber numberWithLong:self.traversalMS],
@"snapshotMS" : [NSNumber numberWithLong:self.snapshotMS],
@"queuingMS" : [NSNumber numberWithLong:self.queuingMS],
@"deferredComputationMS" :
[NSNumber numberWithLong:self.deferredComputationMS],
@"serializationMS" : [NSNumber numberWithLong:self.serializationMS],
@"socketMS" : [NSNumber numberWithLong:self.socketMS],
@"payloadSize" : [NSNumber numberWithLong:self.payloadSize],
@"frameworkEventsMS" : [NSNumber numberWithLong:self.frameworkEventsMS],
}];
if (self.dynamicMeasures) {
for (id key in self.dynamicMeasures) {
[data setObject:self.dynamicMeasures[key] forKey:key];
}
}
return data;
}
@end
#endif

View File

@@ -0,0 +1,24 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <Foundation/Foundation.h>
#import "UIDFoundation.h"
#import "UIDSubtreeUpdateEvent.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIDSubtreeUpdateEvent_Foundation)
@interface UIDSubtreeUpdateEvent (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -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 "NSArray+Foundation.h"
#import "UIDSubtreeUpdateEvent+Foundation.h"
#import "UIImage+Foundation.h"
FB_LINKABLE(UIDSubtreeUpdateEvent_Foundation)
@implementation UIDSubtreeUpdateEvent (Foundation)
- (id)toFoundation {
return @{
@"txId" : [NSNumber numberWithDouble:self.txId],
@"observerType" : self.observerType,
@"rootId" : [NSNumber numberWithUnsignedInt:self.rootId],
@"nodes" : [self.nodes toFoundation],
@"snapshot" : self.snapshot ? [self.snapshot toFoundation] : @"",
@"frameworkEvents" : self.frameworkEvents
? [self.frameworkEvents toFoundation]
: @[],
};
}
@end
#endif

View File

@@ -0,0 +1,23 @@
/*
* 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 <FlipperKit/SKMacros.h>
#import <UIKit/UIKit.h>
#import "UIDFoundation.h"
NS_ASSUME_NONNULL_BEGIN
FB_LINK_REQUIRE_CATEGORY(UIImage_Foundation)
@interface UIImage (Foundation)<UIDFoundation>
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,33 @@
/*
* 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 "UIDPerformance.h"
#import "UIDTimeUtilities.h"
#import "UIImage+Foundation.h"
FB_LINKABLE(UIImage_Foundation)
@implementation UIImage (Foundation)
- (NSString*)toFoundation {
uint64_t t0 = UIDPerformanceNow();
NSData* data = UIImagePNGRepresentation(self);
NSString* base64 = [data
base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
uint64_t t1 = UIDPerformanceNow();
UIDPerformanceAggregate(
@"snapshotSerialisationMS",
UIDMonotonicTimeConvertMachUnitsToMS(t1 - t0));
return base64;
}
@end
#endif