From 2e433eb9be978b581f5f0fae3a24f41f580dfaad Mon Sep 17 00:00:00 2001 From: Seppe Rousseau Date: Thu, 6 Jun 2019 14:01:48 +0200 Subject: [PATCH 1/4] Update Palette.m (Wasn't thread safe) https://github.com/tangdiforx/iOSPalette/pull/12 --- ios/palette/Palette.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/palette/Palette.m b/ios/palette/Palette.m index dd38d87..6311de1 100755 --- a/ios/palette/Palette.m +++ b/ios/palette/Palette.m @@ -366,7 +366,7 @@ - (void)startToAnalyzeForTargetMode:(PaletteTargetMode)mode withCallBack:(GetCol - (void)startToAnalyzeImage{ - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + @synchronized (self) { [self clearHistArray]; @@ -458,7 +458,7 @@ - (void)startToAnalyzeImage{ [self findMaxPopulation]; [self getSwatchForTarget]; - }); + }; } From 89cc3006f2e87c8248f0279b2109bba9f2004f55 Mon Sep 17 00:00:00 2001 From: Seppe Rousseau Date: Thu, 6 Jun 2019 14:02:57 +0200 Subject: [PATCH 2/4] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d14f7b5..abc9950 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-native-palette-full", - "version": "1.0.6", + "version": "1.0.7", "description": "", "main": "index.js", "repository": { From 7b9e89851983eebab37bb19f67f7c2c5bab74300 Mon Sep 17 00:00:00 2001 From: Seppe Rousseau Date: Thu, 6 Jun 2019 14:37:06 +0200 Subject: [PATCH 3/4] Convert to Typescript --- index.js | 27 --------------------------- index.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +-- 3 files changed, 44 insertions(+), 29 deletions(-) delete mode 100644 index.js create mode 100644 index.ts diff --git a/index.js b/index.js deleted file mode 100644 index 3e14d27..0000000 --- a/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import { NativeModules } from "react-native"; - -const { RNPalette } = NativeModules; - -const TAG = "[Palette]"; -export default class Palette { - static getNamedSwatchesFromUrl(url) { - __DEV__ && console.debug(TAG, "getNamedSwatchesFromUrl", url); - return RNPalette.getNamedSwatchesFromUrl(url); - } - - static getAllSwatchesFromUrl(url) { - __DEV__ && console.debug(TAG, "getAllSwatchesFromUrl", url); - return RNPalette.getAllSwatchesFromUrl(url); - } - - static getNamedSwatches(path) { - __DEV__ && console.debug(TAG, "getNamedSwatches", path); - return RNPalette.getNamedSwatches(path); - } - - static getAllSwatches(path) { - __DEV__ && console.debug(TAG, "getAllSwatches", path); - return RNPalette.getAllSwatches(path); - } -} - diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..d07012a --- /dev/null +++ b/index.ts @@ -0,0 +1,43 @@ +import { NativeModules } from 'react-native'; + +const { RNPalette } = NativeModules; + +export enum ISwatchType { + vibrant = 'Vibrant', + vibrantDark = 'Vibrant Dark', + vibrantLight = 'Vibrant Light', + muted = 'Video', + mutedDark = 'Muted Dark', + mutedLight = 'Muted Light', +} + +export interface ISwatch { + color: string; +} + +export interface IPalette { + [key: string]: ISwatch; +} + +const TAG = '[Palette]'; +export default class Palette { + static getNamedSwatchesFromUrl(url: string): IPalette { + __DEV__ && console.debug(TAG, 'getNamedSwatchesFromUrl', url); + return RNPalette.getNamedSwatchesFromUrl(url); + } + + static getAllSwatchesFromUrl(url: string): ISwatch[] { + __DEV__ && console.debug(TAG, 'getAllSwatchesFromUrl', url); + return RNPalette.getAllSwatchesFromUrl(url); + } + + static getNamedSwatches(path: string): IPalette { + __DEV__ && console.debug(TAG, 'getNamedSwatches', path); + return RNPalette.getNamedSwatches(path); + } + + static getAllSwatches(path: string): ISwatch[] { + __DEV__ && console.debug(TAG, 'getAllSwatches', path); + return RNPalette.getAllSwatches(path); + } +} diff --git a/package.json b/package.json index abc9950..81158fb 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,8 @@ - { "name": "react-native-palette-full", "version": "1.0.7", "description": "", - "main": "index.js", + "main": "index.ts", "repository": { "type": "git", "url": "https://github.com/jerson/react-native-palette-full" From b0de8c8c38a6e8230360c3b7d63eae31341f0ca2 Mon Sep 17 00:00:00 2001 From: Seppe Rousseau Date: Thu, 6 Jun 2019 14:43:07 +0200 Subject: [PATCH 4/4] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 81158fb..a9ab031 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-palette-full", - "version": "1.0.7", + "version": "1.0.8", "description": "", "main": "index.ts", "repository": {