Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace react-native-fetch-blob with rn-fetch-blob #150

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CachedImageExample/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ android {
}

dependencies {
compile project(':react-native-fetch-blob')
compile project(':rn-fetch-blob')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
Expand Down
4 changes: 2 additions & 2 deletions CachedImageExample/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rootProject.name = 'CachedImageExample'
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')

include ':app'
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
2D02E47B1E0B4A5D006451C7 /* CachedImageExample-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CachedImageExample-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* CachedImageExample-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "CachedImageExample-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
7308BE64683240A988168F6A /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFetchBlob.xcodeproj; path = "../node_modules/react-native-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = "<group>"; };
7308BE64683240A988168F6A /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFetchBlob.xcodeproj; path = "../node_modules/rn-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down
55 changes: 32 additions & 23 deletions CachedImageExample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3084,14 +3084,19 @@ lodash.templatesettings@^3.0.0:
lodash._reinterpolate "^3.0.0"
lodash.escape "^3.0.0"

[email protected], lodash@^4.14.0, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.6.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
[email protected]:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==

lodash@^3.5.0:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"

lodash@^4.14.0, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.6.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

lodash@^4.16.6:
version "4.17.2"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42"
Expand Down Expand Up @@ -3762,9 +3767,10 @@ qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"

querystringify@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb"
querystringify@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e"
integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==

random-bytes@~1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -3814,28 +3820,21 @@ react-devtools-core@^2.5.0:
ws "^2.0.3"

react-native-cached-image@../:
version "1.4.0-rc"
version "1.4.5"
dependencies:
crypto-js "3.1.9-1"
lodash "4.17.4"
lodash "4.17.11"
prop-types "15.5.10"
react-native-clcasher "1.0.0"
react-native-fetch-blob "0.10.8"
url-parse "1.1.9"
rn-fetch-blob "0.10.16"
url-parse "1.4.4"

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/react-native-clcasher/-/react-native-clcasher-1.0.0.tgz#1f77fb1a4abc6a0337ef19c991e04f19af6d2789"
dependencies:
mock-async-storage "^1.0.3"

[email protected]:
version "0.10.8"
resolved "https://registry.yarnpkg.com/react-native-fetch-blob/-/react-native-fetch-blob-0.10.8.tgz#4fc256abae0cb5f10e7c41f28c11b3ff330d72a9"
dependencies:
base-64 "0.1.0"
glob "7.0.6"

react-native@^0.48.3:
version "0.48.3"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.48.3.tgz#ec17a66929eb292512b14c091cf260b25e2fba18"
Expand Down Expand Up @@ -4148,9 +4147,10 @@ require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"

[email protected].x:
requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=

[email protected]:
version "1.1.7"
Expand Down Expand Up @@ -4204,6 +4204,14 @@ rimraf@~2.2.6:
version "2.2.8"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582"

[email protected]:
version "0.10.16"
resolved "https://registry.yarnpkg.com/rn-fetch-blob/-/rn-fetch-blob-0.10.16.tgz#bd54f66c94f7a8e06c213077483646478ae8d230"
integrity sha512-hZV+nF0HK4CWmspXGMw7/G8Q8qugpS/wbKiNLsFpdBZR8XYzjFZNvBWgGyC0F5JWQn3sjmK2w/FJjBlwdQWNQg==
dependencies:
base-64 "0.1.0"
glob "7.0.6"

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/rndm/-/rndm-1.2.0.tgz#f33fe9cfb52bbfd520aa18323bc65db110a1b76c"
Expand Down Expand Up @@ -4745,12 +4753,13 @@ [email protected], unpipe@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"

[email protected]:
version "1.1.9"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19"
[email protected]:
version "1.4.4"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.4.tgz#cac1556e95faa0303691fec5cf9d5a1bc34648f8"
integrity sha512-/92DTTorg4JjktLNLe6GPS2/RvAd/RGr6LuktmWSMLEOa6rjnlrFXNgSbSmkNvCoL2T028A0a1JaJLzRMlFoHg==
dependencies:
querystringify "~1.0.0"
requires-port "1.0.x"
querystringify "^2.0.0"
requires-port "^1.0.0"

[email protected], util-deprecate@~1.0.1:
version "1.0.2"
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ This package is greatly inspired by [@jayesbe](https://github.com/jayesbe)'s ama
- or -
yarn add react-native-cached-image

We use [`react-native-fetch-blob`](https://github.com/wkh237/react-native-fetch-blob#installation) to handle file system access in this package and it requires an extra step during the installation.
We use [`rn-fetch-blob`](https://github.com/joltup/rn-fetch-blob#installation) to handle file system access in this package and it requires an extra step during the installation.

_You should only have to do this once._

react-native link react-native-fetch-blob
react-native link rn-fetch-blob

Or, if you want to add Android permissions to AndroidManifest.xml automatically, use this one:

RNFB_ANDROID_PERMISSIONS=true react-native link react-native-fetch-blob
RNFB_ANDROID_PERMISSIONS=true react-native link rn-fetch-blob

### Network Status - Android only
Add the following line to your android/app/src/AndroidManifest.xml
Expand Down Expand Up @@ -69,7 +69,7 @@ This package exposes 3 modules:
const {
CachedImage, // react-native component that is a drop-in replacement for your react-native `Image` components
ImageCacheProvider, // a top level component that provides accsess to the underlying `ImageCacheManager` and preloads images
ImageCacheManager, // the logic behind cache machanism - ttl, fs, url resolving etc.
ImageCacheManager, // the logic behind cache machanism - ttl, fs, url resolving etc.
} = require('react-native-cached-image');
```

Expand Down Expand Up @@ -100,7 +100,7 @@ Returns info about the cache, list of files and the total size of the cache.
### CachedImage
`CachedImage` is a drop in replacement for the `Image` component that will attempt to cache remote URLs for better performance.
It's main use is to hide the cache layer from the user and provide a simple way to cache images.
`CachedImage` uses an instance of `ImageCacheManager` to interact with the cache, if there is an instance provided by `ImageCacheProvider` via the context it will be used, otherwise a new instance will be created with the options from the component's props.
`CachedImage` uses an instance of `ImageCacheManager` to interact with the cache, if there is an instance provided by `ImageCacheProvider` via the context it will be used, otherwise a new instance will be created with the options from the component's props.

```jsx
<CachedImage
Expand Down Expand Up @@ -135,16 +135,16 @@ A set of options that are provided to the `ImageCacheManager` and provide ways t
```jsx
type ImageCacheManagerOptions = {
headers: PropTypes.object, // an object to be used as the headers when sending the request for the url. default {}

ttl: PropTypes.number, // the number of seconds each url will stay in the cache. default 2 weeks

useQueryParamsInCacheKey: PropTypes.oneOfType([ // when handling a URL with query params, this indicates how it should be treated:
PropTypes.bool, // if a bool value is given the whole query string will be used / ignored
PropTypes.arrayOf(PropTypes.string) // if an array of strings is given, only these keys will be taken from the query string.
]), // default false
cacheLocation: PropTypes.string, // the path to the root of the cache folder. default the device cache dir

cacheLocation: PropTypes.string, // the path to the root of the cache folder. default the device cache dir

allowSelfSignedSSL: PropTypes.bool, // true to allow self signed SSL URLs to be downloaded. default false
};

Expand Down
4 changes: 2 additions & 2 deletions __tests__/ImageCacheManager-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

jest.mock('react-native-fetch-blob', () => ({default: {fs: {}}}));
jest.mock('rn-fetch-blob', () => ({default: {fs: {}}}));
jest.mock('react-native-clcasher/MemoryCache', () => ({default: {}}));

import ImageCacheManager from '../ImageCacheManager';
Expand Down Expand Up @@ -45,4 +45,4 @@ describe('ImageCacheManager', () => {

});

});
});
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-cached-image",
"version": "1.4.3",
"version": "1.4.5",
"description": "CachedImage component for react-native",
"main": "index.js",
"scripts": {
Expand All @@ -13,7 +13,9 @@
},
"testPathIgnorePatterns": [
"/node_modules/",
"/CachedImageExample/"
"/CachedImageExample/",
"/__tests__/SimpleMemoryCache.js",
"/__tests__/SimpleMemoryFs.js"
],
"modulePathIgnorePatterns": [
"/CachedImageExample/"
Expand Down Expand Up @@ -48,11 +50,11 @@
"typings": "./index.d.ts",
"dependencies": {
"crypto-js": "3.1.9-1",
"lodash": "4.17.4",
"lodash": "4.17.11",
"prop-types": "15.5.10",
"react-native-clcasher": "1.0.0",
"react-native-fetch-blob": "0.10.8",
"url-parse": "1.1.9"
"rn-fetch-blob": "0.10.16",
"url-parse": "1.4.4"
},
"devDependencies": {
"babel-jest": "^21.0.2",
Expand Down
2 changes: 1 addition & 1 deletion utils/fsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const _ = require('lodash');

const RNFetchBlob = require('react-native-fetch-blob').default;
const RNFetchBlob = require('rn-fetch-blob').default;

const {
fs
Expand Down
Loading