mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 15:18:10 +00:00
Summary: We are moving to more stable APIs removing all mentiones of the effort name from the codebase. Reviewed By: mdvacca Differential Revision: D12912894 fbshipit-source-id: 4a0c6b9e7454b8b14e62d419e9e9311dc0c56e7a
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
/**
|
|
* 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 <memory>
|
|
|
|
#include <folly/dynamic.h>
|
|
|
|
#include <react/core/ShadowNode.h>
|
|
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
|
#include <react/uimanager/UIManagerDelegate.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
// Temporary NativeModuleRegistry definition
|
|
using NativeModuleCallFn =
|
|
std::function<folly::dynamic(const std::string &, const folly::dynamic &)>;
|
|
|
|
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<std::string, NativeModuleCallFn> modules_;
|
|
};
|
|
|
|
class UITemplateProcessor {
|
|
public:
|
|
static SharedShadowNode buildShadowTree(
|
|
const std::string &jsonStr,
|
|
int rootTag,
|
|
const folly::dynamic ¶ms,
|
|
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
|
const NativeModuleRegistry &nativeModuleRegistry);
|
|
|
|
private:
|
|
static SharedShadowNode runCommand(
|
|
const folly::dynamic &command,
|
|
Tag rootTag,
|
|
std::vector<SharedShadowNode> &nodes,
|
|
std::vector<folly::dynamic> ®isters,
|
|
const ComponentDescriptorRegistry &componentDescriptorRegistry,
|
|
const NativeModuleRegistry &nativeModuleRegistry);
|
|
};
|
|
} // namespace react
|
|
} // namespace facebook
|