react-native-pdf
Advanced tools
Comparing version 3.0.17 to 4.0.0
@@ -17,5 +17,5 @@ { | ||
"dependencies": { | ||
"react": "16.0.0-alpha.12", | ||
"react-native": "0.47.1", | ||
"react-native-fetch-blob": "0.10.8", | ||
"react": "*", | ||
"react-native": "*", | ||
"rn-fetch-blob": "^0.10.12", | ||
"react-native-pdf": "github:wonday/react-native-pdf#master" | ||
@@ -22,0 +22,0 @@ }, |
49
index.js
@@ -22,3 +22,3 @@ /** | ||
import RNFetchBlob from 'react-native-fetch-blob'; | ||
import RNFetchBlob from 'rn-fetch-blob'; | ||
@@ -154,3 +154,3 @@ const SHA1 = require('crypto-js/sha1'); | ||
} else { | ||
// cache expired then reload it | ||
// cache expirated then reload it | ||
this._prepareFile(source); | ||
@@ -181,4 +181,4 @@ } | ||
// delete old cache file | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
this._unlinkFile(cacheFile); | ||
if (isNetwork) { | ||
@@ -193,3 +193,3 @@ this._downloadFile(source, cacheFile); | ||
.catch(async (error) => { | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
this._unlinkFile(cacheFile); | ||
this._onError(error); | ||
@@ -206,3 +206,3 @@ }) | ||
.catch(async (error) => { | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
this._unlinkFile(cacheFile); | ||
this._onError(error) | ||
@@ -236,3 +236,3 @@ }); | ||
const tempCacheFile = cacheFile + '.tmp'; | ||
await RNFetchBlob.fs.unlink(tempCacheFile); | ||
this._unlinkFile(tempCacheFile); | ||
@@ -273,4 +273,4 @@ this.lastRNBFTask = RNFetchBlob.config({ | ||
.catch(async (error) => { | ||
await RNFetchBlob.fs.unlink(tempCacheFile); | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
RNFetchBlob.fs.unlink(tempCacheFile); | ||
RNFetchBlob.fs.unlink(cacheFile); | ||
this._onError(error) | ||
@@ -280,5 +280,12 @@ }) | ||
.catch(async (error) => { | ||
await RNFetchBlob.fs.unlink(tempCacheFile); | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
this._onError(error) | ||
RNFetchBlob.fs | ||
.cp(tempCacheFile, cacheFile) | ||
.then(() => { | ||
this.setState({path: cacheFile, isDownloaded: true, progress: 1}); | ||
}) | ||
.catch(async (error) => { | ||
RNFetchBlob.fs.unlink(tempCacheFile); | ||
RNFetchBlob.fs.unlink(cacheFile); | ||
this._onError(error) | ||
}) | ||
}); | ||
@@ -288,4 +295,4 @@ break; | ||
default: | ||
await RNFetchBlob.fs.unlink(tempCacheFile); | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
this._unlinkFile(tempCacheFile); | ||
this._unlinkFile(cacheFile); | ||
this._onError(new Error(`load pdf failed with code ${status}`)); | ||
@@ -296,4 +303,4 @@ break; | ||
.catch(async (error) => { | ||
await RNFetchBlob.fs.unlink(tempCacheFile); | ||
await RNFetchBlob.fs.unlink(cacheFile); | ||
this._unlinkFile(tempCacheFile); | ||
this._unlinkFile(cacheFile); | ||
this._onError(error); | ||
@@ -304,2 +311,10 @@ }); | ||
_unlinkFile = async (file) => { | ||
try { | ||
await RNFetchBlob.fs.unlink(file); | ||
}catch (e) { | ||
} | ||
} | ||
setNativeProps = nativeProps => { | ||
@@ -410,2 +425,2 @@ | ||
} | ||
}); | ||
}); |
{ | ||
"name": "react-native-pdf", | ||
"version": "3.0.17", | ||
"version": "4.0.0", | ||
"description": "A react native PDF view component", | ||
@@ -33,4 +33,4 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"react-native-fetch-blob": "^0.10.8" | ||
"rn-fetch-blob": "^0.10.12" | ||
} | ||
} |
@@ -15,10 +15,10 @@ # react-native-pdf | ||
### Installation | ||
We use [`react-native-fetch-blob`](https://github.com/wkh237/react-native-fetch-blob#installation) to handle file system access in this package, | ||
So you should install react-native-pdf and react-native-fetch-blob | ||
We use [`rn-fetch-blob`](https://github.com/joltup/rn-fetch-blob) to handle file system access in this package, | ||
So you should install react-native-pdf and rn-fetch-blob | ||
```bash | ||
npm install react-native-fetch-blob --save | ||
npm install rn-fetch-blob --save | ||
npm install react-native-pdf --save | ||
react-native link react-native-fetch-blob | ||
react-native link rn-fetch-blob | ||
react-native link react-native-pdf | ||
@@ -62,3 +62,13 @@ ``` | ||
### ChangeLog | ||
v4.0.0 (**break change**) | ||
1. replace dependence lib ```react-native-fetch-blob``` with ```rn-fetch-blob``` | ||
if you upgrade from an old version, you should | ||
``` | ||
react-native unlink react-native-fetch-blob | ||
npm uninstall react-native-fetch-blob | ||
npm install rn-fetch-blob --save | ||
react-native link rn-fetch-blob | ||
``` | ||
v3.0.17 | ||
@@ -65,0 +75,0 @@ 1. update android build tool to v26.0.3 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3039391
1670
257