react-native-audio-concat 0.2.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 (59) hide show
  1. package/AudioConcat.podspec +30 -0
  2. package/LICENSE +20 -0
  3. package/README.md +39 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +128 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcat.kt +349 -0
  10. package/android/src/main/java/com/margelo/nitro/audioconcat/AudioConcatPackage.kt +22 -0
  11. package/ios/AudioConcat.swift +75 -0
  12. package/lib/module/AudioConcat.nitro.js +4 -0
  13. package/lib/module/AudioConcat.nitro.js.map +1 -0
  14. package/lib/module/index.js +33 -0
  15. package/lib/module/index.js.map +1 -0
  16. package/lib/module/package.json +1 -0
  17. package/lib/typescript/package.json +1 -0
  18. package/lib/typescript/src/AudioConcat.nitro.d.ts +16 -0
  19. package/lib/typescript/src/AudioConcat.nitro.d.ts.map +1 -0
  20. package/lib/typescript/src/index.d.ts +28 -0
  21. package/lib/typescript/src/index.d.ts.map +1 -0
  22. package/nitro.json +17 -0
  23. package/nitrogen/generated/android/audioconcat+autolinking.cmake +82 -0
  24. package/nitrogen/generated/android/audioconcat+autolinking.gradle +27 -0
  25. package/nitrogen/generated/android/audioconcatOnLoad.cpp +44 -0
  26. package/nitrogen/generated/android/audioconcatOnLoad.hpp +25 -0
  27. package/nitrogen/generated/android/c++/JAudioData.hpp +53 -0
  28. package/nitrogen/generated/android/c++/JAudioDataOrSilence.cpp +26 -0
  29. package/nitrogen/generated/android/c++/JAudioDataOrSilence.hpp +72 -0
  30. package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.cpp +77 -0
  31. package/nitrogen/generated/android/c++/JHybridAudioConcatSpec.hpp +64 -0
  32. package/nitrogen/generated/android/c++/JSilentData.hpp +53 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioData.kt +29 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/AudioDataOrSilence.kt +42 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/HybridAudioConcatSpec.kt +52 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/SilentData.kt +29 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/audioconcat/audioconcatOnLoad.kt +35 -0
  38. package/nitrogen/generated/ios/AudioConcat+autolinking.rb +60 -0
  39. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.cpp +48 -0
  40. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Bridge.hpp +160 -0
  41. package/nitrogen/generated/ios/AudioConcat-Swift-Cxx-Umbrella.hpp +53 -0
  42. package/nitrogen/generated/ios/AudioConcatAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/AudioConcatAutolinking.swift +25 -0
  44. package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridAudioConcatSpecSwift.hpp +81 -0
  46. package/nitrogen/generated/ios/swift/AudioData.swift +35 -0
  47. package/nitrogen/generated/ios/swift/AudioDataOrSilence.swift +18 -0
  48. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  49. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  50. package/nitrogen/generated/ios/swift/HybridAudioConcatSpec.swift +49 -0
  51. package/nitrogen/generated/ios/swift/HybridAudioConcatSpec_cxx.swift +142 -0
  52. package/nitrogen/generated/ios/swift/SilentData.swift +35 -0
  53. package/nitrogen/generated/shared/c++/AudioData.hpp +67 -0
  54. package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.cpp +21 -0
  55. package/nitrogen/generated/shared/c++/HybridAudioConcatSpec.hpp +70 -0
  56. package/nitrogen/generated/shared/c++/SilentData.hpp +67 -0
  57. package/package.json +168 -0
  58. package/src/AudioConcat.nitro.ts +19 -0
  59. package/src/index.tsx +38 -0
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// AudioConcatAutolinking.swift
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
+ public final class AudioConcatAutolinking {
9
+ public typealias bridge = margelo.nitro.audioconcat.bridge.swift
10
+
11
+ /**
12
+ * Creates an instance of a Swift class that implements `HybridAudioConcatSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridAudioConcatSpec_cxx`)
14
+ *
15
+ * This is generated by Nitrogen and will initialize the class specified
16
+ * in the `"autolinking"` property of `nitro.json` (in this case, `AudioConcat`).
17
+ */
18
+ public static func createAudioConcat() -> bridge.std__shared_ptr_HybridAudioConcatSpec_ {
19
+ let hybridObject = AudioConcat()
20
+ return { () -> bridge.std__shared_ptr_HybridAudioConcatSpec_ in
21
+ let __cxxWrapped = hybridObject.getCxxWrapper()
22
+ return __cxxWrapped.getCxxPart()
23
+ }()
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridAudioConcatSpecSwift.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 "HybridAudioConcatSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::audioconcat {
11
+ } // namespace margelo::nitro::audioconcat
@@ -0,0 +1,81 @@
1
+ ///
2
+ /// HybridAudioConcatSpecSwift.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 "HybridAudioConcatSpec.hpp"
11
+
12
+ // Forward declaration of `HybridAudioConcatSpec_cxx` to properly resolve imports.
13
+ namespace AudioConcat { class HybridAudioConcatSpec_cxx; }
14
+
15
+ // Forward declaration of `AudioData` to properly resolve imports.
16
+ namespace margelo::nitro::audioconcat { struct AudioData; }
17
+ // Forward declaration of `SilentData` to properly resolve imports.
18
+ namespace margelo::nitro::audioconcat { struct SilentData; }
19
+
20
+ #include <string>
21
+ #include <NitroModules/Promise.hpp>
22
+ #include "AudioData.hpp"
23
+ #include "SilentData.hpp"
24
+ #include <variant>
25
+ #include <vector>
26
+
27
+ #include "AudioConcat-Swift-Cxx-Umbrella.hpp"
28
+
29
+ namespace margelo::nitro::audioconcat {
30
+
31
+ /**
32
+ * The C++ part of HybridAudioConcatSpec_cxx.swift.
33
+ *
34
+ * HybridAudioConcatSpecSwift (C++) accesses HybridAudioConcatSpec_cxx (Swift), and might
35
+ * contain some additional bridging code for C++ <> Swift interop.
36
+ *
37
+ * Since this obviously introduces an overhead, I hope at some point in
38
+ * the future, HybridAudioConcatSpec_cxx can directly inherit from the C++ class HybridAudioConcatSpec
39
+ * to simplify the whole structure and memory management.
40
+ */
41
+ class HybridAudioConcatSpecSwift: public virtual HybridAudioConcatSpec {
42
+ public:
43
+ // Constructor from a Swift instance
44
+ explicit HybridAudioConcatSpecSwift(const AudioConcat::HybridAudioConcatSpec_cxx& swiftPart):
45
+ HybridObject(HybridAudioConcatSpec::TAG),
46
+ _swiftPart(swiftPart) { }
47
+
48
+ public:
49
+ // Get the Swift part
50
+ inline AudioConcat::HybridAudioConcatSpec_cxx& getSwiftPart() noexcept {
51
+ return _swiftPart;
52
+ }
53
+
54
+ public:
55
+ inline size_t getExternalMemorySize() noexcept override {
56
+ return _swiftPart.getMemorySize();
57
+ }
58
+ void dispose() noexcept override {
59
+ _swiftPart.dispose();
60
+ }
61
+
62
+ public:
63
+ // Properties
64
+
65
+
66
+ public:
67
+ // Methods
68
+ inline std::shared_ptr<Promise<std::string>> concatAudioFiles(const std::vector<std::variant<AudioData, SilentData>>& data, const std::string& outputPath) override {
69
+ auto __result = _swiftPart.concatAudioFiles(data, outputPath);
70
+ if (__result.hasError()) [[unlikely]] {
71
+ std::rethrow_exception(__result.error());
72
+ }
73
+ auto __value = std::move(__result.value());
74
+ return __value;
75
+ }
76
+
77
+ private:
78
+ AudioConcat::HybridAudioConcatSpec_cxx _swiftPart;
79
+ };
80
+
81
+ } // namespace margelo::nitro::audioconcat
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// AudioData.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `AudioData`, backed by a C++ struct.
12
+ */
13
+ public typealias AudioData = margelo.nitro.audioconcat.AudioData
14
+
15
+ public extension AudioData {
16
+ private typealias bridge = margelo.nitro.audioconcat.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `AudioData`.
20
+ */
21
+ init(filePath: String) {
22
+ self.init(std.string(filePath))
23
+ }
24
+
25
+ var filePath: String {
26
+ @inline(__always)
27
+ get {
28
+ return String(self.__filePath)
29
+ }
30
+ @inline(__always)
31
+ set {
32
+ self.__filePath = std.string(newValue)
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,18 @@
1
+ ///
2
+ /// AudioDataOrSilence.swift
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
+
9
+
10
+ /**
11
+ * An Swift enum with associated values representing a Variant/Union type.
12
+ * JS type: `struct | struct`
13
+ */
14
+ @frozen
15
+ public indirect enum AudioDataOrSilence {
16
+ case first(AudioData)
17
+ case second(SilentData)
18
+ }
@@ -0,0 +1,47 @@
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 © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__exception_ptr {
16
+ public typealias bridge = margelo.nitro.audioconcat.bridge.swift
17
+
18
+ private let closure: (_ error: Error) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: std.exception_ptr) -> Void {
26
+ self.closure(RuntimeError.from(cppError: error))
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
45
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
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 © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: String) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__string {
16
+ public typealias bridge = margelo.nitro.audioconcat.bridge.swift
17
+
18
+ private let closure: (_ value: String) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: String) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: std.string) -> Void {
26
+ self.closure(String(value))
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_std__string`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
45
+ return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// HybridAudioConcatSpec.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridAudioConcatSpec``
12
+ public protocol HybridAudioConcatSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func concatAudioFiles(data: [AudioDataOrSilence], outputPath: String) throws -> Promise<String>
18
+ }
19
+
20
+ /// See ``HybridAudioConcatSpec``
21
+ open class HybridAudioConcatSpec_base {
22
+ private weak var cxxWrapper: HybridAudioConcatSpec_cxx? = nil
23
+ public init() { }
24
+ public func getCxxWrapper() -> HybridAudioConcatSpec_cxx {
25
+ #if DEBUG
26
+ guard self is HybridAudioConcatSpec else {
27
+ fatalError("`self` is not a `HybridAudioConcatSpec`! Did you accidentally inherit from `HybridAudioConcatSpec_base` instead of `HybridAudioConcatSpec`?")
28
+ }
29
+ #endif
30
+ if let cxxWrapper = self.cxxWrapper {
31
+ return cxxWrapper
32
+ } else {
33
+ let cxxWrapper = HybridAudioConcatSpec_cxx(self as! HybridAudioConcatSpec)
34
+ self.cxxWrapper = cxxWrapper
35
+ return cxxWrapper
36
+ }
37
+ }
38
+ }
39
+
40
+ /**
41
+ * A Swift base-protocol representing the AudioConcat HybridObject.
42
+ * Implement this protocol to create Swift-based instances of AudioConcat.
43
+ * ```swift
44
+ * class HybridAudioConcat : HybridAudioConcatSpec {
45
+ * // ...
46
+ * }
47
+ * ```
48
+ */
49
+ public typealias HybridAudioConcatSpec = HybridAudioConcatSpec_protocol & HybridAudioConcatSpec_base
@@ -0,0 +1,142 @@
1
+ ///
2
+ /// HybridAudioConcatSpec_cxx.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridAudioConcatSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridAudioConcatSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::audioconcat::bridge::swift`)
23
+ * from `AudioConcat-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.audioconcat.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridAudioConcatSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridAudioConcatSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridAudioConcatSpec_
37
+
38
+ /**
39
+ * Create a new `HybridAudioConcatSpec_cxx` that wraps the given `HybridAudioConcatSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridAudioConcatSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridAudioConcatSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridAudioConcatSpec() -> any HybridAudioConcatSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridAudioConcatSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridAudioConcatSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridAudioConcatSpec_cxx {
70
+ return Unmanaged<HybridAudioConcatSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridAudioConcatSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridAudioConcatSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if cachedCxxPart.__convertToBool() {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridAudioConcatSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridAudioConcatSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ // Properties
109
+
110
+
111
+ // Methods
112
+ @inline(__always)
113
+ public final func concatAudioFiles(data: bridge.std__vector_std__variant_AudioData__SilentData__, outputPath: std.string) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
114
+ do {
115
+ let __result = try self.__implementation.concatAudioFiles(data: data.map({ __item in { () -> AudioDataOrSilence in
116
+ let __variant = bridge.std__variant_AudioData__SilentData_(__item)
117
+ switch __variant.index() {
118
+ case 0:
119
+ let __actual = __variant.get_0()
120
+ return .first(__actual)
121
+ case 1:
122
+ let __actual = __variant.get_1()
123
+ return .second(__actual)
124
+ default:
125
+ fatalError("Variant can never have index \(__variant.index())!")
126
+ }
127
+ }() }), outputPath: String(outputPath))
128
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
129
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
130
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
131
+ __result
132
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
133
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
134
+ return __promise
135
+ }()
136
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
137
+ } catch (let __error) {
138
+ let __exceptionPtr = __error.toCpp()
139
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
140
+ }
141
+ }
142
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// SilentData.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `SilentData`, backed by a C++ struct.
12
+ */
13
+ public typealias SilentData = margelo.nitro.audioconcat.SilentData
14
+
15
+ public extension SilentData {
16
+ private typealias bridge = margelo.nitro.audioconcat.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `SilentData`.
20
+ */
21
+ init(durationMs: Double) {
22
+ self.init(durationMs)
23
+ }
24
+
25
+ var durationMs: Double {
26
+ @inline(__always)
27
+ get {
28
+ return self.__durationMs
29
+ }
30
+ @inline(__always)
31
+ set {
32
+ self.__durationMs = newValue
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,67 @@
1
+ ///
2
+ /// AudioData.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+ #include <string>
24
+
25
+ namespace margelo::nitro::audioconcat {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (AudioData).
29
+ */
30
+ struct AudioData {
31
+ public:
32
+ std::string filePath SWIFT_PRIVATE;
33
+
34
+ public:
35
+ AudioData() = default;
36
+ explicit AudioData(std::string filePath): filePath(filePath) {}
37
+ };
38
+
39
+ } // namespace margelo::nitro::audioconcat
40
+
41
+ namespace margelo::nitro {
42
+
43
+ // C++ AudioData <> JS AudioData (object)
44
+ template <>
45
+ struct JSIConverter<margelo::nitro::audioconcat::AudioData> final {
46
+ static inline margelo::nitro::audioconcat::AudioData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
47
+ jsi::Object obj = arg.asObject(runtime);
48
+ return margelo::nitro::audioconcat::AudioData(
49
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "filePath"))
50
+ );
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::audioconcat::AudioData& arg) {
53
+ jsi::Object obj(runtime);
54
+ obj.setProperty(runtime, "filePath", JSIConverter<std::string>::toJSI(runtime, arg.filePath));
55
+ return obj;
56
+ }
57
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
58
+ if (!value.isObject()) {
59
+ return false;
60
+ }
61
+ jsi::Object obj = value.getObject(runtime);
62
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "filePath"))) return false;
63
+ return true;
64
+ }
65
+ };
66
+
67
+ } // namespace margelo::nitro
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridAudioConcatSpec.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 "HybridAudioConcatSpec.hpp"
9
+
10
+ namespace margelo::nitro::audioconcat {
11
+
12
+ void HybridAudioConcatSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("concatAudioFiles", &HybridAudioConcatSpec::concatAudioFiles);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::audioconcat
@@ -0,0 +1,70 @@
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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `AudioData` to properly resolve imports.
17
+ namespace margelo::nitro::audioconcat { struct AudioData; }
18
+ // Forward declaration of `SilentData` to properly resolve imports.
19
+ namespace margelo::nitro::audioconcat { struct SilentData; }
20
+
21
+ #include <string>
22
+ #include <NitroModules/Promise.hpp>
23
+ #include "AudioData.hpp"
24
+ #include "SilentData.hpp"
25
+ #include <variant>
26
+ #include <vector>
27
+
28
+ namespace margelo::nitro::audioconcat {
29
+
30
+ using namespace margelo::nitro;
31
+
32
+ /**
33
+ * An abstract base class for `AudioConcat`
34
+ * Inherit this class to create instances of `HybridAudioConcatSpec` in C++.
35
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
36
+ * @example
37
+ * ```cpp
38
+ * class HybridAudioConcat: public HybridAudioConcatSpec {
39
+ * public:
40
+ * HybridAudioConcat(...): HybridObject(TAG) { ... }
41
+ * // ...
42
+ * };
43
+ * ```
44
+ */
45
+ class HybridAudioConcatSpec: public virtual HybridObject {
46
+ public:
47
+ // Constructor
48
+ explicit HybridAudioConcatSpec(): HybridObject(TAG) { }
49
+
50
+ // Destructor
51
+ ~HybridAudioConcatSpec() override = default;
52
+
53
+ public:
54
+ // Properties
55
+
56
+
57
+ public:
58
+ // Methods
59
+ virtual std::shared_ptr<Promise<std::string>> concatAudioFiles(const std::vector<std::variant<AudioData, SilentData>>& data, const std::string& outputPath) = 0;
60
+
61
+ protected:
62
+ // Hybrid Setup
63
+ void loadHybridMethods() override;
64
+
65
+ protected:
66
+ // Tag for logging
67
+ static constexpr auto TAG = "AudioConcat";
68
+ };
69
+
70
+ } // namespace margelo::nitro::audioconcat