From 28999f77d00275139540c9b7d244b038654716c0 Mon Sep 17 00:00:00 2001 From: Adam Ernst Date: Thu, 12 Sep 2024 09:06:30 -0700 Subject: [PATCH] Delete unused dead files Summary: No BUCK target owns these, they're from the old Layout plugin (before the UI Debugger). Reviewed By: xavierjurado Differential Revision: D62579358 fbshipit-source-id: c4d786b57bb57a858b0307ca80ed0a9076f04757 --- .../CKCenterLayoutComponent+Sonar.h | 14 - .../CKCenterLayoutComponent+Sonar.mm | 107 ------ .../CKComponent+Sonar.h | 26 -- .../CKComponent+Sonar.mm | 347 ------------------ .../CKFlexboxComponent+Sonar.h | 14 - .../CKFlexboxComponent+Sonar.mm | 170 --------- .../CKInsetComponent+Sonar.h | 14 - .../CKInsetComponent+Sonar.mm | 48 --- .../CKRatioLayoutComponent+Sonar.h | 14 - .../CKRatioLayoutComponent+Sonar.mm | 46 --- .../CKStatelessComponent+Sonar.h | 16 - .../CKStatelessComponent+Sonar.mm | 26 -- .../FKDataStorageForLiveEditing.h | 18 - .../FKDataStorageForLiveEditing.mm | 28 -- .../FlipperKitLayoutComponentKitSupport.h | 16 - .../FlipperKitLayoutComponentKitSupport.mm | 41 --- .../README.md | 6 - .../SKComponentLayoutDescriptor.h | 30 -- .../SKComponentLayoutDescriptor.mm | 293 --------------- .../SKComponentLayoutWrapper.h | 57 --- .../SKComponentLayoutWrapper.mm | 151 -------- .../SKComponentMountedView.h | 35 -- .../SKComponentMountedView.mm | 25 -- .../SKComponentMountedViewDescriptor.h | 15 - .../SKComponentMountedViewDescriptor.mm | 96 ----- .../SKComponentRootViewDescriptor.h | 15 - .../SKComponentRootViewDescriptor.mm | 61 --- .../SKSubDescriptor.h | 20 - .../Utils.h | 14 - .../Utils.mm | 55 --- 30 files changed, 1818 deletions(-) delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/README.md delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.mm delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.h delete mode 100644 iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.mm diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.h deleted file mode 100644 index 783b161da8c..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - -#import -#import - -FB_LINK_REQUIRE_CATEGORY(CKCenterLayoutComponent_Sonar) -@interface CKCenterLayoutComponent (Sonar) - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.mm deleted file mode 100644 index 5250ab7334e..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKCenterLayoutComponent+Sonar.mm +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "CKCenterLayoutComponent+Sonar.h" - -#import -#import - -#import "CKComponent+Sonar.h" - -static NSDictionary* -CKCenterLayoutComponentCenteringOptionsParser( - CKCenterLayoutComponentCenteringOptions centeringOptions) { - NSMutableDictionary* centeringDict = - [NSMutableDictionary new]; - centeringDict[@"centeringX"] = SKMutableObject( - @((BOOL)(centeringOptions & CKCenterLayoutComponentCenteringX))); - centeringDict[@"centeringY"] = SKMutableObject( - @((BOOL)(centeringOptions & CKCenterLayoutComponentCenteringY))); - return centeringDict; -} - -static NSDictionary* -CKCenterLayoutComponentSizingOptionsParser( - CKCenterLayoutComponentSizingOptions sizingOptions) { - NSMutableDictionary* centeringDict = - [NSMutableDictionary new]; - centeringDict[@"sizingMinimumX"] = SKMutableObject( - @((BOOL)(sizingOptions & CKCenterLayoutComponentSizingOptionMinimumX))); - centeringDict[@"sizingMinimumY"] = SKMutableObject( - @((BOOL)(sizingOptions & CKCenterLayoutComponentSizingOptionMinimumY))); - return centeringDict; -} - -struct CKCenterLayoutComponentOptionsStruct { - CKCenterLayoutComponentCenteringOptions centeringOptions; - CKCenterLayoutComponentSizingOptions sizingOptions; - CKCenterLayoutComponentOptionsStruct() { - centeringOptions = 0; - sizingOptions = 0; - } -}; - -FB_LINKABLE(CKCenterLayoutComponent_Sonar) -@implementation CKCenterLayoutComponent (Sonar) - -- (NSArray*>*>*) - sonar_additionalDataOverride { - return @[ [SKNamed - newWithName:@"CKCenterLayoutComponent" - withValue:@{ - @"centeringOptions" : - SKMutableObject(CKCenterLayoutComponentCenteringOptionsParser( - (CKCenterLayoutComponentCenteringOptions)[ - [self valueForKey:@"_centeringOptions"] longValue])), - @"sizingOptions" : - SKMutableObject(CKCenterLayoutComponentSizingOptionsParser( - (CKCenterLayoutComponentSizingOptions)[ - [self valueForKey:@"_sizingOptions"] longValue])) - }] ]; -} - -- (void)setMutableData:(id)data { - CKCenterLayoutComponentOptionsStruct value; - [data getValue:&value]; - [self setValue:@(value.centeringOptions) forKey:@"_centeringOptions"]; - [self setValue:@(value.sizingOptions) forKey:@"_sizingOptions"]; -} - -- (NSDictionary*)sonar_getDataMutationsChanged { - __block CKCenterLayoutComponentOptionsStruct options; - options.centeringOptions = (CKCenterLayoutComponentCenteringOptions)[ - [self valueForKey:@"_centeringOptions"] longValue]; - options.sizingOptions = (CKCenterLayoutComponentSizingOptions)[ - [self valueForKey:@"_sizingOptions"] longValue]; - return @{ - @"CKCenterLayoutComponent.centeringOptions.centeringX" : ^(NSNumber* value){ - options.centeringOptions ^= CKCenterLayoutComponentCenteringX; - return [NSValue value:&options - withObjCType:@encode(CKCenterLayoutComponentOptionsStruct)]; -} -, - @"CKCenterLayoutComponent.centeringOptions.centeringY": ^(NSNumber *value) { - options.centeringOptions ^= CKCenterLayoutComponentCenteringY; - return [NSValue value:&options withObjCType:@encode(CKCenterLayoutComponentOptionsStruct)]; - }, - @"CKCenterLayoutComponent.sizingOptions.sizingMinimumX": ^(NSNumber *value) { - options.sizingOptions ^= CKCenterLayoutComponentSizingOptionMinimumX; - return [NSValue value:&options withObjCType:@encode(CKCenterLayoutComponentOptionsStruct)]; - }, - @"CKCenterLayoutComponent.sizingOptions.sizingMinimumY": ^(NSNumber *value) { - options.sizingOptions ^= CKCenterLayoutComponentSizingOptionMinimumY; - return [NSValue value:&options withObjCType:@encode(CKCenterLayoutComponentOptionsStruct)]; - }, -} -; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.h deleted file mode 100644 index 15f7a6d0445..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -#import -#import -#import -#import - -typedef id (^SKNodeDataChanged)(id value); - -FB_LINK_REQUIRE_CATEGORY(CKComponent_Sonar) -@interface CKComponent (Sonar) -@property(assign, nonatomic) NSUInteger flipper_canBeReusedCounter; - -- (void)setMutableData:(id)data; -- (NSDictionary*)sonar_getDataMutationsChanged; -- (NSArray*>*>*)sonar_getData; -- (NSDictionary*)sonar_getDataMutations; -- (NSString*)sonar_getName; -- (NSString*)sonar_getDecoration; - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.mm deleted file mode 100644 index 61f43e4a568..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKComponent+Sonar.mm +++ /dev/null @@ -1,347 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "CKComponent+Sonar.h" - -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import - -#import "CKCenterLayoutComponent+Sonar.h" -#import "CKFlexboxComponent+Sonar.h" -#import "CKInsetComponent+Sonar.h" -#import "CKRatioLayoutComponent+Sonar.h" -#import "CKStatelessComponent+Sonar.h" -#import "FKDataStorageForLiveEditing.h" -#import "Utils.h" - -/** This protocol isn't actually adopted anywhere, it just lets us use the SEL - * below */ -@protocol SonarKitLayoutComponentKitOverrideInformalProtocol -- (NSString*)sonar_componentNameOverride; -- (NSString*)sonar_componentDecorationOverride; -- (NSArray*>*>*) - sonar_additionalDataOverride; -@end - -static NSDictionary* AccessibilityContextDict( - CKComponentAccessibilityContext accessibilityContext) { - NSMutableDictionary* accessibilityDict = - [NSMutableDictionary new]; - if (accessibilityContext.isAccessibilityElement != nil) { - accessibilityDict[@"isAccessibilityElement"] = - SKObject(@([accessibilityContext.isAccessibilityElement boolValue])); - } - if (accessibilityContext.accessibilityLabel.hasText()) { - accessibilityDict[@"accessibilityLabel"] = - SKObject(accessibilityContext.accessibilityLabel.value()); - } - if (accessibilityContext.accessibilityHint.hasText()) { - accessibilityDict[@"accessibilityHint"] = - SKObject(accessibilityContext.accessibilityHint.value()); - } - if (accessibilityContext.accessibilityValue.hasText()) { - accessibilityDict[@"accessibilityValue"] = - SKObject(accessibilityContext.accessibilityValue.value()); - } - if (accessibilityContext.accessibilityTraits != nil) { - accessibilityDict[@"accessibilityTraits"] = - SKObject(@([accessibilityContext.accessibilityTraits integerValue])); - } - return accessibilityDict; -} - -FB_LINKABLE(CKComponent_Sonar) -@implementation CKComponent (Sonar) - -static FKDataStorageForLiveEditing* _dataStorage; -static NSMutableSet* _swizzledClasses; -static CK::StaticMutex _mutex = CK_MUTEX_INITIALIZER; - -+ (void)swizzleOriginalSEL:(SEL)originalSEL to:(SEL)replacementSEL { - Class targetClass = self; - Method original = class_getInstanceMethod(targetClass, originalSEL); - Method replacement = class_getInstanceMethod(targetClass, replacementSEL); - BOOL didAddMethod = class_addMethod( - targetClass, - originalSEL, - method_getImplementation(replacement), - method_getTypeEncoding(replacement)); - if (didAddMethod) { - class_replaceMethod( - targetClass, - replacementSEL, - method_getImplementation(original), - method_getTypeEncoding(original)); - } else { - method_exchangeImplementations(original, replacement); - } -} - -- (NSString*)sonar_getName { - if ([self respondsToSelector:@selector(sonar_componentNameOverride)]) { - return [(id)self sonar_componentNameOverride]; - } - auto const canBeReusedCounter = self.flipper_canBeReusedCounter; - if (canBeReusedCounter > 0) { - return [NSString stringWithFormat:@"%@ (Can be reused x%lu)", - self.className, - (unsigned long)canBeReusedCounter]; - } - return self.className; -} - -- (NSString*)sonar_getDecoration { - if ([self respondsToSelector:@selector(sonar_componentDecorationOverride)]) { - return [(id)self sonar_componentDecorationOverride]; - } - return @"componentkit"; -} - -- (NSArray*>*>*)sonar_getData { - static NSDictionary* UIControlEventsEnumMap = @{ - @(UIControlEventTouchDown) : @"UIControlEventTouchDown", - @(UIControlEventTouchDownRepeat) : @"UIControlEventTouchDownRepeat", - @(UIControlEventTouchDragInside) : @"UIControlEventTouchDragInside", - @(UIControlEventTouchDragOutside) : @"UIControlEventTouchDragOutside", - @(UIControlEventTouchDragEnter) : @"UIControlEventTouchDragEnter", - @(UIControlEventTouchDragExit) : @"UIControlEventTouchDragExit", - @(UIControlEventTouchUpInside) : @"UIControlEventTouchUpInside", - @(UIControlEventTouchUpOutside) : @"UIControlEventTouchUpOutside", - @(UIControlEventTouchCancel) : @"UIControlEventTouchTouchCancel", - - @(UIControlEventValueChanged) : @"UIControlEventValueChanged", - @(UIControlEventPrimaryActionTriggered) : - @"UIControlEventPrimaryActionTriggered", - - @(UIControlEventEditingDidBegin) : @"UIControlEventEditingDidBegin", - @(UIControlEventEditingChanged) : @"UIControlEventEditingChanged", - @(UIControlEventEditingDidEnd) : @"UIControlEventEditingDidEnd", - @(UIControlEventEditingDidEndOnExit) : @"UIControlEventEditingDidEndOnExit", - }; - - NSMutableArray*>*>* data = - [NSMutableArray new]; - - [data addObject:[SKNamed newWithName:@"CKComponent" - withValue:@{ - @"frame" : SKObject(self.viewContext.frame), - @"controller" : SKObject( - NSStringFromClass([self.controller class])), - @"size" : SKObject(ckcomponentSize([self size])), - }]]; - - auto const canBeReusedCounter = self.flipper_canBeReusedCounter; - if (canBeReusedCounter > 0) { - [data addObject:[SKNamed - newWithName:@"Convert to CKRenderComponent" - withValue:@{ - @"This component can be reused" : SKObject([NSString - stringWithFormat:@"%lu times", - (unsigned long) - canBeReusedCounter]) - }]]; - } - - if (self.viewContext.view) { - auto _actions = _CKComponentDebugControlActionsForComponent(self); - if (_actions.size() > 0) { - NSMutableDictionary* actions = - [NSMutableDictionary new]; - - for (NSNumber* controlEvent : [UIControlEventsEnumMap allKeys]) { - NSMutableArray*>* responders = - [NSMutableArray new]; - - for (const auto& action : _actions) { - if ((action.first & [controlEvent integerValue]) == 0) { - continue; - } - - for (auto responder : action.second) { - auto debugTarget = _CKTypedComponentDebugInitialTarget(responder); - if (debugTarget.isBlockBaseAction()) { - [responders addObject:@{ - @"identifier" : SKObject(@(responder.identifier().c_str())), - @"selector" : - SKObject(NSStringFromSelector(responder.selector())), - }]; - - } else { - id initialTarget = debugTarget.get(self); - const CKActionInfo actionInfo = - CKActionFind(responder.selector(), initialTarget); - [responders addObject:@{ - @"initialTarget" : - SKObject(NSStringFromClass([initialTarget class])), - @"identifier" : SKObject(@(responder.identifier().c_str())), - @"handler" : - SKObject(NSStringFromClass([actionInfo.responder class])), - @"selector" : - SKObject(NSStringFromSelector(responder.selector())), - }]; - } - } - } - - if (responders.count > 0) { - actions[UIControlEventsEnumMap[controlEvent]] = responders; - } - } - - [data addObject:[SKNamed newWithName:@"Actions" withValue:actions]]; - } - } - - auto const identitySection = [NSMutableDictionary dictionary]; - if (auto const i = self.uniqueIdentifier) { - identitySection[@"uniqueIdentifier"] = SKObject{i}; - } - if (auto const node = self.treeNode) { - if (auto const scopeIdentifier = std::get<2>(node.componentKey)) { - identitySection[@"scopeIdentifier"] = scopeIdentifier; - } - } - if (identitySection.count > 0) { - [data addObject:[SKNamed newWithName:@"Identity" - withValue:identitySection]]; - } - - // Only add accessibility panel if accessibilityContext is not default - CKComponentAccessibilityContext accessibilityContext = - [self viewConfiguration].accessibilityContext(); - NSDictionary* accessibilityDict = - AccessibilityContextDict(accessibilityContext); - if ([accessibilityDict count]) { - [data addObject:[SKNamed newWithName:@"Accessibility" - withValue:@{ - @"accessibilityContext" : accessibilityDict, - @"accessibilityEnabled" : SKMutableObject( - @(CK::Component::Accessibility:: - IsAccessibilityEnabled())), - }]]; - } - if ([self respondsToSelector:@selector(sonar_additionalDataOverride)]) { - [data addObjectsFromArray:[(id)self sonar_additionalDataOverride]]; - } - - return data; -} - -- (void)setMutableData:(id)value { -} - -- (void)setMutableDataFromStorage { - const auto globalID = self.treeNode.nodeIdentifier; - id data = [_dataStorage dataForTreeNodeIdentifier:globalID]; - if (data) { - [self setMutableData:data]; - } -} - -+ (NSString*)swizzledMethodNameForRender { - return - [NSString stringWithFormat:@"sonar_render_%@", NSStringFromClass(self)]; -} - -+ (SEL)registerNewImplementation:(SEL)selector { - SEL resultSelector = - sel_registerName([[self swizzledMethodNameForRender] UTF8String]); - Method method = class_getInstanceMethod(self, selector); - class_addMethod( - self, - resultSelector, - method_getImplementation(method), - method_getTypeEncoding(method)); - return resultSelector; -} - -- (CKComponent*)sonar_render:(id)state { - [self setMutableDataFromStorage]; - SEL resultSelector = - NSSelectorFromString([[self class] swizzledMethodNameForRender]); - return ((CKComponent * (*)(CKComponent*, SEL, id)) objc_msgSend)( - self, resultSelector, state); -} - -- (NSDictionary*)sonar_getDataMutationsChanged { - return @{}; -} - -- (NSDictionary*)sonar_getDataMutations { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _dataStorage = [[FKDataStorageForLiveEditing alloc] init]; - _swizzledClasses = [[NSMutableSet alloc] init]; - }); - { - CK::StaticMutexLocker l(_mutex); - if (![_swizzledClasses containsObject:NSStringFromClass([self class])]) { - [_swizzledClasses addObject:NSStringFromClass([self class])]; - if ([self respondsToSelector:@selector(render:)]) { - SEL replacement = - [[self class] registerNewImplementation:@selector(sonar_render:)]; - [[self class] swizzleOriginalSEL:@selector(render:) to:replacement]; - } else { - CKAssert( - NO, - @"Only CKRenderLayoutComponent and CKRenderLayoutWithChildrenComponent children are now able to be live editable"); - } - } - } - NSDictionary* dataChanged = - [self sonar_getDataMutationsChanged]; - NSMutableDictionary* dataMutation = [[NSMutableDictionary alloc] init]; - [dataMutation addEntriesFromDictionary:@{ - @"Accessibility.accessibilityEnabled": ^(NSNumber *value) { - CK::Component::Accessibility::SetForceAccessibilityEnabled([value boolValue]); -} -} - ]; - const auto globalID = self.treeNode.nodeIdentifier; - for (NSString* key in dataChanged) { - const auto block = dataChanged[key]; - [dataMutation - setObject:^(id value) { - id data = block(value); - [_dataStorage setData:data forTreeNodeIdentifier:globalID]; - [CKComponentDebugController - reflowComponentsWithTreeNodeIdentifier:globalID]; - } - forKey:key]; - } - return dataMutation; - } - - static char const kCanBeReusedKey = ' '; - - - (void)setFlipper_canBeReusedCounter:(NSUInteger)canBeReusedCounter { - objc_setAssociatedObject( - self, - &kCanBeReusedKey, - @(canBeReusedCounter), - OBJC_ASSOCIATION_RETAIN_NONATOMIC); - } - - - (NSUInteger)flipper_canBeReusedCounter { - return [objc_getAssociatedObject(self, &kCanBeReusedKey) - unsignedIntegerValue]; - } - - @end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.h deleted file mode 100644 index f7ba4dcf68a..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - -#import -#import - -FB_LINK_REQUIRE_CATEGORY(CKFlexboxComponent_Sonar) -@interface CKFlexboxComponent (Sonar) - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.mm deleted file mode 100644 index f29e05c71c5..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKFlexboxComponent+Sonar.mm +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "CKFlexboxComponent+Sonar.h" - -#import -#import - -#import "CKComponent+Sonar.h" -#import "Utils.h" - -FB_LINKABLE(CKFlexboxComponent_Sonar) -@implementation CKFlexboxComponent (Sonar) - -static NSDictionary* CKFlexboxDirectionEnumMap; - -static NSDictionary* CKFlexboxJustifyContentEnumMap; - -static NSDictionary* CKFlexboxAlignItemsEnumMap; - -static NSDictionary* CKFlexboxAlignContentEnumMap; - -static NSDictionary* CKFlexboxWrapEnumMap; - -+ (void)initialize { - CKFlexboxDirectionEnumMap = @{ - @(CKFlexboxDirectionColumn) : @"column", - @(CKFlexboxDirectionRow) : @"row", - @(CKFlexboxDirectionColumnReverse) : @"column-reverse", - @(CKFlexboxDirectionRowReverse) : @"row-reverse", - }; - CKFlexboxJustifyContentEnumMap = @{ - @(CKFlexboxJustifyContentStart) : @"start", - @(CKFlexboxJustifyContentCenter) : @"center", - @(CKFlexboxJustifyContentEnd) : @"end", - @(CKFlexboxJustifyContentSpaceBetween) : @"space-between", - @(CKFlexboxJustifyContentSpaceAround) : @"space-around", - }; - CKFlexboxAlignItemsEnumMap = @{ - @(CKFlexboxAlignItemsStart) : @"start", - @(CKFlexboxAlignItemsEnd) : @"end", - @(CKFlexboxAlignItemsCenter) : @"center", - @(CKFlexboxAlignItemsBaseline) : @"baseline", - @(CKFlexboxAlignItemsStretch) : @"stretch", - }; - CKFlexboxAlignContentEnumMap = @{ - @(CKFlexboxAlignContentStart) : @"start", - @(CKFlexboxAlignContentEnd) : @"end", - @(CKFlexboxAlignContentCenter) : @"center", - @(CKFlexboxAlignContentSpaceBetween) : @"space-between", - @(CKFlexboxAlignContentSpaceAround) : @"space-around", - @(CKFlexboxAlignContentStretch) : @"stretch", - }; - CKFlexboxWrapEnumMap = @{ - @(CKFlexboxWrapWrap) : @"wrap", - @(CKFlexboxWrapNoWrap) : @"no-wrap", - @(CKFlexboxWrapWrapReverse) : @"wrap-reverse", - }; -} - -- (NSArray*>*>*) - sonar_additionalDataOverride { - CKFlexboxComponentStyle style; - [[self valueForKey:@"_style"] getValue:&style]; - - return @[ [SKNamed - newWithName:@"CKFlexboxComponent" - withValue:@{ - @"spacing" : SKMutableObject(@(style.spacing)), - @"direction" : - SKMutableObject(CKFlexboxDirectionEnumMap[@(style.direction)]), - @"justifyContent" : SKMutableObject( - CKFlexboxJustifyContentEnumMap[@(style.justifyContent)]), - @"alignItems" : - SKMutableObject(CKFlexboxAlignItemsEnumMap[@(style.alignItems)]), - @"alignContent" : SKMutableObject( - CKFlexboxAlignContentEnumMap[@(style.alignContent)]), - @"wrap" : SKMutableObject(CKFlexboxWrapEnumMap[@(style.wrap)]), - @"padding" : SKMutableObject(flexboxRect(style.padding)), - }] ]; -} - -- (void)setMutableData:(id)data { - CKFlexboxComponentStyle style; - [data getValue:&style]; - [self setValue:data forKey:@"_style"]; -} - -- (NSDictionary*)sonar_getDataMutationsChanged { - __block CKFlexboxComponentStyle style; - [[self valueForKey:@"_style"] getValue:&style]; - return @{@"CKFlexboxComponent.spacing" : ^(NSNumber* value){ - style.spacing = value.floatValue; - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; -} -, - @"CKFlexboxComponent.direction": ^(NSString *value) { - for (NSNumber *key in CKFlexboxDirectionEnumMap) { - if ([CKFlexboxDirectionEnumMap[key] isEqualToString:value]) { - style.direction = (CKFlexboxDirection) key.intValue; - break; - } - } - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.alignContent": ^(NSString *value) { - for (NSNumber *key in CKFlexboxAlignContentEnumMap) { - if ([CKFlexboxAlignContentEnumMap[key] isEqualToString:value]) { - style.alignContent = (CKFlexboxAlignContent) key.intValue; - break; - } - } - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.alignContent": ^(NSString *value) { - for (NSNumber *key in CKFlexboxAlignItemsEnumMap) { - if ([CKFlexboxAlignItemsEnumMap[key] isEqualToString:value]) { - style.alignItems = (CKFlexboxAlignItems) key.intValue; - break; - } - } - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.justifyContent": ^(NSString *value) { - for (NSNumber *key in CKFlexboxJustifyContentEnumMap) { - if ([CKFlexboxJustifyContentEnumMap[key] isEqualToString:value]) { - style.justifyContent = (CKFlexboxJustifyContent) key.intValue; - break; - } - } - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.wrap": ^(NSString *value) { - for (NSNumber *key in CKFlexboxWrapEnumMap) { - if ([CKFlexboxWrapEnumMap[key] isEqualToString:value]) { - style.wrap = (CKFlexboxWrap) key.intValue; - break; - } - } - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.padding.bottom": ^(NSString *value) { - style.padding.bottom = relativeStructDimension(value); - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.padding.top": ^(NSString *value) { - style.padding.top = relativeStructDimension(value); - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.padding.end": ^(NSString *value) { - style.padding.end = relativeStructDimension(value); - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, - @"CKFlexboxComponent.padding.start": ^(NSString *value) { - style.padding.start = relativeStructDimension(value); - return [NSValue value:&style withObjCType:@encode(CKFlexboxComponentStyle)]; - }, -} -; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.h deleted file mode 100644 index cdfb76e8d5f..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - -#import -#import - -FB_LINK_REQUIRE_CATEGORY(CKInsetComponent_Sonar) -@interface CKInsetComponent (Sonar) - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm deleted file mode 100644 index b16d7291a32..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKInsetComponent+Sonar.mm +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "CKInsetComponent+Sonar.h" - -#import -#import -#import - -#import "CKComponent+Sonar.h" - -FB_LINKABLE(CKInsetComponent_Sonar) -@implementation CKInsetComponent (Sonar) - -- (NSArray*>*>*) - sonar_additionalDataOverride { - return @[ - [SKNamed newWithName:@"CKInsetComponent" - withValue:@{@"insets" : SKObject([self insetsDictionary])}], - ]; -} - -- (id)insetsDictionary { - CKRelativeDimension top; - CKRelativeDimension left; - CKRelativeDimension bottom; - CKRelativeDimension right; - [[self valueForKey:@"_top"] getValue:&top]; - [[self valueForKey:@"_left"] getValue:&left]; - [[self valueForKey:@"_right"] getValue:&bottom]; - [[self valueForKey:@"_bottom"] getValue:&right]; - return @{ - @"top" : top.description(), - @"left" : left.description(), - @"bottom" : bottom.description(), - @"right" : right.description(), - }; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.h deleted file mode 100644 index 24459f5acbd..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - -#import -#import - -FB_LINK_REQUIRE_CATEGORY(CKRatioLayoutComponent_Sonar) -@interface CKRatioLayoutComponent (Sonar) - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.mm deleted file mode 100644 index e3b60a8b811..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKRatioLayoutComponent+Sonar.mm +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "CKRatioLayoutComponent+Sonar.h" - -#import -#import - -#import "CKComponent+Sonar.h" - -FB_LINKABLE(CKRatioLayoutComponent_Sonar) -@implementation CKRatioLayoutComponent (Sonar) - -- (NSArray*>*>*) - sonar_additionalDataOverride { - return @[ [SKNamed - newWithName:@"CKRatioLayoutComponent" - withValue:@{ - @"ratio" : SKMutableObject((NSNumber*)[self valueForKey:@"_ratio"]) - }] ]; -} - -- (void)setMutableData:(id)data { - [self setValue:data forKey:@"_ratio"]; -} - -- (NSDictionary*)sonar_getDataMutationsChanged { - return @{@"CKRatioLayoutComponent.ratio" : ^(NSNumber* value){ - CGFloat ratio = [(NSNumber*)[self valueForKey:@"_ratio"] floatValue]; - ratio = value.floatValue; - return [NSNumber numberWithFloat:ratio]; -} -, -} -; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.h deleted file mode 100644 index bf049bd9b9a..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -#import -#import - -FB_LINK_REQUIRE_CATEGORY(CKStatelessComponent_Sonar) -@interface CKStatelessComponent (Sonar) - -- (NSString*)sonar_componentNameOverride; - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.mm deleted file mode 100644 index 5d1632b4bb2..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/CKStatelessComponent+Sonar.mm +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "CKStatelessComponent+Sonar.h" - -#import -#import - -#import "CKComponent+Sonar.h" - -FB_LINKABLE(CKStatelessComponent_Sonar) -@implementation CKStatelessComponent (Sonar) - -- (NSString*)sonar_componentNameOverride { - return [self description]; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.h deleted file mode 100644 index 023569d0df9..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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. - */ - -#import - -/** DataStorage uses to map global IDs of nodes to data which we want to store -to prodice live editing*/ -@interface FKDataStorageForLiveEditing : NSObject - -- (id)dataForTreeNodeIdentifier:(CKTreeNodeIdentifier)treeNodeIdentifier; -- (void)setData:(id)value - forTreeNodeIdentifier:(CKTreeNodeIdentifier)treeNodeIdentifier; - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.mm deleted file mode 100644 index 7a134105144..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FKDataStorageForLiveEditing.mm +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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. - */ - -#import "FKDataStorageForLiveEditing.h" -#import -#import - -@implementation FKDataStorageForLiveEditing { - std::unordered_map _data; - std::mutex _mutex; -} - -- (void)setData:(id)value - forTreeNodeIdentifier:(CKTreeNodeIdentifier)treeNodeIdentifier { - std::lock_guard lock(_mutex); - _data[treeNodeIdentifier] = value; -} - -- (id)dataForTreeNodeIdentifier:(CKTreeNodeIdentifier)treeNodeIdentifier { - std::lock_guard lock(_mutex); - return (_data.count(treeNodeIdentifier) ? _data[treeNodeIdentifier] : nil); -} - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h deleted file mode 100644 index ff06a564c28..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -#import - -#import - -@interface FlipperKitLayoutComponentKitSupport : NSObject - -+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper*)mapper; - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm deleted file mode 100644 index 80f985eea4c..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/FlipperKitLayoutComponentKitSupport.mm +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "FlipperKitLayoutComponentKitSupport.h" - -#import -#import - -#import - -#import "SKComponentLayoutDescriptor.h" -#import "SKComponentLayoutWrapper.h" -#import "SKComponentMountedView.h" -#import "SKComponentMountedViewDescriptor.h" -#import "SKComponentRootViewDescriptor.h" - -@implementation FlipperKitLayoutComponentKitSupport - -+ (void)setUpWithDescriptorMapper:(SKDescriptorMapper*)mapper { - // What we really want here is "forProtocol:@protocol(CKInspectableView)" but - // no such luck. - [mapper registerDescriptor:[[SKComponentRootViewDescriptor alloc] - initWithDescriptorMapper:mapper] - forClass:[CKComponentRootView class]]; - [mapper registerDescriptor:[[SKComponentLayoutDescriptor alloc] - initWithDescriptorMapper:mapper] - forClass:[SKComponentLayoutWrapper class]]; - [mapper registerDescriptor:[[SKComponentMountedViewDescriptor alloc] - initWithDescriptorMapper:mapper] - forClass:[SKComponentMountedView class]]; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/README.md b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/README.md deleted file mode 100644 index 32faa1d8fe2..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/README.md +++ /dev/null @@ -1,6 +0,0 @@ -This folder is just kept for opensource integration for Flipper to work with CK -as CK is not planning to make any more releases on Cocoapods. - -Do not make new changes here, the internal layout plugin refers to the code from -sonar/iOS/Plugins/Facebook/FlipperKitLayoutComponentKitSupport and the -opensource refers it from here. diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.h deleted file mode 100644 index 944897e15b1..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - */ - -#import - -#import "SKSubDescriptor.h" - -@class SKComponentLayoutWrapper; - -typedef SKNamed* (*SKAttributeGenerator)(SKComponentLayoutWrapper* node); - -@interface SKComponentLayoutDescriptor - : SKNodeDescriptor - -+ (void)registerSubDescriptor:(SKSubDescriptor)descriptor - forName:(NSString*)name; - -/** - Allows you to 'plug-in' additional logic to update the attribute - string displayed for a node. - - You can return a `nil` object from this, it will be gracefully ignored. - */ -+ (void)registerAttributeGenerator:(SKAttributeGenerator)generator; - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm deleted file mode 100644 index 52e778b98d7..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm +++ /dev/null @@ -1,293 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "SKComponentLayoutDescriptor.h" - -#import -#import - -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import - -#import -#import -#import - -#import "CKComponent+Sonar.h" -#import "SKComponentLayoutWrapper.h" -#import "SKComponentMountedView.h" -#import "SKSubDescriptor.h" -#import "Utils.h" - -@implementation SKComponentLayoutDescriptor - -static std::vector>& subDescriptors() { - // Avoid a global constructor; we want to lazily initialize this when needed. - static std::vector> d; - return d; -} - -static std::vector& attributeGenerators() { - // Avoid a global constructor; we want to lazily initialize this when needed. - static std::vector d; - return d; -} - -+ (void)registerAttributeGenerator:(SKAttributeGenerator)generator { - if (generator) { - attributeGenerators().push_back(generator); - } -} - -+ (void)registerSubDescriptor:(SKSubDescriptor)descriptor - forName:(NSString*)name { - if (name && descriptor) { - subDescriptors().push_back({name, descriptor}); - } -} - -- (NSString*)identifierForNode:(SKComponentLayoutWrapper*)node { - return node.identifier; -} - -- (NSString*)identifierForInvalidation:(SKComponentLayoutWrapper*)node { - return [NSString stringWithFormat:@"%p", node.rootNode]; -} - -- (NSString*)nameForNode:(SKComponentLayoutWrapper*)node { - return [node.component sonar_getName]; -} - -- (NSString*)decorationForNode:(SKComponentLayoutWrapper*)node { - return [node.component sonar_getDecoration]; -} - -- (NSUInteger)childCountForNode:(SKComponentLayoutWrapper*)node { - if (!node) { - return 0; // -children will return garbage if invoked on nil - } - return node.children.match( - [](SKLeafViewChild) -> NSUInteger { return 1; }, - [](SKMountedViewChild) -> NSUInteger { return 1; }, - [](const std::vector& components) - -> NSUInteger { return components.size(); }); -} - -- (id)childForNode:(SKComponentLayoutWrapper*)node atIndex:(NSUInteger)index { - if (!node) { - return nil; // -children will return garbage if invoked on nil - } - return node.children.match( - [](SKLeafViewChild leafView) -> id { return leafView.view; }, - [](SKMountedViewChild mountedView) -> id { return mountedView.view; }, - [&](const std::vector& components) -> id { - return components[index]; - }); -} - -- (NSArray*>*>*)dataForNode: - (SKComponentLayoutWrapper*)node { - NSMutableArray*>*>* data = - [NSMutableArray new]; - - if (node) { - node.flexboxChild.apply([&](const CKFlexboxComponentChild& child) { - [data addObject:[SKNamed newWithName:@"Layout" - withValue:[self propsForFlexboxChild:child]]]; - }); - } - NSMutableDictionary* extraData = - [[NSMutableDictionary alloc] init]; - - for (const auto& pair : subDescriptors()) { - NSString* value = pair.second(node); - if (value) { - [extraData setObject:value forKey:pair.first]; - } - } - if (extraData.count > 0) { - [data addObject:[SKNamed newWithName:@"Extra Sections" - withValue:extraData]]; - } - - [data addObjectsFromArray:[node.component sonar_getData]]; - return data; -} - -- (NSArray*>*>*)extraInfoForNode: - (SKComponentLayoutWrapper*)node { - NSMutableArray*>*>* data = - [NSMutableArray new]; - NSMutableDictionary* 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*)propsForFlexboxChild: - (CKFlexboxComponentChild)child { - return @{ - @"spacingBefore" : SKObject(@(child.spacingBefore)), - @"spacingAfter" : SKObject(@(child.spacingAfter)), - @"flexGrow" : SKObject(@(child.flexGrow)), - @"flexShrink" : SKObject(@(child.flexShrink)), - @"zIndex" : SKObject(@(child.zIndex)), - @"sizeConstraints" : SKObject(ckcomponentSize(child.sizeConstraints)), - @"useTextRounding" : SKObject(@(child.useTextRounding)), - @"margin" : flexboxRect(child.margin), - @"flexBasis" : relativeDimension(child.flexBasis), - @"padding" : flexboxRect(child.padding), - @"alignSelf" : stringForAlignSelf(child.alignSelf), - @"position" : @{ - @"type" : stringForFlexboxPositionType(child.position.type), - @"start" : relativeDimension(child.position.start), - @"top" : relativeDimension(child.position.top), - @"end" : relativeDimension(child.position.end), - @"bottom" : relativeDimension(child.position.bottom), - @"left" : relativeDimension(child.position.left), - @"right" : relativeDimension(child.position.right), - }, - @"aspectRatio" : @(child.aspectRatio.aspectRatio()), - }; -} - -- (NSDictionary*)dataMutationsForNode: - (SKComponentLayoutWrapper*)node { - return [node.component sonar_getDataMutations]; -} - -- (NSArray*>*)attributesForNode: - (SKComponentLayoutWrapper*)node { - NSMutableArray*>* attributes = [NSMutableArray array]; - [attributes - addObject:[SKNamed - newWithName:@"responder" - withValue:SKObject(NSStringFromClass( - [node.component.nextResponder class]))]]; - for (SKAttributeGenerator generator : attributeGenerators()) { - if (!generator) { - // technically, this could be nullptr, so lets be careful. - continue; - } - - SKNamed* const attribute = generator(node); - if (attribute) { - [attributes addObject:attribute]; - } - } - return attributes; -} - -- (void)setHighlighted:(BOOL)highlighted - forNode:(SKComponentLayoutWrapper*)node { - SKHighlightOverlay* overlay = [SKHighlightOverlay sharedInstance]; - if (highlighted) { - const auto viewContext = node.component.viewContext; - [overlay mountInView:viewContext.view withFrame:viewContext.frame]; - } else { - [overlay unmount]; - } -} - -- (void)hitTest:(SKTouch*)touch forNode:(SKComponentLayoutWrapper*)node { - if (!node) { - return; // -children will return garbage if invoked on nil - } - BOOL didContinueTouch = node.children.match( - [&](SKLeafViewChild leafView) -> BOOL { - [touch continueWithChildIndex:0 withOffset:{0, 0}]; - return YES; - }, - [&](SKMountedViewChild mountedView) -> BOOL { - [touch continueWithChildIndex:0 withOffset:{0, 0}]; - return YES; - }, - [&](std::vector children) -> BOOL { - BOOL continueTouch = NO; - for (auto it = children.rbegin(); it != children.rend(); ++it) { - SKComponentLayoutWrapper* wrapper = *it; - CGRect frame = {.origin = wrapper.position, .size = wrapper.size}; - if ([touch containedIn:frame]) { - NSUInteger index = std::distance(children.begin(), it.base()) - 1; - [touch continueWithChildIndex:index withOffset:wrapper.position]; - continueTouch = YES; - } - } - return continueTouch; - }); - if (!didContinueTouch) { - [touch finish]; - } -} - -- (BOOL)matchesQuery:(NSString*)query forNode:(id)node { - if ([super matchesQuery:query forNode:node]) { - return YES; - } - if ([node isKindOfClass:[SKComponentLayoutWrapper class]]) { - const auto layoutWrapper = (SKComponentLayoutWrapper*)node; - if ([layoutWrapper.component - conformsToProtocol:@protocol(FKTextSearchable)]) { - NSString* text = - ((id)layoutWrapper.component).searchableText; - return [self string:text contains:query]; - } - } - return NO; -} - -- (BOOL)string:(NSString*)string contains:(NSString*)substring { - return string != nil && substring != nil && - [string rangeOfString:substring options:NSCaseInsensitiveSearch] - .location != NSNotFound; -} - -static NSString* stringForAlignSelf(CKFlexboxAlignSelf alignSelf) { - switch (alignSelf) { - case CKFlexboxAlignSelfAuto: - return @"auto"; - case CKFlexboxAlignSelfStart: - return @"start"; - case CKFlexboxAlignSelfEnd: - return @"end"; - case CKFlexboxAlignSelfCenter: - return @"center"; - case CKFlexboxAlignSelfBaseline: - return @"baseline"; - case CKFlexboxAlignSelfStretch: - return @"stretch"; - } - return @"unknown"; -} - -static NSString* stringForFlexboxPositionType(CKFlexboxPositionType type) { - switch (type) { - case CKFlexboxPositionTypeRelative: - return @"relative"; - case CKFlexboxPositionTypeAbsolute: - return @"absolute"; - } - return @"unknown"; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h deleted file mode 100644 index 83eef6b3f22..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#import - -#import -#import -#import -#import - -#import - -@protocol CKInspectableView; -@class SKComponentLayoutWrapper; -@class SKComponentMountedView; - -// RC::Variant does not support Objective-C types unless they are boxed: -struct SKLeafViewChild { - UIView* view; -}; -struct SKMountedViewChild { - SKComponentMountedView* view; -}; - -/** - The children of a SKComponentLayoutWrapper may be: - - A single leaf view, which may have UIView children of its own. - - A single non-leaf view, if the component created a view; its children will be - the component's child components. - - An array of SKComponentLayoutWrappers, if the component did not create a - view. - */ -using SKComponentLayoutWrapperChildren = CK::Variant< - SKLeafViewChild, - SKMountedViewChild, - std::vector>; - -@interface SKComponentLayoutWrapper : NSObject - -@property(nonatomic, weak, readonly) CKComponent* component; -@property(nonatomic, readonly) NSString* identifier; -@property(nonatomic, readonly) CGSize size; -@property(nonatomic, readonly) CGPoint position; -@property(nonatomic, readonly) SKComponentLayoutWrapperChildren children; -@property(nonatomic, weak, readonly) id rootNode; -/** CK::none for components that are not the child of a CKFlexboxComponent. */ -@property(nonatomic, readonly) CK::Optional - flexboxChild; - -+ (instancetype)newFromRoot:(id)root - parentKey:(NSString*)parentKey; - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm deleted file mode 100644 index c9e9f9599ab..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "SKComponentLayoutWrapper.h" - -#import -#import -#import -#import -#import -#import -#import - -#import "CKComponent+Sonar.h" -#import "SKComponentMountedView.h" - -static char const kLayoutWrapperKey = ' '; - -static CK::Optional findFlexboxLayoutParams( - id parent, - id child) { - if ([parent isKindOfClass:[CKFlexboxComponent class]]) { - static Ivar ivar = - class_getInstanceVariable([CKFlexboxComponent class], "_children"); - static ptrdiff_t offset = ivar_getOffset(ivar); - - unsigned char* pComponent = (unsigned char*)(__bridge void*)parent; - auto children = - (std::vector*)(pComponent + offset); - - if (children) { - for (auto it = children->begin(); it != children->end(); it++) { - if (it->component == child) { - return *it; - } - } - } - } - - return CK::none; -} - -@implementation SKComponentLayoutWrapper - -+ (instancetype)newFromRoot:(id)root - parentKey:(NSString*)parentKey { - const auto layout = [root mountedLayout]; - // Check if there is a cached wrapper. - if (layout.component) { - SKComponentLayoutWrapper* cachedWrapper = - objc_getAssociatedObject(layout.component, &kLayoutWrapperKey); - if (cachedWrapper) { - return cachedWrapper; - } - } - // TODO: Add support for `CKMountable` components. - CKComponent* component = (CKComponent*)layout.component; - CKComponentReuseWrapper* reuseWrapper = - CKAnalyticsListenerHelpers::GetReusedNodes(component); - // Create a new layout wrapper. - SKComponentLayoutWrapper* const wrapper = [[SKComponentLayoutWrapper alloc] - initWithLayout:layout - position:CGPointMake(0, 0) - flexboxChild:CK::none - parentKey:[NSString - stringWithFormat:@"%@%d.", - parentKey, - component.treeNode.nodeIdentifier] - reuseWrapper:reuseWrapper - rootNode:root]; - // Cache the result. - if (component) { - objc_setAssociatedObject( - component, - &kLayoutWrapperKey, - wrapper, - OBJC_ASSOCIATION_RETAIN_NONATOMIC); - } - return wrapper; -} - -- (instancetype)initWithLayout:(const CKComponentLayout&)layout - position:(CGPoint)position - flexboxChild: - (CK::Optional)flexboxChild - parentKey:(NSString*)parentKey - reuseWrapper:(CKComponentReuseWrapper*)reuseWrapper - rootNode:(id)node { - if (self = [super init]) { - _rootNode = node; - _component = (CKComponent*)layout.component; - _size = layout.size; - _position = position; - _flexboxChild = flexboxChild; - _identifier = [parentKey stringByAppendingString:layout.component - ? layout.component.className - : @"(null)"]; - - if (_component && reuseWrapper) { - auto const canBeReusedCounter = - [reuseWrapper canBeReusedCounter:_component.treeNode.nodeIdentifier]; - if (canBeReusedCounter > 0) { - _component.flipper_canBeReusedCounter = canBeReusedCounter; - } - } - - std::vector childComponents; - if (layout.children != nullptr) { - int index = 0; - for (const auto& child : *layout.children) { - if (child.layout.component == nil) { - continue; // nil children are allowed, ignore them - } - SKComponentLayoutWrapper* childWrapper = - [[SKComponentLayoutWrapper alloc] - initWithLayout:child.layout - position:child.position - flexboxChild:findFlexboxLayoutParams( - _component, child.layout.component) - parentKey:[_identifier - stringByAppendingFormat:@"[%d].", index++] - reuseWrapper:reuseWrapper - rootNode:node]; - childComponents.push_back(childWrapper); - } - } - - UIView* mountedView = _component.mountedView; - if (mountedView && !childComponents.empty()) { - _children = SKMountedViewChild{[[SKComponentMountedView alloc] - initWithView:mountedView - children:childComponents]}; - } else if (mountedView) { - _children = SKLeafViewChild{mountedView}; // leaf view - } else { - _children = childComponents; - } - } - - return self; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.h deleted file mode 100644 index 0ae012986fa..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ - -#import - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class SKComponentLayoutWrapper; - -/** - Represents a non-leaf view created by ComponentKit. Its corresponding - descriptor CKComponentMountedViewDescriptor delegates to the view's descriptor - for attributes and most other behaviors, but redirects back into ComponentKit's - SKComponentLayoutWrapper when queried for children. - - In this way, non-leaf views created by ComponentKit appear in the Flipper - layout hierarchy as the child of the component that created their view. - */ -@interface SKComponentMountedView : NSObject - -- (instancetype)initWithView:(UIView*)view - children:(std::vector)children; - -@property(nonatomic, readonly) UIView* view; -@property(nonatomic, readonly) std::vector children; - -@end - -NS_ASSUME_NONNULL_END diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.mm deleted file mode 100644 index df19fd509a8..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedView.mm +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "SKComponentMountedView.h" - -@implementation SKComponentMountedView - -- (instancetype)initWithView:(UIView*)view - children:(std::vector)children { - if (self = [super init]) { - _view = view; - _children = std::move(children); - } - return self; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.h deleted file mode 100644 index 7e05c3715bb..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - */ - -#import - -@class SKComponentMountedView; - -@interface SKComponentMountedViewDescriptor - : SKNodeDescriptor - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.mm deleted file mode 100644 index 437a9352440..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentMountedViewDescriptor.mm +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "SKComponentMountedViewDescriptor.h" - -#import -#import - -#import -#import -#import - -#import "CKComponent+Sonar.h" -#import "SKComponentLayoutWrapper.h" -#import "SKComponentMountedView.h" -#import "Utils.h" - -@implementation SKComponentMountedViewDescriptor - -- (SKNodeDescriptor*)_viewDescriptorFor:(SKComponentMountedView*)node { - // For most methods, we delegate to the descriptor for the underlying view. - return [self descriptorForClass:[node.view class]]; -} - -- (NSString*)identifierForNode:(SKComponentMountedView*)node { - return [[self _viewDescriptorFor:node] identifierForNode:node.view]; -} - -- (NSString*)nameForNode:(SKComponentMountedView*)node { - return [[self _viewDescriptorFor:node] nameForNode:node.view]; -} - -- (NSUInteger)childCountForNode:(SKComponentMountedView*)node { - // An obvious future improvement: we should also return any - // non-ComponentKit-managed child views of our view. - // Explicit nil check; -children will return garbage if invoked on nil - return node ? node.children.size() : 0; -} - -- (id)childForNode:(SKComponentMountedView*)node atIndex:(NSUInteger)index { - // Explicit nil check; -children will return garbage if invoked on nil - return node ? node.children[index] : nil; -} - -- (NSArray*>*>*)dataForNode: - (SKComponentMountedView*)node { - return [[self _viewDescriptorFor:node] dataForNode:node.view]; -} - -- (NSDictionary*)dataMutationsForNode: - (SKComponentMountedView*)node { - return [[self _viewDescriptorFor:node] dataMutationsForNode:node.view]; -} - -- (NSArray*>*)attributesForNode: - (SKComponentMountedView*)node { - return [[self _viewDescriptorFor:node] attributesForNode:node.view]; -} - -- (void)setHighlighted:(BOOL)highlighted forNode:(SKComponentMountedView*)node { - [[self _viewDescriptorFor:node] setHighlighted:highlighted forNode:node.view]; -} - -- (void)hitTest:(SKTouch*)touch forNode:(SKComponentMountedView*)node { - if (!node) { - return; // -children will return garbage if invoked on nil - } - const auto& children = node.children; - bool finish = true; - for (auto it = children.rbegin(); it != children.rend(); ++it) { - SKComponentLayoutWrapper* child = *it; - CGRect frame = {.origin = child.position, .size = child.size}; - if ([touch containedIn:frame]) { - NSUInteger index = std::distance(children.begin(), it.base()) - 1; - [touch continueWithChildIndex:index withOffset:child.position]; - finish = false; - } - } - if (finish) { - [touch finish]; - } -} - -- (BOOL)matchesQuery:(NSString*)query forNode:(SKComponentMountedView*)node { - return [[self _viewDescriptorFor:node] matchesQuery:query forNode:node.view]; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.h deleted file mode 100644 index 05f2cc653b5..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - */ - -#import - -@class CKComponentRootView; - -@interface SKComponentRootViewDescriptor - : SKNodeDescriptor - -@end diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.mm deleted file mode 100644 index ca380bdabea..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentRootViewDescriptor.mm +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#import "SKComponentRootViewDescriptor.h" - -#import -#import -#import -#import -#import -#import - -#import -#import - -#import "SKComponentLayoutWrapper.h" - -@implementation SKComponentRootViewDescriptor - -- (NSString*)identifierForNode:(CKComponentRootView*)node { - return [NSString stringWithFormat:@"%p", node]; -} - -- (NSUInteger)childCountForNode:(CKComponentRootView*)node { - const auto state = CKGetAttachStateForView(node); - return state == nil ? 0 : 1; -} - -- (id)childForNode:(CKComponentRootView*)node atIndex:(NSUInteger)index { - return [SKComponentLayoutWrapper - newFromRoot:node - parentKey:[NSString stringWithFormat:@"%@.", node.uniqueIdentifier]]; -} - -- (NSArray*>*)dataForNode:(CKComponentRootView*)node { - auto const attachState = CKGetAttachStateForView(node); - return @[ [SKNamed - newWithName:@"Identity" - withValue:@{ - @"scopeRootIdentifier" : SKObject{@(attachState.scopeIdentifier)} - }] ]; -} - -- (void)setHighlighted:(BOOL)highlighted forNode:(CKComponentRootView*)node { - SKNodeDescriptor* viewDescriptor = [self descriptorForClass:[UIView class]]; - [viewDescriptor setHighlighted:highlighted forNode:node]; -} - -- (void)hitTest:(SKTouch*)touch forNode:(CKComponentRootView*)node { - [touch continueWithChildIndex:0 withOffset:(CGPoint){0, 0}]; -} - -@end - -#endif diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h deleted file mode 100644 index 3dc4e2cb490..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKSubDescriptor.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -#import - -@class SKComponentLayoutWrapper; - -/** - A SKSubDescriptor is a function which knows how to expose additional data - to SKLayoutDescriptor. This class is for frameworks wanting to pass data - along through the Layout Descriptor. - - The infra expects that the string returned is a JSON string. - For example: @"{\'key\': 5}" - */ -typedef NSString* (*SKSubDescriptor)(SKComponentLayoutWrapper* node); diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.h deleted file mode 100644 index cfa5ab22276..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - -#import -#import - -NSString* relativeDimension(CKRelativeDimension dimension); -NSDictionary* flexboxRect(CKFlexboxSpacing spacing); -CKRelativeDimension relativeStructDimension(NSString* dimension); -NSDictionary* ckcomponentSize(CKComponentSize size); diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.mm deleted file mode 100644 index 57f86ba1314..00000000000 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/Utils.mm +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -#ifdef FB_SONARKIT_ENABLED - -#include "Utils.h" - -NSString* relativeDimension(CKRelativeDimension dimension) { - switch (dimension.type()) { - case CKRelativeDimension::Type::PERCENT: - return [NSString stringWithFormat:@"%@%%", @(dimension.value())]; - case CKRelativeDimension::Type::POINTS: - return [NSString stringWithFormat:@"%@pt", @(dimension.value())]; - default: - return @"auto"; - } -} - -CKRelativeDimension relativeStructDimension(NSString* dimension) { - if ([dimension hasSuffix:@"%"]) { - return CKRelativeDimension::Percent( - [[dimension substringToIndex:([dimension length] - 1)] integerValue]); - } - if ([dimension hasSuffix:@"pt"]) { - return CKRelativeDimension::Points( - [[dimension substringToIndex:([dimension length] - 2)] integerValue]); - } - return CKRelativeDimension::Auto(); -} - -NSDictionary* flexboxRect(CKFlexboxSpacing spacing) { - return @{ - @"top" : relativeDimension(spacing.top.dimension()), - @"bottom" : relativeDimension(spacing.bottom.dimension()), - @"start" : relativeDimension(spacing.start.dimension()), - @"end" : relativeDimension(spacing.end.dimension()) - }; -} - -NSDictionary* ckcomponentSize(CKComponentSize size) { - return @{ - @"width" : relativeDimension(size.width), - @"height" : relativeDimension(size.height), - @"minWidth" : relativeDimension(size.minWidth), - @"minHeight" : relativeDimension(size.minHeight), - @"maxWidth" : relativeDimension(size.maxWidth), - @"maxHeight" : relativeDimension(size.maxHeight), - }; -} - -#endif