Skip to content

Commit

Permalink
fix(plugin): update dependencies
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Jun 10, 2024
1 parent c2f4a60 commit aabeb65
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 83 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ jobs:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm run build
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- name: Test 📱
run: npm test
run: bun run test
- uses: tobua/release-npm-action@v3
with:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
package-lock.json
bun.lockb
dist
ReactigationApp
app/**/*
Expand Down
21 changes: 3 additions & 18 deletions animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ const windowHeight = Dimensions.get('window').height

// Transition finish handler.
const handlerLeft =
(
value: Animated.Value,
done: () => void,
{ duration }: { duration: number },
reverse?: boolean,
) =>
(value: Animated.Value, done: () => void, { duration }: { duration: number }, reverse?: boolean) =>
() => {
Animated.timing(value, {
toValue: reverse ? windowWidth : 0,
Expand Down Expand Up @@ -44,12 +39,7 @@ const none = () => ({
})

const handlerOpacity =
(
value: Animated.Value,
done: () => void,
{ duration }: { duration: number },
reverse?: boolean,
) =>
(value: Animated.Value, done: () => void, { duration }: { duration: number }, reverse?: boolean) =>
() => {
Animated.timing(value, {
toValue: reverse ? 0 : 1,
Expand Down Expand Up @@ -79,12 +69,7 @@ const opacity = (duration = 500) => ({
})

const handlerTop =
(
value: Animated.Value,
done: () => void,
{ duration }: { duration: number },
reverse?: boolean,
) =>
(value: Animated.Value, done: () => void, { duration }: { duration: number }, reverse?: boolean) =>
() => {
Animated.timing(value, {
toValue: reverse ? windowHeight : 0,
Expand Down
28 changes: 6 additions & 22 deletions index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import React, { useState, useEffect, cloneElement } from 'react'
import { Animated, View, BackHandler, TouchableOpacity } from 'react-native'
import { styles } from './styles'
import startTransition, {
initialPosition,
connect,
isTransitioning,
isTransitionValid,
} from './transition'
import startTransition, { initialPosition, connect, isTransitioning, isTransitionValid } from './transition'
import { CustomTransition } from './animations'
import { Transition, Screen, State, TransitionInput } from './types'

Expand All @@ -31,9 +26,7 @@ export const useCurrentScreen = () => {

// Clear up old listeners.
return () => {
const index = currentScreenHookListeners.findIndex(
(listener) => listener === setCurrentScreen,
)
const index = currentScreenHookListeners.findIndex((listener) => listener === setCurrentScreen)

if (index !== -1) {
currentScreenHookListeners.splice(index, 1)
Expand All @@ -57,9 +50,7 @@ export const register = (
const { transition = Transition.regular, background = 'white', initial } = configuration
const screen: Screen = { Component, transition, background, name }
if (!name) {
return console.error(
'Reactigation: Trying to register a Component without a name as the second argument.',
)
return console.error('Reactigation: Trying to register a Component without a name as the second argument.')
}
if (!isTransitionValid(transition, 'register')) {
return
Expand All @@ -76,15 +67,11 @@ export const register = (

export const initial = (name: string) => {
if (!screens[name]) {
return console.warn(
`Reactigation: Trying to set initial screen "${name}" which hasn't been registered yet.`,
)
return console.warn(`Reactigation: Trying to set initial screen "${name}" which hasn't been registered yet.`)
}

if (history.length === 0) {
return console.error(
'Reactigation: Trying to set initial screen before any screens have been registered.',
)
return console.error('Reactigation: Trying to set initial screen before any screens have been registered.')
}

history[0] = screens[name]
Expand Down Expand Up @@ -166,10 +153,7 @@ const renderBottom = ({ Bottom }: State) => {
})

return (
<Animated.View
key={`${Bottom.name}_bottom`}
style={[styles.back, { backgroundColor: Bottom.background }]}
>
<Animated.View key={`${Bottom.name}_bottom`} style={[styles.back, { backgroundColor: Bottom.background }]}>
{BottomWithProps}
</Animated.View>
)
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@
"react-native": ">= 0.70"
},
"devDependencies": {
"@react-native-community/cli": "^13.0.0",
"@react-native/babel-preset": "^0.74.0",
"@react-native/eslint-config": "^0.74.0",
"@react-native/typescript-config": "^0.74.0",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.4",
"@types/react": "^18.2.43",
"@types/react-native": "^0.72.8",
"@types/react-test-renderer": "^18.0.7",
"@react-native-community/cli": "^13.6.9",
"@react-native/babel-preset": "^0.74.84",
"@react-native/eslint-config": "^0.74.84",
"@react-native/typescript-config": "^0.74.84",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-native": "^0.73.0",
"@types/react-test-renderer": "^18.3.0",
"babel-jest": "^29.7.0",
"cpx": "^1.5.0",
"esbuild": "^0.19.9",
"eslint": "^8.55.0",
"esbuild": "^0.21.5",
"eslint": "8.57.0",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.1.1",
"react": "^18.2.0",
"react-native": "^0.73.0",
"react-test-renderer": "^18.2.0",
"typescript": "^5.3.3"
"prettier": "^3.3.1",
"react": "^18.3.1",
"react-native": "^0.74.2",
"react-test-renderer": "^18.3.1",
"typescript": "^5.4.5"
},
"files": [
"dist"
Expand All @@ -77,7 +77,7 @@
"prettier": {
"semi": false,
"singleQuote": true,
"printWidth": 100
"printWidth": 120
},
"jest": {
"preset": "react-native",
Expand Down
6 changes: 1 addition & 5 deletions test/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,7 @@ test('Initially shown screen can be configured.', () => {
})

test('Initially shown screen can be configured though register.', () => {
const names = [
{ name: 'FirstScreen' },
{ name: 'SecondScreen', options: { initial: true } },
{ name: 'ThirdScreen' },
]
const names = [{ name: 'FirstScreen' }, { name: 'SecondScreen', options: { initial: true } }, { name: 'ThirdScreen' }]
const input = setupScreens(names)

const { screens } = render(<Navigation headless={false} />)
Expand Down
4 changes: 1 addition & 3 deletions test/utils/setup-screens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import { register } from 'reactigation'
import createTestScreen from '../components/Screen'

export default (
screens: (string | { name: string; options?: { initial?: boolean; background?: string } })[],
) => {
export default (screens: (string | { name: string; options?: { initial?: boolean; background?: string } })[]) => {
return screens.map((screen) => {
let name
let options = {} as any
Expand Down
9 changes: 2 additions & 7 deletions transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ let afterRender = () => {}
let options = { headless: false }

// Connects to Reactigation Component's setState.
export const connect = (
current: { setState: (state: State) => void; state: State },
headless: boolean,
) => {
export const connect = (current: { setState: (state: State) => void; state: State }, headless: boolean) => {
state = current.state
setState = current.setState
options.headless = headless
Expand Down Expand Up @@ -62,9 +59,7 @@ export default (
}

// After state is set and new screens rendered, calling this handler starts the animation.
afterRender = options.headless
? () => {}
: transition.animation(state, done, reverse) || (() => {})
afterRender = options.headless ? () => {} : transition.animation(state, done, reverse) || (() => {})

// Skip animation.
if (options.headless) {
Expand Down
6 changes: 1 addition & 5 deletions types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { Animated } from 'react-native'

export type AnimationHandler = (
state: State,
done: () => void,
reverse?: boolean,
) => (() => void) | null
export type AnimationHandler = (state: State, done: () => void, reverse?: boolean) => (() => void) | null

export type Animation = {
backdrop?: boolean
Expand Down

0 comments on commit aabeb65

Please sign in to comment.