react-native-audio-concat 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/AudioConcat.podspec +2 -21
  2. package/README.md +3 -7
  3. package/android/build.gradle +2 -54
  4. package/android/src/main/java/com/{margelo/nitro/audioconcat/AudioConcat.kt → audioconcat/AudioConcatModule.kt} +73 -31
  5. package/android/src/main/java/com/audioconcat/AudioConcatPackage.kt +33 -0
  6. package/ios/AudioConcat.h +5 -0
  7. package/ios/AudioConcat.mm +104 -0
  8. package/lib/module/NativeAudioConcat.js +5 -0
  9. package/lib/module/NativeAudioConcat.js.map +1 -0
  10. package/lib/module/index.js +2 -28
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/src/NativeAudioConcat.d.ts +12 -0
  13. package/lib/typescript/src/NativeAudioConcat.d.ts.map +1 -0
  14. package/lib/typescript/src/index.d.ts +6 -27
  15. package/lib/typescript/src/index.d.ts.map +1 -1
  16. package/package.json +14 -18
  17. package/src/NativeAudioConcat.ts +12 -0
  18. package/src/index.tsx +4 -32
  19. package/android/CMakeLists.txt +0 -24
  20. package/android/src/main/cpp/cpp-adapter.cpp +0 -6
  21. package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcatPackage.kt +0 -22
  22. package/ios/AudioConcat.swift +0 -75
  23. package/lib/module/AudioConcat.nitro.js +0 -4
  24. package/lib/module/AudioConcat.nitro.js.map +0 -1
  25. package/lib/typescript/src/AudioConcat.nitro.d.ts +0 -16
  26. package/lib/typescript/src/AudioConcat.nitro.d.ts.map +0 -1
  27. package/nitro.json +0 -17
  28. package/nitrogen/generated/android/audioconcat+autolinking.cmake +0 -82
  29. package/nitrogen/generated/android/audioconcat+autolinking.gradle +0 -27
  30. package/nitrogen/generated/android/audioconcatOnLoad.cpp +0 -44
  31. package/nitrogen/generated/android/audioconcatOnLoad.hpp +0 -25
  32. package/nitrogen/generated/android/c++/JAudioData.hpp +0 -53
  33. package/nitrogen/generated/android/c++/JAudioDataOrSilence.cpp +0 -26
  34. package/nitrogen/generated/android/c++/JAudioDataOrSilence.hpp +0 -72
  35. package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.cpp +0 -77
  36. package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.hpp +0 -64
  37. package/nitrogen/generated/android/c++/JSilentData.hpp +0 -53
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioData.kt +0 -29
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioDataOrSilence.kt +0 -42
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/HybridAudioConcatSpec.kt +0 -52
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/SilentData.kt +0 -29
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/audioconcatOnLoad.kt +0 -35
  43. package/nitrogen/generated/ios/AudioConcat+autolinking.rb +0 -60
  44. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.cpp +0 -48
  45. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.hpp +0 -160
  46. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Umbrella.hpp +0 -53
  47. package/nitrogen/generated/ios/AudioConcatAutolinking.mm +0 -33
  48. package/nitrogen/generated/ios/AudioConcatAutolinking.swift +0 -25
  49. package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.cpp +0 -11
  50. package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.hpp +0 -81
  51. package/nitrogen/generated/ios/swift/AudioData.swift +0 -35
  52. package/nitrogen/generated/ios/swift/AudioDataOrSilence.swift +0 -18
  53. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -47
  54. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +0 -47
  55. package/nitrogen/generated/ios/swift/HybridAudioConcatSpec.swift +0 -49
  56. package/nitrogen/generated/ios/swift/HybridAudioConcatSpec_cxx.swift +0 -142
  57. package/nitrogen/generated/ios/swift/SilentData.swift +0 -35
  58. package/nitrogen/generated/shared/c++/AudioData.hpp +0 -67
  59. package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.cpp +0 -21
  60. package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.hpp +0 -70
  61. package/nitrogen/generated/shared/c++/SilentData.hpp +0 -67
  62. package/src/AudioConcat.nitro.ts +0 -19
@@ -1,77 +0,0 @@
1
- ///
2
- /// JHybridAudioConcatSpec.cpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #include "JHybridAudioConcatSpec.hpp"
9
-
10
- // Forward declaration of `AudioData` to properly resolve imports.
11
- namespace margelo::nitro::audioconcat { struct AudioData; }
12
- // Forward declaration of `SilentData` to properly resolve imports.
13
- namespace margelo::nitro::audioconcat { struct SilentData; }
14
-
15
- #include <string>
16
- #include <NitroModules/Promise.hpp>
17
- #include <NitroModules/JPromise.hpp>
18
- #include "AudioData.hpp"
19
- #include "SilentData.hpp"
20
- #include <variant>
21
- #include <vector>
22
- #include "JAudioDataOrSilence.hpp"
23
- #include "JAudioData.hpp"
24
- #include "JSilentData.hpp"
25
-
26
- namespace margelo::nitro::audioconcat {
27
-
28
- jni::local_ref<JHybridAudioConcatSpec::jhybriddata> JHybridAudioConcatSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
29
- return makeCxxInstance(jThis);
30
- }
31
-
32
- void JHybridAudioConcatSpec::registerNatives() {
33
- registerHybrid({
34
- makeNativeMethod("initHybrid", JHybridAudioConcatSpec::initHybrid),
35
- });
36
- }
37
-
38
- size_t JHybridAudioConcatSpec::getExternalMemorySize() noexcept {
39
- static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
40
- return method(_javaPart);
41
- }
42
-
43
- void JHybridAudioConcatSpec::dispose() noexcept {
44
- static const auto method = javaClassStatic()->getMethod<void()>("dispose");
45
- method(_javaPart);
46
- }
47
-
48
- // Properties
49
-
50
-
51
- // Methods
52
- std::shared_ptr<Promise<std::string>> JHybridAudioConcatSpec::concatAudioFiles(const std::vector<std::variant<AudioData, SilentData>>& data, const std::string& outputPath) {
53
- static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JArrayClass<JAudioDataOrSilence>> /* data */, jni::alias_ref<jni::JString> /* outputPath */)>("concatAudioFiles");
54
- auto __result = method(_javaPart, [&]() {
55
- size_t __size = data.size();
56
- jni::local_ref<jni::JArrayClass<JAudioDataOrSilence>> __array = jni::JArrayClass<JAudioDataOrSilence>::newArray(__size);
57
- for (size_t __i = 0; __i < __size; __i++) {
58
- const auto& __element = data[__i];
59
- __array->setElement(__i, *JAudioDataOrSilence::fromCpp(__element));
60
- }
61
- return __array;
62
- }(), jni::make_jstring(outputPath));
63
- return [&]() {
64
- auto __promise = Promise<std::string>::create();
65
- __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
66
- auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
67
- __promise->resolve(__result->toStdString());
68
- });
69
- __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
70
- jni::JniException __jniError(__throwable);
71
- __promise->reject(std::make_exception_ptr(__jniError));
72
- });
73
- return __promise;
74
- }();
75
- }
76
-
77
- } // namespace margelo::nitro::audioconcat
@@ -1,64 +0,0 @@
1
- ///
2
- /// HybridAudioConcatSpec.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <NitroModules/JHybridObject.hpp>
11
- #include <fbjni/fbjni.h>
12
- #include "HybridAudioConcatSpec.hpp"
13
-
14
-
15
-
16
-
17
- namespace margelo::nitro::audioconcat {
18
-
19
- using namespace facebook;
20
-
21
- class JHybridAudioConcatSpec: public jni::HybridClass<JHybridAudioConcatSpec, JHybridObject>,
22
- public virtual HybridAudioConcatSpec {
23
- public:
24
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audioconcat/HybridAudioConcatSpec;";
25
- static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
- static void registerNatives();
27
-
28
- protected:
29
- // C++ constructor (called from Java via `initHybrid()`)
30
- explicit JHybridAudioConcatSpec(jni::alias_ref<jhybridobject> jThis) :
31
- HybridObject(HybridAudioConcatSpec::TAG),
32
- HybridBase(jThis),
33
- _javaPart(jni::make_global(jThis)) {}
34
-
35
- public:
36
- ~JHybridAudioConcatSpec() override {
37
- // Hermes GC can destroy JS objects on a non-JNI Thread.
38
- jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
- }
40
-
41
- public:
42
- size_t getExternalMemorySize() noexcept override;
43
- void dispose() noexcept override;
44
-
45
- public:
46
- inline const jni::global_ref<JHybridAudioConcatSpec::javaobject>& getJavaPart() const noexcept {
47
- return _javaPart;
48
- }
49
-
50
- public:
51
- // Properties
52
-
53
-
54
- public:
55
- // Methods
56
- std::shared_ptr<Promise<std::string>> concatAudioFiles(const std::vector<std::variant<AudioData, SilentData>>& data, const std::string& outputPath) override;
57
-
58
- private:
59
- friend HybridBase;
60
- using HybridBase::HybridBase;
61
- jni::global_ref<JHybridAudioConcatSpec::javaobject> _javaPart;
62
- };
63
-
64
- } // namespace margelo::nitro::audioconcat
@@ -1,53 +0,0 @@
1
- ///
2
- /// JSilentData.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #include <fbjni/fbjni.h>
11
- #include "SilentData.hpp"
12
-
13
-
14
-
15
- namespace margelo::nitro::audioconcat {
16
-
17
- using namespace facebook;
18
-
19
- /**
20
- * The C++ JNI bridge between the C++ struct "SilentData" and the the Kotlin data class "SilentData".
21
- */
22
- struct JSilentData final: public jni::JavaClass<JSilentData> {
23
- public:
24
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/audioconcat/SilentData;";
25
-
26
- public:
27
- /**
28
- * Convert this Java/Kotlin-based struct to the C++ struct SilentData by copying all values to C++.
29
- */
30
- [[maybe_unused]]
31
- [[nodiscard]]
32
- SilentData toCpp() const {
33
- static const auto clazz = javaClassStatic();
34
- static const auto fieldDurationMs = clazz->getField<double>("durationMs");
35
- double durationMs = this->getFieldValue(fieldDurationMs);
36
- return SilentData(
37
- durationMs
38
- );
39
- }
40
-
41
- public:
42
- /**
43
- * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
44
- */
45
- [[maybe_unused]]
46
- static jni::local_ref<JSilentData::javaobject> fromCpp(const SilentData& value) {
47
- return newInstance(
48
- value.durationMs
49
- );
50
- }
51
- };
52
-
53
- } // namespace margelo::nitro::audioconcat
@@ -1,29 +0,0 @@
1
- ///
2
- /// AudioData.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audioconcat
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
-
14
-
15
- /**
16
- * Represents the JavaScript object/struct "AudioData".
17
- */
18
- @DoNotStrip
19
- @Keep
20
- data class AudioData
21
- @DoNotStrip
22
- @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val filePath: String
27
- ) {
28
- /* main constructor */
29
- }
@@ -1,42 +0,0 @@
1
- ///
2
- /// AudioDataOrSilence.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audioconcat
9
-
10
- import com.facebook.proguard.annotations.DoNotStrip
11
-
12
-
13
- /**
14
- * Represents the TypeScript variant "AudioData|SilentData".
15
- */
16
- @Suppress("ClassName")
17
- @DoNotStrip
18
- sealed class AudioDataOrSilence {
19
- @DoNotStrip
20
- data class First(@DoNotStrip val value: AudioData): AudioDataOrSilence()
21
- @DoNotStrip
22
- data class Second(@DoNotStrip val value: SilentData): AudioDataOrSilence()
23
-
24
- inline fun <reified T> getAs(): T? = when (this) {
25
- is First -> value as? T
26
- is Second -> value as? T
27
- }
28
-
29
- val isFirst: Boolean
30
- get() = this is First
31
- val isSecond: Boolean
32
- get() = this is Second
33
-
34
- companion object {
35
- @JvmStatic
36
- @DoNotStrip
37
- fun create(value: AudioData): AudioDataOrSilence = First(value)
38
- @JvmStatic
39
- @DoNotStrip
40
- fun create(value: SilentData): AudioDataOrSilence = Second(value)
41
- }
42
- }
@@ -1,52 +0,0 @@
1
- ///
2
- /// HybridAudioConcatSpec.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audioconcat
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.jni.HybridData
12
- import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
14
-
15
- /**
16
- * A Kotlin class representing the AudioConcat HybridObject.
17
- * Implement this abstract class to create Kotlin-based instances of AudioConcat.
18
- */
19
- @DoNotStrip
20
- @Keep
21
- @Suppress(
22
- "KotlinJniMissingFunction", "unused",
23
- "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
- "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
- )
26
- abstract class HybridAudioConcatSpec: HybridObject() {
27
- @DoNotStrip
28
- private var mHybridData: HybridData = initHybrid()
29
-
30
- init {
31
- super.updateNative(mHybridData)
32
- }
33
-
34
- override fun updateNative(hybridData: HybridData) {
35
- mHybridData = hybridData
36
- super.updateNative(hybridData)
37
- }
38
-
39
- // Properties
40
-
41
-
42
- // Methods
43
- @DoNotStrip
44
- @Keep
45
- abstract fun concatAudioFiles(data: Array<AudioDataOrSilence>, outputPath: String): Promise<String>
46
-
47
- private external fun initHybrid(): HybridData
48
-
49
- companion object {
50
- private const val TAG = "HybridAudioConcatSpec"
51
- }
52
- }
@@ -1,29 +0,0 @@
1
- ///
2
- /// SilentData.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audioconcat
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
-
14
-
15
- /**
16
- * Represents the JavaScript object/struct "SilentData".
17
- */
18
- @DoNotStrip
19
- @Keep
20
- data class SilentData
21
- @DoNotStrip
22
- @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val durationMs: Double
27
- ) {
28
- /* main constructor */
29
- }
@@ -1,35 +0,0 @@
1
- ///
2
- /// audioconcatOnLoad.kt
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- package com.margelo.nitro.audioconcat
9
-
10
- import android.util.Log
11
-
12
- internal class audioconcatOnLoad {
13
- companion object {
14
- private const val TAG = "audioconcatOnLoad"
15
- private var didLoad = false
16
- /**
17
- * Initializes the native part of "audioconcat".
18
- * This method is idempotent and can be called more than once.
19
- */
20
- @JvmStatic
21
- fun initializeNative() {
22
- if (didLoad) return
23
- try {
24
- Log.i(TAG, "Loading audioconcat C++ library...")
25
- System.loadLibrary("audioconcat")
26
- Log.i(TAG, "Successfully loaded audioconcat C++ library!")
27
- didLoad = true
28
- } catch (e: Error) {
29
- Log.e(TAG, "Failed to load audioconcat C++ library! Is it properly installed and linked? " +
30
- "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
- throw e
32
- }
33
- }
34
- }
35
- }
@@ -1,60 +0,0 @@
1
- #
2
- # AudioConcat+autolinking.rb
3
- # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- # https://github.com/mrousavy/nitro
5
- # Copyright © 2025 Marc Rousavy @ Margelo
6
- #
7
-
8
- # This is a Ruby script that adds all files generated by Nitrogen
9
- # to the given podspec.
10
- #
11
- # To use it, add this to your .podspec:
12
- # ```ruby
13
- # Pod::Spec.new do |spec|
14
- # # ...
15
- #
16
- # # Add all files generated by Nitrogen
17
- # load 'nitrogen/generated/ios/AudioConcat+autolinking.rb'
18
- # add_nitrogen_files(spec)
19
- # end
20
- # ```
21
-
22
- def add_nitrogen_files(spec)
23
- Pod::UI.puts "[NitroModules] 🔥 AudioConcat is boosted by nitro!"
24
-
25
- spec.dependency "NitroModules"
26
-
27
- current_source_files = Array(spec.attributes_hash['source_files'])
28
- spec.source_files = current_source_files + [
29
- # Generated cross-platform specs
30
- "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
- # Generated bridges for the cross-platform specs
32
- "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
- ]
34
-
35
- current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
- spec.public_header_files = current_public_header_files + [
37
- # Generated specs
38
- "nitrogen/generated/shared/**/*.{h,hpp}",
39
- # Swift to C++ bridging helpers
40
- "nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.hpp"
41
- ]
42
-
43
- current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
- spec.private_header_files = current_private_header_files + [
45
- # iOS specific specs
46
- "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
- # Views are framework-specific and should be private
48
- "nitrogen/generated/shared/**/views/**/*"
49
- ]
50
-
51
- current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
- spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
- # Use C++ 20
54
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
- # Enables C++ <-> Swift interop (by default it's only C)
56
- "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
- # Enables stricter modular headers
58
- "DEFINES_MODULE" => "YES",
59
- })
60
- end
@@ -1,48 +0,0 @@
1
- ///
2
- /// AudioConcat-Swift-Cxx-Bridge.cpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #include "AudioConcat-Swift-Cxx-Bridge.hpp"
9
-
10
- // Include C++ implementation defined types
11
- #include "AudioConcat-Swift-Cxx-Umbrella.hpp"
12
- #include "HybridAudioConcatSpecSwift.hpp"
13
-
14
- namespace margelo::nitro::audioconcat::bridge::swift {
15
-
16
- // pragma MARK: std::function<void(const std::string& /* result */)>
17
- Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
18
- auto swiftClosure = AudioConcat::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
19
- return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
20
- swiftClosure.call(result);
21
- };
22
- }
23
-
24
- // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
25
- Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
26
- auto swiftClosure = AudioConcat::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
27
- return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
28
- swiftClosure.call(error);
29
- };
30
- }
31
-
32
- // pragma MARK: std::shared_ptr<HybridAudioConcatSpec>
33
- std::shared_ptr<HybridAudioConcatSpec> create_std__shared_ptr_HybridAudioConcatSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
34
- AudioConcat::HybridAudioConcatSpec_cxx swiftPart = AudioConcat::HybridAudioConcatSpec_cxx::fromUnsafe(swiftUnsafePointer);
35
- return std::make_shared<margelo::nitro::audioconcat::HybridAudioConcatSpecSwift>(swiftPart);
36
- }
37
- void* NON_NULL get_std__shared_ptr_HybridAudioConcatSpec_(std__shared_ptr_HybridAudioConcatSpec_ cppType) noexcept {
38
- std::shared_ptr<margelo::nitro::audioconcat::HybridAudioConcatSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::audioconcat::HybridAudioConcatSpecSwift>(cppType);
39
- #ifdef NITRO_DEBUG
40
- if (swiftWrapper == nullptr) [[unlikely]] {
41
- throw std::runtime_error("Class \"HybridAudioConcatSpec\" is not implemented in Swift!");
42
- }
43
- #endif
44
- AudioConcat::HybridAudioConcatSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
45
- return swiftPart.toUnsafe();
46
- }
47
-
48
- } // namespace margelo::nitro::audioconcat::bridge::swift
@@ -1,160 +0,0 @@
1
- ///
2
- /// AudioConcat-Swift-Cxx-Bridge.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- // Forward declarations of C++ defined types
11
- // Forward declaration of `AudioData` to properly resolve imports.
12
- namespace margelo::nitro::audioconcat { struct AudioData; }
13
- // Forward declaration of `HybridAudioConcatSpec` to properly resolve imports.
14
- namespace margelo::nitro::audioconcat { class HybridAudioConcatSpec; }
15
- // Forward declaration of `SilentData` to properly resolve imports.
16
- namespace margelo::nitro::audioconcat { struct SilentData; }
17
-
18
- // Forward declarations of Swift defined types
19
- // Forward declaration of `HybridAudioConcatSpec_cxx` to properly resolve imports.
20
- namespace AudioConcat { class HybridAudioConcatSpec_cxx; }
21
-
22
- // Include C++ defined types
23
- #include "AudioData.hpp"
24
- #include "HybridAudioConcatSpec.hpp"
25
- #include "SilentData.hpp"
26
- #include <NitroModules/FastVectorCopy.hpp>
27
- #include <NitroModules/Promise.hpp>
28
- #include <NitroModules/PromiseHolder.hpp>
29
- #include <NitroModules/Result.hpp>
30
- #include <exception>
31
- #include <functional>
32
- #include <memory>
33
- #include <string>
34
- #include <variant>
35
- #include <vector>
36
-
37
- /**
38
- * Contains specialized versions of C++ templated types so they can be accessed from Swift,
39
- * as well as helper functions to interact with those C++ types from Swift.
40
- */
41
- namespace margelo::nitro::audioconcat::bridge::swift {
42
-
43
- // pragma MARK: std::shared_ptr<Promise<std::string>>
44
- /**
45
- * Specialized version of `std::shared_ptr<Promise<std::string>>`.
46
- */
47
- using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
48
- inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
49
- return Promise<std::string>::create();
50
- }
51
- inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
52
- return PromiseHolder<std::string>(std::move(promise));
53
- }
54
-
55
- // pragma MARK: std::function<void(const std::string& /* result */)>
56
- /**
57
- * Specialized version of `std::function<void(const std::string&)>`.
58
- */
59
- using Func_void_std__string = std::function<void(const std::string& /* result */)>;
60
- /**
61
- * Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
62
- */
63
- class Func_void_std__string_Wrapper final {
64
- public:
65
- explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* result */)>>(std::move(func))) {}
66
- inline void call(std::string result) const noexcept {
67
- _function->operator()(result);
68
- }
69
- private:
70
- std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
71
- } SWIFT_NONCOPYABLE;
72
- Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
73
- inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
74
- return Func_void_std__string_Wrapper(std::move(value));
75
- }
76
-
77
- // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
78
- /**
79
- * Specialized version of `std::function<void(const std::exception_ptr&)>`.
80
- */
81
- using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
82
- /**
83
- * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
84
- */
85
- class Func_void_std__exception_ptr_Wrapper final {
86
- public:
87
- explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
88
- inline void call(std::exception_ptr error) const noexcept {
89
- _function->operator()(error);
90
- }
91
- private:
92
- std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
93
- } SWIFT_NONCOPYABLE;
94
- Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
95
- inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
96
- return Func_void_std__exception_ptr_Wrapper(std::move(value));
97
- }
98
-
99
- // pragma MARK: std::variant<AudioData, SilentData>
100
- /**
101
- * Wrapper struct for `std::variant<AudioData, SilentData>`.
102
- * std::variant cannot be used in Swift because of a Swift bug.
103
- * Not even specializing it works. So we create a wrapper struct.
104
- */
105
- struct std__variant_AudioData__SilentData_ {
106
- std::variant<AudioData, SilentData> variant;
107
- std__variant_AudioData__SilentData_(std::variant<AudioData, SilentData> variant): variant(variant) { }
108
- operator std::variant<AudioData, SilentData>() const noexcept {
109
- return variant;
110
- }
111
- inline size_t index() const noexcept {
112
- return variant.index();
113
- }
114
- inline AudioData get_0() const noexcept {
115
- return std::get<0>(variant);
116
- }
117
- inline SilentData get_1() const noexcept {
118
- return std::get<1>(variant);
119
- }
120
- };
121
- inline std__variant_AudioData__SilentData_ create_std__variant_AudioData__SilentData_(const AudioData& value) noexcept {
122
- return std__variant_AudioData__SilentData_(value);
123
- }
124
- inline std__variant_AudioData__SilentData_ create_std__variant_AudioData__SilentData_(const SilentData& value) noexcept {
125
- return std__variant_AudioData__SilentData_(value);
126
- }
127
-
128
- // pragma MARK: std::vector<std::variant<AudioData, SilentData>>
129
- /**
130
- * Specialized version of `std::vector<std::variant<AudioData, SilentData>>`.
131
- */
132
- using std__vector_std__variant_AudioData__SilentData__ = std::vector<std::variant<AudioData, SilentData>>;
133
- inline std::vector<std::variant<AudioData, SilentData>> create_std__vector_std__variant_AudioData__SilentData__(size_t size) noexcept {
134
- std::vector<std::variant<AudioData, SilentData>> vector;
135
- vector.reserve(size);
136
- return vector;
137
- }
138
-
139
- // pragma MARK: std::shared_ptr<HybridAudioConcatSpec>
140
- /**
141
- * Specialized version of `std::shared_ptr<HybridAudioConcatSpec>`.
142
- */
143
- using std__shared_ptr_HybridAudioConcatSpec_ = std::shared_ptr<HybridAudioConcatSpec>;
144
- std::shared_ptr<HybridAudioConcatSpec> create_std__shared_ptr_HybridAudioConcatSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
145
- void* NON_NULL get_std__shared_ptr_HybridAudioConcatSpec_(std__shared_ptr_HybridAudioConcatSpec_ cppType) noexcept;
146
-
147
- // pragma MARK: std::weak_ptr<HybridAudioConcatSpec>
148
- using std__weak_ptr_HybridAudioConcatSpec_ = std::weak_ptr<HybridAudioConcatSpec>;
149
- inline std__weak_ptr_HybridAudioConcatSpec_ weakify_std__shared_ptr_HybridAudioConcatSpec_(const std::shared_ptr<HybridAudioConcatSpec>& strong) noexcept { return strong; }
150
-
151
- // pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
152
- using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
153
- inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
154
- return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
155
- }
156
- inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
157
- return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
158
- }
159
-
160
- } // namespace margelo::nitro::audioconcat::bridge::swift