@inferrlm/react-native-mlx 0.2.0-inferrlm.1

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 (71) hide show
  1. package/MLXReactNative.podspec +42 -0
  2. package/ios/Bridge.h +8 -0
  3. package/ios/Sources/HybridLLM.swift +245 -0
  4. package/ios/Sources/HybridModelManager.swift +77 -0
  5. package/ios/Sources/LLMError.swift +6 -0
  6. package/ios/Sources/MLXReactNative.h +16 -0
  7. package/ios/Sources/ModelDownloader.swift +103 -0
  8. package/lib/module/index.js +6 -0
  9. package/lib/module/index.js.map +1 -0
  10. package/lib/module/llm.js +125 -0
  11. package/lib/module/llm.js.map +1 -0
  12. package/lib/module/modelManager.js +79 -0
  13. package/lib/module/modelManager.js.map +1 -0
  14. package/lib/module/models.js +41 -0
  15. package/lib/module/models.js.map +1 -0
  16. package/lib/module/package.json +1 -0
  17. package/lib/module/specs/LLM.nitro.js +4 -0
  18. package/lib/module/specs/LLM.nitro.js.map +1 -0
  19. package/lib/module/specs/ModelManager.nitro.js +4 -0
  20. package/lib/module/specs/ModelManager.nitro.js.map +1 -0
  21. package/lib/typescript/package.json +1 -0
  22. package/lib/typescript/src/index.d.ts +6 -0
  23. package/lib/typescript/src/index.d.ts.map +1 -0
  24. package/lib/typescript/src/llm.d.ts +87 -0
  25. package/lib/typescript/src/llm.d.ts.map +1 -0
  26. package/lib/typescript/src/modelManager.d.ts +53 -0
  27. package/lib/typescript/src/modelManager.d.ts.map +1 -0
  28. package/lib/typescript/src/models.d.ts +29 -0
  29. package/lib/typescript/src/models.d.ts.map +1 -0
  30. package/lib/typescript/src/specs/LLM.nitro.d.ts +88 -0
  31. package/lib/typescript/src/specs/LLM.nitro.d.ts.map +1 -0
  32. package/lib/typescript/src/specs/ModelManager.nitro.d.ts +41 -0
  33. package/lib/typescript/src/specs/ModelManager.nitro.d.ts.map +1 -0
  34. package/nitrogen/generated/.gitattributes +1 -0
  35. package/nitrogen/generated/ios/MLXReactNative+autolinking.rb +60 -0
  36. package/nitrogen/generated/ios/MLXReactNative-Swift-Cxx-Bridge.cpp +98 -0
  37. package/nitrogen/generated/ios/MLXReactNative-Swift-Cxx-Bridge.hpp +399 -0
  38. package/nitrogen/generated/ios/MLXReactNative-Swift-Cxx-Umbrella.hpp +62 -0
  39. package/nitrogen/generated/ios/MLXReactNativeAutolinking.mm +41 -0
  40. package/nitrogen/generated/ios/MLXReactNativeAutolinking.swift +40 -0
  41. package/nitrogen/generated/ios/c++/HybridLLMSpecSwift.cpp +11 -0
  42. package/nitrogen/generated/ios/c++/HybridLLMSpecSwift.hpp +160 -0
  43. package/nitrogen/generated/ios/c++/HybridModelManagerSpecSwift.cpp +11 -0
  44. package/nitrogen/generated/ios/c++/HybridModelManagerSpecSwift.hpp +116 -0
  45. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  46. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  47. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -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/Func_void_std__vector_std__string_.swift +47 -0
  51. package/nitrogen/generated/ios/swift/GenerationStats.swift +69 -0
  52. package/nitrogen/generated/ios/swift/HybridLLMSpec.swift +67 -0
  53. package/nitrogen/generated/ios/swift/HybridLLMSpec_cxx.swift +285 -0
  54. package/nitrogen/generated/ios/swift/HybridModelManagerSpec.swift +60 -0
  55. package/nitrogen/generated/ios/swift/HybridModelManagerSpec_cxx.swift +234 -0
  56. package/nitrogen/generated/ios/swift/LLMLoadOptions.swift +138 -0
  57. package/nitrogen/generated/ios/swift/LLMMessage.swift +47 -0
  58. package/nitrogen/generated/shared/c++/GenerationStats.hpp +87 -0
  59. package/nitrogen/generated/shared/c++/HybridLLMSpec.cpp +35 -0
  60. package/nitrogen/generated/shared/c++/HybridLLMSpec.hpp +87 -0
  61. package/nitrogen/generated/shared/c++/HybridModelManagerSpec.cpp +27 -0
  62. package/nitrogen/generated/shared/c++/HybridModelManagerSpec.hpp +70 -0
  63. package/nitrogen/generated/shared/c++/LLMLoadOptions.hpp +87 -0
  64. package/nitrogen/generated/shared/c++/LLMMessage.hpp +79 -0
  65. package/package.json +142 -0
  66. package/src/index.ts +6 -0
  67. package/src/llm.ts +144 -0
  68. package/src/modelManager.ts +88 -0
  69. package/src/models.ts +45 -0
  70. package/src/specs/LLM.nitro.ts +98 -0
  71. package/src/specs/ModelManager.nitro.ts +44 -0
@@ -0,0 +1,160 @@
1
+ ///
2
+ /// HybridLLMSpecSwift.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 "HybridLLMSpec.hpp"
11
+
12
+ // Forward declaration of `HybridLLMSpec_cxx` to properly resolve imports.
13
+ namespace MLXReactNative { class HybridLLMSpec_cxx; }
14
+
15
+ // Forward declaration of `LLMLoadOptions` to properly resolve imports.
16
+ namespace margelo::nitro::mlxreactnative { struct LLMLoadOptions; }
17
+ // Forward declaration of `LLMMessage` to properly resolve imports.
18
+ namespace margelo::nitro::mlxreactnative { struct LLMMessage; }
19
+ // Forward declaration of `GenerationStats` to properly resolve imports.
20
+ namespace margelo::nitro::mlxreactnative { struct GenerationStats; }
21
+
22
+ #include <string>
23
+ #include <NitroModules/Promise.hpp>
24
+ #include "LLMLoadOptions.hpp"
25
+ #include <optional>
26
+ #include <functional>
27
+ #include "LLMMessage.hpp"
28
+ #include <vector>
29
+ #include "GenerationStats.hpp"
30
+
31
+ #include "MLXReactNative-Swift-Cxx-Umbrella.hpp"
32
+
33
+ namespace margelo::nitro::mlxreactnative {
34
+
35
+ /**
36
+ * The C++ part of HybridLLMSpec_cxx.swift.
37
+ *
38
+ * HybridLLMSpecSwift (C++) accesses HybridLLMSpec_cxx (Swift), and might
39
+ * contain some additional bridging code for C++ <> Swift interop.
40
+ *
41
+ * Since this obviously introduces an overhead, I hope at some point in
42
+ * the future, HybridLLMSpec_cxx can directly inherit from the C++ class HybridLLMSpec
43
+ * to simplify the whole structure and memory management.
44
+ */
45
+ class HybridLLMSpecSwift: public virtual HybridLLMSpec {
46
+ public:
47
+ // Constructor from a Swift instance
48
+ explicit HybridLLMSpecSwift(const MLXReactNative::HybridLLMSpec_cxx& swiftPart):
49
+ HybridObject(HybridLLMSpec::TAG),
50
+ _swiftPart(swiftPart) { }
51
+
52
+ public:
53
+ // Get the Swift part
54
+ inline MLXReactNative::HybridLLMSpec_cxx& getSwiftPart() noexcept {
55
+ return _swiftPart;
56
+ }
57
+
58
+ public:
59
+ inline size_t getExternalMemorySize() noexcept override {
60
+ return _swiftPart.getMemorySize();
61
+ }
62
+ void dispose() noexcept override {
63
+ _swiftPart.dispose();
64
+ }
65
+ std::string toString() override {
66
+ return _swiftPart.toString();
67
+ }
68
+
69
+ public:
70
+ // Properties
71
+ inline bool getIsLoaded() noexcept override {
72
+ return _swiftPart.isLoaded();
73
+ }
74
+ inline bool getIsGenerating() noexcept override {
75
+ return _swiftPart.isGenerating();
76
+ }
77
+ inline std::string getModelId() noexcept override {
78
+ auto __result = _swiftPart.getModelId();
79
+ return __result;
80
+ }
81
+ inline bool getDebug() noexcept override {
82
+ return _swiftPart.getDebug();
83
+ }
84
+ inline void setDebug(bool debug) noexcept override {
85
+ _swiftPart.setDebug(std::forward<decltype(debug)>(debug));
86
+ }
87
+ inline std::string getSystemPrompt() noexcept override {
88
+ auto __result = _swiftPart.getSystemPrompt();
89
+ return __result;
90
+ }
91
+ inline void setSystemPrompt(const std::string& systemPrompt) noexcept override {
92
+ _swiftPart.setSystemPrompt(systemPrompt);
93
+ }
94
+
95
+ public:
96
+ // Methods
97
+ inline std::shared_ptr<Promise<void>> load(const std::string& modelId, const std::optional<LLMLoadOptions>& options) override {
98
+ auto __result = _swiftPart.load(modelId, options);
99
+ if (__result.hasError()) [[unlikely]] {
100
+ std::rethrow_exception(__result.error());
101
+ }
102
+ auto __value = std::move(__result.value());
103
+ return __value;
104
+ }
105
+ inline std::shared_ptr<Promise<std::string>> generate(const std::string& prompt) override {
106
+ auto __result = _swiftPart.generate(prompt);
107
+ if (__result.hasError()) [[unlikely]] {
108
+ std::rethrow_exception(__result.error());
109
+ }
110
+ auto __value = std::move(__result.value());
111
+ return __value;
112
+ }
113
+ inline std::shared_ptr<Promise<std::string>> stream(const std::string& prompt, const std::function<void(const std::string& /* token */)>& onToken) override {
114
+ auto __result = _swiftPart.stream(prompt, onToken);
115
+ if (__result.hasError()) [[unlikely]] {
116
+ std::rethrow_exception(__result.error());
117
+ }
118
+ auto __value = std::move(__result.value());
119
+ return __value;
120
+ }
121
+ inline void stop() override {
122
+ auto __result = _swiftPart.stop();
123
+ if (__result.hasError()) [[unlikely]] {
124
+ std::rethrow_exception(__result.error());
125
+ }
126
+ }
127
+ inline void unload() override {
128
+ auto __result = _swiftPart.unload();
129
+ if (__result.hasError()) [[unlikely]] {
130
+ std::rethrow_exception(__result.error());
131
+ }
132
+ }
133
+ inline GenerationStats getLastGenerationStats() override {
134
+ auto __result = _swiftPart.getLastGenerationStats();
135
+ if (__result.hasError()) [[unlikely]] {
136
+ std::rethrow_exception(__result.error());
137
+ }
138
+ auto __value = std::move(__result.value());
139
+ return __value;
140
+ }
141
+ inline std::vector<LLMMessage> getHistory() override {
142
+ auto __result = _swiftPart.getHistory();
143
+ if (__result.hasError()) [[unlikely]] {
144
+ std::rethrow_exception(__result.error());
145
+ }
146
+ auto __value = std::move(__result.value());
147
+ return __value;
148
+ }
149
+ inline void clearHistory() override {
150
+ auto __result = _swiftPart.clearHistory();
151
+ if (__result.hasError()) [[unlikely]] {
152
+ std::rethrow_exception(__result.error());
153
+ }
154
+ }
155
+
156
+ private:
157
+ MLXReactNative::HybridLLMSpec_cxx _swiftPart;
158
+ };
159
+
160
+ } // namespace margelo::nitro::mlxreactnative
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridModelManagerSpecSwift.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 "HybridModelManagerSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::mlxreactnative {
11
+ } // namespace margelo::nitro::mlxreactnative
@@ -0,0 +1,116 @@
1
+ ///
2
+ /// HybridModelManagerSpecSwift.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 "HybridModelManagerSpec.hpp"
11
+
12
+ // Forward declaration of `HybridModelManagerSpec_cxx` to properly resolve imports.
13
+ namespace MLXReactNative { class HybridModelManagerSpec_cxx; }
14
+
15
+
16
+
17
+ #include <string>
18
+ #include <NitroModules/Promise.hpp>
19
+ #include <functional>
20
+ #include <vector>
21
+
22
+ #include "MLXReactNative-Swift-Cxx-Umbrella.hpp"
23
+
24
+ namespace margelo::nitro::mlxreactnative {
25
+
26
+ /**
27
+ * The C++ part of HybridModelManagerSpec_cxx.swift.
28
+ *
29
+ * HybridModelManagerSpecSwift (C++) accesses HybridModelManagerSpec_cxx (Swift), and might
30
+ * contain some additional bridging code for C++ <> Swift interop.
31
+ *
32
+ * Since this obviously introduces an overhead, I hope at some point in
33
+ * the future, HybridModelManagerSpec_cxx can directly inherit from the C++ class HybridModelManagerSpec
34
+ * to simplify the whole structure and memory management.
35
+ */
36
+ class HybridModelManagerSpecSwift: public virtual HybridModelManagerSpec {
37
+ public:
38
+ // Constructor from a Swift instance
39
+ explicit HybridModelManagerSpecSwift(const MLXReactNative::HybridModelManagerSpec_cxx& swiftPart):
40
+ HybridObject(HybridModelManagerSpec::TAG),
41
+ _swiftPart(swiftPart) { }
42
+
43
+ public:
44
+ // Get the Swift part
45
+ inline MLXReactNative::HybridModelManagerSpec_cxx& getSwiftPart() noexcept {
46
+ return _swiftPart;
47
+ }
48
+
49
+ public:
50
+ inline size_t getExternalMemorySize() noexcept override {
51
+ return _swiftPart.getMemorySize();
52
+ }
53
+ void dispose() noexcept override {
54
+ _swiftPart.dispose();
55
+ }
56
+ std::string toString() override {
57
+ return _swiftPart.toString();
58
+ }
59
+
60
+ public:
61
+ // Properties
62
+ inline bool getDebug() noexcept override {
63
+ return _swiftPart.getDebug();
64
+ }
65
+ inline void setDebug(bool debug) noexcept override {
66
+ _swiftPart.setDebug(std::forward<decltype(debug)>(debug));
67
+ }
68
+
69
+ public:
70
+ // Methods
71
+ inline std::shared_ptr<Promise<std::string>> download(const std::string& modelId, const std::function<void(double /* progress */)>& progressCallback) override {
72
+ auto __result = _swiftPart.download(modelId, progressCallback);
73
+ if (__result.hasError()) [[unlikely]] {
74
+ std::rethrow_exception(__result.error());
75
+ }
76
+ auto __value = std::move(__result.value());
77
+ return __value;
78
+ }
79
+ inline std::shared_ptr<Promise<bool>> isDownloaded(const std::string& modelId) override {
80
+ auto __result = _swiftPart.isDownloaded(modelId);
81
+ if (__result.hasError()) [[unlikely]] {
82
+ std::rethrow_exception(__result.error());
83
+ }
84
+ auto __value = std::move(__result.value());
85
+ return __value;
86
+ }
87
+ inline std::shared_ptr<Promise<std::vector<std::string>>> getDownloadedModels() override {
88
+ auto __result = _swiftPart.getDownloadedModels();
89
+ if (__result.hasError()) [[unlikely]] {
90
+ std::rethrow_exception(__result.error());
91
+ }
92
+ auto __value = std::move(__result.value());
93
+ return __value;
94
+ }
95
+ inline std::shared_ptr<Promise<void>> deleteModel(const std::string& modelId) override {
96
+ auto __result = _swiftPart.deleteModel(modelId);
97
+ if (__result.hasError()) [[unlikely]] {
98
+ std::rethrow_exception(__result.error());
99
+ }
100
+ auto __value = std::move(__result.value());
101
+ return __value;
102
+ }
103
+ inline std::shared_ptr<Promise<std::string>> getModelPath(const std::string& modelId) override {
104
+ auto __result = _swiftPart.getModelPath(modelId);
105
+ if (__result.hasError()) [[unlikely]] {
106
+ std::rethrow_exception(__result.error());
107
+ }
108
+ auto __value = std::move(__result.value());
109
+ return __value;
110
+ }
111
+
112
+ private:
113
+ MLXReactNative::HybridModelManagerSpec_cxx _swiftPart;
114
+ };
115
+
116
+ } // namespace margelo::nitro::mlxreactnative
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void.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
+ * Wraps a Swift `() -> 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 {
16
+ public typealias bridge = margelo.nitro.mlxreactnative.bridge.swift
17
+
18
+ private let closure: () -> Void
19
+
20
+ public init(_ closure: @escaping () -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call() -> Void {
26
+ self.closure()
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`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
45
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_bool.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
+ * Wraps a Swift `(_ value: Bool) -> 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_bool {
16
+ public typealias bridge = margelo.nitro.mlxreactnative.bridge.swift
17
+
18
+ private let closure: (_ value: Bool) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: Bool) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: Bool) -> Void {
26
+ self.closure(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_bool`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
45
+ return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_double.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
+ * Wraps a Swift `(_ progress: Double) -> 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_double {
16
+ public typealias bridge = margelo.nitro.mlxreactnative.bridge.swift
17
+
18
+ private let closure: (_ progress: Double) -> Void
19
+
20
+ public init(_ closure: @escaping (_ progress: Double) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(progress: Double) -> Void {
26
+ self.closure(progress)
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_double`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_double>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_double {
45
+ return Unmanaged<Func_void_double>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -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 Foundation
9
+ import NitroModules
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.mlxreactnative.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 Foundation
9
+ import NitroModules
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.mlxreactnative.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,47 @@
1
+ ///
2
+ /// Func_void_std__vector_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 Foundation
9
+ import NitroModules
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__vector_std__string_ {
16
+ public typealias bridge = margelo.nitro.mlxreactnative.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: bridge.std__vector_std__string_) -> Void {
26
+ self.closure(value.map({ __item in String(__item) }))
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__vector_std__string_`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_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__vector_std__string_ {
45
+ return Unmanaged<Func_void_std__vector_std__string_>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// GenerationStats.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
+ * Represents an instance of `GenerationStats`, backed by a C++ struct.
13
+ */
14
+ public typealias GenerationStats = margelo.nitro.mlxreactnative.GenerationStats
15
+
16
+ public extension GenerationStats {
17
+ private typealias bridge = margelo.nitro.mlxreactnative.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `GenerationStats`.
21
+ */
22
+ init(tokenCount: Double, tokensPerSecond: Double, timeToFirstToken: Double, totalTime: Double) {
23
+ self.init(tokenCount, tokensPerSecond, timeToFirstToken, totalTime)
24
+ }
25
+
26
+ var tokenCount: Double {
27
+ @inline(__always)
28
+ get {
29
+ return self.__tokenCount
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__tokenCount = newValue
34
+ }
35
+ }
36
+
37
+ var tokensPerSecond: Double {
38
+ @inline(__always)
39
+ get {
40
+ return self.__tokensPerSecond
41
+ }
42
+ @inline(__always)
43
+ set {
44
+ self.__tokensPerSecond = newValue
45
+ }
46
+ }
47
+
48
+ var timeToFirstToken: Double {
49
+ @inline(__always)
50
+ get {
51
+ return self.__timeToFirstToken
52
+ }
53
+ @inline(__always)
54
+ set {
55
+ self.__timeToFirstToken = newValue
56
+ }
57
+ }
58
+
59
+ var totalTime: Double {
60
+ @inline(__always)
61
+ get {
62
+ return self.__totalTime
63
+ }
64
+ @inline(__always)
65
+ set {
66
+ self.__totalTime = newValue
67
+ }
68
+ }
69
+ }