react-native-ota-hot-update 1.0.4 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ota-hot-update",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Hot update for react native",
5
5
  "main": "src/index",
6
6
  "repository": "https://github.com/vantuan88291/react-native-ota-hot-update",
package/src/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
- import {downloadBundleFile} from './Utils.ts';
2
+ import ReactNativeBlobUtil from 'react-native-blob-util';
3
3
  const LINKING_ERROR =
4
4
  'The package \'rn-hotupdate\' doesn\'t seem to be linked. Make sure: \n\n' +
5
5
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
@@ -23,7 +23,21 @@ const RNhotupdate = NativeModules.RNhotupdate
23
23
  },
24
24
  }
25
25
  );
26
-
26
+ const downloadBundleFile = async (uri: string, headers?: object, callback?: (received: string, total: string) => void) => {
27
+ const res = await ReactNativeBlobUtil
28
+ .config({
29
+ fileCache: Platform.OS === 'android',
30
+ })
31
+ .fetch('GET', uri, {
32
+ ...headers,
33
+ })
34
+ .progress((received, total) => {
35
+ if (callback) {
36
+ callback(received, total)
37
+ }
38
+ });
39
+ return res.path();
40
+ };
27
41
  function setupBundlePath(path: string): Promise<boolean> {
28
42
  return RNhotupdate.setupBundlePath(path);
29
43
  }
package/src/Utils.ts DELETED
@@ -1,19 +0,0 @@
1
- import {
2
- Platform,
3
- } from 'react-native';
4
- import ReactNativeBlobUtil from 'react-native-blob-util';
5
- export const downloadBundleFile = async (uri: string, headers?: object, callback?: (received: string, total: string) => void) => {
6
- const res = await ReactNativeBlobUtil
7
- .config({
8
- fileCache: Platform.OS === 'android',
9
- })
10
- .fetch('GET', uri, {
11
- ...headers,
12
- })
13
- .progress((received, total) => {
14
- if (callback) {
15
- callback(received, total)
16
- }
17
- });
18
- return res.path();
19
- };