From e1e2fa3f3b7735fdb0282744704b8d20c8bf5f89 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 8 Apr 2026 20:45:50 +0200 Subject: [PATCH] Create types for player & view --- biome.json | 5 +- nitro.json | 16 +- .../generated/android/Omni+autolinking.cmake | 15 +- nitrogen/generated/android/OmniOnLoad.cpp | 58 ++++- .../c++/JHybridOmniPlayerFactorySpec.cpp | 60 +++++ ...c.hpp => JHybridOmniPlayerFactorySpec.hpp} | 27 ++- .../c++/JHybridOmniPlayerPropsSpec.cpp | 147 ++++++++++++ .../c++/JHybridOmniPlayerPropsSpec.hpp | 72 ++++++ .../android/c++/JHybridOmniPlayerSpec.cpp | 213 ++++++++++++++++++ .../android/c++/JHybridOmniPlayerSpec.hpp | 86 +++++++ .../generated/android/c++/JHybridOmniSpec.cpp | 57 ----- .../android/c++/JHybridOmniViewSpec.cpp | 75 ++++++ .../android/c++/JHybridOmniViewSpec.hpp | 68 ++++++ nitrogen/generated/android/c++/JMetadata.hpp | 78 +++++++ .../generated/android/c++/JMixAudioMode.hpp | 64 ++++++ .../generated/android/c++/JPlayerStatus.hpp | 64 ++++++ nitrogen/generated/android/c++/JRendition.hpp | 73 ++++++ nitrogen/generated/android/c++/JSubtitle.hpp | 74 ++++++ nitrogen/generated/android/c++/JTrack.hpp | 70 ++++++ .../c++/JVariant_NullType_Rendition.cpp | 26 +++ .../c++/JVariant_NullType_Rendition.hpp | 72 ++++++ nitrogen/generated/android/c++/JVideoSrc.hpp | 80 +++++++ ...er.cpp => JHybridOmniViewStateUpdater.cpp} | 34 +-- ...er.hpp => JHybridOmniViewStateUpdater.hpp} | 16 +- .../nitro/omni/HybridOmniPlayerFactorySpec.kt | 54 +++++ .../nitro/omni/HybridOmniPlayerPropsSpec.kt | 80 +++++++ .../nitro/omni/HybridOmniPlayerSpec.kt | 143 ++++++++++++ ...ybridOmniSpec.kt => HybridOmniViewSpec.kt} | 30 ++- .../kotlin/com/margelo/nitro/omni/Metadata.kt | 53 +++++ .../com/margelo/nitro/omni/MixAudioMode.kt | 25 ++ .../com/margelo/nitro/omni/PlayerStatus.kt | 25 ++ .../com/margelo/nitro/omni/Rendition.kt | 50 ++++ .../kotlin/com/margelo/nitro/omni/Subtitle.kt | 50 ++++ .../kotlin/com/margelo/nitro/omni/Track.kt | 47 ++++ .../nitro/omni/Variant_NullType_Rendition.kt | 53 +++++ .../kotlin/com/margelo/nitro/omni/VideoSrc.kt | 44 ++++ ...mniManager.kt => HybridOmniViewManager.kt} | 18 +- ...dater.kt => HybridOmniViewStateUpdater.kt} | 6 +- ...ec.cpp => HybridOmniPlayerFactorySpec.cpp} | 9 +- .../c++/HybridOmniPlayerFactorySpec.hpp | 67 ++++++ .../shared/c++/HybridOmniPlayerPropsSpec.cpp | 30 +++ .../shared/c++/HybridOmniPlayerPropsSpec.hpp | 83 +++++++ .../shared/c++/HybridOmniPlayerSpec.cpp | 45 ++++ .../shared/c++/HybridOmniPlayerSpec.hpp | 96 ++++++++ .../shared/c++/HybridOmniViewSpec.cpp | 26 +++ ...ridOmniSpec.hpp => HybridOmniViewSpec.hpp} | 28 ++- nitrogen/generated/shared/c++/Metadata.hpp | 104 +++++++++ .../generated/shared/c++/MixAudioMode.hpp | 84 +++++++ .../generated/shared/c++/PlayerStatus.hpp | 84 +++++++ nitrogen/generated/shared/c++/Rendition.hpp | 99 ++++++++ nitrogen/generated/shared/c++/Subtitle.hpp | 100 ++++++++ nitrogen/generated/shared/c++/Track.hpp | 96 ++++++++ nitrogen/generated/shared/c++/VideoSrc.hpp | 93 ++++++++ .../shared/c++/views/HybridOmniComponent.cpp | 83 ------- .../shared/c++/views/HybridOmniComponent.hpp | 110 --------- .../c++/views/HybridOmniViewComponent.cpp | 105 +++++++++ .../c++/views/HybridOmniViewComponent.hpp | 112 +++++++++ .../{OmniConfig.json => OmniViewConfig.json} | 6 +- package.json | 2 +- src/index.ts | 10 - src/provider.tsx | 25 ++ src/specs/omni-player.nitro.ts | 15 ++ src/specs/omni-view.nitro.ts | 14 ++ src/specs/omni.nitro.ts | 13 -- src/types/events.ts | 3 + src/types/player.ts | 46 ++++ src/types/provider.ts | 35 +++ src/types/view.ts | 5 + src/view.ts | 10 + tsconfig.json | 2 +- 70 files changed, 3499 insertions(+), 369 deletions(-) create mode 100644 nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.cpp rename nitrogen/generated/android/c++/{JHybridOmniSpec.hpp => JHybridOmniPlayerFactorySpec.hpp} (59%) create mode 100644 nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.cpp create mode 100644 nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.hpp create mode 100644 nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp create mode 100644 nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp delete mode 100644 nitrogen/generated/android/c++/JHybridOmniSpec.cpp create mode 100644 nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp create mode 100644 nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp create mode 100644 nitrogen/generated/android/c++/JMetadata.hpp create mode 100644 nitrogen/generated/android/c++/JMixAudioMode.hpp create mode 100644 nitrogen/generated/android/c++/JPlayerStatus.hpp create mode 100644 nitrogen/generated/android/c++/JRendition.hpp create mode 100644 nitrogen/generated/android/c++/JSubtitle.hpp create mode 100644 nitrogen/generated/android/c++/JTrack.hpp create mode 100644 nitrogen/generated/android/c++/JVariant_NullType_Rendition.cpp create mode 100644 nitrogen/generated/android/c++/JVariant_NullType_Rendition.hpp create mode 100644 nitrogen/generated/android/c++/JVideoSrc.hpp rename nitrogen/generated/android/c++/views/{JHybridOmniStateUpdater.cpp => JHybridOmniViewStateUpdater.cpp} (60%) rename nitrogen/generated/android/c++/views/{JHybridOmniStateUpdater.hpp => JHybridOmniViewStateUpdater.hpp} (74%) create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerFactorySpec.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerPropsSpec.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt rename nitrogen/generated/android/kotlin/com/margelo/nitro/omni/{HybridOmniSpec.kt => HybridOmniViewSpec.kt} (63%) create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/MixAudioMode.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PlayerStatus.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Variant_NullType_Rendition.kt create mode 100644 nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt rename nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/{HybridOmniManager.kt => HybridOmniViewManager.kt} (79%) rename nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/{HybridOmniStateUpdater.kt => HybridOmniViewStateUpdater.kt} (76%) rename nitrogen/generated/shared/c++/{HybridOmniSpec.cpp => HybridOmniPlayerFactorySpec.cpp} (62%) create mode 100644 nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.hpp create mode 100644 nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.cpp create mode 100644 nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.hpp create mode 100644 nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp create mode 100644 nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp create mode 100644 nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp rename nitrogen/generated/shared/c++/{HybridOmniSpec.hpp => HybridOmniViewSpec.hpp} (50%) create mode 100644 nitrogen/generated/shared/c++/Metadata.hpp create mode 100644 nitrogen/generated/shared/c++/MixAudioMode.hpp create mode 100644 nitrogen/generated/shared/c++/PlayerStatus.hpp create mode 100644 nitrogen/generated/shared/c++/Rendition.hpp create mode 100644 nitrogen/generated/shared/c++/Subtitle.hpp create mode 100644 nitrogen/generated/shared/c++/Track.hpp create mode 100644 nitrogen/generated/shared/c++/VideoSrc.hpp delete mode 100644 nitrogen/generated/shared/c++/views/HybridOmniComponent.cpp delete mode 100644 nitrogen/generated/shared/c++/views/HybridOmniComponent.hpp create mode 100644 nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp create mode 100644 nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp rename nitrogen/generated/shared/json/{OmniConfig.json => OmniViewConfig.json} (56%) delete mode 100755 src/index.ts create mode 100755 src/provider.tsx create mode 100644 src/specs/omni-player.nitro.ts create mode 100644 src/specs/omni-view.nitro.ts delete mode 100755 src/specs/omni.nitro.ts create mode 100644 src/types/events.ts create mode 100644 src/types/player.ts create mode 100644 src/types/provider.ts create mode 100644 src/types/view.ts create mode 100644 src/view.ts diff --git a/biome.json b/biome.json index 1e83385..a61bbaa 100644 --- a/biome.json +++ b/biome.json @@ -15,7 +15,10 @@ "linter": { "enabled": true, "rules": { - "recommended": true + "recommended": true, + "style": { + "noNonNullAssertion": "off" + } } }, "javascript": { diff --git a/nitro.json b/nitro.json index b443ef7..22eb761 100644 --- a/nitro.json +++ b/nitro.json @@ -9,10 +9,22 @@ "androidCxxLibName": "Omni" }, "autolinking": { - "Omni": { + "OmniView": { "android": { "language": "kotlin", - "implementationClassName": "HybridOmni" + "implementationClassName": "OmniView" + } + }, + "OmniPlayer": { + "android": { + "language": "kotlin", + "implementationClassName": "OmniPlayer" + } + }, + "OmniPlayerFactory": { + "android": { + "language": "kotlin", + "implementationClassName": "OmniPlayerFactory" } } }, diff --git a/nitrogen/generated/android/Omni+autolinking.cmake b/nitrogen/generated/android/Omni+autolinking.cmake index 2c14a69..392e1b8 100644 --- a/nitrogen/generated/android/Omni+autolinking.cmake +++ b/nitrogen/generated/android/Omni+autolinking.cmake @@ -33,11 +33,18 @@ target_sources( # Autolinking Setup ../nitrogen/generated/android/OmniOnLoad.cpp # Shared Nitrogen C++ sources - ../nitrogen/generated/shared/c++/HybridOmniSpec.cpp - ../nitrogen/generated/shared/c++/views/HybridOmniComponent.cpp + ../nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.cpp + ../nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp + ../nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.cpp + ../nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp + ../nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp # Android-specific Nitrogen C++ sources - ../nitrogen/generated/android/c++/JHybridOmniSpec.cpp - ../nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.cpp + ../nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.cpp + ../nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp + ../nitrogen/generated/android/c++/JVariant_NullType_Rendition.cpp + ../nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.cpp + ../nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp + ../nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp ) # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake diff --git a/nitrogen/generated/android/OmniOnLoad.cpp b/nitrogen/generated/android/OmniOnLoad.cpp index fbef64e..61b3803 100644 --- a/nitrogen/generated/android/OmniOnLoad.cpp +++ b/nitrogen/generated/android/OmniOnLoad.cpp @@ -15,8 +15,11 @@ #include #include -#include "JHybridOmniSpec.hpp" -#include "views/JHybridOmniStateUpdater.hpp" +#include "JHybridOmniPlayerPropsSpec.hpp" +#include "JHybridOmniPlayerSpec.hpp" +#include "JHybridOmniPlayerFactorySpec.hpp" +#include "JHybridOmniViewSpec.hpp" +#include "views/JHybridOmniViewStateUpdater.hpp" #include namespace margelo::nitro::omni { @@ -27,12 +30,28 @@ int initialize(JavaVM* vm) { }); } -struct JHybridOmniSpecImpl: public jni::JavaClass { - static constexpr auto kJavaDescriptor = "Ldev/zoriya/omni/HybridOmni;"; - static std::shared_ptr create() { - static const auto constructorFn = javaClassStatic()->getConstructor(); - jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); - return javaPart->getJHybridOmniSpec(); +struct JHybridOmniViewSpecImpl: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Ldev/zoriya/omni/OmniView;"; + static std::shared_ptr create() { + static const auto constructorFn = javaClassStatic()->getConstructor(); + jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); + return javaPart->getJHybridOmniViewSpec(); + } +}; +struct JHybridOmniPlayerSpecImpl: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Ldev/zoriya/omni/OmniPlayer;"; + static std::shared_ptr create() { + static const auto constructorFn = javaClassStatic()->getConstructor(); + jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); + return javaPart->getJHybridOmniPlayerSpec(); + } +}; +struct JHybridOmniPlayerFactorySpecImpl: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Ldev/zoriya/omni/OmniPlayerFactory;"; + static std::shared_ptr create() { + static const auto constructorFn = javaClassStatic()->getConstructor(); + jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); + return javaPart->getJHybridOmniPlayerFactorySpec(); } }; @@ -41,14 +60,29 @@ void registerAllNatives() { using namespace margelo::nitro::omni; // Register native JNI methods - margelo::nitro::omni::JHybridOmniSpec::CxxPart::registerNatives(); - margelo::nitro::omni::views::JHybridOmniStateUpdater::registerNatives(); + margelo::nitro::omni::JHybridOmniPlayerPropsSpec::CxxPart::registerNatives(); + margelo::nitro::omni::JHybridOmniPlayerSpec::CxxPart::registerNatives(); + margelo::nitro::omni::JHybridOmniPlayerFactorySpec::CxxPart::registerNatives(); + margelo::nitro::omni::JHybridOmniViewSpec::CxxPart::registerNatives(); + margelo::nitro::omni::views::JHybridOmniViewStateUpdater::registerNatives(); // Register Nitro Hybrid Objects HybridObjectRegistry::registerHybridObjectConstructor( - "Omni", + "OmniView", []() -> std::shared_ptr { - return JHybridOmniSpecImpl::create(); + return JHybridOmniViewSpecImpl::create(); + } + ); + HybridObjectRegistry::registerHybridObjectConstructor( + "OmniPlayer", + []() -> std::shared_ptr { + return JHybridOmniPlayerSpecImpl::create(); + } + ); + HybridObjectRegistry::registerHybridObjectConstructor( + "OmniPlayerFactory", + []() -> std::shared_ptr { + return JHybridOmniPlayerFactorySpecImpl::create(); } ); } diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.cpp b/nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.cpp new file mode 100644 index 0000000..85227e1 --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.cpp @@ -0,0 +1,60 @@ +/// +/// JHybridOmniPlayerFactorySpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridOmniPlayerFactorySpec.hpp" + +// Forward declaration of `HybridOmniPlayerSpec` to properly resolve imports. +namespace margelo::nitro::omni { class HybridOmniPlayerSpec; } +// Forward declaration of `HybridOmniPlayerPropsSpec` to properly resolve imports. +namespace margelo::nitro::omni { class HybridOmniPlayerPropsSpec; } + +#include +#include "HybridOmniPlayerSpec.hpp" +#include "JHybridOmniPlayerSpec.hpp" +#include "HybridOmniPlayerPropsSpec.hpp" +#include "JHybridOmniPlayerPropsSpec.hpp" + +namespace margelo::nitro::omni { + + std::shared_ptr JHybridOmniPlayerFactorySpec::JavaPart::getJHybridOmniPlayerFactorySpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniPlayerFactorySpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridOmniPlayerFactorySpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridOmniPlayerFactorySpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniPlayerFactorySpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridOmniPlayerFactorySpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridOmniPlayerFactorySpec::CxxPart::initHybrid), + }); + } + + // Properties + + + // Methods + std::shared_ptr JHybridOmniPlayerFactorySpec::createPlayer(const std::shared_ptr& props) { + static const auto method = _javaPart->javaClassStatic()->getMethod(jni::alias_ref /* props */)>("createPlayer"); + auto __result = method(_javaPart, std::dynamic_pointer_cast(props)->getJavaPart()); + return __result->getJHybridOmniPlayerSpec(); + } + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniSpec.hpp b/nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.hpp similarity index 59% rename from nitrogen/generated/android/c++/JHybridOmniSpec.hpp rename to nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.hpp index 018a002..c1761d1 100644 --- a/nitrogen/generated/android/c++/JHybridOmniSpec.hpp +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerFactorySpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridOmniSpec.hpp +/// HybridOmniPlayerFactorySpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -9,7 +9,7 @@ #include #include -#include "HybridOmniSpec.hpp" +#include "HybridOmniPlayerFactorySpec.hpp" @@ -18,14 +18,14 @@ namespace margelo::nitro::omni { using namespace facebook; - class JHybridOmniSpec: public virtual HybridOmniSpec, public virtual JHybridObject { + class JHybridOmniPlayerFactorySpec: public virtual HybridOmniPlayerFactorySpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniSpec;"; - std::shared_ptr getJHybridOmniSpec(); + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerFactorySpec;"; + std::shared_ptr getJHybridOmniPlayerFactorySpec(); }; struct CxxPart: public jni::HybridClass { - static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerFactorySpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; @@ -34,31 +34,30 @@ namespace margelo::nitro::omni { }; public: - explicit JHybridOmniSpec(const jni::local_ref& javaPart): - HybridObject(HybridOmniSpec::TAG), + explicit JHybridOmniPlayerFactorySpec(const jni::local_ref& javaPart): + HybridObject(HybridOmniPlayerFactorySpec::TAG), JHybridObject(javaPart), _javaPart(jni::make_global(javaPart)) {} - ~JHybridOmniSpec() override { + ~JHybridOmniPlayerFactorySpec() override { // Hermes GC can destroy JS objects on a non-JNI Thread. jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); } public: - inline const jni::global_ref& getJavaPart() const noexcept { + inline const jni::global_ref& getJavaPart() const noexcept { return _javaPart; } public: // Properties - bool getIsRed() override; - void setIsRed(bool isRed) override; + public: // Methods - + std::shared_ptr createPlayer(const std::shared_ptr& props) override; private: - jni::global_ref _javaPart; + jni::global_ref _javaPart; }; } // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.cpp b/nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.cpp new file mode 100644 index 0000000..31dfd80 --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.cpp @@ -0,0 +1,147 @@ +/// +/// JHybridOmniPlayerPropsSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridOmniPlayerPropsSpec.hpp" + +// Forward declaration of `VideoSrc` to properly resolve imports. +namespace margelo::nitro::omni { struct VideoSrc; } +// Forward declaration of `Subtitle` to properly resolve imports. +namespace margelo::nitro::omni { struct Subtitle; } +// Forward declaration of `Metadata` to properly resolve imports. +namespace margelo::nitro::omni { struct Metadata; } +// Forward declaration of `MixAudioMode` to properly resolve imports. +namespace margelo::nitro::omni { enum class MixAudioMode; } + +#include "VideoSrc.hpp" +#include +#include "JVideoSrc.hpp" +#include +#include +#include +#include "Subtitle.hpp" +#include "JSubtitle.hpp" +#include "Metadata.hpp" +#include "JMetadata.hpp" +#include "MixAudioMode.hpp" +#include "JMixAudioMode.hpp" + +namespace margelo::nitro::omni { + + std::shared_ptr JHybridOmniPlayerPropsSpec::JavaPart::getJHybridOmniPlayerPropsSpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniPlayerPropsSpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridOmniPlayerPropsSpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridOmniPlayerPropsSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniPlayerPropsSpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridOmniPlayerPropsSpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridOmniPlayerPropsSpec::CxxPart::initHybrid), + }); + } + + // Properties + std::vector JHybridOmniPlayerPropsSpec::getSrc() { + static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getSrc"); + auto __result = method(_javaPart); + return [&]() { + size_t __size = __result->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __result->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }(); + } + void JHybridOmniPlayerPropsSpec::setSrc(const std::vector& src) { + static const auto method = _javaPart->javaClassStatic()->getMethod> /* src */)>("setSrc"); + method(_javaPart, [&]() { + size_t __size = src.size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = src[__i]; + auto __elementJni = JVideoSrc::fromCpp(__element); + __array->setElement(__i, *__elementJni); + } + return __array; + }()); + } + std::optional JHybridOmniPlayerPropsSpec::getStartTime() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getStartTime"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt; + } + void JHybridOmniPlayerPropsSpec::setStartTime(std::optional startTime) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* startTime */)>("setStartTime"); + method(_javaPart, startTime.has_value() ? jni::JDouble::valueOf(startTime.value()) : nullptr); + } + std::vector JHybridOmniPlayerPropsSpec::getSubtitles() { + static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getSubtitles"); + auto __result = method(_javaPart); + return [&]() { + size_t __size = __result->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __result->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }(); + } + void JHybridOmniPlayerPropsSpec::setSubtitles(const std::vector& subtitles) { + static const auto method = _javaPart->javaClassStatic()->getMethod> /* subtitles */)>("setSubtitles"); + method(_javaPart, [&]() { + size_t __size = subtitles.size(); + jni::local_ref> __array = jni::JArrayClass::newArray(__size); + for (size_t __i = 0; __i < __size; __i++) { + const auto& __element = subtitles[__i]; + auto __elementJni = JSubtitle::fromCpp(__element); + __array->setElement(__i, *__elementJni); + } + return __array; + }()); + } + std::optional JHybridOmniPlayerPropsSpec::getMetadata() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getMetadata"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt; + } + void JHybridOmniPlayerPropsSpec::setMetadata(const std::optional& metadata) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* metadata */)>("setMetadata"); + method(_javaPart, metadata.has_value() ? JMetadata::fromCpp(metadata.value()) : nullptr); + } + std::optional JHybridOmniPlayerPropsSpec::getMixAudio() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getMixAudio"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt; + } + void JHybridOmniPlayerPropsSpec::setMixAudio(std::optional mixAudio) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* mixAudio */)>("setMixAudio"); + method(_javaPart, mixAudio.has_value() ? JMixAudioMode::fromCpp(mixAudio.value()) : nullptr); + } + + // Methods + + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.hpp b/nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.hpp new file mode 100644 index 0000000..37fffa3 --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerPropsSpec.hpp @@ -0,0 +1,72 @@ +/// +/// HybridOmniPlayerPropsSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "HybridOmniPlayerPropsSpec.hpp" + + + + +namespace margelo::nitro::omni { + + using namespace facebook; + + class JHybridOmniPlayerPropsSpec: public virtual HybridOmniPlayerPropsSpec, public virtual JHybridObject { + public: + struct JavaPart: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerPropsSpec;"; + std::shared_ptr getJHybridOmniPlayerPropsSpec(); + }; + struct CxxPart: public jni::HybridClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerPropsSpec$CxxPart;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + using HybridBase::HybridBase; + protected: + std::shared_ptr createHybridObject(const jni::local_ref& javaPart) override; + }; + + public: + explicit JHybridOmniPlayerPropsSpec(const jni::local_ref& javaPart): + HybridObject(HybridOmniPlayerPropsSpec::TAG), + JHybridObject(javaPart), + _javaPart(jni::make_global(javaPart)) {} + ~JHybridOmniPlayerPropsSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + std::vector getSrc() override; + void setSrc(const std::vector& src) override; + std::optional getStartTime() override; + void setStartTime(std::optional startTime) override; + std::vector getSubtitles() override; + void setSubtitles(const std::vector& subtitles) override; + std::optional getMetadata() override; + void setMetadata(const std::optional& metadata) override; + std::optional getMixAudio() override; + void setMixAudio(std::optional mixAudio) override; + + public: + // Methods + + + private: + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp new file mode 100644 index 0000000..c167e77 --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.cpp @@ -0,0 +1,213 @@ +/// +/// JHybridOmniPlayerSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridOmniPlayerSpec.hpp" + +// Forward declaration of `PlayerStatus` to properly resolve imports. +namespace margelo::nitro::omni { enum class PlayerStatus; } +// Forward declaration of `Track` to properly resolve imports. +namespace margelo::nitro::omni { struct Track; } +// Forward declaration of `Rendition` to properly resolve imports. +namespace margelo::nitro::omni { struct Rendition; } + +#include "PlayerStatus.hpp" +#include "JPlayerStatus.hpp" +#include "Track.hpp" +#include +#include "JTrack.hpp" +#include +#include +#include "Rendition.hpp" +#include "JRendition.hpp" +#include +#include +#include "JVariant_NullType_Rendition.hpp" +#include + +namespace margelo::nitro::omni { + + std::shared_ptr JHybridOmniPlayerSpec::JavaPart::getJHybridOmniPlayerSpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniPlayerSpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridOmniPlayerSpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridOmniPlayerSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniPlayerSpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridOmniPlayerSpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridOmniPlayerSpec::CxxPart::initHybrid), + }); + } + + // Properties + bool JHybridOmniPlayerSpec::getHasPrev() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getHasPrev"); + auto __result = method(_javaPart); + return static_cast(__result); + } + bool JHybridOmniPlayerSpec::getHasNext() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getHasNext"); + auto __result = method(_javaPart); + return static_cast(__result); + } + PlayerStatus JHybridOmniPlayerSpec::getStatus() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getStatus"); + auto __result = method(_javaPart); + return __result->toCpp(); + } + bool JHybridOmniPlayerSpec::getIsPlaying() { + static const auto method = _javaPart->javaClassStatic()->getMethod("isPlaying"); + auto __result = method(_javaPart); + return static_cast(__result); + } + double JHybridOmniPlayerSpec::getCurrentTime() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getCurrentTime"); + auto __result = method(_javaPart); + return __result; + } + void JHybridOmniPlayerSpec::setCurrentTime(double currentTime) { + static const auto method = _javaPart->javaClassStatic()->getMethod("setCurrentTime"); + method(_javaPart, currentTime); + } + double JHybridOmniPlayerSpec::getBuffered() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getBuffered"); + auto __result = method(_javaPart); + return __result; + } + double JHybridOmniPlayerSpec::getDuration() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getDuration"); + auto __result = method(_javaPart); + return __result; + } + double JHybridOmniPlayerSpec::getPlaybackRate() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getPlaybackRate"); + auto __result = method(_javaPart); + return __result; + } + void JHybridOmniPlayerSpec::setPlaybackRate(double playbackRate) { + static const auto method = _javaPart->javaClassStatic()->getMethod("setPlaybackRate"); + method(_javaPart, playbackRate); + } + double JHybridOmniPlayerSpec::getVolume() { + static const auto method = _javaPart->javaClassStatic()->getMethod("getVolume"); + auto __result = method(_javaPart); + return __result; + } + void JHybridOmniPlayerSpec::setVolume(double volume) { + static const auto method = _javaPart->javaClassStatic()->getMethod("setVolume"); + method(_javaPart, volume); + } + std::vector JHybridOmniPlayerSpec::getVideos() { + static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getVideos"); + auto __result = method(_javaPart); + return [&]() { + size_t __size = __result->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __result->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }(); + } + std::vector JHybridOmniPlayerSpec::getAudios() { + static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getAudios"); + auto __result = method(_javaPart); + return [&]() { + size_t __size = __result->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __result->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }(); + } + std::vector JHybridOmniPlayerSpec::getSubtitles() { + static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getSubtitles"); + auto __result = method(_javaPart); + return [&]() { + size_t __size = __result->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __result->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }(); + } + std::vector JHybridOmniPlayerSpec::getRendition() { + static const auto method = _javaPart->javaClassStatic()->getMethod>()>("getRendition"); + auto __result = method(_javaPart); + return [&]() { + size_t __size = __result->size(); + std::vector __vector; + __vector.reserve(__size); + for (size_t __i = 0; __i < __size; __i++) { + auto __element = __result->getElement(__i); + __vector.push_back(__element->toCpp()); + } + return __vector; + }(); + } + + // Methods + void JHybridOmniPlayerSpec::play() { + static const auto method = _javaPart->javaClassStatic()->getMethod("play"); + method(_javaPart); + } + void JHybridOmniPlayerSpec::pause() { + static const auto method = _javaPart->javaClassStatic()->getMethod("pause"); + method(_javaPart); + } + void JHybridOmniPlayerSpec::seekBy(double offset) { + static const auto method = _javaPart->javaClassStatic()->getMethod("seekBy"); + method(_javaPart, offset); + } + void JHybridOmniPlayerSpec::playPrev() { + static const auto method = _javaPart->javaClassStatic()->getMethod("playPrev"); + method(_javaPart); + } + void JHybridOmniPlayerSpec::playNext() { + static const auto method = _javaPart->javaClassStatic()->getMethod("playNext"); + method(_javaPart); + } + void JHybridOmniPlayerSpec::selectVideo(const Track& video) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* video */)>("selectVideo"); + method(_javaPart, JTrack::fromCpp(video)); + } + void JHybridOmniPlayerSpec::selectAudio(const Track& audio) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* audio */)>("selectAudio"); + method(_javaPart, JTrack::fromCpp(audio)); + } + void JHybridOmniPlayerSpec::selectSubtitle(const Track& subtitle) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* subtitle */)>("selectSubtitle"); + method(_javaPart, JTrack::fromCpp(subtitle)); + } + void JHybridOmniPlayerSpec::selectRendition(const std::optional>& rendition) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* rendition */)>("selectRendition"); + method(_javaPart, rendition.has_value() ? JVariant_NullType_Rendition::fromCpp(rendition.value()) : nullptr); + } + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp new file mode 100644 index 0000000..3d19653 --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniPlayerSpec.hpp @@ -0,0 +1,86 @@ +/// +/// HybridOmniPlayerSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "HybridOmniPlayerSpec.hpp" + + + + +namespace margelo::nitro::omni { + + using namespace facebook; + + class JHybridOmniPlayerSpec: public virtual HybridOmniPlayerSpec, public virtual JHybridObject { + public: + struct JavaPart: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerSpec;"; + std::shared_ptr getJHybridOmniPlayerSpec(); + }; + struct CxxPart: public jni::HybridClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniPlayerSpec$CxxPart;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + using HybridBase::HybridBase; + protected: + std::shared_ptr createHybridObject(const jni::local_ref& javaPart) override; + }; + + public: + explicit JHybridOmniPlayerSpec(const jni::local_ref& javaPart): + HybridObject(HybridOmniPlayerSpec::TAG), + JHybridObject(javaPart), + _javaPart(jni::make_global(javaPart)) {} + ~JHybridOmniPlayerSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + bool getHasPrev() override; + bool getHasNext() override; + PlayerStatus getStatus() override; + bool getIsPlaying() override; + double getCurrentTime() override; + void setCurrentTime(double currentTime) override; + double getBuffered() override; + double getDuration() override; + double getPlaybackRate() override; + void setPlaybackRate(double playbackRate) override; + double getVolume() override; + void setVolume(double volume) override; + std::vector getVideos() override; + std::vector getAudios() override; + std::vector getSubtitles() override; + std::vector getRendition() override; + + public: + // Methods + void play() override; + void pause() override; + void seekBy(double offset) override; + void playPrev() override; + void playNext() override; + void selectVideo(const Track& video) override; + void selectAudio(const Track& audio) override; + void selectSubtitle(const Track& subtitle) override; + void selectRendition(const std::optional>& rendition) override; + + private: + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniSpec.cpp b/nitrogen/generated/android/c++/JHybridOmniSpec.cpp deleted file mode 100644 index bd10a48..0000000 --- a/nitrogen/generated/android/c++/JHybridOmniSpec.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/// -/// JHybridOmniSpec.cpp -/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. -/// https://github.com/mrousavy/nitro -/// Copyright © Marc Rousavy @ Margelo -/// - -#include "JHybridOmniSpec.hpp" - - - - - -namespace margelo::nitro::omni { - - std::shared_ptr JHybridOmniSpec::JavaPart::getJHybridOmniSpec() { - auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); - auto castHybridObject = std::dynamic_pointer_cast(hybridObject); - if (castHybridObject == nullptr) [[unlikely]] { - throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniSpec!"); - } - return castHybridObject; - } - - jni::local_ref JHybridOmniSpec::CxxPart::initHybrid(jni::alias_ref jThis) { - return makeCxxInstance(jThis); - } - - std::shared_ptr JHybridOmniSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { - auto castJavaPart = jni::dynamic_ref_cast(javaPart); - if (castJavaPart == nullptr) [[unlikely]] { - throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniSpec::JavaPart!"); - } - return std::make_shared(castJavaPart); - } - - void JHybridOmniSpec::CxxPart::registerNatives() { - registerHybrid({ - makeNativeMethod("initHybrid", JHybridOmniSpec::CxxPart::initHybrid), - }); - } - - // Properties - bool JHybridOmniSpec::getIsRed() { - static const auto method = _javaPart->javaClassStatic()->getMethod("isRed"); - auto __result = method(_javaPart); - return static_cast(__result); - } - void JHybridOmniSpec::setIsRed(bool isRed) { - static const auto method = _javaPart->javaClassStatic()->getMethod("setRed"); - method(_javaPart, isRed); - } - - // Methods - - -} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp b/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp new file mode 100644 index 0000000..3e1cbfd --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniViewSpec.cpp @@ -0,0 +1,75 @@ +/// +/// JHybridOmniViewSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JHybridOmniViewSpec.hpp" + + + +#include + +namespace margelo::nitro::omni { + + std::shared_ptr JHybridOmniViewSpec::JavaPart::getJHybridOmniViewSpec() { + auto hybridObject = JHybridObject::JavaPart::getJHybridObject(); + auto castHybridObject = std::dynamic_pointer_cast(hybridObject); + if (castHybridObject == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to downcast JHybridObject to JHybridOmniViewSpec!"); + } + return castHybridObject; + } + + jni::local_ref JHybridOmniViewSpec::CxxPart::initHybrid(jni::alias_ref jThis) { + return makeCxxInstance(jThis); + } + + std::shared_ptr JHybridOmniViewSpec::CxxPart::createHybridObject(const jni::local_ref& javaPart) { + auto castJavaPart = jni::dynamic_ref_cast(javaPart); + if (castJavaPart == nullptr) [[unlikely]] { + throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOmniViewSpec::JavaPart!"); + } + return std::make_shared(castJavaPart); + } + + void JHybridOmniViewSpec::CxxPart::registerNatives() { + registerHybrid({ + makeNativeMethod("initHybrid", JHybridOmniViewSpec::CxxPart::initHybrid), + }); + } + + // Properties + std::optional JHybridOmniViewSpec::getAutoplay() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getAutoplay"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(static_cast(__result->value())) : std::nullopt; + } + void JHybridOmniViewSpec::setAutoplay(std::optional autoplay) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* autoplay */)>("setAutoplay"); + method(_javaPart, autoplay.has_value() ? jni::JBoolean::valueOf(autoplay.value()) : nullptr); + } + std::optional JHybridOmniViewSpec::getShowNotification() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getShowNotification"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(static_cast(__result->value())) : std::nullopt; + } + void JHybridOmniViewSpec::setShowNotification(std::optional showNotification) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* showNotification */)>("setShowNotification"); + method(_javaPart, showNotification.has_value() ? jni::JBoolean::valueOf(showNotification.value()) : nullptr); + } + std::optional JHybridOmniViewSpec::getAutoPip() { + static const auto method = _javaPart->javaClassStatic()->getMethod()>("getAutoPip"); + auto __result = method(_javaPart); + return __result != nullptr ? std::make_optional(static_cast(__result->value())) : std::nullopt; + } + void JHybridOmniViewSpec::setAutoPip(std::optional autoPip) { + static const auto method = _javaPart->javaClassStatic()->getMethod /* autoPip */)>("setAutoPip"); + method(_javaPart, autoPip.has_value() ? jni::JBoolean::valueOf(autoPip.value()) : nullptr); + } + + // Methods + + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp b/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp new file mode 100644 index 0000000..7b1f151 --- /dev/null +++ b/nitrogen/generated/android/c++/JHybridOmniViewSpec.hpp @@ -0,0 +1,68 @@ +/// +/// HybridOmniViewSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include +#include "HybridOmniViewSpec.hpp" + + + + +namespace margelo::nitro::omni { + + using namespace facebook; + + class JHybridOmniViewSpec: public virtual HybridOmniViewSpec, public virtual JHybridObject { + public: + struct JavaPart: public jni::JavaClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniViewSpec;"; + std::shared_ptr getJHybridOmniViewSpec(); + }; + struct CxxPart: public jni::HybridClass { + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/HybridOmniViewSpec$CxxPart;"; + static jni::local_ref initHybrid(jni::alias_ref jThis); + static void registerNatives(); + using HybridBase::HybridBase; + protected: + std::shared_ptr createHybridObject(const jni::local_ref& javaPart) override; + }; + + public: + explicit JHybridOmniViewSpec(const jni::local_ref& javaPart): + HybridObject(HybridOmniViewSpec::TAG), + JHybridObject(javaPart), + _javaPart(jni::make_global(javaPart)) {} + ~JHybridOmniViewSpec() override { + // Hermes GC can destroy JS objects on a non-JNI Thread. + jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); }); + } + + public: + inline const jni::global_ref& getJavaPart() const noexcept { + return _javaPart; + } + + public: + // Properties + std::optional getAutoplay() override; + void setAutoplay(std::optional autoplay) override; + std::optional getShowNotification() override; + void setShowNotification(std::optional showNotification) override; + std::optional getAutoPip() override; + void setAutoPip(std::optional autoPip) override; + + public: + // Methods + + + private: + jni::global_ref _javaPart; + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JMetadata.hpp b/nitrogen/generated/android/c++/JMetadata.hpp new file mode 100644 index 0000000..1d00f8f --- /dev/null +++ b/nitrogen/generated/android/c++/JMetadata.hpp @@ -0,0 +1,78 @@ +/// +/// JMetadata.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "Metadata.hpp" + +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "Metadata" and the the Kotlin data class "Metadata". + */ + struct JMetadata final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Metadata;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct Metadata by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + Metadata toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldTitle = clazz->getField("title"); + jni::local_ref title = this->getFieldValue(fieldTitle); + static const auto fieldAlbum = clazz->getField("album"); + jni::local_ref album = this->getFieldValue(fieldAlbum); + static const auto fieldArtist = clazz->getField("artist"); + jni::local_ref artist = this->getFieldValue(fieldArtist); + static const auto fieldImageLink = clazz->getField("imageLink"); + jni::local_ref imageLink = this->getFieldValue(fieldImageLink); + static const auto fieldHasPrev = clazz->getField("hasPrev"); + jni::local_ref hasPrev = this->getFieldValue(fieldHasPrev); + static const auto fieldHasNext = clazz->getField("hasNext"); + jni::local_ref hasNext = this->getFieldValue(fieldHasNext); + return Metadata( + title->toStdString(), + album != nullptr ? std::make_optional(album->toStdString()) : std::nullopt, + artist != nullptr ? std::make_optional(artist->toStdString()) : std::nullopt, + imageLink != nullptr ? std::make_optional(imageLink->toStdString()) : std::nullopt, + hasPrev != nullptr ? std::make_optional(static_cast(hasPrev->value())) : std::nullopt, + hasNext != nullptr ? std::make_optional(static_cast(hasNext->value())) : std::nullopt + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const Metadata& value) { + using JSignature = JMetadata(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + jni::make_jstring(value.title), + value.album.has_value() ? jni::make_jstring(value.album.value()) : nullptr, + value.artist.has_value() ? jni::make_jstring(value.artist.value()) : nullptr, + value.imageLink.has_value() ? jni::make_jstring(value.imageLink.value()) : nullptr, + value.hasPrev.has_value() ? jni::JBoolean::valueOf(value.hasPrev.value()) : nullptr, + value.hasNext.has_value() ? jni::JBoolean::valueOf(value.hasNext.value()) : nullptr + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JMixAudioMode.hpp b/nitrogen/generated/android/c++/JMixAudioMode.hpp new file mode 100644 index 0000000..cb636a0 --- /dev/null +++ b/nitrogen/generated/android/c++/JMixAudioMode.hpp @@ -0,0 +1,64 @@ +/// +/// JMixAudioMode.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "MixAudioMode.hpp" + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ enum "MixAudioMode" and the the Kotlin enum "MixAudioMode". + */ + struct JMixAudioMode final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/MixAudioMode;"; + + public: + /** + * Convert this Java/Kotlin-based enum to the C++ enum MixAudioMode. + */ + [[maybe_unused]] + [[nodiscard]] + MixAudioMode toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldOrdinal = clazz->getField("value"); + int ordinal = this->getFieldValue(fieldOrdinal); + return static_cast(ordinal); + } + + public: + /** + * Create a Java/Kotlin-based enum with the given C++ enum's value. + */ + [[maybe_unused]] + static jni::alias_ref fromCpp(MixAudioMode value) { + static const auto clazz = javaClassStatic(); + switch (value) { + case MixAudioMode::MIXWITHOTHERS: + static const auto fieldMIXWITHOTHERS = clazz->getStaticField("MIXWITHOTHERS"); + return clazz->getStaticFieldValue(fieldMIXWITHOTHERS); + case MixAudioMode::DONOTMIX: + static const auto fieldDONOTMIX = clazz->getStaticField("DONOTMIX"); + return clazz->getStaticFieldValue(fieldDONOTMIX); + case MixAudioMode::DUCKOTHERS: + static const auto fieldDUCKOTHERS = clazz->getStaticField("DUCKOTHERS"); + return clazz->getStaticFieldValue(fieldDUCKOTHERS); + case MixAudioMode::AUTO: + static const auto fieldAUTO = clazz->getStaticField("AUTO"); + return clazz->getStaticFieldValue(fieldAUTO); + default: + std::string stringValue = std::to_string(static_cast(value)); + throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); + } + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JPlayerStatus.hpp b/nitrogen/generated/android/c++/JPlayerStatus.hpp new file mode 100644 index 0000000..e83fc25 --- /dev/null +++ b/nitrogen/generated/android/c++/JPlayerStatus.hpp @@ -0,0 +1,64 @@ +/// +/// JPlayerStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "PlayerStatus.hpp" + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ enum "PlayerStatus" and the the Kotlin enum "PlayerStatus". + */ + struct JPlayerStatus final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/PlayerStatus;"; + + public: + /** + * Convert this Java/Kotlin-based enum to the C++ enum PlayerStatus. + */ + [[maybe_unused]] + [[nodiscard]] + PlayerStatus toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldOrdinal = clazz->getField("value"); + int ordinal = this->getFieldValue(fieldOrdinal); + return static_cast(ordinal); + } + + public: + /** + * Create a Java/Kotlin-based enum with the given C++ enum's value. + */ + [[maybe_unused]] + static jni::alias_ref fromCpp(PlayerStatus value) { + static const auto clazz = javaClassStatic(); + switch (value) { + case PlayerStatus::IDLE: + static const auto fieldIDLE = clazz->getStaticField("IDLE"); + return clazz->getStaticFieldValue(fieldIDLE); + case PlayerStatus::LOADING: + static const auto fieldLOADING = clazz->getStaticField("LOADING"); + return clazz->getStaticFieldValue(fieldLOADING); + case PlayerStatus::READYTOPLAY: + static const auto fieldREADYTOPLAY = clazz->getStaticField("READYTOPLAY"); + return clazz->getStaticFieldValue(fieldREADYTOPLAY); + case PlayerStatus::ERROR: + static const auto fieldERROR = clazz->getStaticField("ERROR"); + return clazz->getStaticFieldValue(fieldERROR); + default: + std::string stringValue = std::to_string(static_cast(value)); + throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); + } + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JRendition.hpp b/nitrogen/generated/android/c++/JRendition.hpp new file mode 100644 index 0000000..b68d92f --- /dev/null +++ b/nitrogen/generated/android/c++/JRendition.hpp @@ -0,0 +1,73 @@ +/// +/// JRendition.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "Rendition.hpp" + +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "Rendition" and the the Kotlin data class "Rendition". + */ + struct JRendition final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Rendition;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct Rendition by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + Rendition toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldId = clazz->getField("id"); + jni::local_ref id = this->getFieldValue(fieldId); + static const auto fieldWidth = clazz->getField("width"); + double width = this->getFieldValue(fieldWidth); + static const auto fieldHeight = clazz->getField("height"); + double height = this->getFieldValue(fieldHeight); + static const auto fieldBitrate = clazz->getField("bitrate"); + double bitrate = this->getFieldValue(fieldBitrate); + static const auto fieldSelected = clazz->getField("selected"); + jboolean selected = this->getFieldValue(fieldSelected); + return Rendition( + id->toStdString(), + width, + height, + bitrate, + static_cast(selected) + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const Rendition& value) { + using JSignature = JRendition(jni::alias_ref, double, double, double, jboolean); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + jni::make_jstring(value.id), + value.width, + value.height, + value.bitrate, + value.selected + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JSubtitle.hpp b/nitrogen/generated/android/c++/JSubtitle.hpp new file mode 100644 index 0000000..e978370 --- /dev/null +++ b/nitrogen/generated/android/c++/JSubtitle.hpp @@ -0,0 +1,74 @@ +/// +/// JSubtitle.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "Subtitle.hpp" + +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "Subtitle" and the the Kotlin data class "Subtitle". + */ + struct JSubtitle final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Subtitle;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct Subtitle by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + Subtitle toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldId = clazz->getField("id"); + jni::local_ref id = this->getFieldValue(fieldId); + static const auto fieldLink = clazz->getField("link"); + jni::local_ref link = this->getFieldValue(fieldLink); + static const auto fieldMimeType = clazz->getField("mimeType"); + jni::local_ref mimeType = this->getFieldValue(fieldMimeType); + static const auto fieldLanguage = clazz->getField("language"); + jni::local_ref language = this->getFieldValue(fieldLanguage); + static const auto fieldLabel = clazz->getField("label"); + jni::local_ref label = this->getFieldValue(fieldLabel); + return Subtitle( + id->toStdString(), + link->toStdString(), + mimeType != nullptr ? std::make_optional(mimeType->toStdString()) : std::nullopt, + language != nullptr ? std::make_optional(language->toStdString()) : std::nullopt, + label != nullptr ? std::make_optional(label->toStdString()) : std::nullopt + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const Subtitle& value) { + using JSignature = JSubtitle(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + jni::make_jstring(value.id), + jni::make_jstring(value.link), + value.mimeType.has_value() ? jni::make_jstring(value.mimeType.value()) : nullptr, + value.language.has_value() ? jni::make_jstring(value.language.value()) : nullptr, + value.label.has_value() ? jni::make_jstring(value.label.value()) : nullptr + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JTrack.hpp b/nitrogen/generated/android/c++/JTrack.hpp new file mode 100644 index 0000000..78004e7 --- /dev/null +++ b/nitrogen/generated/android/c++/JTrack.hpp @@ -0,0 +1,70 @@ +/// +/// JTrack.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "Track.hpp" + +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "Track" and the the Kotlin data class "Track". + */ + struct JTrack final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Track;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct Track by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + Track toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldId = clazz->getField("id"); + jni::local_ref id = this->getFieldValue(fieldId); + static const auto fieldLabel = clazz->getField("label"); + jni::local_ref label = this->getFieldValue(fieldLabel); + static const auto fieldLanguage = clazz->getField("language"); + jni::local_ref language = this->getFieldValue(fieldLanguage); + static const auto fieldSelected = clazz->getField("selected"); + jboolean selected = this->getFieldValue(fieldSelected); + return Track( + id->toStdString(), + label != nullptr ? std::make_optional(label->toStdString()) : std::nullopt, + language != nullptr ? std::make_optional(language->toStdString()) : std::nullopt, + static_cast(selected) + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const Track& value) { + using JSignature = JTrack(jni::alias_ref, jni::alias_ref, jni::alias_ref, jboolean); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + jni::make_jstring(value.id), + value.label.has_value() ? jni::make_jstring(value.label.value()) : nullptr, + value.language.has_value() ? jni::make_jstring(value.language.value()) : nullptr, + value.selected + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JVariant_NullType_Rendition.cpp b/nitrogen/generated/android/c++/JVariant_NullType_Rendition.cpp new file mode 100644 index 0000000..d8db613 --- /dev/null +++ b/nitrogen/generated/android/c++/JVariant_NullType_Rendition.cpp @@ -0,0 +1,26 @@ +/// +/// JVariant_NullType_Rendition.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "JVariant_NullType_Rendition.hpp" + +namespace margelo::nitro::omni { + /** + * Converts JVariant_NullType_Rendition to std::variant + */ + std::variant JVariant_NullType_Rendition::toCpp() const { + if (isInstanceOf(JVariant_NullType_Rendition_impl::First::javaClassStatic())) { + // It's a `nitro::NullType` + auto jniValue = static_cast(this)->getValue(); + return nitro::null; + } else if (isInstanceOf(JVariant_NullType_Rendition_impl::Second::javaClassStatic())) { + // It's a `Rendition` + auto jniValue = static_cast(this)->getValue(); + return jniValue->toCpp(); + } + throw std::invalid_argument("Variant is unknown Kotlin instance!"); + } +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JVariant_NullType_Rendition.hpp b/nitrogen/generated/android/c++/JVariant_NullType_Rendition.hpp new file mode 100644 index 0000000..d89af29 --- /dev/null +++ b/nitrogen/generated/android/c++/JVariant_NullType_Rendition.hpp @@ -0,0 +1,72 @@ +/// +/// JVariant_NullType_Rendition.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include + +#include +#include "Rendition.hpp" +#include +#include +#include "JRendition.hpp" +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_Rendition". + */ + class JVariant_NullType_Rendition: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Variant_NullType_Rendition;"; + + static jni::local_ref create_0(jni::alias_ref value) { + static const auto method = javaClassStatic()->getStaticMethod)>("create"); + return method(javaClassStatic(), value); + } + static jni::local_ref create_1(jni::alias_ref value) { + static const auto method = javaClassStatic()->getStaticMethod)>("create"); + return method(javaClassStatic(), value); + } + + static jni::local_ref fromCpp(const std::variant& variant) { + switch (variant.index()) { + case 0: return create_0(JNull::null()); + case 1: return create_1(JRendition::fromCpp(std::get<1>(variant))); + default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")"); + } + } + + [[nodiscard]] std::variant toCpp() const; + }; + + namespace JVariant_NullType_Rendition_impl { + class First final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Variant_NullType_Rendition$First;"; + + [[nodiscard]] jni::local_ref getValue() const { + static const auto field = javaClassStatic()->getField("value"); + return getFieldValue(field); + } + }; + + class Second final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Variant_NullType_Rendition$Second;"; + + [[nodiscard]] jni::local_ref getValue() const { + static const auto field = javaClassStatic()->getField("value"); + return getFieldValue(field); + } + }; + } // namespace JVariant_NullType_Rendition_impl +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/JVideoSrc.hpp b/nitrogen/generated/android/c++/JVideoSrc.hpp new file mode 100644 index 0000000..3c9dd4a --- /dev/null +++ b/nitrogen/generated/android/c++/JVideoSrc.hpp @@ -0,0 +1,80 @@ +/// +/// JVideoSrc.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#include +#include "VideoSrc.hpp" + +#include +#include +#include + +namespace margelo::nitro::omni { + + using namespace facebook; + + /** + * The C++ JNI bridge between the C++ struct "VideoSrc" and the the Kotlin data class "VideoSrc". + */ + struct JVideoSrc final: public jni::JavaClass { + public: + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/VideoSrc;"; + + public: + /** + * Convert this Java/Kotlin-based struct to the C++ struct VideoSrc by copying all values to C++. + */ + [[maybe_unused]] + [[nodiscard]] + VideoSrc toCpp() const { + static const auto clazz = javaClassStatic(); + static const auto fieldUri = clazz->getField("uri"); + jni::local_ref uri = this->getFieldValue(fieldUri); + static const auto fieldMimeType = clazz->getField("mimeType"); + jni::local_ref mimeType = this->getFieldValue(fieldMimeType); + static const auto fieldHeaders = clazz->getField>("headers"); + jni::local_ref> headers = this->getFieldValue(fieldHeaders); + return VideoSrc( + uri->toStdString(), + mimeType != nullptr ? std::make_optional(mimeType->toStdString()) : std::nullopt, + [&]() { + std::unordered_map __map; + __map.reserve(headers->size()); + for (const auto& __entry : *headers) { + __map.emplace(__entry.first->toStdString(), __entry.second->toStdString()); + } + return __map; + }() + ); + } + + public: + /** + * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. + */ + [[maybe_unused]] + static jni::local_ref fromCpp(const VideoSrc& value) { + using JSignature = JVideoSrc(jni::alias_ref, jni::alias_ref, jni::alias_ref>); + static const auto clazz = javaClassStatic(); + static const auto create = clazz->getStaticMethod("fromCpp"); + return create( + clazz, + jni::make_jstring(value.uri), + value.mimeType.has_value() ? jni::make_jstring(value.mimeType.value()) : nullptr, + [&]() -> jni::local_ref> { + auto __map = jni::JHashMap::create(value.headers.size()); + for (const auto& __entry : value.headers) { + __map->put(jni::make_jstring(__entry.first), jni::make_jstring(__entry.second)); + } + return __map; + }() + ); + } + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.cpp b/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp similarity index 60% rename from nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.cpp rename to nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp index 990cbb3..08e8e21 100644 --- a/nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.cpp +++ b/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.cpp @@ -1,24 +1,24 @@ /// -/// JHybridOmniStateUpdater.cpp +/// JHybridOmniViewStateUpdater.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "JHybridOmniStateUpdater.hpp" -#include "views/HybridOmniComponent.hpp" +#include "JHybridOmniViewStateUpdater.hpp" +#include "views/HybridOmniViewComponent.hpp" #include #include namespace margelo::nitro::omni::views { using namespace facebook; -using ConcreteStateData = react::ConcreteState; +using ConcreteStateData = react::ConcreteState; -void JHybridOmniStateUpdater::updateViewProps(jni::alias_ref /* class */, - jni::alias_ref javaView, +void JHybridOmniViewStateUpdater::updateViewProps(jni::alias_ref /* class */, + jni::alias_ref javaView, jni::alias_ref stateWrapperInterface) { - std::shared_ptr hybridView = javaView->getJHybridOmniSpec(); + std::shared_ptr hybridView = javaView->getJHybridOmniViewSpec(); // Get concrete StateWrapperImpl from passed StateWrapper interface object jobject rawStateWrapper = stateWrapperInterface.get(); @@ -29,17 +29,25 @@ void JHybridOmniStateUpdater::updateViewProps(jni::alias_ref /* cla static_cast(rawStateWrapper)}; std::shared_ptr state = stateWrapper->cthis()->getState(); auto concreteState = std::static_pointer_cast(state); - const HybridOmniState& data = concreteState->getData(); - const std::shared_ptr& props = data.getProps(); + const HybridOmniViewState& data = concreteState->getData(); + const std::shared_ptr& props = data.getProps(); if (props == nullptr) [[unlikely]] { // Props aren't set yet! - throw std::runtime_error("HybridOmniState's data doesn't contain any props!"); + throw std::runtime_error("HybridOmniViewState's data doesn't contain any props!"); } // Update all props if they are dirty - if (props->isRed.isDirty) { - hybridView->setIsRed(props->isRed.value); - props->isRed.isDirty = false; + if (props->autoplay.isDirty) { + hybridView->setAutoplay(props->autoplay.value); + props->autoplay.isDirty = false; + } + if (props->showNotification.isDirty) { + hybridView->setShowNotification(props->showNotification.value); + props->showNotification.isDirty = false; + } + if (props->autoPip.isDirty) { + hybridView->setAutoPip(props->autoPip.value); + props->autoPip.isDirty = false; } // Update hybridRef if it changed diff --git a/nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.hpp b/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.hpp similarity index 74% rename from nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.hpp rename to nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.hpp index 8bd2fa0..74e47b2 100644 --- a/nitrogen/generated/android/c++/views/JHybridOmniStateUpdater.hpp +++ b/nitrogen/generated/android/c++/views/JHybridOmniViewStateUpdater.hpp @@ -1,5 +1,5 @@ /// -/// JHybridOmniStateUpdater.hpp +/// JHybridOmniViewStateUpdater.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -17,30 +17,30 @@ #include #include #include -#include "JHybridOmniSpec.hpp" -#include "views/HybridOmniComponent.hpp" +#include "JHybridOmniViewSpec.hpp" +#include "views/HybridOmniViewComponent.hpp" namespace margelo::nitro::omni::views { using namespace facebook; -class JHybridOmniStateUpdater final: public jni::JavaClass { +class JHybridOmniViewStateUpdater final: public jni::JavaClass { public: - static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/views/HybridOmniStateUpdater;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/views/HybridOmniViewStateUpdater;"; public: static void updateViewProps(jni::alias_ref /* class */, - jni::alias_ref view, + jni::alias_ref view, jni::alias_ref stateWrapperInterface); public: static void registerNatives() { // Register JNI calls javaClassStatic()->registerNatives({ - makeNativeMethod("updateViewProps", JHybridOmniStateUpdater::updateViewProps), + makeNativeMethod("updateViewProps", JHybridOmniViewStateUpdater::updateViewProps), }); // Register React Native view component descriptor - auto provider = react::concreteComponentDescriptorProvider(); + auto provider = react::concreteComponentDescriptorProvider(); auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry(); providerRegistry->add(provider); } diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerFactorySpec.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerFactorySpec.kt new file mode 100644 index 0000000..8f62d6c --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerFactorySpec.kt @@ -0,0 +1,54 @@ +/// +/// HybridOmniPlayerFactorySpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.HybridObject + +/** + * A Kotlin class representing the OmniPlayerFactory HybridObject. + * Implement this abstract class to create Kotlin-based instances of OmniPlayerFactory. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridOmniPlayerFactorySpec: HybridObject() { + // Properties + + + // Methods + @DoNotStrip + @Keep + abstract fun createPlayer(props: HybridOmniPlayerPropsSpec): HybridOmniPlayerSpec + + // Default implementation of `HybridObject.toString()` + override fun toString(): String { + return "[HybridObject OmniPlayerFactory]" + } + + // C++ backing class + @DoNotStrip + @Keep + protected open class CxxPart(javaPart: HybridOmniPlayerFactorySpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridOmniPlayerFactorySpec::CxxPart::initHybrid(...) + external override fun initHybrid(): HybridData + } + override fun createCxxPart(): CxxPart { + return CxxPart(this) + } + + companion object { + protected const val TAG = "HybridOmniPlayerFactorySpec" + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerPropsSpec.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerPropsSpec.kt new file mode 100644 index 0000000..043635e --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerPropsSpec.kt @@ -0,0 +1,80 @@ +/// +/// HybridOmniPlayerPropsSpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.HybridObject + +/** + * A Kotlin class representing the OmniPlayerProps HybridObject. + * Implement this abstract class to create Kotlin-based instances of OmniPlayerProps. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridOmniPlayerPropsSpec: HybridObject() { + // Properties + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var src: Array + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var startTime: Double? + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var subtitles: Array + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var metadata: Metadata? + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var mixAudio: MixAudioMode? + + // Methods + + + // Default implementation of `HybridObject.toString()` + override fun toString(): String { + return "[HybridObject OmniPlayerProps]" + } + + // C++ backing class + @DoNotStrip + @Keep + protected open class CxxPart(javaPart: HybridOmniPlayerPropsSpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridOmniPlayerPropsSpec::CxxPart::initHybrid(...) + external override fun initHybrid(): HybridData + } + override fun createCxxPart(): CxxPart { + return CxxPart(this) + } + + companion object { + protected const val TAG = "HybridOmniPlayerPropsSpec" + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt new file mode 100644 index 0000000..c67433b --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniPlayerSpec.kt @@ -0,0 +1,143 @@ +/// +/// HybridOmniPlayerSpec.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.NullType +import com.margelo.nitro.core.HybridObject + +/** + * A Kotlin class representing the OmniPlayer HybridObject. + * Implement this abstract class to create Kotlin-based instances of OmniPlayer. + */ +@DoNotStrip +@Keep +@Suppress( + "KotlinJniMissingFunction", "unused", + "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", + "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" +) +abstract class HybridOmniPlayerSpec: HybridObject() { + // Properties + @get:DoNotStrip + @get:Keep + abstract val hasPrev: Boolean + + @get:DoNotStrip + @get:Keep + abstract val hasNext: Boolean + + @get:DoNotStrip + @get:Keep + abstract val status: PlayerStatus + + @get:DoNotStrip + @get:Keep + abstract val isPlaying: Boolean + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var currentTime: Double + + @get:DoNotStrip + @get:Keep + abstract val buffered: Double + + @get:DoNotStrip + @get:Keep + abstract val duration: Double + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var playbackRate: Double + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var volume: Double + + @get:DoNotStrip + @get:Keep + abstract val videos: Array + + @get:DoNotStrip + @get:Keep + abstract val audios: Array + + @get:DoNotStrip + @get:Keep + abstract val subtitles: Array + + @get:DoNotStrip + @get:Keep + abstract val rendition: Array + + // Methods + @DoNotStrip + @Keep + abstract fun play(): Unit + + @DoNotStrip + @Keep + abstract fun pause(): Unit + + @DoNotStrip + @Keep + abstract fun seekBy(offset: Double): Unit + + @DoNotStrip + @Keep + abstract fun playPrev(): Unit + + @DoNotStrip + @Keep + abstract fun playNext(): Unit + + @DoNotStrip + @Keep + abstract fun selectVideo(video: Track): Unit + + @DoNotStrip + @Keep + abstract fun selectAudio(audio: Track): Unit + + @DoNotStrip + @Keep + abstract fun selectSubtitle(subtitle: Track): Unit + + @DoNotStrip + @Keep + abstract fun selectRendition(rendition: Variant_NullType_Rendition?): Unit + + // Default implementation of `HybridObject.toString()` + override fun toString(): String { + return "[HybridObject OmniPlayer]" + } + + // C++ backing class + @DoNotStrip + @Keep + protected open class CxxPart(javaPart: HybridOmniPlayerSpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridOmniPlayerSpec::CxxPart::initHybrid(...) + external override fun initHybrid(): HybridData + } + override fun createCxxPart(): CxxPart { + return CxxPart(this) + } + + companion object { + protected const val TAG = "HybridOmniPlayerSpec" + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniSpec.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt similarity index 63% rename from nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniSpec.kt rename to nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt index 116b007..b0534ff 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniSpec.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/HybridOmniViewSpec.kt @@ -1,5 +1,5 @@ /// -/// HybridOmniSpec.kt +/// HybridOmniViewSpec.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -14,8 +14,8 @@ import com.margelo.nitro.core.HybridObject import com.margelo.nitro.views.HybridView /** - * A Kotlin class representing the Omni HybridObject. - * Implement this abstract class to create Kotlin-based instances of Omni. + * A Kotlin class representing the OmniView HybridObject. + * Implement this abstract class to create Kotlin-based instances of OmniView. */ @DoNotStrip @Keep @@ -24,27 +24,39 @@ import com.margelo.nitro.views.HybridView "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet", "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName" ) -abstract class HybridOmniSpec: HybridView() { +abstract class HybridOmniViewSpec: HybridView() { // Properties @get:DoNotStrip @get:Keep @set:DoNotStrip @set:Keep - abstract var isRed: Boolean + abstract var autoplay: Boolean? + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var showNotification: Boolean? + + @get:DoNotStrip + @get:Keep + @set:DoNotStrip + @set:Keep + abstract var autoPip: Boolean? // Methods // Default implementation of `HybridObject.toString()` override fun toString(): String { - return "[HybridObject Omni]" + return "[HybridObject OmniView]" } // C++ backing class @DoNotStrip @Keep - protected open class CxxPart(javaPart: HybridOmniSpec): HybridObject.CxxPart(javaPart) { - // C++ JHybridOmniSpec::CxxPart::initHybrid(...) + protected open class CxxPart(javaPart: HybridOmniViewSpec): HybridObject.CxxPart(javaPart) { + // C++ JHybridOmniViewSpec::CxxPart::initHybrid(...) external override fun initHybrid(): HybridData } override fun createCxxPart(): CxxPart { @@ -52,6 +64,6 @@ abstract class HybridOmniSpec: HybridView() { } companion object { - protected const val TAG = "HybridOmniSpec" + protected const val TAG = "HybridOmniViewSpec" } } diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt new file mode 100644 index 0000000..fa6fd15 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Metadata.kt @@ -0,0 +1,53 @@ +/// +/// Metadata.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + + +/** + * Represents the JavaScript object/struct "Metadata". + */ +@DoNotStrip +@Keep +data class Metadata( + @DoNotStrip + @Keep + val title: String, + @DoNotStrip + @Keep + val album: String?, + @DoNotStrip + @Keep + val artist: String?, + @DoNotStrip + @Keep + val imageLink: String?, + @DoNotStrip + @Keep + val hasPrev: Boolean?, + @DoNotStrip + @Keep + val hasNext: Boolean? +) { + /* primary constructor */ + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(title: String, album: String?, artist: String?, imageLink: String?, hasPrev: Boolean?, hasNext: Boolean?): Metadata { + return Metadata(title, album, artist, imageLink, hasPrev, hasNext) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/MixAudioMode.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/MixAudioMode.kt new file mode 100644 index 0000000..e3f3628 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/MixAudioMode.kt @@ -0,0 +1,25 @@ +/// +/// MixAudioMode.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +/** + * Represents the JavaScript enum/union "MixAudioMode". + */ +@DoNotStrip +@Keep +enum class MixAudioMode(@DoNotStrip @Keep val value: Int) { + MIXWITHOTHERS(0), + DONOTMIX(1), + DUCKOTHERS(2), + AUTO(3); + + companion object +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PlayerStatus.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PlayerStatus.kt new file mode 100644 index 0000000..3dbe080 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/PlayerStatus.kt @@ -0,0 +1,25 @@ +/// +/// PlayerStatus.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + +/** + * Represents the JavaScript enum/union "PlayerStatus". + */ +@DoNotStrip +@Keep +enum class PlayerStatus(@DoNotStrip @Keep val value: Int) { + IDLE(0), + LOADING(1), + READYTOPLAY(2), + ERROR(3); + + companion object +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt new file mode 100644 index 0000000..f28867e --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Rendition.kt @@ -0,0 +1,50 @@ +/// +/// Rendition.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + + +/** + * Represents the JavaScript object/struct "Rendition". + */ +@DoNotStrip +@Keep +data class Rendition( + @DoNotStrip + @Keep + val id: String, + @DoNotStrip + @Keep + val width: Double, + @DoNotStrip + @Keep + val height: Double, + @DoNotStrip + @Keep + val bitrate: Double, + @DoNotStrip + @Keep + val selected: Boolean +) { + /* primary constructor */ + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(id: String, width: Double, height: Double, bitrate: Double, selected: Boolean): Rendition { + return Rendition(id, width, height, bitrate, selected) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt new file mode 100644 index 0000000..dd17173 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Subtitle.kt @@ -0,0 +1,50 @@ +/// +/// Subtitle.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + + +/** + * Represents the JavaScript object/struct "Subtitle". + */ +@DoNotStrip +@Keep +data class Subtitle( + @DoNotStrip + @Keep + val id: String, + @DoNotStrip + @Keep + val link: String, + @DoNotStrip + @Keep + val mimeType: String?, + @DoNotStrip + @Keep + val language: String?, + @DoNotStrip + @Keep + val label: String? +) { + /* primary constructor */ + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(id: String, link: String, mimeType: String?, language: String?, label: String?): Subtitle { + return Subtitle(id, link, mimeType, language, label) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt new file mode 100644 index 0000000..2e6acae --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Track.kt @@ -0,0 +1,47 @@ +/// +/// Track.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + + +/** + * Represents the JavaScript object/struct "Track". + */ +@DoNotStrip +@Keep +data class Track( + @DoNotStrip + @Keep + val id: String, + @DoNotStrip + @Keep + val label: String?, + @DoNotStrip + @Keep + val language: String?, + @DoNotStrip + @Keep + val selected: Boolean +) { + /* primary constructor */ + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(id: String, label: String?, language: String?, selected: Boolean): Track { + return Track(id, label, language, selected) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Variant_NullType_Rendition.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Variant_NullType_Rendition.kt new file mode 100644 index 0000000..20344d5 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/Variant_NullType_Rendition.kt @@ -0,0 +1,53 @@ +/// +/// Variant_NullType_Rendition.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import com.facebook.proguard.annotations.DoNotStrip +import com.margelo.nitro.core.NullType + +/** + * Represents the TypeScript variant "NullType | Rendition". + */ +@Suppress("ClassName") +@DoNotStrip +sealed class Variant_NullType_Rendition { + @DoNotStrip + data class First(@DoNotStrip val value: NullType): Variant_NullType_Rendition() + @DoNotStrip + data class Second(@DoNotStrip val value: Rendition): Variant_NullType_Rendition() + + val isFirst: Boolean + get() = this is First + val isSecond: Boolean + get() = this is Second + + fun asFirstOrNull(): NullType? { + val value = (this as? First)?.value ?: return null + return value + } + fun asSecondOrNull(): Rendition? { + val value = (this as? Second)?.value ?: return null + return value + } + + inline fun match(first: (NullType) -> R, second: (Rendition) -> R): R { + return when (this) { + is First -> first(value) + is Second -> second(value) + } + } + + companion object { + @JvmStatic + @DoNotStrip + fun create(value: NullType): Variant_NullType_Rendition = First(value) + @JvmStatic + @DoNotStrip + fun create(value: Rendition): Variant_NullType_Rendition = Second(value) + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt new file mode 100644 index 0000000..33bf810 --- /dev/null +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/VideoSrc.kt @@ -0,0 +1,44 @@ +/// +/// VideoSrc.kt +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +package com.margelo.nitro.omni + +import androidx.annotation.Keep +import com.facebook.proguard.annotations.DoNotStrip + + +/** + * Represents the JavaScript object/struct "VideoSrc". + */ +@DoNotStrip +@Keep +data class VideoSrc( + @DoNotStrip + @Keep + val uri: String, + @DoNotStrip + @Keep + val mimeType: String?, + @DoNotStrip + @Keep + val headers: Map +) { + /* primary constructor */ + + companion object { + /** + * Constructor called from C++ + */ + @DoNotStrip + @Keep + @Suppress("unused") + @JvmStatic + private fun fromCpp(uri: String, mimeType: String?, headers: Map): VideoSrc { + return VideoSrc(uri, mimeType, headers) + } + } +} diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniManager.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniViewManager.kt similarity index 79% rename from nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniManager.kt rename to nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniViewManager.kt index cc3515e..c179b45 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniManager.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniViewManager.kt @@ -1,5 +1,5 @@ /// -/// HybridOmniManager.kt +/// HybridOmniViewManager.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -17,22 +17,22 @@ import com.margelo.nitro.views.RecyclableView import dev.zoriya.omni.* /** - * Represents the React Native `ViewManager` for the "Omni" Nitro HybridView. + * Represents the React Native `ViewManager` for the "OmniView" Nitro HybridView. */ -public class HybridOmniManager: SimpleViewManager() { +public class HybridOmniViewManager: SimpleViewManager() { init { - if (RecyclableView::class.java.isAssignableFrom(HybridOmni::class.java)) { + if (RecyclableView::class.java.isAssignableFrom(OmniView::class.java)) { // Enable view recycling super.setupViewRecycling() } } override fun getName(): String { - return "Omni" + return "OmniView" } override fun createViewInstance(reactContext: ThemedReactContext): View { - val hybridView = HybridOmni(reactContext) + val hybridView = OmniView(reactContext) val view = hybridView.view view.setTag(associated_hybrid_view_tag, hybridView) return view @@ -44,7 +44,7 @@ public class HybridOmniManager: SimpleViewManager() { // 1. Update each prop individually hybridView.beforeUpdate() - HybridOmniStateUpdater.updateViewProps(hybridView, stateWrapper) + HybridOmniViewStateUpdater.updateViewProps(hybridView, stateWrapper) hybridView.afterUpdate() // 2. Continue in base View props @@ -74,7 +74,7 @@ public class HybridOmniManager: SimpleViewManager() { } } - private fun getHybridView(view: View): HybridOmni? { - return view.getTag(associated_hybrid_view_tag) as? HybridOmni + private fun getHybridView(view: View): OmniView? { + return view.getTag(associated_hybrid_view_tag) as? OmniView } } diff --git a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniStateUpdater.kt b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniViewStateUpdater.kt similarity index 76% rename from nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniStateUpdater.kt rename to nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniViewStateUpdater.kt index f649765..568affc 100644 --- a/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniStateUpdater.kt +++ b/nitrogen/generated/android/kotlin/com/margelo/nitro/omni/views/HybridOmniViewStateUpdater.kt @@ -1,5 +1,5 @@ /// -/// HybridOmniStateUpdater.kt +/// HybridOmniViewStateUpdater.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -10,7 +10,7 @@ package com.margelo.nitro.omni.views import com.facebook.react.uimanager.StateWrapper import com.margelo.nitro.omni.* -internal class HybridOmniStateUpdater { +internal class HybridOmniViewStateUpdater { companion object { /** * Updates the props for [view] through C++. @@ -18,6 +18,6 @@ internal class HybridOmniStateUpdater { */ @Suppress("KotlinJniMissingFunction") @JvmStatic - external fun updateViewProps(view: HybridOmniSpec, state: StateWrapper) + external fun updateViewProps(view: HybridOmniViewSpec, state: StateWrapper) } } diff --git a/nitrogen/generated/shared/c++/HybridOmniSpec.cpp b/nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.cpp similarity index 62% rename from nitrogen/generated/shared/c++/HybridOmniSpec.cpp rename to nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.cpp index 28e8447..930d476 100644 --- a/nitrogen/generated/shared/c++/HybridOmniSpec.cpp +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.cpp @@ -1,21 +1,20 @@ /// -/// HybridOmniSpec.cpp +/// HybridOmniPlayerFactorySpec.cpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// -#include "HybridOmniSpec.hpp" +#include "HybridOmniPlayerFactorySpec.hpp" namespace margelo::nitro::omni { - void HybridOmniSpec::loadHybridMethods() { + void HybridOmniPlayerFactorySpec::loadHybridMethods() { // load base methods/properties HybridObject::loadHybridMethods(); // load custom methods/properties registerHybrids(this, [](Prototype& prototype) { - prototype.registerHybridGetter("isRed", &HybridOmniSpec::getIsRed); - prototype.registerHybridSetter("isRed", &HybridOmniSpec::setIsRed); + prototype.registerHybridMethod("createPlayer", &HybridOmniPlayerFactorySpec::createPlayer); }); } diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.hpp b/nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.hpp new file mode 100644 index 0000000..3d13e63 --- /dev/null +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerFactorySpec.hpp @@ -0,0 +1,67 @@ +/// +/// HybridOmniPlayerFactorySpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `HybridOmniPlayerSpec` to properly resolve imports. +namespace margelo::nitro::omni { class HybridOmniPlayerSpec; } +// Forward declaration of `HybridOmniPlayerPropsSpec` to properly resolve imports. +namespace margelo::nitro::omni { class HybridOmniPlayerPropsSpec; } + +#include +#include "HybridOmniPlayerSpec.hpp" +#include "HybridOmniPlayerPropsSpec.hpp" + +namespace margelo::nitro::omni { + + using namespace margelo::nitro; + + /** + * An abstract base class for `OmniPlayerFactory` + * Inherit this class to create instances of `HybridOmniPlayerFactorySpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridOmniPlayerFactory: public HybridOmniPlayerFactorySpec { + * public: + * HybridOmniPlayerFactory(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridOmniPlayerFactorySpec: public virtual HybridObject { + public: + // Constructor + explicit HybridOmniPlayerFactorySpec(): HybridObject(TAG) { } + + // Destructor + ~HybridOmniPlayerFactorySpec() override = default; + + public: + // Properties + + + public: + // Methods + virtual std::shared_ptr createPlayer(const std::shared_ptr& props) = 0; + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "OmniPlayerFactory"; + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.cpp b/nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.cpp new file mode 100644 index 0000000..1b26368 --- /dev/null +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.cpp @@ -0,0 +1,30 @@ +/// +/// HybridOmniPlayerPropsSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "HybridOmniPlayerPropsSpec.hpp" + +namespace margelo::nitro::omni { + + void HybridOmniPlayerPropsSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("src", &HybridOmniPlayerPropsSpec::getSrc); + prototype.registerHybridSetter("src", &HybridOmniPlayerPropsSpec::setSrc); + prototype.registerHybridGetter("startTime", &HybridOmniPlayerPropsSpec::getStartTime); + prototype.registerHybridSetter("startTime", &HybridOmniPlayerPropsSpec::setStartTime); + prototype.registerHybridGetter("subtitles", &HybridOmniPlayerPropsSpec::getSubtitles); + prototype.registerHybridSetter("subtitles", &HybridOmniPlayerPropsSpec::setSubtitles); + prototype.registerHybridGetter("metadata", &HybridOmniPlayerPropsSpec::getMetadata); + prototype.registerHybridSetter("metadata", &HybridOmniPlayerPropsSpec::setMetadata); + prototype.registerHybridGetter("mixAudio", &HybridOmniPlayerPropsSpec::getMixAudio); + prototype.registerHybridSetter("mixAudio", &HybridOmniPlayerPropsSpec::setMixAudio); + }); + } + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.hpp b/nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.hpp new file mode 100644 index 0000000..42a8cb9 --- /dev/null +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerPropsSpec.hpp @@ -0,0 +1,83 @@ +/// +/// HybridOmniPlayerPropsSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `VideoSrc` to properly resolve imports. +namespace margelo::nitro::omni { struct VideoSrc; } +// Forward declaration of `Subtitle` to properly resolve imports. +namespace margelo::nitro::omni { struct Subtitle; } +// Forward declaration of `Metadata` to properly resolve imports. +namespace margelo::nitro::omni { struct Metadata; } +// Forward declaration of `MixAudioMode` to properly resolve imports. +namespace margelo::nitro::omni { enum class MixAudioMode; } + +#include "VideoSrc.hpp" +#include +#include +#include "Subtitle.hpp" +#include "Metadata.hpp" +#include "MixAudioMode.hpp" + +namespace margelo::nitro::omni { + + using namespace margelo::nitro; + + /** + * An abstract base class for `OmniPlayerProps` + * Inherit this class to create instances of `HybridOmniPlayerPropsSpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridOmniPlayerProps: public HybridOmniPlayerPropsSpec { + * public: + * HybridOmniPlayerProps(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridOmniPlayerPropsSpec: public virtual HybridObject { + public: + // Constructor + explicit HybridOmniPlayerPropsSpec(): HybridObject(TAG) { } + + // Destructor + ~HybridOmniPlayerPropsSpec() override = default; + + public: + // Properties + virtual std::vector getSrc() = 0; + virtual void setSrc(const std::vector& src) = 0; + virtual std::optional getStartTime() = 0; + virtual void setStartTime(std::optional startTime) = 0; + virtual std::vector getSubtitles() = 0; + virtual void setSubtitles(const std::vector& subtitles) = 0; + virtual std::optional getMetadata() = 0; + virtual void setMetadata(const std::optional& metadata) = 0; + virtual std::optional getMixAudio() = 0; + virtual void setMixAudio(std::optional mixAudio) = 0; + + public: + // Methods + + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "OmniPlayerProps"; + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp new file mode 100644 index 0000000..ad6cc41 --- /dev/null +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.cpp @@ -0,0 +1,45 @@ +/// +/// HybridOmniPlayerSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "HybridOmniPlayerSpec.hpp" + +namespace margelo::nitro::omni { + + void HybridOmniPlayerSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("hasPrev", &HybridOmniPlayerSpec::getHasPrev); + prototype.registerHybridGetter("hasNext", &HybridOmniPlayerSpec::getHasNext); + prototype.registerHybridGetter("status", &HybridOmniPlayerSpec::getStatus); + prototype.registerHybridGetter("isPlaying", &HybridOmniPlayerSpec::getIsPlaying); + prototype.registerHybridGetter("currentTime", &HybridOmniPlayerSpec::getCurrentTime); + prototype.registerHybridSetter("currentTime", &HybridOmniPlayerSpec::setCurrentTime); + prototype.registerHybridGetter("buffered", &HybridOmniPlayerSpec::getBuffered); + prototype.registerHybridGetter("duration", &HybridOmniPlayerSpec::getDuration); + prototype.registerHybridGetter("playbackRate", &HybridOmniPlayerSpec::getPlaybackRate); + prototype.registerHybridSetter("playbackRate", &HybridOmniPlayerSpec::setPlaybackRate); + prototype.registerHybridGetter("volume", &HybridOmniPlayerSpec::getVolume); + prototype.registerHybridSetter("volume", &HybridOmniPlayerSpec::setVolume); + prototype.registerHybridGetter("videos", &HybridOmniPlayerSpec::getVideos); + prototype.registerHybridGetter("audios", &HybridOmniPlayerSpec::getAudios); + prototype.registerHybridGetter("subtitles", &HybridOmniPlayerSpec::getSubtitles); + prototype.registerHybridGetter("rendition", &HybridOmniPlayerSpec::getRendition); + prototype.registerHybridMethod("play", &HybridOmniPlayerSpec::play); + prototype.registerHybridMethod("pause", &HybridOmniPlayerSpec::pause); + prototype.registerHybridMethod("seekBy", &HybridOmniPlayerSpec::seekBy); + prototype.registerHybridMethod("playPrev", &HybridOmniPlayerSpec::playPrev); + prototype.registerHybridMethod("playNext", &HybridOmniPlayerSpec::playNext); + prototype.registerHybridMethod("selectVideo", &HybridOmniPlayerSpec::selectVideo); + prototype.registerHybridMethod("selectAudio", &HybridOmniPlayerSpec::selectAudio); + prototype.registerHybridMethod("selectSubtitle", &HybridOmniPlayerSpec::selectSubtitle); + prototype.registerHybridMethod("selectRendition", &HybridOmniPlayerSpec::selectRendition); + }); + } + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp new file mode 100644 index 0000000..ed0a0f8 --- /dev/null +++ b/nitrogen/generated/shared/c++/HybridOmniPlayerSpec.hpp @@ -0,0 +1,96 @@ +/// +/// HybridOmniPlayerSpec.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +// Forward declaration of `PlayerStatus` to properly resolve imports. +namespace margelo::nitro::omni { enum class PlayerStatus; } +// Forward declaration of `Track` to properly resolve imports. +namespace margelo::nitro::omni { struct Track; } +// Forward declaration of `Rendition` to properly resolve imports. +namespace margelo::nitro::omni { struct Rendition; } + +#include "PlayerStatus.hpp" +#include "Track.hpp" +#include +#include "Rendition.hpp" +#include +#include +#include + +namespace margelo::nitro::omni { + + using namespace margelo::nitro; + + /** + * An abstract base class for `OmniPlayer` + * Inherit this class to create instances of `HybridOmniPlayerSpec` in C++. + * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. + * @example + * ```cpp + * class HybridOmniPlayer: public HybridOmniPlayerSpec { + * public: + * HybridOmniPlayer(...): HybridObject(TAG) { ... } + * // ... + * }; + * ``` + */ + class HybridOmniPlayerSpec: public virtual HybridObject { + public: + // Constructor + explicit HybridOmniPlayerSpec(): HybridObject(TAG) { } + + // Destructor + ~HybridOmniPlayerSpec() override = default; + + public: + // Properties + virtual bool getHasPrev() = 0; + virtual bool getHasNext() = 0; + virtual PlayerStatus getStatus() = 0; + virtual bool getIsPlaying() = 0; + virtual double getCurrentTime() = 0; + virtual void setCurrentTime(double currentTime) = 0; + virtual double getBuffered() = 0; + virtual double getDuration() = 0; + virtual double getPlaybackRate() = 0; + virtual void setPlaybackRate(double playbackRate) = 0; + virtual double getVolume() = 0; + virtual void setVolume(double volume) = 0; + virtual std::vector getVideos() = 0; + virtual std::vector getAudios() = 0; + virtual std::vector getSubtitles() = 0; + virtual std::vector getRendition() = 0; + + public: + // Methods + virtual void play() = 0; + virtual void pause() = 0; + virtual void seekBy(double offset) = 0; + virtual void playPrev() = 0; + virtual void playNext() = 0; + virtual void selectVideo(const Track& video) = 0; + virtual void selectAudio(const Track& audio) = 0; + virtual void selectSubtitle(const Track& subtitle) = 0; + virtual void selectRendition(const std::optional>& rendition) = 0; + + protected: + // Hybrid Setup + void loadHybridMethods() override; + + protected: + // Tag for logging + static constexpr auto TAG = "OmniPlayer"; + }; + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp b/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp new file mode 100644 index 0000000..a03b6ab --- /dev/null +++ b/nitrogen/generated/shared/c++/HybridOmniViewSpec.cpp @@ -0,0 +1,26 @@ +/// +/// HybridOmniViewSpec.cpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#include "HybridOmniViewSpec.hpp" + +namespace margelo::nitro::omni { + + void HybridOmniViewSpec::loadHybridMethods() { + // load base methods/properties + HybridObject::loadHybridMethods(); + // load custom methods/properties + registerHybrids(this, [](Prototype& prototype) { + prototype.registerHybridGetter("autoplay", &HybridOmniViewSpec::getAutoplay); + prototype.registerHybridSetter("autoplay", &HybridOmniViewSpec::setAutoplay); + prototype.registerHybridGetter("showNotification", &HybridOmniViewSpec::getShowNotification); + prototype.registerHybridSetter("showNotification", &HybridOmniViewSpec::setShowNotification); + prototype.registerHybridGetter("autoPip", &HybridOmniViewSpec::getAutoPip); + prototype.registerHybridSetter("autoPip", &HybridOmniViewSpec::setAutoPip); + }); + } + +} // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/HybridOmniSpec.hpp b/nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp similarity index 50% rename from nitrogen/generated/shared/c++/HybridOmniSpec.hpp rename to nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp index 35049db..081921c 100644 --- a/nitrogen/generated/shared/c++/HybridOmniSpec.hpp +++ b/nitrogen/generated/shared/c++/HybridOmniViewSpec.hpp @@ -1,5 +1,5 @@ /// -/// HybridOmniSpec.hpp +/// HybridOmniViewSpec.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo @@ -15,37 +15,41 @@ - +#include namespace margelo::nitro::omni { using namespace margelo::nitro; /** - * An abstract base class for `Omni` - * Inherit this class to create instances of `HybridOmniSpec` in C++. + * An abstract base class for `OmniView` + * Inherit this class to create instances of `HybridOmniViewSpec` in C++. * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual. * @example * ```cpp - * class HybridOmni: public HybridOmniSpec { + * class HybridOmniView: public HybridOmniViewSpec { * public: - * HybridOmni(...): HybridObject(TAG) { ... } + * HybridOmniView(...): HybridObject(TAG) { ... } * // ... * }; * ``` */ - class HybridOmniSpec: public virtual HybridObject { + class HybridOmniViewSpec: public virtual HybridObject { public: // Constructor - explicit HybridOmniSpec(): HybridObject(TAG) { } + explicit HybridOmniViewSpec(): HybridObject(TAG) { } // Destructor - ~HybridOmniSpec() override = default; + ~HybridOmniViewSpec() override = default; public: // Properties - virtual bool getIsRed() = 0; - virtual void setIsRed(bool isRed) = 0; + virtual std::optional getAutoplay() = 0; + virtual void setAutoplay(std::optional autoplay) = 0; + virtual std::optional getShowNotification() = 0; + virtual void setShowNotification(std::optional showNotification) = 0; + virtual std::optional getAutoPip() = 0; + virtual void setAutoPip(std::optional autoPip) = 0; public: // Methods @@ -57,7 +61,7 @@ namespace margelo::nitro::omni { protected: // Tag for logging - static constexpr auto TAG = "Omni"; + static constexpr auto TAG = "OmniView"; }; } // namespace margelo::nitro::omni diff --git a/nitrogen/generated/shared/c++/Metadata.hpp b/nitrogen/generated/shared/c++/Metadata.hpp new file mode 100644 index 0000000..1d3f163 --- /dev/null +++ b/nitrogen/generated/shared/c++/Metadata.hpp @@ -0,0 +1,104 @@ +/// +/// Metadata.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (Metadata). + */ + struct Metadata final { + public: + std::string title SWIFT_PRIVATE; + std::optional album SWIFT_PRIVATE; + std::optional artist SWIFT_PRIVATE; + std::optional imageLink SWIFT_PRIVATE; + std::optional hasPrev SWIFT_PRIVATE; + std::optional hasNext SWIFT_PRIVATE; + + public: + Metadata() = default; + explicit Metadata(std::string title, std::optional album, std::optional artist, std::optional imageLink, std::optional hasPrev, std::optional hasNext): title(title), album(album), artist(artist), imageLink(imageLink), hasPrev(hasPrev), hasNext(hasNext) {} + + public: + friend bool operator==(const Metadata& lhs, const Metadata& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ Metadata <> JS Metadata (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::Metadata fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::Metadata( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "album"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imageLink"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasPrev"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasNext"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::Metadata& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter::toJSI(runtime, arg.title)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "album"), JSIConverter>::toJSI(runtime, arg.album)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "artist"), JSIConverter>::toJSI(runtime, arg.artist)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "imageLink"), JSIConverter>::toJSI(runtime, arg.imageLink)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasPrev"), JSIConverter>::toJSI(runtime, arg.hasPrev)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasNext"), JSIConverter>::toJSI(runtime, arg.hasNext)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "album")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imageLink")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasPrev")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasNext")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/MixAudioMode.hpp b/nitrogen/generated/shared/c++/MixAudioMode.hpp new file mode 100644 index 0000000..28c011c --- /dev/null +++ b/nitrogen/generated/shared/c++/MixAudioMode.hpp @@ -0,0 +1,84 @@ +/// +/// MixAudioMode.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +namespace margelo::nitro::omni { + + /** + * An enum which can be represented as a JavaScript union (MixAudioMode). + */ + enum class MixAudioMode { + MIXWITHOTHERS SWIFT_NAME(mixwithothers) = 0, + DONOTMIX SWIFT_NAME(donotmix) = 1, + DUCKOTHERS SWIFT_NAME(duckothers) = 2, + AUTO SWIFT_NAME(auto) = 3, + } CLOSED_ENUM; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ MixAudioMode <> JS MixAudioMode (union) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::MixAudioMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + std::string unionValue = JSIConverter::fromJSI(runtime, arg); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("mixWithOthers"): return margelo::nitro::omni::MixAudioMode::MIXWITHOTHERS; + case hashString("doNotMix"): return margelo::nitro::omni::MixAudioMode::DONOTMIX; + case hashString("duckOthers"): return margelo::nitro::omni::MixAudioMode::DUCKOTHERS; + case hashString("auto"): return margelo::nitro::omni::MixAudioMode::AUTO; + default: [[unlikely]] + throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum MixAudioMode - invalid value!"); + } + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::omni::MixAudioMode arg) { + switch (arg) { + case margelo::nitro::omni::MixAudioMode::MIXWITHOTHERS: return JSIConverter::toJSI(runtime, "mixWithOthers"); + case margelo::nitro::omni::MixAudioMode::DONOTMIX: return JSIConverter::toJSI(runtime, "doNotMix"); + case margelo::nitro::omni::MixAudioMode::DUCKOTHERS: return JSIConverter::toJSI(runtime, "duckOthers"); + case margelo::nitro::omni::MixAudioMode::AUTO: return JSIConverter::toJSI(runtime, "auto"); + default: [[unlikely]] + throw std::invalid_argument("Cannot convert MixAudioMode to JS - invalid value: " + + std::to_string(static_cast(arg)) + "!"); + } + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isString()) { + return false; + } + std::string unionValue = JSIConverter::fromJSI(runtime, value); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("mixWithOthers"): + case hashString("doNotMix"): + case hashString("duckOthers"): + case hashString("auto"): + return true; + default: + return false; + } + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/PlayerStatus.hpp b/nitrogen/generated/shared/c++/PlayerStatus.hpp new file mode 100644 index 0000000..396ab05 --- /dev/null +++ b/nitrogen/generated/shared/c++/PlayerStatus.hpp @@ -0,0 +1,84 @@ +/// +/// PlayerStatus.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + +namespace margelo::nitro::omni { + + /** + * An enum which can be represented as a JavaScript union (PlayerStatus). + */ + enum class PlayerStatus { + IDLE SWIFT_NAME(idle) = 0, + LOADING SWIFT_NAME(loading) = 1, + READYTOPLAY SWIFT_NAME(readytoplay) = 2, + ERROR SWIFT_NAME(error) = 3, + } CLOSED_ENUM; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ PlayerStatus <> JS PlayerStatus (union) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::PlayerStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + std::string unionValue = JSIConverter::fromJSI(runtime, arg); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("idle"): return margelo::nitro::omni::PlayerStatus::IDLE; + case hashString("loading"): return margelo::nitro::omni::PlayerStatus::LOADING; + case hashString("readyToPlay"): return margelo::nitro::omni::PlayerStatus::READYTOPLAY; + case hashString("error"): return margelo::nitro::omni::PlayerStatus::ERROR; + default: [[unlikely]] + throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PlayerStatus - invalid value!"); + } + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::omni::PlayerStatus arg) { + switch (arg) { + case margelo::nitro::omni::PlayerStatus::IDLE: return JSIConverter::toJSI(runtime, "idle"); + case margelo::nitro::omni::PlayerStatus::LOADING: return JSIConverter::toJSI(runtime, "loading"); + case margelo::nitro::omni::PlayerStatus::READYTOPLAY: return JSIConverter::toJSI(runtime, "readyToPlay"); + case margelo::nitro::omni::PlayerStatus::ERROR: return JSIConverter::toJSI(runtime, "error"); + default: [[unlikely]] + throw std::invalid_argument("Cannot convert PlayerStatus to JS - invalid value: " + + std::to_string(static_cast(arg)) + "!"); + } + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isString()) { + return false; + } + std::string unionValue = JSIConverter::fromJSI(runtime, value); + switch (hashString(unionValue.c_str(), unionValue.size())) { + case hashString("idle"): + case hashString("loading"): + case hashString("readyToPlay"): + case hashString("error"): + return true; + default: + return false; + } + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/Rendition.hpp b/nitrogen/generated/shared/c++/Rendition.hpp new file mode 100644 index 0000000..4b6e2ad --- /dev/null +++ b/nitrogen/generated/shared/c++/Rendition.hpp @@ -0,0 +1,99 @@ +/// +/// Rendition.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (Rendition). + */ + struct Rendition final { + public: + std::string id SWIFT_PRIVATE; + double width SWIFT_PRIVATE; + double height SWIFT_PRIVATE; + double bitrate SWIFT_PRIVATE; + bool selected SWIFT_PRIVATE; + + public: + Rendition() = default; + explicit Rendition(std::string id, double width, double height, double bitrate, bool selected): id(id), width(width), height(height), bitrate(bitrate), selected(selected) {} + + public: + friend bool operator==(const Rendition& lhs, const Rendition& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ Rendition <> JS Rendition (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::Rendition fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::Rendition( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bitrate"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::Rendition& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter::toJSI(runtime, arg.id)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter::toJSI(runtime, arg.width)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter::toJSI(runtime, arg.height)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "bitrate"), JSIConverter::toJSI(runtime, arg.bitrate)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "selected"), JSIConverter::toJSI(runtime, arg.selected)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bitrate")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/Subtitle.hpp b/nitrogen/generated/shared/c++/Subtitle.hpp new file mode 100644 index 0000000..ce6d55e --- /dev/null +++ b/nitrogen/generated/shared/c++/Subtitle.hpp @@ -0,0 +1,100 @@ +/// +/// Subtitle.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (Subtitle). + */ + struct Subtitle final { + public: + std::string id SWIFT_PRIVATE; + std::string link SWIFT_PRIVATE; + std::optional mimeType SWIFT_PRIVATE; + std::optional language SWIFT_PRIVATE; + std::optional label SWIFT_PRIVATE; + + public: + Subtitle() = default; + explicit Subtitle(std::string id, std::string link, std::optional mimeType, std::optional language, std::optional label): id(id), link(link), mimeType(mimeType), language(language), label(label) {} + + public: + friend bool operator==(const Subtitle& lhs, const Subtitle& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ Subtitle <> JS Subtitle (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::Subtitle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::Subtitle( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "link"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "label"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::Subtitle& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter::toJSI(runtime, arg.id)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "link"), JSIConverter::toJSI(runtime, arg.link)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter>::toJSI(runtime, arg.mimeType)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "language"), JSIConverter>::toJSI(runtime, arg.language)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "label"), JSIConverter>::toJSI(runtime, arg.label)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "link")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "label")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/Track.hpp b/nitrogen/generated/shared/c++/Track.hpp new file mode 100644 index 0000000..8b130cd --- /dev/null +++ b/nitrogen/generated/shared/c++/Track.hpp @@ -0,0 +1,96 @@ +/// +/// Track.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (Track). + */ + struct Track final { + public: + std::string id SWIFT_PRIVATE; + std::optional label SWIFT_PRIVATE; + std::optional language SWIFT_PRIVATE; + bool selected SWIFT_PRIVATE; + + public: + Track() = default; + explicit Track(std::string id, std::optional label, std::optional language, bool selected): id(id), label(label), language(language), selected(selected) {} + + public: + friend bool operator==(const Track& lhs, const Track& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ Track <> JS Track (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::Track fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::Track( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "label"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language"))), + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::Track& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter::toJSI(runtime, arg.id)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "label"), JSIConverter>::toJSI(runtime, arg.label)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "language"), JSIConverter>::toJSI(runtime, arg.language)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "selected"), JSIConverter::toJSI(runtime, arg.selected)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "label")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "language")))) return false; + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selected")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/VideoSrc.hpp b/nitrogen/generated/shared/c++/VideoSrc.hpp new file mode 100644 index 0000000..c0c284f --- /dev/null +++ b/nitrogen/generated/shared/c++/VideoSrc.hpp @@ -0,0 +1,93 @@ +/// +/// VideoSrc.hpp +/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. +/// https://github.com/mrousavy/nitro +/// Copyright © Marc Rousavy @ Margelo +/// + +#pragma once + +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif +#if __has_include() +#include +#else +#error NitroModules cannot be found! Are you sure you installed NitroModules properly? +#endif + + + +#include +#include +#include + +namespace margelo::nitro::omni { + + /** + * A struct which can be represented as a JavaScript object (VideoSrc). + */ + struct VideoSrc final { + public: + std::string uri SWIFT_PRIVATE; + std::optional mimeType SWIFT_PRIVATE; + std::unordered_map headers SWIFT_PRIVATE; + + public: + VideoSrc() = default; + explicit VideoSrc(std::string uri, std::optional mimeType, std::unordered_map headers): uri(uri), mimeType(mimeType), headers(headers) {} + + public: + friend bool operator==(const VideoSrc& lhs, const VideoSrc& rhs) = default; + }; + +} // namespace margelo::nitro::omni + +namespace margelo::nitro { + + // C++ VideoSrc <> JS VideoSrc (object) + template <> + struct JSIConverter final { + static inline margelo::nitro::omni::VideoSrc fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { + jsi::Object obj = arg.asObject(runtime); + return margelo::nitro::omni::VideoSrc( + JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType"))), + JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers"))) + ); + } + static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::VideoSrc& arg) { + jsi::Object obj(runtime); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter::toJSI(runtime, arg.uri)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter>::toJSI(runtime, arg.mimeType)); + obj.setProperty(runtime, PropNameIDCache::get(runtime, "headers"), JSIConverter>::toJSI(runtime, arg.headers)); + return obj; + } + static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) { + if (!value.isObject()) { + return false; + } + jsi::Object obj = value.getObject(runtime); + if (!nitro::isPlainObject(runtime, obj)) { + return false; + } + if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) return false; + if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headers")))) return false; + return true; + } + }; + +} // namespace margelo::nitro diff --git a/nitrogen/generated/shared/c++/views/HybridOmniComponent.cpp b/nitrogen/generated/shared/c++/views/HybridOmniComponent.cpp deleted file mode 100644 index 5295ec2..0000000 --- a/nitrogen/generated/shared/c++/views/HybridOmniComponent.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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 { - try { - const react::RawValue* rawValue = rawProps.at("isRed", nullptr, nullptr); - if (rawValue == nullptr) return sourceProps.isRed; - const auto& [runtime, value] = (std::pair)*rawValue; - return CachedProp::fromRawValue(*runtime, value, sourceProps.isRed); - } catch (const std::exception& exc) { - throw std::runtime_error(std::string("Omni.isRed: ") + 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("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 HybridOmniComponentDescriptor::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 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(shadowNode); - const std::shared_ptr& constProps = concreteShadowNode.getConcreteSharedProps(); - const std::shared_ptr& props = std::const_pointer_cast(constProps); - HybridOmniState state{props}; - concreteShadowNode.setStateData(std::move(state)); - } -#endif - -} // namespace margelo::nitro::omni::views diff --git a/nitrogen/generated/shared/c++/views/HybridOmniComponent.hpp b/nitrogen/generated/shared/c++/views/HybridOmniComponent.hpp deleted file mode 100644 index 4042987..0000000 --- a/nitrogen/generated/shared/c++/views/HybridOmniComponent.hpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include "HybridOmniSpec.hpp" -#include -#include - -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 isRed; - CachedProp& /* 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& props): - _props(props) {} - - public: - [[nodiscard]] - const std::shared_ptr& 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 _props; - }; - - /** - * The Shadow Node for the "Omni" View. - */ - using HybridOmniShadowNode = react::ConcreteViewShadowNode; - - /** - * The Component Descriptor for the "Omni" View. - */ - class HybridOmniComponentDescriptor final: public react::ConcreteComponentDescriptor { - public: - explicit HybridOmniComponentDescriptor(const react::ComponentDescriptorParameters& parameters); - - public: - /** - * A faster path for cloning props - reuses the caching logic from `HybridOmniProps`. - */ - std::shared_ptr cloneProps(const react::PropsParserContext& context, - const std::shared_ptr& 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 diff --git a/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp new file mode 100644 index 0000000..0823a3a --- /dev/null +++ b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.cpp @@ -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 +#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), + 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()); + } + }()), + showNotification([&]() -> CachedProp> { + try { + const react::RawValue* rawValue = rawProps.at("showNotification", nullptr, nullptr); + if (rawValue == nullptr) return sourceProps.showNotification; + const auto& [runtime, value] = (std::pair)*rawValue; + return CachedProp>::fromRawValue(*runtime, value, sourceProps.showNotification); + } catch (const std::exception& exc) { + throw std::runtime_error(std::string("OmniView.showNotification: ") + 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()); + } + }()), + 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("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 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 diff --git a/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp new file mode 100644 index 0000000..7980c36 --- /dev/null +++ b/nitrogen/generated/shared/c++/views/HybridOmniViewComponent.hpp @@ -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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "HybridOmniViewSpec.hpp" +#include + +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> autoplay; + CachedProp> showNotification; + CachedProp> autoPip; + CachedProp& /* 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& props): + _props(props) {} + + public: + [[nodiscard]] + const std::shared_ptr& 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 _props; + }; + + /** + * The Shadow Node for the "OmniView" View. + */ + using HybridOmniViewShadowNode = react::ConcreteViewShadowNode; + + /** + * The Component Descriptor for the "OmniView" View. + */ + class HybridOmniViewComponentDescriptor final: public react::ConcreteComponentDescriptor { + public: + explicit HybridOmniViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters); + + public: + /** + * A faster path for cloning props - reuses the caching logic from `HybridOmniViewProps`. + */ + std::shared_ptr cloneProps(const react::PropsParserContext& context, + const std::shared_ptr& 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 diff --git a/nitrogen/generated/shared/json/OmniConfig.json b/nitrogen/generated/shared/json/OmniViewConfig.json similarity index 56% rename from nitrogen/generated/shared/json/OmniConfig.json rename to nitrogen/generated/shared/json/OmniViewConfig.json index e0baf1d..f5d4e3b 100644 --- a/nitrogen/generated/shared/json/OmniConfig.json +++ b/nitrogen/generated/shared/json/OmniViewConfig.json @@ -1,10 +1,12 @@ { - "uiViewClassName": "Omni", + "uiViewClassName": "OmniView", "supportsRawText": false, "bubblingEventTypes": {}, "directEventTypes": {}, "validAttributes": { - "isRed": true, + "autoplay": true, + "showNotification": true, + "autoPip": true, "hybridRef": true } } diff --git a/package.json b/package.json index 3a80923..400d328 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "typecheck": "tsc --noEmit", "build": "bun run typecheck && bob build", - "codegen": "nitrogen --logLevel=\"debug\" && bun run build && node post-script.js" + "codegen": "nitrogen --logLevel=\"debug\" && node post-script.js" }, "keywords": [ "react-native", diff --git a/src/index.ts b/src/index.ts deleted file mode 100755 index 9cc9f44..0000000 --- a/src/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { getHostComponent, type HybridRef } from "react-native-nitro-modules"; -import OmniConfig from "../nitrogen/generated/shared/json/OmniConfig.json"; -import type { OmniMethods, OmniProps } from "./specs/omni.nitro"; - -export const Omni = getHostComponent( - "Omni", - () => OmniConfig, -); - -export type OmniRef = HybridRef; diff --git a/src/provider.tsx b/src/provider.tsx new file mode 100755 index 0000000..69f2442 --- /dev/null +++ b/src/provider.tsx @@ -0,0 +1,25 @@ +import { createContext, type ReactNode, useContext } from "react"; +import { NitroModules } from "react-native-nitro-modules"; +import type { + OmniPlayerFactory, + OmniPlayerProps, +} from "./specs/omni-player.nitro"; +import type { OmniPlayer } from "./types/player"; + +const ProviderFactory = NitroModules.createHybridObject( + "OmniProviderFactory", +); + +const PlayerCtx = createContext(null!); + +export const OmniProvider = ({ + children, + ...props +}: OmniPlayerProps & { children: ReactNode }) => { + const player = ProviderFactory.createPlayer(props); + return {children}; +}; + +export const usePlayer = () => { + return useContext(PlayerCtx); +}; diff --git a/src/specs/omni-player.nitro.ts b/src/specs/omni-player.nitro.ts new file mode 100644 index 0000000..5c0aac0 --- /dev/null +++ b/src/specs/omni-player.nitro.ts @@ -0,0 +1,15 @@ +import type { HybridObject } from "react-native-nitro-modules"; +import type { OmniPlayer as OmniPlayerT } from "../types/player"; +import type { OmniPlayerProps as OmniPlayerPropsT } from "../types/provider"; + +export interface OmniPlayerProps + extends HybridObject<{ android: "kotlin" }>, + OmniPlayerPropsT {} + +export interface OmniPlayer + extends HybridObject<{ android: "kotlin" }>, + OmniPlayerT {} + +export interface OmniPlayerFactory extends HybridObject<{ android: "kotlin" }> { + createPlayer(props: OmniPlayerProps): OmniPlayer; +} diff --git a/src/specs/omni-view.nitro.ts b/src/specs/omni-view.nitro.ts new file mode 100644 index 0000000..1d6b3d6 --- /dev/null +++ b/src/specs/omni-view.nitro.ts @@ -0,0 +1,14 @@ +import type { + HybridView, + HybridViewMethods, + HybridViewProps, +} from "react-native-nitro-modules"; +import type { OmniViewProps } from "../types/view"; + +export interface Props extends HybridViewProps, OmniViewProps {} + +export type OmniView = HybridView< + Props, + HybridViewMethods, + { android: "kotlin" } +>; diff --git a/src/specs/omni.nitro.ts b/src/specs/omni.nitro.ts deleted file mode 100755 index d302eb2..0000000 --- a/src/specs/omni.nitro.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { - HybridView, - HybridViewMethods, - HybridViewProps, -} from "react-native-nitro-modules"; - -export interface OmniProps extends HybridViewProps { - isRed: boolean; -} - -export interface OmniMethods extends HybridViewMethods {} - -export type Omni = HybridView; diff --git a/src/types/events.ts b/src/types/events.ts new file mode 100644 index 0000000..19382fe --- /dev/null +++ b/src/types/events.ts @@ -0,0 +1,3 @@ +export interface OmniEvents { + onEnd: () => void; +} diff --git a/src/types/player.ts b/src/types/player.ts new file mode 100644 index 0000000..1cead0c --- /dev/null +++ b/src/types/player.ts @@ -0,0 +1,46 @@ +export interface OmniPlayer { + play(): void; + pause(): void; + seekBy(offset: number): void; + + // trigger the prev/next event manually, the user has to implement the event + playPrev(): void; + playNext(): void; + readonly hasPrev: boolean; + readonly hasNext: boolean; + + readonly status: PlayerStatus; + readonly isPlaying: boolean; + currentTime: number; + readonly buffered: number; + readonly duration: number; + playbackRate: number; + // between 0 and 1 + volume: number; + + readonly videos: Track[]; + selectVideo(video: Track): void; + readonly audios: Track[]; + selectAudio(audio: Track): void; + readonly subtitles: Track[]; + selectSubtitle(subtitle: Track): void; + readonly rendition: Rendition[]; + selectRendition(rendition: Rendition | null): void; +} + +export type PlayerStatus = "idle" | "loading" | "readyToPlay" | "error"; + +export interface Track { + id: string; + label?: string; + language?: string; + selected: boolean; +} + +export interface Rendition { + id: string; + width: number; + height: number; + bitrate: number; + selected: boolean; +} diff --git a/src/types/provider.ts b/src/types/provider.ts new file mode 100644 index 0000000..35703a2 --- /dev/null +++ b/src/types/provider.ts @@ -0,0 +1,35 @@ +export interface OmniPlayerProps { + src: VideoSrc[]; + startTime?: number; + subtitles: Subtitle[]; + metadata?: Metadata; + mixAudio?: MixAudioMode; +} + +export interface VideoSrc { + uri: string; + mimeType?: string; + // header sends with xhr requests (especially useful for HLS) + // might not be available depending on browser/platform. + headers: Record; +} + +export interface Subtitle { + id: string; + link: string; + mimeType?: string; + language?: string; + label?: string; +} + +export interface Metadata { + title: string; + album?: string; + artist?: string; + imageLink?: string; + // if one of those is true, the prev/next button will be there and a `onPrevSelected` even will be fired. + hasPrev?: boolean; + hasNext?: boolean; +} + +export type MixAudioMode = "mixWithOthers" | "doNotMix" | "duckOthers" | "auto"; diff --git a/src/types/view.ts b/src/types/view.ts new file mode 100644 index 0000000..abd1d43 --- /dev/null +++ b/src/types/view.ts @@ -0,0 +1,5 @@ +export interface OmniViewProps { + autoplay?: boolean; + showNotification?: boolean; + autoPip?: boolean; +} diff --git a/src/view.ts b/src/view.ts new file mode 100644 index 0000000..ded1b2c --- /dev/null +++ b/src/view.ts @@ -0,0 +1,10 @@ +import { getHostComponent, type HybridRef, type HybridViewMethods } from "react-native-nitro-modules"; +import OmniConfig from "../nitrogen/generated/shared/json/OmniViewConfig.json"; +import type { Props } from "./specs/omni-view.nitro"; + +export const OmniView = getHostComponent( + "OmniView", + () => OmniConfig, +); + +export type OmnViewiRef = HybridRef; diff --git a/tsconfig.json b/tsconfig.json index 07f80db..67fe5f5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "allowUnusedLabels": false, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "jsx": "react", + "jsx": "react-jsx", "lib": ["esnext"], "module": "esnext", "moduleResolution": "node",