react-native-ota-hot-update 2.0.2 → 2.0.4
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/README.md +21 -98
- package/android/generated/java/com/otahotupdate/NativeOtaHotUpdateSpec.java +4 -0
- package/android/generated/jni/RNOtaHotUpdateSpec-generated.cpp +6 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI-generated.cpp +7 -0
- package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI.h +9 -0
- package/android/src/main/java/com/otahotupdate/OtaHotUpdateModule.kt +13 -2
- package/android/src/oldarch/OtaHotUpdateSpec.kt +1 -0
- package/ios/OtaHotUpdate.mm +14 -1
- package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec-generated.mm +7 -0
- package/ios/generated/RNOtaHotUpdateSpec/RNOtaHotUpdateSpec.h +3 -0
- package/ios/generated/RNOtaHotUpdateSpecJSI-generated.cpp +7 -0
- package/ios/generated/RNOtaHotUpdateSpecJSI.h +9 -0
- package/lib/commonjs/NativeOtaHotUpdate.js.map +1 -1
- package/lib/commonjs/gits/helper/fileReader.js +36 -0
- package/lib/commonjs/gits/helper/fileReader.js.map +1 -0
- package/lib/commonjs/gits/helper/fs.js +152 -0
- package/lib/commonjs/gits/helper/fs.js.map +1 -0
- package/lib/commonjs/gits/index.js +130 -0
- package/lib/commonjs/gits/index.js.map +1 -0
- package/lib/commonjs/index.d.js +6 -0
- package/lib/commonjs/index.d.js.map +1 -0
- package/lib/commonjs/index.js +63 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/type.js +2 -0
- package/lib/commonjs/type.js.map +1 -0
- package/lib/module/NativeOtaHotUpdate.js.map +1 -1
- package/lib/module/gits/helper/fileReader.js +36 -0
- package/lib/module/gits/helper/fileReader.js.map +1 -0
- package/lib/module/gits/helper/fs.js +139 -0
- package/lib/module/gits/helper/fs.js.map +1 -0
- package/lib/module/gits/index.js +123 -0
- package/lib/module/gits/index.js.map +1 -0
- package/lib/module/index.d.js +4 -0
- package/lib/module/index.d.js.map +1 -0
- package/lib/module/index.js +62 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/type.js +2 -0
- package/lib/module/type.js.map +1 -0
- package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts +1 -0
- package/lib/typescript/commonjs/src/NativeOtaHotUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/gits/helper/fs.d.ts +16 -0
- package/lib/typescript/commonjs/src/gits/helper/fs.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/gits/index.d.ts +25 -0
- package/lib/typescript/commonjs/src/gits/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +25 -8
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/type.d.ts +145 -0
- package/lib/typescript/commonjs/src/type.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts +1 -0
- package/lib/typescript/module/src/NativeOtaHotUpdate.d.ts.map +1 -1
- package/lib/typescript/module/src/gits/helper/fs.d.ts +16 -0
- package/lib/typescript/module/src/gits/helper/fs.d.ts.map +1 -0
- package/lib/typescript/module/src/gits/index.d.ts +25 -0
- package/lib/typescript/module/src/gits/index.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +25 -8
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/type.d.ts +145 -0
- package/lib/typescript/module/src/type.d.ts.map +1 -0
- package/package.json +8 -2
- package/src/NativeOtaHotUpdate.ts +1 -0
- package/src/gits/helper/fileReader.js +44 -0
- package/src/gits/helper/fs.ts +154 -0
- package/src/gits/index.ts +118 -0
- package/src/index.d.ts +80 -0
- package/src/index.tsx +62 -9
- package/src/type.ts +163 -0
package/README.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# react-native-ota-hot-update
|
|
2
2
|
|
|
3
|
-
A React Native module that allows you to control hot update same as Code Push, less config than Code Push, you can control version manager, hosting bundle js by your self, this library just control install the hot update after bundle js downloaded from your side. As we know, Code push is going to retirement soon, that why i create that library for you can control bundle js from your backend side.
|
|
4
3
|
|
|
4
|
+
This React Native module allows you to manage hot updates with minimal configuration, similar to Code Push. You can control versioning and host the JS bundle yourself. The library handles the installation of updates after the bundle is downloaded from your server or Git repository. With Code Push retiring soon, this library gives you full control over your update process, whether hosting the bundle on your own server or in a Git repository.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
1. **Demo via server**
|
|
5
8
|
|
|
6
9
|
iOS GIF | Android GIF
|
|
7
10
|
:-------------------------:|:-------------------------:
|
|
8
11
|
<img src="./ioshotupdate.gif" title="iOS GIF" width="250"> | <img src="./androidhotupdate.gif" title="Android GIF" width="250">
|
|
9
12
|
|
|
13
|
+
2. **Demo via git repository**
|
|
14
|
+
|
|
15
|
+
iOS GIF | Android GIF
|
|
16
|
+
:-------------------------:|:-------------------------:
|
|
17
|
+
<img src="./iosgit.gif" title="iOS GIF" width="250"> | <img src="./androidgithotupdate.gif" title="Android GIF" width="250">
|
|
18
|
+
|
|
10
19
|
[](https://img.shields.io/npm/dw/react-native-ota-hot-update)
|
|
11
20
|
[](https://img.shields.io/npm/v/react-native-ota-hot-update?color=red)
|
|
12
21
|
|
|
@@ -89,108 +98,22 @@ android:requestLegacyExternalStorage="true"
|
|
|
89
98
|
`Remember hot update just work at release mode, debug mode won't working`
|
|
90
99
|
|
|
91
100
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
#### 1.Add these script into your package.json to export bundlejs file and source map file:
|
|
95
|
-
|
|
96
|
-
- For react native CLI:
|
|
97
|
-
```bash
|
|
98
|
-
"scripts": {
|
|
99
|
-
"export-android": "mkdir -p android/output && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/output/index.android.bundle --assets-dest android/output --sourcemap-output android/sourcemap.js && cd android && find output -type f | zip index.android.bundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf android/output && rm -rf android/sourcemap.js",
|
|
100
|
-
"export-ios": "mkdir -p ios/output && react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/output/main.jsbundle --assets-dest ios/output --sourcemap-output ios/sourcemap.js && cd ios && find output -type f | zip main.jsbundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf ios/output && rm -rf ios/sourcemap.js"
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
- For expo / expo bare project:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
"scripts": {
|
|
107
|
-
"export-android": "mkdir -p android/output && npx expo export:embed --platform android --entry-file node_modules/expo/AppEntry.js --bundle-output android/output/index.android.bundle --dev false --assets-dest android/output --sourcemap-output android/sourcemap.js && cd android && find output -type f | zip index.android.bundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf android/output && rm -rf android/sourcemap.js",
|
|
108
|
-
"export-ios": "mkdir -p ios/output && npx expo export:embed --platform ios --entry-file node_modules/expo/AppEntry.js --bundle-output ios/output/main.jsbundle --dev false --assets-dest ios/output --sourcemap-output ios/sourcemap.js && cd ios && find output -type f | zip main.jsbundle.zip -@ && zip sourcemap.zip sourcemap.js && cd .. && rm -rf ios/output && rm -rf ios/sourcemap.js"
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
For expo you might need check path of `--entry-file node_modules/expo/AppEntry.js`, get it from package.json / main
|
|
112
|
-
|
|
113
|
-
These commands are export bundle file and source map file then compress it as a zip file, one for android and one for ios. You can create your own script that export and auto upload to your server. For source map file you can ignore or use that with your purpose to debug in release mode.
|
|
114
|
-
|
|
115
|
-
Then create an json file: `update.json` like that:
|
|
116
|
-
```bash
|
|
117
|
-
{
|
|
118
|
-
"version": 1,
|
|
119
|
-
"downloadAndroidUrl": "https://firebasestorage.googleapis.com/v0/b/ota-demo-68f38.appspot.com/o/index.android.bundle.zip?alt=media",
|
|
120
|
-
"downloadIosUrl": "https://firebasestorage.googleapis.com/v0/b/ota-demo-68f38.appspot.com/o/main.jsbundle.zip?alt=media"
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Then upload your bundlejs files to firebase storage, totally will look like that:
|
|
125
|
-
|
|
126
|
-

|
|
127
|
-
|
|
128
|
-
After you have done everything related to version manager, you just handle the way to update new version like fetch update.json as api to get download url and call this function:
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
import hotUpdate from 'react-native-ota-hot-update';
|
|
132
|
-
import ReactNativeBlobUtil from 'react-native-blob-util';
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
hotUpdate.downloadBundleUri(ReactNativeBlobUtil, url, version, {
|
|
136
|
-
updateSuccess: () => {
|
|
137
|
-
console.log('update success!');
|
|
138
|
-
},
|
|
139
|
-
updateFail(message?: string) {
|
|
140
|
-
Alert.alert('Update failed!', message, [
|
|
141
|
-
{
|
|
142
|
-
text: 'Cancel',
|
|
143
|
-
onPress: () => console.log('Cancel Pressed'),
|
|
144
|
-
style: 'cancel',
|
|
145
|
-
},
|
|
146
|
-
]);
|
|
147
|
-
},
|
|
148
|
-
restartAfterInstall: true,
|
|
149
|
-
});
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
The important thing: this library will control `version` by it self, need always pass version as parameter in `downloadBundleUri`, it will storage as a cache and use this to check whether need update version in the next time. Default of `version` is **0**
|
|
153
|
-
|
|
154
|
-
## Tips for manage bundles
|
|
101
|
+
### Control Hot Update via Server
|
|
102
|
+
With this method, you can host the bundle JS on your own server. The app fetches the updates directly from the server, allowing for dynamic updates.
|
|
155
103
|
|
|
156
|
-
|
|
157
|
-
For CMS, it has a lot open sources, now i am using strapi CMS to control the version, i also create auto release script like code push and can integrate with CI/CD. Here is some screenshot of strapi CMS:
|
|
104
|
+
For detailed instructions on how to implement this, refer to [**DOC_OTA_SERVER.md**](DOC_OTA_SERVER.md).
|
|
158
105
|
|
|
159
|
-
|
|
106
|
+
---
|
|
160
107
|
|
|
161
|
-
|
|
108
|
+
### Control Hot Update via Git Repository
|
|
109
|
+
This method allows you to use a Git repository to host the bundle JS. The app pulls updates directly from the repository, providing an easy and version-controlled way to manage updates.
|
|
162
110
|
|
|
163
|
-
|
|
164
|
-
You can refer folder sampleComponent, it has the logic of update with CMS and also include script auto upload the bundle to CMS.
|
|
165
|
-
Contact me via email if you want to implement hot update via CMS (need service fee)
|
|
166
|
-
|
|
167
|
-
## Functions
|
|
168
|
-
|
|
169
|
-
| key | Return | Action | Parameters |
|
|
170
|
-
| ------------ |--------|------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
|
|
171
|
-
| downloadBundleUri | void | Download bundle and install it | (downloadManager: **DownloadManager**, uri: string, version: number, option?: **UpdateOption**) |
|
|
172
|
-
| setupBundlePath | boolean | Install your bundle path if you control the downloading by your self, ignore that if you use `downloadBundleUri` | path: string, the path of bundlejs file that you downloaded before |
|
|
173
|
-
| removeUpdate | void | Remove you update and use the previos version | restartAfterRemoved?: boolean, restart to apply your changing |
|
|
174
|
-
| resetApp | void | Restart the app to apply the changing | empty |
|
|
175
|
-
| getCurrentVersion | number | Get the current version that let you use to compare and control the logic updating | empty |
|
|
176
|
-
| setCurrentVersion | boolean | Set the current version that let you use to compare and control the logic updating | version: number |
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
## UpdateOption
|
|
180
|
-
|
|
181
|
-
| Option | Required | Type | Description |
|
|
182
|
-
|-------------------------|----------|----------|--------------------------------------------------------------------------------------------------|
|
|
183
|
-
| headers | No | Object | The header to down load your uri bundle file if need token/authentication... |
|
|
184
|
-
| updateSuccess | No | Callback | Will trigger when install update success |
|
|
185
|
-
| updateFail(message: string) | No | Callback | Will trigger when install update failed |
|
|
186
|
-
| restartAfterInstall | No | boolean | default is `false`, if `true` will restart the app after install success to apply the new change |
|
|
187
|
-
| progress | No | void | A callback to show progress when downloading bundle |
|
|
188
|
-
| extensionBundle | No | string | extension of bundle js file, default is .bundle for android, ios is .jsbundle |
|
|
189
|
-
|
|
190
|
-
## DownloadManager
|
|
191
|
-
|
|
192
|
-
The same method as `react-native-blob-util` or `rn-fetch-blob`
|
|
111
|
+
For detailed instructions on how to implement this, refer to [**DOC_OTA_GIT.md**](DOC_OTA_GIT.md).
|
|
193
112
|
|
|
194
113
|
## License
|
|
195
114
|
|
|
196
115
|
[MIT](LICENSE)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### Sponsor this project
|
|
119
|
+
https://paypal.me/vantuan88291
|
|
@@ -36,6 +36,10 @@ public abstract class NativeOtaHotUpdateSpec extends ReactContextBaseJavaModule
|
|
|
36
36
|
@DoNotStrip
|
|
37
37
|
public abstract void setupBundlePath(String path, String extension, Promise promise);
|
|
38
38
|
|
|
39
|
+
@ReactMethod
|
|
40
|
+
@DoNotStrip
|
|
41
|
+
public abstract void setExactBundlePath(String path, Promise promise);
|
|
42
|
+
|
|
39
43
|
@ReactMethod
|
|
40
44
|
@DoNotStrip
|
|
41
45
|
public abstract void deleteBundle(double i, Promise promise);
|
|
@@ -17,6 +17,11 @@ static facebook::jsi::Value __hostFunction_NativeOtaHotUpdateSpecJSI_setupBundle
|
|
|
17
17
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "setupBundlePath", "(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeOtaHotUpdateSpecJSI_setExactBundlePath(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "setExactBundlePath", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
static facebook::jsi::Value __hostFunction_NativeOtaHotUpdateSpecJSI_deleteBundle(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
26
|
static jmethodID cachedMethodId = nullptr;
|
|
22
27
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "deleteBundle", "(DLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
@@ -40,6 +45,7 @@ static facebook::jsi::Value __hostFunction_NativeOtaHotUpdateSpecJSI_setCurrentV
|
|
|
40
45
|
NativeOtaHotUpdateSpecJSI::NativeOtaHotUpdateSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
41
46
|
: JavaTurboModule(params) {
|
|
42
47
|
methodMap_["setupBundlePath"] = MethodMetadata {2, __hostFunction_NativeOtaHotUpdateSpecJSI_setupBundlePath};
|
|
48
|
+
methodMap_["setExactBundlePath"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateSpecJSI_setExactBundlePath};
|
|
43
49
|
methodMap_["deleteBundle"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateSpecJSI_deleteBundle};
|
|
44
50
|
methodMap_["restart"] = MethodMetadata {0, __hostFunction_NativeOtaHotUpdateSpecJSI_restart};
|
|
45
51
|
methodMap_["getCurrentVersion"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateSpecJSI_getCurrentVersion};
|
|
@@ -18,6 +18,12 @@ static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setupBundlePath(js
|
|
|
18
18
|
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
+
static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setExactBundlePath(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
|
+
return static_cast<NativeOtaHotUpdateCxxSpecJSI *>(&turboModule)->setExactBundlePath(
|
|
23
|
+
rt,
|
|
24
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
21
27
|
static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_deleteBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
28
|
return static_cast<NativeOtaHotUpdateCxxSpecJSI *>(&turboModule)->deleteBundle(
|
|
23
29
|
rt,
|
|
@@ -46,6 +52,7 @@ static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setCurrentVersion(
|
|
|
46
52
|
NativeOtaHotUpdateCxxSpecJSI::NativeOtaHotUpdateCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
47
53
|
: TurboModule("OtaHotUpdate", jsInvoker) {
|
|
48
54
|
methodMap_["setupBundlePath"] = MethodMetadata {2, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setupBundlePath};
|
|
55
|
+
methodMap_["setExactBundlePath"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setExactBundlePath};
|
|
49
56
|
methodMap_["deleteBundle"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_deleteBundle};
|
|
50
57
|
methodMap_["restart"] = MethodMetadata {0, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_restart};
|
|
51
58
|
methodMap_["getCurrentVersion"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_getCurrentVersion};
|
package/android/generated/jni/react/renderer/components/RNOtaHotUpdateSpec/RNOtaHotUpdateSpecJSI.h
CHANGED
|
@@ -21,6 +21,7 @@ protected:
|
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
virtual jsi::Value setupBundlePath(jsi::Runtime &rt, jsi::String path, jsi::String extension) = 0;
|
|
24
|
+
virtual jsi::Value setExactBundlePath(jsi::Runtime &rt, jsi::String path) = 0;
|
|
24
25
|
virtual jsi::Value deleteBundle(jsi::Runtime &rt, double i) = 0;
|
|
25
26
|
virtual void restart(jsi::Runtime &rt) = 0;
|
|
26
27
|
virtual jsi::Value getCurrentVersion(jsi::Runtime &rt, double a) = 0;
|
|
@@ -59,6 +60,14 @@ private:
|
|
|
59
60
|
return bridging::callFromJs<jsi::Value>(
|
|
60
61
|
rt, &T::setupBundlePath, jsInvoker_, instance_, std::move(path), std::move(extension));
|
|
61
62
|
}
|
|
63
|
+
jsi::Value setExactBundlePath(jsi::Runtime &rt, jsi::String path) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::setExactBundlePath) == 2,
|
|
66
|
+
"Expected setExactBundlePath(...) to have 2 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<jsi::Value>(
|
|
69
|
+
rt, &T::setExactBundlePath, jsInvoker_, instance_, std::move(path));
|
|
70
|
+
}
|
|
62
71
|
jsi::Value deleteBundle(jsi::Runtime &rt, double i) override {
|
|
63
72
|
static_assert(
|
|
64
73
|
bridging::getParameterCount(&T::deleteBundle) == 2,
|
|
@@ -84,17 +84,21 @@ class OtaHotUpdateModule internal constructor(context: ReactApplicationContext)
|
|
|
84
84
|
@ReactMethod
|
|
85
85
|
override fun setupBundlePath(path: String?, extension: String?, promise: Promise) {
|
|
86
86
|
if (path != null) {
|
|
87
|
-
deleteOldBundleIfneeded()
|
|
88
87
|
val file = File(path)
|
|
89
88
|
if (file.exists() && file.isFile) {
|
|
89
|
+
deleteOldBundleIfneeded()
|
|
90
90
|
val fileUnzip = extractZipFile(file, extension ?: ".bundle")
|
|
91
|
-
Log.d("setupBundlePath----: ", fileUnzip!!)
|
|
92
91
|
if (fileUnzip != null) {
|
|
92
|
+
Log.d("setupBundlePath----: ", fileUnzip)
|
|
93
93
|
file.delete()
|
|
94
94
|
val sharedPrefs = SharedPrefs(reactApplicationContext)
|
|
95
95
|
sharedPrefs.putString(PATH, fileUnzip)
|
|
96
96
|
promise.resolve(true)
|
|
97
97
|
} else {
|
|
98
|
+
file.delete()
|
|
99
|
+
deleteDirectory(file.parentFile)
|
|
100
|
+
val sharedPrefs = SharedPrefs(reactApplicationContext)
|
|
101
|
+
sharedPrefs.putString(PATH, "")
|
|
98
102
|
promise.resolve(false)
|
|
99
103
|
}
|
|
100
104
|
} else {
|
|
@@ -136,6 +140,13 @@ class OtaHotUpdateModule internal constructor(context: ReactApplicationContext)
|
|
|
136
140
|
sharedPrefs.putString(VERSION, version)
|
|
137
141
|
promise.resolve(true)
|
|
138
142
|
}
|
|
143
|
+
|
|
144
|
+
@ReactMethod
|
|
145
|
+
override fun setExactBundlePath(path: String?, promise: Promise) {
|
|
146
|
+
val sharedPrefs = SharedPrefs(reactApplicationContext)
|
|
147
|
+
sharedPrefs.putString(PATH, path)
|
|
148
|
+
promise.resolve(true)
|
|
149
|
+
}
|
|
139
150
|
companion object {
|
|
140
151
|
const val NAME = "OtaHotUpdate"
|
|
141
152
|
}
|
|
@@ -12,4 +12,5 @@ abstract class OtaHotUpdateSpec internal constructor(context: ReactApplicationCo
|
|
|
12
12
|
abstract fun restart()
|
|
13
13
|
abstract fun getCurrentVersion(a: Double, promise: Promise)
|
|
14
14
|
abstract fun setCurrentVersion(version: String?, promise: Promise)
|
|
15
|
+
abstract fun setExactBundlePath(path: String?, promise: Promise)
|
|
15
16
|
}
|
package/ios/OtaHotUpdate.mm
CHANGED
|
@@ -171,8 +171,8 @@ RCT_EXPORT_METHOD(setupBundlePath:(NSString *)path extension:(NSString *)extensi
|
|
|
171
171
|
[self removeBundleIfNeeded];
|
|
172
172
|
//Unzip file
|
|
173
173
|
NSString *extractedFilePath = [self unzipFileAtPath:path extension:(extension != nil) ? extension : @".jsbundle"];
|
|
174
|
-
NSLog(@"file extraction----- %@", extractedFilePath);
|
|
175
174
|
if (extractedFilePath) {
|
|
175
|
+
NSLog(@"file extraction----- %@", extractedFilePath);
|
|
176
176
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
177
177
|
[defaults setObject:extractedFilePath forKey:@"PATH"];
|
|
178
178
|
[defaults synchronize];
|
|
@@ -218,6 +218,19 @@ RCT_EXPORT_METHOD(setCurrentVersion:(NSString *)version
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
RCT_EXPORT_METHOD(setExactBundlePath:(NSString *)path
|
|
222
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
223
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
224
|
+
if (path) {
|
|
225
|
+
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
226
|
+
[defaults setObject:path forKey:@"PATH"];
|
|
227
|
+
[defaults synchronize];
|
|
228
|
+
resolve(@(YES));
|
|
229
|
+
} else {
|
|
230
|
+
resolve(@(NO));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
221
234
|
- (void)loadBundle
|
|
222
235
|
{
|
|
223
236
|
RCTTriggerReloadCommandListeners(@"react-native-ota-hot-update: Restart");
|
|
@@ -30,6 +30,10 @@ namespace facebook::react {
|
|
|
30
30
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "setupBundlePath", @selector(setupBundlePath:extension:resolve:reject:), args, count);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
static facebook::jsi::Value __hostFunction_NativeOtaHotUpdateSpecJSI_setExactBundlePath(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
34
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "setExactBundlePath", @selector(setExactBundlePath:resolve:reject:), args, count);
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
static facebook::jsi::Value __hostFunction_NativeOtaHotUpdateSpecJSI_deleteBundle(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
34
38
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "deleteBundle", @selector(deleteBundle:resolve:reject:), args, count);
|
|
35
39
|
}
|
|
@@ -52,6 +56,9 @@ namespace facebook::react {
|
|
|
52
56
|
methodMap_["setupBundlePath"] = MethodMetadata {2, __hostFunction_NativeOtaHotUpdateSpecJSI_setupBundlePath};
|
|
53
57
|
|
|
54
58
|
|
|
59
|
+
methodMap_["setExactBundlePath"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateSpecJSI_setExactBundlePath};
|
|
60
|
+
|
|
61
|
+
|
|
55
62
|
methodMap_["deleteBundle"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateSpecJSI_deleteBundle};
|
|
56
63
|
|
|
57
64
|
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
extension:(NSString *)extension
|
|
38
38
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
39
39
|
reject:(RCTPromiseRejectBlock)reject;
|
|
40
|
+
- (void)setExactBundlePath:(NSString *)path
|
|
41
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
42
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
40
43
|
- (void)deleteBundle:(double)i
|
|
41
44
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
42
45
|
reject:(RCTPromiseRejectBlock)reject;
|
|
@@ -18,6 +18,12 @@ static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setupBundlePath(js
|
|
|
18
18
|
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
+
static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setExactBundlePath(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
|
+
return static_cast<NativeOtaHotUpdateCxxSpecJSI *>(&turboModule)->setExactBundlePath(
|
|
23
|
+
rt,
|
|
24
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
21
27
|
static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_deleteBundle(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
22
28
|
return static_cast<NativeOtaHotUpdateCxxSpecJSI *>(&turboModule)->deleteBundle(
|
|
23
29
|
rt,
|
|
@@ -46,6 +52,7 @@ static jsi::Value __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setCurrentVersion(
|
|
|
46
52
|
NativeOtaHotUpdateCxxSpecJSI::NativeOtaHotUpdateCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
47
53
|
: TurboModule("OtaHotUpdate", jsInvoker) {
|
|
48
54
|
methodMap_["setupBundlePath"] = MethodMetadata {2, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setupBundlePath};
|
|
55
|
+
methodMap_["setExactBundlePath"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_setExactBundlePath};
|
|
49
56
|
methodMap_["deleteBundle"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_deleteBundle};
|
|
50
57
|
methodMap_["restart"] = MethodMetadata {0, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_restart};
|
|
51
58
|
methodMap_["getCurrentVersion"] = MethodMetadata {1, __hostFunction_NativeOtaHotUpdateCxxSpecJSI_getCurrentVersion};
|
|
@@ -21,6 +21,7 @@ protected:
|
|
|
21
21
|
|
|
22
22
|
public:
|
|
23
23
|
virtual jsi::Value setupBundlePath(jsi::Runtime &rt, jsi::String path, jsi::String extension) = 0;
|
|
24
|
+
virtual jsi::Value setExactBundlePath(jsi::Runtime &rt, jsi::String path) = 0;
|
|
24
25
|
virtual jsi::Value deleteBundle(jsi::Runtime &rt, double i) = 0;
|
|
25
26
|
virtual void restart(jsi::Runtime &rt) = 0;
|
|
26
27
|
virtual jsi::Value getCurrentVersion(jsi::Runtime &rt, double a) = 0;
|
|
@@ -59,6 +60,14 @@ private:
|
|
|
59
60
|
return bridging::callFromJs<jsi::Value>(
|
|
60
61
|
rt, &T::setupBundlePath, jsInvoker_, instance_, std::move(path), std::move(extension));
|
|
61
62
|
}
|
|
63
|
+
jsi::Value setExactBundlePath(jsi::Runtime &rt, jsi::String path) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::setExactBundlePath) == 2,
|
|
66
|
+
"Expected setExactBundlePath(...) to have 2 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<jsi::Value>(
|
|
69
|
+
rt, &T::setExactBundlePath, jsInvoker_, instance_, std::move(path));
|
|
70
|
+
}
|
|
62
71
|
jsi::Value deleteBundle(jsi::Runtime &rt, double i) override {
|
|
63
72
|
static_assert(
|
|
64
73
|
bridging::getParameterCount(&T::deleteBundle) == 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOtaHotUpdate.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOtaHotUpdate.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAWpCC,gCAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
FileReader.prototype.readAsArrayBuffer = function (blob) {
|
|
7
|
+
if (this.readyState === this.LOADING) throw new Error('InvalidStateError');
|
|
8
|
+
this._setReadyState(this.LOADING);
|
|
9
|
+
this._result = null;
|
|
10
|
+
this._error = null;
|
|
11
|
+
const fr = new FileReader();
|
|
12
|
+
fr.onloadend = () => {
|
|
13
|
+
const content = atob(fr.result.replace(/data:[^;]+;base64,/, ''));
|
|
14
|
+
const buffer = new ArrayBuffer(content.length);
|
|
15
|
+
const view = new Uint8Array(buffer);
|
|
16
|
+
view.set(Array.from(content).map(c => c.charCodeAt(0)));
|
|
17
|
+
this._result = buffer;
|
|
18
|
+
this._setReadyState(this.DONE);
|
|
19
|
+
};
|
|
20
|
+
fr.readAsDataURL(blob);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// from: https://stackoverflow.com/questions/42829838/react-native-atob-btoa-not-working-without-remote-js-debugging
|
|
24
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
25
|
+
const atob = (input = '') => {
|
|
26
|
+
let str = input.replace(/[=]+$/, '');
|
|
27
|
+
let output = '';
|
|
28
|
+
if (str.length % 4 == 1) {
|
|
29
|
+
throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
30
|
+
}
|
|
31
|
+
for (let bc = 0, bs = 0, buffer, i = 0; buffer = str.charAt(i++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
|
|
32
|
+
buffer = chars.indexOf(buffer);
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=fileReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FileReader","prototype","readAsArrayBuffer","blob","readyState","LOADING","Error","_setReadyState","_result","_error","fr","onloadend","content","atob","result","replace","buffer","ArrayBuffer","length","view","Uint8Array","set","Array","from","map","c","charCodeAt","DONE","readAsDataURL","chars","input","str","output","bc","bs","i","charAt","String","fromCharCode","ind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,GAAG,CAAC,IAAI,CAAC,EAAE;IACvB,MAAM,IAAIZ,KAAK,CACb,mEACF,CAAC;EACH;EACA,KACE,IAAI2B,EAAE,GAAG,CAAC,EAAEC,EAAE,GAAG,CAAC,EAAElB,MAAM,EAAEmB,CAAC,GAAG,CAAC,EAChCnB,MAAM,GAAGe,GAAG,CAACK,MAAM,CAACD,CAAC,EAAE,CAAC,EACzB,CAACnB,MAAM,KAAMkB,EAAE,GAAGD,EAAE,GAAG,CAAC,GAAGC,EAAE,GAAG,EAAE,GAAGlB,MAAM,GAAGA,MAAM,EAAGiB,EAAE,EAAE,GAAG,CAAC,CAAC,GAC3DD,MAAM,IAAIK,MAAM,CAACC,YAAY,CAAC,GAAG,GAAIJ,EAAE,KAAM,CAAC,CAAC,GAAGD,EAAE,GAAI,CAAC,CAAE,CAAC,GAC7D,CAAC,EACL;IACAjB,MAAM,GAAGa,KAAK,CAACU,OAAO,CAACvB,MAAM,CAAC;EAChC;EAEA,OAAOgB,MAAM;AACf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.writeFile = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.readlink = exports.readdir = exports.readFile = exports.mkdir = exports.lstat = exports.chmod = void 0;
|
|
7
|
+
var _buffer = require("buffer");
|
|
8
|
+
let RNFS = {
|
|
9
|
+
unlink: console.log,
|
|
10
|
+
readdir: console.log,
|
|
11
|
+
mkdir: console.log,
|
|
12
|
+
readFile: console.log,
|
|
13
|
+
writeFile: console.log,
|
|
14
|
+
stat: console.log
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
RNFS = require('react-native-fs');
|
|
18
|
+
} catch {}
|
|
19
|
+
function Err(name) {
|
|
20
|
+
return class extends Error {
|
|
21
|
+
code = name;
|
|
22
|
+
constructor(...args) {
|
|
23
|
+
super(...args);
|
|
24
|
+
if (this.message) {
|
|
25
|
+
this.message = name + ': ' + this.message;
|
|
26
|
+
} else {
|
|
27
|
+
this.message = name;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// const EEXIST = Err('EEXIST'); // <-- Unused because RNFS's mkdir never throws
|
|
34
|
+
const ENOENT = Err('ENOENT');
|
|
35
|
+
const ENOTDIR = Err('ENOTDIR');
|
|
36
|
+
// const ENOTEMPTY = Err('ENOTEMPTY'); // <-- Unused because RNFS's unlink is recursive by default
|
|
37
|
+
|
|
38
|
+
const readdir = async path => {
|
|
39
|
+
try {
|
|
40
|
+
return await RNFS.readdir(path);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
switch (err.message) {
|
|
43
|
+
case 'Attempt to get length of null array':
|
|
44
|
+
{
|
|
45
|
+
throw new ENOTDIR(path);
|
|
46
|
+
}
|
|
47
|
+
case 'Folder does not exist':
|
|
48
|
+
{
|
|
49
|
+
throw new ENOENT(path);
|
|
50
|
+
}
|
|
51
|
+
default:
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.readdir = readdir;
|
|
57
|
+
const mkdir = async path => {
|
|
58
|
+
return RNFS.mkdir(path);
|
|
59
|
+
};
|
|
60
|
+
exports.mkdir = mkdir;
|
|
61
|
+
const readFile = async (path, opts) => {
|
|
62
|
+
let encoding;
|
|
63
|
+
if (typeof opts === 'string') {
|
|
64
|
+
encoding = opts;
|
|
65
|
+
} else if (typeof opts === 'object') {
|
|
66
|
+
encoding = opts.encoding;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
let result = await RNFS.readFile(path, encoding || 'base64');
|
|
71
|
+
if (!encoding) {
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
result = _buffer.Buffer.from(result, 'base64');
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
exports.readFile = readFile;
|
|
78
|
+
const writeFile = async (path, content, opts) => {
|
|
79
|
+
let encoding;
|
|
80
|
+
if (typeof opts === 'string') {
|
|
81
|
+
encoding = opts;
|
|
82
|
+
} else if (typeof opts === 'object') {
|
|
83
|
+
encoding = opts.encoding;
|
|
84
|
+
}
|
|
85
|
+
if (typeof content === 'string') {
|
|
86
|
+
encoding = encoding || 'utf8';
|
|
87
|
+
} else {
|
|
88
|
+
encoding = 'base64';
|
|
89
|
+
content = _buffer.Buffer.from(content).toString('base64');
|
|
90
|
+
}
|
|
91
|
+
await RNFS.writeFile(path, content, encoding);
|
|
92
|
+
};
|
|
93
|
+
exports.writeFile = writeFile;
|
|
94
|
+
const stat = async path => {
|
|
95
|
+
try {
|
|
96
|
+
const r = await RNFS.stat(path);
|
|
97
|
+
// we monkeypatch the result with a `isSymbolicLink` method because isomorphic-git needs it.
|
|
98
|
+
// Since RNFS doesn't appear to support symlinks at all, we'll just always return false.
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
r.isSymbolicLink = () => false;
|
|
101
|
+
return r;
|
|
102
|
+
} catch (err) {
|
|
103
|
+
switch (err.message) {
|
|
104
|
+
case 'File does not exist':
|
|
105
|
+
{
|
|
106
|
+
throw new ENOENT(path);
|
|
107
|
+
}
|
|
108
|
+
default:
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Since there are no symbolic links, lstat and stat are equivalent
|
|
115
|
+
exports.stat = stat;
|
|
116
|
+
const lstat = exports.lstat = stat;
|
|
117
|
+
const unlink = async path => {
|
|
118
|
+
try {
|
|
119
|
+
await RNFS.unlink(path);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
switch (err.message) {
|
|
122
|
+
case 'File does not exist':
|
|
123
|
+
{
|
|
124
|
+
throw new ENOENT(path);
|
|
125
|
+
}
|
|
126
|
+
default:
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// RNFS doesn't have a separate rmdir method, so we can use unlink for deleting directories too
|
|
133
|
+
exports.unlink = unlink;
|
|
134
|
+
const rmdir = exports.rmdir = unlink;
|
|
135
|
+
|
|
136
|
+
// These are optional, which is good because there is no equivalent in RNFS
|
|
137
|
+
const readlink = async () => {
|
|
138
|
+
throw new Error('not implemented');
|
|
139
|
+
};
|
|
140
|
+
exports.readlink = readlink;
|
|
141
|
+
const symlink = async () => {
|
|
142
|
+
throw new Error('not implemented');
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Technically we could pull this off by using `readFile` + `writeFile` with the `mode` option
|
|
146
|
+
// However, it's optional, because isomorphic-git will do exactly that (a readFile and a writeFile with the new mode)
|
|
147
|
+
exports.symlink = symlink;
|
|
148
|
+
const chmod = async () => {
|
|
149
|
+
throw new Error('not implemented');
|
|
150
|
+
};
|
|
151
|
+
exports.chmod = chmod;
|
|
152
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_buffer","require","RNFS","unlink","console","log","readdir","mkdir","readFile","writeFile","stat","Err","name","Error","code","constructor","args","message","ENOENT","ENOTDIR","path","err","exports","opts","encoding","result","Buffer","from","content","toString","r","isSymbolicLink","lstat","rmdir","readlink","symlink","chmod"],"sourceRoot":"../../../../src","sources":["gits/helper/fs.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAIC,IAAI,GAAG;EACTC,MAAM,EAAEC,OAAO,CAACC,GAAG;EACnBC,OAAO,EAAEF,OAAO,CAACC,GAAG;EACpBE,KAAK,EAAEH,OAAO,CAACC,GAAG;EAClBG,QAAQ,EAAEJ,OAAO,CAACC,GAAG;EACrBI,SAAS,EAAEL,OAAO,CAACC,GAAG;EACtBK,IAAI,EAAEN,OAAO,CAACC;AAChB,CAAC;AACD,IAAI;EACFH,IAAI,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