/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include #include #include namespace facebook { namespace react { // Temporary NativeModuleRegistry definition using NativeModuleCallFn = std::function; class NativeModuleRegistry { public: void registerModule( const std::string &moduleName, NativeModuleCallFn callFn) { modules_.emplace(moduleName, callFn); } folly::dynamic call( const std::string &moduleName, const std::string &methodName, const folly::dynamic &args) const { return modules_.at(moduleName)(methodName, args); } private: std::unordered_map modules_; }; class UITemplateProcessor { public: static ShadowNode::Shared buildShadowTree( const std::string &jsonStr, int rootTag, const folly::dynamic ¶ms, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, const std::shared_ptr reactNativeConfig); private: static ShadowNode::Shared runCommand( const folly::dynamic &command, Tag rootTag, std::vector &nodes, std::vector ®isters, const ComponentDescriptorRegistry &componentDescriptorRegistry, const NativeModuleRegistry &nativeModuleRegistry, const std::shared_ptr reactNativeConfig); }; } // namespace react } // namespace facebook