@onekeyfe/react-native-range-downloader 3.0.39

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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/ReactNativeRangeDownloader.podspec +30 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +132 -0
  6. package/android/gradle.properties +4 -0
  7. package/android/src/main/AndroidManifest.xml +1 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ConcurrentRangeDownloader.kt +340 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ReactNativeRangeDownloader.kt +233 -0
  11. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ReactNativeRangeDownloaderPackage.kt +24 -0
  12. package/ios/ReactNativeRangeDownloader.swift +732 -0
  13. package/lib/module/ReactNativeRangeDownloader.nitro.js +4 -0
  14. package/lib/module/ReactNativeRangeDownloader.nitro.js.map +1 -0
  15. package/lib/module/index.js +15 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/typescript/package.json +1 -0
  19. package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts +35 -0
  20. package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts.map +1 -0
  21. package/lib/typescript/src/index.d.ts +9 -0
  22. package/lib/typescript/src/index.d.ts.map +1 -0
  23. package/nitro.json +17 -0
  24. package/nitrogen/generated/android/c++/JDownloadChannel.hpp +62 -0
  25. package/nitrogen/generated/android/c++/JFunc_void_RangeDownloadEvent.hpp +80 -0
  26. package/nitrogen/generated/android/c++/JHybridReactNativeRangeDownloaderSpec.cpp +117 -0
  27. package/nitrogen/generated/android/c++/JHybridReactNativeRangeDownloaderSpec.hpp +69 -0
  28. package/nitrogen/generated/android/c++/JRangeDownloadEvent.hpp +75 -0
  29. package/nitrogen/generated/android/c++/JRangeDownloadOutcome.hpp +59 -0
  30. package/nitrogen/generated/android/c++/JRangeDownloadParams.hpp +84 -0
  31. package/nitrogen/generated/android/c++/JRangeDownloadResult.hpp +68 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/DownloadChannel.kt +22 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/Func_void_RangeDownloadEvent.kt +80 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/HybridReactNativeRangeDownloaderSpec.kt +79 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadEvent.kt +50 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadOutcome.kt +21 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadParams.kt +56 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadResult.kt +44 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/reactnativerangedownloaderOnLoad.kt +35 -0
  40. package/nitrogen/generated/android/reactnativerangedownloader+autolinking.cmake +81 -0
  41. package/nitrogen/generated/android/reactnativerangedownloader+autolinking.gradle +27 -0
  42. package/nitrogen/generated/android/reactnativerangedownloaderOnLoad.cpp +46 -0
  43. package/nitrogen/generated/android/reactnativerangedownloaderOnLoad.hpp +25 -0
  44. package/nitrogen/generated/ios/ReactNativeRangeDownloader+autolinking.rb +60 -0
  45. package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Bridge.cpp +65 -0
  46. package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Bridge.hpp +246 -0
  47. package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Umbrella.hpp +62 -0
  48. package/nitrogen/generated/ios/ReactNativeRangeDownloaderAutolinking.mm +33 -0
  49. package/nitrogen/generated/ios/ReactNativeRangeDownloaderAutolinking.swift +25 -0
  50. package/nitrogen/generated/ios/c++/HybridReactNativeRangeDownloaderSpecSwift.cpp +11 -0
  51. package/nitrogen/generated/ios/c++/HybridReactNativeRangeDownloaderSpecSwift.hpp +123 -0
  52. package/nitrogen/generated/ios/swift/DownloadChannel.swift +44 -0
  53. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  54. package/nitrogen/generated/ios/swift/Func_void_RangeDownloadEvent.swift +47 -0
  55. package/nitrogen/generated/ios/swift/Func_void_RangeDownloadResult.swift +47 -0
  56. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  57. package/nitrogen/generated/ios/swift/HybridReactNativeRangeDownloaderSpec.swift +60 -0
  58. package/nitrogen/generated/ios/swift/HybridReactNativeRangeDownloaderSpec_cxx.swift +197 -0
  59. package/nitrogen/generated/ios/swift/RangeDownloadEvent.swift +80 -0
  60. package/nitrogen/generated/ios/swift/RangeDownloadOutcome.swift +40 -0
  61. package/nitrogen/generated/ios/swift/RangeDownloadParams.swift +145 -0
  62. package/nitrogen/generated/ios/swift/RangeDownloadResult.swift +77 -0
  63. package/nitrogen/generated/shared/c++/DownloadChannel.hpp +80 -0
  64. package/nitrogen/generated/shared/c++/HybridReactNativeRangeDownloaderSpec.cpp +25 -0
  65. package/nitrogen/generated/shared/c++/HybridReactNativeRangeDownloaderSpec.hpp +79 -0
  66. package/nitrogen/generated/shared/c++/RangeDownloadEvent.hpp +93 -0
  67. package/nitrogen/generated/shared/c++/RangeDownloadOutcome.hpp +76 -0
  68. package/nitrogen/generated/shared/c++/RangeDownloadParams.hpp +102 -0
  69. package/nitrogen/generated/shared/c++/RangeDownloadResult.hpp +86 -0
  70. package/package.json +169 -0
  71. package/src/ReactNativeRangeDownloader.nitro.ts +60 -0
  72. package/src/index.tsx +20 -0
@@ -0,0 +1,145 @@
1
+ ///
2
+ /// RangeDownloadParams.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `RangeDownloadParams`, backed by a C++ struct.
13
+ */
14
+ public typealias RangeDownloadParams = margelo.nitro.reactnativerangedownloader.RangeDownloadParams
15
+
16
+ public extension RangeDownloadParams {
17
+ private typealias bridge = margelo.nitro.reactnativerangedownloader.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `RangeDownloadParams`.
21
+ */
22
+ init(channel: DownloadChannel, taskId: String, url: String, destFilePath: String, expectedSha256: String?, segmentCount: Double?, minConcurrentBytes: Double?) {
23
+ self.init(channel, std.string(taskId), std.string(url), std.string(destFilePath), { () -> bridge.std__optional_std__string_ in
24
+ if let __unwrappedValue = expectedSha256 {
25
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
26
+ } else {
27
+ return .init()
28
+ }
29
+ }(), { () -> bridge.std__optional_double_ in
30
+ if let __unwrappedValue = segmentCount {
31
+ return bridge.create_std__optional_double_(__unwrappedValue)
32
+ } else {
33
+ return .init()
34
+ }
35
+ }(), { () -> bridge.std__optional_double_ in
36
+ if let __unwrappedValue = minConcurrentBytes {
37
+ return bridge.create_std__optional_double_(__unwrappedValue)
38
+ } else {
39
+ return .init()
40
+ }
41
+ }())
42
+ }
43
+
44
+ var channel: DownloadChannel {
45
+ @inline(__always)
46
+ get {
47
+ return self.__channel
48
+ }
49
+ @inline(__always)
50
+ set {
51
+ self.__channel = newValue
52
+ }
53
+ }
54
+
55
+ var taskId: String {
56
+ @inline(__always)
57
+ get {
58
+ return String(self.__taskId)
59
+ }
60
+ @inline(__always)
61
+ set {
62
+ self.__taskId = std.string(newValue)
63
+ }
64
+ }
65
+
66
+ var url: String {
67
+ @inline(__always)
68
+ get {
69
+ return String(self.__url)
70
+ }
71
+ @inline(__always)
72
+ set {
73
+ self.__url = std.string(newValue)
74
+ }
75
+ }
76
+
77
+ var destFilePath: String {
78
+ @inline(__always)
79
+ get {
80
+ return String(self.__destFilePath)
81
+ }
82
+ @inline(__always)
83
+ set {
84
+ self.__destFilePath = std.string(newValue)
85
+ }
86
+ }
87
+
88
+ var expectedSha256: String? {
89
+ @inline(__always)
90
+ get {
91
+ return { () -> String? in
92
+ if bridge.has_value_std__optional_std__string_(self.__expectedSha256) {
93
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__expectedSha256)
94
+ return String(__unwrapped)
95
+ } else {
96
+ return nil
97
+ }
98
+ }()
99
+ }
100
+ @inline(__always)
101
+ set {
102
+ self.__expectedSha256 = { () -> bridge.std__optional_std__string_ in
103
+ if let __unwrappedValue = newValue {
104
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
105
+ } else {
106
+ return .init()
107
+ }
108
+ }()
109
+ }
110
+ }
111
+
112
+ var segmentCount: Double? {
113
+ @inline(__always)
114
+ get {
115
+ return self.__segmentCount.value
116
+ }
117
+ @inline(__always)
118
+ set {
119
+ self.__segmentCount = { () -> bridge.std__optional_double_ in
120
+ if let __unwrappedValue = newValue {
121
+ return bridge.create_std__optional_double_(__unwrappedValue)
122
+ } else {
123
+ return .init()
124
+ }
125
+ }()
126
+ }
127
+ }
128
+
129
+ var minConcurrentBytes: Double? {
130
+ @inline(__always)
131
+ get {
132
+ return self.__minConcurrentBytes.value
133
+ }
134
+ @inline(__always)
135
+ set {
136
+ self.__minConcurrentBytes = { () -> bridge.std__optional_double_ in
137
+ if let __unwrappedValue = newValue {
138
+ return bridge.create_std__optional_double_(__unwrappedValue)
139
+ } else {
140
+ return .init()
141
+ }
142
+ }()
143
+ }
144
+ }
145
+ }
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// RangeDownloadResult.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `RangeDownloadResult`, backed by a C++ struct.
13
+ */
14
+ public typealias RangeDownloadResult = margelo.nitro.reactnativerangedownloader.RangeDownloadResult
15
+
16
+ public extension RangeDownloadResult {
17
+ private typealias bridge = margelo.nitro.reactnativerangedownloader.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `RangeDownloadResult`.
21
+ */
22
+ init(outcome: RangeDownloadOutcome, filePath: String, fallbackReason: String?) {
23
+ self.init(outcome, std.string(filePath), { () -> bridge.std__optional_std__string_ in
24
+ if let __unwrappedValue = fallbackReason {
25
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
26
+ } else {
27
+ return .init()
28
+ }
29
+ }())
30
+ }
31
+
32
+ var outcome: RangeDownloadOutcome {
33
+ @inline(__always)
34
+ get {
35
+ return self.__outcome
36
+ }
37
+ @inline(__always)
38
+ set {
39
+ self.__outcome = newValue
40
+ }
41
+ }
42
+
43
+ var filePath: String {
44
+ @inline(__always)
45
+ get {
46
+ return String(self.__filePath)
47
+ }
48
+ @inline(__always)
49
+ set {
50
+ self.__filePath = std.string(newValue)
51
+ }
52
+ }
53
+
54
+ var fallbackReason: String? {
55
+ @inline(__always)
56
+ get {
57
+ return { () -> String? in
58
+ if bridge.has_value_std__optional_std__string_(self.__fallbackReason) {
59
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__fallbackReason)
60
+ return String(__unwrapped)
61
+ } else {
62
+ return nil
63
+ }
64
+ }()
65
+ }
66
+ @inline(__always)
67
+ set {
68
+ self.__fallbackReason = { () -> bridge.std__optional_std__string_ in
69
+ if let __unwrappedValue = newValue {
70
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
71
+ } else {
72
+ return .init()
73
+ }
74
+ }()
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// DownloadChannel.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::reactnativerangedownloader {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (DownloadChannel).
30
+ */
31
+ enum class DownloadChannel {
32
+ BUNDLE SWIFT_NAME(bundle) = 0,
33
+ APK SWIFT_NAME(apk) = 1,
34
+ CHART SWIFT_NAME(chart) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::reactnativerangedownloader
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ DownloadChannel <> JS DownloadChannel (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel> final {
44
+ static inline margelo::nitro::reactnativerangedownloader::DownloadChannel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("bundle"): return margelo::nitro::reactnativerangedownloader::DownloadChannel::BUNDLE;
48
+ case hashString("apk"): return margelo::nitro::reactnativerangedownloader::DownloadChannel::APK;
49
+ case hashString("chart"): return margelo::nitro::reactnativerangedownloader::DownloadChannel::CHART;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum DownloadChannel - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::reactnativerangedownloader::DownloadChannel arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::reactnativerangedownloader::DownloadChannel::BUNDLE: return JSIConverter<std::string>::toJSI(runtime, "bundle");
57
+ case margelo::nitro::reactnativerangedownloader::DownloadChannel::APK: return JSIConverter<std::string>::toJSI(runtime, "apk");
58
+ case margelo::nitro::reactnativerangedownloader::DownloadChannel::CHART: return JSIConverter<std::string>::toJSI(runtime, "chart");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert DownloadChannel to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("bundle"):
71
+ case hashString("apk"):
72
+ case hashString("chart"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// HybridReactNativeRangeDownloaderSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridReactNativeRangeDownloaderSpec.hpp"
9
+
10
+ namespace margelo::nitro::reactnativerangedownloader {
11
+
12
+ void HybridReactNativeRangeDownloaderSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("download", &HybridReactNativeRangeDownloaderSpec::download);
18
+ prototype.registerHybridMethod("discardArtifacts", &HybridReactNativeRangeDownloaderSpec::discardArtifacts);
19
+ prototype.registerHybridMethod("addDownloadListener", &HybridReactNativeRangeDownloaderSpec::addDownloadListener);
20
+ prototype.registerHybridMethod("removeDownloadListener", &HybridReactNativeRangeDownloaderSpec::removeDownloadListener);
21
+ prototype.registerHybridMethod("getDownloadsDir", &HybridReactNativeRangeDownloaderSpec::getDownloadsDir);
22
+ });
23
+ }
24
+
25
+ } // namespace margelo::nitro::reactnativerangedownloader
@@ -0,0 +1,79 @@
1
+ ///
2
+ /// HybridReactNativeRangeDownloaderSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 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 `RangeDownloadResult` to properly resolve imports.
17
+ namespace margelo::nitro::reactnativerangedownloader { struct RangeDownloadResult; }
18
+ // Forward declaration of `RangeDownloadParams` to properly resolve imports.
19
+ namespace margelo::nitro::reactnativerangedownloader { struct RangeDownloadParams; }
20
+ // Forward declaration of `DownloadChannel` to properly resolve imports.
21
+ namespace margelo::nitro::reactnativerangedownloader { enum class DownloadChannel; }
22
+ // Forward declaration of `RangeDownloadEvent` to properly resolve imports.
23
+ namespace margelo::nitro::reactnativerangedownloader { struct RangeDownloadEvent; }
24
+
25
+ #include "RangeDownloadResult.hpp"
26
+ #include <NitroModules/Promise.hpp>
27
+ #include "RangeDownloadParams.hpp"
28
+ #include "DownloadChannel.hpp"
29
+ #include <string>
30
+ #include "RangeDownloadEvent.hpp"
31
+ #include <functional>
32
+
33
+ namespace margelo::nitro::reactnativerangedownloader {
34
+
35
+ using namespace margelo::nitro;
36
+
37
+ /**
38
+ * An abstract base class for `ReactNativeRangeDownloader`
39
+ * Inherit this class to create instances of `HybridReactNativeRangeDownloaderSpec` in C++.
40
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
41
+ * @example
42
+ * ```cpp
43
+ * class HybridReactNativeRangeDownloader: public HybridReactNativeRangeDownloaderSpec {
44
+ * public:
45
+ * HybridReactNativeRangeDownloader(...): HybridObject(TAG) { ... }
46
+ * // ...
47
+ * };
48
+ * ```
49
+ */
50
+ class HybridReactNativeRangeDownloaderSpec: public virtual HybridObject {
51
+ public:
52
+ // Constructor
53
+ explicit HybridReactNativeRangeDownloaderSpec(): HybridObject(TAG) { }
54
+
55
+ // Destructor
56
+ ~HybridReactNativeRangeDownloaderSpec() override = default;
57
+
58
+ public:
59
+ // Properties
60
+
61
+
62
+ public:
63
+ // Methods
64
+ virtual std::shared_ptr<Promise<RangeDownloadResult>> download(const RangeDownloadParams& params) = 0;
65
+ virtual std::shared_ptr<Promise<void>> discardArtifacts(DownloadChannel channel, const std::string& taskId, const std::string& destFilePath) = 0;
66
+ virtual double addDownloadListener(const std::function<void(const RangeDownloadEvent& /* event */)>& callback) = 0;
67
+ virtual void removeDownloadListener(double id) = 0;
68
+ virtual std::string getDownloadsDir() = 0;
69
+
70
+ protected:
71
+ // Hybrid Setup
72
+ void loadHybridMethods() override;
73
+
74
+ protected:
75
+ // Tag for logging
76
+ static constexpr auto TAG = "ReactNativeRangeDownloader";
77
+ };
78
+
79
+ } // namespace margelo::nitro::reactnativerangedownloader
@@ -0,0 +1,93 @@
1
+ ///
2
+ /// RangeDownloadEvent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 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
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ // Forward declaration of `DownloadChannel` to properly resolve imports.
27
+ namespace margelo::nitro::reactnativerangedownloader { enum class DownloadChannel; }
28
+
29
+ #include "DownloadChannel.hpp"
30
+ #include <string>
31
+
32
+ namespace margelo::nitro::reactnativerangedownloader {
33
+
34
+ /**
35
+ * A struct which can be represented as a JavaScript object (RangeDownloadEvent).
36
+ */
37
+ struct RangeDownloadEvent {
38
+ public:
39
+ DownloadChannel channel SWIFT_PRIVATE;
40
+ std::string taskId SWIFT_PRIVATE;
41
+ std::string type SWIFT_PRIVATE;
42
+ double progress SWIFT_PRIVATE;
43
+ std::string message SWIFT_PRIVATE;
44
+
45
+ public:
46
+ RangeDownloadEvent() = default;
47
+ explicit RangeDownloadEvent(DownloadChannel channel, std::string taskId, std::string type, double progress, std::string message): channel(channel), taskId(taskId), type(type), progress(progress), message(message) {}
48
+ };
49
+
50
+ } // namespace margelo::nitro::reactnativerangedownloader
51
+
52
+ namespace margelo::nitro {
53
+
54
+ // C++ RangeDownloadEvent <> JS RangeDownloadEvent (object)
55
+ template <>
56
+ struct JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadEvent> final {
57
+ static inline margelo::nitro::reactnativerangedownloader::RangeDownloadEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
58
+ jsi::Object obj = arg.asObject(runtime);
59
+ return margelo::nitro::reactnativerangedownloader::RangeDownloadEvent(
60
+ JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel>::fromJSI(runtime, obj.getProperty(runtime, "channel")),
61
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "taskId")),
62
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "type")),
63
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "progress")),
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "message"))
65
+ );
66
+ }
67
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativerangedownloader::RangeDownloadEvent& arg) {
68
+ jsi::Object obj(runtime);
69
+ obj.setProperty(runtime, "channel", JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel>::toJSI(runtime, arg.channel));
70
+ obj.setProperty(runtime, "taskId", JSIConverter<std::string>::toJSI(runtime, arg.taskId));
71
+ obj.setProperty(runtime, "type", JSIConverter<std::string>::toJSI(runtime, arg.type));
72
+ obj.setProperty(runtime, "progress", JSIConverter<double>::toJSI(runtime, arg.progress));
73
+ obj.setProperty(runtime, "message", JSIConverter<std::string>::toJSI(runtime, arg.message));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel>::canConvert(runtime, obj.getProperty(runtime, "channel"))) return false;
85
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "taskId"))) return false;
86
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "type"))) return false;
87
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "progress"))) return false;
88
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "message"))) return false;
89
+ return true;
90
+ }
91
+ };
92
+
93
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// RangeDownloadOutcome.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::reactnativerangedownloader {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (RangeDownloadOutcome).
30
+ */
31
+ enum class RangeDownloadOutcome {
32
+ COMPLETED SWIFT_NAME(completed) = 0,
33
+ FALLBACK SWIFT_NAME(fallback) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::reactnativerangedownloader
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ RangeDownloadOutcome <> JS RangeDownloadOutcome (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome> final {
43
+ static inline margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("completed"): return margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome::COMPLETED;
47
+ case hashString("fallback"): return margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome::FALLBACK;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum RangeDownloadOutcome - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome::COMPLETED: return JSIConverter<std::string>::toJSI(runtime, "completed");
55
+ case margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome::FALLBACK: return JSIConverter<std::string>::toJSI(runtime, "fallback");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert RangeDownloadOutcome to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("completed"):
68
+ case hashString("fallback"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,102 @@
1
+ ///
2
+ /// RangeDownloadParams.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 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
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ // Forward declaration of `DownloadChannel` to properly resolve imports.
27
+ namespace margelo::nitro::reactnativerangedownloader { enum class DownloadChannel; }
28
+
29
+ #include "DownloadChannel.hpp"
30
+ #include <string>
31
+ #include <optional>
32
+
33
+ namespace margelo::nitro::reactnativerangedownloader {
34
+
35
+ /**
36
+ * A struct which can be represented as a JavaScript object (RangeDownloadParams).
37
+ */
38
+ struct RangeDownloadParams {
39
+ public:
40
+ DownloadChannel channel SWIFT_PRIVATE;
41
+ std::string taskId SWIFT_PRIVATE;
42
+ std::string url SWIFT_PRIVATE;
43
+ std::string destFilePath SWIFT_PRIVATE;
44
+ std::optional<std::string> expectedSha256 SWIFT_PRIVATE;
45
+ std::optional<double> segmentCount SWIFT_PRIVATE;
46
+ std::optional<double> minConcurrentBytes SWIFT_PRIVATE;
47
+
48
+ public:
49
+ RangeDownloadParams() = default;
50
+ explicit RangeDownloadParams(DownloadChannel channel, std::string taskId, std::string url, std::string destFilePath, std::optional<std::string> expectedSha256, std::optional<double> segmentCount, std::optional<double> minConcurrentBytes): channel(channel), taskId(taskId), url(url), destFilePath(destFilePath), expectedSha256(expectedSha256), segmentCount(segmentCount), minConcurrentBytes(minConcurrentBytes) {}
51
+ };
52
+
53
+ } // namespace margelo::nitro::reactnativerangedownloader
54
+
55
+ namespace margelo::nitro {
56
+
57
+ // C++ RangeDownloadParams <> JS RangeDownloadParams (object)
58
+ template <>
59
+ struct JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadParams> final {
60
+ static inline margelo::nitro::reactnativerangedownloader::RangeDownloadParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
61
+ jsi::Object obj = arg.asObject(runtime);
62
+ return margelo::nitro::reactnativerangedownloader::RangeDownloadParams(
63
+ JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel>::fromJSI(runtime, obj.getProperty(runtime, "channel")),
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "taskId")),
65
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "url")),
66
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "destFilePath")),
67
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "expectedSha256")),
68
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "segmentCount")),
69
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "minConcurrentBytes"))
70
+ );
71
+ }
72
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativerangedownloader::RangeDownloadParams& arg) {
73
+ jsi::Object obj(runtime);
74
+ obj.setProperty(runtime, "channel", JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel>::toJSI(runtime, arg.channel));
75
+ obj.setProperty(runtime, "taskId", JSIConverter<std::string>::toJSI(runtime, arg.taskId));
76
+ obj.setProperty(runtime, "url", JSIConverter<std::string>::toJSI(runtime, arg.url));
77
+ obj.setProperty(runtime, "destFilePath", JSIConverter<std::string>::toJSI(runtime, arg.destFilePath));
78
+ obj.setProperty(runtime, "expectedSha256", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.expectedSha256));
79
+ obj.setProperty(runtime, "segmentCount", JSIConverter<std::optional<double>>::toJSI(runtime, arg.segmentCount));
80
+ obj.setProperty(runtime, "minConcurrentBytes", JSIConverter<std::optional<double>>::toJSI(runtime, arg.minConcurrentBytes));
81
+ return obj;
82
+ }
83
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
84
+ if (!value.isObject()) {
85
+ return false;
86
+ }
87
+ jsi::Object obj = value.getObject(runtime);
88
+ if (!nitro::isPlainObject(runtime, obj)) {
89
+ return false;
90
+ }
91
+ if (!JSIConverter<margelo::nitro::reactnativerangedownloader::DownloadChannel>::canConvert(runtime, obj.getProperty(runtime, "channel"))) return false;
92
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "taskId"))) return false;
93
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "url"))) return false;
94
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "destFilePath"))) return false;
95
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "expectedSha256"))) return false;
96
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "segmentCount"))) return false;
97
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "minConcurrentBytes"))) return false;
98
+ return true;
99
+ }
100
+ };
101
+
102
+ } // namespace margelo::nitro