react-native-img-cache
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -0,1 +1,9 @@ | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
import React, { Component } from "react"; | ||
@@ -5,4 +13,4 @@ import { Image, Platform } from "react-native"; | ||
const SHA1 = require("crypto-js/sha1"); | ||
const dirs = RNFetchBlob.fs.dirs; | ||
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); | ||
const BASE_DIR = RNFetchBlob.fs.dirs.CacheDir + "/react-native-img-cache"; | ||
const FILE_PREFIX = Platform.OS === "ios" ? "" : "file://"; | ||
@@ -19,6 +27,6 @@ export class ImageCache { | ||
if (immutable === true) { | ||
return dirs.CacheDir + "/" + SHA1(uri) + ext; | ||
return BASE_DIR + "/" + SHA1(uri) + ext; | ||
} | ||
else { | ||
return dirs.CacheDir + "/" + s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4() + ext; | ||
return BASE_DIR + "/" + s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4() + ext; | ||
} | ||
@@ -138,7 +146,14 @@ } | ||
render() { | ||
const { style, blurRadius } = this.props; | ||
const source = this.state.path ? { uri: FILE_PREFIX + this.state.path } : {}; | ||
return React.createElement(Image, { style: style, blurRadius: blurRadius, source: source }, this.props.children); | ||
const props = {}; | ||
Object.keys(this.props).forEach(prop => { | ||
if (prop === "source") { | ||
props.source = this.state.path ? { uri: FILE_PREFIX + this.state.path } : {}; | ||
} | ||
else { | ||
props[prop] = this.props[prop]; | ||
} | ||
}); | ||
return React.createElement(Image, __assign({}, props), this.props.children); | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-native-img-cache", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "CachedImage component for React native", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
27189
191