Skip to content

Commit

Permalink
Merge pull request #81 from alabsi91/fix-commonjs-compilation-conflict
Browse files Browse the repository at this point in the history
Fix JS Compilation Conflict with Reanimated Babel Plugin
  • Loading branch information
alabsi91 authored May 28, 2024
2 parents 74f66fa + f92d1be commit 75c43c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reanimated-color-picker",
"version": "3.0.3",
"version": "3.0.4",
"description": "A Pure JavaScript Color Picker for React Native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
4 changes: 2 additions & 2 deletions src/colorKit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
// this transformation can lead to a slow initial execution.
// To address this issue, I consolidated them into a single worklet function.

export function colorKitUI() {
export const colorKitUI = () => {
'worklet';

const NAMED_COLORS = {
Expand Down Expand Up @@ -2066,7 +2066,7 @@ export function colorKitUI() {
randomHwbColor,
adjustContrast,
};
}
};

type ColorKit = ReturnType<typeof colorKitUI> & {
/** - Initiates the asynchronous execution of a workletized colorKit function on the UI thread. */
Expand Down
8 changes: 4 additions & 4 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export function getStyle<T extends keyof ViewStyle>(style: StyleProp<ViewStyle>,
}

/** - Clamp a number value between `0` and a max value */
export function clamp(v: number, max: number) {
export const clamp = (v: number, max: number) => {
'worklet';
return Math.min(Math.max(v, 0), max);
}
};

/** - Convert `HSV` color to an `HSLA` string representation */
export function HSVA2HSLA_string(h: number, s: number, v: number, a = 1) {
export const HSVA2HSLA_string = (h: number, s: number, v: number, a = 1) => {
'worklet';

s = s / 100;
Expand All @@ -30,7 +30,7 @@ export function HSVA2HSLA_string(h: number, s: number, v: number, a = 1) {
sln = l !== 0 && l !== 1 ? sl / (l < 0.5 ? l * 2 : 2 - l * 2) : sl;

return `hsla(${h}, ${sln * 100}%, ${l * 100}%, ${a})`;
}
};

/** - Render children only if the `render` property is `true` */
export function ConditionalRendering(props: { children: React.ReactNode; if: boolean }) {
Expand Down

0 comments on commit 75c43c8

Please sign in to comment.