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

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 (72) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +17 -12
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.h +2 -2
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +2 -2
  4. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +30 -0
  5. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +1 -1
  6. package/Common/cpp/SharedItems/Shareables.cpp +3 -1
  7. package/Common/cpp/SharedItems/Shareables.h +37 -22
  8. package/Common/cpp/Tools/RuntimeDecorator.cpp +26 -25
  9. package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
  10. package/ios/LayoutReanimation/REAAnimationsManager.h +3 -1
  11. package/ios/LayoutReanimation/REAAnimationsManager.m +49 -16
  12. package/ios/LayoutReanimation/REAUIManager.mm +22 -62
  13. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +2 -2
  14. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  15. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  16. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  17. package/lib/commonjs/reanimated2/core.js +6 -74
  18. package/lib/commonjs/reanimated2/core.js.map +1 -1
  19. package/lib/commonjs/reanimated2/errors.js +66 -0
  20. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  21. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  22. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +0 -10
  23. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  24. package/lib/commonjs/reanimated2/initializers.js +157 -0
  25. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  26. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +1 -6
  27. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  28. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -7
  29. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  30. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +0 -4
  31. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  32. package/lib/commonjs/reanimated2/mock.js +26 -0
  33. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  34. package/lib/commonjs/reanimated2/shareables.js +6 -0
  35. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  36. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +2 -2
  37. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  38. package/lib/module/reanimated2/component/FlatList.js +18 -4
  39. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  40. package/lib/module/reanimated2/core.js +3 -74
  41. package/lib/module/reanimated2/core.js.map +1 -1
  42. package/lib/module/reanimated2/errors.js +58 -0
  43. package/lib/module/reanimated2/errors.js.map +1 -0
  44. package/lib/module/reanimated2/globals.d.js.map +1 -1
  45. package/lib/module/reanimated2/hook/useAnimatedStyle.js +2 -12
  46. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  47. package/lib/module/reanimated2/initializers.js +143 -0
  48. package/lib/module/reanimated2/initializers.js.map +1 -0
  49. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +1 -6
  50. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  51. package/lib/module/reanimated2/js-reanimated/global.js +4 -7
  52. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  53. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +0 -2
  54. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  55. package/lib/module/reanimated2/mock.js +26 -0
  56. package/lib/module/reanimated2/mock.js.map +1 -1
  57. package/lib/module/reanimated2/shareables.js +6 -1
  58. package/lib/module/reanimated2/shareables.js.map +1 -1
  59. package/package.json +3 -2
  60. package/plugin.js +81 -15
  61. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +11 -2
  62. package/src/reanimated2/component/FlatList.tsx +30 -5
  63. package/src/reanimated2/core.ts +3 -66
  64. package/src/reanimated2/errors.ts +57 -0
  65. package/src/reanimated2/globals.d.ts +22 -3
  66. package/src/reanimated2/hook/useAnimatedStyle.ts +1 -11
  67. package/src/reanimated2/initializers.ts +143 -0
  68. package/src/reanimated2/js-reanimated/JSReanimated.ts +8 -4
  69. package/src/reanimated2/js-reanimated/global.ts +4 -7
  70. package/src/reanimated2/layoutReanimation/animationsManager.ts +0 -3
  71. package/src/reanimated2/mock.ts +105 -0
  72. package/src/reanimated2/shareables.ts +7 -0
@@ -1 +1 @@
1
- {"version":3,"names":["NativeReanimated","isJest","JSReanimated","constructor","undefined","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,SAASA,gBAAT,QAAiC,sCAAjC;AAEA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,eAAe,MAAMC,YAAN,SAA2BF,gBAA3B,CAA4C;EAGzDG,WAAW,GAAG;IACZ,MAAM,KAAN;;IADY,wCAF2BC,SAE3B;;IAEZ,IAAIH,MAAM,EAAV,EAAc;MACZ;MACA;MACA;MACA,KAAKI,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"}
1
+ {"version":3,"names":["NativeReanimated","isJest","JSReanimated","constructor","getTimestamp","Date","now","window","performance","makeShareableClone","value","__hostObjectShareableJSRef","installCoreFunctions","_callGuard","_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 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(\n _callGuard: <T extends Array<any>, U>(\n fn: (...args: T) => U,\n ...args: T\n ) => void,\n _valueUnpacker: <T>(value: T) => T\n ): void {\n // noop\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,SAASA,gBAAT,QAAiC,sCAAjC;AAEA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,eAAe,MAAMC,YAAN,SAA2BF,gBAA3B,CAA4C;EACzDG,WAAW,GAAG;IACZ,MAAM,KAAN;;IACA,IAAIF,MAAM,EAAV,EAAc;MACZ;MACA;MACA;MACA,KAAKG,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,CAClBC,UADkB,EAKlBC,cALkB,EAMZ,CACN;EACD;;EAEDC,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;;AApEwD"}
@@ -5,9 +5,6 @@ const initializeGlobalsForWeb = () => {
5
5
  if (shouldBeUseWeb()) {
6
6
  global._frameTimestamp = null;
7
7
 
8
- global._setGlobalConsole = _val => {// noop
9
- };
10
-
11
8
  global._measure = () => {
12
9
  console.warn("[Reanimated] You can't use `measure` with Chrome Debugger or with web version");
13
10
  return {
@@ -36,10 +33,10 @@ const initializeGlobalsForWeb = () => {
36
33
  return true;
37
34
  };
38
35
  /*
39
- If a file doesn't export anything, tree shaking doesn't pack
40
- it into the JS bundle. In effect, the code inside of this file
41
- will never execute. That is why we wrapped initialization code
42
- into a function, and we call this one during creating
36
+ If a file doesn't export anything, tree shaking doesn't pack
37
+ it into the JS bundle. In effect, the code inside of this file
38
+ will never execute. That is why we wrapped initialization code
39
+ into a function, and we call this one during creating
43
40
  the module export object.
44
41
  */
45
42
 
@@ -1 +1 @@
1
- {"version":3,"names":["shouldBeUseWeb","initializeGlobalsForWeb","global","_frameTimestamp","_setGlobalConsole","_val","_measure","console","warn","x","y","width","height","pageX","pageY","_scrollTo","_dispatchCommand","_setGestureState"],"sources":["global.ts"],"sourcesContent":["// In order to keep bundle size down, we treat this file as a polyfill for Web.\n\nimport { shouldBeUseWeb } from '../PlatformChecker';\nconst initializeGlobalsForWeb = () => {\n if (shouldBeUseWeb()) {\n global._frameTimestamp = null;\n global._setGlobalConsole = (_val) => {\n // noop\n };\n global._measure = () => {\n console.warn(\n \"[Reanimated] You can't use `measure` with Chrome Debugger or with web version\"\n );\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n };\n };\n global._scrollTo = () => {\n console.warn(\n \"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version\"\n );\n };\n global._dispatchCommand = () => {\n console.warn(\n \"[Reanimated] You can't use `scrollTo` or `dispatchCommand` methods with Chrome Debugger or with web version\"\n );\n };\n global._setGestureState = () => {\n console.warn(\n \"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version\"\n );\n };\n }\n return true;\n};\n\n/*\n If a file doesn't export anything, tree shaking doesn't pack \n it into the JS bundle. In effect, the code inside of this file \n will never execute. That is why we wrapped initialization code \n into a function, and we call this one during creating \n the module export object.\n*/\n\nexport default initializeGlobalsForWeb();\n"],"mappings":"AAAA;AAEA,SAASA,cAAT,QAA+B,oBAA/B;;AACA,MAAMC,uBAAuB,GAAG,MAAM;EACpC,IAAID,cAAc,EAAlB,EAAsB;IACpBE,MAAM,CAACC,eAAP,GAAyB,IAAzB;;IACAD,MAAM,CAACE,iBAAP,GAA4BC,IAAD,IAAU,CACnC;IACD,CAFD;;IAGAH,MAAM,CAACI,QAAP,GAAkB,MAAM;MACtBC,OAAO,CAACC,IAAR,CACE,+EADF;MAGA,OAAO;QACLC,CAAC,EAAE,CADE;QAELC,CAAC,EAAE,CAFE;QAGLC,KAAK,EAAE,CAHF;QAILC,MAAM,EAAE,CAJH;QAKLC,KAAK,EAAE,CALF;QAMLC,KAAK,EAAE;MANF,CAAP;IAQD,CAZD;;IAaAZ,MAAM,CAACa,SAAP,GAAmB,MAAM;MACvBR,OAAO,CAACC,IAAR,CACE,gFADF;IAGD,CAJD;;IAKAN,MAAM,CAACc,gBAAP,GAA0B,MAAM;MAC9BT,OAAO,CAACC,IAAR,CACE,6GADF;IAGD,CAJD;;IAKAN,MAAM,CAACe,gBAAP,GAA0B,MAAM;MAC9BV,OAAO,CAACC,IAAR,CACE,uFADF;IAGD,CAJD;EAKD;;EACD,OAAO,IAAP;AACD,CApCD;AAsCA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEA,eAAeP,uBAAuB,EAAtC"}
1
+ {"version":3,"names":["shouldBeUseWeb","initializeGlobalsForWeb","global","_frameTimestamp","_measure","console","warn","x","y","width","height","pageX","pageY","_scrollTo","_dispatchCommand","_setGestureState"],"sources":["global.ts"],"sourcesContent":["// In order to keep bundle size down, we treat this file as a polyfill for Web.\n\nimport { shouldBeUseWeb } from '../PlatformChecker';\nconst initializeGlobalsForWeb = () => {\n if (shouldBeUseWeb()) {\n global._frameTimestamp = null;\n global._measure = () => {\n console.warn(\n \"[Reanimated] You can't use `measure` with Chrome Debugger or with web version\"\n );\n return {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n };\n };\n global._scrollTo = () => {\n console.warn(\n \"[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version\"\n );\n };\n global._dispatchCommand = () => {\n console.warn(\n \"[Reanimated] You can't use `scrollTo` or `dispatchCommand` methods with Chrome Debugger or with web version\"\n );\n };\n global._setGestureState = () => {\n console.warn(\n \"[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version\"\n );\n };\n }\n return true;\n};\n\n/*\n If a file doesn't export anything, tree shaking doesn't pack\n it into the JS bundle. In effect, the code inside of this file\n will never execute. That is why we wrapped initialization code\n into a function, and we call this one during creating\n the module export object.\n*/\n\nexport default initializeGlobalsForWeb();\n"],"mappings":"AAAA;AAEA,SAASA,cAAT,QAA+B,oBAA/B;;AACA,MAAMC,uBAAuB,GAAG,MAAM;EACpC,IAAID,cAAc,EAAlB,EAAsB;IACpBE,MAAM,CAACC,eAAP,GAAyB,IAAzB;;IACAD,MAAM,CAACE,QAAP,GAAkB,MAAM;MACtBC,OAAO,CAACC,IAAR,CACE,+EADF;MAGA,OAAO;QACLC,CAAC,EAAE,CADE;QAELC,CAAC,EAAE,CAFE;QAGLC,KAAK,EAAE,CAHF;QAILC,MAAM,EAAE,CAJH;QAKLC,KAAK,EAAE,CALF;QAMLC,KAAK,EAAE;MANF,CAAP;IAQD,CAZD;;IAaAV,MAAM,CAACW,SAAP,GAAmB,MAAM;MACvBR,OAAO,CAACC,IAAR,CACE,gFADF;IAGD,CAJD;;IAKAJ,MAAM,CAACY,gBAAP,GAA0B,MAAM;MAC9BT,OAAO,CAACC,IAAR,CACE,6GADF;IAGD,CAJD;;IAKAJ,MAAM,CAACa,gBAAP,GAA0B,MAAM;MAC9BV,OAAO,CAACC,IAAR,CACE,uFADF;IAGD,CAJD;EAKD;;EACD,OAAO,IAAP;AACD,CAjCD;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEA,eAAeL,uBAAuB,EAAtC"}
@@ -1,8 +1,6 @@
1
1
  import { runOnUI } from '../core';
2
2
  import { withStyleAnimation } from '../animation/styleAnimation';
3
- import { LogBox } from 'react-native';
4
3
  import { makeUIMutable } from '../mutables';
5
- LogBox.ignoreLogs(['Overriding previous layout animation with']);
6
4
  const TAG_OFFSET = 1e9;
7
5
 
8
6
  function startObservingProgress(tag, sharedValue) {
@@ -1 +1 @@
1
- {"version":3,"names":["runOnUI","withStyleAnimation","LogBox","makeUIMutable","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","initialValues","_value","animation","callback","finished","delete","shouldRemoveView","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,SAASA,OAAT,QAAwB,SAAxB;AACA,SAASC,kBAAT,QAAmC,6BA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AED,IAAIhB,KAAK,GAAGS,mBAAmB,CAACU,GAApB,CAAwBvB,GAAxB,CAAZ;;MACA,IAAII,KAAK,KAAKoB,SAAd,EAAyB;QACvBpB,KAAK,GAAGR,aAAa,CAACsB,KAAK,CAACO,aAAP,CAArB;QACAZ,mBAAmB,CAACQ,GAApB,CAAwBrB,GAAxB,EAA6BI,KAA7B;MACD,CAHD,MAGO;QACLC,qBAAqB,CAACL,GAAD,EAAMI,KAAN,EAAa,KAAb,EAAoB,KAApB,CAArB;QACAA,KAAK,CAACsB,MAAN,GAAeR,KAAK,CAACO,aAArB;MACD,CAtBD,CAwBA;;;MACA,MAAME,SAAS,GAAGjC,kBAAkB,CAACyB,gBAAD,CAApC;;MAEAQ,SAAS,CAACC,QAAV,GAAsBC,QAAD,IAAwB;QAC3C,IAAIA,QAAJ,EAAc;UACZlB,uBAAuB,CAACmB,MAAxB,CAA+B9B,GAA/B;UACAa,mBAAmB,CAACiB,MAApB,CAA2B9B,GAA3B;UACA,MAAM+B,gBAAgB,GAAGhB,IAAI,KAAK,SAAlC;UACAV,qBAAqB,CAACL,GAAD,EAAMI,KAAN,EAAayB,QAAb,EAAuBE,gBAAvB,CAArB;QACD;;QACDb,KAAK,CAACU,QAAN,IACEV,KAAK,CAACU,QAAN,CAAeC,QAAQ,KAAKL,SAAb,GAAyB,KAAzB,GAAiCK,QAAhD,CADF;MAED,CATD;;MAWA9B,sBAAsB,CAACC,GAAD,EAAMI,KAAN,CAAtB;MACAA,KAAK,CAACA,KAAN,GAAcuB,SAAd;IACD;;EA9CI,CAAP;AAgDD;;AAEDlC,OAAO,CAAC,MAAM;EACZ;;EACAuC,MAAM,CAACC,uBAAP,GAAiCvB,4BAA4B,EAA7D;AACD,CAHM,CAAP"}
1
+ {"version":3,"names":["runOnUI","withStyleAnimation","makeUIMutable","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","initialValues","_value","animation","callback","finished","delete","shouldRemoveView","global","LayoutAnimationsManager"],"sources":["animationsManager.ts"],"sourcesContent":["import { runOnUI } from '../core';\nimport { withStyleAnimation } from '../animation/styleAnimation';\nimport { SharedValue } from '../commonTypes';\nimport { makeUIMutable } from '../mutables';\nimport {\n LayoutAnimationFunction,\n LayoutAnimationsValues,\n} from './animationBuilder';\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,SAASA,OAAT,QAAwB,SAAxB;AACA,SAASC,kBAAT,QAAmC,6BAAnC;AAEA,SAASC,aAAT,QAA8B,aAA9B;AAMA,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,EAAhC;EACA,MAAMC,mBAAmB,GAAG,IAAID,GAAJ,EAA5B;EAEA,OAAO;IACLE,KAAK,CACHd,GADG,EAEHe,IAFG,EAGHC,UAHG,EAIHC,MAJG,EAKH;MACA,MAAMC,KAAK,GAAGD,MAAM,CAACD,UAAD,CAApB;MACA,IAAIG,gBAAgB,GAAGD,KAAK,CAACE,UAA7B;;MAEA,IAAIL,IAAI,KAAK,UAAb,EAAyB;QACvBJ,uBAAuB,CAACU,GAAxB,CAA4BrB,GAA5B,EAAiCmB,gBAAjC;MACD,C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DD;;AAEDhC,OAAO,CAAC,MAAM;EACZ;;EACAqC,MAAM,CAACC,uBAAP,GAAiCvB,4BAA4B,EAA7D;AACD,CAHM,CAAP"}
@@ -8,6 +8,29 @@ const ID = t => t;
8
8
 
9
9
  const IMMEDIATE_CB_INVOCATION = cb => cb();
10
10
 
11
+ class BaseAnimationMock {
12
+ duration(_) {
13
+ return this;
14
+ }
15
+
16
+ delay(_) {
17
+ return this;
18
+ }
19
+
20
+ withCallback(_) {
21
+ return this;
22
+ }
23
+
24
+ randomDelay() {
25
+ return this;
26
+ }
27
+
28
+ withInitialValues() {
29
+ return this;
30
+ }
31
+
32
+ }
33
+
11
34
  const ReanimatedV2 = {
12
35
  useSharedValue: v => ({
13
36
  value: v
@@ -81,6 +104,9 @@ const ReanimatedV2 = {
81
104
  runOnJS: fn => fn,
82
105
  runOnUI: fn => fn
83
106
  };
107
+ ['FadeIn', 'FadeInRight', 'FadeInLeft', 'FadeInUp', 'FadFadeInDown', 'FadeOut', 'FadeOutRight', 'FadeOutLeft', 'FadeOutUp', 'FadeOutDown', 'FlipInYLeft', 'FlipInXDown', 'FlipInYRight', 'FlipInEasyX', 'FlipInEasyY', 'FlipOutXUp', 'FlipOutYLeft', 'FlipOutXDown', 'FlipOutYRight', 'FlipOutEasyX', 'FlipOutEasyY', 'StretchInY', 'StretchOutX', 'StretchOutY', 'SlideInLeft', 'SlideOutRight', 'SlideOutLeft', 'SlideInUp', 'SlideInDown', 'SlideOutUp', 'ZoomInRotate', 'ZoomInLeft', 'ZoomInRight', 'ZoomInUp', 'ZoomInDown', 'ZoomInEasyUp', 'ZoomInEasyDown', 'ZoomOut', 'ZoomOutRotate', 'ZoomOutLeft', 'ZoomOutRight', 'ZoomOutUp', 'ZoomOutDown', 'ZoomOutEasyUp', 'ZoomOutEasyDown', 'BounceInDown', 'BounceInUp', 'BounceInLeft', 'BounceInRight', 'BounceOut', 'BounceOutDown', 'BounceOutUp', 'BounceOutLeft', 'BounceOutRight', 'LightSpeedInLeft', 'LightSpeedOutRight', 'LightSpeedOutLeft', 'PinwheelOut', 'RotateInDownRight', 'RotateInUpLeft', 'RotateInUpRight', 'RotateOutDownLeft', 'RotateOutDownRight', 'RotateOutUpLeft', 'RotateOutUpRight', 'RollInRight', 'RollOutLeft', 'RollOutRight'].forEach(k => Object.assign(ReanimatedV2, {
108
+ [k]: new BaseAnimationMock()
109
+ }));
84
110
  module.exports = { ...ReanimatedV2
85
111
  };
86
112
  //# sourceMappingURL=mock.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NOOP","ID","t","IMMEDIATE_CB_INVOCATION","cb","ReanimatedV2","useSharedValue","v","value","useDerivedValue","a","useAnimatedScrollHandler","useAnimatedGestureHandler","useAnimatedStyle","useAnimatedRef","current","useAnimatedReaction","useAnimatedProps","withTiming","toValue","_","withSpring","withDecay","withDelay","animationValue","withSequence","withRepeat","animation","cancelAnimation","measure","x","y","width","height","pageX","pageY","Easing","linear","ease","quad","cubic","poly","sin","circle","exp","elastic","back","bounce","bezier","factory","bezierFn","in","out","inOut","Extrapolation","EXTEND","CLAMP","IDENTITY","runOnJS","fn","runOnUI","module","exports"],"sources":["mock.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nconst NOOP = () => {\n // noop\n};\nconst ID = (t) => t;\nconst IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();\n\nconst ReanimatedV2 = {\n useSharedValue: (v) => ({ value: v }),\n useDerivedValue: (a) => ({ value: a() }),\n useAnimatedScrollHandler: () => NOOP,\n useAnimatedGestureHandler: () => NOOP,\n useAnimatedStyle: IMMEDIATE_CB_INVOCATION,\n useAnimatedRef: () => ({ current: null }),\n useAnimatedReaction: NOOP,\n useAnimatedProps: IMMEDIATE_CB_INVOCATION,\n\n withTiming: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withSpring: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withDecay: (_, cb) => {\n cb && cb(true);\n return 0;\n },\n withDelay: (_, animationValue) => {\n return animationValue;\n },\n withSequence: (..._animations) => {\n return 0;\n },\n withRepeat: (animation) => {\n return animation;\n },\n cancelAnimation: NOOP,\n measure: () => ({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n }),\n Easing: {\n linear: ID,\n ease: ID,\n quad: ID,\n cubic: ID,\n poly: ID,\n sin: ID,\n circle: ID,\n exp: ID,\n elastic: ID,\n back: ID,\n bounce: ID,\n bezier: () => ({ factory: ID }),\n bezierFn: ID,\n in: ID,\n out: ID,\n inOut: ID,\n },\n Extrapolation: {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n },\n\n runOnJS: (fn) => fn,\n runOnUI: (fn) => fn,\n};\n\nmodule.exports = {\n ...ReanimatedV2,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,MAAM,CACjB;AACD,CAFD;;AAGA,MAAMC,EAAE,GAAIC,CAAD,IAAOA,CAAlB;;AACA,MAAMC,uBAAuB,GAAIC,EAAD,IAAuBA,EAAE,EAAzD;;AAEA,MAAMC,YAAY,GAAG;EACnBC,cAAc,EAAGC,CAAD,KAAQ;IAAEC,KAAK,EAAED;EAAT,CAAR,CADG;EAEnBE,eAAe,EAAGC,CAAD,KAAQ;IAAEF,KAAK,EAAEE,CAAC;EAAV,CAAR,CAFE;EAGnBC,wBAAwB,EAAE,MAAMX,IAHb;EAInBY,yBAAyB,EAAE,MAAMZ,IAJd;EAKnBa,gBAAgB,EAAEV,uBALC;EAMnBW,cAAc,EAAE,OAAO;IAAEC,OAAO,EAAE;EAAX,CAAP,CANG;EAOnBC,mBAAmB,EAAEhB,IAPF;EAQnBiB,gBAAgB,EAAEd,uBARC;EAUnBe,UAAU,EAAE,CAACC,OAAD,EAAUC,CAAV,EAAahB,EAAb,KAAoB;IAC9BA,EAAE,IAAIA,EAAE,CAAC,IAAD,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AAK,EAAEpD;EAhBD,CAxCW;EA0DnBqD,aAAa,EAAE;IACbC,MAAM,EAAE,QADK;IAEbC,KAAK,EAAE,OAFM;IAGbC,QAAQ,EAAE;EAHG,CA1DI;EAgEnBC,OAAO,EAAGC,EAAD,IAAQA,EAhEE;EAiEnBC,OAAO,EAAGD,EAAD,IAAQA;AAjEE,CAArB;AAoEAE,MAAM,CAACC,OAAP,GAAiB,EACf,GAAGzD;AADY,CAAjB"}
1
+ {"version":3,"names":["NOOP","ID","t","IMMEDIATE_CB_INVOCATION","cb","BaseAnimationMock","duration","_","delay","withCallback","randomDelay","withInitialValues","ReanimatedV2","useSharedValue","v","value","useDerivedValue","a","useAnimatedScrollHandler","useAnimatedGestureHandler","useAnimatedStyle","useAnimatedRef","current","useAnimatedReaction","useAnimatedProps","withTiming","toValue","withSpring","withDecay","withDelay","animationValue","withSequence","withRepeat","animation","cancelAnimation","measure","x","y","width","height","pageX","pageY","Easing","linear","ease","quad","cubic","poly","sin","circle","exp","elastic","back","bounce","bezier","factory","bezierFn","in","out","inOut","Extrapolation","EXTEND","CLAMP","IDENTITY","runOnJS","fn","runOnUI","forEach","k","Object","assign","module","exports"],"sources":["mock.ts"],"sourcesContent":["/* eslint-disable node/no-callback-literal */\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nconst NOOP = () => {\n // noop\n};\nconst ID = (t) => t;\nconst IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();\n\nclass BaseAnimationMock {\n duration(_: number) {\n return this;\n }\n\n delay(_: number) {\n return this;\n }\n\n withCallback(_: (finsihed: boolean) => void) {\n return this;\n }\n\n randomDelay() {\n return this;\n }\n\n withInitialValues() {\n return this;\n }\n}\n\nconst ReanimatedV2 = {\n useSharedValue: (v) => ({ value: v }),\n useDerivedValue: (a) => ({ value: a() }),\n useAnimatedScrollHandler: () => NOOP,\n useAnimatedGestureHandler: () => NOOP,\n useAnimatedStyle: IMMEDIATE_CB_INVOCATION,\n useAnimatedRef: () => ({ current: null }),\n useAnimatedReaction: NOOP,\n useAnimatedProps: IMMEDIATE_CB_INVOCATION,\n\n withTiming: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withSpring: (toValue, _, cb) => {\n cb && cb(true);\n return toValue;\n },\n withDecay: (_, cb) => {\n cb && cb(true);\n return 0;\n },\n withDelay: (_, animationValue) => {\n return animationValue;\n },\n withSequence: (..._animations) => {\n return 0;\n },\n withRepeat: (animation) => {\n return animation;\n },\n cancelAnimation: NOOP,\n measure: () => ({\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n pageX: 0,\n pageY: 0,\n }),\n Easing: {\n linear: ID,\n ease: ID,\n quad: ID,\n cubic: ID,\n poly: ID,\n sin: ID,\n circle: ID,\n exp: ID,\n elastic: ID,\n back: ID,\n bounce: ID,\n bezier: () => ({ factory: ID }),\n bezierFn: ID,\n in: ID,\n out: ID,\n inOut: ID,\n },\n Extrapolation: {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n },\n\n runOnJS: (fn) => fn,\n runOnUI: (fn) => fn,\n};\n\n[\n 'FadeIn',\n 'FadeInRight',\n 'FadeInLeft',\n 'FadeInUp',\n 'FadFadeInDown',\n 'FadeOut',\n 'FadeOutRight',\n 'FadeOutLeft',\n 'FadeOutUp',\n 'FadeOutDown',\n\n 'FlipInYLeft',\n 'FlipInXDown',\n 'FlipInYRight',\n 'FlipInEasyX',\n 'FlipInEasyY',\n 'FlipOutXUp',\n 'FlipOutYLeft',\n 'FlipOutXDown',\n 'FlipOutYRight',\n 'FlipOutEasyX',\n 'FlipOutEasyY',\n\n 'StretchInY',\n 'StretchOutX',\n 'StretchOutY',\n 'SlideInLeft',\n 'SlideOutRight',\n 'SlideOutLeft',\n 'SlideInUp',\n 'SlideInDown',\n 'SlideOutUp',\n\n 'ZoomInRotate',\n 'ZoomInLeft',\n 'ZoomInRight',\n 'ZoomInUp',\n 'ZoomInDown',\n 'ZoomInEasyUp',\n 'ZoomInEasyDown',\n 'ZoomOut',\n 'ZoomOutRotate',\n 'ZoomOutLeft',\n 'ZoomOutRight',\n 'ZoomOutUp',\n 'ZoomOutDown',\n 'ZoomOutEasyUp',\n 'ZoomOutEasyDown',\n\n 'BounceInDown',\n 'BounceInUp',\n 'BounceInLeft',\n 'BounceInRight',\n 'BounceOut',\n 'BounceOutDown',\n 'BounceOutUp',\n 'BounceOutLeft',\n 'BounceOutRight',\n\n 'LightSpeedInLeft',\n 'LightSpeedOutRight',\n 'LightSpeedOutLeft',\n\n 'PinwheelOut',\n\n 'RotateInDownRight',\n 'RotateInUpLeft',\n 'RotateInUpRight',\n 'RotateOutDownLeft',\n 'RotateOutDownRight',\n 'RotateOutUpLeft',\n 'RotateOutUpRight',\n\n 'RollInRight',\n 'RollOutLeft',\n 'RollOutRight',\n].forEach((k) =>\n Object.assign(ReanimatedV2, {\n [k]: new BaseAnimationMock(),\n })\n);\n\nmodule.exports = {\n ...ReanimatedV2,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,MAAM,CACjB;AACD,CAFD;;AAGA,MAAMC,EAAE,GAAIC,CAAD,IAAOA,CAAlB;;AACA,MAAMC,uBAAuB,GAAIC,EAAD,IAAuBA,EAAE,EAAzD;;AAEA,MAAMC,iBAAN,CAAwB;EACtBC,QAAQ,CAACC,CAAD,EAAY;IAClB,OAAO,IAAP;EACD;;EAEDC,KAAK,CAACD,CAAD,EAAY;IACf,OAAO,IAAP;EACD;;EAEDE,YAAY,CAACF,CAAD,EAAiC;IAC3C,OAAO,IAAP;EACD;;EAEDG,WAAW,GAAG;IACZ,OAAO,IAAP;EACD;;EAEDC,iBAAiB,GAAG;IAClB,OAAO,IAAP;EACD;;AAnBqB;;AAsBxB,MAAMC,YAAY,GAAG;EACnBC,cAAc,EAAGC,CAAD,KAAQ;IAAEC,KAAK,EAAED;EAAT,CAAR,CADG;EAEnBE,eAAe,EAAGC,CAAD,KAAQ;IAAEF,KAAK,EA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mDE,YAnDF,EAoDE,cApDF,EAqDE,eArDF,EAsDE,WAtDF,EAuDE,eAvDF,EAwDE,aAxDF,EAyDE,eAzDF,EA0DE,gBA1DF,EA4DE,kBA5DF,EA6DE,oBA7DF,EA8DE,mBA9DF,EAgEE,aAhEF,EAkEE,mBAlEF,EAmEE,gBAnEF,EAoEE,iBApEF,EAqEE,mBArEF,EAsEE,oBAtEF,EAuEE,iBAvEF,EAwEE,kBAxEF,EA0EE,aA1EF,EA2EE,aA3EF,EA4EE,cA5EF,EA6EEE,OA7EF,CA6EWC,CAAD,IACRC,MAAM,CAACC,MAAP,CAAc1D,YAAd,EAA4B;EAC1B,CAACwD,CAAD,GAAK,IAAI/D,iBAAJ;AADqB,CAA5B,CA9EF;AAmFAkE,MAAM,CAACC,OAAP,GAAiB,EACf,GAAG5D;AADY,CAAjB"}
@@ -1,5 +1,6 @@
1
1
  import NativeReanimatedModule from './NativeReanimated';
2
- import { shouldBeUseWeb } from './PlatformChecker'; // for web/chrome debugger/jest environments this file provides a stub implementation
2
+ import { shouldBeUseWeb } from './PlatformChecker';
3
+ import { registerWorkletStackDetails } from './errors'; // for web/chrome debugger/jest environments this file provides a stub implementation
3
4
  // where no shareable references are used. Instead, the objects themselves are used
4
5
  // instead of shareable references, because of the fact that we don't have to deal with
5
6
  // runnning the code on separate VMs.
@@ -48,6 +49,10 @@ export function makeShareableCloneRecursive(value) {
48
49
  // this is a remote function
49
50
  toAdapt = value;
50
51
  } else {
52
+ if (__DEV__ && value.__workletHash !== undefined) {
53
+ registerWorkletStackDetails(value.__workletHash, value.__stackDetails);
54
+ }
55
+
51
56
  toAdapt = {};
52
57
 
53
58
  for (const [key, element] of Object.entries(value)) {
@@ -1 +1 @@
1
- {"version":3,"names":["NativeReanimatedModule","shouldBeUseWeb","USE_STUB_IMPLEMENTATION","_shareableCache","WeakMap","_shareableFlag","Symbol","registerShareableMapping","shareable","shareableRef","set","makeShareableShadowNodeWrapper","shadowNodeWrapper","adoptedSNW","makeShareableClone","makeShareableCloneRecursive","value","type","cached","get","undefined","toAdapt","Array","isArray","map","element","__workletHash","key","Object","entries","__DEV__","freeze","adopted","makeShareableCloneOnUIRecursive","cloneRecursive","_makeShareableClone","makeShareable","handle","__init"],"sources":["shareables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { ShareableRef } from './commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\n\n// for web/chrome debugger/jest environments this file provides a stub implementation\n// where no shareable references are used. Instead, the objects themselves are used\n// instead of shareable references, because of the fact that we don't have to deal with\n// runnning the code on separate VMs.\nconst USE_STUB_IMPLEMENTATION = shouldBeUseWeb();\n\nconst _shareableCache = new WeakMap<\n Record<string, unknown>,\n ShareableRef<any> | symbol\n>();\n// the below symbol is used to represent a mapping from the value to itself\n// this is used to allow for a converted shareable to be passed to makeShareableClone\nconst _shareableFlag = Symbol('shareable flag');\n\nexport function registerShareableMapping(\n shareable: any,\n shareableRef?: ShareableRef<any>\n): void {\n if (USE_STUB_IMPLEMENTATION) {\n return;\n }\n _shareableCache.set(shareable, shareableRef || _shareableFlag);\n}\n\nexport function makeShareableShadowNodeWrapper<T>(shadowNodeWrapper: T): T {\n const adoptedSNW =\n NativeReanimatedModule.makeShareableClone(shadowNodeWrapper);\n registerShareableMapping(shadowNodeWrapper, adoptedSNW);\n return shadowNodeWrapper;\n}\n\nexport function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n const cached = _shareableCache.get(value);\n if (cached === _shareableFlag) {\n return value;\n } else if (cached !== undefined) {\n return cached as ShareableRef<T>;\n } else {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => makeShareableCloneRecursive(element));\n } else if (type === 'function' && value.__workletHash === undefined) {\n // this is a remote function\n toAdapt = value;\n } else {\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = makeShareableCloneRecursive(element);\n }\n }\n if (__DEV__) {\n // we freeze objects that are transformed to shareable. This should help\n // detect issues when someone modifies data after it's been converted to\n // shareable. Meaning that they may be doing a faulty assumption in their\n // code expecting that the updates are going to automatically populate to\n // the object sent to the UI thread. If the user really wants some objects\n // to be mutable they should use share values instead.\n Object.freeze(value);\n }\n const adopted = NativeReanimatedModule.makeShareableClone(toAdapt);\n _shareableCache.set(value, adopted);\n _shareableCache.set(adopted, _shareableFlag);\n return adopted;\n }\n }\n return NativeReanimatedModule.makeShareableClone(value);\n}\n\nexport function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {\n 'worklet';\n if (USE_STUB_IMPLEMENTATION) {\n // @ts-ignore web is an interesting place where we don't run a secondary VM on the UI thread\n // see more details in the comment where USE_STUB_IMPLEMENTATION is defined.\n return value;\n }\n function cloneRecursive<T>(value: T): ShareableRef<T> {\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => cloneRecursive(element));\n } else {\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = cloneRecursive(element);\n }\n }\n if (__DEV__) {\n // See the reasoning behind freezing in the other comment above.\n Object.freeze(value);\n }\n return _makeShareableClone(toAdapt);\n }\n return _makeShareableClone(value);\n }\n return cloneRecursive(value);\n}\n\nexport function makeShareable<T>(value: T): T {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return value;\n },\n });\n registerShareableMapping(value, handle);\n return value;\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AAEA,SAASC,cAAT,QAA+B,mBAA/B,C,CAEA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAGD,cAAc,EAA9C;;AAEA,MAAME,eAAe,GAAG,IAAIC,OAAJ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AAc,CAACT,OAAD,CAA7B;QACD;MACF;;MACD,IAAIK,OAAJ,EAAa;QACX;QACAF,MAAM,CAACG,MAAP,CAAcf,KAAd;MACD;;MACD,OAAOmB,mBAAmB,CAACd,OAAD,CAA1B;IACD;;IACD,OAAOc,mBAAmB,CAACnB,KAAD,CAA1B;EACD;;EACD,OAAOkB,cAAc,CAAClB,KAAD,CAArB;AACD;AAED,OAAO,SAASoB,aAAT,CAA0BpB,KAA1B,EAAuC;EAC5C,IAAId,uBAAJ,EAA6B;IAC3B,OAAOc,KAAP;EACD;;EACD,MAAMqB,MAAM,GAAGtB,2BAA2B,CAAC;IACzCuB,MAAM,EAAE,MAAM;MACZ;;MACA,OAAOtB,KAAP;IACD;EAJwC,CAAD,CAA1C;EAMAT,wBAAwB,CAACS,KAAD,EAAQqB,MAAR,CAAxB;EACA,OAAOrB,KAAP;AACD"}
1
+ {"version":3,"names":["NativeReanimatedModule","shouldBeUseWeb","registerWorkletStackDetails","USE_STUB_IMPLEMENTATION","_shareableCache","WeakMap","_shareableFlag","Symbol","registerShareableMapping","shareable","shareableRef","set","makeShareableShadowNodeWrapper","shadowNodeWrapper","adoptedSNW","makeShareableClone","makeShareableCloneRecursive","value","type","cached","get","undefined","toAdapt","Array","isArray","map","element","__workletHash","__DEV__","__stackDetails","key","Object","entries","freeze","adopted","makeShareableCloneOnUIRecursive","cloneRecursive","_makeShareableClone","makeShareable","handle","__init"],"sources":["shareables.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { ShareableRef } from './commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport { registerWorkletStackDetails } from './errors';\n\n// for web/chrome debugger/jest environments this file provides a stub implementation\n// where no shareable references are used. Instead, the objects themselves are used\n// instead of shareable references, because of the fact that we don't have to deal with\n// runnning the code on separate VMs.\nconst USE_STUB_IMPLEMENTATION = shouldBeUseWeb();\n\nconst _shareableCache = new WeakMap<\n Record<string, unknown>,\n ShareableRef<any> | symbol\n>();\n// the below symbol is used to represent a mapping from the value to itself\n// this is used to allow for a converted shareable to be passed to makeShareableClone\nconst _shareableFlag = Symbol('shareable flag');\n\nexport function registerShareableMapping(\n shareable: any,\n shareableRef?: ShareableRef<any>\n): void {\n if (USE_STUB_IMPLEMENTATION) {\n return;\n }\n _shareableCache.set(shareable, shareableRef || _shareableFlag);\n}\n\nexport function makeShareableShadowNodeWrapper<T>(shadowNodeWrapper: T): T {\n const adoptedSNW =\n NativeReanimatedModule.makeShareableClone(shadowNodeWrapper);\n registerShareableMapping(shadowNodeWrapper, adoptedSNW);\n return shadowNodeWrapper;\n}\n\nexport function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n // This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n const cached = _shareableCache.get(value);\n if (cached === _shareableFlag) {\n return value;\n } else if (cached !== undefined) {\n return cached as ShareableRef<T>;\n } else {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => makeShareableCloneRecursive(element));\n } else if (type === 'function' && value.__workletHash === undefined) {\n // this is a remote function\n toAdapt = value;\n } else {\n if (__DEV__ && value.__workletHash !== undefined) {\n registerWorkletStackDetails(\n value.__workletHash,\n value.__stackDetails\n );\n }\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = makeShareableCloneRecursive(element);\n }\n }\n if (__DEV__) {\n // we freeze objects that are transformed to shareable. This should help\n // detect issues when someone modifies data after it's been converted to\n // shareable. Meaning that they may be doing a faulty assumption in their\n // code expecting that the updates are going to automatically populate to\n // the object sent to the UI thread. If the user really wants some objects\n // to be mutable they should use share values instead.\n Object.freeze(value);\n }\n const adopted = NativeReanimatedModule.makeShareableClone(toAdapt);\n _shareableCache.set(value, adopted);\n _shareableCache.set(adopted, _shareableFlag);\n return adopted;\n }\n }\n return NativeReanimatedModule.makeShareableClone(value);\n}\n\nexport function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {\n 'worklet';\n if (USE_STUB_IMPLEMENTATION) {\n // @ts-ignore web is an interesting place where we don't run a secondary VM on the UI thread\n // see more details in the comment where USE_STUB_IMPLEMENTATION is defined.\n return value;\n }\n function cloneRecursive<T>(value: T): ShareableRef<T> {\n const type = typeof value;\n if ((type === 'object' || type === 'function') && value !== null) {\n let toAdapt: any;\n if (Array.isArray(value)) {\n toAdapt = value.map((element) => cloneRecursive(element));\n } else {\n toAdapt = {};\n for (const [key, element] of Object.entries(value)) {\n toAdapt[key] = cloneRecursive(element);\n }\n }\n if (__DEV__) {\n // See the reasoning behind freezing in the other comment above.\n Object.freeze(value);\n }\n return _makeShareableClone(toAdapt);\n }\n return _makeShareableClone(value);\n }\n return cloneRecursive(value);\n}\n\nexport function makeShareable<T>(value: T): T {\n if (USE_STUB_IMPLEMENTATION) {\n return value;\n }\n const handle = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return value;\n },\n });\n registerShareableMapping(value, handle);\n return value;\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AAEA,SAASC,cAAT,QAA+B,mBAA/B;AACA,SAASC,2BAAT,QAA4C,UAA5C,C,CAEA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAGF,cAAc,EAA9C;;AAEA,MAAMG,eAAe,GAAG,IAAIC,OAAJ,EAAxB,C,CAIA;AACA;;;AACA,MAAMC,cAAc,GAAGC,MAAM,CAAC,gBAAD,CAA7B;;AAEA,OAAO,SAASC,wBAAT,CACLC,SADK,EAELC,YAFK,EAGC;EACN,IAAIP,uBAAJ,EAA6B;IAC3B;EACD;;EACDC,eAAe,CAACO,GAAhB,CAAoBF,SAApB,EAA+BC,YAAY,IAAIJ,cAA/C;AACD;AAED,OAAO,SAASM,8BAAT,CAA2CC,iBAA3C,EAAoE;EACzE,MAAMC,UAAU,GACdd,sBAAsB,CAACe,kBAAvB,CAA0CF,iBAA1C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AAOmB,cAAc,CAACnB,KAAD,CAArB;AACD;AAED,OAAO,SAASqB,aAAT,CAA0BrB,KAA1B,EAAuC;EAC5C,IAAId,uBAAJ,EAA6B;IAC3B,OAAOc,KAAP;EACD;;EACD,MAAMsB,MAAM,GAAGvB,2BAA2B,CAAC;IACzCwB,MAAM,EAAE,MAAM;MACZ;;MACA,OAAOvB,KAAP;IACD;EAJwC,CAAD,CAA1C;EAMAT,wBAAwB,CAACS,KAAD,EAAQsB,MAAR,CAAxB;EACA,OAAOtB,KAAP;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "3.0.0-rc.8",
3
+ "version": "3.0.0-rc.9",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
@@ -79,7 +79,8 @@
79
79
  "invariant": "^2.2.4",
80
80
  "lodash.isequal": "^4.5.0",
81
81
  "setimmediate": "^1.0.5",
82
- "string-hash-64": "^1.0.3"
82
+ "string-hash-64": "^1.0.3",
83
+ "convert-source-map": "^1.7.0"
83
84
  },
84
85
  "peerDependencies": {
85
86
  "@babel/core": "^7.0.0-0",
package/plugin.js CHANGED
@@ -4,6 +4,7 @@ const hash = require('string-hash-64');
4
4
  const traverse = require('@babel/traverse').default;
5
5
  const { transformSync } = require('@babel/core');
6
6
  const fs = require('fs');
7
+ const convertSourceMap = require('convert-source-map');
7
8
  /**
8
9
  * holds a map of function names as keys and array of argument indexes as values which should be automatically workletized(they have to be functions)(starting from 0)
9
10
  */
@@ -32,7 +33,6 @@ const globals = new Set([
32
33
  'this',
33
34
  'console',
34
35
  'performance',
35
- '_setGlobalConsole',
36
36
  '_chronoNow',
37
37
  'Date',
38
38
  'Array',
@@ -77,6 +77,7 @@ const globals = new Set([
77
77
  '_removeShadowNodeFromRegistry',
78
78
  'RegExp',
79
79
  'Error',
80
+ 'ErrorUtils',
80
81
  'global',
81
82
  '_measure',
82
83
  '_scrollTo',
@@ -381,10 +382,12 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
381
382
  }
382
383
  }
383
384
 
385
+ const includeSourceMap = shouldGenerateSourceMap();
386
+
384
387
  const transformed = transformSync(code, {
385
388
  plugins: [prependClosureVariablesIfNecessary()],
386
- compact: !shouldGenerateSourceMap(),
387
- sourceMaps: shouldGenerateSourceMap() ? 'inline' : false,
389
+ compact: !includeSourceMap,
390
+ sourceMaps: includeSourceMap,
388
391
  inputSourceMap: inputMap,
389
392
  ast: false,
390
393
  babelrc: false,
@@ -392,7 +395,17 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
392
395
  comments: false,
393
396
  });
394
397
 
395
- return transformed.code;
398
+ let sourceMap;
399
+ if (includeSourceMap) {
400
+ sourceMap = convertSourceMap.fromObject(transformed.map).toObject();
401
+ // sourcesContent field contains a full source code of the file which contains the worklet
402
+ // and is not needed by the source map interpreter in order to symbolicate a stack trace.
403
+ // Therefore, we remove it to reduce the bandwith and avoid sending it potentially multiple times
404
+ // in files that contain multiple worklets. Along with sourcesContent.
405
+ delete sourceMap.sourcesContent;
406
+ }
407
+
408
+ return [transformed.code, JSON.stringify(sourceMap)];
396
409
  }
397
410
 
398
411
  function makeWorkletName(t, fun) {
@@ -405,7 +418,7 @@ function makeWorkletName(t, fun) {
405
418
  if (t.isFunctionExpression(fun) && t.isIdentifier(fun.node.id)) {
406
419
  return fun.node.id.name;
407
420
  }
408
- return '_f'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
421
+ return 'anonymous'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
409
422
  }
410
423
 
411
424
  function makeWorklet(t, fun, state) {
@@ -514,7 +527,7 @@ function makeWorklet(t, fun, state) {
514
527
  funExpression = clone;
515
528
  }
516
529
 
517
- const funString = buildWorkletString(
530
+ const [funString, sourceMapString] = buildWorkletString(
518
531
  t,
519
532
  transformed.ast,
520
533
  variables,
@@ -529,12 +542,14 @@ function makeWorklet(t, fun, state) {
529
542
  location = path.relative(state.cwd, location);
530
543
  }
531
544
 
532
- const loc = fun && fun.node && fun.node.loc && fun.node.loc.start;
533
- if (loc) {
534
- const { line, column } = loc;
535
- if (typeof line === 'number' && typeof column === 'number') {
536
- location = `${location} (${line}:${column})`;
537
- }
545
+ let lineOffset = 1;
546
+ if (closure.size > 0) {
547
+ // When worklet captures some variables, we append closure destructing at
548
+ // the beginning of the function body. This effectively results in line
549
+ // numbers shifting by the number of captured variables (size of the
550
+ // closure) + 2 (for the opening and closing brackets of the destruct
551
+ // statement)
552
+ lineOffset -= closure.size + 2;
538
553
  }
539
554
 
540
555
  const statements = [
@@ -579,6 +594,50 @@ function makeWorklet(t, fun, state) {
579
594
  ),
580
595
  ];
581
596
 
597
+ if (sourceMapString) {
598
+ statements.push(
599
+ t.expressionStatement(
600
+ t.assignmentExpression(
601
+ '=',
602
+ t.memberExpression(
603
+ privateFunctionId,
604
+ t.identifier('__sourceMap'),
605
+ false
606
+ ),
607
+ t.stringLiteral(sourceMapString)
608
+ )
609
+ )
610
+ );
611
+ }
612
+
613
+ if (!isRelease()) {
614
+ statements.unshift(
615
+ t.variableDeclaration('const', [
616
+ t.variableDeclarator(
617
+ t.identifier('_e'),
618
+ t.arrayExpression([
619
+ t.newExpression(t.identifier('Error'), []),
620
+ t.numericLiteral(lineOffset),
621
+ t.numericLiteral(-20), // the placement of opening bracket after Exception in line that defined '_e' variable
622
+ ])
623
+ ),
624
+ ])
625
+ );
626
+ statements.push(
627
+ t.expressionStatement(
628
+ t.assignmentExpression(
629
+ '=',
630
+ t.memberExpression(
631
+ privateFunctionId,
632
+ t.identifier('__stackDetails'),
633
+ false
634
+ ),
635
+ t.identifier('_e')
636
+ )
637
+ )
638
+ );
639
+ }
640
+
582
641
  if (options && options.optFlags) {
583
642
  statements.push(
584
643
  t.expressionStatement(
@@ -782,10 +841,17 @@ function isGestureObject(t, node) {
782
841
  }
783
842
 
784
843
  function processWorklets(t, path, state) {
844
+
845
+ const callee =
846
+ path.node.callee.type === 'SequenceExpression'
847
+ ? path.node.callee.expressions[path.node.callee.expressions.length - 1]
848
+ : path.node.callee;
849
+
785
850
  const name =
786
- path.node.callee.type === 'MemberExpression'
787
- ? path.node.callee.property.name
788
- : path.node.callee.name;
851
+ callee.type === 'MemberExpression'
852
+ ? callee.property.name
853
+ : callee.name;
854
+
789
855
  if (
790
856
  objectHooks.has(name) &&
791
857
  path.get('arguments.0').type === 'ObjectExpression'
@@ -47,8 +47,17 @@ export class NativeReanimated {
47
47
  throw new Error('stub implementation, used on the web only');
48
48
  }
49
49
 
50
- installCoreFunctions(valueUnpacker: <T>(value: T) => T): void {
51
- return this.InnerNativeModule.installCoreFunctions(valueUnpacker);
50
+ installCoreFunctions(
51
+ callGuard: <T extends Array<any>, U>(
52
+ fn: (...args: T) => U,
53
+ ...args: T
54
+ ) => void,
55
+ valueUnpacker: <T>(value: T) => T
56
+ ): void {
57
+ return this.InnerNativeModule.installCoreFunctions(
58
+ callGuard,
59
+ valueUnpacker
60
+ );
52
61
  }
53
62
 
54
63
  makeShareableClone<T>(value: T): ShareableRef<T> {
@@ -1,8 +1,14 @@
1
1
  import React, { ForwardedRef, forwardRef } from 'react';
2
- import { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';
2
+ import {
3
+ FlatList,
4
+ FlatListProps,
5
+ LayoutChangeEvent,
6
+ StyleSheet,
7
+ } from 'react-native';
3
8
  import ReanimatedView from './View';
4
9
  import createAnimatedComponent from '../../createAnimatedComponent';
5
10
  import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
11
+ import { StyleProps } from '../commonTypes';
6
12
 
7
13
  const AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;
8
14
 
@@ -10,12 +16,20 @@ interface AnimatedFlatListProps {
10
16
  onLayout: (event: LayoutChangeEvent) => void;
11
17
  // implicit `children` prop has been removed in @types/react^18.0.0
12
18
  children: React.ReactNode;
19
+ inverted?: boolean;
20
+ horizontal?: boolean;
13
21
  }
14
22
 
15
- const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
23
+ const createCellRenderer = (
24
+ itemLayoutAnimation?: ILayoutAnimationBuilder,
25
+ cellStyle?: StyleProps
26
+ ) => {
16
27
  const cellRenderer = (props: AnimatedFlatListProps) => {
17
28
  return (
18
- <ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>
29
+ <ReanimatedView
30
+ layout={itemLayoutAnimation}
31
+ onLayout={props.onLayout}
32
+ style={cellStyle}>
19
33
  {props.children}
20
34
  </ReanimatedView>
21
35
  );
@@ -34,9 +48,15 @@ const ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(
34
48
  (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {
35
49
  const { itemLayoutAnimation, ...restProps } = props;
36
50
 
51
+ const cellStyle = restProps?.inverted
52
+ ? restProps?.horizontal
53
+ ? styles.horizontallyInverted
54
+ : styles.verticallyInverted
55
+ : undefined;
56
+
37
57
  const cellRenderer = React.useMemo(
38
- () => createCellRenderer(itemLayoutAnimation),
39
- []
58
+ () => createCellRenderer(itemLayoutAnimation, cellStyle),
59
+ [cellStyle]
40
60
  );
41
61
 
42
62
  return (
@@ -49,4 +69,9 @@ const ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(
49
69
  }
50
70
  );
51
71
 
72
+ const styles = StyleSheet.create({
73
+ verticallyInverted: { transform: [{ scaleY: -1 }] },
74
+ horizontallyInverted: { transform: [{ scaleX: -1 }] },
75
+ });
76
+
52
77
  export default ReanimatedFlatlist;
@@ -1,4 +1,3 @@
1
- /* global _setGlobalConsole */
2
1
  import NativeReanimatedModule from './NativeReanimated';
3
2
  import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
4
3
  import { BasicWorkletFunction, Value3D, ValueRotation } from './commonTypes';
@@ -6,25 +5,18 @@ import {
6
5
  makeShareableCloneRecursive,
7
6
  makeShareable as makeShareableUnwrapped,
8
7
  } from './shareables';
9
- import { runOnUI, runOnJS } from './threads';
10
8
  import { startMapper as startMapperUnwrapped } from './mappers';
11
9
  import {
12
10
  makeMutable as makeMutableUnwrapped,
13
11
  makeRemote as makeRemoteUnwrapped,
14
12
  } from './mutables';
15
13
  import { LayoutAnimationFunction } from './layoutReanimation';
14
+ import { initializeUIRuntime } from './initializers';
16
15
 
17
16
  export { stopMapper } from './mappers';
18
17
  export { runOnJS, runOnUI } from './threads';
19
18
  export { getTimestamp } from './time';
20
19
 
21
- if (global._setGlobalConsole === undefined) {
22
- // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
23
- global._setGlobalConsole = () => {
24
- // noop
25
- };
26
- }
27
-
28
20
  export type ReanimatedConsole = Pick<
29
21
  Console,
30
22
  'debug' | 'log' | 'warn' | 'info' | 'error'
@@ -114,49 +106,6 @@ export function getViewProp<T>(viewTag: string, propName: string): Promise<T> {
114
106
  });
115
107
  }
116
108
 
117
- function valueUnpacker(objectToUnpack: any, category?: string): any {
118
- 'worklet';
119
- let workletsCache = global.__workletsCache;
120
- let handleCache = global.__handleCache;
121
- if (workletsCache === undefined) {
122
- // init
123
- workletsCache = global.__workletsCache = new Map();
124
- handleCache = global.__handleCache = new WeakMap();
125
- }
126
- if (objectToUnpack.__workletHash) {
127
- let workletFun = workletsCache.get(objectToUnpack.__workletHash);
128
- if (workletFun === undefined) {
129
- // eslint-disable-next-line no-eval
130
- workletFun = eval('(' + objectToUnpack.asString + '\n)') as (
131
- ...args: any[]
132
- ) => any;
133
- workletsCache.set(objectToUnpack.__workletHash, workletFun);
134
- }
135
- const functionInstance = workletFun.bind(objectToUnpack);
136
- objectToUnpack._recur = functionInstance;
137
- return functionInstance;
138
- } else if (objectToUnpack.__init) {
139
- let value = handleCache!.get(objectToUnpack);
140
- if (value === undefined) {
141
- value = objectToUnpack.__init();
142
- handleCache!.set(objectToUnpack, value);
143
- }
144
- return value;
145
- } else if (category === 'RemoteFunction') {
146
- const fun = () => {
147
- throw new Error(`Tried to synchronously call a non-worklet function on the UI thread.
148
-
149
- Possible solutions are:
150
- a) If you want to synchronously execute this method, mark it as a worklet
151
- b) If you want to execute this function on the JS thread, wrap it using \`runOnJS\``);
152
- };
153
- fun.__remoteFunction = objectToUnpack;
154
- return fun;
155
- } else {
156
- throw new Error('data type not recognized by unpack method');
157
- }
158
- }
159
-
160
109
  export function registerEventHandler<T>(
161
110
  eventHash: string,
162
111
  eventHandler: (event: T) => void
@@ -199,21 +148,9 @@ export function unregisterSensor(listenerId: number): void {
199
148
  return NativeReanimatedModule.unregisterSensor(listenerId);
200
149
  }
201
150
 
202
- NativeReanimatedModule.installCoreFunctions(valueUnpacker);
203
-
151
+ // initialize UI runtime if applicable
204
152
  if (!isWeb() && isConfigured()) {
205
- const capturableConsole = console;
206
- runOnUI(() => {
207
- 'worklet';
208
- const console = {
209
- debug: runOnJS(capturableConsole.debug),
210
- log: runOnJS(capturableConsole.log),
211
- warn: runOnJS(capturableConsole.warn),
212
- error: runOnJS(capturableConsole.error),
213
- info: runOnJS(capturableConsole.info),
214
- };
215
- _setGlobalConsole(console);
216
- })();
153
+ initializeUIRuntime();
217
154
  }
218
155
 
219
156
  type FeaturesConfig = {