* Copyright (c) 2025 Huawei Technologies Co., Ltd.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import mustache from 'mustache';
const TEMPLATE = `
/**
* This code was generated by "react-native codegen-harmony"
*
* Do not edit this file as changes may cause incorrect behavior and will be
* lost once the code is regenerated.
*
* @generatorVersion: 1
*/
#pragma once
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/components/view/ViewShadowNode.h>
namespace facebook {
namespace react {
// RNOH patch
constexpr char {{name}}ComponentName[] = "{{name}}";
class {{name}}Props : public ViewProps {
public:
{{name}}Props() = default;
{{name}}Props(const PropsParserContext &context, const {{name}}Props &sourceProps, const RawProps &rawProps)
: ViewProps(context, sourceProps, rawProps) {}
};
using {{name}}ShadowNode = ConcreteViewShadowNode<
{{name}}ComponentName,
{{name}}Props,
ViewEventEmitter>;
class {{name}}ComponentDescriptor final
: public ConcreteComponentDescriptor<{{name}}ShadowNode> {
public:
{{name}}ComponentDescriptor(ComponentDescriptorParameters const ¶meters)
: ConcreteComponentDescriptor(parameters) {}
};
} // namespace react
} // namespace facebook
`;
export class ComponentDescriptorHTemplate {
constructor(private name: string) {}
build(): string {
return mustache.render(TEMPLATE, {
name: this.name,
});
}
}