Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organise Reanimated 1 #1789

Merged
merged 4 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/interpolate.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import interpolate from '../src/derived/interpolate';
import AnimatedValue from '../src/core/AnimatedValue';
import interpolate from '../src/reanimated1/derived/interpolate';
import AnimatedValue from '../src/reanimated1/core/AnimatedValue';

jest.mock('../src/ReanimatedEventEmitter');
jest.mock('../src/ReanimatedModule');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"android/",
"ios/",
"!ios/build/",
"!android/build/",
"RNReanimated.podspec",
"README.md",
"react-native-reanimated.d.ts",
Expand Down
83 changes: 6 additions & 77 deletions src/Animated.js
Original file line number Diff line number Diff line change
@@ -1,99 +1,28 @@
import { Image, ScrollView, Text, View } from 'react-native';
import EasingNode from './Easing';
import AnimatedClock from './core/AnimatedClock';
import AnimatedValue from './core/AnimatedValue';
import AnimatedNode from './core/AnimatedNode';
import AnimatedCode from './core/AnimatedCode';
import * as base from './base';
import * as derived from './derived';
import createAnimatedComponent from './createAnimatedComponent';
import decay from './animations/decay';
import timing from './animations/timing';
import spring from './animations/spring';
import Animation from './animations/Animation';
import {
addWhitelistedNativeProps,
addWhitelistedUIProps,
} from './ConfigHelper';
import backwardCompatibleAnimWrapper from './animations/backwardCompatibleAnimWrapper';
import {
Transition,
Transitioning,
createTransitioningComponent,
} from './Transitioning';
import SpringUtils from './animations/SpringUtils';
import useValue from './useValue';
import * as reanimated2 from './reanimated2';
import * as reanimated1 from './reanimated1';

const decayWrapper = backwardCompatibleAnimWrapper(
decay,
Animation.decayDefaultState
);
const timingWrapper = backwardCompatibleAnimWrapper(
timing,
Animation.timingDefaultState
);
const springWrapper = backwardCompatibleAnimWrapper(
spring,
Animation.springDefaultState
);
const Animated = {
// components
View: createAnimatedComponent(View),
Text: createAnimatedComponent(Text),
Image: createAnimatedComponent(Image),
ScrollView: createAnimatedComponent(ScrollView),
Code: AnimatedCode,
createAnimatedComponent,

// classes
Clock: AnimatedClock,
Value: AnimatedValue,
Node: AnimatedNode,

// operations
...base,
...derived,

// animations
decay: decayWrapper,
timing: timingWrapper,
spring: springWrapper,
SpringUtils,

// configuration
addWhitelistedNativeProps,
addWhitelistedUIProps,

// hooks
useValue,

// reanimated2
// reanimated 1
...reanimated1,
// reanimated 2
...reanimated2,
};

export default Animated;

// operations
export * from './base';
export * from './derived';

export * from './reanimated2';

export {
EasingNode,
Transitioning,
Transition,
createTransitioningComponent,
// classes
AnimatedClock as Clock,
AnimatedValue as Value,
AnimatedNode as Node,
// animations
decayWrapper as decay,
timingWrapper as timing,
springWrapper as spring,
SpringUtils,
// hooks
useValue,
};
export * from './reanimated1';
export default Animated;
8 changes: 4 additions & 4 deletions src/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { findNodeHandle, Platform, StyleSheet } from 'react-native';
import ReanimatedEventEmitter from './ReanimatedEventEmitter';

import AnimatedEvent from './core/AnimatedEvent';
import AnimatedNode from './core/AnimatedNode';
import AnimatedValue from './core/AnimatedValue';
import { createOrReusePropsNode } from './core/AnimatedProps';
import AnimatedEvent from './reanimated1/core/AnimatedEvent';
import AnimatedNode from './reanimated1/core/AnimatedNode';
import AnimatedValue from './reanimated1/core/AnimatedValue';
import { createOrReusePropsNode } from './reanimated1/core/AnimatedProps';
import WorkletEventHandler from './reanimated2/WorkletEventHandler';
import setAndForwardRef from './setAndForwardRef';

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Transitioning.js → src/reanimated1/Transitioning.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { View, findNodeHandle } from 'react-native';
import ReanimatedModule from './ReanimatedModule';
import ReanimatedModule from '../ReanimatedModule';

const TransitioningContext = React.createContext();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import invariant from 'fbjs/lib/invariant';
import ReanimatedEventEmitter from '../ReanimatedEventEmitter';
import ReanimatedEventEmitter from '../../ReanimatedEventEmitter';
import { val } from '../val';
import AnimatedNode from './AnimatedNode';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Platform, findNodeHandle } from 'react-native';
import ReanimatedModule from '../ReanimatedModule';
import ReanimatedModule from '../../ReanimatedModule';

import AnimatedNode from './AnimatedNode';
import InternalAnimatedValue from './AnimatedValue';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReanimatedModule from '../ReanimatedModule';
import ReanimatedModule from '../../ReanimatedModule';
import { Platform } from 'react-native';

const UPDATED_NODES = [];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import interpolate from '../derived/interpolate';
import InternalAnimatedValue from './InternalAnimatedValue';
import { Platform } from 'react-native';
import { evaluateOnce } from '../derived/evaluateOnce';
import ReanimatedModule from '../ReanimatedModule';
import ReanimatedModule from '../../ReanimatedModule';
import { val } from '../val';

// Animated value wrapped with extra methods for omit cycle of dependencies
Expand Down
8 changes: 4 additions & 4 deletions src/core/Core.test.js → src/reanimated1/core/Core.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import Animated from '../Animated';
import Animated from '../../Animated';

import renderer from 'react-test-renderer';

jest.mock('../ReanimatedEventEmitter');
jest.mock('../ReanimatedModule');
jest.mock('../reanimated2/NativeReanimated');
jest.mock('../../ReanimatedEventEmitter');
jest.mock('../../ReanimatedModule');
jest.mock('../../reanimated2/NativeReanimated');

describe('Core Animated components', () => {
xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AnimatedNode from './AnimatedNode';
import { val } from '../val';
import ReanimatedModule from '../ReanimatedModule';
import ReanimatedModule from '../../ReanimatedModule';
import invariant from 'fbjs/lib/invariant';

function sanitizeValue(value) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions src/reanimated1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import EasingNode from './Easing';
import AnimatedClock from './core/AnimatedClock';
import AnimatedValue from './core/AnimatedValue';
import AnimatedNode from './core/AnimatedNode';
import AnimatedCode from './core/AnimatedCode';
import decay from './animations/decay';
import timing from './animations/timing';
import spring from './animations/spring';
import Animation from './animations/Animation';
import {
Transition,
Transitioning,
createTransitioningComponent,
} from './Transitioning';
import SpringUtils from './animations/SpringUtils';
import useValue from './useValue';
import backwardCompatibleAnimWrapper from './animations/backwardCompatibleAnimWrapper';

const decayWrapper = backwardCompatibleAnimWrapper(
decay,
Animation.decayDefaultState
);
const timingWrapper = backwardCompatibleAnimWrapper(
timing,
Animation.timingDefaultState
);
const springWrapper = backwardCompatibleAnimWrapper(
spring,
Animation.springDefaultState
);

// operations
export * from './base';
export * from './derived';
export {
AnimatedCode as Code,
// transitions
EasingNode,
Transitioning,
Transition,
createTransitioningComponent,
// nodes
AnimatedClock as Clock,
AnimatedValue as Value,
AnimatedNode as Node,
// animations
decayWrapper as decay,
timingWrapper as timing,
springWrapper as spring,
SpringUtils,
// hooks
useValue,
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/reanimated2/Colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { Platform } from 'react-native';
import { makeRemote, makeShareable } from './core';
import { interpolate } from './interpolation';
import { Extrapolate } from '../derived';
import { Extrapolate } from '../reanimated1/derived';

// var INTEGER = '[-+]?\\d+';
const NUMBER = '[-+]?\\d*\\.?\\d+';
Expand Down
16 changes: 10 additions & 6 deletions src/reanimated2/Easing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global _WORKLET */
import EasingNode from '../Easing';
import EasingNode from '../reanimated1/Easing';
import { Bezier } from './Bezier';

/**
Expand Down Expand Up @@ -257,21 +257,25 @@ const EasingObject = {

function createChecker(worklet, workletName, prevArgs) {
function checkIfReaOne() {
'worklet'
if (arguments && (!_WORKLET)) {
'worklet';
if (arguments && !_WORKLET) {
for (let i = 0; i < arguments.length; i++) {
const arg = arguments[i];
if (arg && arg.__nodeID) {
console.warn(`Easing was renamed to EasingNode in Reanimated 2. Please use EasingNode instead`);
console.warn(
`Easing was renamed to EasingNode in Reanimated 2. Please use EasingNode instead`
);
if (prevArgs) {
return EasingNode[workletName].apply(undefined, prevArgs).apply(undefined, arguments);
return EasingNode[workletName]
.apply(undefined, prevArgs)
.apply(undefined, arguments);
}
return EasingNode[workletName].apply(undefined, arguments);
}
}
}
const res = worklet.apply(this, arguments);
if ((!_WORKLET) && res && (typeof res === 'function') && res.__worklet) {
if (!_WORKLET && res && typeof res === 'function' && res.__worklet) {
return createChecker(res, workletName, arguments);
}
return res;
Expand Down
10 changes: 6 additions & 4 deletions src/reanimated2/interpolation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import interpolateNode,{
Extrapolate
} from '../derived/interpolate';
import interpolateNode, {
Extrapolate,
} from '../reanimated1/derived/interpolate';

function getVal(config) {
'worklet';
Expand Down Expand Up @@ -114,7 +114,9 @@ function internalInterpolate(x, l, r, ll, rr, type) {
export function interpolate(x, input, output, type) {
'worklet';
if (x && x.__nodeID) {
console.warn(`interpolate() was renamed to interpolateNode() in Reanimated 2. Please use interpolateNode() instead`);
console.warn(
`interpolate() was renamed to interpolateNode() in Reanimated 2. Please use interpolateNode() instead`
);
return interpolateNode.apply(undefined, arguments);
}

Expand Down