react-native-worklets 0.0.1-alpha → 0.1.0

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 (246) hide show
  1. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +71 -0
  2. package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
  3. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +131 -0
  4. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +82 -0
  5. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +72 -0
  6. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +44 -0
  7. package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
  8. package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -0
  9. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
  10. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -0
  11. package/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -0
  12. package/Common/cpp/worklets/SharedItems/Shareables.h +345 -0
  13. package/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -0
  14. package/Common/cpp/worklets/Tools/AsyncQueue.h +35 -0
  15. package/Common/cpp/worklets/Tools/Defs.h +10 -0
  16. package/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
  17. package/Common/cpp/worklets/Tools/JSISerializer.h +47 -0
  18. package/Common/cpp/worklets/Tools/JSLogger.cpp +16 -0
  19. package/Common/cpp/worklets/Tools/JSLogger.h +20 -0
  20. package/Common/cpp/worklets/Tools/JSScheduler.cpp +10 -0
  21. package/Common/cpp/worklets/Tools/JSScheduler.h +29 -0
  22. package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
  23. package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -0
  24. package/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
  25. package/Common/cpp/worklets/Tools/UIScheduler.cpp +19 -0
  26. package/Common/cpp/worklets/Tools/UIScheduler.h +22 -0
  27. package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
  28. package/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
  29. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +26 -0
  30. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +199 -0
  31. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +20 -0
  32. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -0
  33. package/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
  34. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +19 -0
  35. package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +16 -0
  36. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +108 -0
  37. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +127 -0
  38. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +183 -0
  39. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -0
  40. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
  41. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +179 -0
  42. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -0
  43. package/LICENSE +20 -0
  44. package/README.md +27 -0
  45. package/RNWorklets.podspec +70 -0
  46. package/android/CMakeLists.txt +56 -0
  47. package/android/build.gradle +313 -0
  48. package/android/gradle.properties +5 -0
  49. package/android/proguard-rules.pro +3 -0
  50. package/android/spotless.gradle +9 -0
  51. package/android/src/main/AndroidManifest.xml +2 -0
  52. package/android/src/main/cpp/worklets/CMakeLists.txt +85 -0
  53. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +63 -0
  54. package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +41 -0
  55. package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +32 -0
  56. package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +29 -0
  57. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +83 -0
  58. package/android/src/main/cpp/worklets/android/WorkletsModule.h +63 -0
  59. package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +13 -0
  60. package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.java +60 -0
  61. package/android/src/main/java/com/swmansion/worklets/AnimationFrameQueue/AnimationFrameCallback.java +20 -0
  62. package/android/src/main/java/com/swmansion/worklets/AnimationFrameQueue/AnimationFrameQueue.java +113 -0
  63. package/android/src/main/java/com/swmansion/worklets/JSCallInvokerResolver.java +27 -0
  64. package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThread.java +16 -0
  65. package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +72 -0
  66. package/android/src/main/java/com/swmansion/worklets/WorkletsModule.java +106 -0
  67. package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +49 -0
  68. package/android/src/paper/com/swmansion/worklets/NativeWorkletsModuleSpec.java +26 -0
  69. package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
  70. package/apple/worklets/apple/AnimationFrameQueue.mm +81 -0
  71. package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
  72. package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +16 -0
  73. package/apple/worklets/apple/IOSUIScheduler.h +14 -0
  74. package/apple/worklets/apple/IOSUIScheduler.mm +24 -0
  75. package/apple/worklets/apple/PlatformLogger.mm +31 -0
  76. package/apple/worklets/apple/SlowAnimations.h +8 -0
  77. package/apple/worklets/apple/SlowAnimations.mm +47 -0
  78. package/apple/worklets/apple/WorkletsDisplayLink.h +21 -0
  79. package/apple/worklets/apple/WorkletsMessageThread.h +16 -0
  80. package/apple/worklets/apple/WorkletsMessageThread.mm +32 -0
  81. package/apple/worklets/apple/WorkletsModule.h +10 -0
  82. package/apple/worklets/apple/WorkletsModule.mm +85 -0
  83. package/lib/module/PlatformChecker.js +35 -0
  84. package/lib/module/PlatformChecker.js.map +1 -0
  85. package/lib/module/WorkletsError.js +13 -0
  86. package/lib/module/WorkletsError.js.map +1 -0
  87. package/lib/module/WorkletsModule/JSWorklets.js +36 -0
  88. package/lib/module/WorkletsModule/JSWorklets.js.map +1 -0
  89. package/lib/module/WorkletsModule/NativeWorklets.js +39 -0
  90. package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
  91. package/lib/module/WorkletsModule/index.js +4 -0
  92. package/lib/module/WorkletsModule/index.js.map +1 -0
  93. package/lib/module/WorkletsModule/workletsModuleInstance.js +7 -0
  94. package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -0
  95. package/lib/module/WorkletsModule/workletsModuleInstance.web.js +5 -0
  96. package/lib/module/WorkletsModule/workletsModuleInstance.web.js.map +1 -0
  97. package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
  98. package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
  99. package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js +10 -0
  100. package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js.map +1 -0
  101. package/lib/module/animationFrameQueue/requestAnimationFrame.js +36 -0
  102. package/lib/module/animationFrameQueue/requestAnimationFrame.js.map +1 -0
  103. package/lib/module/errors.js +78 -0
  104. package/lib/module/errors.js.map +1 -0
  105. package/lib/module/index.js +17 -0
  106. package/lib/module/index.js.map +1 -0
  107. package/lib/module/initializers.js +158 -0
  108. package/lib/module/initializers.js.map +1 -0
  109. package/lib/module/logger/LogBox.js +15 -0
  110. package/lib/module/logger/LogBox.js.map +1 -0
  111. package/lib/module/logger/index.js +5 -0
  112. package/lib/module/logger/index.js.map +1 -0
  113. package/lib/module/logger/logger.js +137 -0
  114. package/lib/module/logger/logger.js.map +1 -0
  115. package/lib/module/privateGlobals.d.js +8 -0
  116. package/lib/module/privateGlobals.d.js.map +1 -0
  117. package/lib/module/runtimes.js +63 -0
  118. package/lib/module/runtimes.js.map +1 -0
  119. package/lib/module/shareableMappingCache.js +39 -0
  120. package/lib/module/shareableMappingCache.js.map +1 -0
  121. package/lib/module/shareables.js +417 -0
  122. package/lib/module/shareables.js.map +1 -0
  123. package/lib/module/specs/NativeWorkletsModule.js +5 -0
  124. package/lib/module/specs/NativeWorkletsModule.js.map +1 -0
  125. package/lib/module/specs/index.js +5 -0
  126. package/lib/module/specs/index.js.map +1 -0
  127. package/lib/module/threads.js +204 -0
  128. package/lib/module/threads.js.map +1 -0
  129. package/lib/module/valueUnpacker.js +83 -0
  130. package/lib/module/valueUnpacker.js.map +1 -0
  131. package/lib/module/workletFunction.js +37 -0
  132. package/lib/module/workletFunction.js.map +1 -0
  133. package/lib/module/workletTypes.js +12 -0
  134. package/lib/module/workletTypes.js.map +1 -0
  135. package/lib/typescript/PlatformChecker.d.ts +7 -0
  136. package/lib/typescript/PlatformChecker.d.ts.map +1 -0
  137. package/lib/typescript/WorkletsError.d.ts +3 -0
  138. package/lib/typescript/WorkletsError.d.ts.map +1 -0
  139. package/lib/typescript/WorkletsModule/JSWorklets.d.ts +3 -0
  140. package/lib/typescript/WorkletsModule/JSWorklets.d.ts.map +1 -0
  141. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +5 -0
  142. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -0
  143. package/lib/typescript/WorkletsModule/index.d.ts +3 -0
  144. package/lib/typescript/WorkletsModule/index.d.ts.map +1 -0
  145. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +2 -0
  146. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -0
  147. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +2 -0
  148. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -0
  149. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +12 -0
  150. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
  151. package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts +6 -0
  152. package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts.map +1 -0
  153. package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts +2 -0
  154. package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts.map +1 -0
  155. package/lib/typescript/errors.d.ts +19 -0
  156. package/lib/typescript/errors.d.ts.map +1 -0
  157. package/lib/typescript/index.d.ts +13 -0
  158. package/lib/typescript/index.d.ts.map +1 -0
  159. package/lib/typescript/initializers.d.ts +6 -0
  160. package/lib/typescript/initializers.d.ts.map +1 -0
  161. package/lib/typescript/logger/LogBox.d.ts +32 -0
  162. package/lib/typescript/logger/LogBox.d.ts.map +1 -0
  163. package/lib/typescript/logger/index.d.ts +3 -0
  164. package/lib/typescript/logger/index.d.ts.map +1 -0
  165. package/lib/typescript/logger/logger.d.ts +52 -0
  166. package/lib/typescript/logger/logger.d.ts.map +1 -0
  167. package/lib/typescript/runtimes.d.ts +16 -0
  168. package/lib/typescript/runtimes.d.ts.map +1 -0
  169. package/lib/typescript/shareableMappingCache.d.ts +16 -0
  170. package/lib/typescript/shareableMappingCache.d.ts.map +1 -0
  171. package/lib/typescript/shareables.d.ts +15 -0
  172. package/lib/typescript/shareables.d.ts.map +1 -0
  173. package/lib/typescript/specs/NativeWorkletsModule.d.ts +7 -0
  174. package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
  175. package/lib/typescript/specs/index.d.ts +3 -0
  176. package/lib/typescript/specs/index.d.ts.map +1 -0
  177. package/lib/typescript/threads.d.ts +49 -0
  178. package/lib/typescript/threads.d.ts.map +1 -0
  179. package/lib/typescript/valueUnpacker.d.ts +2 -0
  180. package/lib/typescript/valueUnpacker.d.ts.map +1 -0
  181. package/lib/typescript/workletFunction.d.ts +27 -0
  182. package/lib/typescript/workletFunction.d.ts.map +1 -0
  183. package/lib/typescript/workletTypes.d.ts +49 -0
  184. package/lib/typescript/workletTypes.d.ts.map +1 -0
  185. package/package.json +106 -8
  186. package/plugin/index.js +3 -0
  187. package/scripts/worklets_utils.rb +53 -0
  188. package/src/PlatformChecker.ts +43 -0
  189. package/src/WorkletsError.ts +13 -0
  190. package/src/WorkletsModule/JSWorklets.ts +57 -0
  191. package/src/WorkletsModule/NativeWorklets.ts +68 -0
  192. package/src/WorkletsModule/index.ts +7 -0
  193. package/src/WorkletsModule/workletsModuleInstance.ts +9 -0
  194. package/src/WorkletsModule/workletsModuleInstance.web.ts +5 -0
  195. package/src/WorkletsModule/workletsModuleProxy.ts +30 -0
  196. package/src/animationFrameQueue/mockedRequestAnimationFrame.ts +11 -0
  197. package/src/animationFrameQueue/requestAnimationFrame.ts +41 -0
  198. package/src/errors.ts +103 -0
  199. package/src/index.ts +42 -0
  200. package/src/initializers.ts +175 -0
  201. package/src/logger/LogBox.ts +55 -0
  202. package/src/logger/index.ts +3 -0
  203. package/src/logger/logger.ts +155 -0
  204. package/src/privateGlobals.d.ts +41 -0
  205. package/src/runtimes.ts +92 -0
  206. package/src/shareableMappingCache.ts +44 -0
  207. package/src/shareables.ts +577 -0
  208. package/src/specs/NativeWorkletsModule.ts +9 -0
  209. package/src/specs/index.ts +5 -0
  210. package/src/threads.ts +275 -0
  211. package/src/valueUnpacker.ts +110 -0
  212. package/src/workletFunction.ts +47 -0
  213. package/src/workletTypes.ts +76 -0
  214. package/Animated.js +0 -13
  215. package/AnimatedEvent.js +0 -167
  216. package/AnimatedImplementation.js +0 -666
  217. package/CoreAnimated.js +0 -43
  218. package/Easing.js +0 -236
  219. package/NativeAnimatedHelper.js +0 -226
  220. package/SpringConfig.js +0 -79
  221. package/animations/Animation.js +0 -36
  222. package/animations/DecayAnimation.js +0 -70
  223. package/animations/SpringAnimation.js +0 -125
  224. package/animations/TimingAnimation.js +0 -70
  225. package/bezier.js +0 -128
  226. package/createAnimatedComponent.js +0 -188
  227. package/nodes/AnimatedBlock.js +0 -19
  228. package/nodes/AnimatedClock.js +0 -76
  229. package/nodes/AnimatedCond.js +0 -23
  230. package/nodes/AnimatedDetach.js +0 -15
  231. package/nodes/AnimatedInterpolation.js +0 -338
  232. package/nodes/AnimatedNode.js +0 -97
  233. package/nodes/AnimatedOnChange.js +0 -28
  234. package/nodes/AnimatedOp.js +0 -17
  235. package/nodes/AnimatedProps.js +0 -154
  236. package/nodes/AnimatedSet.js +0 -19
  237. package/nodes/AnimatedStartClock.js +0 -21
  238. package/nodes/AnimatedStopClock.js +0 -21
  239. package/nodes/AnimatedStyle.js +0 -89
  240. package/nodes/AnimatedTracking.js +0 -36
  241. package/nodes/AnimatedTransform.js +0 -93
  242. package/nodes/AnimatedValue.js +0 -271
  243. package/nodes/AnimatedWithInput.js +0 -21
  244. package/nodes/SpringNode.js +0 -106
  245. package/nodes/TimingStep.js +0 -44
  246. package/utils.js +0 -28
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logger/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { LogData } from './LogBox';
2
+ type LogFunction = (data: LogData) => void;
3
+ export declare enum LogLevel {
4
+ warn = 1,
5
+ error = 2
6
+ }
7
+ export type LoggerConfig = {
8
+ level?: LogLevel;
9
+ strict?: boolean;
10
+ };
11
+ export type LoggerConfigInternal = {
12
+ logFunction: LogFunction;
13
+ } & Required<LoggerConfig>;
14
+ export declare const DEFAULT_LOGGER_CONFIG: LoggerConfigInternal;
15
+ /**
16
+ * Function that logs to LogBox and console. Used to replace the default console
17
+ * logging with logging to LogBox on the UI thread when runOnJS is available.
18
+ *
19
+ * @param data - The details of the log.
20
+ */
21
+ export declare function logToLogBoxAndConsole(data: LogData): void;
22
+ /**
23
+ * Registers the logger configuration. use it only for Worklet runtimes.
24
+ *
25
+ * @param config - The config to register.
26
+ */
27
+ export declare function registerLoggerConfig(config: LoggerConfigInternal): void;
28
+ /**
29
+ * Replaces the default log function with a custom implementation.
30
+ *
31
+ * @param logFunction - The custom log function.
32
+ */
33
+ export declare function replaceLoggerImplementation(logFunction: LogFunction): void;
34
+ /**
35
+ * Updates logger configuration.
36
+ *
37
+ * @param options - The new logger configuration to apply.
38
+ *
39
+ * - Level: The minimum log level to display.
40
+ * - Strict: Whether to log warnings and errors that are not strict. Defaults to
41
+ * false.
42
+ */
43
+ export declare function updateLoggerConfig(options?: Partial<LoggerConfig>): void;
44
+ type LogOptions = {
45
+ strict?: boolean;
46
+ };
47
+ export declare const logger: {
48
+ warn(message: string, options?: LogOptions): void;
49
+ error(message: string, options?: LogOptions): void;
50
+ };
51
+ export {};
52
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,OAAO,EAAE,MAAM,UAAU,CAAC;AAOxD,KAAK,WAAW,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;AAE3C,oBAAY,QAAQ;IAClB,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,WAAW,CAAC;CAC1B,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;AAgB3B,eAAO,MAAM,qBAAqB,EAAE,oBAInC,CAAC;AAyBF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,QAGlD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,QAGhE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,QAGnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,QAQjE;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AA0BF,eAAO,MAAM,MAAM;kBACH,MAAM,YAAW,UAAU;mBAI1B,MAAM,YAAW,UAAU;CAI3C,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { WorkletFunction, WorkletRuntime } from './workletTypes';
2
+ /**
3
+ * Lets you create a new JS runtime which can be used to run worklets possibly
4
+ * on different threads than JS or UI thread.
5
+ *
6
+ * @param name - A name used to identify the runtime which will appear in
7
+ * devices list in Chrome DevTools.
8
+ * @param initializer - An optional worklet that will be run synchronously on
9
+ * the same thread immediately after the runtime is created.
10
+ * @returns WorkletRuntime which is a
11
+ * `jsi::HostObject<worklets::WorkletRuntime>` - {@link WorkletRuntime}
12
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/createWorkletRuntime
13
+ */
14
+ export declare function createWorkletRuntime(name: string, initializer?: () => void): WorkletRuntime;
15
+ export declare function runOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>;
16
+ //# sourceMappingURL=runtimes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../../src/runtimes.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAItE;;;;;;;;;;;GAWG;AAEH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,cAAc,CAAC;AAuBlB,wBAAgB,YAAY,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EAC9D,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,GACtC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ShareableRef } from './workletTypes';
2
+ /**
3
+ * This symbol is used to represent a mapping from the value to itself.
4
+ *
5
+ * It's used to prevent converting a shareable that's already converted - for
6
+ * example a Shared Value that's in worklet's closure.
7
+ */
8
+ export declare const shareableMappingFlag: unique symbol;
9
+ export declare const shareableMappingCache: {
10
+ set(): void;
11
+ get(): null;
12
+ } | {
13
+ set(shareable: object, shareableRef?: ShareableRef): void;
14
+ get: (key: object) => symbol | ShareableRef | undefined;
15
+ };
16
+ //# sourceMappingURL=shareableMappingCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shareableMappingCache.d.ts","sourceRoot":"","sources":["../../src/shareableMappingCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAInD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,eAA2B,CAAC;AAiB7D,eAAO,MAAM,qBAAqB;;;;mBAUb,MAAM,iBAAiB,YAAY,GAAG,IAAI;;CAI1D,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { FlatShareableRef, ShareableRef } from './workletTypes';
2
+ export interface MakeShareableClone {
3
+ <T>(value: T, shouldPersistRemote?: boolean, depth?: number): ShareableRef<T>;
4
+ }
5
+ export declare const makeShareableCloneRecursive: MakeShareableClone;
6
+ export declare function makeShareableCloneOnUIRecursive<T>(value: T): FlatShareableRef<T>;
7
+ declare function makeShareableJS<T extends object>(value: T): T;
8
+ /**
9
+ * This function creates a value on UI with persistent state - changes to it on
10
+ * the UI thread will be seen by all worklets. Use it when you want to create a
11
+ * value that is read and written only on the UI thread.
12
+ */
13
+ export declare const makeShareable: typeof makeShareableJS;
14
+ export {};
15
+ //# sourceMappingURL=shareables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shareables.d.ts","sourceRoot":"","sources":["../../src/shareables.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EAGb,MAAM,gBAAgB,CAAC;AAyJxB,MAAM,WAAW,kBAAkB;IACjC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CAC/E;AAED,eAAO,MAAM,2BAA2B,EAAE,kBAEL,CAAC;AA0UtC,wBAAgB,+BAA+B,CAAC,CAAC,EAC/C,KAAK,EAAE,CAAC,GACP,gBAAgB,CAAC,CAAC,CAAC,CA0CrB;AAED,iBAAS,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEtD;AAgBD;;;;GAIG;AACH,eAAO,MAAM,aAAa,wBAEH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { TurboModule } from 'react-native';
2
+ interface Spec extends TurboModule {
3
+ installTurboModule: (valueUnpackerCode: string) => boolean;
4
+ }
5
+ declare const _default: Spec | null;
6
+ export default _default;
7
+ //# sourceMappingURL=NativeWorkletsModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeWorkletsModule.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeWorkletsModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,UAAU,IAAK,SAAQ,WAAW;IAChC,kBAAkB,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5D;;AAED,wBAA+D"}
@@ -0,0 +1,3 @@
1
+ import WorkletsTurboModule from './NativeWorkletsModule';
2
+ export { WorkletsTurboModule };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/specs/index.ts"],"names":[],"mappings":"AAEA,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { WorkletFunction } from './workletTypes';
2
+ export declare function setupMicrotasks(): void;
3
+ export declare const callMicrotasks: () => void;
4
+ /**
5
+ * Lets you asynchronously run
6
+ * [workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize)
7
+ * functions on the [UI
8
+ * thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
9
+ *
10
+ * This method does not schedule the work immediately but instead waits for
11
+ * other worklets to be scheduled within the same JS loop. It uses
12
+ * queueMicrotask to schedule all the worklets at once making sure they will run
13
+ * within the same frame boundaries on the UI thread.
14
+ *
15
+ * @param fun - A reference to a function you want to execute on the [UI
16
+ * thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI)
17
+ * from the [JavaScript
18
+ * thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
19
+ * @returns A function that accepts arguments for the function passed as the
20
+ * first argument.
21
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI
22
+ */
23
+ export declare function runOnUI<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): (...args: Args) => void;
24
+ export declare function executeOnUIRuntimeSync<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): (...args: Args) => ReturnValue;
25
+ export declare function runOnUIImmediately<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>;
26
+ type ReleaseRemoteFunction<Args extends unknown[], ReturnValue> = {
27
+ (...args: Args): ReturnValue;
28
+ };
29
+ type DevRemoteFunction<Args extends unknown[], ReturnValue> = {
30
+ __remoteFunction: (...args: Args) => ReturnValue;
31
+ };
32
+ type RemoteFunction<Args extends unknown[], ReturnValue> = ReleaseRemoteFunction<Args, ReturnValue> | DevRemoteFunction<Args, ReturnValue>;
33
+ /**
34
+ * Lets you asynchronously run
35
+ * non-[workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize)
36
+ * functions that couldn't otherwise run on the [UI
37
+ * thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).
38
+ * This applies to most external libraries as they don't have their functions
39
+ * marked with "worklet"; directive.
40
+ *
41
+ * @param fun - A reference to a function you want to execute on the JavaScript
42
+ * thread from the UI thread.
43
+ * @returns A function that accepts arguments for the function passed as the
44
+ * first argument.
45
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnJS
46
+ */
47
+ export declare function runOnJS<Args extends unknown[], ReturnValue>(fun: ((...args: Args) => ReturnValue) | RemoteFunction<Args, ReturnValue> | WorkletFunction<Args, ReturnValue>): (...args: Args) => void;
48
+ export {};
49
+ //# sourceMappingURL=threads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../src/threads.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQtD,wBAAgB,eAAe,SA0B9B;AAOD,eAAO,MAAM,cAAc,YAIC,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AAGH,wBAAgB,OAAO,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACzD,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,GACtC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AA+D3B,wBAAgB,sBAAsB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACxE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,GACtC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC;AAiBlC,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACpE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,GACtC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AA0BtC,KAAK,qBAAqB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,IAAI;IAChE,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,WAAW,CAAC;CAC9B,CAAC;AAEF,KAAK,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,IAAI;IAC5D,gBAAgB,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC;CAClD,CAAC;AAEF,KAAK,cAAc,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,IACnD,qBAAqB,CAAC,IAAI,EAAE,WAAW,CAAC,GACxC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAUzC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACzD,GAAG,EACC,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC,GAChC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,GACjC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,GACrC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CA8CzB"}
@@ -0,0 +1,2 @@
1
+ export declare function getValueUnpackerCode(): string;
2
+ //# sourceMappingURL=valueUnpacker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueUnpacker.d.ts","sourceRoot":"","sources":["../../src/valueUnpacker.ts"],"names":[],"mappings":"AA2GA,wBAAgB,oBAAoB,WAEnC"}
@@ -0,0 +1,27 @@
1
+ import type { WorkletBaseDev, WorkletBaseRelease, WorkletFunction } from './workletTypes';
2
+ /**
3
+ * This function allows you to determine if a given function is a worklet. It
4
+ * only works with Reanimated Babel plugin enabled. Unless you are doing
5
+ * something with internals of Reanimated you shouldn't need to use this
6
+ * function.
7
+ *
8
+ * ### Note
9
+ *
10
+ * Do not call it before the worklet is declared, as it will always return false
11
+ * then. E.g.:
12
+ *
13
+ * ```ts
14
+ * isWorkletFunction(myWorklet); // Will always return false.
15
+ *
16
+ * function myWorklet() {
17
+ * 'worklet';
18
+ * }
19
+ * ```
20
+ *
21
+ * ### Maintainer note
22
+ *
23
+ * This function is supposed to be used only in the React Runtime. It always
24
+ * returns `false` in Worklet Runtimes.
25
+ */
26
+ export declare function isWorkletFunction<Args extends unknown[] = unknown[], ReturnValue = unknown, BuildType extends WorkletBaseDev | WorkletBaseRelease = WorkletBaseDev>(value: unknown): value is WorkletFunction<Args, ReturnValue> & BuildType;
27
+ //# sourceMappingURL=workletFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workletFunction.d.ts","sourceRoot":"","sources":["../../src/workletFunction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAClC,WAAW,GAAG,OAAO,EACrB,SAAS,SAAS,cAAc,GAAG,kBAAkB,GAAG,cAAc,EACtE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,SAAS,CAUzE"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The below type is used for HostObjects returned by the JSI API that don't
3
+ * have any accessible fields or methods but can carry data that is accessed
4
+ * from the c++ side. We add a field to the type to make it possible for
5
+ * typescript to recognize which JSI methods accept those types as arguments and
6
+ * to be able to correctly type check other methods that may use them. However,
7
+ * this field is not actually defined nor should be used for anything else as
8
+ * assigning any data to those objects will throw an error.
9
+ */
10
+ export type ShareableRef<T = unknown> = {
11
+ __hostObjectShareableJSRef: T;
12
+ };
13
+ export type FlatShareableRef<T> = T extends ShareableRef<infer U> ? ShareableRef<U> : ShareableRef<T>;
14
+ export type WorkletRuntime = {
15
+ __hostObjectWorkletRuntime: never;
16
+ readonly name: string;
17
+ };
18
+ export type WorkletStackDetails = [
19
+ error: Error,
20
+ lineOffset: number,
21
+ columnOffset: number
22
+ ];
23
+ type WorkletClosure = Record<string, unknown>;
24
+ interface WorkletInitDataCommon {
25
+ code: string;
26
+ }
27
+ type WorkletInitDataRelease = WorkletInitDataCommon;
28
+ interface WorkletInitDataDev extends WorkletInitDataCommon {
29
+ location: string;
30
+ sourceMap: string;
31
+ version: string;
32
+ }
33
+ interface WorkletBaseCommon {
34
+ __closure: WorkletClosure;
35
+ __workletHash: number;
36
+ }
37
+ export interface WorkletBaseRelease extends WorkletBaseCommon {
38
+ __initData: WorkletInitDataRelease;
39
+ }
40
+ export interface WorkletBaseDev extends WorkletBaseCommon {
41
+ __initData: WorkletInitDataDev;
42
+ /** `__stackDetails` is removed after parsing. */
43
+ __stackDetails?: WorkletStackDetails;
44
+ }
45
+ export type WorkletFunctionDev<Args extends unknown[] = unknown[], ReturnValue = unknown> = ((...args: Args) => ReturnValue) & WorkletBaseDev;
46
+ type WorkletFunctionRelease<Args extends unknown[] = unknown[], ReturnValue = unknown> = ((...args: Args) => ReturnValue) & WorkletBaseRelease;
47
+ export type WorkletFunction<Args extends unknown[] = unknown[], ReturnValue = unknown> = WorkletFunctionDev<Args, ReturnValue> | WorkletFunctionRelease<Args, ReturnValue>;
48
+ export {};
49
+ //# sourceMappingURL=workletTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workletTypes.d.ts","sourceRoot":"","sources":["../../src/workletTypes.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IACtC,0BAA0B,EAAE,CAAC,CAAC;CAC/B,CAAC;AAIF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC5B,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;AAEtE,MAAM,MAAM,cAAc,GAAG;IAC3B,0BAA0B,EAAE,KAAK,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,MAAM;IAClB,YAAY,EAAE,MAAM;CACrB,CAAC;AAEF,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9C,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,sBAAsB,GAAG,qBAAqB,CAAC;AAEpD,UAAU,kBAAmB,SAAQ,qBAAqB;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,SAAS,EAAE,cAAc,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,UAAU,EAAE,sBAAsB,CAAC;CACpC;AAED,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD,UAAU,EAAE,kBAAkB,CAAC;IAC/B,iDAAiD;IACjD,cAAc,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED,MAAM,MAAM,kBAAkB,CAC5B,IAAI,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAClC,WAAW,GAAG,OAAO,IACnB,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC,GAAG,cAAc,CAAC;AAEtD,KAAK,sBAAsB,CACzB,IAAI,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAClC,WAAW,GAAG,OAAO,IACnB,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC,GAAG,kBAAkB,CAAC;AAE1D,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAClC,WAAW,GAAG,OAAO,IAEnB,kBAAkB,CAAC,IAAI,EAAE,WAAW,CAAC,GACrC,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,112 @@
1
1
  {
2
2
  "name": "react-native-worklets",
3
- "version": "0.0.1-alpha",
4
- "description": "Alternative and enhanced implementation of React Native's Animated API",
5
- "main": "Animated.js",
3
+ "version": "0.1.0",
4
+ "description": "The React Native multithreading library",
5
+ "keywords": [
6
+ "react-native",
7
+ "react",
8
+ "native",
9
+ "worklets"
10
+ ],
6
11
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
12
+ "build": "bob build",
13
+ "circular-dependency-check": "yarn madge --extensions js,jsx,ts,tsx --circular src lib",
14
+ "format": "yarn format:js && yarn format:plugin && yarn format:common && yarn format:android:java && yarn format:apple",
15
+ "format:android:java": "node ../../scripts/format-java.js",
16
+ "format:apple": "find apple -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i",
17
+ "format:common": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
18
+ "format:js": "prettier --write --list-different src",
19
+ "format:plugin": "yarn workspace babel-plugin-reanimated format",
20
+ "lint": "yarn lint:js && yarn lint:plugin && yarn lint:android && yarn lint:apple",
21
+ "lint:android": "./android/gradlew -p android spotlessCheck -q",
22
+ "lint:apple": "yarn format:apple --dry-run -Werror",
23
+ "lint:js": "eslint src && yarn prettier --check src",
24
+ "lint:plugin": "yarn workspace babel-plugin-reanimated lint",
25
+ "test": "jest",
26
+ "type:check": "yarn type:check:src && yarn type:check:plugin",
27
+ "type:check:src": "yarn tsc --noEmit",
28
+ "type:check:plugin": "yarn workspace babel-plugin-reanimated type:check"
8
29
  },
9
- "author": {
10
- "email": "krzys@swmansion.com",
11
- "name": "Krzysztof Magiera"
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/software-mansion/react-native-reanimated.git",
33
+ "directory": "packages/react-native-worklets"
12
34
  },
13
- "license": "MIT"
35
+ "license": "MIT",
36
+ "readmeFilename": "README.md",
37
+ "bugs": {
38
+ "url": "https://github.com/software-mansion/react-native-reanimated/issues"
39
+ },
40
+ "homepage": "https://docs.swmansion.com/react-native-reanimated",
41
+ "peerDependencies": {
42
+ "@babel/core": "^7.0.0-0",
43
+ "react": "*",
44
+ "react-native": "*"
45
+ },
46
+ "devDependencies": {
47
+ "@react-native-community/cli": "15.0.1",
48
+ "@react-native/eslint-config": "0.76.5",
49
+ "@types/jest": "^29.5.5",
50
+ "@types/react": "^18.2.44",
51
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
52
+ "babel-plugin-reanimated": "workspace:*",
53
+ "clang-format-node": "^1.3.1",
54
+ "eslint": "^8.57.0",
55
+ "eslint-plugin-reanimated": "workspace:*",
56
+ "jest": "^29.0.0",
57
+ "madge": "^5.0.1",
58
+ "prettier": "^3.3.3",
59
+ "react": "18.3.1",
60
+ "react-native": "0.77.0",
61
+ "react-native-builder-bob": "0.33.1",
62
+ "typescript": "~5.3.0"
63
+ },
64
+ "main": "./lib/module/index",
65
+ "module": "./lib/module/index",
66
+ "react-native": "./src/index",
67
+ "source": "./src/index",
68
+ "types": "lib/typescript/index.d.ts",
69
+ "files": [
70
+ "src",
71
+ "lib",
72
+ "android",
73
+ "apple",
74
+ "Common",
75
+ "scripts/worklets_utils.rb",
76
+ "plugin/index.js",
77
+ "*.podspec",
78
+ "react-native.config.js",
79
+ "!apple/build",
80
+ "!android/build",
81
+ "!android/gradle",
82
+ "!android/gradlew",
83
+ "!android/gradlew.bat",
84
+ "!android/local.properties",
85
+ "!**/__tests__",
86
+ "!**/__fixtures__",
87
+ "!**/__mocks__",
88
+ "!**/.*"
89
+ ],
90
+ "react-native-builder-bob": {
91
+ "source": "src",
92
+ "output": "lib",
93
+ "targets": [
94
+ [
95
+ "module",
96
+ {
97
+ "esm": true,
98
+ "jsxRuntime": "classic"
99
+ }
100
+ ],
101
+ "typescript"
102
+ ]
103
+ },
104
+ "codegenConfig": {
105
+ "name": "rnworklets",
106
+ "type": "modules",
107
+ "jsSrcsDir": "src/specs",
108
+ "android": {
109
+ "javaPackageName": "com.swmansion.worklets"
110
+ }
111
+ }
14
112
  }
@@ -0,0 +1,3 @@
1
+ "use strict";var st=Object.create;var ge=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lt(t))!ut.call(e,n)&&n!==r&&ge(e,n,{get:()=>t[n],enumerable:!(i=at(t,n))||i.enumerable});return e};var R=(e,t,r)=>(r=e!=null?st(ct(e)):{},dt(t||!e||!e.__esModule?ge(r,"default",{value:e,enumerable:!0}):r,e));var Oe=p(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.isGestureObjectEventCallbackMethod=w.isGestureHandlerEventCallback=w.gestureHandlerBuilderMethods=void 0;var I=require("@babel/types"),ft=new Set(["Tap","Pan","Pinch","Rotation","Fling","LongPress","ForceTouch","Native","Manual","Race","Simultaneous","Exclusive","Hover"]);w.gestureHandlerBuilderMethods=new Set(["onBegin","onStart","onEnd","onFinalize","onUpdate","onChange","onTouchesDown","onTouchesMove","onTouchesUp","onTouchesCancelled"]);function pt(e){return(0,I.isCallExpression)(e.parent)&&(0,I.isExpression)(e.parent.callee)&&_e(e.parent.callee)}w.isGestureHandlerEventCallback=pt;function _e(e){return(0,I.isMemberExpression)(e)&&(0,I.isIdentifier)(e.property)&&w.gestureHandlerBuilderMethods.has(e.property.name)&&ve(e.object)}w.isGestureObjectEventCallbackMethod=_e;function ve(e){return!!(mt(e)||(0,I.isCallExpression)(e)&&(0,I.isMemberExpression)(e.callee)&&ve(e.callee.object))}function mt(e){return(0,I.isCallExpression)(e)&&(0,I.isMemberExpression)(e.callee)&&(0,I.isIdentifier)(e.callee.object)&&e.callee.object.name==="Gesture"&&(0,I.isIdentifier)(e.callee.property)&&ft.has(e.callee.property.name)}});var Ie=p(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.isLayoutAnimationCallback=void 0;var S=require("@babel/types"),bt=new Set(["BounceIn","BounceInDown","BounceInLeft","BounceInRight","BounceInUp","BounceOut","BounceOutDown","BounceOutLeft","BounceOutRight","BounceOutUp","FadeIn","FadeInDown","FadeInLeft","FadeInRight","FadeInUp","FadeOut","FadeOutDown","FadeOutLeft","FadeOutRight","FadeOutUp","FlipInEasyX","FlipInEasyY","FlipInXDown","FlipInXUp","FlipInYLeft","FlipInYRight","FlipOutEasyX","FlipOutEasyY","FlipOutXDown","FlipOutXUp","FlipOutYLeft","FlipOutYRight","LightSpeedInLeft","LightSpeedInRight","LightSpeedOutLeft","LightSpeedOutRight","PinwheelIn","PinwheelOut","RollInLeft","RollInRight","RollOutLeft","RollOutRight","RotateInDownLeft","RotateInDownRight","RotateInUpLeft","RotateInUpRight","RotateOutDownLeft","RotateOutDownRight","RotateOutUpLeft","RotateOutUpRight","SlideInDown","SlideInLeft","SlideInRight","SlideInUp","SlideOutDown","SlideOutLeft","SlideOutRight","SlideOutUp","StretchInX","StretchInY","StretchOutX","StretchOutY","ZoomIn","ZoomInDown","ZoomInEasyDown","ZoomInEasyUp","ZoomInLeft","ZoomInRight","ZoomInRotate","ZoomInUp","ZoomOut","ZoomOutDown","ZoomOutEasyDown","ZoomOutEasyUp","ZoomOutLeft","ZoomOutRight","ZoomOutRotate","ZoomOutUp"]),yt=new Set(["Layout","LinearTransition","SequencedTransition","FadingTransition","JumpingTransition","CurvedTransition","EntryExitTransition"]),he=new Set([...bt,...yt]),kt=new Set(["build","duration","delay","getDuration","randomDelay","getDelay","getDelayFunction"]),gt=new Set(["easing","rotate","springify","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","withInitialValues","getAnimationAndConfig"]),_t=new Set(["easingX","easingY","easingWidth","easingHeight","entering","exiting","reverse"]),vt=new Set([...kt,...gt,..._t]),Ot=new Set(["withCallback"]);function ht(e){return(0,S.isCallExpression)(e.parent)&&(0,S.isExpression)(e.parent.callee)&&Et(e.parent.callee)}X.isLayoutAnimationCallback=ht;function Et(e){return(0,S.isMemberExpression)(e)&&(0,S.isIdentifier)(e.property)&&Ot.has(e.property.name)&&Ee(e.object)}function Ee(e){return(0,S.isIdentifier)(e)&&he.has(e.name)?!0:!!((0,S.isNewExpression)(e)&&(0,S.isIdentifier)(e.callee)&&he.has(e.callee.name)||(0,S.isCallExpression)(e)&&(0,S.isMemberExpression)(e.callee)&&(0,S.isIdentifier)(e.callee.property)&&vt.has(e.callee.property.name)&&Ee(e.callee.object))}});var x=p(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.workletClassFactorySuffix=b.isWorkletizableObjectNode=b.isWorkletizableObjectPath=b.isWorkletizableFunctionNode=b.isWorkletizableFunctionPath=b.WorkletizableObject=b.WorkletizableFunction=void 0;var H=require("@babel/types");b.WorkletizableFunction="FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod";b.WorkletizableObject="ObjectExpression";function It(e){return e.isFunctionDeclaration()||e.isFunctionExpression()||e.isArrowFunctionExpression()||e.isObjectMethod()}b.isWorkletizableFunctionPath=It;function St(e){return(0,H.isFunctionDeclaration)(e)||(0,H.isFunctionExpression)(e)||(0,H.isArrowFunctionExpression)(e)||(0,H.isObjectMethod)(e)}b.isWorkletizableFunctionNode=St;function xt(e){return e.isObjectExpression()}b.isWorkletizableObjectPath=xt;function Wt(e){return(0,H.isObjectExpression)(e)}b.isWorkletizableObjectNode=Wt;b.workletClassFactorySuffix="__classFactory"});var q=p(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.replaceWithFactoryCall=A.isRelease=void 0;var Z=require("@babel/types");function wt(){var e,t;let r=/(prod|release|stag[ei])/i;return!!(!((e=process.env.BABEL_ENV)===null||e===void 0)&&e.match(r)||!((t=process.env.NODE_ENV)===null||t===void 0)&&t.match(r))}A.isRelease=wt;function Ct(e,t,r){if(!t||!Ft(e))e.replaceWith(r);else{let i=(0,Z.variableDeclaration)("const",[(0,Z.variableDeclarator)((0,Z.identifier)(t),r)]);e.replaceWith(i)}}A.replaceWithFactoryCall=Ct;function Ft(e){return(0,Z.isScopable)(e.parent)||(0,Z.isExportNamedDeclaration)(e.parent)}});var le=p(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.addCustomGlobals=g.initializeGlobals=g.globals=g.defaultGlobals=g.initializeState=void 0;var jt=["globalThis","Infinity","NaN","undefined","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape","Object","Function","Boolean","Symbol","Error","AggregateError","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","InternalError","Number","BigInt","Math","Date","String","RegExp","Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","BigInt64Array","BigUint64Array","Float32Array","Float64Array","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Atomics","JSON","WeakRef","FinalizationRegistry","Iterator","AsyncIterator","Promise","GeneratorFunction","AsyncGeneratorFunction","Generator","AsyncGenerator","AsyncFunction","Reflect","Proxy","Intl","null","this","global","window","globalThis","console","performance","queueMicrotask","requestAnimationFrame","setImmediate","arguments","HermesInternal","ReanimatedError","_WORKLET","WorkletsError","__workletsLoggerConfig"],Dt=["_IS_FABRIC","_log","_toString","_scheduleHostFunctionOnJS","_scheduleRemoteFunctionOnJS","_scheduleOnRuntime","_makeShareableClone","_updatePropsPaper","_updatePropsFabric","_measurePaper","_measureFabric","_scrollToPaper","_dispatchCommandPaper","_dispatchCommandFabric","_setGestureState","_notifyAboutProgress","_notifyAboutEnd","_runOnUIQueue","_getAnimationTimestamp"];function Pt(e){e.workletNumber=1,e.classesToWorkletize=[],Se(),xe(e)}g.initializeState=Pt;g.defaultGlobals=new Set(jt.concat(Dt));function Se(){g.globals=new Set(g.defaultGlobals)}g.initializeGlobals=Se;function xe(e){e.opts&&Array.isArray(e.opts.globals)&&e.opts.globals.forEach(t=>{g.globals.add(t)})}g.addCustomGlobals=xe});var $=p(z=>{"use strict";var Mt=z&&z.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};Object.defineProperty(z,"__esModule",{value:!0});z.workletTransformSync=void 0;var Rt=require("@babel/core");function At(e,t){let{extraPlugins:r=[],extraPresets:i=[]}=t,n=Mt(t,["extraPlugins","extraPresets"]);return(0,Rt.transformSync)(e,Object.assign(Object.assign({},n),{plugins:[...zt,...r],presets:[...qt,...i]}))}z.workletTransformSync=At;var qt=[require.resolve("@babel/preset-typescript")],zt=[]});var Ce=p(v=>{"use strict";var Lt=v&&v.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),Tt=v&&v.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),We=v&&v.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Lt(t,e,r);return Tt(t,e),t},Nt=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(v,"__esModule",{value:!0});v.buildWorkletString=void 0;var we=require("@babel/core"),Bt=Nt(require("@babel/generator")),u=require("@babel/types"),V=require("assert"),Ut=We(require("convert-source-map")),Gt=We(require("fs")),Ht=$(),Zt=x(),Vt=q(),Jt="mock source map";function Xt(e,t,r,i,n){var s;$t(e,i);let l=e.program.body.find(_=>(0,u.isFunctionDeclaration)(_))||e.program.body.find(_=>(0,u.isExpressionStatement)(_))||void 0;(0,V.strict)(l,"[Reanimated] `draftExpression` is undefined.");let a=(0,u.isFunctionDeclaration)(l)?l:l.expression;(0,V.strict)("params"in a,"'params' property is undefined in 'expression'"),(0,V.strict)((0,u.isBlockStatement)(a.body),"[Reanimated] `expression.body` is not a `BlockStatement`");let y=new Set;(0,we.traverse)(e,{NewExpression(_){if(!(0,u.isIdentifier)(_.node.callee))return;let W=_.node.callee.name;if(!r.some(J=>J.name===W)||y.has(W))return;let M=r.findIndex(J=>J.name===W);r.splice(M,1);let oe=W+Zt.workletClassFactorySuffix;r.push((0,u.identifier)(oe)),(0,u.assertBlockStatement)(a.body),a.body.body.unshift((0,u.variableDeclaration)("const",[(0,u.variableDeclarator)((0,u.identifier)(W),(0,u.callExpression)((0,u.identifier)(oe),[]))])),y.add(W)}});let d=(0,u.functionExpression)((0,u.identifier)(i),a.params,a.body,a.generator,a.async),j=(0,Bt.default)(d).code;(0,V.strict)(n,"[Reanimated] `inputMap` is undefined.");let E=!((0,Vt.isRelease)()||t.opts.disableSourceMaps);if(E){n.sourcesContent=[];for(let _ of n.sources)n.sourcesContent.push(Gt.readFileSync(_).toString("utf-8"))}let P=(0,Ht.workletTransformSync)(j,{filename:t.file.opts.filename,extraPlugins:[er(r),...(s=t.opts.extraPlugins)!==null&&s!==void 0?s:[]],extraPresets:t.opts.extraPresets,compact:!0,sourceMaps:E,inputSourceMap:n,ast:!1,babelrc:!1,configFile:!1,comments:!1});(0,V.strict)(P,"[Reanimated] `transformed` is null.");let D;return E&&(Yt()?D=Jt:(D=Ut.fromObject(P.map).toObject(),delete D.sourcesContent)),[P.code,JSON.stringify(D)]}v.buildWorkletString=Xt;function $t(e,t){(0,we.traverse)(e,{FunctionExpression(r){if(!r.node.id){r.stop();return}let i=r.node.id.name;r.scope.rename(i,t)}})}function Yt(){return process.env.REANIMATED_JEST_SHOULD_MOCK_SOURCE_MAP==="1"}function Kt(e,t,r){t.length===0||!(0,u.isProgram)(e.parent)||(0,u.isExpression)(e.node.body)||e.node.body.body.unshift(r)}function Qt(e){var t;(0,u.isProgram)(e.parent)&&!(0,u.isArrowFunctionExpression)(e.node)&&!(0,u.isObjectMethod)(e.node)&&e.node.id&&e.scope.parent&&((t=e.scope.parent.bindings[e.node.id.name])===null||t===void 0?void 0:t.references)>0&&e.node.body.body.unshift((0,u.variableDeclaration)("const",[(0,u.variableDeclarator)((0,u.identifier)(e.node.id.name),(0,u.memberExpression)((0,u.thisExpression)(),(0,u.identifier)("_recur")))]))}function er(e){let t=(0,u.variableDeclaration)("const",[(0,u.variableDeclarator)((0,u.objectPattern)(e.map(r=>(0,u.objectProperty)((0,u.identifier)(r.name),(0,u.identifier)(r.name),!1,!0))),(0,u.memberExpression)((0,u.thisExpression)(),(0,u.identifier)("__closure")))]);return{visitor:{"FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod":r=>{Kt(r,e,t),Qt(r)}}}}});var De=p(L=>{"use strict";var tr=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(L,"__esModule",{value:!0});L.makeWorkletFactory=void 0;var rr=require("@babel/core"),nr=tr(require("@babel/generator")),o=require("@babel/types"),C=require("assert"),je=require("path"),ir=le(),or=$(),Fe=x(),ce=q(),sr=Ce(),ar=require("../package.json").version,lr="x.y.z";function cr(e,t){var r;ur(e),(0,C.strict)(t.file.opts.filename,"[Reanimated] `state.file.opts.filename` is undefined.");let i=(0,nr.default)(e.node,{sourceMaps:!0,sourceFileName:t.file.opts.filename});i.code="("+(e.isObjectMethod()?"function ":"")+i.code+`
2
+ )`;let n=(0,or.workletTransformSync)(i.code,{extraPlugins:[...br,...(r=t.opts.extraPlugins)!==null&&r!==void 0?r:[]],extraPresets:t.opts.extraPresets,filename:t.file.opts.filename,ast:!0,babelrc:!1,configFile:!1,inputSourceMap:i.map});(0,C.strict)(n,"[Reanimated] `transformed` is undefined."),(0,C.strict)(n.ast,"[Reanimated] `transformed.ast` is undefined.");let s=mr(n.ast,e),l=(0,o.cloneNode)(e.node),a=(0,o.isBlockStatement)(l.body)?(0,o.functionExpression)(null,l.params,l.body,l.generator,l.async):l,{workletName:y,reactName:d}=pr(e,t),[j,E]=(0,sr.buildWorkletString)(n.ast,t,s,y,n.map);(0,C.strict)(j,"[Reanimated] `funString` is undefined.");let P=fr(j),D=1;s.length>0&&(D-=s.length+2);let _=e.parentPath.isProgram()?e:e.findParent(k=>{var se,ae;return(ae=(se=k.parentPath)===null||se===void 0?void 0:se.isProgram())!==null&&ae!==void 0?ae:!1});(0,C.strict)(_,"[Reanimated] `pathForStringDefinitions` is null."),(0,C.strict)(_.parentPath,"[Reanimated] `pathForStringDefinitions.parentPath` is null.");let W=_.parentPath.scope.generateUidIdentifier(`worklet_${P}_init_data`),M=(0,o.objectExpression)([(0,o.objectProperty)((0,o.identifier)("code"),(0,o.stringLiteral)(j))]);if(!(0,ce.isRelease)()){let k=t.file.opts.filename;t.opts.relativeSourceLocation&&(k=(0,je.relative)(t.cwd,k),E=E==null?void 0:E.replace(t.file.opts.filename,k)),M.properties.push((0,o.objectProperty)((0,o.identifier)("location"),(0,o.stringLiteral)(k)))}E&&M.properties.push((0,o.objectProperty)((0,o.identifier)("sourceMap"),(0,o.stringLiteral)(E))),!(0,ce.isRelease)()&&M.properties.push((0,o.objectProperty)((0,o.identifier)("version"),(0,o.stringLiteral)(dr()?lr:ar)));let ke=!t.opts.omitNativeOnlyData;ke&&_.insertBefore((0,o.variableDeclaration)("const",[(0,o.variableDeclarator)(W,M)])),(0,C.strict)(!(0,o.isFunctionDeclaration)(a),"[Reanimated] `funExpression` is a `FunctionDeclaration`."),(0,C.strict)(!(0,o.isObjectMethod)(a),"[Reanimated] `funExpression` is an `ObjectMethod`.");let G=[(0,o.variableDeclaration)("const",[(0,o.variableDeclarator)((0,o.identifier)(d),a)]),(0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__closure"),!1),(0,o.objectExpression)(s.map(k=>k.name.endsWith(Fe.workletClassFactorySuffix)?(0,o.objectProperty)((0,o.identifier)(k.name),(0,o.memberExpression)((0,o.identifier)(k.name.slice(0,k.name.length-Fe.workletClassFactorySuffix.length)),(0,o.identifier)(k.name))):(0,o.objectProperty)((0,o.identifier)(k.name),k,!1,!0))))),(0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__workletHash"),!1),(0,o.numericLiteral)(P)))];return ke&&G.push((0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__initData"),!1),W))),(0,ce.isRelease)()||(G.unshift((0,o.variableDeclaration)("const",[(0,o.variableDeclarator)((0,o.identifier)("_e"),(0,o.arrayExpression)([(0,o.newExpression)((0,o.memberExpression)((0,o.identifier)("global"),(0,o.identifier)("Error")),[]),(0,o.numericLiteral)(D),(0,o.numericLiteral)(-27)]))])),G.push((0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__stackDetails"),!1),(0,o.identifier)("_e"))))),G.push((0,o.returnStatement)((0,o.identifier)(d))),(0,o.functionExpression)(void 0,[],(0,o.blockStatement)(G))}L.makeWorkletFactory=cr;function ur(e){e.traverse({DirectiveLiteral(t){t.node.value==="worklet"&&t.getFunctionParent()===e&&t.parentPath.remove()}})}function dr(){return process.env.REANIMATED_JEST_SHOULD_MOCK_VERSION==="1"}function fr(e){let t=e.length,r=5381,i=52711;for(;t--;){let n=e.charCodeAt(t);r=r*33^n,i=i*33^n}return(r>>>0)*4096+(i>>>0)}function pr(e,t){let r="unknownFile";if(t.file.opts.filename){let l=t.file.opts.filename;r=(0,je.basename)(l);let a=l.split("/"),y=a.indexOf("node_modules");y!==-1&&(r=`${a[y+1]}_${r}`)}let i=`${r}${t.workletNumber++}`,n="";(0,o.isObjectMethod)(e.node)&&(0,o.isIdentifier)(e.node.key)?n=e.node.key.name:((0,o.isFunctionDeclaration)(e.node)||(0,o.isFunctionExpression)(e.node))&&(0,o.isIdentifier)(e.node.id)&&(n=e.node.id.name);let s=n?(0,o.toIdentifier)(`${n}_${i}`):(0,o.toIdentifier)(i);return n=n||(0,o.toIdentifier)(i),{workletName:s,reactName:n}}function mr(e,t){let r=new Map,i=new Map;return(0,rr.traverse)(e,{Identifier(n){if(!n.isReferencedIdentifier())return;let s=n.node.name;if(ir.globals.has(s)||"id"in t.node&&t.node.id&&t.node.id.name===s)return;let l=n.parent;if((0,o.isMemberExpression)(l)&&l.property===n.node&&!l.computed||(0,o.isObjectProperty)(l)&&(0,o.isObjectExpression)(n.parentPath.parent)&&n.node!==l.value)return;let a=n.scope;for(;a!=null;){if(a.bindings[s]!=null)return;a=a.parent}r.set(s,n.node),i.set(s,!1)}}),t.traverse({Identifier(n){if(!n.isReferencedIdentifier())return;let s=r.get(n.node.name);!s||i.get(n.node.name)||(s.loc=n.node.loc,i.set(n.node.name,!0))}}),Array.from(r.values())}var br=[require.resolve("@babel/plugin-transform-shorthand-properties"),require.resolve("@babel/plugin-transform-arrow-functions"),require.resolve("@babel/plugin-transform-optional-chaining"),require.resolve("@babel/plugin-transform-nullish-coalescing-operator"),[require.resolve("@babel/plugin-transform-template-literals"),{loose:!0}]]});var Pe=p(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.makeWorkletFactoryCall=void 0;var yr=require("@babel/types"),kr=De();function gr(e,t){let r=(0,kr.makeWorkletFactory)(e,t),i=(0,yr.callExpression)(r,[]);return _r(e,i),i}Y.makeWorkletFactoryCall=gr;function _r(e,t){let r=e.node.loc;r&&(t.callee.loc={filename:r.filename,identifierName:r.identifierName,start:r.start,end:r.start})}});var K=p(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.substituteObjectMethodWithObjectProperty=F.processWorklet=F.processIfWithWorkletDirective=void 0;var ue=require("@babel/types"),vr=x(),Or=q(),hr=Pe();function Me(e,t){return!(0,ue.isBlockStatement)(e.node.body)||!Er(e.node.body.directives)?!1:(Re(e,t),!0)}F.processIfWithWorkletDirective=Me;function Re(e,t){t.opts.processNestedWorklets&&e.traverse({[vr.WorkletizableFunction](i,n){Me(i,n)}},t);let r=(0,hr.makeWorkletFactoryCall)(e,t);Ir(e,r)}F.processWorklet=Re;function Er(e){return e.some(t=>(0,ue.isDirectiveLiteral)(t.value)&&t.value.value==="worklet")}function Ir(e,t){var r;if(e.isObjectMethod())Ae(e,t);else{let i="id"in e.node?(r=e.node.id)===null||r===void 0?void 0:r.name:void 0;(0,Or.replaceWithFactoryCall)(e,i,t)}}function Ae(e,t){let r=(0,ue.objectProperty)(e.node.key,t);e.replaceWith(r)}F.substituteObjectMethodWithObjectProperty=Ae});var ze=p(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.processWorkletizableObject=void 0;var Sr=x(),qe=K();function xr(e,t){let r=e.get("properties");for(let i of r)if(i.isObjectMethod())(0,qe.processWorklet)(i,t);else if(i.isObjectProperty()){let n=i.get("value");(0,Sr.isWorkletizableFunctionPath)(n)&&(0,qe.processWorklet)(n,t)}else throw new Error(`[Reanimated] '${i.type}' as to-be workletized argument is not supported for object hooks.`)}Q.processWorkletizableObject=xr});var Le=p(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.findReferencedWorklet=void 0;var T=x();function de(e,t,r){let i=e.node.name,s=e.scope.getBinding(i);return s?t&&s.path.isFunctionDeclaration()?s.path:s.constant?Wr(s,t,r):wr(s,t,r):void 0}ee.findReferencedWorklet=de;function Wr(e,t,r){let i=e.path;if(!i.isVariableDeclarator())return;let n=i.get("init");if(t&&(0,T.isWorkletizableFunctionPath)(n)||r&&(0,T.isWorkletizableObjectPath)(n))return n;if(n.isIdentifier()&&n.isReferencedIdentifier())return de(n,t,r)}function wr(e,t,r){let i=e.constantViolations.reverse().find(s=>s.isAssignmentExpression()&&(t&&(0,T.isWorkletizableFunctionPath)(s.get("right"))||r&&(0,T.isWorkletizableObjectPath)(s.get("right"))));if(!i||!i.isAssignmentExpression())return;let n=i.get("right");if(t&&(0,T.isWorkletizableFunctionPath)(n)||r&&(0,T.isWorkletizableObjectPath)(n))return n;if(n.isIdentifier()&&n.isReferencedIdentifier())return de(n,t,r)}});var He=p(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.processCalleesAutoworkletizableCallbacks=N.processIfAutoworkletizableCallback=void 0;var Te=require("@babel/types"),fe=Oe(),Cr=Ie(),Fr=ze(),jr=Le(),te=x(),Ge=K(),Ne=new Set(["useAnimatedGestureHandler","useAnimatedScrollHandler"]),Be=new Set(["useFrameCallback","useAnimatedStyle","useAnimatedProps","createAnimatedPropAdapter","useDerivedValue","useAnimatedScrollHandler","useAnimatedReaction","useWorkletCallback","withTiming","withSpring","withDecay","withRepeat","runOnUI","executeOnUIRuntimeSync"]),Dr=new Map([["useAnimatedGestureHandler",[0]],["useFrameCallback",[0]],["useAnimatedStyle",[0]],["useAnimatedProps",[0]],["createAnimatedPropAdapter",[0]],["useDerivedValue",[0]],["useAnimatedScrollHandler",[0]],["useAnimatedReaction",[0,1]],["useWorkletCallback",[0]],["withTiming",[2]],["withSpring",[2]],["withDecay",[1]],["withRepeat",[3]],["runOnUI",[0]],["executeOnUIRuntimeSync",[0]],...Array.from(fe.gestureHandlerBuilderMethods).map(e=>[e,[0]])]);function Pr(e,t){return(0,fe.isGestureHandlerEventCallback)(e)||(0,Cr.isLayoutAnimationCallback)(e)?((0,Ge.processWorklet)(e,t),!0):!1}N.processIfAutoworkletizableCallback=Pr;function Mr(e,t){let r=(0,Te.isSequenceExpression)(e.node.callee)?e.node.callee.expressions[e.node.callee.expressions.length-1]:e.node.callee,i="name"in r?r.name:"property"in r&&"name"in r.property?r.property.name:void 0;if(i!==void 0){if(Be.has(i)||Ne.has(i)){let n=Be.has(i),s=Ne.has(i),l=Dr.get(i),a=e.get("arguments").filter((y,d)=>l.includes(d));Ue(a,t,n,s)}else if(!(0,Te.isV8IntrinsicIdentifier)(r)&&(0,fe.isGestureObjectEventCallbackMethod)(r)){let n=e.get("arguments");Ue(n,t,!0,!0)}}}N.processCalleesAutoworkletizableCallbacks=Mr;function Ue(e,t,r,i){e.forEach(n=>{let s=Rr(n,r,i);s&&((0,te.isWorkletizableFunctionPath)(s)?(0,Ge.processWorklet)(s,t):(0,te.isWorkletizableObjectPath)(s)&&(0,Fr.processWorkletizableObject)(s,t))})}function Rr(e,t,r){if(t&&(0,te.isWorkletizableFunctionPath)(e)||r&&(0,te.isWorkletizableObjectPath)(e))return e;if(e.isIdentifier()&&e.isReferencedIdentifier())return(0,jr.findReferencedWorklet)(e,t,r)}});var Xe=p(B=>{"use strict";var Ze=B&&B.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(B,"__esModule",{value:!0});B.processIfWorkletClass=void 0;var Ar=Ze(require("@babel/generator")),qr=Ze(require("@babel/traverse")),c=require("@babel/types"),re=require("assert"),zr=$(),Lr=x(),Tr=q(),Ve="__workletClass";function Nr(e,t){return Qr(e,t)?(Jr(e.node.body),Br(e,t),!0):!1}B.processIfWorkletClass=Nr;function Br(e,t){(0,re.strict)(e.node.id);let r=e.node.id.name,i=Ur(e.node,t);Xr(i),Gr(i.program.body),Hr(i.program.body,r),i.program.body.push((0,c.returnStatement)((0,c.identifier)(r)));let n=(0,c.functionExpression)(null,[],(0,c.blockStatement)([...i.program.body])),s=(0,c.callExpression)(n,[]);(0,Tr.replaceWithFactoryCall)(e,r,s)}function Ur(e,t){var r;let i=(0,Ar.default)(e).code,n=(0,zr.workletTransformSync)(i,{extraPlugins:["@babel/plugin-transform-class-properties","@babel/plugin-transform-classes","@babel/plugin-transform-unicode-regex",...(r=t.opts.extraPlugins)!==null&&r!==void 0?r:[]],extraPresets:t.opts.extraPresets,filename:t.file.opts.filename,ast:!0,babelrc:!1,configFile:!1});return(0,re.strict)(n&&n.ast),n.ast}function Gr(e){e.forEach(t=>{if((0,c.isFunctionDeclaration)(t)){let r=(0,c.directive)((0,c.directiveLiteral)("worklet"));t.body.directives.push(r)}})}function Hr(e,t){let r=t+Lr.workletClassFactorySuffix,i=Zr(e,t),s=e[i].declarations[0].init,l=(0,c.functionDeclaration)((0,c.identifier)(r),[],(0,c.blockStatement)([(0,c.variableDeclaration)("const",[(0,c.variableDeclarator)((0,c.identifier)(t),s)]),(0,c.expressionStatement)((0,c.assignmentExpression)("=",(0,c.memberExpression)((0,c.identifier)(t),(0,c.identifier)(r)),(0,c.identifier)(r))),(0,c.returnStatement)((0,c.identifier)(t))],[(0,c.directive)((0,c.directiveLiteral)("worklet"))])),a=(0,c.variableDeclaration)("const",[(0,c.variableDeclarator)((0,c.identifier)(t),(0,c.callExpression)((0,c.identifier)(r),[]))]);e.splice(i,1,l,a)}function Zr(e,t){let r=e.findIndex(i=>(0,c.isVariableDeclaration)(i)&&i.declarations.some(n=>(0,c.isIdentifier)(n.id)&&n.id.name===t));return(0,re.strict)(r>=0),r}function Vr(e){return e.body.some(t=>(0,c.isClassProperty)(t)&&(0,c.isIdentifier)(t.key)&&t.key.name===Ve)}function Jr(e){e.body=e.body.filter(t=>!(0,c.isClassProperty)(t)||!(0,c.isIdentifier)(t.key)||t.key.name!==Ve)}function Xr(e){let t=$r(e),r=Yr(t),i=t.map(a=>a.index),n=r.map(a=>a.index),s=e.program.body,l=[...s];for(let a=0;a<t.length;a++){let y=n[a],d=i[a],j=l[y];s[d]=j}}function $r(e){let t=[];return(0,qr.default)(e,{Program:{enter:r=>{r.get("body").forEach((n,s)=>{var l;let a=n.getBindingIdentifiers();if(!n.isFunctionDeclaration()||!(!((l=n.node.id)===null||l===void 0)&&l.name))return;let y={name:n.node.id.name,index:s,dependencies:new Set};t.push(y),n.traverse({Identifier(d){Kr(d,a,n)&&y.dependencies.add(d.node.name)}})})}}}),t}function Yr(e){let t=[],r=new Set;for(let i of e)Je(i,e,t,r);return t}function Je(e,t,r,i){if(i.has(e.name))throw new Error("Cycle detected. This should never happen.");if(!r.find(n=>n.name===e.name)){i.add(e.name);for(let n of e.dependencies)if(!r.find(s=>s.name===n)){let s=t.find(l=>l.name===n);(0,re.strict)(s),Je(s,t,r,i)}r.push(e),i.delete(e.name)}}function Kr(e,t,r){return e.isReferencedIdentifier()&&!(e.node.name in t)&&!r.scope.hasOwnBinding(e.node.name)&&r.scope.hasReference(e.node.name)}function Qr(e,t){var r;let i=(r=e.node.id)===null||r===void 0?void 0:r.name,n=e.node;if(!i)return!1;let s=Vr(n.body),l=t.classesToWorkletize.some(d=>d.node===n),a=e.parentPath.isProgram()&&t.classesToWorkletize.some(d=>d.name===i);return t.classesToWorkletize=t.classesToWorkletize.filter(d=>d.node!==n&&d.name!==i),s||l||a}});var pe=p(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.isContextObject=h.processIfWorkletContextObject=h.contextObjectMarker=void 0;var O=require("@babel/types");h.contextObjectMarker="__workletContextObject";function en(e,t){return $e(e.node)?(rn(e.node),tn(e.node),!0):!1}h.processIfWorkletContextObject=en;function $e(e){return e.properties.some(t=>(0,O.isObjectProperty)(t)&&(0,O.isIdentifier)(t.key)&&t.key.name===h.contextObjectMarker)}h.isContextObject=$e;function tn(e){let t=(0,O.functionExpression)(null,[],(0,O.blockStatement)([(0,O.returnStatement)((0,O.cloneNode)(e))],[(0,O.directive)((0,O.directiveLiteral)("worklet"))]));e.properties.push((0,O.objectProperty)((0,O.identifier)(`${h.contextObjectMarker}Factory`),t))}function rn(e){e.properties=e.properties.filter(t=>!((0,O.isObjectProperty)(t)&&(0,O.isIdentifier)(t.key)&&t.key.name===h.contextObjectMarker))}});var tt=p(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.isImplicitContextObject=U.processIfWorkletFile=void 0;var m=require("@babel/types"),Ye=pe(),Ke=x();function nn(e,t){return e.node.directives.some(r=>r.value.value==="worklet")?(e.node.directives=e.node.directives.filter(r=>r.value.value!=="worklet"),on(e,t),!0):!1}U.processIfWorkletFile=nn;function on(e,t){let r=e.get("body");pn(e.node),r.forEach(i=>{let n=sn(i);me(n,t)})}function sn(e){return e.isExportNamedDeclaration()||e.isExportDefaultDeclaration()?e.get("declaration"):e}function me(e,t){var r;(0,Ke.isWorkletizableFunctionPath)(e)?(e.isArrowFunctionExpression()&&cn(e.node),Qe(e.node.body)):(0,Ke.isWorkletizableObjectPath)(e)?et(e)?un(e.node):ln(e,t):e.isVariableDeclaration()?an(e,t):e.isClassDeclaration()&&(fn(e.node.body),!((r=e.node.id)===null||r===void 0)&&r.name&&t.classesToWorkletize.push({node:e.node,name:e.node.id.name}))}function an(e,t){e.get("declarations").forEach(i=>{let n=i.get("init");n.isExpression()&&me(n,t)})}function ln(e,t){e.get("properties").forEach(i=>{if(i.isObjectMethod())Qe(i.node.body);else if(i.isObjectProperty()){let n=i.get("value");me(n,t)}})}function cn(e){(0,m.isBlockStatement)(e.body)||(e.body=(0,m.blockStatement)([(0,m.returnStatement)(e.body)]))}function Qe(e){e.directives.some(t=>t.value.value==="worklet")||e.directives.push((0,m.directive)((0,m.directiveLiteral)("worklet")))}function un(e){e.properties.some(t=>(0,m.isObjectProperty)(t)&&(0,m.isIdentifier)(t.key)&&t.key.name===Ye.contextObjectMarker)||e.properties.push((0,m.objectProperty)((0,m.identifier)(`${Ye.contextObjectMarker}`),(0,m.booleanLiteral)(!0)))}function et(e){return e.get("properties").some(r=>r.isObjectMethod()?dn(r):!1)}U.isImplicitContextObject=et;function dn(e){let t=!1;return e.traverse({ThisExpression(r){t=!0,r.stop()}}),t}function fn(e){e.body.push((0,m.classProperty)((0,m.identifier)("__workletClass"),(0,m.booleanLiteral)(!0)))}function pn(e){let t=e.body,r=t.length,i=0;for(;i<r;){let n=t[i];if(!mn(n)){i++;continue}let s=t.splice(i,1);t.push(...s),r--}}function mn(e){return(0,m.isExpressionStatement)(e)&&(0,m.isAssignmentExpression)(e.expression)&&(0,m.isMemberExpression)(e.expression.left)&&(0,m.isIdentifier)(e.expression.left.object)&&e.expression.left.object.name==="exports"}});var rt=p(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.processInlineStylesWarning=void 0;var f=require("@babel/types"),be=require("assert"),bn=q();function yn(e){return(0,f.callExpression)((0,f.arrowFunctionExpression)([],(0,f.blockStatement)([(0,f.expressionStatement)((0,f.callExpression)((0,f.memberExpression)((0,f.identifier)("console"),(0,f.identifier)("warn")),[(0,f.callExpression)((0,f.memberExpression)((0,f.callExpression)((0,f.identifier)("require"),[(0,f.stringLiteral)("react-native-reanimated")]),(0,f.identifier)("getUseOfValueInStyleWarning")),[])])),(0,f.returnStatement)(e.node)])),[])}function kn(e){e.isMemberExpression()&&(0,f.isIdentifier)(e.node.property)&&e.node.property.name==="value"&&e.replaceWith(yn(e))}function gn(e){if((0,f.isArrayExpression)(e.node)){let t=e.get("elements");(0,be.strict)(Array.isArray(t),"[Reanimated] `elements` should be an array.");for(let r of t)r.isObjectExpression()&&ye(r)}}function ye(e){let t=e.get("properties");for(let r of t)if(r.isObjectProperty()){let i=r.get("value");(0,f.isIdentifier)(r.node.key)&&r.node.key.name==="transform"?gn(i):kn(i)}}function _n(e,t){if((0,bn.isRelease)()||t.opts.disableInlineStylesWarning||e.node.name.name!=="style"||!(0,f.isJSXExpressionContainer)(e.node.value))return;let r=e.get("value").get("expression");if((0,be.strict)(!Array.isArray(r),"[Reanimated] `expression` should not be an array."),r.isArrayExpression()){let i=r.get("elements");(0,be.strict)(Array.isArray(i),"[Reanimated] `elements` should be an array.");for(let n of i)n.isObjectExpression()&&ye(n)}else r.isObjectExpression()&&ye(r)}ne.processInlineStylesWarning=_n});var it=p(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.substituteWebCallExpression=void 0;var nt=require("@babel/types");function vn(e){let t=e.node.callee;if((0,nt.isIdentifier)(t)){let r=t.name;(r==="isWeb"||r==="shouldBeUseWeb")&&e.replaceWith((0,nt.booleanLiteral)(!0))}}ie.substituteWebCallExpression=vn});Object.defineProperty(exports,"__esModule",{value:!0});var ot=He(),On=Xe(),hn=pe(),En=tt(),In=le(),Sn=rt(),xn=x(),Wn=it(),wn=K();module.exports=function(){function e(t){try{t()}catch(r){throw new Error(`[Reanimated] Babel plugin exception: ${r}`)}}return{name:"reanimated",pre(){e(()=>{(0,In.initializeState)(this)})},visitor:{CallExpression:{enter(t,r){e(()=>{(0,ot.processCalleesAutoworkletizableCallbacks)(t,r),r.opts.substituteWebPlatformChecks&&(0,Wn.substituteWebCallExpression)(t)})}},[xn.WorkletizableFunction]:{enter(t,r){e(()=>{(0,wn.processIfWithWorkletDirective)(t,r)||(0,ot.processIfAutoworkletizableCallback)(t,r)})}},ObjectExpression:{enter(t,r){e(()=>{(0,hn.processIfWorkletContextObject)(t,r)})}},ClassDeclaration:{enter(t,r){e(()=>{(0,On.processIfWorkletClass)(t,r)})}},Program:{enter(t,r){e(()=>{(0,En.processIfWorkletFile)(t,r)})}},JSXAttribute:{enter(t,r){e(()=>(0,Sn.processInlineStylesWarning)(t,r))}}}}};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,53 @@
1
+ def worklets_try_to_parse_react_native_package_json(node_modules_dir)
2
+ react_native_package_json_path = File.join(node_modules_dir, 'react-native/package.json')
3
+ if !File.exist?(react_native_package_json_path)
4
+ return nil
5
+ end
6
+ return JSON.parse(File.read(react_native_package_json_path))
7
+ end
8
+
9
+ def worklets_find_config()
10
+ result = {
11
+ :is_reanimated_example_app => nil,
12
+ :react_native_version => nil,
13
+ :react_native_minor_version => nil,
14
+ :react_native_node_modules_dir => nil,
15
+ :react_native_common_dir => nil
16
+ }
17
+
18
+ react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
19
+ react_native_json = worklets_try_to_parse_react_native_package_json(react_native_node_modules_dir)
20
+
21
+ if react_native_json == nil
22
+ # user configuration, just in case
23
+ node_modules_dir = ENV["REACT_NATIVE_NODE_MODULES_DIR"]
24
+ react_native_json = worklets_try_to_parse_react_native_package_json(node_modules_dir)
25
+ end
26
+
27
+ if react_native_json == nil
28
+ raise '[Worklets] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
29
+ end
30
+
31
+ result[:is_reanimated_example_app] = ENV["IS_REANIMATED_EXAMPLE_APP"] != nil
32
+ result[:react_native_version] = react_native_json['version']
33
+ result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
34
+ if result[:react_native_minor_version] == 0 # nightly
35
+ result[:react_native_minor_version] = 1000
36
+ end
37
+ result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
38
+
39
+ pods_root = Pod::Config.instance.project_pods_root
40
+ react_native_common_dir_absolute = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
41
+ react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
42
+ result[:react_native_common_dir] = react_native_common_dir_relative
43
+
44
+ return result
45
+ end
46
+
47
+ def worklets_assert_minimal_react_native_version(config)
48
+ # If you change the minimal React Native version remember to update Compatibility Table in docs
49
+ minimalReactNativeVersion = 75
50
+ if config[:react_native_minor_version] < minimalReactNativeVersion
51
+ raise "[Worklets] Unsupported React Native version. Please use #{minimalReactNativeVersion} or newer."
52
+ end
53
+ end
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+ import { Platform } from 'react-native';
3
+
4
+ // This type is necessary since some libraries tend to do a lib check
5
+ // and this file causes type errors on `global` access.
6
+ type localGlobal = typeof global & Record<string, unknown>;
7
+
8
+ export function isJest(): boolean {
9
+ return !!process.env.JEST_WORKER_ID;
10
+ }
11
+
12
+ // `isChromeDebugger` also returns true in Jest environment, so `isJest()` check should always be performed first
13
+ export function isChromeDebugger(): boolean {
14
+ return (
15
+ (!(global as localGlobal).nativeCallSyncHook ||
16
+ !!(global as localGlobal).__REMOTEDEV__) &&
17
+ !(global as localGlobal).RN$Bridgeless
18
+ );
19
+ }
20
+
21
+ export function isWeb(): boolean {
22
+ return Platform.OS === 'web';
23
+ }
24
+
25
+ export function isAndroid(): boolean {
26
+ return Platform.OS === 'android';
27
+ }
28
+
29
+ function isWindows(): boolean {
30
+ return Platform.OS === 'windows';
31
+ }
32
+
33
+ export function shouldBeUseWeb() {
34
+ return isJest() || isChromeDebugger() || isWeb() || isWindows();
35
+ }
36
+
37
+ export function isWindowAvailable() {
38
+ // the window object is unavailable when building the server portion of a site that uses SSG
39
+ // this function shouldn't be used to conditionally render components
40
+ // https://www.joshwcomeau.com/react/the-perils-of-rehydration/
41
+ // @ts-ignore Fallback if `window` is undefined.
42
+ return typeof window !== 'undefined';
43
+ }
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ import { createCustomError, registerCustomError } from './errors';
4
+
5
+ export const WorkletsError = createCustomError('Worklets');
6
+
7
+ // To capture it in a the registering worklet's closure.
8
+ const WorkletsErrorConstructor = WorkletsError;
9
+
10
+ export function registerWorkletsError() {
11
+ 'worklet';
12
+ registerCustomError(WorkletsErrorConstructor, 'Worklets');
13
+ }