react-native-nitro-audio-record 0.1.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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/NitroAudioRecord.podspec +33 -0
  3. package/README.md +92 -0
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +148 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/nitroaudiorecord/HybridNitroAudioRecord.kt +189 -0
  11. package/android/src/main/java/com/nitroaudiorecord/NitroAudioRecordPackage.kt +20 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/HybridNitroAudioRecord.swift +108 -0
  14. package/lib/commonjs/index.js +9 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/nitro-audio-record.nitro.js +6 -0
  18. package/lib/commonjs/specs/nitro-audio-record.nitro.js.map +1 -0
  19. package/lib/module/index.js +5 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/specs/nitro-audio-record.nitro.js +4 -0
  22. package/lib/module/specs/nitro-audio-record.nitro.js.map +1 -0
  23. package/lib/typescript/src/index.d.ts +3 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/lib/typescript/src/specs/nitro-audio-record.nitro.d.ts +18 -0
  26. package/lib/typescript/src/specs/nitro-audio-record.nitro.d.ts.map +1 -0
  27. package/nitro.json +30 -0
  28. package/nitrogen/generated/.gitattributes +1 -0
  29. package/nitrogen/generated/android/NitroAudioRecord+autolinking.cmake +81 -0
  30. package/nitrogen/generated/android/NitroAudioRecord+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/NitroAudioRecordOnLoad.cpp +56 -0
  32. package/nitrogen/generated/android/NitroAudioRecordOnLoad.hpp +34 -0
  33. package/nitrogen/generated/android/c++/JAudioRecordOptions.hpp +74 -0
  34. package/nitrogen/generated/android/c++/JFunc_void_std__shared_ptr_ArrayBuffer_.hpp +77 -0
  35. package/nitrogen/generated/android/c++/JHybridNitroAudioRecordSpec.cpp +87 -0
  36. package/nitrogen/generated/android/c++/JHybridNitroAudioRecordSpec.hpp +66 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroaudiorecord/AudioRecordOptions.kt +50 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroaudiorecord/Func_void_std__shared_ptr_ArrayBuffer_.kt +80 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroaudiorecord/HybridNitroAudioRecordSpec.kt +73 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroaudiorecord/NitroAudioRecordOnLoad.kt +35 -0
  41. package/nitrogen/generated/ios/NitroAudioRecord+autolinking.rb +60 -0
  42. package/nitrogen/generated/ios/NitroAudioRecord-Swift-Cxx-Bridge.cpp +57 -0
  43. package/nitrogen/generated/ios/NitroAudioRecord-Swift-Cxx-Bridge.hpp +177 -0
  44. package/nitrogen/generated/ios/NitroAudioRecord-Swift-Cxx-Umbrella.hpp +51 -0
  45. package/nitrogen/generated/ios/NitroAudioRecordAutolinking.mm +33 -0
  46. package/nitrogen/generated/ios/NitroAudioRecordAutolinking.swift +26 -0
  47. package/nitrogen/generated/ios/c++/HybridNitroAudioRecordSpecSwift.cpp +11 -0
  48. package/nitrogen/generated/ios/c++/HybridNitroAudioRecordSpecSwift.hpp +109 -0
  49. package/nitrogen/generated/ios/swift/AudioRecordOptions.swift +75 -0
  50. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  51. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_ArrayBuffer_.swift +46 -0
  52. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  53. package/nitrogen/generated/ios/swift/HybridNitroAudioRecordSpec.swift +58 -0
  54. package/nitrogen/generated/ios/swift/HybridNitroAudioRecordSpec_cxx.swift +183 -0
  55. package/nitrogen/generated/shared/c++/AudioRecordOptions.hpp +100 -0
  56. package/nitrogen/generated/shared/c++/HybridNitroAudioRecordSpec.cpp +24 -0
  57. package/nitrogen/generated/shared/c++/HybridNitroAudioRecordSpec.hpp +70 -0
  58. package/package.json +123 -0
  59. package/src/index.ts +5 -0
  60. package/src/specs/nitro-audio-record.nitro.ts +17 -0
@@ -0,0 +1,66 @@
1
+ ///
2
+ /// HybridNitroAudioRecordSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridNitroAudioRecordSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::nitroaudiorecord {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridNitroAudioRecordSpec: public virtual HybridNitroAudioRecordSpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroaudiorecord/HybridNitroAudioRecordSpec;";
25
+ std::shared_ptr<JHybridNitroAudioRecordSpec> getJHybridNitroAudioRecordSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroaudiorecord/HybridNitroAudioRecordSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridNitroAudioRecordSpec(const jni::local_ref<JHybridNitroAudioRecordSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridNitroAudioRecordSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridNitroAudioRecordSpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridNitroAudioRecordSpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ void setup(const AudioRecordOptions& options) override;
58
+ void start() override;
59
+ std::shared_ptr<Promise<std::string>> stop() override;
60
+ void onData(const std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>& callback) override;
61
+
62
+ private:
63
+ jni::global_ref<JHybridNitroAudioRecordSpec::JavaPart> _javaPart;
64
+ };
65
+
66
+ } // namespace margelo::nitro::nitroaudiorecord
@@ -0,0 +1,50 @@
1
+ ///
2
+ /// AudioRecordOptions.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitroaudiorecord
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "AudioRecordOptions".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class AudioRecordOptions(
20
+ @DoNotStrip
21
+ @Keep
22
+ val sampleRate: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val channels: Double,
26
+ @DoNotStrip
27
+ @Keep
28
+ val bitsPerSample: Double,
29
+ @DoNotStrip
30
+ @Keep
31
+ val audioSource: Double?,
32
+ @DoNotStrip
33
+ @Keep
34
+ val wavFile: String?
35
+ ) {
36
+ /* primary constructor */
37
+
38
+ companion object {
39
+ /**
40
+ * Constructor called from C++
41
+ */
42
+ @DoNotStrip
43
+ @Keep
44
+ @Suppress("unused")
45
+ @JvmStatic
46
+ private fun fromCpp(sampleRate: Double, channels: Double, bitsPerSample: Double, audioSource: Double?, wavFile: String?): AudioRecordOptions {
47
+ return AudioRecordOptions(sampleRate, channels, bitsPerSample, audioSource, wavFile)
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_std__shared_ptr_ArrayBuffer_.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitroaudiorecord
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+ import com.margelo.nitro.core.ArrayBuffer
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(data: array-buffer) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_std__shared_ptr_ArrayBuffer_: (ArrayBuffer) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(data: ArrayBuffer): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(data: array-buffer) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_std__shared_ptr_ArrayBuffer__cxx: Func_void_std__shared_ptr_ArrayBuffer_ {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(data: ArrayBuffer): Unit
60
+ = invoke_cxx(data)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(data: ArrayBuffer): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(data: array-buffer) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(ArrayBuffer) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_std__shared_ptr_ArrayBuffer__java(private val function: (ArrayBuffer) -> Unit): Func_void_std__shared_ptr_ArrayBuffer_ {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(data: ArrayBuffer): Unit {
78
+ return this.function(data)
79
+ }
80
+ }
@@ -0,0 +1,73 @@
1
+ ///
2
+ /// HybridNitroAudioRecordSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitroaudiorecord
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.Promise
14
+ import com.margelo.nitro.core.ArrayBuffer
15
+ import com.margelo.nitro.core.HybridObject
16
+
17
+ /**
18
+ * A Kotlin class representing the NitroAudioRecord HybridObject.
19
+ * Implement this abstract class to create Kotlin-based instances of NitroAudioRecord.
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress(
24
+ "KotlinJniMissingFunction", "unused",
25
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
26
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
27
+ )
28
+ abstract class HybridNitroAudioRecordSpec: HybridObject() {
29
+ // Properties
30
+
31
+
32
+ // Methods
33
+ @DoNotStrip
34
+ @Keep
35
+ abstract fun setup(options: AudioRecordOptions): Unit
36
+
37
+ @DoNotStrip
38
+ @Keep
39
+ abstract fun start(): Unit
40
+
41
+ @DoNotStrip
42
+ @Keep
43
+ abstract fun stop(): Promise<String>
44
+
45
+ abstract fun onData(callback: (data: ArrayBuffer) -> Unit): Unit
46
+
47
+ @DoNotStrip
48
+ @Keep
49
+ private fun onData_cxx(callback: Func_void_std__shared_ptr_ArrayBuffer_): Unit {
50
+ val __result = onData(callback)
51
+ return __result
52
+ }
53
+
54
+ // Default implementation of `HybridObject.toString()`
55
+ override fun toString(): String {
56
+ return "[HybridObject NitroAudioRecord]"
57
+ }
58
+
59
+ // C++ backing class
60
+ @DoNotStrip
61
+ @Keep
62
+ protected open class CxxPart(javaPart: HybridNitroAudioRecordSpec): HybridObject.CxxPart(javaPart) {
63
+ // C++ JHybridNitroAudioRecordSpec::CxxPart::initHybrid(...)
64
+ external override fun initHybrid(): HybridData
65
+ }
66
+ override fun createCxxPart(): CxxPart {
67
+ return CxxPart(this)
68
+ }
69
+
70
+ companion object {
71
+ protected const val TAG = "HybridNitroAudioRecordSpec"
72
+ }
73
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// NitroAudioRecordOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitroaudiorecord
9
+
10
+ import android.util.Log
11
+
12
+ internal class NitroAudioRecordOnLoad {
13
+ companion object {
14
+ private const val TAG = "NitroAudioRecordOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "NitroAudioRecord".
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 NitroAudioRecord C++ library...")
25
+ System.loadLibrary("NitroAudioRecord")
26
+ Log.i(TAG, "Successfully loaded NitroAudioRecord C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load NitroAudioRecord 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
+ }
@@ -0,0 +1,60 @@
1
+ #
2
+ # NitroAudioRecord+autolinking.rb
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 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/NitroAudioRecord+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 NitroAudioRecord 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/NitroAudioRecord-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 ObjC)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ })
60
+ end
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// NitroAudioRecord-Swift-Cxx-Bridge.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "NitroAudioRecord-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridNitroAudioRecordSpecSwift.hpp"
12
+ #include "NitroAudioRecord-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::nitroaudiorecord::bridge::swift {
16
+
17
+ // pragma MARK: std::function<void(const std::string& /* result */)>
18
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
19
+ auto swiftClosure = NitroAudioRecord::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
20
+ return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
21
+ swiftClosure.call(result);
22
+ };
23
+ }
24
+
25
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
26
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
27
+ auto swiftClosure = NitroAudioRecord::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
28
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
29
+ swiftClosure.call(error);
30
+ };
31
+ }
32
+
33
+ // pragma MARK: std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>
34
+ Func_void_std__shared_ptr_ArrayBuffer_ create_Func_void_std__shared_ptr_ArrayBuffer_(void* NON_NULL swiftClosureWrapper) noexcept {
35
+ auto swiftClosure = NitroAudioRecord::Func_void_std__shared_ptr_ArrayBuffer_::fromUnsafe(swiftClosureWrapper);
36
+ return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<ArrayBuffer>& data) mutable -> void {
37
+ swiftClosure.call(ArrayBufferHolder(data));
38
+ };
39
+ }
40
+
41
+ // pragma MARK: std::shared_ptr<HybridNitroAudioRecordSpec>
42
+ std::shared_ptr<HybridNitroAudioRecordSpec> create_std__shared_ptr_HybridNitroAudioRecordSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
43
+ NitroAudioRecord::HybridNitroAudioRecordSpec_cxx swiftPart = NitroAudioRecord::HybridNitroAudioRecordSpec_cxx::fromUnsafe(swiftUnsafePointer);
44
+ return std::make_shared<margelo::nitro::nitroaudiorecord::HybridNitroAudioRecordSpecSwift>(swiftPart);
45
+ }
46
+ void* NON_NULL get_std__shared_ptr_HybridNitroAudioRecordSpec_(std__shared_ptr_HybridNitroAudioRecordSpec_ cppType) {
47
+ std::shared_ptr<margelo::nitro::nitroaudiorecord::HybridNitroAudioRecordSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitroaudiorecord::HybridNitroAudioRecordSpecSwift>(cppType);
48
+ #ifdef NITRO_DEBUG
49
+ if (swiftWrapper == nullptr) [[unlikely]] {
50
+ throw std::runtime_error("Class \"HybridNitroAudioRecordSpec\" is not implemented in Swift!");
51
+ }
52
+ #endif
53
+ NitroAudioRecord::HybridNitroAudioRecordSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
54
+ return swiftPart.toUnsafe();
55
+ }
56
+
57
+ } // namespace margelo::nitro::nitroaudiorecord::bridge::swift
@@ -0,0 +1,177 @@
1
+ ///
2
+ /// NitroAudioRecord-Swift-Cxx-Bridge.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
12
+ namespace NitroModules { class ArrayBufferHolder; }
13
+ // Forward declaration of `HybridNitroAudioRecordSpec` to properly resolve imports.
14
+ namespace margelo::nitro::nitroaudiorecord { class HybridNitroAudioRecordSpec; }
15
+
16
+ // Forward declarations of Swift defined types
17
+ // Forward declaration of `HybridNitroAudioRecordSpec_cxx` to properly resolve imports.
18
+ namespace NitroAudioRecord { class HybridNitroAudioRecordSpec_cxx; }
19
+
20
+ // Include C++ defined types
21
+ #include "HybridNitroAudioRecordSpec.hpp"
22
+ #include <NitroModules/ArrayBuffer.hpp>
23
+ #include <NitroModules/ArrayBufferHolder.hpp>
24
+ #include <NitroModules/Promise.hpp>
25
+ #include <NitroModules/PromiseHolder.hpp>
26
+ #include <NitroModules/Result.hpp>
27
+ #include <exception>
28
+ #include <functional>
29
+ #include <memory>
30
+ #include <optional>
31
+ #include <string>
32
+
33
+ /**
34
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
35
+ * as well as helper functions to interact with those C++ types from Swift.
36
+ */
37
+ namespace margelo::nitro::nitroaudiorecord::bridge::swift {
38
+
39
+ // pragma MARK: std::optional<double>
40
+ /**
41
+ * Specialized version of `std::optional<double>`.
42
+ */
43
+ using std__optional_double_ = std::optional<double>;
44
+ inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
45
+ return std::optional<double>(value);
46
+ }
47
+ inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
48
+ return optional.has_value();
49
+ }
50
+ inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
51
+ return optional.value();
52
+ }
53
+
54
+ // pragma MARK: std::optional<std::string>
55
+ /**
56
+ * Specialized version of `std::optional<std::string>`.
57
+ */
58
+ using std__optional_std__string_ = std::optional<std::string>;
59
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
60
+ return std::optional<std::string>(value);
61
+ }
62
+ inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
63
+ return optional.has_value();
64
+ }
65
+ inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
66
+ return optional.value();
67
+ }
68
+
69
+ // pragma MARK: std::shared_ptr<Promise<std::string>>
70
+ /**
71
+ * Specialized version of `std::shared_ptr<Promise<std::string>>`.
72
+ */
73
+ using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
74
+ inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
75
+ return Promise<std::string>::create();
76
+ }
77
+ inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
78
+ return PromiseHolder<std::string>(std::move(promise));
79
+ }
80
+
81
+ // pragma MARK: std::function<void(const std::string& /* result */)>
82
+ /**
83
+ * Specialized version of `std::function<void(const std::string&)>`.
84
+ */
85
+ using Func_void_std__string = std::function<void(const std::string& /* result */)>;
86
+ /**
87
+ * Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
88
+ */
89
+ class Func_void_std__string_Wrapper final {
90
+ public:
91
+ 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))) {}
92
+ inline void call(std::string result) const noexcept {
93
+ _function->operator()(result);
94
+ }
95
+ private:
96
+ std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
97
+ } SWIFT_NONCOPYABLE;
98
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
99
+ inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
100
+ return Func_void_std__string_Wrapper(std::move(value));
101
+ }
102
+
103
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
104
+ /**
105
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
106
+ */
107
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
108
+ /**
109
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
110
+ */
111
+ class Func_void_std__exception_ptr_Wrapper final {
112
+ public:
113
+ 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))) {}
114
+ inline void call(std::exception_ptr error) const noexcept {
115
+ _function->operator()(error);
116
+ }
117
+ private:
118
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
119
+ } SWIFT_NONCOPYABLE;
120
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
121
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
122
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
123
+ }
124
+
125
+ // pragma MARK: std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>
126
+ /**
127
+ * Specialized version of `std::function<void(const std::shared_ptr<ArrayBuffer>&)>`.
128
+ */
129
+ using Func_void_std__shared_ptr_ArrayBuffer_ = std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>;
130
+ /**
131
+ * Wrapper class for a `std::function<void(const std::shared_ptr<ArrayBuffer>& / * data * /)>`, this can be used from Swift.
132
+ */
133
+ class Func_void_std__shared_ptr_ArrayBuffer__Wrapper final {
134
+ public:
135
+ explicit Func_void_std__shared_ptr_ArrayBuffer__Wrapper(std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>&& func): _function(std::make_unique<std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>>(std::move(func))) {}
136
+ inline void call(ArrayBufferHolder data) const noexcept {
137
+ _function->operator()(data.getArrayBuffer());
138
+ }
139
+ private:
140
+ std::unique_ptr<std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>> _function;
141
+ } SWIFT_NONCOPYABLE;
142
+ Func_void_std__shared_ptr_ArrayBuffer_ create_Func_void_std__shared_ptr_ArrayBuffer_(void* NON_NULL swiftClosureWrapper) noexcept;
143
+ inline Func_void_std__shared_ptr_ArrayBuffer__Wrapper wrap_Func_void_std__shared_ptr_ArrayBuffer_(Func_void_std__shared_ptr_ArrayBuffer_ value) noexcept {
144
+ return Func_void_std__shared_ptr_ArrayBuffer__Wrapper(std::move(value));
145
+ }
146
+
147
+ // pragma MARK: std::shared_ptr<HybridNitroAudioRecordSpec>
148
+ /**
149
+ * Specialized version of `std::shared_ptr<HybridNitroAudioRecordSpec>`.
150
+ */
151
+ using std__shared_ptr_HybridNitroAudioRecordSpec_ = std::shared_ptr<HybridNitroAudioRecordSpec>;
152
+ std::shared_ptr<HybridNitroAudioRecordSpec> create_std__shared_ptr_HybridNitroAudioRecordSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
153
+ void* NON_NULL get_std__shared_ptr_HybridNitroAudioRecordSpec_(std__shared_ptr_HybridNitroAudioRecordSpec_ cppType);
154
+
155
+ // pragma MARK: std::weak_ptr<HybridNitroAudioRecordSpec>
156
+ using std__weak_ptr_HybridNitroAudioRecordSpec_ = std::weak_ptr<HybridNitroAudioRecordSpec>;
157
+ inline std__weak_ptr_HybridNitroAudioRecordSpec_ weakify_std__shared_ptr_HybridNitroAudioRecordSpec_(const std::shared_ptr<HybridNitroAudioRecordSpec>& strong) noexcept { return strong; }
158
+
159
+ // pragma MARK: Result<void>
160
+ using Result_void_ = Result<void>;
161
+ inline Result_void_ create_Result_void_() noexcept {
162
+ return Result<void>::withValue();
163
+ }
164
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
165
+ return Result<void>::withError(error);
166
+ }
167
+
168
+ // pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
169
+ using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
170
+ 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 {
171
+ return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
172
+ }
173
+ inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
174
+ return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
175
+ }
176
+
177
+ } // namespace margelo::nitro::nitroaudiorecord::bridge::swift
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// NitroAudioRecord-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `AudioRecordOptions` to properly resolve imports.
12
+ namespace margelo::nitro::nitroaudiorecord { struct AudioRecordOptions; }
13
+ // Forward declaration of `HybridNitroAudioRecordSpec` to properly resolve imports.
14
+ namespace margelo::nitro::nitroaudiorecord { class HybridNitroAudioRecordSpec; }
15
+
16
+ // Include C++ defined types
17
+ #include "AudioRecordOptions.hpp"
18
+ #include "HybridNitroAudioRecordSpec.hpp"
19
+ #include <NitroModules/ArrayBuffer.hpp>
20
+ #include <NitroModules/Promise.hpp>
21
+ #include <NitroModules/Result.hpp>
22
+ #include <exception>
23
+ #include <functional>
24
+ #include <memory>
25
+ #include <optional>
26
+ #include <string>
27
+
28
+ // C++ helpers for Swift
29
+ #include "NitroAudioRecord-Swift-Cxx-Bridge.hpp"
30
+
31
+ // Common C++ types used in Swift
32
+ #include <NitroModules/ArrayBufferHolder.hpp>
33
+ #include <NitroModules/AnyMapUtils.hpp>
34
+ #include <NitroModules/RuntimeError.hpp>
35
+ #include <NitroModules/DateToChronoDate.hpp>
36
+
37
+ // Forward declarations of Swift defined types
38
+ // Forward declaration of `HybridNitroAudioRecordSpec_cxx` to properly resolve imports.
39
+ namespace NitroAudioRecord { class HybridNitroAudioRecordSpec_cxx; }
40
+
41
+ // Include Swift defined types
42
+ #if __has_include("NitroAudioRecord-Swift.h")
43
+ // This header is generated by Xcode/Swift on every app build.
44
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroAudioRecord".
45
+ #include "NitroAudioRecord-Swift.h"
46
+ // Same as above, but used when building with frameworks (`use_frameworks`)
47
+ #elif __has_include(<NitroAudioRecord/NitroAudioRecord-Swift.h>)
48
+ #include <NitroAudioRecord/NitroAudioRecord-Swift.h>
49
+ #else
50
+ #error NitroAudioRecord's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroAudioRecord", and try building the app first.
51
+ #endif