@onekeyfe/react-native-range-downloader 3.0.81-alpha.7 → 3.0.81-alpha.9

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 (24) 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 +132 -68
  5. package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ReactNativeRangeDownloader.kt +1 -1
  6. package/android/src/test/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArchiveRulesTest.kt +39 -0
  7. package/android/src/test/java/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactOrphanSweepTest.kt +107 -0
  8. package/ios/FirmwareArtifactStore.swift +242 -172
  9. package/ios/RangeDownloadLogic.swift +194 -36
  10. package/ios/ReactNativeRangeDownloader.swift +9 -423
  11. package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts +3 -3
  12. package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts.map +1 -1
  13. package/nitrogen/generated/android/c++/JFirmwareArchiveMaterializeParams.hpp +7 -6
  14. package/nitrogen/generated/android/c++/JFirmwareArtifactDownloadParams.hpp +7 -7
  15. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/FirmwareArchiveMaterializeParams.kt +2 -2
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/FirmwareArtifactDownloadParams.kt +3 -3
  17. package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Bridge.hpp +15 -0
  18. package/nitrogen/generated/ios/swift/FirmwareArchiveMaterializeParams.swift +32 -13
  19. package/nitrogen/generated/ios/swift/FirmwareArtifactDownloadParams.swift +39 -8
  20. package/nitrogen/generated/shared/c++/FirmwareArchiveMaterializeParams.hpp +6 -5
  21. package/nitrogen/generated/shared/c++/FirmwareArtifactDownloadParams.hpp +9 -9
  22. package/package.json +2 -2
  23. package/src/ReactNativeRangeDownloader.nitro.ts +3 -3
  24. package/ios/FirmwareBackgroundSessionEventRouter.swift +0 -17
@@ -402,6 +402,21 @@ namespace margelo::nitro::reactnativerangedownloader::bridge::swift {
402
402
  return vector;
403
403
  }
404
404
 
405
+ // pragma MARK: std::optional<std::vector<FirmwareArchiveExpectedEntry>>
406
+ /**
407
+ * Specialized version of `std::optional<std::vector<FirmwareArchiveExpectedEntry>>`.
408
+ */
409
+ using std__optional_std__vector_FirmwareArchiveExpectedEntry__ = std::optional<std::vector<FirmwareArchiveExpectedEntry>>;
410
+ inline std::optional<std::vector<FirmwareArchiveExpectedEntry>> create_std__optional_std__vector_FirmwareArchiveExpectedEntry__(const std::vector<FirmwareArchiveExpectedEntry>& value) noexcept {
411
+ return std::optional<std::vector<FirmwareArchiveExpectedEntry>>(value);
412
+ }
413
+ inline bool has_value_std__optional_std__vector_FirmwareArchiveExpectedEntry__(const std::optional<std::vector<FirmwareArchiveExpectedEntry>>& optional) noexcept {
414
+ return optional.has_value();
415
+ }
416
+ inline std::vector<FirmwareArchiveExpectedEntry> get_std__optional_std__vector_FirmwareArchiveExpectedEntry__(const std::optional<std::vector<FirmwareArchiveExpectedEntry>>& optional) noexcept {
417
+ return *optional;
418
+ }
419
+
405
420
  // pragma MARK: std::shared_ptr<Promise<FirmwareArtifactLease>>
406
421
  /**
407
422
  * Specialized version of `std::shared_ptr<Promise<FirmwareArtifactLease>>`.
@@ -19,13 +19,19 @@ public extension FirmwareArchiveMaterializeParams {
19
19
  /**
20
20
  * Create a new instance of `FirmwareArchiveMaterializeParams`.
21
21
  */
22
- init(leaseRef: String, archiveArtifactRef: String, expectedEntries: [FirmwareArchiveExpectedEntry]) {
23
- self.init(std.string(leaseRef), std.string(archiveArtifactRef), { () -> bridge.std__vector_FirmwareArchiveExpectedEntry_ in
24
- var __vector = bridge.create_std__vector_FirmwareArchiveExpectedEntry_(expectedEntries.count)
25
- for __item in expectedEntries {
26
- __vector.push_back(__item)
22
+ init(leaseRef: String, archiveArtifactRef: String, expectedEntries: [FirmwareArchiveExpectedEntry]?) {
23
+ self.init(std.string(leaseRef), std.string(archiveArtifactRef), { () -> bridge.std__optional_std__vector_FirmwareArchiveExpectedEntry__ in
24
+ if let __unwrappedValue = expectedEntries {
25
+ return bridge.create_std__optional_std__vector_FirmwareArchiveExpectedEntry__({ () -> bridge.std__vector_FirmwareArchiveExpectedEntry_ in
26
+ var __vector = bridge.create_std__vector_FirmwareArchiveExpectedEntry_(__unwrappedValue.count)
27
+ for __item in __unwrappedValue {
28
+ __vector.push_back(__item)
29
+ }
30
+ return __vector
31
+ }())
32
+ } else {
33
+ return .init()
27
34
  }
28
- return __vector
29
35
  }())
30
36
  }
31
37
 
@@ -51,19 +57,32 @@ public extension FirmwareArchiveMaterializeParams {
51
57
  }
52
58
  }
53
59
 
54
- var expectedEntries: [FirmwareArchiveExpectedEntry] {
60
+ var expectedEntries: [FirmwareArchiveExpectedEntry]? {
55
61
  @inline(__always)
56
62
  get {
57
- return self.__expectedEntries.map({ __item in __item })
63
+ return { () -> [FirmwareArchiveExpectedEntry]? in
64
+ if bridge.has_value_std__optional_std__vector_FirmwareArchiveExpectedEntry__(self.__expectedEntries) {
65
+ let __unwrapped = bridge.get_std__optional_std__vector_FirmwareArchiveExpectedEntry__(self.__expectedEntries)
66
+ return __unwrapped.map({ __item in __item })
67
+ } else {
68
+ return nil
69
+ }
70
+ }()
58
71
  }
59
72
  @inline(__always)
60
73
  set {
61
- self.__expectedEntries = { () -> bridge.std__vector_FirmwareArchiveExpectedEntry_ in
62
- var __vector = bridge.create_std__vector_FirmwareArchiveExpectedEntry_(newValue.count)
63
- for __item in newValue {
64
- __vector.push_back(__item)
74
+ self.__expectedEntries = { () -> bridge.std__optional_std__vector_FirmwareArchiveExpectedEntry__ in
75
+ if let __unwrappedValue = newValue {
76
+ return bridge.create_std__optional_std__vector_FirmwareArchiveExpectedEntry__({ () -> bridge.std__vector_FirmwareArchiveExpectedEntry_ in
77
+ var __vector = bridge.create_std__vector_FirmwareArchiveExpectedEntry_(__unwrappedValue.count)
78
+ for __item in __unwrappedValue {
79
+ __vector.push_back(__item)
80
+ }
81
+ return __vector
82
+ }())
83
+ } else {
84
+ return .init()
65
85
  }
66
- return __vector
67
86
  }()
68
87
  }
69
88
  }
@@ -19,14 +19,26 @@ public extension FirmwareArtifactDownloadParams {
19
19
  /**
20
20
  * Create a new instance of `FirmwareArtifactDownloadParams`.
21
21
  */
22
- init(taskId: String, transactionId: String, leaseRef: String, artifactId: String, url: String, routeType: String, resolvedIp: String?, expectedSize: Double, expectedSha256: String, maxBytes: Double, overallDeadlineSeconds: Double?) {
22
+ init(taskId: String, transactionId: String, leaseRef: String, artifactId: String, url: String, routeType: String, resolvedIp: String?, expectedSize: Double?, expectedSha256: String?, maxBytes: Double, overallDeadlineSeconds: Double?) {
23
23
  self.init(std.string(taskId), std.string(transactionId), std.string(leaseRef), std.string(artifactId), std.string(url), std.string(routeType), { () -> bridge.std__optional_std__string_ in
24
24
  if let __unwrappedValue = resolvedIp {
25
25
  return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
26
26
  } else {
27
27
  return .init()
28
28
  }
29
- }(), expectedSize, std.string(expectedSha256), maxBytes, { () -> bridge.std__optional_double_ in
29
+ }(), { () -> bridge.std__optional_double_ in
30
+ if let __unwrappedValue = expectedSize {
31
+ return bridge.create_std__optional_double_(__unwrappedValue)
32
+ } else {
33
+ return .init()
34
+ }
35
+ }(), { () -> bridge.std__optional_std__string_ in
36
+ if let __unwrappedValue = expectedSha256 {
37
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
38
+ } else {
39
+ return .init()
40
+ }
41
+ }(), maxBytes, { () -> bridge.std__optional_double_ in
30
42
  if let __unwrappedValue = overallDeadlineSeconds {
31
43
  return bridge.create_std__optional_double_(__unwrappedValue)
32
44
  } else {
@@ -125,25 +137,44 @@ public extension FirmwareArtifactDownloadParams {
125
137
  }
126
138
  }
127
139
 
128
- var expectedSize: Double {
140
+ var expectedSize: Double? {
129
141
  @inline(__always)
130
142
  get {
131
- return self.__expectedSize
143
+ return self.__expectedSize.value
132
144
  }
133
145
  @inline(__always)
134
146
  set {
135
- self.__expectedSize = newValue
147
+ self.__expectedSize = { () -> bridge.std__optional_double_ in
148
+ if let __unwrappedValue = newValue {
149
+ return bridge.create_std__optional_double_(__unwrappedValue)
150
+ } else {
151
+ return .init()
152
+ }
153
+ }()
136
154
  }
137
155
  }
138
156
 
139
- var expectedSha256: String {
157
+ var expectedSha256: String? {
140
158
  @inline(__always)
141
159
  get {
142
- return String(self.__expectedSha256)
160
+ return { () -> String? in
161
+ if bridge.has_value_std__optional_std__string_(self.__expectedSha256) {
162
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__expectedSha256)
163
+ return String(__unwrapped)
164
+ } else {
165
+ return nil
166
+ }
167
+ }()
143
168
  }
144
169
  @inline(__always)
145
170
  set {
146
- self.__expectedSha256 = std.string(newValue)
171
+ self.__expectedSha256 = { () -> bridge.std__optional_std__string_ in
172
+ if let __unwrappedValue = newValue {
173
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
174
+ } else {
175
+ return .init()
176
+ }
177
+ }()
147
178
  }
148
179
  }
149
180
 
@@ -29,6 +29,7 @@ namespace margelo::nitro::reactnativerangedownloader { struct FirmwareArchiveExp
29
29
  #include <string>
30
30
  #include "FirmwareArchiveExpectedEntry.hpp"
31
31
  #include <vector>
32
+ #include <optional>
32
33
 
33
34
  namespace margelo::nitro::reactnativerangedownloader {
34
35
 
@@ -39,11 +40,11 @@ namespace margelo::nitro::reactnativerangedownloader {
39
40
  public:
40
41
  std::string leaseRef SWIFT_PRIVATE;
41
42
  std::string archiveArtifactRef SWIFT_PRIVATE;
42
- std::vector<FirmwareArchiveExpectedEntry> expectedEntries SWIFT_PRIVATE;
43
+ std::optional<std::vector<FirmwareArchiveExpectedEntry>> expectedEntries SWIFT_PRIVATE;
43
44
 
44
45
  public:
45
46
  FirmwareArchiveMaterializeParams() = default;
46
- explicit FirmwareArchiveMaterializeParams(std::string leaseRef, std::string archiveArtifactRef, std::vector<FirmwareArchiveExpectedEntry> expectedEntries): leaseRef(leaseRef), archiveArtifactRef(archiveArtifactRef), expectedEntries(expectedEntries) {}
47
+ explicit FirmwareArchiveMaterializeParams(std::string leaseRef, std::string archiveArtifactRef, std::optional<std::vector<FirmwareArchiveExpectedEntry>> expectedEntries): leaseRef(leaseRef), archiveArtifactRef(archiveArtifactRef), expectedEntries(expectedEntries) {}
47
48
  };
48
49
 
49
50
  } // namespace margelo::nitro::reactnativerangedownloader
@@ -58,14 +59,14 @@ namespace margelo::nitro {
58
59
  return margelo::nitro::reactnativerangedownloader::FirmwareArchiveMaterializeParams(
59
60
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "leaseRef")),
60
61
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "archiveArtifactRef")),
61
- JSIConverter<std::vector<margelo::nitro::reactnativerangedownloader::FirmwareArchiveExpectedEntry>>::fromJSI(runtime, obj.getProperty(runtime, "expectedEntries"))
62
+ JSIConverter<std::optional<std::vector<margelo::nitro::reactnativerangedownloader::FirmwareArchiveExpectedEntry>>>::fromJSI(runtime, obj.getProperty(runtime, "expectedEntries"))
62
63
  );
63
64
  }
64
65
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativerangedownloader::FirmwareArchiveMaterializeParams& arg) {
65
66
  jsi::Object obj(runtime);
66
67
  obj.setProperty(runtime, "leaseRef", JSIConverter<std::string>::toJSI(runtime, arg.leaseRef));
67
68
  obj.setProperty(runtime, "archiveArtifactRef", JSIConverter<std::string>::toJSI(runtime, arg.archiveArtifactRef));
68
- obj.setProperty(runtime, "expectedEntries", JSIConverter<std::vector<margelo::nitro::reactnativerangedownloader::FirmwareArchiveExpectedEntry>>::toJSI(runtime, arg.expectedEntries));
69
+ obj.setProperty(runtime, "expectedEntries", JSIConverter<std::optional<std::vector<margelo::nitro::reactnativerangedownloader::FirmwareArchiveExpectedEntry>>>::toJSI(runtime, arg.expectedEntries));
69
70
  return obj;
70
71
  }
71
72
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -78,7 +79,7 @@ namespace margelo::nitro {
78
79
  }
79
80
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "leaseRef"))) return false;
80
81
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "archiveArtifactRef"))) return false;
81
- if (!JSIConverter<std::vector<margelo::nitro::reactnativerangedownloader::FirmwareArchiveExpectedEntry>>::canConvert(runtime, obj.getProperty(runtime, "expectedEntries"))) return false;
82
+ if (!JSIConverter<std::optional<std::vector<margelo::nitro::reactnativerangedownloader::FirmwareArchiveExpectedEntry>>>::canConvert(runtime, obj.getProperty(runtime, "expectedEntries"))) return false;
82
83
  return true;
83
84
  }
84
85
  };
@@ -42,14 +42,14 @@ namespace margelo::nitro::reactnativerangedownloader {
42
42
  std::string url SWIFT_PRIVATE;
43
43
  std::string routeType SWIFT_PRIVATE;
44
44
  std::optional<std::string> resolvedIp SWIFT_PRIVATE;
45
- double expectedSize SWIFT_PRIVATE;
46
- std::string expectedSha256 SWIFT_PRIVATE;
45
+ std::optional<double> expectedSize SWIFT_PRIVATE;
46
+ std::optional<std::string> expectedSha256 SWIFT_PRIVATE;
47
47
  double maxBytes SWIFT_PRIVATE;
48
48
  std::optional<double> overallDeadlineSeconds SWIFT_PRIVATE;
49
49
 
50
50
  public:
51
51
  FirmwareArtifactDownloadParams() = default;
52
- explicit FirmwareArtifactDownloadParams(std::string taskId, std::string transactionId, std::string leaseRef, std::string artifactId, std::string url, std::string routeType, std::optional<std::string> resolvedIp, double expectedSize, std::string expectedSha256, double maxBytes, std::optional<double> overallDeadlineSeconds): taskId(taskId), transactionId(transactionId), leaseRef(leaseRef), artifactId(artifactId), url(url), routeType(routeType), resolvedIp(resolvedIp), expectedSize(expectedSize), expectedSha256(expectedSha256), maxBytes(maxBytes), overallDeadlineSeconds(overallDeadlineSeconds) {}
52
+ explicit FirmwareArtifactDownloadParams(std::string taskId, std::string transactionId, std::string leaseRef, std::string artifactId, std::string url, std::string routeType, std::optional<std::string> resolvedIp, std::optional<double> expectedSize, std::optional<std::string> expectedSha256, double maxBytes, std::optional<double> overallDeadlineSeconds): taskId(taskId), transactionId(transactionId), leaseRef(leaseRef), artifactId(artifactId), url(url), routeType(routeType), resolvedIp(resolvedIp), expectedSize(expectedSize), expectedSha256(expectedSha256), maxBytes(maxBytes), overallDeadlineSeconds(overallDeadlineSeconds) {}
53
53
  };
54
54
 
55
55
  } // namespace margelo::nitro::reactnativerangedownloader
@@ -69,8 +69,8 @@ namespace margelo::nitro {
69
69
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "url")),
70
70
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "routeType")),
71
71
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "resolvedIp")),
72
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "expectedSize")),
73
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "expectedSha256")),
72
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "expectedSize")),
73
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "expectedSha256")),
74
74
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "maxBytes")),
75
75
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "overallDeadlineSeconds"))
76
76
  );
@@ -84,8 +84,8 @@ namespace margelo::nitro {
84
84
  obj.setProperty(runtime, "url", JSIConverter<std::string>::toJSI(runtime, arg.url));
85
85
  obj.setProperty(runtime, "routeType", JSIConverter<std::string>::toJSI(runtime, arg.routeType));
86
86
  obj.setProperty(runtime, "resolvedIp", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.resolvedIp));
87
- obj.setProperty(runtime, "expectedSize", JSIConverter<double>::toJSI(runtime, arg.expectedSize));
88
- obj.setProperty(runtime, "expectedSha256", JSIConverter<std::string>::toJSI(runtime, arg.expectedSha256));
87
+ obj.setProperty(runtime, "expectedSize", JSIConverter<std::optional<double>>::toJSI(runtime, arg.expectedSize));
88
+ obj.setProperty(runtime, "expectedSha256", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.expectedSha256));
89
89
  obj.setProperty(runtime, "maxBytes", JSIConverter<double>::toJSI(runtime, arg.maxBytes));
90
90
  obj.setProperty(runtime, "overallDeadlineSeconds", JSIConverter<std::optional<double>>::toJSI(runtime, arg.overallDeadlineSeconds));
91
91
  return obj;
@@ -105,8 +105,8 @@ namespace margelo::nitro {
105
105
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "url"))) return false;
106
106
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "routeType"))) return false;
107
107
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "resolvedIp"))) return false;
108
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "expectedSize"))) return false;
109
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "expectedSha256"))) return false;
108
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "expectedSize"))) return false;
109
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "expectedSha256"))) return false;
110
110
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "maxBytes"))) return false;
111
111
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "overallDeadlineSeconds"))) return false;
112
112
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-range-downloader",
3
- "version": "3.0.81-alpha.7",
3
+ "version": "3.0.81-alpha.9",
4
4
  "description": "react-native-range-downloader",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -88,7 +88,7 @@
88
88
  "typescript": "^5.9.2"
89
89
  },
90
90
  "peerDependencies": {
91
- "@onekeyfe/react-native-sni-connect": "3.0.81-alpha.7",
91
+ "@onekeyfe/react-native-sni-connect": "3.0.81-alpha.8",
92
92
  "react": "*",
93
93
  "react-native": "*",
94
94
  "react-native-nitro-modules": "0.33.2"
@@ -76,8 +76,8 @@ 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
82
  overallDeadlineSeconds?: number; // defaults to 180; must be > 0 and <= 24 hours
83
83
  }
@@ -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 {
@@ -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
- }