74808f086e
* feat: Replace Legacy Media Controls with Nitro-Powered Playback * feat: Add TTS Engine Selection * chore: Remove User-Facing Error Reporting * refactor: Combine `Tts` and `TtsSession` Imports from `nitro-tts` Module --------- Co-authored-by: Claude <noreply@anthropic.com>
93 lines
4.0 KiB
C++
Generated
93 lines
4.0 KiB
C++
Generated
///
|
|
/// TtsPlaybackState.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(<NitroModules/NitroHash.hpp>)
|
|
#include <NitroModules/NitroHash.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
#include <NitroModules/JSIConverter.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
#include <NitroModules/NitroDefines.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
|
|
namespace margelo::nitro::nitrotts {
|
|
|
|
/**
|
|
* An enum which can be represented as a JavaScript union (TtsPlaybackState).
|
|
*/
|
|
enum class TtsPlaybackState {
|
|
IDLE SWIFT_NAME(idle) = 0,
|
|
LOADING SWIFT_NAME(loading) = 1,
|
|
PLAYING SWIFT_NAME(playing) = 2,
|
|
PAUSED SWIFT_NAME(paused) = 3,
|
|
COMPLETED SWIFT_NAME(completed) = 4,
|
|
ERROR SWIFT_NAME(error) = 5,
|
|
} CLOSED_ENUM;
|
|
|
|
} // namespace margelo::nitro::nitrotts
|
|
|
|
namespace margelo::nitro {
|
|
|
|
// C++ TtsPlaybackState <> JS TtsPlaybackState (union)
|
|
template <>
|
|
struct JSIConverter<margelo::nitro::nitrotts::TtsPlaybackState> final {
|
|
static inline margelo::nitro::nitrotts::TtsPlaybackState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
case hashString("idle"): return margelo::nitro::nitrotts::TtsPlaybackState::IDLE;
|
|
case hashString("loading"): return margelo::nitro::nitrotts::TtsPlaybackState::LOADING;
|
|
case hashString("playing"): return margelo::nitro::nitrotts::TtsPlaybackState::PLAYING;
|
|
case hashString("paused"): return margelo::nitro::nitrotts::TtsPlaybackState::PAUSED;
|
|
case hashString("completed"): return margelo::nitro::nitrotts::TtsPlaybackState::COMPLETED;
|
|
case hashString("error"): return margelo::nitro::nitrotts::TtsPlaybackState::ERROR;
|
|
default: [[unlikely]]
|
|
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum TtsPlaybackState - invalid value!");
|
|
}
|
|
}
|
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitrotts::TtsPlaybackState arg) {
|
|
switch (arg) {
|
|
case margelo::nitro::nitrotts::TtsPlaybackState::IDLE: return JSIConverter<std::string>::toJSI(runtime, "idle");
|
|
case margelo::nitro::nitrotts::TtsPlaybackState::LOADING: return JSIConverter<std::string>::toJSI(runtime, "loading");
|
|
case margelo::nitro::nitrotts::TtsPlaybackState::PLAYING: return JSIConverter<std::string>::toJSI(runtime, "playing");
|
|
case margelo::nitro::nitrotts::TtsPlaybackState::PAUSED: return JSIConverter<std::string>::toJSI(runtime, "paused");
|
|
case margelo::nitro::nitrotts::TtsPlaybackState::COMPLETED: return JSIConverter<std::string>::toJSI(runtime, "completed");
|
|
case margelo::nitro::nitrotts::TtsPlaybackState::ERROR: return JSIConverter<std::string>::toJSI(runtime, "error");
|
|
default: [[unlikely]]
|
|
throw std::invalid_argument("Cannot convert TtsPlaybackState to JS - invalid value: "
|
|
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
}
|
|
}
|
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
if (!value.isString()) {
|
|
return false;
|
|
}
|
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
case hashString("idle"):
|
|
case hashString("loading"):
|
|
case hashString("playing"):
|
|
case hashString("paused"):
|
|
case hashString("completed"):
|
|
case hashString("error"):
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace margelo::nitro
|