react-native-nitro-mlx 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 (63) hide show
  1. package/MLXReactNative.podspec +42 -0
  2. package/ios/Bridge.h +8 -0
  3. package/ios/Sources/MLXReactNative.h +16 -0
  4. package/lib/module/index.js +6 -0
  5. package/lib/module/index.js.map +1 -0
  6. package/lib/module/llm.js +105 -0
  7. package/lib/module/llm.js.map +1 -0
  8. package/lib/module/modelManager.js +79 -0
  9. package/lib/module/modelManager.js.map +1 -0
  10. package/lib/module/models.js +41 -0
  11. package/lib/module/models.js.map +1 -0
  12. package/lib/module/package.json +1 -0
  13. package/lib/module/specs/LLM.nitro.js +4 -0
  14. package/lib/module/specs/LLM.nitro.js.map +1 -0
  15. package/lib/module/specs/ModelManager.nitro.js +4 -0
  16. package/lib/module/specs/ModelManager.nitro.js.map +1 -0
  17. package/lib/typescript/package.json +1 -0
  18. package/lib/typescript/src/index.d.ts +6 -0
  19. package/lib/typescript/src/index.d.ts.map +1 -0
  20. package/lib/typescript/src/llm.d.ts +69 -0
  21. package/lib/typescript/src/llm.d.ts.map +1 -0
  22. package/lib/typescript/src/modelManager.d.ts +53 -0
  23. package/lib/typescript/src/modelManager.d.ts.map +1 -0
  24. package/lib/typescript/src/models.d.ts +29 -0
  25. package/lib/typescript/src/models.d.ts.map +1 -0
  26. package/lib/typescript/src/specs/LLM.nitro.d.ts +61 -0
  27. package/lib/typescript/src/specs/LLM.nitro.d.ts.map +1 -0
  28. package/lib/typescript/src/specs/ModelManager.nitro.d.ts +41 -0
  29. package/lib/typescript/src/specs/ModelManager.nitro.d.ts.map +1 -0
  30. package/nitrogen/generated/.gitattributes +1 -0
  31. package/nitrogen/generated/ios/MLXReactNative+autolinking.rb +60 -0
  32. package/nitrogen/generated/ios/MLXReactNative-Swift-Cxx-Bridge.cpp +98 -0
  33. package/nitrogen/generated/ios/MLXReactNative-Swift-Cxx-Bridge.hpp +312 -0
  34. package/nitrogen/generated/ios/MLXReactNative-Swift-Cxx-Umbrella.hpp +55 -0
  35. package/nitrogen/generated/ios/MLXReactNativeAutolinking.mm +41 -0
  36. package/nitrogen/generated/ios/MLXReactNativeAutolinking.swift +40 -0
  37. package/nitrogen/generated/ios/c++/HybridLLMSpecSwift.cpp +11 -0
  38. package/nitrogen/generated/ios/c++/HybridLLMSpecSwift.hpp +132 -0
  39. package/nitrogen/generated/ios/c++/HybridModelManagerSpecSwift.cpp +11 -0
  40. package/nitrogen/generated/ios/c++/HybridModelManagerSpecSwift.hpp +116 -0
  41. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  42. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  43. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  44. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  45. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  46. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
  47. package/nitrogen/generated/ios/swift/GenerationStats.swift +69 -0
  48. package/nitrogen/generated/ios/swift/HybridLLMSpec.swift +64 -0
  49. package/nitrogen/generated/ios/swift/HybridLLMSpec_cxx.swift +250 -0
  50. package/nitrogen/generated/ios/swift/HybridModelManagerSpec.swift +60 -0
  51. package/nitrogen/generated/ios/swift/HybridModelManagerSpec_cxx.swift +234 -0
  52. package/nitrogen/generated/shared/c++/GenerationStats.hpp +87 -0
  53. package/nitrogen/generated/shared/c++/HybridLLMSpec.cpp +32 -0
  54. package/nitrogen/generated/shared/c++/HybridLLMSpec.hpp +76 -0
  55. package/nitrogen/generated/shared/c++/HybridModelManagerSpec.cpp +27 -0
  56. package/nitrogen/generated/shared/c++/HybridModelManagerSpec.hpp +70 -0
  57. package/package.json +96 -0
  58. package/src/index.ts +6 -0
  59. package/src/llm.ts +116 -0
  60. package/src/modelManager.ts +88 -0
  61. package/src/models.ts +45 -0
  62. package/src/specs/LLM.nitro.ts +66 -0
  63. package/src/specs/ModelManager.nitro.ts +44 -0
@@ -0,0 +1,60 @@
1
+ #
2
+ # MLXReactNative+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/MLXReactNative+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 MLXReactNative 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/MLXReactNative-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
@@ -0,0 +1,98 @@
1
+ ///
2
+ /// MLXReactNative-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 "MLXReactNative-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridLLMSpecSwift.hpp"
12
+ #include "HybridModelManagerSpecSwift.hpp"
13
+ #include "MLXReactNative-Swift-Cxx-Umbrella.hpp"
14
+ #include <NitroModules/NitroDefines.hpp>
15
+
16
+ namespace margelo::nitro::mlxreactnative::bridge::swift {
17
+
18
+ // pragma MARK: std::function<void()>
19
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
20
+ auto swiftClosure = MLXReactNative::Func_void::fromUnsafe(swiftClosureWrapper);
21
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
22
+ swiftClosure.call();
23
+ };
24
+ }
25
+
26
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
27
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
28
+ auto swiftClosure = MLXReactNative::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
29
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
30
+ swiftClosure.call(error);
31
+ };
32
+ }
33
+
34
+ // pragma MARK: std::function<void(double /* progress */)>
35
+ Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept {
36
+ auto swiftClosure = MLXReactNative::Func_void_double::fromUnsafe(swiftClosureWrapper);
37
+ return [swiftClosure = std::move(swiftClosure)](double progress) mutable -> void {
38
+ swiftClosure.call(progress);
39
+ };
40
+ }
41
+
42
+ // pragma MARK: std::function<void(const std::string& /* result */)>
43
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
44
+ auto swiftClosure = MLXReactNative::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
45
+ return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
46
+ swiftClosure.call(result);
47
+ };
48
+ }
49
+
50
+ // pragma MARK: std::shared_ptr<HybridLLMSpec>
51
+ std::shared_ptr<HybridLLMSpec> create_std__shared_ptr_HybridLLMSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
52
+ MLXReactNative::HybridLLMSpec_cxx swiftPart = MLXReactNative::HybridLLMSpec_cxx::fromUnsafe(swiftUnsafePointer);
53
+ return std::make_shared<margelo::nitro::mlxreactnative::HybridLLMSpecSwift>(swiftPart);
54
+ }
55
+ void* NON_NULL get_std__shared_ptr_HybridLLMSpec_(std__shared_ptr_HybridLLMSpec_ cppType) {
56
+ std::shared_ptr<margelo::nitro::mlxreactnative::HybridLLMSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridLLMSpecSwift>(cppType);
57
+ #ifdef NITRO_DEBUG
58
+ if (swiftWrapper == nullptr) [[unlikely]] {
59
+ throw std::runtime_error("Class \"HybridLLMSpec\" is not implemented in Swift!");
60
+ }
61
+ #endif
62
+ MLXReactNative::HybridLLMSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
63
+ return swiftPart.toUnsafe();
64
+ }
65
+
66
+ // pragma MARK: std::function<void(bool /* result */)>
67
+ Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
68
+ auto swiftClosure = MLXReactNative::Func_void_bool::fromUnsafe(swiftClosureWrapper);
69
+ return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
70
+ swiftClosure.call(result);
71
+ };
72
+ }
73
+
74
+ // pragma MARK: std::function<void(const std::vector<std::string>& /* result */)>
75
+ Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
76
+ auto swiftClosure = MLXReactNative::Func_void_std__vector_std__string_::fromUnsafe(swiftClosureWrapper);
77
+ return [swiftClosure = std::move(swiftClosure)](const std::vector<std::string>& result) mutable -> void {
78
+ swiftClosure.call(result);
79
+ };
80
+ }
81
+
82
+ // pragma MARK: std::shared_ptr<HybridModelManagerSpec>
83
+ std::shared_ptr<HybridModelManagerSpec> create_std__shared_ptr_HybridModelManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
84
+ MLXReactNative::HybridModelManagerSpec_cxx swiftPart = MLXReactNative::HybridModelManagerSpec_cxx::fromUnsafe(swiftUnsafePointer);
85
+ return std::make_shared<margelo::nitro::mlxreactnative::HybridModelManagerSpecSwift>(swiftPart);
86
+ }
87
+ void* NON_NULL get_std__shared_ptr_HybridModelManagerSpec_(std__shared_ptr_HybridModelManagerSpec_ cppType) {
88
+ std::shared_ptr<margelo::nitro::mlxreactnative::HybridModelManagerSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::mlxreactnative::HybridModelManagerSpecSwift>(cppType);
89
+ #ifdef NITRO_DEBUG
90
+ if (swiftWrapper == nullptr) [[unlikely]] {
91
+ throw std::runtime_error("Class \"HybridModelManagerSpec\" is not implemented in Swift!");
92
+ }
93
+ #endif
94
+ MLXReactNative::HybridModelManagerSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
95
+ return swiftPart.toUnsafe();
96
+ }
97
+
98
+ } // namespace margelo::nitro::mlxreactnative::bridge::swift
@@ -0,0 +1,312 @@
1
+ ///
2
+ /// MLXReactNative-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 `GenerationStats` to properly resolve imports.
12
+ namespace margelo::nitro::mlxreactnative { struct GenerationStats; }
13
+ // Forward declaration of `HybridLLMSpec` to properly resolve imports.
14
+ namespace margelo::nitro::mlxreactnative { class HybridLLMSpec; }
15
+ // Forward declaration of `HybridModelManagerSpec` to properly resolve imports.
16
+ namespace margelo::nitro::mlxreactnative { class HybridModelManagerSpec; }
17
+
18
+ // Forward declarations of Swift defined types
19
+ // Forward declaration of `HybridLLMSpec_cxx` to properly resolve imports.
20
+ namespace MLXReactNative { class HybridLLMSpec_cxx; }
21
+ // Forward declaration of `HybridModelManagerSpec_cxx` to properly resolve imports.
22
+ namespace MLXReactNative { class HybridModelManagerSpec_cxx; }
23
+
24
+ // Include C++ defined types
25
+ #include "GenerationStats.hpp"
26
+ #include "HybridLLMSpec.hpp"
27
+ #include "HybridModelManagerSpec.hpp"
28
+ #include <NitroModules/Promise.hpp>
29
+ #include <NitroModules/PromiseHolder.hpp>
30
+ #include <NitroModules/Result.hpp>
31
+ #include <exception>
32
+ #include <functional>
33
+ #include <memory>
34
+ #include <string>
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::mlxreactnative::bridge::swift {
42
+
43
+ // pragma MARK: std::shared_ptr<Promise<void>>
44
+ /**
45
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
46
+ */
47
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
48
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
49
+ return Promise<void>::create();
50
+ }
51
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
52
+ return PromiseHolder<void>(std::move(promise));
53
+ }
54
+
55
+ // pragma MARK: std::function<void()>
56
+ /**
57
+ * Specialized version of `std::function<void()>`.
58
+ */
59
+ using Func_void = std::function<void()>;
60
+ /**
61
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
62
+ */
63
+ class Func_void_Wrapper final {
64
+ public:
65
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
66
+ inline void call() const noexcept {
67
+ _function->operator()();
68
+ }
69
+ private:
70
+ std::unique_ptr<std::function<void()>> _function;
71
+ } SWIFT_NONCOPYABLE;
72
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
73
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
74
+ return Func_void_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::function<void(double /* progress */)>
100
+ /**
101
+ * Specialized version of `std::function<void(double)>`.
102
+ */
103
+ using Func_void_double = std::function<void(double /* progress */)>;
104
+ /**
105
+ * Wrapper class for a `std::function<void(double / * progress * /)>`, this can be used from Swift.
106
+ */
107
+ class Func_void_double_Wrapper final {
108
+ public:
109
+ explicit Func_void_double_Wrapper(std::function<void(double /* progress */)>&& func): _function(std::make_unique<std::function<void(double /* progress */)>>(std::move(func))) {}
110
+ inline void call(double progress) const noexcept {
111
+ _function->operator()(progress);
112
+ }
113
+ private:
114
+ std::unique_ptr<std::function<void(double /* progress */)>> _function;
115
+ } SWIFT_NONCOPYABLE;
116
+ Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept;
117
+ inline Func_void_double_Wrapper wrap_Func_void_double(Func_void_double value) noexcept {
118
+ return Func_void_double_Wrapper(std::move(value));
119
+ }
120
+
121
+ // pragma MARK: std::shared_ptr<Promise<std::string>>
122
+ /**
123
+ * Specialized version of `std::shared_ptr<Promise<std::string>>`.
124
+ */
125
+ using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
126
+ inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
127
+ return Promise<std::string>::create();
128
+ }
129
+ inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
130
+ return PromiseHolder<std::string>(std::move(promise));
131
+ }
132
+
133
+ // pragma MARK: std::function<void(const std::string& /* result */)>
134
+ /**
135
+ * Specialized version of `std::function<void(const std::string&)>`.
136
+ */
137
+ using Func_void_std__string = std::function<void(const std::string& /* result */)>;
138
+ /**
139
+ * Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
140
+ */
141
+ class Func_void_std__string_Wrapper final {
142
+ public:
143
+ 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))) {}
144
+ inline void call(std::string result) const noexcept {
145
+ _function->operator()(result);
146
+ }
147
+ private:
148
+ std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
149
+ } SWIFT_NONCOPYABLE;
150
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
151
+ inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
152
+ return Func_void_std__string_Wrapper(std::move(value));
153
+ }
154
+
155
+ // pragma MARK: std::shared_ptr<HybridLLMSpec>
156
+ /**
157
+ * Specialized version of `std::shared_ptr<HybridLLMSpec>`.
158
+ */
159
+ using std__shared_ptr_HybridLLMSpec_ = std::shared_ptr<HybridLLMSpec>;
160
+ std::shared_ptr<HybridLLMSpec> create_std__shared_ptr_HybridLLMSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
161
+ void* NON_NULL get_std__shared_ptr_HybridLLMSpec_(std__shared_ptr_HybridLLMSpec_ cppType);
162
+
163
+ // pragma MARK: std::weak_ptr<HybridLLMSpec>
164
+ using std__weak_ptr_HybridLLMSpec_ = std::weak_ptr<HybridLLMSpec>;
165
+ inline std__weak_ptr_HybridLLMSpec_ weakify_std__shared_ptr_HybridLLMSpec_(const std::shared_ptr<HybridLLMSpec>& strong) noexcept { return strong; }
166
+
167
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
168
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
169
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
170
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
171
+ }
172
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
173
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
174
+ }
175
+
176
+ // pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
177
+ using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
178
+ 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 {
179
+ return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
180
+ }
181
+ inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
182
+ return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
183
+ }
184
+
185
+ // pragma MARK: Result<void>
186
+ using Result_void_ = Result<void>;
187
+ inline Result_void_ create_Result_void_() noexcept {
188
+ return Result<void>::withValue();
189
+ }
190
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
191
+ return Result<void>::withError(error);
192
+ }
193
+
194
+ // pragma MARK: Result<GenerationStats>
195
+ using Result_GenerationStats_ = Result<GenerationStats>;
196
+ inline Result_GenerationStats_ create_Result_GenerationStats_(const GenerationStats& value) noexcept {
197
+ return Result<GenerationStats>::withValue(value);
198
+ }
199
+ inline Result_GenerationStats_ create_Result_GenerationStats_(const std::exception_ptr& error) noexcept {
200
+ return Result<GenerationStats>::withError(error);
201
+ }
202
+
203
+ // pragma MARK: std::shared_ptr<Promise<bool>>
204
+ /**
205
+ * Specialized version of `std::shared_ptr<Promise<bool>>`.
206
+ */
207
+ using std__shared_ptr_Promise_bool__ = std::shared_ptr<Promise<bool>>;
208
+ inline std::shared_ptr<Promise<bool>> create_std__shared_ptr_Promise_bool__() noexcept {
209
+ return Promise<bool>::create();
210
+ }
211
+ inline PromiseHolder<bool> wrap_std__shared_ptr_Promise_bool__(std::shared_ptr<Promise<bool>> promise) noexcept {
212
+ return PromiseHolder<bool>(std::move(promise));
213
+ }
214
+
215
+ // pragma MARK: std::function<void(bool /* result */)>
216
+ /**
217
+ * Specialized version of `std::function<void(bool)>`.
218
+ */
219
+ using Func_void_bool = std::function<void(bool /* result */)>;
220
+ /**
221
+ * Wrapper class for a `std::function<void(bool / * result * /)>`, this can be used from Swift.
222
+ */
223
+ class Func_void_bool_Wrapper final {
224
+ public:
225
+ explicit Func_void_bool_Wrapper(std::function<void(bool /* result */)>&& func): _function(std::make_unique<std::function<void(bool /* result */)>>(std::move(func))) {}
226
+ inline void call(bool result) const noexcept {
227
+ _function->operator()(result);
228
+ }
229
+ private:
230
+ std::unique_ptr<std::function<void(bool /* result */)>> _function;
231
+ } SWIFT_NONCOPYABLE;
232
+ Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept;
233
+ inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) noexcept {
234
+ return Func_void_bool_Wrapper(std::move(value));
235
+ }
236
+
237
+ // pragma MARK: std::vector<std::string>
238
+ /**
239
+ * Specialized version of `std::vector<std::string>`.
240
+ */
241
+ using std__vector_std__string_ = std::vector<std::string>;
242
+ inline std::vector<std::string> create_std__vector_std__string_(size_t size) noexcept {
243
+ std::vector<std::string> vector;
244
+ vector.reserve(size);
245
+ return vector;
246
+ }
247
+
248
+ // pragma MARK: std::shared_ptr<Promise<std::vector<std::string>>>
249
+ /**
250
+ * Specialized version of `std::shared_ptr<Promise<std::vector<std::string>>>`.
251
+ */
252
+ using std__shared_ptr_Promise_std__vector_std__string___ = std::shared_ptr<Promise<std::vector<std::string>>>;
253
+ inline std::shared_ptr<Promise<std::vector<std::string>>> create_std__shared_ptr_Promise_std__vector_std__string___() noexcept {
254
+ return Promise<std::vector<std::string>>::create();
255
+ }
256
+ inline PromiseHolder<std::vector<std::string>> wrap_std__shared_ptr_Promise_std__vector_std__string___(std::shared_ptr<Promise<std::vector<std::string>>> promise) noexcept {
257
+ return PromiseHolder<std::vector<std::string>>(std::move(promise));
258
+ }
259
+
260
+ // pragma MARK: std::function<void(const std::vector<std::string>& /* result */)>
261
+ /**
262
+ * Specialized version of `std::function<void(const std::vector<std::string>&)>`.
263
+ */
264
+ using Func_void_std__vector_std__string_ = std::function<void(const std::vector<std::string>& /* result */)>;
265
+ /**
266
+ * Wrapper class for a `std::function<void(const std::vector<std::string>& / * result * /)>`, this can be used from Swift.
267
+ */
268
+ class Func_void_std__vector_std__string__Wrapper final {
269
+ public:
270
+ explicit Func_void_std__vector_std__string__Wrapper(std::function<void(const std::vector<std::string>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::vector<std::string>& /* result */)>>(std::move(func))) {}
271
+ inline void call(std::vector<std::string> result) const noexcept {
272
+ _function->operator()(result);
273
+ }
274
+ private:
275
+ std::unique_ptr<std::function<void(const std::vector<std::string>& /* result */)>> _function;
276
+ } SWIFT_NONCOPYABLE;
277
+ Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* NON_NULL swiftClosureWrapper) noexcept;
278
+ inline Func_void_std__vector_std__string__Wrapper wrap_Func_void_std__vector_std__string_(Func_void_std__vector_std__string_ value) noexcept {
279
+ return Func_void_std__vector_std__string__Wrapper(std::move(value));
280
+ }
281
+
282
+ // pragma MARK: std::shared_ptr<HybridModelManagerSpec>
283
+ /**
284
+ * Specialized version of `std::shared_ptr<HybridModelManagerSpec>`.
285
+ */
286
+ using std__shared_ptr_HybridModelManagerSpec_ = std::shared_ptr<HybridModelManagerSpec>;
287
+ std::shared_ptr<HybridModelManagerSpec> create_std__shared_ptr_HybridModelManagerSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
288
+ void* NON_NULL get_std__shared_ptr_HybridModelManagerSpec_(std__shared_ptr_HybridModelManagerSpec_ cppType);
289
+
290
+ // pragma MARK: std::weak_ptr<HybridModelManagerSpec>
291
+ using std__weak_ptr_HybridModelManagerSpec_ = std::weak_ptr<HybridModelManagerSpec>;
292
+ inline std__weak_ptr_HybridModelManagerSpec_ weakify_std__shared_ptr_HybridModelManagerSpec_(const std::shared_ptr<HybridModelManagerSpec>& strong) noexcept { return strong; }
293
+
294
+ // pragma MARK: Result<std::shared_ptr<Promise<bool>>>
295
+ using Result_std__shared_ptr_Promise_bool___ = Result<std::shared_ptr<Promise<bool>>>;
296
+ inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::shared_ptr<Promise<bool>>& value) noexcept {
297
+ return Result<std::shared_ptr<Promise<bool>>>::withValue(value);
298
+ }
299
+ inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::exception_ptr& error) noexcept {
300
+ return Result<std::shared_ptr<Promise<bool>>>::withError(error);
301
+ }
302
+
303
+ // pragma MARK: Result<std::shared_ptr<Promise<std::vector<std::string>>>>
304
+ using Result_std__shared_ptr_Promise_std__vector_std__string____ = Result<std::shared_ptr<Promise<std::vector<std::string>>>>;
305
+ inline Result_std__shared_ptr_Promise_std__vector_std__string____ create_Result_std__shared_ptr_Promise_std__vector_std__string____(const std::shared_ptr<Promise<std::vector<std::string>>>& value) noexcept {
306
+ return Result<std::shared_ptr<Promise<std::vector<std::string>>>>::withValue(value);
307
+ }
308
+ inline Result_std__shared_ptr_Promise_std__vector_std__string____ create_Result_std__shared_ptr_Promise_std__vector_std__string____(const std::exception_ptr& error) noexcept {
309
+ return Result<std::shared_ptr<Promise<std::vector<std::string>>>>::withError(error);
310
+ }
311
+
312
+ } // namespace margelo::nitro::mlxreactnative::bridge::swift
@@ -0,0 +1,55 @@
1
+ ///
2
+ /// MLXReactNative-Swift-Cxx-Umbrella.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 `GenerationStats` to properly resolve imports.
12
+ namespace margelo::nitro::mlxreactnative { struct GenerationStats; }
13
+ // Forward declaration of `HybridLLMSpec` to properly resolve imports.
14
+ namespace margelo::nitro::mlxreactnative { class HybridLLMSpec; }
15
+ // Forward declaration of `HybridModelManagerSpec` to properly resolve imports.
16
+ namespace margelo::nitro::mlxreactnative { class HybridModelManagerSpec; }
17
+
18
+ // Include C++ defined types
19
+ #include "GenerationStats.hpp"
20
+ #include "HybridLLMSpec.hpp"
21
+ #include "HybridModelManagerSpec.hpp"
22
+ #include <NitroModules/Promise.hpp>
23
+ #include <NitroModules/Result.hpp>
24
+ #include <exception>
25
+ #include <functional>
26
+ #include <memory>
27
+ #include <string>
28
+ #include <vector>
29
+
30
+ // C++ helpers for Swift
31
+ #include "MLXReactNative-Swift-Cxx-Bridge.hpp"
32
+
33
+ // Common C++ types used in Swift
34
+ #include <NitroModules/ArrayBufferHolder.hpp>
35
+ #include <NitroModules/AnyMapUtils.hpp>
36
+ #include <NitroModules/RuntimeError.hpp>
37
+ #include <NitroModules/DateToChronoDate.hpp>
38
+
39
+ // Forward declarations of Swift defined types
40
+ // Forward declaration of `HybridLLMSpec_cxx` to properly resolve imports.
41
+ namespace MLXReactNative { class HybridLLMSpec_cxx; }
42
+ // Forward declaration of `HybridModelManagerSpec_cxx` to properly resolve imports.
43
+ namespace MLXReactNative { class HybridModelManagerSpec_cxx; }
44
+
45
+ // Include Swift defined types
46
+ #if __has_include("MLXReactNative-Swift.h")
47
+ // This header is generated by Xcode/Swift on every app build.
48
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "MLXReactNative".
49
+ #include "MLXReactNative-Swift.h"
50
+ // Same as above, but used when building with frameworks (`use_frameworks`)
51
+ #elif __has_include(<MLXReactNative/MLXReactNative-Swift.h>)
52
+ #include <MLXReactNative/MLXReactNative-Swift.h>
53
+ #else
54
+ #error MLXReactNative's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "MLXReactNative", and try building the app first.
55
+ #endif
@@ -0,0 +1,41 @@
1
+ ///
2
+ /// MLXReactNativeAutolinking.mm
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/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "MLXReactNative-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridLLMSpecSwift.hpp"
14
+ #include "HybridModelManagerSpecSwift.hpp"
15
+
16
+ @interface MLXReactNativeAutolinking : NSObject
17
+ @end
18
+
19
+ @implementation MLXReactNativeAutolinking
20
+
21
+ + (void) load {
22
+ using namespace margelo::nitro;
23
+ using namespace margelo::nitro::mlxreactnative;
24
+
25
+ HybridObjectRegistry::registerHybridObjectConstructor(
26
+ "LLM",
27
+ []() -> std::shared_ptr<HybridObject> {
28
+ std::shared_ptr<HybridLLMSpec> hybridObject = MLXReactNative::MLXReactNativeAutolinking::createLLM();
29
+ return hybridObject;
30
+ }
31
+ );
32
+ HybridObjectRegistry::registerHybridObjectConstructor(
33
+ "ModelManager",
34
+ []() -> std::shared_ptr<HybridObject> {
35
+ std::shared_ptr<HybridModelManagerSpec> hybridObject = MLXReactNative::MLXReactNativeAutolinking::createModelManager();
36
+ return hybridObject;
37
+ }
38
+ );
39
+ }
40
+
41
+ @end
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// MLXReactNativeAutolinking.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 MLXReactNativeAutolinking {
9
+ public typealias bridge = margelo.nitro.mlxreactnative.bridge.swift
10
+
11
+ /**
12
+ * Creates an instance of a Swift class that implements `HybridLLMSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridLLMSpec_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, `HybridLLM`).
17
+ */
18
+ public static func createLLM() -> bridge.std__shared_ptr_HybridLLMSpec_ {
19
+ let hybridObject = HybridLLM()
20
+ return { () -> bridge.std__shared_ptr_HybridLLMSpec_ in
21
+ let __cxxWrapped = hybridObject.getCxxWrapper()
22
+ return __cxxWrapped.getCxxPart()
23
+ }()
24
+ }
25
+
26
+ /**
27
+ * Creates an instance of a Swift class that implements `HybridModelManagerSpec`,
28
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridModelManagerSpec_cxx`)
29
+ *
30
+ * This is generated by Nitrogen and will initialize the class specified
31
+ * in the `"autolinking"` property of `nitro.json` (in this case, `HybridModelManager`).
32
+ */
33
+ public static func createModelManager() -> bridge.std__shared_ptr_HybridModelManagerSpec_ {
34
+ let hybridObject = HybridModelManager()
35
+ return { () -> bridge.std__shared_ptr_HybridModelManagerSpec_ in
36
+ let __cxxWrapped = hybridObject.getCxxWrapper()
37
+ return __cxxWrapped.getCxxPart()
38
+ }()
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridLLMSpecSwift.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 "HybridLLMSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::mlxreactnative {
11
+ } // namespace margelo::nitro::mlxreactnative