Create types for player & view

This commit is contained in:
2026-04-09 12:52:54 +02:00
parent c71c8fb8f9
commit e1e2fa3f3b
70 changed files with 3499 additions and 369 deletions
@@ -1,83 +0,0 @@
///
/// HybridOmniComponent.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#include "HybridOmniComponent.hpp"
#include <string>
#include <exception>
#include <utility>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/JSIConverter.hpp>
#include <NitroModules/PropNameIDCache.hpp>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/core/ShadowNode.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/components/view/ViewProps.h>
namespace margelo::nitro::omni::views {
extern const char HybridOmniComponentName[] = "Omni";
HybridOmniProps::HybridOmniProps(const react::PropsParserContext& context,
const HybridOmniProps& sourceProps,
const react::RawProps& rawProps):
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
isRed([&]() -> CachedProp<bool> {
try {
const react::RawValue* rawValue = rawProps.at("isRed", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.isRed;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.isRed);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("Omni.isRed: ") + exc.what());
}
}()),
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniSpec>& /* ref */)>>> {
try {
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.hybridRef;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("Omni.hybridRef: ") + exc.what());
}
}()) { }
bool HybridOmniProps::filterObjectKeys(const std::string& propName) {
switch (hashString(propName)) {
case hashString("isRed"): return true;
case hashString("hybridRef"): return true;
default: return false;
}
}
HybridOmniComponentDescriptor::HybridOmniComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
: ConcreteComponentDescriptor(parameters,
react::RawPropsParser(/* enableJsiParser */ true)) {}
std::shared_ptr<const react::Props> HybridOmniComponentDescriptor::cloneProps(const react::PropsParserContext& context,
const std::shared_ptr<const react::Props>& props,
react::RawProps rawProps) const {
// 1. Prepare raw props parser
rawProps.parse(rawPropsParser_);
// 2. Copy props with Nitro's cached copy constructor
return HybridOmniShadowNode::Props(context, /* & */ rawProps, props);
}
#ifdef ANDROID
void HybridOmniComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
// This is called immediately after `ShadowNode` is created, cloned or in progress.
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
auto& concreteShadowNode = static_cast<HybridOmniShadowNode&>(shadowNode);
const std::shared_ptr<const HybridOmniProps>& constProps = concreteShadowNode.getConcreteSharedProps();
const std::shared_ptr<HybridOmniProps>& props = std::const_pointer_cast<HybridOmniProps>(constProps);
HybridOmniState state{props};
concreteShadowNode.setStateData(std::move(state));
}
#endif
} // namespace margelo::nitro::omni::views
@@ -1,110 +0,0 @@
///
/// HybridOmniComponent.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>
#include <memory>
#include "HybridOmniSpec.hpp"
#include <functional>
#include <optional>
namespace margelo::nitro::omni::views {
using namespace facebook;
/**
* The name of the actual native View.
*/
extern const char HybridOmniComponentName[];
/**
* Props for the "Omni" View.
*/
class HybridOmniProps final: public react::ViewProps {
public:
HybridOmniProps() = default;
HybridOmniProps(const react::PropsParserContext& context,
const HybridOmniProps& sourceProps,
const react::RawProps& rawProps);
public:
CachedProp<bool> isRed;
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniSpec>& /* ref */)>>> hybridRef;
private:
static bool filterObjectKeys(const std::string& propName);
};
/**
* State for the "Omni" View.
*/
class HybridOmniState final {
public:
HybridOmniState() = default;
explicit HybridOmniState(const std::shared_ptr<HybridOmniProps>& props):
_props(props) {}
public:
[[nodiscard]]
const std::shared_ptr<HybridOmniProps>& getProps() const {
return _props;
}
public:
#ifdef ANDROID
HybridOmniState(const HybridOmniState& /* previousState */, folly::dynamic /* data */) {}
folly::dynamic getDynamic() const {
throw std::runtime_error("HybridOmniState does not support folly!");
}
react::MapBuffer getMapBuffer() const {
throw std::runtime_error("HybridOmniState does not support MapBuffer!");
};
#endif
private:
std::shared_ptr<HybridOmniProps> _props;
};
/**
* The Shadow Node for the "Omni" View.
*/
using HybridOmniShadowNode = react::ConcreteViewShadowNode<HybridOmniComponentName /* "HybridOmni" */,
HybridOmniProps /* custom props */,
react::ViewEventEmitter /* default */,
HybridOmniState /* custom state */>;
/**
* The Component Descriptor for the "Omni" View.
*/
class HybridOmniComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridOmniShadowNode> {
public:
explicit HybridOmniComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
public:
/**
* A faster path for cloning props - reuses the caching logic from `HybridOmniProps`.
*/
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
const std::shared_ptr<const react::Props>& props,
react::RawProps rawProps) const override;
#ifdef ANDROID
void adopt(react::ShadowNode& shadowNode) const override;
#endif
};
/* The actual view for "Omni" needs to be implemented in platform-specific code. */
} // namespace margelo::nitro::omni::views
@@ -0,0 +1,105 @@
///
/// HybridOmniViewComponent.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#include "HybridOmniViewComponent.hpp"
#include <string>
#include <exception>
#include <utility>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/JSIConverter.hpp>
#include <NitroModules/PropNameIDCache.hpp>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/core/ShadowNode.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/components/view/ViewProps.h>
namespace margelo::nitro::omni::views {
extern const char HybridOmniViewComponentName[] = "OmniView";
HybridOmniViewProps::HybridOmniViewProps(const react::PropsParserContext& context,
const HybridOmniViewProps& sourceProps,
const react::RawProps& rawProps):
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
autoplay([&]() -> CachedProp<std::optional<bool>> {
try {
const react::RawValue* rawValue = rawProps.at("autoplay", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.autoplay;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.autoplay);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("OmniView.autoplay: ") + exc.what());
}
}()),
showNotification([&]() -> CachedProp<std::optional<bool>> {
try {
const react::RawValue* rawValue = rawProps.at("showNotification", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.showNotification;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.showNotification);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("OmniView.showNotification: ") + exc.what());
}
}()),
autoPip([&]() -> CachedProp<std::optional<bool>> {
try {
const react::RawValue* rawValue = rawProps.at("autoPip", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.autoPip;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.autoPip);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("OmniView.autoPip: ") + exc.what());
}
}()),
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniViewSpec>& /* ref */)>>> {
try {
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
if (rawValue == nullptr) return sourceProps.hybridRef;
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniViewSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
} catch (const std::exception& exc) {
throw std::runtime_error(std::string("OmniView.hybridRef: ") + exc.what());
}
}()) { }
bool HybridOmniViewProps::filterObjectKeys(const std::string& propName) {
switch (hashString(propName)) {
case hashString("autoplay"): return true;
case hashString("showNotification"): return true;
case hashString("autoPip"): return true;
case hashString("hybridRef"): return true;
default: return false;
}
}
HybridOmniViewComponentDescriptor::HybridOmniViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
: ConcreteComponentDescriptor(parameters,
react::RawPropsParser(/* enableJsiParser */ true)) {}
std::shared_ptr<const react::Props> HybridOmniViewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
const std::shared_ptr<const react::Props>& props,
react::RawProps rawProps) const {
// 1. Prepare raw props parser
rawProps.parse(rawPropsParser_);
// 2. Copy props with Nitro's cached copy constructor
return HybridOmniViewShadowNode::Props(context, /* & */ rawProps, props);
}
#ifdef ANDROID
void HybridOmniViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
// This is called immediately after `ShadowNode` is created, cloned or in progress.
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
auto& concreteShadowNode = static_cast<HybridOmniViewShadowNode&>(shadowNode);
const std::shared_ptr<const HybridOmniViewProps>& constProps = concreteShadowNode.getConcreteSharedProps();
const std::shared_ptr<HybridOmniViewProps>& props = std::const_pointer_cast<HybridOmniViewProps>(constProps);
HybridOmniViewState state{props};
concreteShadowNode.setStateData(std::move(state));
}
#endif
} // namespace margelo::nitro::omni::views
@@ -0,0 +1,112 @@
///
/// HybridOmniViewComponent.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>
#include <optional>
#include <memory>
#include "HybridOmniViewSpec.hpp"
#include <functional>
namespace margelo::nitro::omni::views {
using namespace facebook;
/**
* The name of the actual native View.
*/
extern const char HybridOmniViewComponentName[];
/**
* Props for the "OmniView" View.
*/
class HybridOmniViewProps final: public react::ViewProps {
public:
HybridOmniViewProps() = default;
HybridOmniViewProps(const react::PropsParserContext& context,
const HybridOmniViewProps& sourceProps,
const react::RawProps& rawProps);
public:
CachedProp<std::optional<bool>> autoplay;
CachedProp<std::optional<bool>> showNotification;
CachedProp<std::optional<bool>> autoPip;
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridOmniViewSpec>& /* ref */)>>> hybridRef;
private:
static bool filterObjectKeys(const std::string& propName);
};
/**
* State for the "OmniView" View.
*/
class HybridOmniViewState final {
public:
HybridOmniViewState() = default;
explicit HybridOmniViewState(const std::shared_ptr<HybridOmniViewProps>& props):
_props(props) {}
public:
[[nodiscard]]
const std::shared_ptr<HybridOmniViewProps>& getProps() const {
return _props;
}
public:
#ifdef ANDROID
HybridOmniViewState(const HybridOmniViewState& /* previousState */, folly::dynamic /* data */) {}
folly::dynamic getDynamic() const {
throw std::runtime_error("HybridOmniViewState does not support folly!");
}
react::MapBuffer getMapBuffer() const {
throw std::runtime_error("HybridOmniViewState does not support MapBuffer!");
};
#endif
private:
std::shared_ptr<HybridOmniViewProps> _props;
};
/**
* The Shadow Node for the "OmniView" View.
*/
using HybridOmniViewShadowNode = react::ConcreteViewShadowNode<HybridOmniViewComponentName /* "HybridOmniView" */,
HybridOmniViewProps /* custom props */,
react::ViewEventEmitter /* default */,
HybridOmniViewState /* custom state */>;
/**
* The Component Descriptor for the "OmniView" View.
*/
class HybridOmniViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridOmniViewShadowNode> {
public:
explicit HybridOmniViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
public:
/**
* A faster path for cloning props - reuses the caching logic from `HybridOmniViewProps`.
*/
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
const std::shared_ptr<const react::Props>& props,
react::RawProps rawProps) const override;
#ifdef ANDROID
void adopt(react::ShadowNode& shadowNode) const override;
#endif
};
/* The actual view for "OmniView" needs to be implemented in platform-specific code. */
} // namespace margelo::nitro::omni::views