react-native-reanimated 3.4.1 → 3.4.2

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.
Files changed (144) hide show
  1. package/lib/module/Animated.js +60 -1
  2. package/lib/module/Animated.js.map +1 -1
  3. package/lib/module/createAnimatedComponent.js.map +1 -1
  4. package/lib/module/reanimated2/Easing.js +8 -0
  5. package/lib/module/reanimated2/Easing.js.map +1 -1
  6. package/lib/module/reanimated2/UpdateProps.js +2 -2
  7. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  8. package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
  9. package/lib/module/reanimated2/animation/decay.js.map +1 -1
  10. package/lib/module/reanimated2/animation/index.js +1 -1
  11. package/lib/module/reanimated2/animation/index.js.map +1 -1
  12. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  13. package/lib/module/reanimated2/animation/styleAnimation.js +2 -2
  14. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  15. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  16. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +6 -0
  17. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
  18. package/lib/module/reanimated2/animation/util.js +4 -19
  19. package/lib/module/reanimated2/animation/util.js.map +1 -1
  20. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  21. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  22. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  23. package/lib/module/reanimated2/fabricUtils.js +3 -1
  24. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  25. package/lib/module/reanimated2/globals.d.js.map +1 -1
  26. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  27. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  28. package/lib/module/reanimated2/hook/index.js.map +1 -1
  29. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -1
  30. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  31. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  32. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  33. package/lib/module/reanimated2/hook/useAnimatedStyle.js +1 -1
  34. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  35. package/lib/module/reanimated2/hook/utils.js +2 -27
  36. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  37. package/lib/module/reanimated2/index.js.map +1 -1
  38. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  39. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  40. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  41. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  42. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  43. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  44. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  45. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  46. package/lib/module/reanimated2/mappers.js +1 -1
  47. package/lib/module/reanimated2/mappers.js.map +1 -1
  48. package/lib/module/reanimated2/mock.js +26 -0
  49. package/lib/module/reanimated2/mock.js.map +1 -1
  50. package/lib/module/reanimated2/mutables.js +0 -1
  51. package/lib/module/reanimated2/mutables.js.map +1 -1
  52. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +3 -0
  53. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  54. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  55. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  56. package/lib/module/reanimated2/valueSetter.js +0 -1
  57. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  58. package/lib/module/setAndForwardRef.js.map +1 -1
  59. package/lib/typescript/Animated.d.ts +68 -3
  60. package/lib/typescript/createAnimatedComponent.d.ts +1 -26
  61. package/lib/typescript/reanimated2/Easing.d.ts +17 -9
  62. package/lib/typescript/reanimated2/UpdateProps.d.ts +5 -5
  63. package/lib/typescript/reanimated2/animation/commonTypes.d.ts +4 -3
  64. package/lib/typescript/reanimated2/animation/decay.d.ts +2 -4
  65. package/lib/typescript/reanimated2/animation/index.d.ts +3 -3
  66. package/lib/typescript/reanimated2/animation/springUtils.d.ts +1 -0
  67. package/lib/typescript/reanimated2/animation/styleAnimation.d.ts +2 -6
  68. package/lib/typescript/reanimated2/animation/timing.d.ts +4 -7
  69. package/lib/typescript/reanimated2/animation/transformationMatrix/matrixUtils.d.ts +1 -1
  70. package/lib/typescript/reanimated2/animation/util.d.ts +2 -4
  71. package/lib/typescript/reanimated2/commonTypes.d.ts +0 -4
  72. package/lib/typescript/reanimated2/component/FlatList.d.ts +2 -1
  73. package/lib/typescript/reanimated2/component/ScrollView.d.ts +1 -1
  74. package/lib/typescript/reanimated2/helperTypes.d.ts +11 -7
  75. package/lib/typescript/reanimated2/hook/commonTypes.d.ts +2 -2
  76. package/lib/typescript/reanimated2/hook/index.d.ts +1 -1
  77. package/lib/typescript/reanimated2/hook/useAnimatedGestureHandler.d.ts +2 -2
  78. package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +4 -4
  79. package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +4 -5
  80. package/lib/typescript/reanimated2/hook/utils.d.ts +3 -11
  81. package/lib/typescript/reanimated2/index.d.ts +3 -1
  82. package/lib/typescript/reanimated2/interpolateColor.d.ts +2 -3
  83. package/lib/typescript/reanimated2/js-reanimated/commonTypes.d.ts +1 -43
  84. package/lib/typescript/reanimated2/js-reanimated/index.d.ts +3 -2
  85. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -4
  86. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -11
  87. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +3 -3
  88. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -13
  89. package/lib/typescript/reanimated2/layoutReanimation/index.d.ts +1 -0
  90. package/lib/typescript/reanimated2/mappers.d.ts +0 -12
  91. package/lib/typescript/reanimated2/mock.d.ts +1 -76
  92. package/lib/typescript/reanimated2/mutables.d.ts +0 -1
  93. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  94. package/lib/typescript/reanimated2/valueSetter.d.ts +0 -1
  95. package/lib/typescript/setAndForwardRef.d.ts +1 -1
  96. package/package.json +3 -1
  97. package/src/Animated.ts +80 -6
  98. package/src/createAnimatedComponent.tsx +2 -2
  99. package/src/reanimated2/Easing.ts +18 -8
  100. package/src/reanimated2/UpdateProps.ts +13 -17
  101. package/src/reanimated2/animation/commonTypes.ts +3 -3
  102. package/src/reanimated2/animation/decay.ts +3 -1
  103. package/src/reanimated2/animation/index.ts +3 -3
  104. package/src/reanimated2/animation/springUtils.ts +2 -0
  105. package/src/reanimated2/animation/styleAnimation.ts +5 -5
  106. package/src/reanimated2/animation/timing.ts +6 -4
  107. package/src/reanimated2/animation/transformationMatrix/matrixUtils.tsx +4 -1
  108. package/src/reanimated2/animation/util.ts +5 -29
  109. package/src/reanimated2/commonTypes.ts +0 -25
  110. package/src/reanimated2/component/FlatList.tsx +3 -1
  111. package/src/reanimated2/component/ScrollView.tsx +1 -1
  112. package/src/reanimated2/fabricUtils.ts +1 -0
  113. package/src/reanimated2/globals.d.ts +3 -3
  114. package/src/reanimated2/helperTypes.ts +17 -7
  115. package/src/reanimated2/hook/commonTypes.ts +2 -3
  116. package/src/reanimated2/hook/index.ts +4 -1
  117. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
  118. package/src/reanimated2/hook/useAnimatedRef.ts +13 -10
  119. package/src/reanimated2/hook/useAnimatedStyle.ts +27 -26
  120. package/src/reanimated2/hook/utils.ts +5 -31
  121. package/src/reanimated2/index.ts +13 -1
  122. package/src/reanimated2/interpolateColor.ts +2 -2
  123. package/src/reanimated2/js-reanimated/commonTypes.ts +3 -3
  124. package/src/reanimated2/js-reanimated/index.ts +4 -3
  125. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -4
  126. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +5 -5
  127. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -3
  128. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -13
  129. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  130. package/src/reanimated2/mappers.ts +2 -2
  131. package/src/reanimated2/mock.ts +27 -0
  132. package/src/reanimated2/mutables.ts +0 -1
  133. package/src/reanimated2/platform-specific/checkCppVersion.ts +2 -0
  134. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  135. package/src/reanimated2/valueSetter.ts +0 -1
  136. package/src/setAndForwardRef.ts +1 -1
  137. package/lib/module/reanimated2/js-reanimated/Mapper.js +0 -69
  138. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +0 -1
  139. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +0 -109
  140. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +0 -1
  141. package/lib/typescript/reanimated2/js-reanimated/Mapper.d.ts +0 -14
  142. package/lib/typescript/reanimated2/js-reanimated/MapperRegistry.d.ts +0 -14
  143. package/src/reanimated2/js-reanimated/Mapper.ts +0 -94
  144. package/src/reanimated2/js-reanimated/MapperRegistry.ts +0 -133
@@ -1,94 +0,0 @@
1
- import type { NestedObjectValues } from '../commonTypes';
2
- import { shouldBeUseWeb } from '../PlatformChecker';
3
- import type { JSReanimated } from './commonTypes';
4
- import MutableValue from './MutableValue';
5
-
6
- export default class Mapper<T> {
7
- static MAPPER_ID = 1;
8
- id: number;
9
- inputs: MutableValue<T>[];
10
- outputs: MutableValue<T>[];
11
- mapper: () => void;
12
-
13
- dirty = true;
14
-
15
- constructor(
16
- module: JSReanimated,
17
- mapper: () => void,
18
- inputs: NestedObjectValues<MutableValue<T>>[] = [],
19
- outputs: NestedObjectValues<MutableValue<T>>[] = []
20
- ) {
21
- this.id = Mapper.MAPPER_ID++;
22
- this.inputs = this.extractMutablesFromArray(inputs);
23
- this.outputs = this.extractMutablesFromArray(outputs);
24
- this.mapper = mapper;
25
-
26
- const markDirty = () => {
27
- this.dirty = true;
28
- module.maybeRequestRender();
29
- };
30
-
31
- this.inputs.forEach((input) => {
32
- input.addListener(markDirty);
33
- });
34
- }
35
-
36
- execute(): void {
37
- this.dirty = false;
38
- this.mapper();
39
- }
40
-
41
- extractMutablesFromArray<T>(
42
- array: NestedObjectValues<MutableValue<T>>
43
- ): MutableValue<T>[] {
44
- const res: MutableValue<T>[] = [];
45
-
46
- function extractMutables(value: NestedObjectValues<MutableValue<T>>) {
47
- if (value == null) {
48
- // return;
49
- } else if (value instanceof MutableValue) {
50
- res.push(value);
51
- } else if (Array.isArray(value)) {
52
- value.forEach((v) => extractMutables(v));
53
- } else if (isWebDomElement(value)) {
54
- // do nothing on dom elements
55
- // without this check, we get a "Maximum call size exceeded error"
56
- } else if (typeof value === 'object') {
57
- Object.keys(value).forEach((key) => {
58
- extractMutables(value[key]);
59
- });
60
- }
61
- }
62
-
63
- extractMutables(array);
64
- return res;
65
- }
66
- }
67
-
68
- function isWebDomElement(value: any) {
69
- if (!shouldBeUseWeb()) {
70
- return false;
71
- }
72
-
73
- // https://stackoverflow.com/a/384380/7869175
74
- function isWebNode(o: any) {
75
- return typeof Node === 'object'
76
- ? o instanceof Node
77
- : o &&
78
- typeof o === 'object' &&
79
- typeof o.nodeType === 'number' &&
80
- typeof o.nodeName === 'string';
81
- }
82
-
83
- function isWebElement(o: any) {
84
- return typeof HTMLElement === 'object'
85
- ? o instanceof HTMLElement // DOM2
86
- : o &&
87
- typeof o === 'object' &&
88
- o !== null &&
89
- o.nodeType === 1 &&
90
- typeof o.nodeName === 'string';
91
- }
92
-
93
- return isWebNode(value) || isWebElement(value);
94
- }
@@ -1,133 +0,0 @@
1
- import type { JSReanimated } from './commonTypes';
2
- import type Mapper from './Mapper';
3
-
4
- export default class MapperRegistry<T> {
5
- sortedMappers: Mapper<T>[] = [];
6
- mappers: Map<number, Mapper<T>> = new Map();
7
- _module: JSReanimated;
8
-
9
- updatedSinceLastExecute = false;
10
-
11
- constructor(module: JSReanimated) {
12
- this._module = module;
13
- }
14
-
15
- startMapper(mapper: Mapper<T>): number {
16
- this.mappers.set(mapper.id, mapper);
17
- this.updatedSinceLastExecute = true;
18
- return mapper.id;
19
- }
20
-
21
- stopMapper(id: number): void {
22
- this.mappers.delete(id);
23
- this.updatedSinceLastExecute = true;
24
- }
25
-
26
- execute(): void {
27
- if (this.updatedSinceLastExecute) {
28
- this.updateOrder();
29
- this.updatedSinceLastExecute = false;
30
- }
31
-
32
- for (let i = 0, len = this.sortedMappers.length; i < len; ++i) {
33
- const mapper = this.sortedMappers[i];
34
- if (mapper.dirty) {
35
- mapper.execute();
36
- }
37
- }
38
- }
39
-
40
- updateOrder(): void {
41
- const nodes = [...this.mappers.values()].map((mapper) => new Node(mapper));
42
-
43
- const mappersById: Record<number, Mapper<T>> = {};
44
- this.mappers.forEach((mapper) => {
45
- mappersById[mapper.id] = mapper;
46
- });
47
-
48
- // create a graph from array of nodes
49
- for (let i = 0, nodesLen = nodes.length; i < nodesLen; ++i) {
50
- const node = nodes[i];
51
- if (node.mapper.outputs.length === 0) {
52
- continue;
53
- }
54
- for (let j = 0; j < nodesLen; ++j) {
55
- const restNode = nodes[j];
56
- if (i === j || restNode.mapper.inputs.length === 0) {
57
- continue;
58
- }
59
- for (
60
- let outi = 0, outputsLen = node.mapper.outputs.length;
61
- outi < outputsLen;
62
- ++outi
63
- ) {
64
- for (
65
- let resti = 0, restLen = restNode.mapper.inputs.length;
66
- resti < restLen;
67
- ++resti
68
- ) {
69
- if (
70
- node.mapper.outputs[outi]._id ===
71
- restNode.mapper.inputs[resti]._id
72
- ) {
73
- node.children.push(restNode);
74
- }
75
- }
76
- }
77
- }
78
- }
79
-
80
- const post: Record<number, number> = {};
81
- let postCounter = 1;
82
- const dfs = (node: Node<T>) => {
83
- const index = nodes.indexOf(node);
84
- if (index === -1) {
85
- // this node has already been handled
86
- return;
87
- }
88
- ++postCounter;
89
- nodes.splice(index, 1);
90
- if (node.children.length === 0 && nodes.length > 0) {
91
- post[node.mapper.id] = postCounter++;
92
- dfs(nodes[0]);
93
- return;
94
- }
95
- for (let i = 0, len = node.children.length; i < len; ++i) {
96
- dfs(node.children[i]);
97
- }
98
- post[node.mapper.id] = postCounter++;
99
- };
100
-
101
- while (nodes.length) dfs(nodes[0]);
102
-
103
- const postArray = Object.keys(post).map((key) => {
104
- const num = parseInt(key);
105
- return [num, post[num]];
106
- });
107
- postArray.sort((a, b) => {
108
- return b[1] - a[1];
109
- });
110
-
111
- // clear sorted mappers
112
- this.sortedMappers = [];
113
-
114
- for (let i = 0, len = postArray.length; i < len; ++i) {
115
- const [id] = postArray[i];
116
- this.sortedMappers.push(mappersById[id]);
117
- }
118
- }
119
-
120
- get needRunOnRender(): boolean {
121
- return this.updatedSinceLastExecute;
122
- }
123
- }
124
-
125
- class Node<T> {
126
- mapper: Mapper<T>;
127
- children: Node<T>[];
128
-
129
- constructor(mapper: Mapper<T>, children = []) {
130
- this.mapper = mapper;
131
- this.children = children;
132
- }
133
- }