/// /// 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 #include #include #include #include #include #include #include #include #include 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), player([&]() -> CachedProp> { try { const react::RawValue* rawValue = rawProps.at("player", nullptr, nullptr); if (rawValue == nullptr) return sourceProps.player; const auto& [runtime, value] = (std::pair)*rawValue; return CachedProp>::fromRawValue(*runtime, value, sourceProps.player); } catch (const std::exception& exc) { throw std::runtime_error(std::string("OmniView.player: ") + exc.what()); } }()), autoplay([&]() -> CachedProp> { try { const react::RawValue* rawValue = rawProps.at("autoplay", nullptr, nullptr); if (rawValue == nullptr) return sourceProps.autoplay; const auto& [runtime, value] = (std::pair)*rawValue; return CachedProp>::fromRawValue(*runtime, value, sourceProps.autoplay); } catch (const std::exception& exc) { throw std::runtime_error(std::string("OmniView.autoplay: ") + exc.what()); } }()), autoPip([&]() -> CachedProp> { try { const react::RawValue* rawValue = rawProps.at("autoPip", nullptr, nullptr); if (rawValue == nullptr) return sourceProps.autoPip; const auto& [runtime, value] = (std::pair)*rawValue; return CachedProp>::fromRawValue(*runtime, value, sourceProps.autoPip); } catch (const std::exception& exc) { throw std::runtime_error(std::string("OmniView.autoPip: ") + exc.what()); } }()), subtitleAssets([&]() -> CachedProp> { try { const react::RawValue* rawValue = rawProps.at("subtitleAssets", nullptr, nullptr); if (rawValue == nullptr) return sourceProps.subtitleAssets; const auto& [runtime, value] = (std::pair)*rawValue; return CachedProp>::fromRawValue(*runtime, value, sourceProps.subtitleAssets); } catch (const std::exception& exc) { throw std::runtime_error(std::string("OmniView.subtitleAssets: ") + exc.what()); } }()), hybridRef([&]() -> CachedProp& /* ref */)>>> { try { const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr); if (rawValue == nullptr) return sourceProps.hybridRef; const auto& [runtime, value] = (std::pair)*rawValue; return CachedProp& /* 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("player"): return true; case hashString("autoplay"): return true; case hashString("autoPip"): return true; case hashString("subtitleAssets"): return true; case hashString("hybridRef"): return true; default: return false; } } HybridOmniViewComponentDescriptor::HybridOmniViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters) : ConcreteComponentDescriptor(parameters, react::RawPropsParser()) {} std::shared_ptr HybridOmniViewComponentDescriptor::cloneProps(const react::PropsParserContext& context, const std::shared_ptr& 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(shadowNode); const std::shared_ptr& constProps = concreteShadowNode.getConcreteSharedProps(); const std::shared_ptr& props = std::const_pointer_cast(constProps); HybridOmniViewState state{props}; concreteShadowNode.setStateData(std::move(state)); } #endif } // namespace margelo::nitro::omni::views