react-native-reanimated 1.13.3 → 1.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,8 +17,10 @@ buildscript {
17
17
  }
18
18
  }
19
19
 
20
- apply plugin: 'com.android.library'
21
- apply plugin: 'maven'
20
+ plugins {
21
+ id('com.android.library')
22
+ id('maven-publish')
23
+ }
22
24
 
23
25
  android {
24
26
  compileSdkVersion safeExtGet('compileSdkVersion', 28)
@@ -54,34 +56,6 @@ dependencies {
54
56
  implementation "androidx.transition:transition:1.1.0"
55
57
  }
56
58
 
57
- def configureReactNativePom(def pom) {
58
- def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
59
-
60
- pom.project {
61
- name packageJson.title
62
- artifactId packageJson.name
63
- version = packageJson.version
64
- group = "com.swmansion.reanimated"
65
- description packageJson.description
66
- url packageJson.repository.baseUrl
67
-
68
- licenses {
69
- license {
70
- name packageJson.license
71
- url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
72
- distribution 'repo'
73
- }
74
- }
75
-
76
- developers {
77
- developer {
78
- id packageJson.author.username
79
- name packageJson.author.name
80
- }
81
- }
82
- }
83
- }
84
-
85
59
  afterEvaluate { project ->
86
60
 
87
61
  task androidJavadoc(type: Javadoc) {
@@ -92,12 +66,12 @@ afterEvaluate { project ->
92
66
  }
93
67
 
94
68
  task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
95
- classifier = 'javadoc'
69
+ archiveClassifier = 'javadoc'
96
70
  from androidJavadoc.destinationDir
97
71
  }
98
72
 
99
73
  task androidSourcesJar(type: Jar) {
100
- classifier = 'sources'
74
+ archiveClassifier = 'sources'
101
75
  from android.sourceSets.main.java.srcDirs
102
76
  include '**/*.java'
103
77
  }
@@ -121,13 +95,11 @@ afterEvaluate { project ->
121
95
  archives androidJavadocJar
122
96
  }
123
97
 
124
- task installArchives(type: Upload) {
125
- configuration = configurations.archives
126
- repositories.mavenDeployer {
127
- // Deploy to react-native-event-bridge/maven, ready to publish to npm
128
- repository url: "file://${projectDir}/../android/maven"
129
-
130
- configureReactNativePom pom
98
+ publishing {
99
+ publications {
100
+ maven(MavenPublication) {
101
+ artifact androidSourcesJar
102
+ }
131
103
  }
132
104
  }
133
105
  }
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+
3
+ var _Animated = _interopRequireWildcard(require("./Animated"));
4
+
5
+ var _ReanimatedModule = _interopRequireDefault(require("./ReanimatedModule"));
6
+
7
+ var _react = _interopRequireDefault(require("react"));
8
+
9
+ var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
14
+
15
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+
17
+ jest.mock('./ReanimatedEventEmitter');
18
+ jest.mock('./ReanimatedModule');
19
+ jest.mock('./derived/evaluateOnce');
20
+ jest.mock('./core/AnimatedProps');
21
+ const {
22
+ Value,
23
+ timing,
24
+ spring,
25
+ decay
26
+ } = _Animated.default;
27
+ describe('Reanimated backward compatible API', () => {
28
+ beforeEach(() => {
29
+ let numberOfNodes = 0;
30
+
31
+ _ReanimatedModule.default.createNode = () => numberOfNodes++;
32
+
33
+ _ReanimatedModule.default.dropNode = () => numberOfNodes--;
34
+
35
+ _ReanimatedModule.default.getNumberOfNodes = () => numberOfNodes;
36
+ });
37
+
38
+ const checkIfNodesGetDetachedCorrectly = animation => {
39
+ class TestComponent extends _react.default.Component {
40
+ constructor(props) {
41
+ super(props);
42
+ this.transX = new Value(0);
43
+ this.anim = animation.node(this.transX, animation.config);
44
+ }
45
+
46
+ start(method) {
47
+ this.anim.start(method);
48
+ }
49
+
50
+ stop(res) {
51
+ this.anim.__stopImmediately_testOnly(res);
52
+ }
53
+
54
+ render() {
55
+ return /*#__PURE__*/_react.default.createElement(_Animated.default.View, {
56
+ style: {
57
+ transform: [{
58
+ translateX: this.transX
59
+ }]
60
+ }
61
+ });
62
+ }
63
+
64
+ }
65
+
66
+ const ref = _react.default.createRef();
67
+
68
+ let result;
69
+
70
+ const resMethod = ({
71
+ finished
72
+ }) => result = finished;
73
+
74
+ const initial = _ReanimatedModule.default.getNumberOfNodes();
75
+
76
+ const wrapper = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(TestComponent, {
77
+ ref: ref
78
+ }));
79
+
80
+ const before = _ReanimatedModule.default.getNumberOfNodes();
81
+
82
+ ref.current.start(resMethod);
83
+
84
+ const during = _ReanimatedModule.default.getNumberOfNodes();
85
+
86
+ ref.current.stop(true);
87
+
88
+ const after = _ReanimatedModule.default.getNumberOfNodes();
89
+
90
+ wrapper.unmount();
91
+
92
+ const final = _ReanimatedModule.default.getNumberOfNodes();
93
+
94
+ return result && initial === final && after === before && during > after && initial === 0 && before === 4;
95
+ };
96
+
97
+ it('fails if timing does not attach nodes correctly', () => {
98
+ expect(checkIfNodesGetDetachedCorrectly({
99
+ node: timing,
100
+ name: 'timing',
101
+ config: {
102
+ duration: 5000,
103
+ toValue: 120,
104
+ easing: _Animated.Easing.inOut(_Animated.Easing.ease)
105
+ }
106
+ })).toBeTruthy();
107
+ });
108
+ it('fails if decay does not attach nodes correctly', () => {
109
+ expect(checkIfNodesGetDetachedCorrectly({
110
+ node: decay,
111
+ name: 'decay',
112
+ config: {
113
+ deceleration: 0.997
114
+ }
115
+ })).toBeTruthy();
116
+ });
117
+ it('fails if spring does not attach nodes correctly', () => {
118
+ expect(checkIfNodesGetDetachedCorrectly({
119
+ node: spring,
120
+ name: 'spring',
121
+ config: {
122
+ toValue: 0,
123
+ damping: 7,
124
+ mass: 1,
125
+ stiffness: 121.6,
126
+ overshootClamping: false,
127
+ restSpeedThreshold: 0.001,
128
+ restDisplacementThreshold: 0.001
129
+ }
130
+ })).toBeTruthy();
131
+ });
132
+ it('fails if animation related nodes are still attached after detaching of value with two animations triggered', () => {
133
+ const {
134
+ timing,
135
+ Value
136
+ } = _Animated.default;
137
+
138
+ class TestComponent extends _react.default.Component {
139
+ constructor(props) {
140
+ super(props);
141
+ this.transX = new Value(0);
142
+ const config = {
143
+ duration: 5000,
144
+ toValue: -120,
145
+ easing: _Animated.Easing.inOut(_Animated.Easing.ease)
146
+ };
147
+ this.anim = timing(this.transX, config);
148
+ this.anim2 = timing(this.transX, config);
149
+ }
150
+
151
+ start1(method) {
152
+ this.anim.start(method);
153
+ }
154
+
155
+ start2(method) {
156
+ this.anim2.start(method);
157
+ }
158
+
159
+ render() {
160
+ return /*#__PURE__*/_react.default.createElement(_Animated.default.View, {
161
+ style: {
162
+ transform: [{
163
+ translateX: this.transX
164
+ }]
165
+ }
166
+ });
167
+ }
168
+
169
+ }
170
+
171
+ const ref = _react.default.createRef();
172
+
173
+ const wrapper = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(TestComponent, {
174
+ ref: ref
175
+ }));
176
+
177
+ let result = true;
178
+
179
+ const resMethod = ({
180
+ finished
181
+ }) => result = finished;
182
+
183
+ ref.current.start1(resMethod);
184
+ ref.current.start2(resMethod);
185
+ expect(result).toBeFalsy();
186
+ result = true;
187
+
188
+ const numberOfNodesBeforeUnmounting = _ReanimatedModule.default.getNumberOfNodes();
189
+
190
+ wrapper.unmount();
191
+ expect(result).toBeFalsy();
192
+
193
+ const numberOfNodesAfterUnmounting = _ReanimatedModule.default.getNumberOfNodes();
194
+
195
+ const pass = numberOfNodesAfterUnmounting === 0 && numberOfNodesBeforeUnmounting > 0;
196
+ expect(pass).toBeTruthy();
197
+ });
198
+ it('fails if animation related nodes are detached if there are two children and only one detach', () => {
199
+ const {
200
+ timing,
201
+ Value
202
+ } = _Animated.default;
203
+ const transX = new Value(0);
204
+
205
+ const wrapper1 = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_Animated.default.View, {
206
+ style: {
207
+ transform: [{
208
+ translateX: transX
209
+ }]
210
+ }
211
+ }));
212
+
213
+ const wrapper2 = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_Animated.default.View, {
214
+ style: {
215
+ transform: [{
216
+ translateX: transX
217
+ }]
218
+ }
219
+ }));
220
+
221
+ const config = {
222
+ duration: 5000,
223
+ toValue: -120,
224
+ easing: _Animated.Easing.inOut(_Animated.Easing.ease)
225
+ };
226
+ const anim = timing(transX, config);
227
+ anim.start();
228
+
229
+ const numberOfNodesBeforeDetach = _ReanimatedModule.default.getNumberOfNodes();
230
+
231
+ wrapper1.unmount();
232
+
233
+ const numberOfNodesAfterDetach = _ReanimatedModule.default.getNumberOfNodes();
234
+
235
+ const result = // 3 means AnimatedProps, AnimatedStyle and AnimatedTransform
236
+ // which are nodes not related to animation and has to be detached
237
+ numberOfNodesBeforeDetach - 3 === numberOfNodesAfterDetach && numberOfNodesAfterDetach > 3;
238
+ expect(result).toBeTruthy();
239
+ wrapper2.unmount();
240
+ expect(_ReanimatedModule.default.getNumberOfNodes() === 0).toBeTruthy();
241
+ });
242
+ it('fails if animation attaches some node without view related', () => {
243
+ const {
244
+ timing,
245
+ Value
246
+ } = _Animated.default;
247
+ const transX = new Value(0);
248
+ const config = {
249
+ duration: 5000,
250
+ toValue: -120,
251
+ easing: _Animated.Easing.inOut(_Animated.Easing.ease)
252
+ };
253
+ const anim = timing(transX, config);
254
+ anim.start();
255
+ expect(_ReanimatedModule.default.getNumberOfNodes()).toBe(0);
256
+ });
257
+ });
258
+ //# sourceMappingURL=Animated.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Animated.test.js"],"names":["jest","mock","Value","timing","spring","decay","Animated","describe","beforeEach","numberOfNodes","ReanimatedModule","createNode","dropNode","getNumberOfNodes","checkIfNodesGetDetachedCorrectly","animation","TestComponent","React","Component","constructor","props","transX","anim","node","config","start","method","stop","res","__stopImmediately_testOnly","render","transform","translateX","ref","createRef","result","resMethod","finished","initial","wrapper","renderer","create","before","current","during","after","unmount","final","it","expect","name","duration","toValue","easing","Easing","inOut","ease","toBeTruthy","deceleration","damping","mass","stiffness","overshootClamping","restSpeedThreshold","restDisplacementThreshold","anim2","start1","start2","toBeFalsy","numberOfNodesBeforeUnmounting","numberOfNodesAfterUnmounting","pass","wrapper1","wrapper2","numberOfNodesBeforeDetach","numberOfNodesAfterDetach","toBe"],"mappings":";;AAAA;;AACA;;AACA;;AAEA;;;;;;;;AAEAA,IAAI,CAACC,IAAL,CAAU,0BAAV;AACAD,IAAI,CAACC,IAAL,CAAU,oBAAV;AACAD,IAAI,CAACC,IAAL,CAAU,wBAAV;AACAD,IAAI,CAACC,IAAL,CAAU,sBAAV;AAEA,MAAM;AAAEC,EAAAA,KAAF;AAASC,EAAAA,MAAT;AAAiBC,EAAAA,MAAjB;AAAyBC,EAAAA;AAAzB,IAAmCC,iBAAzC;AACAC,QAAQ,CAAC,oCAAD,EAAuC,MAAM;AACnDC,EAAAA,UAAU,CAAC,MAAM;AACf,QAAIC,aAAa,GAAG,CAApB;;AACAC,8BAAiBC,UAAjB,GAA8B,MAAMF,aAAa,EAAjD;;AACAC,8BAAiBE,QAAjB,GAA4B,MAAMH,aAAa,EAA/C;;AACAC,8BAAiBG,gBAAjB,GAAoC,MAAMJ,aAA1C;AACD,GALS,CAAV;;AAOA,QAAMK,gCAAgC,GAAGC,SAAS,IAAI;AACpD,UAA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G,MAAT,CAAnB;AACAF,IAAAA,IAAI,CAACG,KAAL;AACAwB,IAAAA,MAAM,CAACvC,0BAAiBG,gBAAjB,EAAD,CAAN,CAA4C+D,IAA5C,CAAiD,CAAjD;AACD,GAZC,CAAF;AAaD,CAjMO,CAAR","sourcesContent":["import Animated, { Easing } from './Animated';\nimport ReanimatedModule from './ReanimatedModule';\nimport React from 'react';\n\nimport renderer from 'react-test-renderer';\n\njest.mock('./ReanimatedEventEmitter');\njest.mock('./ReanimatedModule');\njest.mock('./derived/evaluateOnce');\njest.mock('./core/AnimatedProps');\n\nconst { Value, timing, spring, decay } = Animated;\ndescribe('Reanimated backward compatible API', () => {\n beforeEach(() => {\n let numberOfNodes = 0;\n ReanimatedModule.createNode = () => numberOfNodes++;\n ReanimatedModule.dropNode = () => numberOfNodes--;\n ReanimatedModule.getNumberOfNodes = () => numberOfNodes;\n });\n\n const checkIfNodesGetDetachedCorrectly = animation => {\n class TestComponent extends React.Component {\n constructor(props) {\n super(props);\n this.transX = new Value(0);\n this.anim = animation.node(this.transX, animation.config);\n }\n\n start(method) {\n this.anim.start(method);\n }\n\n stop(res) {\n this.anim.__stopImmediately_testOnly(res);\n }\n\n render() {\n return (\n <Animated.View style={{ transform: [{ translateX: this.transX }] }} />\n );\n }\n }\n const ref = React.createRef();\n let result;\n const resMethod = ({ finished }) => (result = finished);\n const initial = ReanimatedModule.getNumberOfNodes();\n const wrapper = renderer.create(<TestComponent ref={ref} />);\n const before = ReanimatedModule.getNumberOfNodes();\n ref.current.start(resMethod);\n const during = ReanimatedModule.getNumberOfNodes();\n ref.current.stop(true);\n const after = ReanimatedModule.getNumberOfNodes();\n wrapper.unmount();\n const final = ReanimatedModule.getNumberOfNodes();\n\n return (\n result &&\n initial === final &&\n after === before &&\n during > after &&\n initial === 0 &&\n before === 4\n );\n };\n\n it('fails if timing does not attach nodes correctly', () => {\n expect(\n checkIfNodesGetDetachedCorrectly({\n node: timing,\n name: 'timing',\n config: {\n duration: 5000,\n toValue: 120,\n easing: Easing.inOut(Easing.ease),\n },\n })\n ).toBeTruthy();\n });\n\n it('fails if decay does not attach nodes correctly', () => {\n expect(\n checkIfNodesGetDetachedCorrectly({\n node: decay,\n name: 'decay',\n config: {\n deceleration: 0.997,\n },\n })\n ).toBeTruthy();\n });\n\n it('fails if spring does not attach nodes correctly', () => {\n expect(\n checkIfNodesGetDetachedCorrectly({\n node: spring,\n name: 'spring',\n config: {\n toValue: 0,\n damping: 7,\n mass: 1,\n stiffness: 121.6,\n overshootClamping: false,\n restSpeedThreshold: 0.001,\n restDisplacementThreshold: 0.001,\n },\n })\n ).toBeTruthy();\n });\n\n it('fails if animation related nodes are still attached after detaching of value with two animations triggered', () => {\n const { timing, Value } = Animated;\n class TestComponent extends React.Component {\n constructor(props) {\n super(props);\n this.transX = new Value(0);\n const config = {\n duration: 5000,\n toValue: -120,\n easing: Easing.inOut(Easing.ease),\n };\n this.anim = timing(this.transX, config);\n this.anim2 = timing(this.transX, config);\n }\n\n start1(method) {\n this.anim.start(method);\n }\n\n start2(method) {\n this.anim2.start(method);\n }\n\n render() {\n return (\n <Animated.View style={{ transform: [{ translateX: this.transX }] }} />\n );\n }\n }\n const ref = React.createRef();\n const wrapper = renderer.create(<TestComponent ref={ref} />);\n let result = true;\n const resMethod = ({ finished }) => (result = finished);\n ref.current.start1(resMethod);\n ref.current.start2(resMethod);\n expect(result).toBeFalsy();\n result = true;\n const numberOfNodesBeforeUnmounting = ReanimatedModule.getNumberOfNodes();\n wrapper.unmount();\n expect(result).toBeFalsy();\n const numberOfNodesAfterUnmounting = ReanimatedModule.getNumberOfNodes();\n const pass =\n numberOfNodesAfterUnmounting === 0 && numberOfNodesBeforeUnmounting > 0;\n expect(pass).toBeTruthy();\n });\n\n it('fails if animation related nodes are detached if there are two children and only one detach', () => {\n const { timing, Value } = Animated;\n const transX = new Value(0);\n const wrapper1 = renderer.create(\n <Animated.View\n style={{\n transform: [{ translateX: transX }],\n }}\n />\n );\n const wrapper2 = renderer.create(\n <Animated.View\n style={{\n transform: [{ translateX: transX }],\n }}\n />\n );\n const config = {\n duration: 5000,\n toValue: -120,\n easing: Easing.inOut(Easing.ease),\n };\n const anim = timing(transX, config);\n anim.start();\n const numberOfNodesBeforeDetach = ReanimatedModule.getNumberOfNodes();\n wrapper1.unmount();\n const numberOfNodesAfterDetach = ReanimatedModule.getNumberOfNodes();\n const result =\n // 3 means AnimatedProps, AnimatedStyle and AnimatedTransform\n // which are nodes not related to animation and has to be detached\n numberOfNodesBeforeDetach - 3 === numberOfNodesAfterDetach &&\n numberOfNodesAfterDetach > 3;\n expect(result).toBeTruthy();\n wrapper2.unmount();\n expect(ReanimatedModule.getNumberOfNodes() === 0).toBeTruthy();\n });\n\n it('fails if animation attaches some node without view related', () => {\n const { timing, Value } = Animated;\n const transX = new Value(0);\n\n const config = {\n duration: 5000,\n toValue: -120,\n easing: Easing.inOut(Easing.ease),\n };\n const anim = timing(transX, config);\n anim.start();\n expect(ReanimatedModule.getNumberOfNodes()).toBe(0);\n });\n});\n"]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _Animated = _interopRequireDefault(require("../Animated"));
6
+
7
+ var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ jest.mock('../ReanimatedEventEmitter');
12
+ jest.mock('../ReanimatedModule');
13
+ describe('Core Animated components', () => {
14
+ xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
15
+ console.error = jest.fn();
16
+ expect(() => _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_Animated.default.Code, {
17
+ exec: "not a node"
18
+ }))).toThrowError("<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.");
19
+ });
20
+ xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
21
+ console.error = jest.fn();
22
+ expect(() => _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_Animated.default.Code, null, "not a node"))).toThrowError("<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.");
23
+ });
24
+ });
25
+ //# sourceMappingURL=Core.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Core.test.js"],"names":["jest","mock","describe","xit","console","error","fn","expect","renderer","create","toThrowError"],"mappings":";;AAAA;;AACA;;AAEA;;;;AAEAA,IAAI,CAACC,IAAL,CAAU,2BAAV;AACAD,IAAI,CAACC,IAAL,CAAU,qBAAV;AAEAC,QAAQ,CAAC,0BAAD,EAA6B,MAAM;AACzCC,EAAAA,GAAG,CAAC,2GAAD,EAA8G,MAAM;AACrHC,IAAAA,OAAO,CAACC,KAAR,GAAgBL,IAAI,CAACM,EAAL,EAAhB;AAEAC,IAAAA,MAAM,CAAC,MACLC,2BAASC,MAAT,eAAgB,6BAAC,iBAAD,CAAU,IAAV;AAAe,MAAA,IAAI,EAAC;AAApB,MAAhB,CADI,CAAN,CAEEC,YAFF,CAGE,wHAHF;AAKD,GARE,CAAH;AAUAP,EAAAA,GAAG,CAAC,0GAAD,EAA6G,MAAM;AACpHC,IAAAA,OAAO,CAACC,KAAR,GAAgBL,IAAI,CAACM,EAAL,EAAhB;AAEAC,IAAAA,MAAM,CAAC,MACLC,2BAASC,MAAT,eAAgB,6BAAC,iBAAD,CAAU,IAAV,qBAAhB,CADI,CAAN,CAEEC,YAFF,CAGE,wHAHF;AAKD,GARE,CAAH;AASD,CApBO,CAAR","sourcesContent":["import React from 'react';\nimport Animated from '../Animated';\n\nimport renderer from 'react-test-renderer';\n\njest.mock('../ReanimatedEventEmitter');\njest.mock('../ReanimatedModule');\n\ndescribe('Core Animated components', () => {\n xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {\n console.error = jest.fn();\n\n expect(() =>\n renderer.create(<Animated.Code exec=\"not a node\" />)\n ).toThrowError(\n \"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.\"\n );\n });\n\n xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {\n console.error = jest.fn();\n\n expect(() =>\n renderer.create(<Animated.Code>not a node</Animated.Code>)\n ).toThrowError(\n \"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.\"\n );\n });\n});\n"]}
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`throws if inputRange and outputRange are not the same length 1`] = `"inputRange and outputRange must be the same length."`;
4
+
5
+ exports[`throws if inputRange is not monotonically non-decreasing 1`] = `"inputRange must be monotonically non-decreasing. (0,1,0)"`;
6
+
7
+ exports[`throws if inputRange or outputRange contains an invalid value 1`] = `"inputRange cannot include Infinity. (0,1,Infinity)"`;
8
+
9
+ exports[`throws if inputRange or outputRange contains an invalid value 2`] = `"outputRange cannot include NaN. (0,1,NaN)"`;
10
+
11
+ exports[`throws if inputRange or outputRange does not contain at least 2 elements 1`] = `"inputRange must have at least 2 elements. (0)"`;
12
+
13
+ exports[`throws if inputRange or outputRange does not contain at least 2 elements 2`] = `"outputRange must have at least 2 elements. (0)"`;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interpolate = _interopRequireDefault(require("./interpolate"));
4
+
5
+ var _AnimatedValue = _interopRequireDefault(require("../core/AnimatedValue"));
6
+
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+
9
+ jest.mock('../ReanimatedEventEmitter');
10
+ jest.mock('../ReanimatedModule');
11
+ const value = new _AnimatedValue.default(0);
12
+ it('throws if inputRange or outputRange does not contain at least 2 elements', () => {
13
+ expect(() => (0, _interpolate.default)(value, {
14
+ inputRange: [0],
15
+ outputRange: [0, 1]
16
+ })).toThrowErrorMatchingSnapshot();
17
+ expect(() => (0, _interpolate.default)(value, {
18
+ inputRange: [0, 1],
19
+ outputRange: [0]
20
+ })).toThrowErrorMatchingSnapshot();
21
+ });
22
+ it('throws if inputRange and outputRange are not the same length', () => {
23
+ expect(() => (0, _interpolate.default)(value, {
24
+ inputRange: [0, 1, 2],
25
+ outputRange: [0, 1, 2, 3]
26
+ })).toThrowErrorMatchingSnapshot();
27
+ });
28
+ it('throws if inputRange or outputRange contains an invalid value', () => {
29
+ expect(() => (0, _interpolate.default)(value, {
30
+ inputRange: [0, 1, Infinity],
31
+ outputRange: [0, 1, 2]
32
+ })).toThrowErrorMatchingSnapshot();
33
+ expect(() => (0, _interpolate.default)(value, {
34
+ inputRange: [0, 1, 2],
35
+ outputRange: [0, 1, NaN]
36
+ })).toThrowErrorMatchingSnapshot();
37
+ });
38
+ it('throws if inputRange is not monotonically non-decreasing', () => {
39
+ expect(() => (0, _interpolate.default)(value, {
40
+ inputRange: [0, 1, 0],
41
+ outputRange: [0, 1, 2]
42
+ })).toThrowErrorMatchingSnapshot();
43
+ });
44
+ //# sourceMappingURL=interpolate.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["interpolate.test.js"],"names":["jest","mock","value","AnimatedValue","it","expect","inputRange","outputRange","toThrowErrorMatchingSnapshot","Infinity","NaN"],"mappings":";;AAAA;;AACA;;;;AAEAA,IAAI,CAACC,IAAL,CAAU,2BAAV;AACAD,IAAI,CAACC,IAAL,CAAU,qBAAV;AAEA,MAAMC,KAAK,GAAG,IAAIC,sBAAJ,CAAkB,CAAlB,CAAd;AAEAC,EAAE,CAAC,0EAAD,EAA6E,MAAM;AACnFC,EAAAA,MAAM,CAAC,MACL,0BAAYH,KAAZ,EAAmB;AACjBI,IAAAA,UAAU,EAAE,CAAC,CAAD,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ;AAFI,GAAnB,CADI,CAAN,CAKEC,4BALF;AAMAH,EAAAA,MAAM,CAAC,MACL,0BAAYH,KAAZ,EAAmB;AACjBI,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC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');\njest.mock('../ReanimatedModule');\n\nconst value = new AnimatedValue(0);\n\nit('throws if inputRange or outputRange does not contain at least 2 elements', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0],\n outputRange: [0, 1],\n })\n ).toThrowErrorMatchingSnapshot();\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1],\n outputRange: [0],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n\nit('throws if inputRange and outputRange are not the same length', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, 2],\n outputRange: [0, 1, 2, 3],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n\nit('throws if inputRange or outputRange contains an invalid value', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, Infinity],\n outputRange: [0, 1, 2],\n })\n ).toThrowErrorMatchingSnapshot();\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, 2],\n outputRange: [0, 1, NaN],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n\nit('throws if inputRange is not monotonically non-decreasing', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, 0],\n outputRange: [0, 1, 2],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n"]}
@@ -0,0 +1,223 @@
1
+ import Animated, { Easing } from './Animated';
2
+ import ReanimatedModule from './ReanimatedModule';
3
+ import React from 'react';
4
+ import renderer from 'react-test-renderer';
5
+ jest.mock('./ReanimatedEventEmitter');
6
+ jest.mock('./ReanimatedModule');
7
+ jest.mock('./derived/evaluateOnce');
8
+ jest.mock('./core/AnimatedProps');
9
+ const {
10
+ Value,
11
+ timing,
12
+ spring,
13
+ decay
14
+ } = Animated;
15
+ describe('Reanimated backward compatible API', () => {
16
+ beforeEach(() => {
17
+ let numberOfNodes = 0;
18
+
19
+ ReanimatedModule.createNode = () => numberOfNodes++;
20
+
21
+ ReanimatedModule.dropNode = () => numberOfNodes--;
22
+
23
+ ReanimatedModule.getNumberOfNodes = () => numberOfNodes;
24
+ });
25
+
26
+ const checkIfNodesGetDetachedCorrectly = animation => {
27
+ class TestComponent extends React.Component {
28
+ constructor(props) {
29
+ super(props);
30
+ this.transX = new Value(0);
31
+ this.anim = animation.node(this.transX, animation.config);
32
+ }
33
+
34
+ start(method) {
35
+ this.anim.start(method);
36
+ }
37
+
38
+ stop(res) {
39
+ this.anim.__stopImmediately_testOnly(res);
40
+ }
41
+
42
+ render() {
43
+ return /*#__PURE__*/React.createElement(Animated.View, {
44
+ style: {
45
+ transform: [{
46
+ translateX: this.transX
47
+ }]
48
+ }
49
+ });
50
+ }
51
+
52
+ }
53
+
54
+ const ref = React.createRef();
55
+ let result;
56
+
57
+ const resMethod = ({
58
+ finished
59
+ }) => result = finished;
60
+
61
+ const initial = ReanimatedModule.getNumberOfNodes();
62
+ const wrapper = renderer.create( /*#__PURE__*/React.createElement(TestComponent, {
63
+ ref: ref
64
+ }));
65
+ const before = ReanimatedModule.getNumberOfNodes();
66
+ ref.current.start(resMethod);
67
+ const during = ReanimatedModule.getNumberOfNodes();
68
+ ref.current.stop(true);
69
+ const after = ReanimatedModule.getNumberOfNodes();
70
+ wrapper.unmount();
71
+ const final = ReanimatedModule.getNumberOfNodes();
72
+ return result && initial === final && after === before && during > after && initial === 0 && before === 4;
73
+ };
74
+
75
+ it('fails if timing does not attach nodes correctly', () => {
76
+ expect(checkIfNodesGetDetachedCorrectly({
77
+ node: timing,
78
+ name: 'timing',
79
+ config: {
80
+ duration: 5000,
81
+ toValue: 120,
82
+ easing: Easing.inOut(Easing.ease)
83
+ }
84
+ })).toBeTruthy();
85
+ });
86
+ it('fails if decay does not attach nodes correctly', () => {
87
+ expect(checkIfNodesGetDetachedCorrectly({
88
+ node: decay,
89
+ name: 'decay',
90
+ config: {
91
+ deceleration: 0.997
92
+ }
93
+ })).toBeTruthy();
94
+ });
95
+ it('fails if spring does not attach nodes correctly', () => {
96
+ expect(checkIfNodesGetDetachedCorrectly({
97
+ node: spring,
98
+ name: 'spring',
99
+ config: {
100
+ toValue: 0,
101
+ damping: 7,
102
+ mass: 1,
103
+ stiffness: 121.6,
104
+ overshootClamping: false,
105
+ restSpeedThreshold: 0.001,
106
+ restDisplacementThreshold: 0.001
107
+ }
108
+ })).toBeTruthy();
109
+ });
110
+ it('fails if animation related nodes are still attached after detaching of value with two animations triggered', () => {
111
+ const {
112
+ timing,
113
+ Value
114
+ } = Animated;
115
+
116
+ class TestComponent extends React.Component {
117
+ constructor(props) {
118
+ super(props);
119
+ this.transX = new Value(0);
120
+ const config = {
121
+ duration: 5000,
122
+ toValue: -120,
123
+ easing: Easing.inOut(Easing.ease)
124
+ };
125
+ this.anim = timing(this.transX, config);
126
+ this.anim2 = timing(this.transX, config);
127
+ }
128
+
129
+ start1(method) {
130
+ this.anim.start(method);
131
+ }
132
+
133
+ start2(method) {
134
+ this.anim2.start(method);
135
+ }
136
+
137
+ render() {
138
+ return /*#__PURE__*/React.createElement(Animated.View, {
139
+ style: {
140
+ transform: [{
141
+ translateX: this.transX
142
+ }]
143
+ }
144
+ });
145
+ }
146
+
147
+ }
148
+
149
+ const ref = React.createRef();
150
+ const wrapper = renderer.create( /*#__PURE__*/React.createElement(TestComponent, {
151
+ ref: ref
152
+ }));
153
+ let result = true;
154
+
155
+ const resMethod = ({
156
+ finished
157
+ }) => result = finished;
158
+
159
+ ref.current.start1(resMethod);
160
+ ref.current.start2(resMethod);
161
+ expect(result).toBeFalsy();
162
+ result = true;
163
+ const numberOfNodesBeforeUnmounting = ReanimatedModule.getNumberOfNodes();
164
+ wrapper.unmount();
165
+ expect(result).toBeFalsy();
166
+ const numberOfNodesAfterUnmounting = ReanimatedModule.getNumberOfNodes();
167
+ const pass = numberOfNodesAfterUnmounting === 0 && numberOfNodesBeforeUnmounting > 0;
168
+ expect(pass).toBeTruthy();
169
+ });
170
+ it('fails if animation related nodes are detached if there are two children and only one detach', () => {
171
+ const {
172
+ timing,
173
+ Value
174
+ } = Animated;
175
+ const transX = new Value(0);
176
+ const wrapper1 = renderer.create( /*#__PURE__*/React.createElement(Animated.View, {
177
+ style: {
178
+ transform: [{
179
+ translateX: transX
180
+ }]
181
+ }
182
+ }));
183
+ const wrapper2 = renderer.create( /*#__PURE__*/React.createElement(Animated.View, {
184
+ style: {
185
+ transform: [{
186
+ translateX: transX
187
+ }]
188
+ }
189
+ }));
190
+ const config = {
191
+ duration: 5000,
192
+ toValue: -120,
193
+ easing: Easing.inOut(Easing.ease)
194
+ };
195
+ const anim = timing(transX, config);
196
+ anim.start();
197
+ const numberOfNodesBeforeDetach = ReanimatedModule.getNumberOfNodes();
198
+ wrapper1.unmount();
199
+ const numberOfNodesAfterDetach = ReanimatedModule.getNumberOfNodes();
200
+ const result = // 3 means AnimatedProps, AnimatedStyle and AnimatedTransform
201
+ // which are nodes not related to animation and has to be detached
202
+ numberOfNodesBeforeDetach - 3 === numberOfNodesAfterDetach && numberOfNodesAfterDetach > 3;
203
+ expect(result).toBeTruthy();
204
+ wrapper2.unmount();
205
+ expect(ReanimatedModule.getNumberOfNodes() === 0).toBeTruthy();
206
+ });
207
+ it('fails if animation attaches some node without view related', () => {
208
+ const {
209
+ timing,
210
+ Value
211
+ } = Animated;
212
+ const transX = new Value(0);
213
+ const config = {
214
+ duration: 5000,
215
+ toValue: -120,
216
+ easing: Easing.inOut(Easing.ease)
217
+ };
218
+ const anim = timing(transX, config);
219
+ anim.start();
220
+ expect(ReanimatedModule.getNumberOfNodes()).toBe(0);
221
+ });
222
+ });
223
+ //# sourceMappingURL=Animated.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Animated.test.js"],"names":["Animated","Easing","ReanimatedModule","React","renderer","jest","mock","Value","timing","spring","decay","describe","beforeEach","numberOfNodes","createNode","dropNode","getNumberOfNodes","checkIfNodesGetDetachedCorrectly","animation","TestComponent","Component","constructor","props","transX","anim","node","config","start","method","stop","res","__stopImmediately_testOnly","render","transform","translateX","ref","createRef","result","resMethod","finished","initial","wrapper","create","before","current","during","after","unmount","final","it","expect","name","duration","toValue","easing","inOut","ease","toBeTruthy","deceleration","damping","mass","stiffness","overshootClamping","restSpeedThreshold","restDisplacementThreshold","anim2","start1","start2","toBeFalsy","numberOfNodesBeforeUnmounting","numberOfNodesAfterUnmounting","pass","wrapper1","wrapper2","numberOfNodesBeforeDetach","numberOfNodesAfterDetach","toBe"],"mappings":"AAAA,OAAOA,QAAP,IAAmBC,MAAnB,QAAiC,YAAjC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,KAAP,MAAkB,OAAlB;AAEA,OAAOC,QAAP,MAAqB,qBAArB;AAEAC,IAAI,CAACC,IAAL,CAAU,0BAAV;AACAD,IAAI,CAACC,IAAL,CAAU,oBAAV;AACAD,IAAI,CAACC,IAAL,CAAU,wBAAV;AACAD,IAAI,CAACC,IAAL,CAAU,sBAAV;AAEA,MAAM;AAAEC,EAAAA,KAAF;AAASC,EAAAA,MAAT;AAAiBC,EAAAA,MAAjB;AAAyBC,EAAAA;AAAzB,IAAmCV,QAAzC;AACAW,QAAQ,CAAC,oCAAD,EAAuC,MAAM;AACnDC,EAAAA,UAAU,CAAC,MAAM;AACf,QAAIC,aAAa,GAAG,CAApB;;AACAX,IAAAA,gBAAgB,CAACY,UAAjB,GAA8B,MAAMD,aAAa,EAAjD;;AACAX,IAAAA,gBAAgB,CAACa,QAAjB,GAA4B,MAAMF,aAAa,EAA/C;;AACAX,IAAAA,gBAAgB,CAACc,gBAAjB,GAAoC,MAAMH,aAA1C;AACD,GALS,CAAV;;AAOA,QAAMI,gCAAgC,GAAGC,SAAS,IAAI;AACpD,UAAMC,aAAN,SAA4BhB,KAAK,CAACiB,SAAlC,CAA4C;AAC1CC,MAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,cAAMA,KAAN;AACA,aAAKC,MAAL,GAAc,IAAIhB,KAAJ,CAAU,CAAV,CAAd;AACA,aAAKiB,IAAL,GAAYN,SAAS,CAACO,IAAV,CAAe,KAAKF,MAApB,EAA4BL,SAAS,CAACQ,MAAtC,CAAZ;AACD;;AAEDC,MAAAA,KA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CAAR","sourcesContent":["import Animated, { Easing } from './Animated';\nimport ReanimatedModule from './ReanimatedModule';\nimport React from 'react';\n\nimport renderer from 'react-test-renderer';\n\njest.mock('./ReanimatedEventEmitter');\njest.mock('./ReanimatedModule');\njest.mock('./derived/evaluateOnce');\njest.mock('./core/AnimatedProps');\n\nconst { Value, timing, spring, decay } = Animated;\ndescribe('Reanimated backward compatible API', () => {\n beforeEach(() => {\n let numberOfNodes = 0;\n ReanimatedModule.createNode = () => numberOfNodes++;\n ReanimatedModule.dropNode = () => numberOfNodes--;\n ReanimatedModule.getNumberOfNodes = () => numberOfNodes;\n });\n\n const checkIfNodesGetDetachedCorrectly = animation => {\n class TestComponent extends React.Component {\n constructor(props) {\n super(props);\n this.transX = new Value(0);\n this.anim = animation.node(this.transX, animation.config);\n }\n\n start(method) {\n this.anim.start(method);\n }\n\n stop(res) {\n this.anim.__stopImmediately_testOnly(res);\n }\n\n render() {\n return (\n <Animated.View style={{ transform: [{ translateX: this.transX }] }} />\n );\n }\n }\n const ref = React.createRef();\n let result;\n const resMethod = ({ finished }) => (result = finished);\n const initial = ReanimatedModule.getNumberOfNodes();\n const wrapper = renderer.create(<TestComponent ref={ref} />);\n const before = ReanimatedModule.getNumberOfNodes();\n ref.current.start(resMethod);\n const during = ReanimatedModule.getNumberOfNodes();\n ref.current.stop(true);\n const after = ReanimatedModule.getNumberOfNodes();\n wrapper.unmount();\n const final = ReanimatedModule.getNumberOfNodes();\n\n return (\n result &&\n initial === final &&\n after === before &&\n during > after &&\n initial === 0 &&\n before === 4\n );\n };\n\n it('fails if timing does not attach nodes correctly', () => {\n expect(\n checkIfNodesGetDetachedCorrectly({\n node: timing,\n name: 'timing',\n config: {\n duration: 5000,\n toValue: 120,\n easing: Easing.inOut(Easing.ease),\n },\n })\n ).toBeTruthy();\n });\n\n it('fails if decay does not attach nodes correctly', () => {\n expect(\n checkIfNodesGetDetachedCorrectly({\n node: decay,\n name: 'decay',\n config: {\n deceleration: 0.997,\n },\n })\n ).toBeTruthy();\n });\n\n it('fails if spring does not attach nodes correctly', () => {\n expect(\n checkIfNodesGetDetachedCorrectly({\n node: spring,\n name: 'spring',\n config: {\n toValue: 0,\n damping: 7,\n mass: 1,\n stiffness: 121.6,\n overshootClamping: false,\n restSpeedThreshold: 0.001,\n restDisplacementThreshold: 0.001,\n },\n })\n ).toBeTruthy();\n });\n\n it('fails if animation related nodes are still attached after detaching of value with two animations triggered', () => {\n const { timing, Value } = Animated;\n class TestComponent extends React.Component {\n constructor(props) {\n super(props);\n this.transX = new Value(0);\n const config = {\n duration: 5000,\n toValue: -120,\n easing: Easing.inOut(Easing.ease),\n };\n this.anim = timing(this.transX, config);\n this.anim2 = timing(this.transX, config);\n }\n\n start1(method) {\n this.anim.start(method);\n }\n\n start2(method) {\n this.anim2.start(method);\n }\n\n render() {\n return (\n <Animated.View style={{ transform: [{ translateX: this.transX }] }} />\n );\n }\n }\n const ref = React.createRef();\n const wrapper = renderer.create(<TestComponent ref={ref} />);\n let result = true;\n const resMethod = ({ finished }) => (result = finished);\n ref.current.start1(resMethod);\n ref.current.start2(resMethod);\n expect(result).toBeFalsy();\n result = true;\n const numberOfNodesBeforeUnmounting = ReanimatedModule.getNumberOfNodes();\n wrapper.unmount();\n expect(result).toBeFalsy();\n const numberOfNodesAfterUnmounting = ReanimatedModule.getNumberOfNodes();\n const pass =\n numberOfNodesAfterUnmounting === 0 && numberOfNodesBeforeUnmounting > 0;\n expect(pass).toBeTruthy();\n });\n\n it('fails if animation related nodes are detached if there are two children and only one detach', () => {\n const { timing, Value } = Animated;\n const transX = new Value(0);\n const wrapper1 = renderer.create(\n <Animated.View\n style={{\n transform: [{ translateX: transX }],\n }}\n />\n );\n const wrapper2 = renderer.create(\n <Animated.View\n style={{\n transform: [{ translateX: transX }],\n }}\n />\n );\n const config = {\n duration: 5000,\n toValue: -120,\n easing: Easing.inOut(Easing.ease),\n };\n const anim = timing(transX, config);\n anim.start();\n const numberOfNodesBeforeDetach = ReanimatedModule.getNumberOfNodes();\n wrapper1.unmount();\n const numberOfNodesAfterDetach = ReanimatedModule.getNumberOfNodes();\n const result =\n // 3 means AnimatedProps, AnimatedStyle and AnimatedTransform\n // which are nodes not related to animation and has to be detached\n numberOfNodesBeforeDetach - 3 === numberOfNodesAfterDetach &&\n numberOfNodesAfterDetach > 3;\n expect(result).toBeTruthy();\n wrapper2.unmount();\n expect(ReanimatedModule.getNumberOfNodes() === 0).toBeTruthy();\n });\n\n it('fails if animation attaches some node without view related', () => {\n const { timing, Value } = Animated;\n const transX = new Value(0);\n\n const config = {\n duration: 5000,\n toValue: -120,\n easing: Easing.inOut(Easing.ease),\n };\n const anim = timing(transX, config);\n anim.start();\n expect(ReanimatedModule.getNumberOfNodes()).toBe(0);\n });\n});\n"]}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import Animated from '../Animated';
3
+ import renderer from 'react-test-renderer';
4
+ jest.mock('../ReanimatedEventEmitter');
5
+ jest.mock('../ReanimatedModule');
6
+ describe('Core Animated components', () => {
7
+ xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
8
+ console.error = jest.fn();
9
+ expect(() => renderer.create( /*#__PURE__*/React.createElement(Animated.Code, {
10
+ exec: "not a node"
11
+ }))).toThrowError("<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.");
12
+ });
13
+ xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
14
+ console.error = jest.fn();
15
+ expect(() => renderer.create( /*#__PURE__*/React.createElement(Animated.Code, null, "not a node"))).toThrowError("<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.");
16
+ });
17
+ });
18
+ //# sourceMappingURL=Core.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["Core.test.js"],"names":["React","Animated","renderer","jest","mock","describe","xit","console","error","fn","expect","create","toThrowError"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,QAAP,MAAqB,aAArB;AAEA,OAAOC,QAAP,MAAqB,qBAArB;AAEAC,IAAI,CAACC,IAAL,CAAU,2BAAV;AACAD,IAAI,CAACC,IAAL,CAAU,qBAAV;AAEAC,QAAQ,CAAC,0BAAD,EAA6B,MAAM;AACzCC,EAAAA,GAAG,CAAC,2GAAD,EAA8G,MAAM;AACrHC,IAAAA,OAAO,CAACC,KAAR,GAAgBL,IAAI,CAACM,EAAL,EAAhB;AAEAC,IAAAA,MAAM,CAAC,MACLR,QAAQ,CAACS,MAAT,eAAgB,oBAAC,QAAD,CAAU,IAAV;AAAe,MAAA,IAAI,EAAC;AAApB,MAAhB,CADI,CAAN,CAEEC,YAFF,CAGE,wHAHF;AAKD,GARE,CAAH;AAUAN,EAAAA,GAAG,CAAC,0GAAD,EAA6G,MAAM;AACpHC,IAAAA,OAAO,CAACC,KAAR,GAAgBL,IAAI,CAACM,EAAL,EAAhB;AAEAC,IAAAA,MAAM,CAAC,MACLR,QAAQ,CAACS,MAAT,eAAgB,oBAAC,QAAD,CAAU,IAAV,qBAAhB,CADI,CAAN,CAEEC,YAFF,CAGE,wHAHF;AAKD,GARE,CAAH;AASD,CApBO,CAAR","sourcesContent":["import React from 'react';\nimport Animated from '../Animated';\n\nimport renderer from 'react-test-renderer';\n\njest.mock('../ReanimatedEventEmitter');\njest.mock('../ReanimatedModule');\n\ndescribe('Core Animated components', () => {\n xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {\n console.error = jest.fn();\n\n expect(() =>\n renderer.create(<Animated.Code exec=\"not a node\" />)\n ).toThrowError(\n \"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.\"\n );\n });\n\n xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {\n console.error = jest.fn();\n\n expect(() =>\n renderer.create(<Animated.Code>not a node</Animated.Code>)\n ).toThrowError(\n \"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node.\"\n );\n });\n});\n"]}
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`throws if inputRange and outputRange are not the same length 1`] = `"inputRange and outputRange must be the same length."`;
4
+
5
+ exports[`throws if inputRange is not monotonically non-decreasing 1`] = `"inputRange must be monotonically non-decreasing. (0,1,0)"`;
6
+
7
+ exports[`throws if inputRange or outputRange contains an invalid value 1`] = `"inputRange cannot include Infinity. (0,1,Infinity)"`;
8
+
9
+ exports[`throws if inputRange or outputRange contains an invalid value 2`] = `"outputRange cannot include NaN. (0,1,NaN)"`;
10
+
11
+ exports[`throws if inputRange or outputRange does not contain at least 2 elements 1`] = `"inputRange must have at least 2 elements. (0)"`;
12
+
13
+ exports[`throws if inputRange or outputRange does not contain at least 2 elements 2`] = `"outputRange must have at least 2 elements. (0)"`;
@@ -0,0 +1,38 @@
1
+ import interpolate from './interpolate';
2
+ import AnimatedValue from '../core/AnimatedValue';
3
+ jest.mock('../ReanimatedEventEmitter');
4
+ jest.mock('../ReanimatedModule');
5
+ const value = new AnimatedValue(0);
6
+ it('throws if inputRange or outputRange does not contain at least 2 elements', () => {
7
+ expect(() => interpolate(value, {
8
+ inputRange: [0],
9
+ outputRange: [0, 1]
10
+ })).toThrowErrorMatchingSnapshot();
11
+ expect(() => interpolate(value, {
12
+ inputRange: [0, 1],
13
+ outputRange: [0]
14
+ })).toThrowErrorMatchingSnapshot();
15
+ });
16
+ it('throws if inputRange and outputRange are not the same length', () => {
17
+ expect(() => interpolate(value, {
18
+ inputRange: [0, 1, 2],
19
+ outputRange: [0, 1, 2, 3]
20
+ })).toThrowErrorMatchingSnapshot();
21
+ });
22
+ it('throws if inputRange or outputRange contains an invalid value', () => {
23
+ expect(() => interpolate(value, {
24
+ inputRange: [0, 1, Infinity],
25
+ outputRange: [0, 1, 2]
26
+ })).toThrowErrorMatchingSnapshot();
27
+ expect(() => interpolate(value, {
28
+ inputRange: [0, 1, 2],
29
+ outputRange: [0, 1, NaN]
30
+ })).toThrowErrorMatchingSnapshot();
31
+ });
32
+ it('throws if inputRange is not monotonically non-decreasing', () => {
33
+ expect(() => interpolate(value, {
34
+ inputRange: [0, 1, 0],
35
+ outputRange: [0, 1, 2]
36
+ })).toThrowErrorMatchingSnapshot();
37
+ });
38
+ //# sourceMappingURL=interpolate.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["interpolate.test.js"],"names":["interpolate","AnimatedValue","jest","mock","value","it","expect","inputRange","outputRange","toThrowErrorMatchingSnapshot","Infinity","NaN"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,eAAxB;AACA,OAAOC,aAAP,MAA0B,uBAA1B;AAEAC,IAAI,CAACC,IAAL,CAAU,2BAAV;AACAD,IAAI,CAACC,IAAL,CAAU,qBAAV;AAEA,MAAMC,KAAK,GAAG,IAAIH,aAAJ,CAAkB,CAAlB,CAAd;AAEAI,EAAE,CAAC,0EAAD,EAA6E,MAAM;AACnFC,EAAAA,MAAM,CAAC,MACLN,WAAW,CAACI,KAAD,EAAQ;AACjBG,IAAAA,UAAU,EAAE,CAAC,CAAD,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ;AAFI,GAAR,CADP,CAAN,CAKEC,4BALF;AAMAH,EAAAA,MAAM,CAAC,MACLN,WAAW,CAACI,KAAD,EAAQ;AACjBG,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC,CAAD;AAFI,GAAR,CADP,CAAN,CAKEC,4BALF;AAMD,CAbC,CAAF;AAeAJ,EAAE,CAAC,8DAAD,EAAiE,MAAM;AACvEC,EAAAA,MAAM,CAAC,MACLN,WAAW,CAACI,KAAD,EAAQ;AACjBG,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AAFI,GAAR,CADP,CAAN,CAKEC,4BALF;AAMD,CAPC,CAAF;AASAJ,EAAE,CAAC,+DAAD,EAAkE,MAAM;AACxEC,EAAAA,MAAM,CAAC,MACLN,WAAW,CAACI,KAAD,EAAQ;AACjBG,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAOG,QAAP,CADK;AAEjBF,IAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP;AAFI,GAAR,CADP,CAAN,CAKEC,4BALF;AAMAH,EAAAA,MAAM,CAAC,MACLN,WAAW,CAACI,KAAD,EAAQ;AACjBG,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAOG,GAAP;AAFI,GAAR,CADP,CAAN,CAKEF,4BALF;AAMD,CAbC,CAAF;AAeAJ,EAAE,CAAC,0DAAD,EAA6D,MAAM;AACnEC,EAAAA,MAAM,CAAC,MACLN,WAAW,CAACI,KAAD,EAAQ;AACjBG,IAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CADK;AAEjBC,IAAAA,WAAW,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP;AAFI,GAAR,CADP,CAAN,CAKEC,4BALF;AAMD,CAPC,CAAF","sourcesContent":["import interpolate from './interpolate';\nimport AnimatedValue from '../core/AnimatedValue';\n\njest.mock('../ReanimatedEventEmitter');\njest.mock('../ReanimatedModule');\n\nconst value = new AnimatedValue(0);\n\nit('throws if inputRange or outputRange does not contain at least 2 elements', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0],\n outputRange: [0, 1],\n })\n ).toThrowErrorMatchingSnapshot();\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1],\n outputRange: [0],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n\nit('throws if inputRange and outputRange are not the same length', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, 2],\n outputRange: [0, 1, 2, 3],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n\nit('throws if inputRange or outputRange contains an invalid value', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, Infinity],\n outputRange: [0, 1, 2],\n })\n ).toThrowErrorMatchingSnapshot();\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, 2],\n outputRange: [0, 1, NaN],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n\nit('throws if inputRange is not monotonically non-decreasing', () => {\n expect(() =>\n interpolate(value, {\n inputRange: [0, 1, 0],\n outputRange: [0, 1, 2],\n })\n ).toThrowErrorMatchingSnapshot();\n});\n"]}
package/mock.js CHANGED
@@ -166,6 +166,7 @@ const Reanimated = {
166
166
  diff: NOOP,
167
167
  diffClamp: NOOP,
168
168
  interpolate: NOOP,
169
+ interpolateColors: NOOP,
169
170
  max: (a, b) => Math.max(getValue(a), getValue(b)),
170
171
  min: (a, b) => Math.min(getValue(a), getValue(b)),
171
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "1.13.3",
3
+ "version": "1.13.4",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "start": "node node_modules/react-native/local-cli/cli.js start",
@@ -0,0 +1,206 @@
1
+ import Animated, { Easing } from './Animated';
2
+ import ReanimatedModule from './ReanimatedModule';
3
+ import React from 'react';
4
+
5
+ import renderer from 'react-test-renderer';
6
+
7
+ jest.mock('./ReanimatedEventEmitter');
8
+ jest.mock('./ReanimatedModule');
9
+ jest.mock('./derived/evaluateOnce');
10
+ jest.mock('./core/AnimatedProps');
11
+
12
+ const { Value, timing, spring, decay } = Animated;
13
+ describe('Reanimated backward compatible API', () => {
14
+ beforeEach(() => {
15
+ let numberOfNodes = 0;
16
+ ReanimatedModule.createNode = () => numberOfNodes++;
17
+ ReanimatedModule.dropNode = () => numberOfNodes--;
18
+ ReanimatedModule.getNumberOfNodes = () => numberOfNodes;
19
+ });
20
+
21
+ const checkIfNodesGetDetachedCorrectly = animation => {
22
+ class TestComponent extends React.Component {
23
+ constructor(props) {
24
+ super(props);
25
+ this.transX = new Value(0);
26
+ this.anim = animation.node(this.transX, animation.config);
27
+ }
28
+
29
+ start(method) {
30
+ this.anim.start(method);
31
+ }
32
+
33
+ stop(res) {
34
+ this.anim.__stopImmediately_testOnly(res);
35
+ }
36
+
37
+ render() {
38
+ return (
39
+ <Animated.View style={{ transform: [{ translateX: this.transX }] }} />
40
+ );
41
+ }
42
+ }
43
+ const ref = React.createRef();
44
+ let result;
45
+ const resMethod = ({ finished }) => (result = finished);
46
+ const initial = ReanimatedModule.getNumberOfNodes();
47
+ const wrapper = renderer.create(<TestComponent ref={ref} />);
48
+ const before = ReanimatedModule.getNumberOfNodes();
49
+ ref.current.start(resMethod);
50
+ const during = ReanimatedModule.getNumberOfNodes();
51
+ ref.current.stop(true);
52
+ const after = ReanimatedModule.getNumberOfNodes();
53
+ wrapper.unmount();
54
+ const final = ReanimatedModule.getNumberOfNodes();
55
+
56
+ return (
57
+ result &&
58
+ initial === final &&
59
+ after === before &&
60
+ during > after &&
61
+ initial === 0 &&
62
+ before === 4
63
+ );
64
+ };
65
+
66
+ it('fails if timing does not attach nodes correctly', () => {
67
+ expect(
68
+ checkIfNodesGetDetachedCorrectly({
69
+ node: timing,
70
+ name: 'timing',
71
+ config: {
72
+ duration: 5000,
73
+ toValue: 120,
74
+ easing: Easing.inOut(Easing.ease),
75
+ },
76
+ })
77
+ ).toBeTruthy();
78
+ });
79
+
80
+ it('fails if decay does not attach nodes correctly', () => {
81
+ expect(
82
+ checkIfNodesGetDetachedCorrectly({
83
+ node: decay,
84
+ name: 'decay',
85
+ config: {
86
+ deceleration: 0.997,
87
+ },
88
+ })
89
+ ).toBeTruthy();
90
+ });
91
+
92
+ it('fails if spring does not attach nodes correctly', () => {
93
+ expect(
94
+ checkIfNodesGetDetachedCorrectly({
95
+ node: spring,
96
+ name: 'spring',
97
+ config: {
98
+ toValue: 0,
99
+ damping: 7,
100
+ mass: 1,
101
+ stiffness: 121.6,
102
+ overshootClamping: false,
103
+ restSpeedThreshold: 0.001,
104
+ restDisplacementThreshold: 0.001,
105
+ },
106
+ })
107
+ ).toBeTruthy();
108
+ });
109
+
110
+ it('fails if animation related nodes are still attached after detaching of value with two animations triggered', () => {
111
+ const { timing, Value } = Animated;
112
+ class TestComponent extends React.Component {
113
+ constructor(props) {
114
+ super(props);
115
+ this.transX = new Value(0);
116
+ const config = {
117
+ duration: 5000,
118
+ toValue: -120,
119
+ easing: Easing.inOut(Easing.ease),
120
+ };
121
+ this.anim = timing(this.transX, config);
122
+ this.anim2 = timing(this.transX, config);
123
+ }
124
+
125
+ start1(method) {
126
+ this.anim.start(method);
127
+ }
128
+
129
+ start2(method) {
130
+ this.anim2.start(method);
131
+ }
132
+
133
+ render() {
134
+ return (
135
+ <Animated.View style={{ transform: [{ translateX: this.transX }] }} />
136
+ );
137
+ }
138
+ }
139
+ const ref = React.createRef();
140
+ const wrapper = renderer.create(<TestComponent ref={ref} />);
141
+ let result = true;
142
+ const resMethod = ({ finished }) => (result = finished);
143
+ ref.current.start1(resMethod);
144
+ ref.current.start2(resMethod);
145
+ expect(result).toBeFalsy();
146
+ result = true;
147
+ const numberOfNodesBeforeUnmounting = ReanimatedModule.getNumberOfNodes();
148
+ wrapper.unmount();
149
+ expect(result).toBeFalsy();
150
+ const numberOfNodesAfterUnmounting = ReanimatedModule.getNumberOfNodes();
151
+ const pass =
152
+ numberOfNodesAfterUnmounting === 0 && numberOfNodesBeforeUnmounting > 0;
153
+ expect(pass).toBeTruthy();
154
+ });
155
+
156
+ it('fails if animation related nodes are detached if there are two children and only one detach', () => {
157
+ const { timing, Value } = Animated;
158
+ const transX = new Value(0);
159
+ const wrapper1 = renderer.create(
160
+ <Animated.View
161
+ style={{
162
+ transform: [{ translateX: transX }],
163
+ }}
164
+ />
165
+ );
166
+ const wrapper2 = renderer.create(
167
+ <Animated.View
168
+ style={{
169
+ transform: [{ translateX: transX }],
170
+ }}
171
+ />
172
+ );
173
+ const config = {
174
+ duration: 5000,
175
+ toValue: -120,
176
+ easing: Easing.inOut(Easing.ease),
177
+ };
178
+ const anim = timing(transX, config);
179
+ anim.start();
180
+ const numberOfNodesBeforeDetach = ReanimatedModule.getNumberOfNodes();
181
+ wrapper1.unmount();
182
+ const numberOfNodesAfterDetach = ReanimatedModule.getNumberOfNodes();
183
+ const result =
184
+ // 3 means AnimatedProps, AnimatedStyle and AnimatedTransform
185
+ // which are nodes not related to animation and has to be detached
186
+ numberOfNodesBeforeDetach - 3 === numberOfNodesAfterDetach &&
187
+ numberOfNodesAfterDetach > 3;
188
+ expect(result).toBeTruthy();
189
+ wrapper2.unmount();
190
+ expect(ReanimatedModule.getNumberOfNodes() === 0).toBeTruthy();
191
+ });
192
+
193
+ it('fails if animation attaches some node without view related', () => {
194
+ const { timing, Value } = Animated;
195
+ const transX = new Value(0);
196
+
197
+ const config = {
198
+ duration: 5000,
199
+ toValue: -120,
200
+ easing: Easing.inOut(Easing.ease),
201
+ };
202
+ const anim = timing(transX, config);
203
+ anim.start();
204
+ expect(ReanimatedModule.getNumberOfNodes()).toBe(0);
205
+ });
206
+ });
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import Animated from '../Animated';
3
+
4
+ import renderer from 'react-test-renderer';
5
+
6
+ jest.mock('../ReanimatedEventEmitter');
7
+ jest.mock('../ReanimatedModule');
8
+
9
+ describe('Core Animated components', () => {
10
+ xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
11
+ console.error = jest.fn();
12
+
13
+ expect(() =>
14
+ renderer.create(<Animated.Code exec="not a node" />)
15
+ ).toThrowError(
16
+ "<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node."
17
+ );
18
+ });
19
+
20
+ xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
21
+ console.error = jest.fn();
22
+
23
+ expect(() =>
24
+ renderer.create(<Animated.Code>not a node</Animated.Code>)
25
+ ).toThrowError(
26
+ "<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node."
27
+ );
28
+ });
29
+ });
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`throws if inputRange and outputRange are not the same length 1`] = `"inputRange and outputRange must be the same length."`;
4
+
5
+ exports[`throws if inputRange is not monotonically non-decreasing 1`] = `"inputRange must be monotonically non-decreasing. (0,1,0)"`;
6
+
7
+ exports[`throws if inputRange or outputRange contains an invalid value 1`] = `"inputRange cannot include Infinity. (0,1,Infinity)"`;
8
+
9
+ exports[`throws if inputRange or outputRange contains an invalid value 2`] = `"outputRange cannot include NaN. (0,1,NaN)"`;
10
+
11
+ exports[`throws if inputRange or outputRange does not contain at least 2 elements 1`] = `"inputRange must have at least 2 elements. (0)"`;
12
+
13
+ exports[`throws if inputRange or outputRange does not contain at least 2 elements 2`] = `"outputRange must have at least 2 elements. (0)"`;
@@ -0,0 +1,55 @@
1
+ import interpolate from './interpolate';
2
+ import AnimatedValue from '../core/AnimatedValue';
3
+
4
+ jest.mock('../ReanimatedEventEmitter');
5
+ jest.mock('../ReanimatedModule');
6
+
7
+ const value = new AnimatedValue(0);
8
+
9
+ it('throws if inputRange or outputRange does not contain at least 2 elements', () => {
10
+ expect(() =>
11
+ interpolate(value, {
12
+ inputRange: [0],
13
+ outputRange: [0, 1],
14
+ })
15
+ ).toThrowErrorMatchingSnapshot();
16
+ expect(() =>
17
+ interpolate(value, {
18
+ inputRange: [0, 1],
19
+ outputRange: [0],
20
+ })
21
+ ).toThrowErrorMatchingSnapshot();
22
+ });
23
+
24
+ it('throws if inputRange and outputRange are not the same length', () => {
25
+ expect(() =>
26
+ interpolate(value, {
27
+ inputRange: [0, 1, 2],
28
+ outputRange: [0, 1, 2, 3],
29
+ })
30
+ ).toThrowErrorMatchingSnapshot();
31
+ });
32
+
33
+ it('throws if inputRange or outputRange contains an invalid value', () => {
34
+ expect(() =>
35
+ interpolate(value, {
36
+ inputRange: [0, 1, Infinity],
37
+ outputRange: [0, 1, 2],
38
+ })
39
+ ).toThrowErrorMatchingSnapshot();
40
+ expect(() =>
41
+ interpolate(value, {
42
+ inputRange: [0, 1, 2],
43
+ outputRange: [0, 1, NaN],
44
+ })
45
+ ).toThrowErrorMatchingSnapshot();
46
+ });
47
+
48
+ it('throws if inputRange is not monotonically non-decreasing', () => {
49
+ expect(() =>
50
+ interpolate(value, {
51
+ inputRange: [0, 1, 0],
52
+ outputRange: [0, 1, 2],
53
+ })
54
+ ).toThrowErrorMatchingSnapshot();
55
+ });
package/android/README.md DELETED
@@ -1,15 +0,0 @@
1
-
2
- README
3
- ======
4
-
5
- If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
6
-
7
- 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
8
- 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
9
- ```
10
- ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
11
- sdk.dir=/Users/{username}/Library/Android/sdk
12
- ```
13
- 3. Delete the `maven` folder
14
- 4. Run `sudo ./gradlew installArchives`
15
- 5. Verify that latest set of generated files is in the maven folder with the correct version number