@onekeyfe/react-native-range-downloader 3.0.81-alpha.0 → 3.0.81-alpha.10

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 (38) hide show
  1. package/ReactNativeRangeDownloader.podspec +1 -1
  2. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArchiveRules.kt +12 -5
  3. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactOrphanSweep.kt +111 -0
  4. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactStore.kt +185 -189
  5. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ReactNativeRangeDownloader.kt +16 -20
  6. package/android/src/test/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArchiveRulesTest.kt +39 -0
  7. package/android/src/test/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactDeadlineTest.kt +26 -0
  8. package/android/src/test/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactOrphanSweepTest.kt +107 -0
  9. package/ios/FirmwareArtifactStore.swift +662 -408
  10. package/ios/RangeDownloadLogic.swift +297 -0
  11. package/ios/ReactNativeRangeDownloader.swift +42 -471
  12. package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts +3 -7
  13. package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts.map +1 -1
  14. package/nitrogen/generated/android/c++/JFirmwareArchiveMaterializeParams.hpp +7 -6
  15. package/nitrogen/generated/android/c++/JFirmwareArtifactDownloadParams.hpp +7 -7
  16. package/nitrogen/generated/android/c++/JHybridReactNativeRangeDownloaderSpec.cpp +0 -19
  17. package/nitrogen/generated/android/c++/JHybridReactNativeRangeDownloaderSpec.hpp +0 -1
  18. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/FirmwareArchiveMaterializeParams.kt +2 -2
  19. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactDownloadParams.kt +3 -3
  20. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/HybridReactNativeRangeDownloaderSpec.kt +0 -4
  21. package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Bridge.hpp +15 -0
  22. package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Umbrella.hpp +0 -3
  23. package/nitrogen/generated/ios/c++/HybridReactNativeRangeDownloaderSpecSwift.hpp +0 -11
  24. package/nitrogen/generated/ios/swift/FirmwareArchiveMaterializeParams.swift +32 -13
  25. package/nitrogen/generated/ios/swift/FirmwareArtifactDownloadParams.swift +39 -8
  26. package/nitrogen/generated/ios/swift/HybridReactNativeRangeDownloaderSpec.swift +0 -1
  27. package/nitrogen/generated/ios/swift/HybridReactNativeRangeDownloaderSpec_cxx.swift +0 -19
  28. package/nitrogen/generated/shared/c++/FirmwareArchiveMaterializeParams.hpp +6 -5
  29. package/nitrogen/generated/shared/c++/FirmwareArtifactDownloadParams.hpp +9 -9
  30. package/nitrogen/generated/shared/c++/HybridReactNativeRangeDownloaderSpec.cpp +0 -1
  31. package/nitrogen/generated/shared/c++/HybridReactNativeRangeDownloaderSpec.hpp +0 -4
  32. package/package.json +2 -2
  33. package/src/ReactNativeRangeDownloader.nitro.ts +4 -11
  34. package/ios/FirmwareBackgroundSessionEventRouter.swift +0 -17
  35. package/nitrogen/generated/android/c++/JFirmwareArtifactLeaseReconcileParams.hpp +0 -76
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactLeaseReconcileParams.kt +0 -38
  37. package/nitrogen/generated/ios/swift/FirmwareArtifactLeaseReconcileParams.swift +0 -48
  38. package/nitrogen/generated/shared/c++/FirmwareArtifactLeaseReconcileParams.hpp +0 -76
@@ -76,10 +76,10 @@ export interface FirmwareArtifactDownloadParams {
76
76
  url: string;
77
77
  routeType: string;
78
78
  resolvedIp?: string;
79
- expectedSize: number;
80
- expectedSha256: string;
79
+ expectedSize?: number;
80
+ expectedSha256?: string;
81
81
  maxBytes: number;
82
- overallDeadlineSeconds?: number;
82
+ overallDeadlineSeconds?: number; // defaults to 180; must be > 0 and <= 24 hours
83
83
  }
84
84
 
85
85
  export interface FirmwareArtifactReceipt {
@@ -121,7 +121,7 @@ export interface FirmwareArtifactReaderCloseParams {
121
121
  export interface FirmwareArchiveMaterializeParams {
122
122
  leaseRef: string;
123
123
  archiveArtifactRef: string;
124
- expectedEntries: FirmwareArchiveExpectedEntry[];
124
+ expectedEntries?: FirmwareArchiveExpectedEntry[];
125
125
  }
126
126
 
127
127
  export interface FirmwareArchiveExpectedEntry {
@@ -158,10 +158,6 @@ export interface FirmwareArtifactLeaseReleaseParams {
158
158
  disposition: string;
159
159
  }
160
160
 
161
- export interface FirmwareArtifactLeaseReconcileParams {
162
- activeLeaseRefs: string[];
163
- }
164
-
165
161
  export interface FirmwareArtifactSweepResult {
166
162
  deletedFiles: number;
167
163
  deletedBytes: number;
@@ -231,8 +227,5 @@ export interface ReactNativeRangeDownloader
231
227
  releaseFirmwareArtifactLease(
232
228
  params: FirmwareArtifactLeaseReleaseParams
233
229
  ): Promise<void>;
234
- reconcileFirmwareArtifactLeases(
235
- params: FirmwareArtifactLeaseReconcileParams
236
- ): Promise<void>;
237
230
  sweepFirmwareArtifactOrphans(): Promise<FirmwareArtifactSweepResult>;
238
231
  }
@@ -1,17 +0,0 @@
1
- import Foundation
2
-
3
- @objc(FirmwareBackgroundSessionEventRouter)
4
- public final class FirmwareBackgroundSessionEventRouter: NSObject {
5
- @objc(routeEventsForBackgroundURLSession:completionHandler:)
6
- public static func routeEvents(
7
- forBackgroundURLSession identifier: String,
8
- completionHandler: @escaping () -> Void
9
- ) -> NSNumber {
10
- NSNumber(
11
- value: RangeDownloader.routeFirmwareBackgroundEvents(
12
- identifier: identifier,
13
- completionHandler: completionHandler
14
- )
15
- )
16
- }
17
- }
@@ -1,76 +0,0 @@
1
- ///
2
- /// JFirmwareArtifactLeaseReconcileParams.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
- #include <fbjni/fbjni.h>
11
- #include "FirmwareArtifactLeaseReconcileParams.hpp"
12
-
13
- #include <string>
14
- #include <vector>
15
-
16
- namespace margelo::nitro::reactnativerangedownloader {
17
-
18
- using namespace facebook;
19
-
20
- /**
21
- * The C++ JNI bridge between the C++ struct "FirmwareArtifactLeaseReconcileParams" and the the Kotlin data class "FirmwareArtifactLeaseReconcileParams".
22
- */
23
- struct JFirmwareArtifactLeaseReconcileParams final: public jni::JavaClass<JFirmwareArtifactLeaseReconcileParams> {
24
- public:
25
- static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativerangedownloader/FirmwareArtifactLeaseReconcileParams;";
26
-
27
- public:
28
- /**
29
- * Convert this Java/Kotlin-based struct to the C++ struct FirmwareArtifactLeaseReconcileParams by copying all values to C++.
30
- */
31
- [[maybe_unused]]
32
- [[nodiscard]]
33
- FirmwareArtifactLeaseReconcileParams toCpp() const {
34
- static const auto clazz = javaClassStatic();
35
- static const auto fieldActiveLeaseRefs = clazz->getField<jni::JArrayClass<jni::JString>>("activeLeaseRefs");
36
- jni::local_ref<jni::JArrayClass<jni::JString>> activeLeaseRefs = this->getFieldValue(fieldActiveLeaseRefs);
37
- return FirmwareArtifactLeaseReconcileParams(
38
- [&]() {
39
- size_t __size = activeLeaseRefs->size();
40
- std::vector<std::string> __vector;
41
- __vector.reserve(__size);
42
- for (size_t __i = 0; __i < __size; __i++) {
43
- auto __element = activeLeaseRefs->getElement(__i);
44
- __vector.push_back(__element->toStdString());
45
- }
46
- return __vector;
47
- }()
48
- );
49
- }
50
-
51
- public:
52
- /**
53
- * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
54
- */
55
- [[maybe_unused]]
56
- static jni::local_ref<JFirmwareArtifactLeaseReconcileParams::javaobject> fromCpp(const FirmwareArtifactLeaseReconcileParams& value) {
57
- using JSignature = JFirmwareArtifactLeaseReconcileParams(jni::alias_ref<jni::JArrayClass<jni::JString>>);
58
- static const auto clazz = javaClassStatic();
59
- static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
60
- return create(
61
- clazz,
62
- [&]() {
63
- size_t __size = value.activeLeaseRefs.size();
64
- jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
65
- for (size_t __i = 0; __i < __size; __i++) {
66
- const auto& __element = value.activeLeaseRefs[__i];
67
- auto __elementJni = jni::make_jstring(__element);
68
- __array->setElement(__i, *__elementJni);
69
- }
70
- return __array;
71
- }()
72
- );
73
- }
74
- };
75
-
76
- } // namespace margelo::nitro::reactnativerangedownloader
@@ -1,38 +0,0 @@
1
- ///
2
- /// FirmwareArtifactLeaseReconcileParams.kt
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
- package com.margelo.nitro.reactnativerangedownloader
9
-
10
- import androidx.annotation.Keep
11
- import com.facebook.proguard.annotations.DoNotStrip
12
-
13
-
14
- /**
15
- * Represents the JavaScript object/struct "FirmwareArtifactLeaseReconcileParams".
16
- */
17
- @DoNotStrip
18
- @Keep
19
- data class FirmwareArtifactLeaseReconcileParams(
20
- @DoNotStrip
21
- @Keep
22
- val activeLeaseRefs: Array<String>
23
- ) {
24
- /* primary constructor */
25
-
26
- private companion object {
27
- /**
28
- * Constructor called from C++
29
- */
30
- @DoNotStrip
31
- @Keep
32
- @Suppress("unused")
33
- @JvmStatic
34
- private fun fromCpp(activeLeaseRefs: Array<String>): FirmwareArtifactLeaseReconcileParams {
35
- return FirmwareArtifactLeaseReconcileParams(activeLeaseRefs)
36
- }
37
- }
38
- }
@@ -1,48 +0,0 @@
1
- ///
2
- /// FirmwareArtifactLeaseReconcileParams.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 `FirmwareArtifactLeaseReconcileParams`, backed by a C++ struct.
13
- */
14
- public typealias FirmwareArtifactLeaseReconcileParams = margelo.nitro.reactnativerangedownloader.FirmwareArtifactLeaseReconcileParams
15
-
16
- public extension FirmwareArtifactLeaseReconcileParams {
17
- private typealias bridge = margelo.nitro.reactnativerangedownloader.bridge.swift
18
-
19
- /**
20
- * Create a new instance of `FirmwareArtifactLeaseReconcileParams`.
21
- */
22
- init(activeLeaseRefs: [String]) {
23
- self.init({ () -> bridge.std__vector_std__string_ in
24
- var __vector = bridge.create_std__vector_std__string_(activeLeaseRefs.count)
25
- for __item in activeLeaseRefs {
26
- __vector.push_back(std.string(__item))
27
- }
28
- return __vector
29
- }())
30
- }
31
-
32
- var activeLeaseRefs: [String] {
33
- @inline(__always)
34
- get {
35
- return self.__activeLeaseRefs.map({ __item in String(__item) })
36
- }
37
- @inline(__always)
38
- set {
39
- self.__activeLeaseRefs = { () -> bridge.std__vector_std__string_ in
40
- var __vector = bridge.create_std__vector_std__string_(newValue.count)
41
- for __item in newValue {
42
- __vector.push_back(std.string(__item))
43
- }
44
- return __vector
45
- }()
46
- }
47
- }
48
- }
@@ -1,76 +0,0 @@
1
- ///
2
- /// FirmwareArtifactLeaseReconcileParams.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
-
27
-
28
- #include <string>
29
- #include <vector>
30
-
31
- namespace margelo::nitro::reactnativerangedownloader {
32
-
33
- /**
34
- * A struct which can be represented as a JavaScript object (FirmwareArtifactLeaseReconcileParams).
35
- */
36
- struct FirmwareArtifactLeaseReconcileParams {
37
- public:
38
- std::vector<std::string> activeLeaseRefs SWIFT_PRIVATE;
39
-
40
- public:
41
- FirmwareArtifactLeaseReconcileParams() = default;
42
- explicit FirmwareArtifactLeaseReconcileParams(std::vector<std::string> activeLeaseRefs): activeLeaseRefs(activeLeaseRefs) {}
43
- };
44
-
45
- } // namespace margelo::nitro::reactnativerangedownloader
46
-
47
- namespace margelo::nitro {
48
-
49
- // C++ FirmwareArtifactLeaseReconcileParams <> JS FirmwareArtifactLeaseReconcileParams (object)
50
- template <>
51
- struct JSIConverter<margelo::nitro::reactnativerangedownloader::FirmwareArtifactLeaseReconcileParams> final {
52
- static inline margelo::nitro::reactnativerangedownloader::FirmwareArtifactLeaseReconcileParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
53
- jsi::Object obj = arg.asObject(runtime);
54
- return margelo::nitro::reactnativerangedownloader::FirmwareArtifactLeaseReconcileParams(
55
- JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "activeLeaseRefs"))
56
- );
57
- }
58
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativerangedownloader::FirmwareArtifactLeaseReconcileParams& arg) {
59
- jsi::Object obj(runtime);
60
- obj.setProperty(runtime, "activeLeaseRefs", JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.activeLeaseRefs));
61
- return obj;
62
- }
63
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
64
- if (!value.isObject()) {
65
- return false;
66
- }
67
- jsi::Object obj = value.getObject(runtime);
68
- if (!nitro::isPlainObject(runtime, obj)) {
69
- return false;
70
- }
71
- if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, "activeLeaseRefs"))) return false;
72
- return true;
73
- }
74
- };
75
-
76
- } // namespace margelo::nitro