Skip to content

Commit

Permalink
chore: remove nanoid and react-native-redash to clean up some build i…
Browse files Browse the repository at this point in the history
…ssues (#1046)

* chore: remove nanoid and react-native-redash to clean up some build issues

* chore: put back invariant dependency

Co-authored-by: gorhom <[email protected]>
  • Loading branch information
natew and gorhom authored Sep 9, 2022
1 parent cebae97 commit 8fc11fd
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 38 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
},
"dependencies": {
"@gorhom/portal": "1.0.13",
"invariant": "^2.2.4",
"nanoid": "^3.3.3",
"react-native-redash": "^16.1.1"
"invariant": "^2.2.4"
},
"devDependencies": {
"@commitlint/cli": "^13.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/bottomSheetModal/BottomSheetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import React, {
useState,
} from 'react';
import { Portal, usePortal } from '@gorhom/portal';
import { nanoid } from 'nanoid/non-secure';
import BottomSheet from '../bottomSheet';
import { useBottomSheetModalInternal } from '../../hooks';
import { print } from '../../utilities';
Expand All @@ -18,6 +17,7 @@ import {
} from './constants';
import type { BottomSheetModalMethods, BottomSheetMethods } from '../../types';
import type { BottomSheetModalProps } from './types';
import { id } from '../../utilities/id';

type BottomSheetModal = BottomSheetModalMethods;

Expand Down Expand Up @@ -80,7 +80,7 @@ const BottomSheetModalComponent = forwardRef<
//#endregion

//#region variables
const key = useMemo(() => name || `bottom-sheet-modal-${nanoid()}`, [name]);
const key = useMemo(() => name || `bottom-sheet-modal-${id()}`, [name]);
//#endregion

//#region private methods
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useGestureEventsHandlersDefault.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Keyboard, Platform } from 'react-native';
import { runOnJS, useWorkletCallback } from 'react-native-reanimated';
import { clamp, snapPoint } from 'react-native-redash';
import { useBottomSheetInternal } from './useBottomSheetInternal';
import {
ANIMATION_SOURCE,
Expand All @@ -13,6 +12,8 @@ import type {
GestureEventsHandlersHookType,
GestureEventHandlerCallbackType,
} from '../types';
import { clamp } from '../utilities/clamp';
import { snapPoint } from '../utilities/snapPoint';

type GestureEventContextType = {
initialPosition: number;
Expand Down
8 changes: 8 additions & 0 deletions src/utilities/clamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const clamp = (
value: number,
lowerBound: number,
upperBound: number
) => {
'worklet';
return Math.min(Math.max(lowerBound, value), upperBound);
};
6 changes: 6 additions & 0 deletions src/utilities/id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let current = 0;

export const id = () => {
current = (current + 1) % Number.MAX_SAFE_INTEGER;
return current;
};
11 changes: 11 additions & 0 deletions src/utilities/snapPoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const snapPoint = (
value: number,
velocity: number,
points: ReadonlyArray<number>
): number => {
'worklet';
const point = value + 0.2 * velocity;
const deltas = points.map(p => Math.abs(point - p));
const minDelta = Math.min.apply(null, deltas);
return points.filter(p => Math.abs(point - p) === minDelta)[0];
};
33 changes: 1 addition & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2043,11 +2043,6 @@ abort-controller@^3.0.0:
dependencies:
event-target-shim "^5.0.0"

abs-svg-path@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/abs-svg-path/-/abs-svg-path-0.1.1.tgz#df601c8e8d2ba10d4a76d625e236a9a39c2723bf"
integrity sha1-32Acjo0roQ1KdtYl4japo5wnI78=

absolute-path@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/absolute-path/-/absolute-path-0.0.0.tgz#a78762fbdadfb5297be99b15d35a785b2f095bf7"
Expand Down Expand Up @@ -6296,7 +6291,7 @@ nan@^2.12.1:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==

nanoid@^3.3.1, nanoid@^3.3.3:
nanoid@^3.3.1:
version "3.3.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25"
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
Expand Down Expand Up @@ -6416,13 +6411,6 @@ normalize-path@^3.0.0:
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==

normalize-svg-path@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/normalize-svg-path/-/normalize-svg-path-1.1.0.tgz#0e614eca23c39f0cffe821d6be6cd17e569a766c"
integrity sha512-r9KHKG2UUeB5LoTouwDzBy2VxXlHsiM6fyLQvnJa0S5hrhzqElH/CH7TUGhT1fVvIYBIKf3OpY4YJ4CK+iaqHg==
dependencies:
svg-arc-to-cubic-bezier "^3.0.0"

normalize-url@^4.1.0:
version "4.5.1"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a"
Expand Down Expand Up @@ -6776,11 +6764,6 @@ parse-path@^4.0.0:
qs "^6.9.4"
query-string "^6.13.8"

parse-svg-path@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/parse-svg-path/-/parse-svg-path-0.1.2.tgz#7a7ec0d1eb06fa5325c7d3e009b859a09b5d49eb"
integrity sha1-en7A0esG+lMlx9PgCbhZoJtdSes=

parse-url@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-6.0.0.tgz#f5dd262a7de9ec00914939220410b66cff09107d"
Expand Down Expand Up @@ -7146,15 +7129,6 @@ react-native-reanimated@^2.8.0:
setimmediate "^1.0.5"
string-hash-64 "^1.0.3"

react-native-redash@^16.1.1:
version "16.1.1"
resolved "https://registry.yarnpkg.com/react-native-redash/-/react-native-redash-16.1.1.tgz#784cdf55672043aab9f15ae8c965dcbae8b119ba"
integrity sha512-pD3GMNqRz/5bUnX0ni4MMOBlVwH2dJnd7u6M80VqYGI87IfcuP6Sn1z171r0nUUeYvJ7blJQs0OKKmTsJIbWew==
dependencies:
abs-svg-path "^0.1.1"
normalize-svg-path "^1.0.1"
parse-svg-path "^0.1.2"

react-native@^0.62.2:
version "0.62.3"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.62.3.tgz#9a2e96af3dedd0723c8657831eec4ed3c30f3299"
Expand Down Expand Up @@ -8200,11 +8174,6 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

svg-arc-to-cubic-bezier@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/svg-arc-to-cubic-bezier/-/svg-arc-to-cubic-bezier-3.2.0.tgz#390c450035ae1c4a0104d90650304c3bc814abe6"
integrity sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g==

table@^6.0.9:
version "6.7.1"
resolved "https://registry.yarnpkg.com/table/-/table-6.7.1.tgz#ee05592b7143831a8c94f3cee6aae4c1ccef33e2"
Expand Down

0 comments on commit 8fc11fd

Please sign in to comment.