New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

react-native-image-color-picker

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-image-color-picker - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

{
"name": "react-native-image-color-picker",
"version": "1.0.3",
"description":
"Image color picker based on image source provided and return image different color palettes or average color palette",
"version": "1.0.4",
"description": "Image color picker based on image source provided and return image different color palettes or average color palette",
"main": "src/index.js",

@@ -10,9 +9,7 @@ "scripts": {

"precommit": "lint-staged && npm test",
"prettify":
"prettier --single-quote --trailing-comma es5 --write 'src/**/*.js'"
"prettify": "prettier --single-quote --trailing-comma es5 --write 'src/**/*.js'"
},
"repository": {
"type": "git",
"url":
"git+https://github.com/pradeep1991singh/react-native-image-color-picker.git"
"url": "git+https://github.com/pradeep1991singh/react-native-image-color-picker.git"
},

@@ -33,2 +30,3 @@ "keywords": [

"dependencies": {
"image-color-picker": "^1.0.0",
"react-native-fetch-blob": "^0.10.8"

@@ -41,3 +39,5 @@ },

],
"setupFiles": ["<rootDir>/__mocks__/setup.js"]
"setupFiles": [
"<rootDir>/__mocks__/setup.js"
]
},

@@ -44,0 +44,0 @@ "devDependencies": {

import React, { Component } from 'react';
import { WebView } from 'react-native';
import { WebView, Platform } from 'react-native'
import RNFetchBlob from 'react-native-fetch-blob';
import RNImageColorPicker from 'image-color-picker'
import { canvasHtml } from './canvas-html';
async function getColor(imagePath) {
return RNImageColorPicker.getColor(imagePath)
}
export default class ImageColorPicker extends Component {

@@ -18,11 +22,28 @@ state = {

try {
await RNFetchBlob.fetch('GET', imageUrl)
.then(res => {
this.setState({ imageBlob: res.base64() });
})
.catch((errorMessage, statusCode) => {
this.props.pickerCallback(errorMessage, statusCode);
const localImage = await RNFetchBlob.config({ fileCache: true }).fetch(
'GET',
imageUrl
)
// if we are on Android, then use native for Android
if (Platform.OS === 'android') {
let colors = [];
const color = await getColor(localImage.path());
color.forEach(c => {
colors.push(c.split('-'));
});
} catch (e) {
this.props.pickerCallback(e);
this.imageColorPickerView.props.onMessage({
promise: JSON.stringify({ 'message': 'imageColorPicker', 'payload': colors })
});
return;
}
const base64EncodedImage = await RNFetchBlob.fs.readFile(
localImage.path(),
'base64'
);
this.setState({ imageBlob: base64EncodedImage });
} catch (error) {
this.props.pickerCallback(error);
}

@@ -36,3 +57,3 @@ };

<WebView
ref="imageColorPickerWebview"
ref={imageColorPickerView => (this.imageColorPickerView = imageColorPickerView)}
source={{ html: canvasHtml(this.state.imageBlob, this.props) }}

@@ -39,0 +60,0 @@ javaScriptEnabled={true}

Sorry, the diff of this file is not supported yet