@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.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/ReactNativeRangeDownloader.podspec +30 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +132 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ConcurrentRangeDownloader.kt +340 -0
- package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ReactNativeRangeDownloader.kt +233 -0
- package/android/src/main/java/com/margelo/nitro/reactnativerangedownloader/ReactNativeRangeDownloaderPackage.kt +24 -0
- package/ios/ReactNativeRangeDownloader.swift +732 -0
- package/lib/module/ReactNativeRangeDownloader.nitro.js +4 -0
- package/lib/module/ReactNativeRangeDownloader.nitro.js.map +1 -0
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts +35 -0
- package/lib/typescript/src/ReactNativeRangeDownloader.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JDownloadChannel.hpp +62 -0
- package/nitrogen/generated/android/c++/JFunc_void_RangeDownloadEvent.hpp +80 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeRangeDownloaderSpec.cpp +117 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeRangeDownloaderSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JRangeDownloadEvent.hpp +75 -0
- package/nitrogen/generated/android/c++/JRangeDownloadOutcome.hpp +59 -0
- package/nitrogen/generated/android/c++/JRangeDownloadParams.hpp +84 -0
- package/nitrogen/generated/android/c++/JRangeDownloadResult.hpp +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/DownloadChannel.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/Func_void_RangeDownloadEvent.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/HybridReactNativeRangeDownloaderSpec.kt +79 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadEvent.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadOutcome.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadParams.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/RangeDownloadResult.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativerangedownloader/reactnativerangedownloaderOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativerangedownloader+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativerangedownloader+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativerangedownloaderOnLoad.cpp +46 -0
- package/nitrogen/generated/android/reactnativerangedownloaderOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/ReactNativeRangeDownloader+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Bridge.hpp +246 -0
- package/nitrogen/generated/ios/ReactNativeRangeDownloader-Swift-Cxx-Umbrella.hpp +62 -0
- package/nitrogen/generated/ios/ReactNativeRangeDownloaderAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeRangeDownloaderAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeRangeDownloaderSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeRangeDownloaderSpecSwift.hpp +123 -0
- package/nitrogen/generated/ios/swift/DownloadChannel.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_RangeDownloadEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_RangeDownloadResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeRangeDownloaderSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeRangeDownloaderSpec_cxx.swift +197 -0
- package/nitrogen/generated/ios/swift/RangeDownloadEvent.swift +80 -0
- package/nitrogen/generated/ios/swift/RangeDownloadOutcome.swift +40 -0
- package/nitrogen/generated/ios/swift/RangeDownloadParams.swift +145 -0
- package/nitrogen/generated/ios/swift/RangeDownloadResult.swift +77 -0
- package/nitrogen/generated/shared/c++/DownloadChannel.hpp +80 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeRangeDownloaderSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeRangeDownloaderSpec.hpp +79 -0
- package/nitrogen/generated/shared/c++/RangeDownloadEvent.hpp +93 -0
- package/nitrogen/generated/shared/c++/RangeDownloadOutcome.hpp +76 -0
- package/nitrogen/generated/shared/c++/RangeDownloadParams.hpp +102 -0
- package/nitrogen/generated/shared/c++/RangeDownloadResult.hpp +86 -0
- package/package.json +169 -0
- package/src/ReactNativeRangeDownloader.nitro.ts +60 -0
- package/src/index.tsx +20 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RangeDownloadResult.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 `RangeDownloadOutcome` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::reactnativerangedownloader { enum class RangeDownloadOutcome; }
|
|
28
|
+
|
|
29
|
+
#include "RangeDownloadOutcome.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 (RangeDownloadResult).
|
|
37
|
+
*/
|
|
38
|
+
struct RangeDownloadResult {
|
|
39
|
+
public:
|
|
40
|
+
RangeDownloadOutcome outcome SWIFT_PRIVATE;
|
|
41
|
+
std::string filePath SWIFT_PRIVATE;
|
|
42
|
+
std::optional<std::string> fallbackReason SWIFT_PRIVATE;
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
RangeDownloadResult() = default;
|
|
46
|
+
explicit RangeDownloadResult(RangeDownloadOutcome outcome, std::string filePath, std::optional<std::string> fallbackReason): outcome(outcome), filePath(filePath), fallbackReason(fallbackReason) {}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace margelo::nitro::reactnativerangedownloader
|
|
50
|
+
|
|
51
|
+
namespace margelo::nitro {
|
|
52
|
+
|
|
53
|
+
// C++ RangeDownloadResult <> JS RangeDownloadResult (object)
|
|
54
|
+
template <>
|
|
55
|
+
struct JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadResult> final {
|
|
56
|
+
static inline margelo::nitro::reactnativerangedownloader::RangeDownloadResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
57
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
58
|
+
return margelo::nitro::reactnativerangedownloader::RangeDownloadResult(
|
|
59
|
+
JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome>::fromJSI(runtime, obj.getProperty(runtime, "outcome")),
|
|
60
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "filePath")),
|
|
61
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "fallbackReason"))
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativerangedownloader::RangeDownloadResult& arg) {
|
|
65
|
+
jsi::Object obj(runtime);
|
|
66
|
+
obj.setProperty(runtime, "outcome", JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome>::toJSI(runtime, arg.outcome));
|
|
67
|
+
obj.setProperty(runtime, "filePath", JSIConverter<std::string>::toJSI(runtime, arg.filePath));
|
|
68
|
+
obj.setProperty(runtime, "fallbackReason", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.fallbackReason));
|
|
69
|
+
return obj;
|
|
70
|
+
}
|
|
71
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
72
|
+
if (!value.isObject()) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
jsi::Object obj = value.getObject(runtime);
|
|
76
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (!JSIConverter<margelo::nitro::reactnativerangedownloader::RangeDownloadOutcome>::canConvert(runtime, obj.getProperty(runtime, "outcome"))) return false;
|
|
80
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "filePath"))) return false;
|
|
81
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "fallbackReason"))) return false;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/react-native-range-downloader",
|
|
3
|
+
"version": "3.0.39",
|
|
4
|
+
"description": "react-native-range-downloader",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
38
|
+
"prepare": "bob build",
|
|
39
|
+
"nitrogen": "nitrogen",
|
|
40
|
+
"typecheck": "tsc",
|
|
41
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
42
|
+
"test": "jest",
|
|
43
|
+
"release": "yarn prepare && npm whoami && npm publish --access public"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"react-native",
|
|
47
|
+
"ios",
|
|
48
|
+
"android"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/OneKeyHQ/app-modules/react-native-range-downloader.git"
|
|
53
|
+
},
|
|
54
|
+
"author": "onekeyfe <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/OneKeyHQ/app-modules/react-native-range-downloader/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/OneKeyHQ/app-modules/react-native-range-downloader#readme",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
65
|
+
"@eslint/compat": "^1.3.2",
|
|
66
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
67
|
+
"@eslint/js": "^9.35.0",
|
|
68
|
+
"@react-native/babel-preset": "0.83.0",
|
|
69
|
+
"@react-native/eslint-config": "0.83.0",
|
|
70
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
71
|
+
"@types/jest": "^29.5.14",
|
|
72
|
+
"@types/react": "^19.2.0",
|
|
73
|
+
"commitlint": "^19.8.1",
|
|
74
|
+
"del-cli": "^6.0.0",
|
|
75
|
+
"eslint": "^9.35.0",
|
|
76
|
+
"eslint-config-prettier": "^10.1.8",
|
|
77
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
78
|
+
"jest": "^29.7.0",
|
|
79
|
+
"lefthook": "^2.0.3",
|
|
80
|
+
"nitrogen": "0.31.10",
|
|
81
|
+
"prettier": "^2.8.8",
|
|
82
|
+
"react": "19.2.0",
|
|
83
|
+
"react-native": "patch:react-native@npm%3A0.83.0#~/.yarn/patches/react-native-npm-0.83.0-577d0f2d83.patch",
|
|
84
|
+
"react-native-builder-bob": "^0.40.13",
|
|
85
|
+
"react-native-nitro-modules": "0.33.2",
|
|
86
|
+
"release-it": "^19.0.4",
|
|
87
|
+
"turbo": "^2.5.6",
|
|
88
|
+
"typescript": "^5.9.2"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"react": "*",
|
|
92
|
+
"react-native": "*",
|
|
93
|
+
"react-native-nitro-modules": "0.33.2"
|
|
94
|
+
},
|
|
95
|
+
"react-native-builder-bob": {
|
|
96
|
+
"source": "src",
|
|
97
|
+
"output": "lib",
|
|
98
|
+
"targets": [
|
|
99
|
+
[
|
|
100
|
+
"custom",
|
|
101
|
+
{
|
|
102
|
+
"script": "nitrogen",
|
|
103
|
+
"clean": "nitrogen/"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"module",
|
|
108
|
+
{
|
|
109
|
+
"esm": true
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
"typescript",
|
|
114
|
+
{
|
|
115
|
+
"project": "tsconfig.build.json"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"prettier": {
|
|
121
|
+
"quoteProps": "consistent",
|
|
122
|
+
"singleQuote": true,
|
|
123
|
+
"tabWidth": 2,
|
|
124
|
+
"trailingComma": "es5",
|
|
125
|
+
"useTabs": false
|
|
126
|
+
},
|
|
127
|
+
"jest": {
|
|
128
|
+
"preset": "react-native",
|
|
129
|
+
"modulePathIgnorePatterns": [
|
|
130
|
+
"<rootDir>/example/node_modules",
|
|
131
|
+
"<rootDir>/lib/"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"commitlint": {
|
|
135
|
+
"extends": [
|
|
136
|
+
"@commitlint/config-conventional"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"release-it": {
|
|
140
|
+
"git": {
|
|
141
|
+
"commitMessage": "chore: release ${version}",
|
|
142
|
+
"tagName": "v${version}"
|
|
143
|
+
},
|
|
144
|
+
"npm": {
|
|
145
|
+
"publish": true
|
|
146
|
+
},
|
|
147
|
+
"github": {
|
|
148
|
+
"release": true
|
|
149
|
+
},
|
|
150
|
+
"plugins": {
|
|
151
|
+
"@release-it/conventional-changelog": {
|
|
152
|
+
"preset": {
|
|
153
|
+
"name": "angular"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"create-react-native-library": {
|
|
159
|
+
"type": "nitro-module",
|
|
160
|
+
"languages": "kotlin-swift",
|
|
161
|
+
"tools": [
|
|
162
|
+
"eslint",
|
|
163
|
+
"jest",
|
|
164
|
+
"lefthook",
|
|
165
|
+
"release-it"
|
|
166
|
+
],
|
|
167
|
+
"version": "0.56.0"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
// A channel = one logical consumer (bundle update / apk update / chart webview).
|
|
4
|
+
// The channel decides the iOS background URLSession identifier suffix and the
|
|
5
|
+
// event-routing key, so different consumers never cross-talk. Closed set per
|
|
6
|
+
// design decision 10.1 (constant enum, not a bare string).
|
|
7
|
+
export type DownloadChannel = 'bundle' | 'apk' | 'chart';
|
|
8
|
+
|
|
9
|
+
export interface RangeDownloadParams {
|
|
10
|
+
channel: DownloadChannel;
|
|
11
|
+
taskId: string; // caller-generated unique id (dedupe / resume locating within a channel)
|
|
12
|
+
url: string; // must be HTTPS (enforced inside the module, mirrors current behavior)
|
|
13
|
+
destFilePath: string; // final absolute path on disk (module does not own directory layout)
|
|
14
|
+
expectedSha256?: string; // optional: in-module post-download self-check; else caller verifies later
|
|
15
|
+
segmentCount?: number; // default 8 (mirrors current behavior)
|
|
16
|
+
minConcurrentBytes?: number; // default 2MB (below this falls straight back to single stream)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type RangeDownloadOutcome =
|
|
20
|
+
| 'completed' // destFilePath fully on disk (and expectedSha256, if passed, has passed)
|
|
21
|
+
| 'fallback'; // concurrent unavailable, caller should run its own single-stream path
|
|
22
|
+
|
|
23
|
+
export interface RangeDownloadResult {
|
|
24
|
+
outcome: RangeDownloadOutcome;
|
|
25
|
+
filePath: string;
|
|
26
|
+
fallbackReason?: string; // filled when outcome=fallback (range unsupported / 200 / too small ...)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface RangeDownloadEvent {
|
|
30
|
+
channel: DownloadChannel; // callers filter their own events by channel
|
|
31
|
+
taskId: string;
|
|
32
|
+
type: string; // 'start' | 'progress' | 'complete' | 'error' | 'fallback'
|
|
33
|
+
progress: number; // 0-100
|
|
34
|
+
message: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ReactNativeRangeDownloader
|
|
38
|
+
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
39
|
+
// Main entry: concurrent ranged download (iOS background session / Android thread pool).
|
|
40
|
+
// The promise resolves once the outcome is decided; on fallback the module has already
|
|
41
|
+
// cleaned up its own segment artifacts.
|
|
42
|
+
download(params: RangeDownloadParams): Promise<RangeDownloadResult>;
|
|
43
|
+
|
|
44
|
+
// Clean the concurrent artifacts (.segN / .partial / .progress) for one task.
|
|
45
|
+
// Caller invokes before falling back to its own single-stream path.
|
|
46
|
+
discardArtifacts(
|
|
47
|
+
channel: DownloadChannel,
|
|
48
|
+
taskId: string,
|
|
49
|
+
destFilePath: string
|
|
50
|
+
): Promise<void>;
|
|
51
|
+
|
|
52
|
+
// Event listening: all consumers share one listener registry and filter by channel.
|
|
53
|
+
addDownloadListener(callback: (event: RangeDownloadEvent) => void): number;
|
|
54
|
+
removeDownloadListener(id: number): void;
|
|
55
|
+
|
|
56
|
+
// App-owned writable directory (caches) for scratch downloads. The module does
|
|
57
|
+
// not own directory layout for real consumers, but exposes this so demos/simple
|
|
58
|
+
// callers have a valid absolute destination without hardcoding sandbox paths.
|
|
59
|
+
getDownloadsDir(): string;
|
|
60
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { ReactNativeRangeDownloader as ReactNativeRangeDownloaderType } from './ReactNativeRangeDownloader.nitro';
|
|
3
|
+
|
|
4
|
+
const ReactNativeRangeDownloaderHybridObject =
|
|
5
|
+
NitroModules.createHybridObject<ReactNativeRangeDownloaderType>(
|
|
6
|
+
'ReactNativeRangeDownloader'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const ReactNativeRangeDownloader = ReactNativeRangeDownloaderHybridObject;
|
|
10
|
+
|
|
11
|
+
// Closed set of download channels (design decision 10.1). The native side builds the
|
|
12
|
+
// background session identifier as `so.onekey.rangedownloader.bg.<channel>`. New channels
|
|
13
|
+
// must be added here (review-visible), preventing consumers from passing typo'd strings.
|
|
14
|
+
export const RangeDownloadChannel = {
|
|
15
|
+
Bundle: 'bundle',
|
|
16
|
+
Apk: 'apk',
|
|
17
|
+
Chart: 'chart',
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export type * from './ReactNativeRangeDownloader.nitro';
|