react-native-reanimated 3.0.0-rc.7 → 3.0.0-rc.8

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 (177) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +32 -37
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +4 -3
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +76 -0
  4. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +41 -0
  5. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +161 -165
  6. package/Common/cpp/NativeModules/NativeReanimatedModule.h +36 -34
  7. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +22 -34
  8. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +13 -14
  9. package/Common/cpp/SharedItems/RuntimeManager.h +1 -34
  10. package/Common/cpp/SharedItems/Shareables.cpp +142 -0
  11. package/Common/cpp/SharedItems/Shareables.h +455 -0
  12. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -0
  13. package/Common/cpp/Tools/RuntimeDecorator.cpp +54 -26
  14. package/Common/cpp/Tools/RuntimeDecorator.h +11 -2
  15. package/Common/cpp/Tools/Scheduler.cpp +10 -0
  16. package/Common/cpp/Tools/SingleInstanceChecker.h +1 -1
  17. package/android/src/main/cpp/LayoutAnimations.cpp +6 -16
  18. package/android/src/main/cpp/LayoutAnimations.h +4 -4
  19. package/android/src/main/cpp/NativeProxy.cpp +50 -63
  20. package/ios/native/NativeProxy.mm +26 -42
  21. package/lib/commonjs/createAnimatedComponent.js +7 -11
  22. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  23. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +24 -25
  24. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  25. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +27 -55
  26. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
  27. package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -3
  28. package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
  29. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  30. package/lib/commonjs/reanimated2/commonTypes.js +7 -0
  31. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  32. package/lib/commonjs/reanimated2/core.js +111 -209
  33. package/lib/commonjs/reanimated2/core.js.map +1 -1
  34. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  35. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +15 -9
  36. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  37. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +18 -8
  38. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  39. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +27 -36
  40. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  41. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +24 -50
  42. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  43. package/lib/commonjs/reanimated2/hook/useSharedValue.js +3 -2
  44. package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
  45. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  46. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  47. package/lib/commonjs/reanimated2/jestUtils.js +8 -33
  48. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  49. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +16 -100
  50. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  51. package/lib/commonjs/reanimated2/js-reanimated/index.js +5 -0
  52. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  53. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  54. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  55. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +91 -0
  56. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
  57. package/lib/commonjs/reanimated2/layoutReanimation/index.js +1 -1
  58. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  59. package/lib/commonjs/reanimated2/mappers.js +186 -0
  60. package/lib/commonjs/reanimated2/mappers.js.map +1 -0
  61. package/lib/commonjs/reanimated2/mutables.js +173 -0
  62. package/lib/commonjs/reanimated2/mutables.js.map +1 -0
  63. package/lib/commonjs/reanimated2/shareables.js +153 -0
  64. package/lib/commonjs/reanimated2/shareables.js.map +1 -0
  65. package/lib/commonjs/reanimated2/threads.js +58 -0
  66. package/lib/commonjs/reanimated2/threads.js.map +1 -0
  67. package/lib/commonjs/reanimated2/time.js +55 -0
  68. package/lib/commonjs/reanimated2/time.js.map +1 -0
  69. package/lib/commonjs/reanimated2/valueSetter.js +81 -0
  70. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -0
  71. package/lib/module/createAnimatedComponent.js +7 -12
  72. package/lib/module/createAnimatedComponent.js.map +1 -1
  73. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +24 -25
  74. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  75. package/lib/module/reanimated2/ViewDescriptorsSet.js +27 -53
  76. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  77. package/lib/module/reanimated2/WorkletEventHandler.js +4 -3
  78. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  79. package/lib/module/reanimated2/animation/util.js.map +1 -1
  80. package/lib/module/reanimated2/commonTypes.js +7 -0
  81. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  82. package/lib/module/reanimated2/core.js +66 -188
  83. package/lib/module/reanimated2/core.js.map +1 -1
  84. package/lib/module/reanimated2/globals.d.js.map +1 -1
  85. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +16 -6
  86. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  87. package/lib/module/reanimated2/hook/useAnimatedRef.js +17 -8
  88. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  89. package/lib/module/reanimated2/hook/useAnimatedSensor.js +29 -34
  90. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  91. package/lib/module/reanimated2/hook/useAnimatedStyle.js +26 -52
  92. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  93. package/lib/module/reanimated2/hook/useSharedValue.js +3 -2
  94. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  95. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  96. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  97. package/lib/module/reanimated2/jestUtils.js +8 -31
  98. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  99. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +16 -95
  100. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  101. package/lib/module/reanimated2/js-reanimated/index.js +5 -0
  102. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  103. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  104. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  105. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +84 -0
  106. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
  107. package/lib/module/reanimated2/layoutReanimation/index.js +1 -1
  108. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  109. package/lib/module/reanimated2/mappers.js +173 -0
  110. package/lib/module/reanimated2/mappers.js.map +1 -0
  111. package/lib/module/reanimated2/mutables.js +149 -0
  112. package/lib/module/reanimated2/mutables.js.map +1 -0
  113. package/lib/module/reanimated2/shareables.js +133 -0
  114. package/lib/module/reanimated2/shareables.js.map +1 -0
  115. package/lib/module/reanimated2/threads.js +45 -0
  116. package/lib/module/reanimated2/threads.js.map +1 -0
  117. package/lib/module/reanimated2/time.js +37 -0
  118. package/lib/module/reanimated2/time.js.map +1 -0
  119. package/lib/module/reanimated2/valueSetter.js +66 -0
  120. package/lib/module/reanimated2/valueSetter.js.map +1 -0
  121. package/package.json +1 -1
  122. package/plugin.js +31 -15
  123. package/src/createAnimatedComponent.tsx +8 -24
  124. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +34 -53
  125. package/src/reanimated2/ViewDescriptorsSet.ts +30 -69
  126. package/src/reanimated2/WorkletEventHandler.ts +4 -11
  127. package/src/reanimated2/animation/util.ts +1 -0
  128. package/src/reanimated2/commonTypes.ts +29 -4
  129. package/src/reanimated2/core.ts +103 -230
  130. package/src/reanimated2/globals.d.ts +26 -26
  131. package/src/reanimated2/hook/useAnimatedKeyboard.ts +18 -9
  132. package/src/reanimated2/hook/useAnimatedRef.ts +27 -9
  133. package/src/reanimated2/hook/useAnimatedSensor.ts +33 -31
  134. package/src/reanimated2/hook/useAnimatedStyle.ts +26 -64
  135. package/src/reanimated2/hook/useSharedValue.ts +6 -3
  136. package/src/reanimated2/hook/utils.ts +1 -1
  137. package/src/reanimated2/interpolateColor.ts +2 -2
  138. package/src/reanimated2/jestUtils.ts +14 -29
  139. package/src/reanimated2/js-reanimated/JSReanimated.ts +19 -93
  140. package/src/reanimated2/js-reanimated/index.ts +4 -0
  141. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +7 -0
  142. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  143. package/src/reanimated2/layoutReanimation/animationsManager.ts +94 -0
  144. package/src/reanimated2/layoutReanimation/index.ts +1 -1
  145. package/src/reanimated2/mappers.ts +179 -0
  146. package/src/reanimated2/mutables.ts +151 -0
  147. package/src/reanimated2/shareables.ts +121 -0
  148. package/src/reanimated2/threads.ts +46 -0
  149. package/src/reanimated2/time.ts +30 -0
  150. package/src/reanimated2/valueSetter.ts +64 -0
  151. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +0 -127
  152. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +0 -56
  153. package/Common/cpp/Registries/MapperRegistry.cpp +0 -147
  154. package/Common/cpp/Registries/MapperRegistry.h +0 -29
  155. package/Common/cpp/Registries/WorkletsCache.cpp +0 -45
  156. package/Common/cpp/Registries/WorkletsCache.h +0 -24
  157. package/Common/cpp/SharedItems/FrozenObject.cpp +0 -35
  158. package/Common/cpp/SharedItems/FrozenObject.h +0 -36
  159. package/Common/cpp/SharedItems/HostFunctionHandler.h +0 -28
  160. package/Common/cpp/SharedItems/MutableValue.cpp +0 -134
  161. package/Common/cpp/SharedItems/MutableValue.h +0 -54
  162. package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +0 -47
  163. package/Common/cpp/SharedItems/MutableValueSetterProxy.h +0 -25
  164. package/Common/cpp/SharedItems/RemoteObject.cpp +0 -45
  165. package/Common/cpp/SharedItems/RemoteObject.h +0 -35
  166. package/Common/cpp/SharedItems/ShareableValue.cpp +0 -529
  167. package/Common/cpp/SharedItems/ShareableValue.h +0 -63
  168. package/Common/cpp/SharedItems/ValueWrapper.h +0 -183
  169. package/Common/cpp/Tools/JSIStoreValueUser.cpp +0 -55
  170. package/Common/cpp/Tools/JSIStoreValueUser.h +0 -37
  171. package/Common/cpp/Tools/Mapper.cpp +0 -86
  172. package/Common/cpp/Tools/Mapper.h +0 -51
  173. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -58
  174. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
  175. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -52
  176. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
  177. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +0 -49
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.withReanimatedTimer = exports.setUpTests = exports.getAnimatedStyle = exports.advanceAnimationByTime = exports.advanceAnimationByFrame = void 0;
7
-
8
- var _core = require("./core");
9
-
10
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
8
  // @ts-nocheck
12
9
  let config = {
@@ -141,35 +138,18 @@ const compareStyle = (received, expectedStyle, config) => {
141
138
  };
142
139
 
143
140
  let frameTime = 1000 / config.fps;
144
- let requestAnimationFrameCopy;
145
- let currentTimestamp = 0;
146
-
147
- const requestAnimationFrame = callback => {
148
- setTimeout(callback, frameTime);
149
- };
150
141
 
151
142
  const beforeTest = () => {
152
- (0, _core.jestResetJsReanimatedModule)();
153
- requestAnimationFrameCopy = global.requestAnimationFrame;
154
- global.requestAnimationFrame = requestAnimationFrame;
155
- global.ReanimatedDataMock = {
156
- now: () => currentTimestamp
157
- };
158
- currentTimestamp = 0;
159
143
  jest.useFakeTimers();
160
144
  };
161
145
 
162
146
  const afterTest = () => {
147
+ jest.runOnlyPendingTimers();
163
148
  jest.useRealTimers();
164
- global.requestAnimationFrame = requestAnimationFrameCopy;
165
- };
166
-
167
- const tickTravel = () => {
168
- currentTimestamp += frameTime;
169
- jest.advanceTimersByTime(frameTime);
170
149
  };
171
150
 
172
151
  const withReanimatedTimer = animationTest => {
152
+ console.warn('This method is deprecated, you shoulddefine your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing');
173
153
  beforeTest();
174
154
  animationTest();
175
155
  afterTest();
@@ -179,22 +159,17 @@ exports.withReanimatedTimer = withReanimatedTimer;
179
159
 
180
160
  const advanceAnimationByTime = function () {
181
161
  let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : frameTime;
182
-
183
- for (let i = 0; i <= Math.ceil(time / frameTime); i++) {
184
- tickTravel();
185
- }
186
-
187
- jest.advanceTimersByTime(frameTime);
162
+ console.warn('This method is deprecated, use jest.advanceTimersByTime directly');
163
+ jest.advanceTimersByTime(time);
164
+ jest.runOnlyPendingTimers();
188
165
  };
189
166
 
190
167
  exports.advanceAnimationByTime = advanceAnimationByTime;
191
168
 
192
169
  const advanceAnimationByFrame = count => {
193
- for (let i = 0; i <= count; i++) {
194
- tickTravel();
195
- }
196
-
197
- jest.advanceTimersByTime(frameTime);
170
+ console.warn('This method is deprecated, use jest.advanceTimersByTime directly');
171
+ jest.advanceTimersByTime(count * frameTime);
172
+ jest.runOnlyPendingTimers();
198
173
  };
199
174
 
200
175
  exports.advanceAnimationByFrame = advanceAnimationByFrame;
@@ -1 +1 @@
1
- {"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","requestAnimationFrameCopy","currentTimestamp","requestAnimationFrame","callback","setTimeout","beforeTest","jestResetJsReanimatedModule","global","ReanimatedDataMock","now","jest","useFakeTimers","afterTest","useRealTimers","tickTravel","advanceTimersByTime","withReanimatedTimer","animationTest","advanceAnimationByTime","time","Math","ceil","advanceAnimationByFrame","count","setUpTests","userConfig","expectModule","require","jestGlobals","extend","default","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport { jestResetJsReanimatedModule } from './core';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\nlet requestAnimationFrameCopy;\nlet currentTimestamp = 0;\n\nconst requestAnimationFrame = (callback) => {\n setTimeout(callback, frameTime);\n};\n\nconst beforeTest = () => {\n jestResetJsReanimatedModule();\n requestAnimationFrameCopy = global.requestAnimationFrame;\n global.requestAnimationFrame = requestAnimationFrame;\n global.ReanimatedDataMock = {\n now: () => currentTimestamp,\n };\n currentTimestamp = 0;\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.useRealTimers();\n global.requestAnimationFrame = requestAnimationFrameCopy;\n};\n\nconst tickTravel = () => {\n currentTimestamp += frameTime;\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n for (let i = 0; i <= Math.ceil(time / frameTime); i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const advanceAnimationByFrame = (count) => {\n for (let i = 0; i <= count; i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;;AAEA;;AAFA;AACA;AAcA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,KAAf,CAAqBY,OAArB,CAA8BZ,KAAD,IAAW;MACtC,IAAID,eAAe,CAACC,KAAD,CAAnB,EAA4B;QAC1BS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGP,0BAA0B,CAACF,KAAD;QAFhB,CAAf;MAID,CALD,MAKO;QACLS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGT;QAFU,CAAf;MAID;IACF,CAZD;EAaD,CAdD,MAcO;IACL,IAAID,eAAe,CAACQ,WAAD,CAAnB,EAAkC;MAChCE,YAAY,GAAGP,0BAA0B,CAACK,WAAD,CAAzC;IACD,CAFD,MAEO;MACLE,YAAY,GAAG,EACb,GAAGF,WADU;QAEb,GAAGD,QAAQ,CAACE,KAAT,CAAeP,aAAf,CAA6BG;MAFnB,CAAf;IAID;EACF;;EACD,OAAOK,YAAP;AACD,CA5BD;;AA8BA,MAAMI,UAAU,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I;MACxD,OAAO8B,YAAY,CAACrB,QAAD,EAAWsB,aAAX,EAA0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CA/BM;;;;AAiCA,MAAM6E,gBAAgB,GAAIpE,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
1
+ {"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","setUpTests","userConfig","global","expectModule","require","jestGlobals","extend","default","Math","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n console.warn(\n 'This method is deprecated, you shoulddefine your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAYA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CA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OpE,MAAM,CAACC,GAAzB,CAAZ;EAEAD,MAAM,GAAG,EACP,GAAGA,MADI;IAEP,GAAG4D;EAFI,CAAT;EAKAtC,MAAM,CAAC2C,MAAP,CAAc;IACZI,mBAAmB,CAAC5D,QAAD,EAAWsB,aAAX,EAAuC;MAAA,IAAb/B,MAAa,uEAAJ,EAAI;MACxD,OAAO8B,YAAY,CAACrB,QAAD,EAAWsB,aAAX,EAA0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CA/BM;;;;AAiCA,MAAMsE,gBAAgB,GAAI7D,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
@@ -5,115 +5,44 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _MapperRegistry = _interopRequireDefault(require("./MapperRegistry"));
9
-
10
- var _Mapper = _interopRequireDefault(require("./Mapper"));
11
-
12
- var _MutableValue = _interopRequireDefault(require("./MutableValue"));
13
-
14
8
  var _NativeReanimated = require("../NativeReanimated/NativeReanimated");
15
9
 
16
10
  var _PlatformChecker = require("../PlatformChecker");
17
11
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
12
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
13
 
22
14
  class JSReanimated extends _NativeReanimated.NativeReanimated {
23
15
  constructor() {
24
16
  super(false);
25
17
 
26
- _defineProperty(this, "_valueSetter", undefined);
27
-
28
- _defineProperty(this, "_renderRequested", false);
29
-
30
- _defineProperty(this, "_mapperRegistry", new _MapperRegistry.default(this));
31
-
32
- _defineProperty(this, "_frames", []);
33
-
34
- _defineProperty(this, "timeProvider", void 0);
18
+ _defineProperty(this, "_valueUnpacker", undefined);
35
19
 
36
20
  if ((0, _PlatformChecker.isJest)()) {
37
- this.timeProvider = {
38
- now: () => global.ReanimatedDataMock.now()
39
- };
21
+ // on node < 16 jest have problems mocking performance.now method which
22
+ // results in the tests failing, since date precision isn't that important
23
+ // for tests, we use Date.now instead
24
+ this.getTimestamp = () => Date.now();
40
25
  } else {
41
- this.timeProvider = {
42
- now: () => window.performance.now()
43
- };
26
+ this.getTimestamp = () => window.performance.now();
44
27
  }
45
28
  }
46
29
 
47
- pushFrame(frame) {
48
- this._frames.push(frame);
49
-
50
- this.maybeRequestRender();
30
+ makeShareableClone(value) {
31
+ return {
32
+ __hostObjectShareableJSRef: value
33
+ };
51
34
  }
52
35
 
53
- getTimestamp() {
54
- return this.timeProvider.now();
36
+ installCoreFunctions(valueUnpacker) {
37
+ this._valueUnpacker = valueUnpacker;
55
38
  }
56
39
 
57
- maybeRequestRender() {
58
- if (!this._renderRequested) {
59
- this._renderRequested = true;
60
- requestAnimationFrame(_timestampMs => {
61
- this._renderRequested = false;
62
-
63
- this._onRender(this.getTimestamp());
64
- });
65
- }
40
+ scheduleOnUI(worklet) {
41
+ // @ts-ignore web implementation has still not been updated after the rewrite, this will be addressed once the web implementation updates are ready
42
+ requestAnimationFrame(worklet);
66
43
  }
67
44
 
68
- _onRender(timestampMs) {
69
- this._mapperRegistry.execute();
70
-
71
- const frames = [...this._frames];
72
- this._frames = [];
73
-
74
- for (let i = 0, len = frames.length; i < len; ++i) {
75
- frames[i](timestampMs);
76
- }
77
-
78
- if (this._mapperRegistry.needRunOnRender) {
79
- this._mapperRegistry.execute();
80
- }
81
- }
82
-
83
- installCoreFunctions(valueSetter) {
84
- this._valueSetter = valueSetter;
85
- }
86
-
87
- makeShareable(value) {
88
- return value;
89
- }
90
-
91
- makeMutable(value) {
92
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
93
- return new _MutableValue.default(value, this._valueSetter);
94
- }
95
-
96
- makeRemote() {
97
- let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
98
- return object;
99
- }
100
-
101
- startMapper(mapper) {
102
- let inputs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
103
- let outputs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
104
- const instance = new _Mapper.default(this, mapper, inputs, outputs);
105
-
106
- const mapperId = this._mapperRegistry.startMapper(instance);
107
-
108
- this.maybeRequestRender();
109
- return mapperId;
110
- }
111
-
112
- stopMapper(mapperId) {
113
- this._mapperRegistry.stopMapper(mapperId);
114
- }
115
-
116
- registerEventHandler(_, __) {
45
+ registerEventHandler(_eventHash, _eventHandler) {
117
46
  // noop
118
47
  return '';
119
48
  }
@@ -133,19 +62,6 @@ class JSReanimated extends _NativeReanimated.NativeReanimated {
133
62
  unregisterSensor() {// noop
134
63
  }
135
64
 
136
- jestResetModule() {
137
- if ((0, _PlatformChecker.isJest)()) {
138
- /**
139
- * If someone used timers to stop animation before the end,
140
- * then _renderRequested was set as true
141
- * and any new update from another test wasn't applied.
142
- */
143
- this._renderRequested = false;
144
- } else {
145
- throw Error('This method can be only use in Jest testing.');
146
- }
147
- }
148
-
149
65
  subscribeForKeyboardEvents(_) {
150
66
  console.warn('[Reanimated] useAnimatedKeyboard is not available on web yet.');
151
67
  return -1;
@@ -1 +1 @@
1
- {"version":3,"names":["JSReanimated","NativeReanimated","constructor","undefined","MapperRegistry","isJest","timeProvider","now","global","ReanimatedDataMock","window","performance","pushFrame","frame","_frames","push","maybeRequestRender","getTimestamp","_renderRequested","requestAnimationFrame","_timestampMs","_onRender","timestampMs","_mapperRegistry","execute","frames","i","len","length","needRunOnRender","installCoreFunctions","valueSetter","_valueSetter","makeShareable","value","makeMutable","MutableValue","makeRemote","object","startMapper","mapper","inputs","outputs","instance","Mapper","mapperId","stopMapper","registerEventHandler","_","__","unregisterEventHandler","enableLayoutAnimations","console","warn","registerSensor","unregisterSensor","jestResetModule","Error","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents"],"sources":["JSReanimated.ts"],"sourcesContent":["import MapperRegistry from './MapperRegistry';\nimport Mapper from './Mapper';\nimport MutableValue from './MutableValue';\nimport { NativeReanimated } from '../NativeReanimated/NativeReanimated';\nimport {\n Timestamp,\n NestedObjectValues,\n AnimatedKeyboardInfo,\n} from '../commonTypes';\nimport { isJest } from '../PlatformChecker';\n\nexport default class JSReanimated extends NativeReanimated {\n _valueSetter?: <T>(value: T) => void = undefined;\n\n _renderRequested = false;\n _mapperRegistry: MapperRegistry<any> = new MapperRegistry(this);\n _frames: ((timestamp: Timestamp) => void)[] = [];\n timeProvider: { now: () => number };\n\n constructor() {\n super(false);\n if (isJest()) {\n this.timeProvider = { now: () => global.ReanimatedDataMock.now() };\n } else {\n this.timeProvider = { now: () => window.performance.now() };\n }\n }\n\n pushFrame(frame: (timestamp: Timestamp) => void): void {\n this._frames.push(frame);\n this.maybeRequestRender();\n }\n\n getTimestamp(): number {\n return this.timeProvider.now();\n }\n\n maybeRequestRender(): void {\n if (!this._renderRequested) {\n this._renderRequested = true;\n\n requestAnimationFrame((_timestampMs) => {\n this._renderRequested = false;\n\n this._onRender(this.getTimestamp());\n });\n }\n }\n\n _onRender(timestampMs: number): void {\n this._mapperRegistry.execute();\n\n const frames = [...this._frames];\n this._frames = [];\n\n for (let i = 0, len = frames.length; i < len; ++i) {\n frames[i](timestampMs);\n }\n\n if (this._mapperRegistry.needRunOnRender) {\n this._mapperRegistry.execute();\n }\n }\n\n installCoreFunctions(valueSetter: <T>(value: T) => void): void {\n this._valueSetter = valueSetter;\n }\n\n makeShareable<T>(value: T): T {\n return value;\n }\n\n makeMutable<T>(value: T): MutableValue<T> {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return new MutableValue(value, this._valueSetter!);\n }\n\n makeRemote<T>(object = {}): T {\n return object as T;\n }\n\n startMapper(\n mapper: () => void,\n inputs: NestedObjectValues<MutableValue<unknown>>[] = [],\n outputs: NestedObjectValues<MutableValue<unknown>>[] = []\n ): number {\n const instance = new Mapper(this, mapper, inputs, outputs);\n const mapperId = this._mapperRegistry.startMapper(instance);\n this.maybeRequestRender();\n return mapperId;\n }\n\n stopMapper(mapperId: number): void {\n this._mapperRegistry.stopMapper(mapperId);\n }\n\n registerEventHandler<T>(_: string, __: (event: T) => void): string {\n // noop\n return '';\n }\n\n unregisterEventHandler(_: string): void {\n // noop\n }\n\n enableLayoutAnimations() {\n console.warn(\n '[Reanimated] enableLayoutAnimations is not available for WEB yet'\n );\n }\n\n registerSensor(): number {\n console.warn('[Reanimated] useAnimatedSensor is not available on web yet.');\n return -1;\n }\n\n unregisterSensor(): void {\n // noop\n }\n\n jestResetModule() {\n if (isJest()) {\n /**\n * If someone used timers to stop animation before the end,\n * then _renderRequested was set as true\n * and any new update from another test wasn't applied.\n */\n this._renderRequested = false;\n } else {\n throw Error('This method can be only use in Jest testing.');\n }\n }\n\n subscribeForKeyboardEvents(_: AnimatedKeyboardInfo): number {\n console.warn(\n '[Reanimated] useAnimatedKeyboard is not available on web yet.'\n );\n return -1;\n }\n\n unsubscribeFromKeyboardEvents(_: number): void {\n // noop\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAMA;;;;;;AAEe,MAAMA,YAAN,SAA2BC,kCAA3B,CAA4C;EAQzDC,WAAW,GAAG;IACZ,MAAM,KAAN;;IADY,sCAPyBC,SAOzB;;IAAA,0CALK,KAKL;;IAAA,yCAJyB,IAAIC,uBAAJ,CAAmB,IAAnB,CAIzB;;IAAA,iCAHgC,EAGhC;;IAAA;;IAEZ,IAAI,IAAAC,uBAAA,GAAJ,EAAc;MACZ,KAAKC,YAAL,GAAoB;QAAEC,GAAG,EAAE,MAAMC,MAAM,CAACC,kBAAP,CAA0BF,GAA1B;MAAb,CAApB;IACD,CAFD,MAEO;MACL,KAAKD,YAAL,GAAoB;QAAEC,GAAG,EAAE,MAAMG,MAAM,CAACC,WAAP,CAAmBJ,GAAnB;MAAb,CAApB;IACD;EACF;;EAEDK,SAAS,CAACC,KAAD,EAA8C;IACrD,KAAKC,OAAL,CAAaC,IAAb,CAAkBF,KAAlB;;IACA,KAAKG,kBAAL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AW,IAAX,EAAiBJ,MAAjB,EAAyBC,MAAzB,EAAiCC,OAAjC,CAAjB;;IACA,MAAMG,QAAQ,GAAG,KAAKtB,eAAL,CAAqBgB,WAArB,CAAiCI,QAAjC,CAAjB;;IACA,KAAK3B,kBAAL;IACA,OAAO6B,QAAP;EACD;;EAEDC,UAAU,CAACD,QAAD,EAAyB;IACjC,KAAKtB,eAAL,CAAqBuB,UAArB,CAAgCD,QAAhC;EACD;;EAEDE,oBAAoB,CAAIC,CAAJ,EAAeC,EAAf,EAA+C;IACjE;IACA,OAAO,EAAP;EACD;;EAEDC,sBAAsB,CAACF,CAAD,EAAkB,CACtC;EACD;;EAEDG,sBAAsB,GAAG;IACvBC,OAAO,CAACC,IAAR,CACE,kEADF;EAGD;;EAEDC,cAAc,GAAW;IACvBF,OAAO,CAACC,IAAR,CAAa,6DAAb;IACA,OAAO,CAAC,CAAR;EACD;;EAEDE,gBAAgB,GAAS,CACvB;EACD;;EAEDC,eAAe,GAAG;IAChB,IAAI,IAAAnD,uBAAA,GAAJ,EAAc;MACZ;AACN;AACA;AACA;AACA;MACM,KAAKa,gBAAL,GAAwB,KAAxB;IACD,CAPD,MAOO;MACL,MAAMuC,KAAK,CAAC,8CAAD,CAAX;IACD;EACF;;EAEDC,0BAA0B,CAACV,CAAD,EAAkC;IAC1DI,OAAO,CAACC,IAAR,CACE,+DADF;IAGA,OAAO,CAAC,CAAR;EACD;;EAEDM,6BAA6B,CAACX,CAAD,EAAkB,CAC7C;EACD;;AAnIwD"}
1
+ {"version":3,"names":["JSReanimated","NativeReanimated","constructor","undefined","isJest","getTimestamp","Date","now","window","performance","makeShareableClone","value","__hostObjectShareableJSRef","installCoreFunctions","valueUnpacker","_valueUnpacker","scheduleOnUI","worklet","requestAnimationFrame","registerEventHandler","_eventHash","_eventHandler","unregisterEventHandler","_","enableLayoutAnimations","console","warn","registerSensor","unregisterSensor","subscribeForKeyboardEvents","unsubscribeFromKeyboardEvents"],"sources":["JSReanimated.ts"],"sourcesContent":["import { NativeReanimated } from '../NativeReanimated/NativeReanimated';\nimport { ShareableRef } from '../commonTypes';\nimport { isJest } from '../PlatformChecker';\n\nexport default class JSReanimated extends NativeReanimated {\n _valueUnpacker?: <T>(value: T) => void = undefined;\n\n constructor() {\n super(false);\n if (isJest()) {\n // on node < 16 jest have problems mocking performance.now method which\n // results in the tests failing, since date precision isn't that important\n // for tests, we use Date.now instead\n this.getTimestamp = () => Date.now();\n } else {\n this.getTimestamp = () => window.performance.now();\n }\n }\n\n makeShareableClone<T>(value: T): ShareableRef<T> {\n return { __hostObjectShareableJSRef: value };\n }\n\n installCoreFunctions(valueUnpacker: <T>(value: T) => T): void {\n this._valueUnpacker = valueUnpacker;\n }\n\n scheduleOnUI<T>(worklet: ShareableRef<T>) {\n // @ts-ignore web implementation has still not been updated after the rewrite, this will be addressed once the web implementation updates are ready\n requestAnimationFrame(worklet);\n }\n\n registerEventHandler<T>(\n _eventHash: string,\n _eventHandler: ShareableRef<T>\n ): string {\n // noop\n return '';\n }\n\n unregisterEventHandler(_: string): void {\n // noop\n }\n\n enableLayoutAnimations() {\n console.warn(\n '[Reanimated] enableLayoutAnimations is not available for WEB yet'\n );\n }\n\n registerSensor(): number {\n console.warn('[Reanimated] useAnimatedSensor is not available on web yet.');\n return -1;\n }\n\n unregisterSensor(): void {\n // noop\n }\n\n subscribeForKeyboardEvents(_: ShareableRef<number>): number {\n console.warn(\n '[Reanimated] useAnimatedKeyboard is not available on web yet.'\n );\n return -1;\n }\n\n unsubscribeFromKeyboardEvents(_: number): void {\n // noop\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEe,MAAMA,YAAN,SAA2BC,kCAA3B,CAA4C;EAGzDC,WAAW,GAAG;IACZ,MAAM,KAAN;;IADY,wCAF2BC,SAE3B;;IAEZ,IAAI,IAAAC,uBAAA,GAAJ,EAAc;MACZ;MACA;MACA;MACA,KAAKC,YAAL,GAAoB,MAAMC,IAAI,CAACC,GAAL,EAA1B;IACD,CALD,MAKO;MACL,KAAKF,YAAL,GAAoB,MAAMG,MAAM,CAACC,WAAP,CAAmBF,GAAnB,EAA1B;IACD;EACF;;EAEDG,kBAAkB,CAAIC,KAAJ,EAA+B;IAC/C,OAAO;MAAEC,0BAA0B,EAAED;IAA9B,CAAP;EACD;;EAEDE,oBAAoB,CAACC,aAAD,EAA0C;IAC5D,KAAKC,cAAL,GAAsBD,aAAtB;EACD;;EAEDE,YAAY,CAAIC,OAAJ,EAA8B;IACxC;IACAC,qBAAqB,CAACD,OAAD,CAArB;EACD;;EAEDE,oBAAoB,CAClBC,UADkB,EAElBC,aAFkB,EAGV;IACR;IACA,OAAO,EAAP;EACD;;EAEDC,sBAAsB,CAACC,CAAD,EAAkB,CACtC;EACD;;EAEDC,sBAAsB,GAAG;IACvBC,OAAO,CAACC,IAAR,CACE,kEADF;EAGD;;EAEDC,cAAc,GAAW;IACvBF,OAAO,CAACC,IAAR,CAAa,6DAAb;IACA,OAAO,CAAC,CAAR;EACD;;EAEDE,gBAAgB,GAAS,CACvB;EACD;;EAEDC,0BAA0B,CAACN,CAAD,EAAkC;IAC1DE,OAAO,CAACC,IAAR,CACE,+DADF;IAGA,OAAO,CAAC,CAAR;EACD;;EAEDI,6BAA6B,CAACP,CAAD,EAAkB,CAC7C;EACD;;AAhEwD"}
@@ -11,6 +11,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
11
11
 
12
12
  const reanimatedJS = new _JSReanimated.default();
13
13
 
14
+ global._makeShareableClone = c => c;
15
+
16
+ global._scheduleOnJS = setImmediate;
17
+ global._getTimestamp = reanimatedJS.getTimestamp.bind(reanimatedJS);
18
+
14
19
  const _updatePropsJS = (updates, viewRef) => {
15
20
  if (viewRef._component) {
16
21
  const component = viewRef._component;
@@ -1 +1 @@
1
- {"version":3,"names":["reanimatedJS","JSReanimated","_updatePropsJS","updates","viewRef","_component","component","rawStyles","Object","keys","reduce","acc","key","value","index","setNativeProps","props","length","forEach","dashedKey","replace","m","toLowerCase","_touchableNode","setAttribute","console","warn","style","previousStyle","currentStyle"],"sources":["index.ts"],"sourcesContent":["import JSReanimated from './JSReanimated';\nimport { AnimatedStyle, StyleProps } from '../commonTypes';\n\nconst reanimatedJS = new JSReanimated();\n\ninterface JSReanimatedComponent {\n previousStyle: StyleProps;\n setNativeProps: (style: StyleProps) => void;\n props: Record<string, string | number>;\n _touchableNode: {\n setAttribute: (key: string, props: unknown) => void;\n };\n}\n\nexport const _updatePropsJS = (\n updates: StyleProps | AnimatedStyle,\n viewRef: { _component?: JSReanimatedComponent }\n): void => {\n if (viewRef._component) {\n const component = viewRef._component;\n const [rawStyles] = Object.keys(updates).reduce(\n (acc: [StyleProps, AnimatedStyle], key) => {\n const value = updates[key];\n const index = typeof value === 'function' ? 1 : 0;\n acc[index][key] = value;\n return acc;\n },\n [{}, {}]\n );\n\n if (typeof component.setNativeProps === 'function') {\n setNativeProps(component, rawStyles);\n } else if (Object.keys(component.props).length > 0) {\n Object.keys(component.props).forEach((key) => {\n if (!rawStyles[key]) {\n return;\n }\n const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n component._touchableNode.setAttribute(dashedKey, rawStyles[key]);\n });\n } else {\n console.warn('It is not possible to manipulate component');\n }\n }\n};\n\nconst setNativeProps = (\n component: JSReanimatedComponent,\n style: StyleProps\n): void => {\n const previousStyle = component.previousStyle ? component.previousStyle : {};\n const currentStyle = { ...previousStyle, ...style };\n component.previousStyle = currentStyle;\n component.setNativeProps({ style: currentStyle });\n};\n\nexport default reanimatedJS;\n"],"mappings":";;;;;;;AAAA;;;;AAGA,MAAMA,YAAY,GAAG,IAAIC,qBAAJ,EAArB;;AAWO,MAAMC,cAAc,GAAG,CAC5BC,OAD4B,EAE5BC,OAF4B,KAGnB;EACT,IAAIA,OAAO,CAACC,UAAZ,EAAwB;IACtB,MAAMC,SAAS,GAAGF,OAAO,CAACC,UAA1B;IACA,MAAM,CAACE,SAAD,IAAcC,MAAM,CAACC,I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AAS,CAACsB,aAAV,GAA0BC,YAA1B;EACAvB,SAAS,CAACS,cAAV,CAAyB;IAAEY,KAAK,EAAEE;EAAT,CAAzB;AACD,CARD;;eAUe7B,Y"}
1
+ {"version":3,"names":["reanimatedJS","JSReanimated","global","_makeShareableClone","c","_scheduleOnJS","setImmediate","_getTimestamp","getTimestamp","bind","_updatePropsJS","updates","viewRef","_component","component","rawStyles","Object","keys","reduce","acc","key","value","index","setNativeProps","props","length","forEach","dashedKey","replace","m","toLowerCase","_touchableNode","setAttribute","console","warn","style","previousStyle","currentStyle"],"sources":["index.ts"],"sourcesContent":["import JSReanimated from './JSReanimated';\nimport { AnimatedStyle, StyleProps } from '../commonTypes';\n\nconst reanimatedJS = new JSReanimated();\n\nglobal._makeShareableClone = (c) => c;\nglobal._scheduleOnJS = setImmediate;\nglobal._getTimestamp = reanimatedJS.getTimestamp.bind(reanimatedJS);\n\ninterface JSReanimatedComponent {\n previousStyle: StyleProps;\n setNativeProps: (style: StyleProps) => void;\n props: Record<string, string | number>;\n _touchableNode: {\n setAttribute: (key: string, props: unknown) => void;\n };\n}\n\nexport const _updatePropsJS = (\n updates: StyleProps | AnimatedStyle,\n viewRef: { _component?: JSReanimatedComponent }\n): void => {\n if (viewRef._component) {\n const component = viewRef._component;\n const [rawStyles] = Object.keys(updates).reduce(\n (acc: [StyleProps, AnimatedStyle], key) => {\n const value = updates[key];\n const index = typeof value === 'function' ? 1 : 0;\n acc[index][key] = value;\n return acc;\n },\n [{}, {}]\n );\n\n if (typeof component.setNativeProps === 'function') {\n setNativeProps(component, rawStyles);\n } else if (Object.keys(component.props).length > 0) {\n Object.keys(component.props).forEach((key) => {\n if (!rawStyles[key]) {\n return;\n }\n const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n component._touchableNode.setAttribute(dashedKey, rawStyles[key]);\n });\n } else {\n console.warn('It is not possible to manipulate component');\n }\n }\n};\n\nconst setNativeProps = (\n component: JSReanimatedComponent,\n style: StyleProps\n): void => {\n const previousStyle = component.previousStyle ? component.previousStyle : {};\n const currentStyle = { ...previousStyle, ...style };\n component.previousStyle = currentStyle;\n component.setNativeProps({ style: currentStyle });\n};\n\nexport default reanimatedJS;\n"],"mappings":";;;;;;;AAAA;;;;AAGA,MAAMA,YAAY,GAAG,IAAIC,qBAAJ,EAArB;;AAEAC,MAAM,CAACC,mBAAP,GAA8BC,CAAD,IAAOA,CAApC;;AACAF,MAAM,CAACG,aAAP,GAAuBC,YAAvB;AACAJ,MAAM,CAACK,aAAP,GAAuBP,YAAY,CAACQ,YAAb,CAA0BC,IAA1B,CAA+BT,YAA/B,CAAvB;;AAWO,MAAMU,cAAc,GAAG,CAC5BC,OAD4B,EAE5BC,OAF4B,KAGnB;EACT,IAAIA,OAAO,CAACC,UAAZ,EAAwB;IACtB,MAAMC,SAAS,GAAGF,OAAO,CAACC,UAA1B;IACA,MAAM,CAACE,SAAD,IAAcC,MAAM,CAACC,IAAP,CAAYN,OAAZ,EAAqBO,MAArB,CAClB,CAACC,GAAD,EAAmCC,GAAnC,KAA2C;MACzC,MAAMC,KAAK,GAAGV,OAAO,CAACS,GAAD,CAArB;MACA,MAAME,KAAK,GAAG,OAAOD,KAAP,KAAiB,UAAjB,GAA8B,CAA9B,GAAkC,CAAhD;MACAF,GAAG,CAACG,KAAD,CAAH,CAAWF,GAAX,IAAkBC,KAAlB;MACA,OAAOF,GAAP;IACD,CANiB,EAOlB,CAAC,EAAD,EAAK,EAAL,CAPkB,CAApB;;IAUA,IAAI,OAAOL,SAAS,CAACS,cAAjB,KAAoC,UAAxC,EAAoD;MAClDA,cAAc,CAACT,SAAD,EAAYC,SAAZ,CAAd;IACD,CAFD,MAEO,IAAIC,MAAM,CAACC,IAAP,CAAYH,SAAS,CAACU,KAAtB,EAA6BC,MAA7B,GAAsC,CAA1C,EAA6C;MAClDT,MAAM,CAACC,IAAP,CAAYH,SAAS,CAACU,KAAtB,EAA6BE,OAA7B,CAAsCN,GAAD,IAAS;QAC5C,IAAI,CAACL,SAAS,CAACK,GAAD,CAAd,EAAqB;UACnB;QACD;;QACD,MAAMO,SAAS,GAAGP,GAAG,CAACQ,OAAJ,CAAY,QAAZ,EAAuBC,CAAD,IAAO,MAAMA,CAAC,CAACC,WAAF,EAAnC,CAAlB;;QACAhB,SAAS,CAACiB,cAAV,CAAyBC,YAAzB,CAAsCL,SAAtC,EAAiDZ,SAAS,CAACK,GAAD,CAA1D;MACD,CAND;IAOD,CARM,MAQA;MACLa,OAAO,CAACC,IAAR,CAAa,4CAAb;IACD;EACF;AACF,CA9BM;;;;AAgCP,MAAMX,cAAc,GAAG,CACrBT,SADqB,EAErBqB,KAFqB,KAGZ;EACT,MAAMC,aAAa,GAAGtB,SAAS,CAACsB,aAAV,GAA0BtB,SAAS,CAACsB,aAApC,GAAoD,EAA1E;EACA,MAAMC,YAAY,GAAG,EAAE,GAAGD,aAAL;IAAoB,GAAGD;EAAvB,CAArB;EACArB,SAAS,CAACsB,aAAV,GAA0BC,YAA1B;EACAvB,SAAS,CAACS,cAAV,CAAyB;IAAEY,KAAK,EAAEE;EAAT,CAAzB;AACD,CARD;;eAUerC,Y"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { EasingFn } from '../../Easing';\nimport { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFn;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n}\n\nexport type EntryExitAnimationFunction = (\n targetValues: EntryAnimationsValues | ExitAnimationsValues\n) => LayoutAnimation;\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport interface ILayoutAnimationBuilder {\n build: () => LayoutAnimationFunction;\n}\n\nexport interface BaseLayoutAnimationConfig {\n duration?: number;\n easing?: EasingFn;\n type?: AnimationFunction;\n damping?: number;\n mass?: number;\n stiffness?: number;\n overshootClamping?: number;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n}\n\nexport interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {\n rotate?: number | string;\n}\n\nexport type LayoutAnimationAndConfig = [\n AnimationFunction,\n BaseBuilderAnimationConfig\n];\n\nexport interface IEntryExitAnimationBuilder {\n build: () => EntryExitAnimationFunction;\n}\n\nexport interface IEntryAnimationBuilder {\n build: () => AnimationConfigFunction<EntryAnimationsValues>;\n}\n\nexport interface IExitAnimationBuilder {\n build: () => AnimationConfigFunction<ExitAnimationsValues>;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { EasingFn } from '../../Easing';\nimport { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFn;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n}\n\nexport type EntryExitAnimationFunction = (\n targetValues: EntryAnimationsValues | ExitAnimationsValues\n) => LayoutAnimation;\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport type LayoutAnimationStartFunction = (\n tag: number,\n type: string,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n) => void;\n\nexport interface ILayoutAnimationBuilder {\n build: () => LayoutAnimationFunction;\n}\n\nexport interface BaseLayoutAnimationConfig {\n duration?: number;\n easing?: EasingFn;\n type?: AnimationFunction;\n damping?: number;\n mass?: number;\n stiffness?: number;\n overshootClamping?: number;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n}\n\nexport interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {\n rotate?: number | string;\n}\n\nexport type LayoutAnimationAndConfig = [\n AnimationFunction,\n BaseBuilderAnimationConfig\n];\n\nexport interface IEntryExitAnimationBuilder {\n build: () => EntryExitAnimationFunction;\n}\n\nexport interface IEntryAnimationBuilder {\n build: () => AnimationConfigFunction<EntryAnimationsValues>;\n}\n\nexport interface IExitAnimationBuilder {\n build: () => AnimationConfigFunction<ExitAnimationsValues>;\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BaseAnimationBuilder } from './BaseAnimationBuilder';\nexport { ComplexAnimationBuilder } from './ComplexAnimationBuilder';\nexport { Keyframe } from './Keyframe';\nexport type {\n LayoutAnimation,\n AnimationFunction,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n AnimationConfigFunction,\n IEntryAnimationBuilder,\n IExitAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n ILayoutAnimationBuilder,\n BaseLayoutAnimationConfig,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n IEntryExitAnimationBuilder,\n} from './commonTypes';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BaseAnimationBuilder } from './BaseAnimationBuilder';\nexport { ComplexAnimationBuilder } from './ComplexAnimationBuilder';\nexport { Keyframe } from './Keyframe';\nexport type {\n LayoutAnimation,\n AnimationFunction,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n AnimationConfigFunction,\n IEntryAnimationBuilder,\n IExitAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n LayoutAnimationStartFunction,\n ILayoutAnimationBuilder,\n BaseLayoutAnimationConfig,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n IEntryExitAnimationBuilder,\n} from './commonTypes';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ var _core = require("../core");
4
+
5
+ var _styleAnimation = require("../animation/styleAnimation");
6
+
7
+ var _reactNative = require("react-native");
8
+
9
+ var _mutables = require("../mutables");
10
+
11
+ _reactNative.LogBox.ignoreLogs(['Overriding previous layout animation with']);
12
+
13
+ const TAG_OFFSET = 1e9;
14
+
15
+ function startObservingProgress(tag, sharedValue) {
16
+ 'worklet';
17
+
18
+ sharedValue.addListener(tag + TAG_OFFSET, () => {
19
+ _notifyAboutProgress(tag, sharedValue.value);
20
+ });
21
+ }
22
+
23
+ function stopObservingProgress(tag, sharedValue, cancelled, removeView) {
24
+ 'worklet';
25
+
26
+ sharedValue.removeListener(tag + TAG_OFFSET);
27
+
28
+ _notifyAboutEnd(tag, cancelled, removeView);
29
+ }
30
+
31
+ function createLayoutAnimationManager() {
32
+ 'worklet';
33
+
34
+ const enteringAnimationForTag = new Map();
35
+ const mutableValuesForTag = new Map();
36
+ return {
37
+ start(tag, type, yogaValues, config) {
38
+ const style = config(yogaValues);
39
+ let currentAnimation = style.animations;
40
+
41
+ if (type === 'entering') {
42
+ enteringAnimationForTag.set(tag, currentAnimation);
43
+ } else if (type === 'layout') {
44
+ // When layout animation is requested, but entering is still running, we merge
45
+ // new layout animation targets into the ongoing animation
46
+ const enteringAnimation = enteringAnimationForTag.get(tag);
47
+
48
+ if (enteringAnimation) {
49
+ currentAnimation = { ...enteringAnimation,
50
+ ...style.animations
51
+ };
52
+ }
53
+ }
54
+
55
+ let value = mutableValuesForTag.get(tag);
56
+
57
+ if (value === undefined) {
58
+ value = (0, _mutables.makeUIMutable)(style.initialValues);
59
+ mutableValuesForTag.set(tag, value);
60
+ } else {
61
+ stopObservingProgress(tag, value, false, false);
62
+ value._value = style.initialValues;
63
+ } // @ts-ignore The line below started failing because I added types to the method – don't have time to fix it right now
64
+
65
+
66
+ const animation = (0, _styleAnimation.withStyleAnimation)(currentAnimation);
67
+
68
+ animation.callback = finished => {
69
+ if (finished) {
70
+ enteringAnimationForTag.delete(tag);
71
+ mutableValuesForTag.delete(tag);
72
+ const shouldRemoveView = type === 'exiting';
73
+ stopObservingProgress(tag, value, finished, shouldRemoveView);
74
+ }
75
+
76
+ style.callback && style.callback(finished === undefined ? false : finished);
77
+ };
78
+
79
+ startObservingProgress(tag, value);
80
+ value.value = animation;
81
+ }
82
+
83
+ };
84
+ }
85
+
86
+ (0, _core.runOnUI)(() => {
87
+ 'worklet';
88
+
89
+ global.LayoutAnimationsManager = createLayoutAnimationManager();
90
+ })();
91
+ //# sourceMappingURL=animationsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LogBox","ignoreLogs","TAG_OFFSET","startObservingProgress","tag","sharedValue","addListener","_notifyAboutProgress","value","stopObservingProgress","cancelled","removeView","removeListener","_notifyAboutEnd","createLayoutAnimationManager","enteringAnimationForTag","Map","mutableValuesForTag","start","type","yogaValues","config","style","currentAnimation","animations","set","enteringAnimation","get","undefined","makeUIMutable","initialValues","_value","animation","withStyleAnimation","callback","finished","delete","shouldRemoveView","runOnUI","global","LayoutAnimationsManager"],"sources":["animationsManager.ts"],"sourcesContent":["import { runOnUI } from '../core';\nimport { withStyleAnimation } from '../animation/styleAnimation';\nimport { LogBox } from 'react-native';\nimport { SharedValue } from '../commonTypes';\nimport { makeUIMutable } from '../mutables';\nimport {\n LayoutAnimationFunction,\n LayoutAnimationsValues,\n} from './animationBuilder';\n\nLogBox.ignoreLogs(['Overriding previous layout animation with']);\n\nconst TAG_OFFSET = 1e9;\n\nfunction startObservingProgress(\n tag: number,\n sharedValue: SharedValue<number>\n): void {\n 'worklet';\n sharedValue.addListener(tag + TAG_OFFSET, () => {\n _notifyAboutProgress(tag, sharedValue.value);\n });\n}\n\nfunction stopObservingProgress(\n tag: number,\n sharedValue: SharedValue<number>,\n cancelled: boolean,\n removeView: boolean\n): void {\n 'worklet';\n sharedValue.removeListener(tag + TAG_OFFSET);\n _notifyAboutEnd(tag, cancelled, removeView);\n}\n\nfunction createLayoutAnimationManager() {\n 'worklet';\n const enteringAnimationForTag = new Map();\n const mutableValuesForTag = new Map();\n\n return {\n start(\n tag: number,\n type: string,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n ) {\n const style = config(yogaValues);\n let currentAnimation = style.animations;\n\n if (type === 'entering') {\n enteringAnimationForTag.set(tag, currentAnimation);\n } else if (type === 'layout') {\n // When layout animation is requested, but entering is still running, we merge\n // new layout animation targets into the ongoing animation\n const enteringAnimation = enteringAnimationForTag.get(tag);\n if (enteringAnimation) {\n currentAnimation = { ...enteringAnimation, ...style.animations };\n }\n }\n\n let value = mutableValuesForTag.get(tag);\n if (value === undefined) {\n value = makeUIMutable(style.initialValues);\n mutableValuesForTag.set(tag, value);\n } else {\n stopObservingProgress(tag, value, false, false);\n value._value = style.initialValues;\n }\n\n // @ts-ignore The line below started failing because I added types to the method – don't have time to fix it right now\n const animation = withStyleAnimation(currentAnimation);\n\n animation.callback = (finished?: boolean) => {\n if (finished) {\n enteringAnimationForTag.delete(tag);\n mutableValuesForTag.delete(tag);\n const shouldRemoveView = type === 'exiting';\n stopObservingProgress(tag, value, finished, shouldRemoveView);\n }\n style.callback &&\n style.callback(finished === undefined ? false : finished);\n };\n\n startObservingProgress(tag, value);\n value.value = animation;\n },\n };\n}\n\nrunOnUI(() => {\n 'worklet';\n global.LayoutAnimationsManager = createLayoutAnimationManager();\n})();\n"],"mappings":";;AAAA;;AACA;;AACA;;AAEA;;AAMAA,mBAAA,CAAOC,UAAP,CAAkB,CAAC,2CAAD,CAAlB;;AAEA,MAAMC,UAAU,GAAG,GAAnB;;AAEA,SAASC,sBAAT,CACEC,GADF,EAEEC,WAFF,EAGQ;EACN;;EACAA,WAAW,CAACC,WAAZ,CAAwBF,GAAG,GAAGF,UAA9B,EAA0C,MAAM;IAC9CK,oBAAoB,CAACH,GAAD,EAAMC,WAAW,CAACG,KAAlB,CAApB;EACD,CAFD;AAGD;;AAED,SAASC,qBAAT,CACEL,GADF,EAEEC,WAFF,EAGEK,SAHF,EAIEC,UAJF,EAKQ;EACN;;EACAN,WAAW,CAACO,cAAZ,CAA2BR,GAAG,GAAGF,UAAjC;;EACAW,eAAe,CAACT,GAAD,EAAMM,SAAN,EAAiBC,UAAjB,CAAf;AACD;;AAED,SAASG,4BAAT,GAAwC;EACtC;;EACA,MAAMC,uBAAuB,GAAG,IAAIC,GAAJ,EAAh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C,gBAAgB,GAAGlB,IAAI,KAAK,SAAlC;UACAV,qBAAqB,CAACL,GAAD,EAAMI,KAAN,EAAa2B,QAAb,EAAuBE,gBAAvB,CAArB;QACD;;QACDf,KAAK,CAACY,QAAN,IACEZ,KAAK,CAACY,QAAN,CAAeC,QAAQ,KAAKP,SAAb,GAAyB,KAAzB,GAAiCO,QAAhD,CADF;MAED,CATD;;MAWAhC,sBAAsB,CAACC,GAAD,EAAMI,KAAN,CAAtB;MACAA,KAAK,CAACA,KAAN,GAAcwB,SAAd;IACD;;EA9CI,CAAP;AAgDD;;AAED,IAAAM,aAAA,EAAQ,MAAM;EACZ;;EACAC,MAAM,CAACC,uBAAP,GAAiC1B,4BAA4B,EAA7D;AACD,CAHD"}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- require("./LayoutAnimationRepository");
7
+ require("./animationsManager");
8
8
 
9
9
  var _animationBuilder = require("./animationBuilder");
10
10
 
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './LayoutAnimationRepository';\nexport * from './animationBuilder';\nexport * from './defaultAnimations';\nexport * from './defaultTransitions';\n"],"mappings":";;;;;;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './animationsManager';\nexport * from './animationBuilder';\nexport * from './defaultAnimations';\nexport * from './defaultTransitions';\n"],"mappings":";;;;;;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}