react-native-worklets 0.3.0 → 0.4.0-bundle-mode-preview-1

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 (202) hide show
  1. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +532 -0
  2. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +88 -0
  3. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +40 -122
  4. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +16 -40
  5. package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +2 -1
  6. package/Common/cpp/worklets/Resources/ValueUnpacker.cpp +1 -1
  7. package/Common/cpp/worklets/SharedItems/Shareables.cpp +200 -24
  8. package/Common/cpp/worklets/SharedItems/Shareables.h +108 -7
  9. package/Common/cpp/worklets/Tools/JSLogger.cpp +56 -4
  10. package/Common/cpp/worklets/Tools/JSLogger.h +17 -0
  11. package/Common/cpp/worklets/Tools/JSScheduler.cpp +12 -0
  12. package/Common/cpp/worklets/Tools/JSScheduler.h +10 -2
  13. package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +3 -1
  14. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +19 -1
  15. package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +12 -3
  16. package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +136 -0
  17. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +4 -4
  18. package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +1 -1
  19. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +85 -0
  20. package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +55 -0
  21. package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +8 -4
  22. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +70 -24
  23. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +24 -4
  24. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +53 -1
  25. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +2 -1
  26. package/RNWorklets.podspec +9 -4
  27. package/android/CMakeLists.txt +14 -36
  28. package/android/build.gradle +16 -33
  29. package/android/src/experimentalBundling/com/swmansion/worklets/WorkletsModule.java +149 -0
  30. package/android/src/{main/java → legacyBundling}/com/swmansion/worklets/WorkletsModule.java +17 -2
  31. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +49 -8
  32. package/android/src/main/cpp/worklets/android/WorkletsModule.h +17 -2
  33. package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +1 -1
  34. package/apple/worklets/apple/WorkletsMessageThread.mm +4 -0
  35. package/apple/worklets/apple/WorkletsModule.h +16 -1
  36. package/apple/worklets/apple/WorkletsModule.mm +29 -2
  37. package/bundleMode/index.d.ts +3 -0
  38. package/bundleMode/index.js +55 -0
  39. package/lib/module/PlatformChecker/PlatformChecker.js +8 -0
  40. package/lib/module/PlatformChecker/PlatformChecker.js.map +1 -0
  41. package/lib/module/PlatformChecker/index.js +17 -0
  42. package/lib/module/PlatformChecker/index.js.map +1 -0
  43. package/lib/module/WorkletsError.js +2 -1
  44. package/lib/module/WorkletsError.js.map +1 -1
  45. package/lib/module/WorkletsModule/JSWorklets.js +36 -4
  46. package/lib/module/WorkletsModule/JSWorklets.js.map +1 -1
  47. package/lib/module/WorkletsModule/NativeWorklets.js +35 -15
  48. package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -1
  49. package/lib/module/WorkletsModule/workletsModuleInstance.js +2 -2
  50. package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -1
  51. package/lib/module/bundleUnpacker.js +47 -0
  52. package/lib/module/bundleUnpacker.js.map +1 -0
  53. package/lib/module/callGuard.js +30 -0
  54. package/lib/module/callGuard.js.map +1 -0
  55. package/lib/module/errors.js +30 -11
  56. package/lib/module/errors.js.map +1 -1
  57. package/lib/module/index.js +10 -7
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/initializers.js +123 -103
  60. package/lib/module/initializers.js.map +1 -1
  61. package/lib/module/logger.js +15 -0
  62. package/lib/module/logger.js.map +1 -0
  63. package/lib/module/privateGlobals.d.js +0 -1
  64. package/lib/module/privateGlobals.d.js.map +1 -1
  65. package/lib/module/publicGlobals.js +5 -0
  66. package/lib/module/publicGlobals.js.map +1 -0
  67. package/lib/module/runLoop/mockedRequestAnimationFrame.js.map +1 -0
  68. package/lib/module/runLoop/requestAnimationFrame.js +50 -0
  69. package/lib/module/runLoop/requestAnimationFrame.js.map +1 -0
  70. package/lib/module/runLoop/setImmediatePolyfill.js +15 -0
  71. package/lib/module/runLoop/setImmediatePolyfill.js.map +1 -0
  72. package/lib/module/runLoop/setIntervalPolyfill.js +26 -0
  73. package/lib/module/runLoop/setIntervalPolyfill.js.map +1 -0
  74. package/lib/module/runLoop/setTimeoutPolyfill.js +32 -0
  75. package/lib/module/runLoop/setTimeoutPolyfill.js.map +1 -0
  76. package/lib/module/runtimes.js +6 -10
  77. package/lib/module/runtimes.js.map +1 -1
  78. package/lib/module/shareableMappingCache.js +1 -3
  79. package/lib/module/shareableMappingCache.js.map +1 -1
  80. package/lib/module/shareables.js +116 -34
  81. package/lib/module/shareables.js.map +1 -1
  82. package/lib/module/specs/index.js +2 -2
  83. package/lib/module/specs/index.js.map +1 -1
  84. package/lib/module/threads.js +49 -54
  85. package/lib/module/threads.js.map +1 -1
  86. package/lib/module/valueUnpacker.js +3 -3
  87. package/lib/module/valueUnpacker.js.map +1 -1
  88. package/lib/module/workletRuntimeEntry.js +30 -0
  89. package/lib/module/workletRuntimeEntry.js.map +1 -0
  90. package/lib/typescript/PlatformChecker/PlatformChecker.d.ts +5 -0
  91. package/lib/typescript/PlatformChecker/PlatformChecker.d.ts.map +1 -0
  92. package/lib/typescript/PlatformChecker/index.d.ts +10 -0
  93. package/lib/typescript/PlatformChecker/index.d.ts.map +1 -0
  94. package/lib/typescript/WorkletsError.d.ts.map +1 -1
  95. package/lib/typescript/WorkletsModule/JSWorklets.d.ts.map +1 -1
  96. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +1 -3
  97. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -1
  98. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +1 -1
  99. package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -1
  100. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +1 -1
  101. package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -1
  102. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +12 -2
  103. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
  104. package/lib/typescript/bundleUnpacker.d.ts +7 -0
  105. package/lib/typescript/bundleUnpacker.d.ts.map +1 -0
  106. package/lib/typescript/callGuard.d.ts +4 -0
  107. package/lib/typescript/callGuard.d.ts.map +1 -0
  108. package/lib/typescript/errors.d.ts +13 -5
  109. package/lib/typescript/errors.d.ts.map +1 -1
  110. package/lib/typescript/index.d.ts +1 -2
  111. package/lib/typescript/index.d.ts.map +1 -1
  112. package/lib/typescript/initializers.d.ts +16 -5
  113. package/lib/typescript/initializers.d.ts.map +1 -1
  114. package/lib/typescript/logger.d.ts +5 -0
  115. package/lib/typescript/logger.d.ts.map +1 -0
  116. package/lib/typescript/publicGlobals.d.ts +22 -0
  117. package/lib/typescript/publicGlobals.d.ts.map +1 -0
  118. package/lib/typescript/runLoop/mockedRequestAnimationFrame.d.ts.map +1 -0
  119. package/lib/typescript/runLoop/requestAnimationFrame.d.ts.map +1 -0
  120. package/lib/typescript/runLoop/setImmediatePolyfill.d.ts +2 -0
  121. package/lib/typescript/runLoop/setImmediatePolyfill.d.ts.map +1 -0
  122. package/lib/typescript/runLoop/setIntervalPolyfill.d.ts +2 -0
  123. package/lib/typescript/runLoop/setIntervalPolyfill.d.ts.map +1 -0
  124. package/lib/typescript/runLoop/setTimeoutPolyfill.d.ts +2 -0
  125. package/lib/typescript/runLoop/setTimeoutPolyfill.d.ts.map +1 -0
  126. package/lib/typescript/runtimes.d.ts.map +1 -1
  127. package/lib/typescript/shareableMappingCache.d.ts.map +1 -1
  128. package/lib/typescript/shareables.d.ts +3 -2
  129. package/lib/typescript/shareables.d.ts.map +1 -1
  130. package/lib/typescript/specs/NativeWorkletsModule.d.ts +1 -1
  131. package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -1
  132. package/lib/typescript/specs/index.d.ts +2 -2
  133. package/lib/typescript/specs/index.d.ts.map +1 -1
  134. package/lib/typescript/threads.d.ts.map +1 -1
  135. package/lib/typescript/workletRuntimeEntry.d.ts +14 -0
  136. package/lib/typescript/workletRuntimeEntry.d.ts.map +1 -0
  137. package/lib/typescript/workletTypes.d.ts +14 -3
  138. package/lib/typescript/workletTypes.d.ts.map +1 -1
  139. package/package.json +17 -8
  140. package/plugin/index.js +145 -52
  141. package/scripts/worklets_utils.rb +9 -0
  142. package/src/PlatformChecker/PlatformChecker.ts +7 -0
  143. package/src/PlatformChecker/index.ts +29 -0
  144. package/src/WorkletsError.ts +2 -1
  145. package/src/WorkletsModule/JSWorklets.ts +71 -4
  146. package/src/WorkletsModule/NativeWorklets.ts +83 -21
  147. package/src/WorkletsModule/workletsModuleInstance.ts +2 -2
  148. package/src/WorkletsModule/workletsModuleProxy.ts +49 -1
  149. package/src/bundleUnpacker.ts +75 -0
  150. package/src/callGuard.ts +33 -0
  151. package/src/errors.ts +35 -18
  152. package/src/index.ts +12 -12
  153. package/src/initializers.ts +143 -113
  154. package/src/logger.ts +16 -0
  155. package/src/privateGlobals.d.ts +22 -6
  156. package/src/publicGlobals.ts +26 -0
  157. package/src/runLoop/requestAnimationFrame.ts +67 -0
  158. package/src/runLoop/setImmediatePolyfill.ts +20 -0
  159. package/src/runLoop/setIntervalPolyfill.ts +38 -0
  160. package/src/runLoop/setTimeoutPolyfill.ts +40 -0
  161. package/src/runtimes.ts +6 -11
  162. package/src/shareableMappingCache.ts +1 -3
  163. package/src/shareables.ts +179 -65
  164. package/src/specs/NativeWorkletsModule.ts +1 -1
  165. package/src/specs/index.ts +5 -2
  166. package/src/threads.ts +75 -65
  167. package/src/valueUnpacker.ts +3 -3
  168. package/src/workletRuntimeEntry.ts +30 -0
  169. package/src/workletTypes.ts +22 -5
  170. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +0 -139
  171. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +0 -61
  172. package/android/src/paper/com/swmansion/worklets/NativeWorkletsModuleSpec.java +0 -26
  173. package/lib/module/PlatformChecker.js +0 -26
  174. package/lib/module/PlatformChecker.js.map +0 -1
  175. package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js.map +0 -1
  176. package/lib/module/animationFrameQueue/requestAnimationFrame.js +0 -36
  177. package/lib/module/animationFrameQueue/requestAnimationFrame.js.map +0 -1
  178. package/lib/module/logger/LogBox.js +0 -15
  179. package/lib/module/logger/LogBox.js.map +0 -1
  180. package/lib/module/logger/index.js +0 -5
  181. package/lib/module/logger/index.js.map +0 -1
  182. package/lib/module/logger/logger.js +0 -137
  183. package/lib/module/logger/logger.js.map +0 -1
  184. package/lib/typescript/PlatformChecker.d.ts +0 -6
  185. package/lib/typescript/PlatformChecker.d.ts.map +0 -1
  186. package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts.map +0 -1
  187. package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts.map +0 -1
  188. package/lib/typescript/logger/LogBox.d.ts +0 -32
  189. package/lib/typescript/logger/LogBox.d.ts.map +0 -1
  190. package/lib/typescript/logger/index.d.ts +0 -3
  191. package/lib/typescript/logger/index.d.ts.map +0 -1
  192. package/lib/typescript/logger/logger.d.ts +0 -52
  193. package/lib/typescript/logger/logger.d.ts.map +0 -1
  194. package/src/PlatformChecker.ts +0 -30
  195. package/src/animationFrameQueue/requestAnimationFrame.ts +0 -41
  196. package/src/logger/LogBox.ts +0 -55
  197. package/src/logger/index.ts +0 -3
  198. package/src/logger/logger.ts +0 -155
  199. /package/lib/module/{animationFrameQueue → runLoop}/mockedRequestAnimationFrame.js +0 -0
  200. /package/lib/typescript/{animationFrameQueue → runLoop}/mockedRequestAnimationFrame.d.ts +0 -0
  201. /package/lib/typescript/{animationFrameQueue → runLoop}/requestAnimationFrame.d.ts +0 -0
  202. /package/src/{animationFrameQueue → runLoop}/mockedRequestAnimationFrame.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicGlobals.d.ts","sourceRoot":"","sources":["../../src/publicGlobals.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,IAAI,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAElC;;;OAGG;IACH,IAAI,gBAAgB,EAAE,WAAW,CAAC;IAElC,6BAA6B;IAC7B,IAAI,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;CACrC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockedRequestAnimationFrame.d.ts","sourceRoot":"","sources":["../../../src/runLoop/mockedRequestAnimationFrame.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GACpC,UAAU,CAAC,OAAO,UAAU,CAAC,CAE/B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestAnimationFrame.d.ts","sourceRoot":"","sources":["../../../src/runLoop/requestAnimationFrame.ts"],"names":[],"mappings":"AAIA,wBAAgB,0BAA0B,SA8DzC"}
@@ -0,0 +1,2 @@
1
+ export declare function setupSetImmediate(): void;
2
+ //# sourceMappingURL=setImmediatePolyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setImmediatePolyfill.d.ts","sourceRoot":"","sources":["../../../src/runLoop/setImmediatePolyfill.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,SAiBhC"}
@@ -0,0 +1,2 @@
1
+ export declare function setupSetInterval(): void;
2
+ //# sourceMappingURL=setIntervalPolyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setIntervalPolyfill.d.ts","sourceRoot":"","sources":["../../../src/runLoop/setIntervalPolyfill.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,SAmC/B"}
@@ -0,0 +1,2 @@
1
+ export declare function setupSetTimeout(): void;
2
+ //# sourceMappingURL=setTimeoutPolyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setTimeoutPolyfill.d.ts","sourceRoot":"","sources":["../../../src/runLoop/setTimeoutPolyfill.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,SAqC9B"}
@@ -1 +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"}
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;AAEtE;;;;;;;;;;;GAWG;AAEH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,cAAc,CAAC;AAoBlB,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"}
@@ -1 +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"}
1
+ {"version":3,"file":"shareableMappingCache.d.ts","sourceRoot":"","sources":["../../src/shareableMappingCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,eAA2B,CAAC;AAiB7D,eAAO,MAAM,qBAAqB;;;;mBAUb,MAAM,iBAAiB,YAAY,GAAG,IAAI;;CAI1D,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import type { FlatShareableRef, ShareableRef } from './workletTypes';
2
- export interface MakeShareableClone {
2
+ interface MakeShareableClone {
3
3
  <T>(value: T, shouldPersistRemote?: boolean, depth?: number): ShareableRef<T>;
4
4
  }
5
5
  export declare const makeShareableCloneRecursive: MakeShareableClone;
6
- export declare function makeShareableCloneOnUIRecursive<T>(value: T): FlatShareableRef<T>;
6
+ declare function makeShareableCloneOnUIRecursiveLEGACY<T>(value: T): FlatShareableRef<T>;
7
+ export declare const makeShareableCloneOnUIRecursive: typeof makeShareableCloneOnUIRecursiveLEGACY;
7
8
  declare function makeShareableJS<T extends object>(value: T): T;
8
9
  /**
9
10
  * This function creates a value on UI with persistent state - changes to it on
@@ -1 +1 @@
1
- {"version":3,"file":"shareables.d.ts","sourceRoot":"","sources":["../../src/shareables.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAiLxB,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;AAkWtC,wBAAgB,+BAA+B,CAAC,CAAC,EAC/C,KAAK,EAAE,CAAC,GACP,gBAAgB,CAAC,CAAC,CAAC,CAmErB;AAED,iBAAS,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEtD;AAgBD;;;;GAIG;AACH,eAAO,MAAM,aAAa,wBAEH,CAAC"}
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;AAuNxB,UAAU,kBAAkB;IAC1B,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;AA2atC,iBAAS,qCAAqC,CAAC,CAAC,EAC9C,KAAK,EAAE,CAAC,GACP,gBAAgB,CAAC,CAAC,CAAC,CA+DrB;AAED,eAAO,MAAM,+BAA+B,8CAIK,CAAC;AAElD,iBAAS,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEtD;AAgBD;;;;GAIG;AACH,eAAO,MAAM,aAAa,wBAEH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { TurboModule } from 'react-native';
2
- interface Spec extends TurboModule {
2
+ export interface Spec extends TurboModule {
3
3
  installTurboModule: () => boolean;
4
4
  }
5
5
  declare const _default: Spec | null;
@@ -1 +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,MAAM,OAAO,CAAC;CACnC;;AAED,wBAA+D"}
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,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,kBAAkB,EAAE,MAAM,OAAO,CAAC;CACnC;;AAED,wBAA+D"}
@@ -1,3 +1,3 @@
1
- import WorkletsTurboModule from './NativeWorkletsModule';
2
- export { WorkletsTurboModule };
1
+ import type { Spec } from './NativeWorkletsModule';
2
+ export declare const WorkletsTurboModule: Spec | null;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/specs/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAGnD,eAAO,MAAM,mBAAmB,EAAE,IAAI,GAAG,IA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EF,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,CA2CzB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EAC9D,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,GACtC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,WAAW,CAAC,CAqCzC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This function is an entry point for Worklet Runtimes. We can use it to setup
3
+ * necessary tools, like the ValueUnpacker.
4
+ *
5
+ * We must throw an error at the end of this function to prevent the bundle to
6
+ * continue executing. This is because the next module to be ran would be the
7
+ * React Native one, and it would break the Worklet Runtime if initialized. The
8
+ * error is caught in C++ code.
9
+ *
10
+ * This function has no effect on the RN Runtime beside setting the
11
+ * `_WORKLETS_BUNDLE_MODE` flag.
12
+ */
13
+ export declare function bundleModeInit(): void;
14
+ //# sourceMappingURL=workletRuntimeEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workletRuntimeEntry.d.ts","sourceRoot":"","sources":["../../src/workletRuntimeEntry.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,SAU7B"}
@@ -20,7 +20,7 @@ export type WorkletStackDetails = [
20
20
  lineOffset: number,
21
21
  columnOffset: number
22
22
  ];
23
- type WorkletClosure = Record<string, unknown>;
23
+ export type WorkletClosure = Record<string, unknown>;
24
24
  interface WorkletInitData {
25
25
  code: string;
26
26
  /** Only in dev builds. */
@@ -30,7 +30,7 @@ interface WorkletInitData {
30
30
  /** Only in dev builds. */
31
31
  version?: string;
32
32
  }
33
- export interface WorkletProps {
33
+ interface WorkletProps {
34
34
  __closure: WorkletClosure;
35
35
  __workletHash: number;
36
36
  __initData: WorkletInitData;
@@ -39,10 +39,21 @@ export interface WorkletProps {
39
39
  /** `__stackDetails` is removed after parsing. */
40
40
  __stackDetails?: WorkletStackDetails;
41
41
  }
42
- export type WorkletFunction<Args extends unknown[] = unknown[], ReturnValue = unknown> = ((...args: Args) => ReturnValue) & WorkletProps;
42
+ export type WorkletFunction<TArgs extends unknown[] = unknown[], TReturn = unknown> = ((...args: TArgs) => TReturn) & WorkletProps;
43
+ export interface WorkletFactory<TArgs extends unknown[] = unknown[], TReturn = unknown, TClosureVariables extends Record<string, unknown> = Record<string, unknown>> {
44
+ (closureVariables: TClosureVariables): WorkletFunction<TArgs, TReturn>;
45
+ }
43
46
  export type ValueUnpacker = WorkletFunction<[
44
47
  objectToUnpack: unknown,
45
48
  category?: string
46
49
  ], unknown>;
50
+ export interface WorkletImport {
51
+ __bundleData: {
52
+ /** Name of the module which is the source of the import. */
53
+ source: string;
54
+ /** The name of the imported value. */
55
+ imported: string;
56
+ };
57
+ }
47
58
  export {};
48
59
  //# sourceMappingURL=workletTypes.d.ts.map
@@ -1 +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,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AE,GAAG,OAAO,EAAE,EACnC,OAAO,GAAG,OAAO,EACjB,iBAAiB,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE3E,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CACxE;AAED,MAAM,MAAM,aAAa,GAAG,eAAe,CACzC;IAAC,cAAc,EAAE,OAAO;IAAE,QAAQ,CAAC,EAAE,MAAM;CAAC,EAC5C,OAAO,CACR,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE;QACZ,4DAA4D;QAC5D,MAAM,EAAE,MAAM,CAAC;QACf,sCAAsC;QACtC,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-worklets",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-bundle-mode-preview-1",
4
4
  "description": "The React Native multithreading library",
5
5
  "keywords": [
6
6
  "react-native",
@@ -9,10 +9,10 @@
9
9
  "worklets"
10
10
  ],
11
11
  "scripts": {
12
- "build": "bob build && yarn build:valueUnpacker",
12
+ "build": "yarn workspace babel-plugin-worklets build && bob build && yarn build:valueUnpacker",
13
13
  "build:valueUnpacker": "node ./scripts/export-value-unpacker.js",
14
- "circular-dependency-check": "yarn madge --extensions js,jsx,ts,tsx --circular src lib",
15
- "find-unused-code:js": "yarn ts-prune --ignore \"index|.web.\" --error",
14
+ "circular-dependency-check": "yarn madge --extensions js,jsx --circular lib",
15
+ "find-unused-code:js": "knip",
16
16
  "format": "yarn format:js && yarn format:plugin && yarn format:common && yarn format:android && yarn format:apple",
17
17
  "format:android": "yarn format:android:java && yarn format:android:cpp && yarn format:android:cmake",
18
18
  "format:android:cpp": "find android/src -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
@@ -69,19 +69,19 @@
69
69
  "@babel/cli": "^7.20.0",
70
70
  "@babel/core": "^7.25.2",
71
71
  "@react-native-community/cli": "19.0.0",
72
- "@react-native/eslint-config": "0.80.0-rc.2",
72
+ "@react-native/eslint-config": "0.80.0",
73
73
  "@types/jest": "^29.5.5",
74
74
  "@types/react": "^19.1.0",
75
- "@typescript-eslint/eslint-plugin": "^6.19.0",
76
75
  "babel-plugin-worklets": "workspace:*",
77
76
  "clang-format-node": "^1.3.1",
78
- "eslint": "^8.57.0",
77
+ "eslint": "^9.29.0",
79
78
  "eslint-plugin-reanimated": "workspace:*",
80
79
  "jest": "^29.0.0",
80
+ "knip": "^5.61.3",
81
81
  "madge": "^5.0.1",
82
82
  "prettier": "^3.3.3",
83
83
  "react": "19.1.0",
84
- "react-native": "0.80.0-rc.2",
84
+ "react-native": "patch:react-native@npm%3A0.80.0#~/.yarn/patches/react-native-npm-0.80.0-dababd395b.patch",
85
85
  "react-native-builder-bob": "patch:react-native-builder-bob@npm%3A0.33.1#~/.yarn/patches/react-native-builder-bob-npm-0.33.1-383d9e23a5.patch",
86
86
  "typescript": "~5.3.0"
87
87
  },
@@ -96,6 +96,8 @@
96
96
  "android",
97
97
  "apple",
98
98
  "Common",
99
+ "bundleMode/index.js",
100
+ "bundleMode/index.d.ts",
99
101
  "scripts/worklets_utils.rb",
100
102
  "plugin/index.js",
101
103
  "*.podspec",
@@ -131,6 +133,13 @@
131
133
  "jsSrcsDir": "src/specs",
132
134
  "android": {
133
135
  "javaPackageName": "com.swmansion.worklets"
136
+ },
137
+ "ios": {
138
+ "modulesConformingToProtocol": {
139
+ "RCTBundleConsumer": [
140
+ "WorkletsModule"
141
+ ]
142
+ }
134
143
  }
135
144
  }
136
145
  }
package/plugin/index.js CHANGED
@@ -245,7 +245,7 @@ var require_types = __commonJS({
245
245
  "lib/types.js"(exports2) {
246
246
  "use strict";
247
247
  Object.defineProperty(exports2, "__esModule", { value: true });
248
- exports2.workletClassFactorySuffix = exports2.isWorkletizableObjectNode = exports2.isWorkletizableObjectPath = exports2.isWorkletizableFunctionNode = exports2.isWorkletizableFunctionPath = exports2.WorkletizableObject = exports2.WorkletizableFunction = void 0;
248
+ exports2.generatedWorkletsDir = exports2.workletClassFactorySuffix = exports2.isWorkletizableObjectNode = exports2.isWorkletizableObjectPath = exports2.isWorkletizableFunctionNode = exports2.isWorkletizableFunctionPath = exports2.WorkletizableObject = exports2.WorkletizableFunction = void 0;
249
249
  var types_12 = require("@babel/types");
250
250
  exports2.WorkletizableFunction = "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod";
251
251
  exports2.WorkletizableObject = "ObjectExpression";
@@ -266,6 +266,7 @@ var require_types = __commonJS({
266
266
  }
267
267
  exports2.isWorkletizableObjectNode = isWorkletizableObjectNode;
268
268
  exports2.workletClassFactorySuffix = "__classFactory";
269
+ exports2.generatedWorkletsDir = "__generatedWorklets";
269
270
  }
270
271
  });
271
272
 
@@ -304,7 +305,7 @@ var require_globals = __commonJS({
304
305
  "lib/globals.js"(exports2) {
305
306
  "use strict";
306
307
  Object.defineProperty(exports2, "__esModule", { value: true });
307
- exports2.addCustomGlobals = exports2.initializeGlobals = exports2.globals = exports2.defaultGlobals = exports2.initializeState = void 0;
308
+ exports2.addCustomGlobals = exports2.initializeGlobals = exports2.globals = exports2.defaultGlobals = exports2.initializeState = exports2.internalBindingsToCaptureFromGlobalScope = exports2.outsideBindingsToCaptureFromGlobalScope = void 0;
308
309
  var notCapturedIdentifiers = [
309
310
  "globalThis",
310
311
  "Infinity",
@@ -379,35 +380,30 @@ var require_globals = __commonJS({
379
380
  "global",
380
381
  "window",
381
382
  "globalThis",
383
+ "self",
382
384
  "console",
383
385
  "performance",
386
+ "arguments",
387
+ "require",
384
388
  "queueMicrotask",
385
389
  "requestAnimationFrame",
390
+ "cancelAnimationFrame",
391
+ "setTimeout",
392
+ "clearTimeout",
386
393
  "setImmediate",
387
- "arguments",
394
+ "clearImmediate",
395
+ "setInterval",
396
+ "clearInterval",
388
397
  "HermesInternal",
389
- "ReanimatedError",
390
- "_WORKLET",
391
- "WorkletsError",
392
- "__workletsLoggerConfig"
393
- ];
394
- var notCapturedIdentifiers_DEPRECATED = [
395
- "_IS_FABRIC",
396
- "_log",
397
- "_toString",
398
- "_scheduleHostFunctionOnJS",
399
- "_scheduleRemoteFunctionOnJS",
400
- "_scheduleOnRuntime",
401
- "_makeShareableClone",
402
- "_updateProps",
403
- "_measure",
404
- "_dispatchCommand",
405
- "_setGestureState",
406
- "_notifyAboutProgress",
407
- "_notifyAboutEnd",
408
- "_runOnUIQueue",
409
- "_getAnimationTimestamp"
398
+ "_WORKLET"
410
399
  ];
400
+ exports2.outsideBindingsToCaptureFromGlobalScope = /* @__PURE__ */ new Set([
401
+ "ReanimatedError"
402
+ ]);
403
+ exports2.internalBindingsToCaptureFromGlobalScope = /* @__PURE__ */ new Set([
404
+ "WorkletsError"
405
+ ]);
406
+ var notCapturedIdentifiers_DEPRECATED = ["_IS_FABRIC"];
411
407
  function initializeState(state) {
412
408
  state.workletNumber = 1;
413
409
  state.classesToWorkletize = [];
@@ -442,6 +438,8 @@ var require_closure = __commonJS({
442
438
  function getClosure(funPath, state) {
443
439
  const capturedNames = /* @__PURE__ */ new Set();
444
440
  const closureVariables = new Array();
441
+ const libraryBindingsToImport = /* @__PURE__ */ new Set();
442
+ const relativeBindingsToImport = /* @__PURE__ */ new Set();
445
443
  funPath.traverse({
446
444
  "TSType|TSTypeAliasDeclaration|TSInterfaceDeclaration"(typePath) {
447
445
  typePath.skip();
@@ -454,7 +452,16 @@ var require_closure = __commonJS({
454
452
  if (capturedNames.has(name)) {
455
453
  return;
456
454
  }
457
- if (globals_12.globals.has(name)) {
455
+ const binding = idPath.scope.getBinding(name);
456
+ if (!binding) {
457
+ if (globals_12.globals.has(name)) {
458
+ return;
459
+ }
460
+ capturedNames.add(name);
461
+ closureVariables.push((0, types_12.cloneNode)(idPath.node, true));
462
+ return;
463
+ }
464
+ if (globals_12.outsideBindingsToCaptureFromGlobalScope.has(name) || !state.opts.bundleMode && globals_12.internalBindingsToCaptureFromGlobalScope.has(name)) {
458
465
  return;
459
466
  }
460
467
  if ("id" in funPath.node) {
@@ -470,13 +477,88 @@ var require_closure = __commonJS({
470
477
  }
471
478
  scope = scope.parent;
472
479
  }
480
+ if (state.opts.bundleMode && isImport(binding)) {
481
+ if (isImportRelative(binding) && isAllowedForRelativeImports(state.filename, state.opts.workletizableModules)) {
482
+ capturedNames.add(name);
483
+ relativeBindingsToImport.add(binding);
484
+ return;
485
+ }
486
+ const source = binding.path.parentPath.node.source.value;
487
+ if (isWorkletizableModule(source, state.opts.workletizableModules)) {
488
+ capturedNames.add(name);
489
+ libraryBindingsToImport.add(binding);
490
+ return;
491
+ }
492
+ }
473
493
  capturedNames.add(name);
474
494
  closureVariables.push((0, types_12.cloneNode)(idPath.node, true));
475
495
  }
476
496
  }, state);
477
- return closureVariables;
497
+ return {
498
+ closureVariables,
499
+ libraryBindingsToImport,
500
+ relativeBindingsToImport
501
+ };
478
502
  }
479
503
  exports2.getClosure = getClosure;
504
+ function isImport(binding) {
505
+ return binding.kind === "module" && binding.constant && binding.path.isImportSpecifier() && binding.path.parentPath.isImportDeclaration();
506
+ }
507
+ function isImportRelative(imported) {
508
+ return imported.path.parentPath.node.source.value.startsWith(".");
509
+ }
510
+ function isAllowedForRelativeImports(filename, workletizableModules) {
511
+ return !!filename && (filename.includes("react-native-worklets") || !!(workletizableModules === null || workletizableModules === void 0 ? void 0 : workletizableModules.some((module3) => filename.includes(module3))));
512
+ }
513
+ function isWorkletizableModule(source, workletizableModules) {
514
+ return source.startsWith("react-native-worklets") || !!(workletizableModules === null || workletizableModules === void 0 ? void 0 : workletizableModules.some((module3) => source.startsWith(module3)));
515
+ }
516
+ }
517
+ });
518
+
519
+ // lib/generate.js
520
+ var require_generate = __commonJS({
521
+ "lib/generate.js"(exports2) {
522
+ "use strict";
523
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
524
+ return mod && mod.__esModule ? mod : { "default": mod };
525
+ };
526
+ Object.defineProperty(exports2, "__esModule", { value: true });
527
+ exports2.generateWorkletFile = void 0;
528
+ var core_1 = require("@babel/core");
529
+ var types_12 = require("@babel/types");
530
+ var assert_1 = __importDefault(require("assert"));
531
+ var fs_1 = require("fs");
532
+ var path_1 = require("path");
533
+ var types_2 = require_types();
534
+ function generateWorkletFile(libraryBindingsToImport, relativeBindingsToImport, factory, workletHash, state) {
535
+ var _a;
536
+ const libraryImports = Array.from(libraryBindingsToImport).filter((binding) => binding.path.isImportSpecifier() && binding.path.parentPath.isImportDeclaration()).map((binding) => (0, types_12.importDeclaration)([(0, types_12.cloneNode)(binding.path.node, true)], (0, types_12.stringLiteral)(binding.path.parentPath.node.source.value)));
537
+ const filesDirPath = (0, path_1.resolve)((0, path_1.dirname)(require.resolve("react-native-worklets/package.json")), types_2.generatedWorkletsDir);
538
+ const relativeImports = Array.from(relativeBindingsToImport).filter((binding) => binding.path.isImportSpecifier() && binding.path.parentPath.isImportDeclaration()).map((binding) => {
539
+ const resolved = (0, path_1.resolve)((0, path_1.dirname)(state.file.opts.filename), binding.path.parentPath.node.source.value);
540
+ const importPath = (0, path_1.relative)(filesDirPath, resolved);
541
+ return (0, types_12.importDeclaration)([(0, types_12.cloneNode)(binding.path.node, true)], (0, types_12.stringLiteral)(importPath));
542
+ });
543
+ const imports = [...libraryImports, ...relativeImports];
544
+ const newProg = (0, types_12.program)([...imports, (0, types_12.exportDefaultDeclaration)(factory)]);
545
+ const transformedProg = (_a = (0, core_1.transformFromAstSync)(newProg, void 0, {
546
+ filename: state.file.opts.filename,
547
+ presets: ["@babel/preset-typescript"],
548
+ plugins: [],
549
+ ast: false,
550
+ babelrc: false,
551
+ configFile: false,
552
+ comments: false
553
+ })) === null || _a === void 0 ? void 0 : _a.code;
554
+ (0, assert_1.default)(transformedProg, "[Worklets] `transformedProg` is undefined.");
555
+ if (!(0, fs_1.existsSync)(filesDirPath)) {
556
+ (0, fs_1.mkdirSync)(filesDirPath, {});
557
+ }
558
+ const dedicatedFilePath = (0, path_1.resolve)(filesDirPath, `${workletHash}.js`);
559
+ (0, fs_1.writeFileSync)(dedicatedFilePath, transformedProg);
560
+ }
561
+ exports2.generateWorkletFile = generateWorkletFile;
480
562
  }
481
563
  });
482
564
 
@@ -694,6 +776,7 @@ var require_workletFactory = __commonJS({
694
776
  var assert_1 = require("assert");
695
777
  var path_1 = require("path");
696
778
  var closure_1 = require_closure();
779
+ var generate_1 = require_generate();
697
780
  var transform_1 = require_transform();
698
781
  var types_2 = require_types();
699
782
  var utils_1 = require_utils();
@@ -720,7 +803,7 @@ var require_workletFactory = __commonJS({
720
803
  });
721
804
  (0, assert_1.strict)(transformed, "[Reanimated] `transformed` is undefined.");
722
805
  (0, assert_1.strict)(transformed.ast, "[Reanimated] `transformed.ast` is undefined.");
723
- const closureVariables = (0, closure_1.getClosure)(fun, state);
806
+ const { closureVariables, libraryBindingsToImport, relativeBindingsToImport } = (0, closure_1.getClosure)(fun, state);
724
807
  const clone = (0, types_12.cloneNode)(fun.node);
725
808
  const funExpression = (0, types_12.isBlockStatement)(clone.body) ? (0, types_12.functionExpression)(null, clone.params, clone.body, clone.generator, clone.async) : clone;
726
809
  const { workletName, reactName } = makeWorkletName(fun, state);
@@ -758,7 +841,7 @@ var require_workletFactory = __commonJS({
758
841
  initDataObjectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)("version"), (0, types_12.stringLiteral)(shouldMockVersion() ? MOCK_VERSION : REAL_VERSION)));
759
842
  }
760
843
  const shouldIncludeInitData = !state.opts.omitNativeOnlyData;
761
- if (shouldIncludeInitData) {
844
+ if (shouldIncludeInitData && !state.opts.bundleMode) {
762
845
  pathForStringDefinitions.insertBefore((0, types_12.variableDeclaration)("const", [
763
846
  (0, types_12.variableDeclarator)(initDataId, initDataObjectExpression)
764
847
  ]));
@@ -769,10 +852,10 @@ var require_workletFactory = __commonJS({
769
852
  (0, types_12.variableDeclaration)("const", [
770
853
  (0, types_12.variableDeclarator)((0, types_12.identifier)(reactName), funExpression)
771
854
  ]),
772
- (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(closureVariables.map((variable) => variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.cloneNode)(variable, true), (0, types_12.cloneNode)(variable, true), false, true))))),
855
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(closureVariables.map((variable) => !state.opts.bundleMode && variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.cloneNode)(variable, true), (0, types_12.cloneNode)(variable, true), false, true))))),
773
856
  (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__workletHash"), false), (0, types_12.numericLiteral)(workletHash)))
774
857
  ];
775
- if (shouldIncludeInitData) {
858
+ if (shouldIncludeInitData && !state.opts.bundleMode) {
776
859
  statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__initData"), false), (0, types_12.cloneNode)(initDataId, true))));
777
860
  }
778
861
  if (!(0, utils_1.isRelease)()) {
@@ -786,29 +869,32 @@ var require_workletFactory = __commonJS({
786
869
  statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__stackDetails"), false), (0, types_12.identifier)("_e"))));
787
870
  }
788
871
  statements.push((0, types_12.returnStatement)((0, types_12.identifier)(reactName)));
789
- const factoryParams = [
790
- (0, types_12.cloneNode)(initDataId, true),
791
- ...closureVariables.map((variableId) => {
792
- const clonedId = (0, types_12.cloneNode)(variableId, true);
793
- if (clonedId.name.endsWith(types_2.workletClassFactorySuffix)) {
794
- clonedId.name = clonedId.name.slice(0, clonedId.name.length - types_2.workletClassFactorySuffix.length);
795
- }
796
- return clonedId;
797
- })
798
- ];
872
+ const factoryParams = closureVariables.map((variableId) => {
873
+ const clonedId = (0, types_12.cloneNode)(variableId, true);
874
+ if (!state.opts.bundleMode && clonedId.name.endsWith(types_2.workletClassFactorySuffix)) {
875
+ clonedId.name = clonedId.name.slice(0, clonedId.name.length - types_2.workletClassFactorySuffix.length);
876
+ }
877
+ return clonedId;
878
+ });
879
+ if (shouldIncludeInitData && !state.opts.bundleMode) {
880
+ factoryParams.unshift((0, types_12.cloneNode)(initDataId, true));
881
+ }
799
882
  const factoryParamObjectPattern = (0, types_12.objectPattern)(factoryParams.map((param) => (0, types_12.objectProperty)((0, types_12.cloneNode)(param, true), (0, types_12.cloneNode)(param, true), false, true)));
800
883
  const factory = (0, types_12.functionExpression)((0, types_12.identifier)(workletName + "Factory"), [factoryParamObjectPattern], (0, types_12.blockStatement)(statements));
801
884
  const factoryCallArgs = factoryParams.map((param) => (0, types_12.cloneNode)(param, true));
802
885
  const factoryCallParamPack = (0, types_12.objectExpression)(factoryCallArgs.map((param) => (0, types_12.objectProperty)((0, types_12.cloneNode)(param, true), (0, types_12.cloneNode)(param, true), false, true)));
886
+ if (state.opts.bundleMode) {
887
+ (0, generate_1.generateWorkletFile)(libraryBindingsToImport, relativeBindingsToImport, factory, workletHash, state);
888
+ }
803
889
  factory.workletized = true;
804
- return { factory, factoryCallParamPack };
890
+ return { factory, factoryCallParamPack, workletHash };
805
891
  }
806
892
  exports2.makeWorkletFactory = makeWorkletFactory;
807
893
  function removeWorkletDirective(fun) {
808
894
  fun.traverse({
809
- DirectiveLiteral(path) {
810
- if (path.node.value === "worklet" && path.getFunctionParent() === fun) {
811
- path.parentPath.remove();
895
+ DirectiveLiteral(nodePath) {
896
+ if (nodePath.node.value === "worklet" && nodePath.getFunctionParent() === fun) {
897
+ nodePath.parentPath.remove();
812
898
  }
813
899
  }
814
900
  });
@@ -870,10 +956,18 @@ var require_workletFactoryCall = __commonJS({
870
956
  Object.defineProperty(exports2, "__esModule", { value: true });
871
957
  exports2.makeWorkletFactoryCall = void 0;
872
958
  var types_12 = require("@babel/types");
959
+ var types_2 = require_types();
873
960
  var workletFactory_1 = require_workletFactory();
874
961
  function makeWorkletFactoryCall(path, state) {
875
- const { factory, factoryCallParamPack } = (0, workletFactory_1.makeWorkletFactory)(path, state);
876
- const factoryCall = (0, types_12.callExpression)(factory, [factoryCallParamPack]);
962
+ const { factory, factoryCallParamPack, workletHash } = (0, workletFactory_1.makeWorkletFactory)(path, state);
963
+ let factoryCall;
964
+ if (state.opts.bundleMode) {
965
+ factoryCall = (0, types_12.callExpression)((0, types_12.memberExpression)((0, types_12.callExpression)((0, types_12.identifier)("require"), [
966
+ (0, types_12.stringLiteral)(`react-native-worklets/${types_2.generatedWorkletsDir}/${workletHash}.js`)
967
+ ]), (0, types_12.identifier)("default")), [factoryCallParamPack]);
968
+ } else {
969
+ factoryCall = (0, types_12.callExpression)(factory, [factoryCallParamPack]);
970
+ }
877
971
  addStackTraceDataToWorkletFactory(path, factoryCall);
878
972
  const replacement = factoryCall;
879
973
  return replacement;
@@ -1058,7 +1152,6 @@ var require_autoworkletization = __commonJS({
1058
1152
  "useDerivedValue",
1059
1153
  "useAnimatedScrollHandler",
1060
1154
  "useAnimatedReaction",
1061
- "useWorkletCallback",
1062
1155
  "withTiming",
1063
1156
  "withSpring",
1064
1157
  "withDecay",
@@ -1075,7 +1168,6 @@ var require_autoworkletization = __commonJS({
1075
1168
  ["useDerivedValue", [0]],
1076
1169
  ["useAnimatedScrollHandler", [0]],
1077
1170
  ["useAnimatedReaction", [0, 1]],
1078
- ["useWorkletCallback", [0]],
1079
1171
  ["withTiming", [2]],
1080
1172
  ["withSpring", [2]],
1081
1173
  ["withDecay", [1]],
@@ -1609,7 +1701,10 @@ module.exports = function WorkletsBabelPlugin() {
1609
1701
  try {
1610
1702
  fun();
1611
1703
  } catch (e) {
1612
- throw new Error(`[Worklets] Babel plugin exception: ${e}`);
1704
+ const error = e;
1705
+ error.message = `[Worklets] Babel plugin exception: ${error.message}`;
1706
+ error.name = "WorkletsBabelPluginError";
1707
+ throw error;
1613
1708
  }
1614
1709
  }
1615
1710
  return {
@@ -1632,9 +1727,7 @@ module.exports = function WorkletsBabelPlugin() {
1632
1727
  },
1633
1728
  [types_1.WorkletizableFunction]: {
1634
1729
  enter(path, state) {
1635
- runWithTaggedExceptions(() => {
1636
- (0, workletSubstitution_1.processIfWithWorkletDirective)(path, state) || (0, autoworkletization_1.processIfAutoworkletizableCallback)(path, state);
1637
- });
1730
+ runWithTaggedExceptions(() => (0, workletSubstitution_1.processIfWithWorkletDirective)(path, state) || (0, autoworkletization_1.processIfAutoworkletizableCallback)(path, state));
1638
1731
  }
1639
1732
  },
1640
1733
  ObjectExpression: {
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  def worklets_find_config()
10
10
  result = {
11
+ :bundle_mode => nil,
11
12
  :is_reanimated_example_app => nil,
12
13
  :react_native_version => nil,
13
14
  :react_native_minor_version => nil,
@@ -16,6 +17,8 @@ def worklets_find_config()
16
17
  :dynamic_frameworks_worklets_dir => nil,
17
18
  }
18
19
 
20
+ result[:bundle_mode] = ENV["WORKLETS_BUNDLE_MODE"] == "1"
21
+
19
22
  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')"`), '..')
20
23
  react_native_json = worklets_try_to_parse_react_native_package_json(react_native_node_modules_dir)
21
24
 
@@ -56,3 +59,9 @@ def worklets_assert_minimal_react_native_version(config)
56
59
  raise "[Worklets] Unsupported React Native version. Please use #{minimalReactNativeVersion} or newer."
57
60
  end
58
61
  end
62
+
63
+ def worklets_assert_new_architecture_enabled(new_arch_enabled)
64
+ if !new_arch_enabled
65
+ raise "[Worklets] Worklets require the New Architecture to be enabled. If you have `RCT_NEW_ARCH_ENABLED=0` set in your environment you should remove it."
66
+ end
67
+ end
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+ import { Platform } from 'react-native';
3
+
4
+ export const IS_JEST: boolean = !!process.env.JEST_WORKER_ID;
5
+ export const IS_WEB: boolean = Platform.OS === 'web';
6
+ export const IS_WINDOWS: boolean = Platform.OS === 'windows';
7
+ export const SHOULD_BE_USE_WEB: boolean = IS_JEST || IS_WEB || IS_WINDOWS;