From a9bc741a3341f0aef401587f8a68df7c74cf9dea Mon Sep 17 00:00:00 2001 From: luomy Date: Wed, 5 Jan 2022 19:47:10 +0800 Subject: [PATCH] feat(ios): add interface and demo to third party (#1377) * feat(ios): add interface and demo to third party * feat(ios): use test mock data for demo --- .../HippyDemo.xcodeproj/project.pbxproj | 12 ++- .../{ViewController.m => ViewController.mm} | 97 +++++++++++++++++-- ios/sdk/base/HippyBatchedBridge.mm | 32 +++--- ios/sdk/base/HippyBridge.h | 2 + ios/sdk/base/HippyBridge.mm | 12 +++ ios/sdk/base/HippyRootView.h | 2 + ios/sdk/base/HippyRootView.mm | 16 ++- ios/sdk/module/dev/HippyDevLoadingView.m | 3 + ios/sdk/utils/HippyDomNodeUtils.h | 2 + ios/sdk/utils/HippyDomNodeUtils.mm | 61 ++++++++++++ 10 files changed, 209 insertions(+), 30 deletions(-) rename framework/js/examples/ios-demo/HippyDemo/{ViewController.m => ViewController.mm} (55%) diff --git a/framework/js/examples/ios-demo/HippyDemo.xcodeproj/project.pbxproj b/framework/js/examples/ios-demo/HippyDemo.xcodeproj/project.pbxproj index f4fa0aa5e..a7297cab1 100644 --- a/framework/js/examples/ios-demo/HippyDemo.xcodeproj/project.pbxproj +++ b/framework/js/examples/ios-demo/HippyDemo.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ 06082A7B24AB222000AF85BC /* HippyFooterRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = 06082A7424AB222000AF85BC /* HippyFooterRefresh.m */; }; 060F6F6D25F1DE0C0038F8F9 /* HippyVirtualList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 060F6F6B25F1DE0C0038F8F9 /* HippyVirtualList.mm */; }; 0612F02323A8BE320079E622 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0612F02223A8BE320079E622 /* AppDelegate.m */; }; - 0612F02923A8BE320079E622 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0612F02823A8BE320079E622 /* ViewController.m */; }; + 0612F02923A8BE320079E622 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0612F02823A8BE320079E622 /* ViewController.mm */; }; 0612F03423A8BE330079E622 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0612F03323A8BE330079E622 /* main.m */; }; 0640D25824AC75DD00F122A0 /* UIView+AppearEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 0640D25724AC75DD00F122A0 /* UIView+AppearEvent.m */; }; 0649F42725A5ADE900E8F485 /* HippyBaseListViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0649F42625A5ADE900E8F485 /* HippyBaseListViewCell.mm */; }; @@ -189,6 +189,7 @@ F417B5532727B31200894090 /* HippyDevCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F417B5522727B31200894090 /* HippyDevCommand.m */; }; F419C383274634E9003E242A /* taitank_layout_node.cc in Sources */ = {isa = PBXBuildFile; fileRef = F419C382274634E9003E242A /* taitank_layout_node.cc */; }; F419C38A27464047003E242A /* NativeRenderManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = F419C38927464047003E242A /* NativeRenderManager.mm */; }; + F41E3F6127859AB600BD3935 /* create_node.json in Resources */ = {isa = PBXBuildFile; fileRef = F41E3F6027859AB600BD3935 /* create_node.json */; }; F42EA79A277C354C007874A2 /* TurboConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = F42EA796277C354C007874A2 /* TurboConfig.m */; }; F42EA79B277C354C007874A2 /* TurboBaseModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = F42EA799277C354C007874A2 /* TurboBaseModule.mm */; }; F43640BC275DE608007E1301 /* HippyBaseListShadowView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F43640BB275DE608007E1301 /* HippyBaseListShadowView.mm */; }; @@ -233,7 +234,7 @@ 0612F02123A8BE320079E622 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 0612F02223A8BE320079E622 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 0612F02723A8BE320079E622 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 0612F02823A8BE320079E622 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 0612F02823A8BE320079E622 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = ""; }; 0612F03223A8BE330079E622 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 0612F03323A8BE330079E622 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 0640D25624AC75DD00F122A0 /* UIView+AppearEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+AppearEvent.h"; sourceTree = ""; }; @@ -621,6 +622,7 @@ F419C382274634E9003E242A /* taitank_layout_node.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = taitank_layout_node.cc; sourceTree = ""; }; F419C38927464047003E242A /* NativeRenderManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeRenderManager.mm; sourceTree = ""; }; F419C38B27464061003E242A /* NativeRenderManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeRenderManager.h; sourceTree = ""; }; + F41E3F6027859AB600BD3935 /* create_node.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = create_node.json; path = ../../../../../dom/test/create_node.json; sourceTree = ""; }; F42EA796277C354C007874A2 /* TurboConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TurboConfig.m; sourceTree = ""; }; F42EA797277C354C007874A2 /* TurboConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TurboConfig.h; sourceTree = ""; }; F42EA798277C354C007874A2 /* TurboBaseModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TurboBaseModule.h; sourceTree = ""; }; @@ -743,6 +745,7 @@ 0612F02023A8BE320079E622 /* HippyDemo */ = { isa = PBXGroup; children = ( + F41E3F6027859AB600BD3935 /* create_node.json */, F42EA795277C354C007874A2 /* turbomodule */, 067AB97023B5F309009D5EE2 /* myview */, 067AB96E23B5EEF3009D5EE2 /* TestModule.h */, @@ -750,7 +753,7 @@ 0612F02123A8BE320079E622 /* AppDelegate.h */, 0612F02223A8BE320079E622 /* AppDelegate.m */, 0612F02723A8BE320079E622 /* ViewController.h */, - 0612F02823A8BE320079E622 /* ViewController.m */, + 0612F02823A8BE320079E622 /* ViewController.mm */, 0612F03223A8BE330079E622 /* Info.plist */, 0612F03323A8BE330079E622 /* main.m */, ); @@ -1811,6 +1814,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + F41E3F6127859AB600BD3935 /* create_node.json in Resources */, AC63515623F92C99007FABA5 /* TTTGB-Medium.otf in Resources */, 064C5AF023AB1A70001E80DD /* res in Resources */, ); @@ -1839,7 +1843,7 @@ 064C5A4923AB1A51001E80DD /* HippyEventDispatcher.mm in Sources */, F400C2E1274F41EC008BD74B /* ios_loader.cc in Sources */, 064C5A0123AB1A51001E80DD /* HippyExceptionModule.m in Sources */, - 0612F02923A8BE320079E622 /* ViewController.m in Sources */, + 0612F02923A8BE320079E622 /* ViewController.mm in Sources */, 0612F02323A8BE320079E622 /* AppDelegate.m in Sources */, 064C5A5123AB1A51001E80DD /* HippyJSCWrapper.mm in Sources */, 064C5A3A23AB1A51001E80DD /* HippyParserUtils.m in Sources */, diff --git a/framework/js/examples/ios-demo/HippyDemo/ViewController.m b/framework/js/examples/ios-demo/HippyDemo/ViewController.mm similarity index 55% rename from framework/js/examples/ios-demo/HippyDemo/ViewController.m rename to framework/js/examples/ios-demo/HippyDemo/ViewController.mm index ed6d44b2d..a6dc3ed60 100644 --- a/framework/js/examples/ios-demo/HippyDemo/ViewController.m +++ b/framework/js/examples/ios-demo/HippyDemo/ViewController.mm @@ -25,7 +25,15 @@ #import "HippyLog.h" #import "HippyBundleURLProvider.h" -@interface ViewController () +#include "dom/dom_manager.h" +#include "NativeRenderManager.h" +#include "dom/dom_node.h" +#include "dom/dom_value.h" + +@interface ViewController () { + std::shared_ptr _domManager; + std::shared_ptr _nativeRenderManager; +} @end @@ -38,14 +46,15 @@ HippySetLogFunction(^(HippyLogLevel level, HippyLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { NSLog(@"hippy says:%@ in file %@ at line %@", message, fileName, lineNumber); }); + [self runCommonDemo]; +// [self runDemoWithoutRuntime]; +} - +- (void)runCommonDemo { BOOL isSimulator = NO; #if TARGET_IPHONE_SIMULATOR isSimulator = YES; #endif - - //release macro below if use debug mode //#define HIPPYDEBUG @@ -71,17 +80,85 @@ executorKey:@"Demo"]; HippyRootView *rootView = [[HippyRootView alloc] initWithBridge:bridge businessURL:[NSURL fileURLWithPath:businessBundlePath] moduleName:@"Demo" initialProperties: @{@"isSimulator": @(isSimulator)} launchOptions:nil shareOptions:nil debugMode:NO delegate:nil]; #endif - - - -// HippyBridge *bridge = [[HippyBridge alloc] initWithDelegate:self bundleURL:[NSURL URLWithString:@"http://localhost:38989/index.bundle?platform=ios&dev=true&minify=false"] moduleProvider:nil launchOptions:nil executorKey:@"Demo"]; -// HippyRootView *rootView = [[HippyRootView alloc] initWithBridge:bridge moduleName:@"Demo" initialProperties:nil shareOptions:nil delegate:nil];; + rootView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; + rootView.frame = self.view.bounds; + [self.view addSubview:rootView]; +} - +- (void)runDemoWithoutRuntime { + //step1: create HippyBridge and HippyRootView + HippyBridge *bridge = [[HippyBridge alloc] initWithmoduleProviderWithoutRuntime:nil]; + HippyRootView *rootView = [[HippyRootView alloc] initWithBridgeButNoRuntime:bridge]; + rootView.backgroundColor = [UIColor whiteColor]; rootView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; rootView.frame = self.view.bounds; [self.view addSubview:rootView]; + //step2: get HippyUIManager, then set DomManager for it. + //and set RenderManager for DomNanager + HippyUIManager *uiManager = [bridge moduleForName:@"UIManager"]; + int32_t rootTag = [rootView.hippyTag intValue]; + _domManager = std::make_shared(rootTag); + [uiManager setDomManager:_domManager]; + _domManager->SetRootSize(CGRectGetWidth(rootView.bounds), CGRectGetHeight(rootView.bounds)); + _nativeRenderManager = std::make_shared(uiManager); + _domManager->SetRenderManager(_nativeRenderManager); + + //step3:create your nodes data into dommanager + auto nodesData = [self mockNodesData]; + _domManager->CreateDomNodes(std::move(nodesData)); + _domManager->BeginBatch(); + _domManager->EndBatch(); +} + +- (std::vector>) mockNodesData { + std::vector> dom_node_vector; + using StyleMap = std::unordered_map>; + NSString *mockDataPath = [[NSBundle mainBundle] pathForResource:@"create_node" ofType:@"json"]; + NSData *mockData = [NSData dataWithContentsOfFile:mockDataPath]; + NSArray *> *mockJson = [NSJSONSerialization JSONObjectWithData:mockData options:(NSJSONReadingOptions)0 error:nil]; + for (NSDictionary *mockNode in mockJson) { + uint32_t tag = 0; + uint32_t pid = 0; + uint32_t index = 0; + StyleMap style_map; + StyleMap ext_map; + std::string name; + for (NSString *key in mockNode) { + if ([key isEqualToString:@"id"]) { + tag = [mockNode[@"id"] unsignedIntValue]; + } + else if ([key isEqualToString:@"pId"]) { + pid = [mockNode[@"pId"] unsignedIntValue]; + } + else if ([key isEqualToString:@"index"]) { + index = [mockNode[@"index"] unsignedIntValue]; + } + else if ([key isEqualToString:@"props"]) { + id props = mockNode[key]; + auto all_props = dictionaryToUnorderedMapDomValue(props); + auto style_props = all_props["style"]; + if (style_props) { + if (tdf::base::DomValue::Type::kObject == style_props->GetType()) { + auto style_object = style_props->ToObject(); + for (auto iter = style_object.begin(); iter != style_object.end(); iter++) { + const std::string &iter_key = iter->first; + auto &iter_value = iter->second; + style_map[iter_key] = std::make_shared(std::move(iter_value)); + } + } + all_props.erase("style"); + } + ext_map.swap(all_props); + } + else if ([key isEqualToString:@"name"]) { + name = [mockNode[key] UTF8String]; + } + } + std::shared_ptr dom_node = std::make_shared(tag, pid, index, name, name, std::move(style_map), std::move(ext_map), _domManager); + dom_node_vector.push_back(dom_node); + } + return dom_node_vector; } - (NSDictionary *)objectsBeforeExecuteCode { diff --git a/ios/sdk/base/HippyBatchedBridge.mm b/ios/sdk/base/HippyBatchedBridge.mm index 984b961b5..2e2c98c1b 100644 --- a/ios/sdk/base/HippyBatchedBridge.mm +++ b/ios/sdk/base/HippyBatchedBridge.mm @@ -143,22 +143,24 @@ HIPPY_NOT_IMPLEMENTED(-(instancetype)initWithDelegate dispatch_group_enter(initModulesAndLoadSource); __weak HippyBatchedBridge *weakSelf = self; __block NSData *sourceCode; - [self loadSource:^(NSError *error, NSData *source, __unused int64_t sourceLength) { - if (error) { - HippyLogWarn(@"Failed to load source: %@", error); - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf stopLoadingWithError:error]; - }); - } + if (self.bundleURL) { + [self loadSource:^(NSError *error, NSData *source, __unused int64_t sourceLength) { + if (error) { + HippyLogWarn(@"Failed to load source: %@", error); + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf stopLoadingWithError:error]; + }); + } - sourceCode = source; - dispatch_group_leave(initModulesAndLoadSource); - } onProgress:^(HippyLoadingProgress *progressData) { -#ifdef HIPPY_DEV - HippyDevLoadingView *loadingView = [weakSelf moduleForClass:[HippyDevLoadingView class]]; - [loadingView updateProgress:progressData]; -#endif - }]; + sourceCode = source; + dispatch_group_leave(initModulesAndLoadSource); + } onProgress:^(HippyLoadingProgress *progressData) { + #ifdef HIPPY_DEV + HippyDevLoadingView *loadingView = [weakSelf moduleForClass:[HippyDevLoadingView class]]; + [loadingView updateProgress:progressData]; + #endif + }]; + } // Synchronously initialize all native modules that cannot be loaded lazily [self initModulesWithDispatchGroup:initModulesAndLoadSource]; diff --git a/ios/sdk/base/HippyBridge.h b/ios/sdk/base/HippyBridge.h index 770883b5c..a8d093552 100644 --- a/ios/sdk/base/HippyBridge.h +++ b/ios/sdk/base/HippyBridge.h @@ -90,6 +90,8 @@ HIPPY_EXTERN NSString *HippyBridgeModuleNameForClass(Class bridgeModuleClass); */ @interface HippyBridge : NSObject +- (instancetype)initWithmoduleProviderWithoutRuntime:(HippyBridgeModuleProviderBlock)block; + - (instancetype)initWithDelegate:(id)delegate bundleURL:(NSURL *)bundleURL moduleProvider:(HippyBridgeModuleProviderBlock)block diff --git a/ios/sdk/base/HippyBridge.mm b/ios/sdk/base/HippyBridge.mm index 04e237be0..d0fa50ffa 100644 --- a/ios/sdk/base/HippyBridge.mm +++ b/ios/sdk/base/HippyBridge.mm @@ -207,6 +207,18 @@ static HippyBridge *HippyCurrentBridgeInstance = nil; return self; } +- (instancetype)initWithmoduleProviderWithoutRuntime:(HippyBridgeModuleProviderBlock)block { + self = [super init]; + if (self) { + _moduleProvider = block; + [self setUp]; + } + HippyExecuteOnMainQueue(^{ + [self bindKeys]; + }); + return self; +} + HIPPY_NOT_IMPLEMENTED(-(instancetype)init) - (void)dealloc { diff --git a/ios/sdk/base/HippyRootView.h b/ios/sdk/base/HippyRootView.h index 87e7fd569..37601a48a 100644 --- a/ios/sdk/base/HippyRootView.h +++ b/ios/sdk/base/HippyRootView.h @@ -85,6 +85,8 @@ extern NSString *const HippyContentDidAppearNotification; debugMode:(BOOL)mode delegate:(id)delegate; +- (instancetype)initWithBridgeButNoRuntime:(HippyBridge *)bridge; + /** * The name of the JavaScript module to execute within the * specified scriptURL (required). Setting this will not have diff --git a/ios/sdk/base/HippyRootView.mm b/ios/sdk/base/HippyRootView.mm index c65f47ab3..c281b29dc 100644 --- a/ios/sdk/base/HippyRootView.mm +++ b/ios/sdk/base/HippyRootView.mm @@ -192,7 +192,17 @@ NSString *const HippyContentDidAppearNotification = @"HippyContentDidAppearNotif } } -HIPPY_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) +- (instancetype)initWithBridgeButNoRuntime:(HippyBridge *)bridge { + self = [super init]; + if (self) { + self.bridge = bridge; + bridge.batchedBridge.useCommonBridge = YES; + [self bundleFinishedLoading:bridge.batchedBridge]; + } + return self; +} + +//HIPPY_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) HIPPY_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder) - (void)setBackgroundColor:(UIColor *)backgroundColor { @@ -200,6 +210,10 @@ HIPPY_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder) _contentView.backgroundColor = backgroundColor; } +- (void)setBridge:(HippyBridge *)bridge { + _bridge = bridge; +} + - (UIViewController *)hippyViewController { return _hippyViewController ?: [super hippyViewController]; } diff --git a/ios/sdk/module/dev/HippyDevLoadingView.m b/ios/sdk/module/dev/HippyDevLoadingView.m index 60f8b27e7..bdfe575e3 100644 --- a/ios/sdk/module/dev/HippyDevLoadingView.m +++ b/ios/sdk/module/dev/HippyDevLoadingView.m @@ -135,6 +135,9 @@ HIPPY_EXPORT_METHOD(hide) { UIColor *color; UIColor *backgroundColor; NSString *source; + if (!URL) { + return; + } if (URL.fileURL) { color = [UIColor grayColor]; backgroundColor = [UIColor blackColor]; diff --git a/ios/sdk/utils/HippyDomNodeUtils.h b/ios/sdk/utils/HippyDomNodeUtils.h index b73dd3a7c..b922a2cf8 100644 --- a/ios/sdk/utils/HippyDomNodeUtils.h +++ b/ios/sdk/utils/HippyDomNodeUtils.h @@ -32,6 +32,8 @@ HIPPY_EXTERN id domValueToOCType(const tdf::base::DomValue *const pDomValue); HIPPY_EXTERN NSDictionary *unorderedMapDomValueToDictionary(const std::unordered_map> &domValuesObject); +extern std::unordered_map> dictionaryToUnorderedMapDomValue(NSDictionary *dictionary); + HIPPY_EXTERN CGRect CGRectMakeFromLayoutResult(hippy::LayoutResult result); HIPPY_EXTERN UIEdgeInsets UIEdgeInsetsFromLayoutResult(hippy::LayoutResult result); diff --git a/ios/sdk/utils/HippyDomNodeUtils.mm b/ios/sdk/utils/HippyDomNodeUtils.mm index b4defd30a..68da8fc62 100644 --- a/ios/sdk/utils/HippyDomNodeUtils.mm +++ b/ios/sdk/utils/HippyDomNodeUtils.mm @@ -70,6 +70,56 @@ id domValueToOCType(const DomValue *const pDomValue) { return value; } +DomValue OCTypeToDomValue(id value) { + if ([value isKindOfClass:[NSString class]]) { + return DomValue([value UTF8String]); + } + else if ([value isKindOfClass:[NSNumber class]]) { + CFNumberRef numberRef = (__bridge CFNumberRef)value; + CFNumberType numberType = CFNumberGetType(numberRef); + if (kCFNumberSInt32Type == numberType || + kCFNumberSInt64Type == numberType || + kCFNumberShortType == numberType || + kCFNumberIntType == numberType || + kCFNumberLongType == numberType || + kCFNumberLongLongType == numberType) { + return DomValue([value unsignedIntValue]); + } + else if (kCFNumberFloatType == numberType || + kCFNumberDoubleType == numberType) { + return DomValue([value doubleValue]); + } + else { + BOOL flag = [value boolValue]; + return DomValue(flag);; + } + } + else if (value == [NSNull null]) { + return DomValue::Null(); + } + else if ([value isKindOfClass:[NSDictionary class]]) { + DomValue::DomValueObjectType object; + for (NSString *key in value) { + std::string objKey = [key UTF8String]; + id objValue = [value objectForKey:key]; + auto dom_obj = OCTypeToDomValue(objValue); + object[objKey] = std::move(dom_obj); + } + return DomValue(std::move(object)); + } + else if ([value isKindOfClass:[NSArray class]]) { + DomValue::DomValueArrayType array; + for (id obj in value) { + auto dom_obj = OCTypeToDomValue(obj); + array.push_back(std::move(dom_obj)); + } + return DomValue(std::move(array)); + } + else { + return DomValue::Undefined(); + } +} + NSDictionary *unorderedMapDomValueToDictionary(const std::unordered_map> &domValuesObject) { NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:domValuesObject.size()]; for (auto it = domValuesObject.begin(); it != domValuesObject.end(); it++) { @@ -81,6 +131,17 @@ NSDictionary *unorderedMapDomValueToDictionary(const std::unordered_map> dictionaryToUnorderedMapDomValue(NSDictionary *dictionary) { + std::unordered_map> style; + for (NSString *key in dictionary) { + id value = dictionary[key]; + std::string style_key = [key UTF8String]; + tdf::base::DomValue dom_value = OCTypeToDomValue(value); + style[style_key] = std::make_shared(std::move(dom_value)); + } + return style; +} + CGRect CGRectMakeFromLayoutResult(hippy::LayoutResult result) { return CGRectMake(result.left, result.top, result.width, result.height); }