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,33 @@
1
+ ///
2
+ /// NitroAudioRecordAutolinking.mm
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
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "NitroAudioRecord-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridNitroAudioRecordSpecSwift.hpp"
14
+
15
+ @interface NitroAudioRecordAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation NitroAudioRecordAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::nitroaudiorecord;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "NitroAudioRecord",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridNitroAudioRecordSpec> hybridObject = NitroAudioRecord::NitroAudioRecordAutolinking::createNitroAudioRecord();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// NitroAudioRecordAutolinking.swift
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
+ import NitroModules
9
+
10
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class NitroAudioRecordAutolinking {
13
+ public typealias bridge = margelo.nitro.nitroaudiorecord.bridge.swift
14
+
15
+ public static func createNitroAudioRecord() -> bridge.std__shared_ptr_HybridNitroAudioRecordSpec_ {
16
+ let hybridObject = HybridNitroAudioRecord()
17
+ return { () -> bridge.std__shared_ptr_HybridNitroAudioRecordSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isNitroAudioRecordRecyclable() -> Bool {
24
+ return HybridNitroAudioRecord.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridNitroAudioRecordSpecSwift.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 "HybridNitroAudioRecordSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::nitroaudiorecord {
11
+ } // namespace margelo::nitro::nitroaudiorecord
@@ -0,0 +1,109 @@
1
+ ///
2
+ /// HybridNitroAudioRecordSpecSwift.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 "HybridNitroAudioRecordSpec.hpp"
11
+
12
+ // Forward declaration of `HybridNitroAudioRecordSpec_cxx` to properly resolve imports.
13
+ namespace NitroAudioRecord { class HybridNitroAudioRecordSpec_cxx; }
14
+
15
+ // Forward declaration of `AudioRecordOptions` to properly resolve imports.
16
+ namespace margelo::nitro::nitroaudiorecord { struct AudioRecordOptions; }
17
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
18
+ namespace NitroModules { class ArrayBufferHolder; }
19
+
20
+ #include "AudioRecordOptions.hpp"
21
+ #include <optional>
22
+ #include <string>
23
+ #include <NitroModules/Promise.hpp>
24
+ #include <NitroModules/ArrayBuffer.hpp>
25
+ #include <functional>
26
+ #include <NitroModules/ArrayBufferHolder.hpp>
27
+
28
+ #include "NitroAudioRecord-Swift-Cxx-Umbrella.hpp"
29
+
30
+ namespace margelo::nitro::nitroaudiorecord {
31
+
32
+ /**
33
+ * The C++ part of HybridNitroAudioRecordSpec_cxx.swift.
34
+ *
35
+ * HybridNitroAudioRecordSpecSwift (C++) accesses HybridNitroAudioRecordSpec_cxx (Swift), and might
36
+ * contain some additional bridging code for C++ <> Swift interop.
37
+ *
38
+ * Since this obviously introduces an overhead, I hope at some point in
39
+ * the future, HybridNitroAudioRecordSpec_cxx can directly inherit from the C++ class HybridNitroAudioRecordSpec
40
+ * to simplify the whole structure and memory management.
41
+ */
42
+ class HybridNitroAudioRecordSpecSwift: public virtual HybridNitroAudioRecordSpec {
43
+ public:
44
+ // Constructor from a Swift instance
45
+ explicit HybridNitroAudioRecordSpecSwift(const NitroAudioRecord::HybridNitroAudioRecordSpec_cxx& swiftPart):
46
+ HybridObject(HybridNitroAudioRecordSpec::TAG),
47
+ _swiftPart(swiftPart) { }
48
+
49
+ public:
50
+ // Get the Swift part
51
+ inline NitroAudioRecord::HybridNitroAudioRecordSpec_cxx& getSwiftPart() noexcept {
52
+ return _swiftPart;
53
+ }
54
+
55
+ public:
56
+ inline size_t getExternalMemorySize() noexcept override {
57
+ return _swiftPart.getMemorySize();
58
+ }
59
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
60
+ if (auto otherCast = std::dynamic_pointer_cast<HybridNitroAudioRecordSpecSwift>(other)) {
61
+ return _swiftPart.equals(otherCast->_swiftPart);
62
+ }
63
+ return false;
64
+ }
65
+ void dispose() noexcept override {
66
+ _swiftPart.dispose();
67
+ }
68
+ std::string toString() override {
69
+ return _swiftPart.toString();
70
+ }
71
+
72
+ public:
73
+ // Properties
74
+
75
+
76
+ public:
77
+ // Methods
78
+ inline void setup(const AudioRecordOptions& options) override {
79
+ auto __result = _swiftPart.setup(std::forward<decltype(options)>(options));
80
+ if (__result.hasError()) [[unlikely]] {
81
+ std::rethrow_exception(__result.error());
82
+ }
83
+ }
84
+ inline void start() override {
85
+ auto __result = _swiftPart.start();
86
+ if (__result.hasError()) [[unlikely]] {
87
+ std::rethrow_exception(__result.error());
88
+ }
89
+ }
90
+ inline std::shared_ptr<Promise<std::string>> stop() override {
91
+ auto __result = _swiftPart.stop();
92
+ if (__result.hasError()) [[unlikely]] {
93
+ std::rethrow_exception(__result.error());
94
+ }
95
+ auto __value = std::move(__result.value());
96
+ return __value;
97
+ }
98
+ inline void onData(const std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */)>& callback) override {
99
+ auto __result = _swiftPart.onData(callback);
100
+ if (__result.hasError()) [[unlikely]] {
101
+ std::rethrow_exception(__result.error());
102
+ }
103
+ }
104
+
105
+ private:
106
+ NitroAudioRecord::HybridNitroAudioRecordSpec_cxx _swiftPart;
107
+ };
108
+
109
+ } // namespace margelo::nitro::nitroaudiorecord
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// AudioRecordOptions.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `AudioRecordOptions`, backed by a C++ struct.
12
+ */
13
+ public typealias AudioRecordOptions = margelo.nitro.nitroaudiorecord.AudioRecordOptions
14
+
15
+ public extension AudioRecordOptions {
16
+ private typealias bridge = margelo.nitro.nitroaudiorecord.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `AudioRecordOptions`.
20
+ */
21
+ init(sampleRate: Double, channels: Double, bitsPerSample: Double, audioSource: Double?, wavFile: String?) {
22
+ self.init(sampleRate, channels, bitsPerSample, { () -> bridge.std__optional_double_ in
23
+ if let __unwrappedValue = audioSource {
24
+ return bridge.create_std__optional_double_(__unwrappedValue)
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), { () -> bridge.std__optional_std__string_ in
29
+ if let __unwrappedValue = wavFile {
30
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
31
+ } else {
32
+ return .init()
33
+ }
34
+ }())
35
+ }
36
+
37
+ @inline(__always)
38
+ var sampleRate: Double {
39
+ return self.__sampleRate
40
+ }
41
+
42
+ @inline(__always)
43
+ var channels: Double {
44
+ return self.__channels
45
+ }
46
+
47
+ @inline(__always)
48
+ var bitsPerSample: Double {
49
+ return self.__bitsPerSample
50
+ }
51
+
52
+ @inline(__always)
53
+ var audioSource: Double? {
54
+ return { () -> Double? in
55
+ if bridge.has_value_std__optional_double_(self.__audioSource) {
56
+ let __unwrapped = bridge.get_std__optional_double_(self.__audioSource)
57
+ return __unwrapped
58
+ } else {
59
+ return nil
60
+ }
61
+ }()
62
+ }
63
+
64
+ @inline(__always)
65
+ var wavFile: String? {
66
+ return { () -> String? in
67
+ if bridge.has_value_std__optional_std__string_(self.__wavFile) {
68
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__wavFile)
69
+ return String(__unwrapped)
70
+ } else {
71
+ return nil
72
+ }
73
+ }()
74
+ }
75
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.nitroaudiorecord.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__shared_ptr_ArrayBuffer_.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ data: ArrayBuffer) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__shared_ptr_ArrayBuffer_ {
15
+ public typealias bridge = margelo.nitro.nitroaudiorecord.bridge.swift
16
+
17
+ private let closure: (_ data: ArrayBuffer) -> Void
18
+
19
+ public init(_ closure: @escaping (_ data: ArrayBuffer) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(data: ArrayBuffer) -> Void {
25
+ self.closure(data)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__shared_ptr_ArrayBuffer_`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_ArrayBuffer_>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_ArrayBuffer_ {
44
+ return Unmanaged<Func_void_std__shared_ptr_ArrayBuffer_>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__string.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ value: String) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__string {
15
+ public typealias bridge = margelo.nitro.nitroaudiorecord.bridge.swift
16
+
17
+ private let closure: (_ value: String) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: String) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: std.string) -> Void {
25
+ self.closure(String(value))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__string`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
44
+ return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// HybridNitroAudioRecordSpec.swift
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
+ import NitroModules
9
+
10
+ /// See ``HybridNitroAudioRecordSpec``
11
+ public protocol HybridNitroAudioRecordSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func setup(options: AudioRecordOptions) throws -> Void
17
+ func start() throws -> Void
18
+ func stop() throws -> Promise<String>
19
+ func onData(callback: @escaping (_ data: ArrayBuffer) -> Void) throws -> Void
20
+ }
21
+
22
+ public extension HybridNitroAudioRecordSpec_protocol {
23
+ /// Default implementation of ``HybridObject.toString``
24
+ func toString() -> String {
25
+ return "[HybridObject NitroAudioRecord]"
26
+ }
27
+ }
28
+
29
+ /// See ``HybridNitroAudioRecordSpec``
30
+ open class HybridNitroAudioRecordSpec_base {
31
+ private weak var cxxWrapper: HybridNitroAudioRecordSpec_cxx? = nil
32
+ public init() { }
33
+ public func getCxxWrapper() -> HybridNitroAudioRecordSpec_cxx {
34
+ #if DEBUG
35
+ guard self is any HybridNitroAudioRecordSpec else {
36
+ fatalError("`self` is not a `HybridNitroAudioRecordSpec`! Did you accidentally inherit from `HybridNitroAudioRecordSpec_base` instead of `HybridNitroAudioRecordSpec`?")
37
+ }
38
+ #endif
39
+ if let cxxWrapper = self.cxxWrapper {
40
+ return cxxWrapper
41
+ } else {
42
+ let cxxWrapper = HybridNitroAudioRecordSpec_cxx(self as! any HybridNitroAudioRecordSpec)
43
+ self.cxxWrapper = cxxWrapper
44
+ return cxxWrapper
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * A Swift base-protocol representing the NitroAudioRecord HybridObject.
51
+ * Implement this protocol to create Swift-based instances of NitroAudioRecord.
52
+ * ```swift
53
+ * class HybridNitroAudioRecord : HybridNitroAudioRecordSpec {
54
+ * // ...
55
+ * }
56
+ * ```
57
+ */
58
+ public typealias HybridNitroAudioRecordSpec = HybridNitroAudioRecordSpec_protocol & HybridNitroAudioRecordSpec_base
@@ -0,0 +1,183 @@
1
+ ///
2
+ /// HybridNitroAudioRecordSpec_cxx.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * A class implementation that bridges HybridNitroAudioRecordSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridNitroAudioRecordSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::nitroaudiorecord::bridge::swift`)
22
+ * from `NitroAudioRecord-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.nitroaudiorecord.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridNitroAudioRecordSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridNitroAudioRecordSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridNitroAudioRecordSpec_
36
+
37
+ /**
38
+ * Create a new `HybridNitroAudioRecordSpec_cxx` that wraps the given `HybridNitroAudioRecordSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridNitroAudioRecordSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridNitroAudioRecordSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridNitroAudioRecordSpec() -> any HybridNitroAudioRecordSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridNitroAudioRecordSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridNitroAudioRecordSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroAudioRecordSpec_cxx {
69
+ return Unmanaged<HybridNitroAudioRecordSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridNitroAudioRecordSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroAudioRecordSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNitroAudioRecordSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroAudioRecordSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridNitroAudioRecordSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func setup(options: AudioRecordOptions) -> bridge.Result_void_ {
129
+ do {
130
+ try self.__implementation.setup(options: options)
131
+ return bridge.create_Result_void_()
132
+ } catch (let __error) {
133
+ let __exceptionPtr = __error.toCpp()
134
+ return bridge.create_Result_void_(__exceptionPtr)
135
+ }
136
+ }
137
+
138
+ @inline(__always)
139
+ public final func start() -> bridge.Result_void_ {
140
+ do {
141
+ try self.__implementation.start()
142
+ return bridge.create_Result_void_()
143
+ } catch (let __error) {
144
+ let __exceptionPtr = __error.toCpp()
145
+ return bridge.create_Result_void_(__exceptionPtr)
146
+ }
147
+ }
148
+
149
+ @inline(__always)
150
+ public final func stop() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
151
+ do {
152
+ let __result = try self.__implementation.stop()
153
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
154
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
155
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
156
+ __result
157
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
158
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
159
+ return __promise
160
+ }()
161
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
162
+ } catch (let __error) {
163
+ let __exceptionPtr = __error.toCpp()
164
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
165
+ }
166
+ }
167
+
168
+ @inline(__always)
169
+ public final func onData(callback: bridge.Func_void_std__shared_ptr_ArrayBuffer_) -> bridge.Result_void_ {
170
+ do {
171
+ try self.__implementation.onData(callback: { () -> (ArrayBuffer) -> Void in
172
+ let __wrappedFunction = bridge.wrap_Func_void_std__shared_ptr_ArrayBuffer_(callback)
173
+ return { (__data: ArrayBuffer) -> Void in
174
+ __wrappedFunction.call(__data)
175
+ }
176
+ }())
177
+ return bridge.create_Result_void_()
178
+ } catch (let __error) {
179
+ let __exceptionPtr = __error.toCpp()
180
+ return bridge.create_Result_void_(__exceptionPtr)
181
+ }
182
+ }
183
+ }