react-native-worklets 0.7.2 → 0.8.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 (123) hide show
  1. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +32 -28
  2. package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +13 -5
  3. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +7 -5
  4. package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +5 -4
  5. package/Common/cpp/worklets/Resources/SynchronizableUnpacker.cpp +5 -5
  6. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +42 -19
  7. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +2 -0
  8. package/Common/cpp/worklets/Tools/Defs.h +2 -2
  9. package/Common/cpp/worklets/Tools/ScriptBuffer.h +34 -0
  10. package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +24 -0
  11. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +11 -6
  12. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +82 -0
  13. package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +12 -0
  14. package/RNWorklets.podspec +15 -14
  15. package/android/CMakeLists.txt +8 -2
  16. package/android/build.gradle +92 -56
  17. package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.cpp +67 -0
  18. package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.h +48 -0
  19. package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +52 -0
  20. package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +43 -0
  21. package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +115 -19
  22. package/android/src/main/cpp/worklets/android/WorkletsModule.h +11 -13
  23. package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +6 -0
  24. package/android/src/main/java/com/swmansion/worklets/ScriptBufferWrapper.java +88 -0
  25. package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +23 -0
  26. package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +30 -0
  27. package/android/src/{legacyBundling → networking}/com/swmansion/worklets/WorkletsModule.java +52 -2
  28. package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +268 -0
  29. package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +1084 -0
  30. package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +37 -0
  31. package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +9 -0
  32. package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +98 -0
  33. package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +57 -0
  34. package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +82 -0
  35. package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +177 -0
  36. package/android/src/{experimentalBundling → no-networking}/com/swmansion/worklets/WorkletsModule.java +10 -15
  37. package/apple/worklets/apple/Networking/WorkletsNetworking.h +22 -0
  38. package/apple/worklets/apple/Networking/WorkletsNetworking.mm +706 -0
  39. package/apple/worklets/apple/WorkletsModule.mm +56 -17
  40. package/bundleMode/index.js +2 -6
  41. package/compatibility.json +4 -1
  42. package/lib/module/WorkletsModule/NativeWorklets.native.js +8 -2
  43. package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -1
  44. package/lib/module/bundleMode/metroOverrides.native.js +115 -0
  45. package/lib/module/bundleMode/metroOverrides.native.js.map +1 -0
  46. package/lib/module/bundleMode/network.native.js +41 -0
  47. package/lib/module/bundleMode/network.native.js.map +1 -0
  48. package/lib/module/debug/jsVersion.js +1 -1
  49. package/lib/module/debug/jsVersion.js.map +1 -1
  50. package/lib/module/featureFlags/staticFlags.json +2 -0
  51. package/lib/module/featureFlags/types.js +3 -1
  52. package/lib/module/featureFlags/types.js.map +1 -1
  53. package/lib/module/index.js +4 -2
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/initializers/initializers.native.js +24 -50
  56. package/lib/module/initializers/initializers.native.js.map +1 -1
  57. package/lib/module/initializers/workletRuntimeEntry.native.js +3 -3
  58. package/lib/module/initializers/workletRuntimeEntry.native.js.map +1 -1
  59. package/lib/module/memory/bundleUnpacker.native.js +2 -2
  60. package/lib/module/memory/bundleUnpacker.native.js.map +1 -1
  61. package/lib/module/memory/serializable.native.js +3 -3
  62. package/lib/module/memory/serializable.native.js.map +1 -1
  63. package/lib/module/memory/synchronizableUnpacker.native.js +3 -3
  64. package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -1
  65. package/lib/module/platformChecker.js +2 -2
  66. package/lib/module/platformChecker.js.map +1 -1
  67. package/lib/module/runtimeKind.js +51 -0
  68. package/lib/module/runtimeKind.js.map +1 -1
  69. package/lib/module/runtimes.js +3 -0
  70. package/lib/module/runtimes.js.map +1 -1
  71. package/lib/module/runtimes.native.js +34 -3
  72. package/lib/module/runtimes.native.js.map +1 -1
  73. package/lib/module/threads.native.js +2 -2
  74. package/lib/module/threads.native.js.map +1 -1
  75. package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -1
  76. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +2 -1
  77. package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
  78. package/lib/typescript/bundleMode/metroOverrides.native.d.ts +28 -0
  79. package/lib/typescript/bundleMode/metroOverrides.native.d.ts.map +1 -0
  80. package/lib/typescript/bundleMode/network.native.d.ts +7 -0
  81. package/lib/typescript/bundleMode/network.native.d.ts.map +1 -0
  82. package/lib/typescript/debug/jsVersion.d.ts +1 -1
  83. package/lib/typescript/debug/jsVersion.d.ts.map +1 -1
  84. package/lib/typescript/featureFlags/types.d.ts +3 -1
  85. package/lib/typescript/featureFlags/types.d.ts.map +1 -1
  86. package/lib/typescript/index.d.ts +2 -2
  87. package/lib/typescript/index.d.ts.map +1 -1
  88. package/lib/typescript/initializers/initializers.native.d.ts +1 -0
  89. package/lib/typescript/initializers/initializers.native.d.ts.map +1 -1
  90. package/lib/typescript/initializers/workletRuntimeEntry.native.d.ts +1 -1
  91. package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -1
  92. package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -1
  93. package/lib/typescript/platformChecker.d.ts.map +1 -1
  94. package/lib/typescript/runtimeKind.d.ts +31 -0
  95. package/lib/typescript/runtimeKind.d.ts.map +1 -1
  96. package/lib/typescript/runtimes.d.ts +1 -0
  97. package/lib/typescript/runtimes.d.ts.map +1 -1
  98. package/lib/typescript/runtimes.native.d.ts +20 -2
  99. package/lib/typescript/runtimes.native.d.ts.map +1 -1
  100. package/lib/typescript/threads.native.d.ts +1 -1
  101. package/package.json +8 -6
  102. package/plugin/index.d.ts +109 -0
  103. package/plugin/index.js +59 -9
  104. package/scripts/worklets_utils.rb +21 -5
  105. package/src/WorkletsModule/NativeWorklets.native.ts +14 -4
  106. package/src/WorkletsModule/workletsModuleProxy.ts +6 -3
  107. package/src/bundleMode/metroOverrides.native.ts +151 -0
  108. package/src/bundleMode/network.native.ts +59 -0
  109. package/src/debug/jsVersion.ts +1 -1
  110. package/src/featureFlags/staticFlags.json +2 -0
  111. package/src/featureFlags/types.ts +3 -1
  112. package/src/index.ts +10 -1
  113. package/src/initializers/initializers.native.ts +29 -70
  114. package/src/initializers/workletRuntimeEntry.native.ts +3 -3
  115. package/src/memory/bundleUnpacker.native.ts +2 -4
  116. package/src/memory/serializable.native.ts +3 -3
  117. package/src/memory/synchronizableUnpacker.native.ts +6 -12
  118. package/src/platformChecker.ts +3 -2
  119. package/src/privateGlobals.d.ts +7 -2
  120. package/src/runtimeKind.ts +47 -0
  121. package/src/runtimes.native.ts +43 -2
  122. package/src/runtimes.ts +10 -0
  123. package/src/threads.native.ts +2 -2
@@ -13,5 +13,6 @@
13
13
  */
14
14
  export declare function getMemorySafeCapturableConsole(): typeof console;
15
15
  export declare function setupConsole(boundCapturableConsole: typeof console): void;
16
+ export declare function setupSerializer(): void;
16
17
  export declare function init(): void;
17
18
  //# sourceMappingURL=initializers.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initializers.native.d.ts","sourceRoot":"","sources":["../../../src/initializers/initializers.native.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,IAAI,OAAO,OAAO,CA8B/D;AAED,wBAAgB,YAAY,CAAC,sBAAsB,EAAE,OAAO,OAAO,QAWlE;AAID,wBAAgB,IAAI,SAcnB"}
1
+ {"version":3,"file":"initializers.native.d.ts","sourceRoot":"","sources":["../../../src/initializers/initializers.native.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,IAAI,OAAO,OAAO,CA8B/D;AAED,wBAAgB,YAAY,CAAC,sBAAsB,EAAE,OAAO,OAAO,QAWlE;AAED,wBAAgB,eAAe,SAG9B;AAID,wBAAgB,IAAI,SAcnB"}
@@ -8,7 +8,7 @@
8
8
  * error is caught in C++ code.
9
9
  *
10
10
  * This function has no effect on the RN Runtime beside setting the
11
- * `_WORKLETS_BUNDLE_MODE` flag.
11
+ * `_WORKLETS_BUNDLE_MODE_ENABLED` flag.
12
12
  */
13
13
  export declare function bundleModeInit(): void;
14
14
  //# sourceMappingURL=workletRuntimeEntry.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundleUnpacker.native.d.ts","sourceRoot":"","sources":["../../../src/memory/bundleUnpacker.native.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhE,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CA4BT;AAiCD,UAAU,cAAe,SAAQ,eAAe;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB"}
1
+ {"version":3,"file":"bundleUnpacker.native.d.ts","sourceRoot":"","sources":["../../../src/memory/bundleUnpacker.native.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,UAAU,CAAC;AAIhE,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CA4BT;AA+BD,UAAU,cAAe,SAAQ,eAAe;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"synchronizableUnpacker.native.d.ts","sourceRoot":"","sources":["../../../src/memory/synchronizableUnpacker.native.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEtE,wBAAgB,iBAAiB,SAyDhC;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAC1C,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,KACzC,cAAc,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"synchronizableUnpacker.native.d.ts","sourceRoot":"","sources":["../../../src/memory/synchronizableUnpacker.native.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEtE,wBAAgB,iBAAiB,SAmDhC;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAC1C,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,KACzC,cAAc,CAAC,MAAM,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"platformChecker.d.ts","sourceRoot":"","sources":["../../src/platformChecker.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,EAAE,OAAsC,CAAC;AAC7D,eAAO,MAAM,MAAM,EAAE,OAA+B,CAAC;AACrD,eAAO,MAAM,UAAU,EAAE,OAAmC,CAAC;AAC7D,eAAO,MAAM,iBAAiB,EAAE,OAAyC,CAAC"}
1
+ {"version":3,"file":"platformChecker.d.ts","sourceRoot":"","sources":["../../src/platformChecker.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,EAAE,OAAsC,CAAC;AAC7D,eAAO,MAAM,MAAM,EAAE,OAAyD,CAAC;AAC/E,eAAO,MAAM,UAAU,EAAE,OACK,CAAC;AAC/B,eAAO,MAAM,iBAAiB,EAAE,OAAyC,CAAC"}
@@ -22,4 +22,35 @@ export declare enum RuntimeKind {
22
22
  * @returns The kind of the current runtime.
23
23
  */
24
24
  export declare function getRuntimeKind(): RuntimeKind;
25
+ /**
26
+ * Checks if the current runtime is the [React Native
27
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds/#rn-runtime).
28
+ *
29
+ * @returns `true` if the current runtime is the React Native Runtime, `false`
30
+ * otherwise.
31
+ */
32
+ export declare function isRNRuntime(): boolean;
33
+ /**
34
+ * Checks if the current runtime is a [Worklet
35
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds/#worklet-runtime).
36
+ *
37
+ * @returns `true` if the current runtime is a Worklet Runtime, `false`
38
+ * otherwise.
39
+ */
40
+ export declare function isWorkletRuntime(): boolean;
41
+ /**
42
+ * Checks if the current runtime is the [UI
43
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds/#ui-runtime).
44
+ *
45
+ * @returns `true` if the current runtime is the UI Runtime, `false` otherwise.
46
+ */
47
+ export declare function isUIRuntime(): boolean;
48
+ /**
49
+ * Checks if the current runtime is a [Worker
50
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds/#worker-runtime).
51
+ *
52
+ * @returns `true` if the current runtime is a Worker Runtime, `false`
53
+ * otherwise.
54
+ */
55
+ export declare function isWorkerRuntime(): boolean;
25
56
  //# sourceMappingURL=runtimeKind.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeKind.d.ts","sourceRoot":"","sources":["../../src/runtimeKind.ts"],"names":[],"mappings":"AAEA,oBAAY,WAAW;IACrB;;;OAGG;IACH,WAAW,IAAI;IACf;;;OAGG;IACH,EAAE,IAAI;IACN,wDAAwD;IACxD,MAAM,IAAI;CACX;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAG5C"}
1
+ {"version":3,"file":"runtimeKind.d.ts","sourceRoot":"","sources":["../../src/runtimeKind.ts"],"names":[],"mappings":"AAEA,oBAAY,WAAW;IACrB;;;OAGG;IACH,WAAW,IAAI;IACf;;;OAGG;IACH,EAAE,IAAI;IACN,wDAAwD;IACxD,MAAM,IAAI;CACX;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAG5C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAGrC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAG1C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAGrC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAGzC"}
@@ -3,4 +3,5 @@ export declare function createWorkletRuntime(config?: WorkletRuntimeConfig): Wor
3
3
  export declare function createWorkletRuntime(name?: string, initializer?: () => void): WorkletRuntime;
4
4
  export declare function runOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>;
5
5
  export declare function scheduleOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue, ...args: Args): void;
6
+ export declare function runOnRuntimeSync<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue, ...args: Args): ReturnValue;
6
7
  //# sourceMappingURL=runtimes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../../src/runtimes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,oBAAoB,CAClC,MAAM,CAAC,EAAE,oBAAoB,GAC5B,cAAc,CAAC;AAElB,wBAAgB,oBAAoB,CAClC,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,cAAc,CAAC;AAMlB,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;AAMtC,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACnE,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,EACvC,GAAG,IAAI,EAAE,IAAI,GACZ,IAAI,CAAC"}
1
+ {"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../../src/runtimes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,oBAAoB,CAClC,MAAM,CAAC,EAAE,oBAAoB,GAC5B,cAAc,CAAC;AAElB,wBAAgB,oBAAoB,CAClC,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,cAAc,CAAC;AAMlB,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;AAMtC,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACnE,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,EACvC,GAAG,IAAI,EAAE,IAAI,GACZ,IAAI,CAAC;AAMR,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EAClE,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,EACvC,GAAG,IAAI,EAAE,IAAI,GACZ,WAAW,CAAC"}
@@ -41,8 +41,8 @@ export declare function createWorkletRuntime(name?: string, initializer?: () =>
41
41
  * or another [Worker
42
42
  * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime),
43
43
  * unless the [Bundle
44
- * Mode](https://docs.swmansion.com/react-native-worklets/docs/experimental/bundleMode)
45
- * is enabled.
44
+ * Mode](https://docs.swmansion.com/react-native-worklets/docs/bundleMode/) is
45
+ * enabled.
46
46
  *
47
47
  * @param workletRuntime - The runtime to schedule the worklet on.
48
48
  * @param worklet - The worklet to schedule.
@@ -56,4 +56,22 @@ export declare function scheduleOnRuntime<Args extends unknown[], ReturnValue>(w
56
56
  * Schedule a worklet to execute on the background queue.
57
57
  */
58
58
  export declare function runOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>;
59
+ /**
60
+ * Lets you run a function synchronously on a [Worker
61
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime).
62
+ *
63
+ * - This function cannot be called from the [UI
64
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime).
65
+ * or another [Worker
66
+ * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime),
67
+ * unless the [Bundle
68
+ * Mode](https://docs.swmansion.com/react-native-worklets/docs/bundleMode/) is
69
+ * enabled.
70
+ *
71
+ * @param workletRuntime - The runtime to run the worklet on.
72
+ * @param worklet - The worklet to run.
73
+ * @param args - The arguments to pass to the worklet.
74
+ * @returns The return value of the worklet.
75
+ */
76
+ export declare function runOnRuntimeSync<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue, ...args: Args): ReturnValue;
59
77
  //# sourceMappingURL=runtimes.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimes.native.d.ts","sourceRoot":"","sources":["../../src/runtimes.native.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;GAQG;AAEH,wBAAgB,oBAAoB,CAClC,MAAM,CAAC,EAAE,oBAAoB,GAC5B,cAAc,CAAC;AAElB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,cAAc,CAAC;AAqDlB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACnE,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,EACvC,GAAG,IAAI,EAAE,IAAI,GACZ,IAAI,CAAC;AAiCR;;;;GAIG;AAGH,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.native.d.ts","sourceRoot":"","sources":["../../src/runtimes.native.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB;;;;;;;;GAQG;AAEH,wBAAgB,oBAAoB,CAClC,MAAM,CAAC,EAAE,oBAAoB,GAC5B,cAAc,CAAC;AAElB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,IAAI,GACvB,cAAc,CAAC;AAsDlB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EACnE,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,EACvC,GAAG,IAAI,EAAE,IAAI,GACZ,IAAI,CAAC;AAiCR;;;;GAIG;AAGH,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;AAmBtC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,WAAW,EAClE,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,WAAW,EACvC,GAAG,IAAI,EAAE,IAAI,GACZ,WAAW,CAgBb"}
@@ -14,7 +14,7 @@ export declare const callMicrotasks: typeof callMicrotasksOnUIThread;
14
14
  * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime)
15
15
  * or a [Worker
16
16
  * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime),
17
- * unless you have the [Bundle Mode](/docs/experimental/bundleMode) enabled.
17
+ * unless you have the [Bundle Mode](/docs/bundleMode/) enabled.
18
18
  *
19
19
  * @param fun - A reference to a function you want to schedule on the [UI
20
20
  * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-worklets",
3
- "version": "0.7.2",
3
+ "version": "0.8.0-bundle-mode-preview-1",
4
4
  "description": "The React Native multithreading library",
5
5
  "keywords": [
6
6
  "react-native",
@@ -36,7 +36,8 @@
36
36
  "type:check:src:web": "yarn tsc --noEmit --project tsconfig.web.json",
37
37
  "type:check:app": "yarn workspace common-app type:check",
38
38
  "type:check:plugin": "yarn workspace babel-plugin-worklets type:check",
39
- "type:check:tests": "../../scripts/test-ts.sh __typetests__"
39
+ "type:check:tests": "../../scripts/test-ts.sh __typetests__",
40
+ "tree-shake:check:web": "yarn is-tree-shakable --resolution web"
40
41
  },
41
42
  "repository": {
42
43
  "type": "git",
@@ -65,13 +66,14 @@
65
66
  "@babel/plugin-transform-unicode-regex": "7.27.1",
66
67
  "@babel/preset-typescript": "7.27.1",
67
68
  "convert-source-map": "2.0.0",
69
+ "is-tree-shakable": "0.4.1",
68
70
  "semver": "7.7.3"
69
71
  },
70
72
  "devDependencies": {
71
73
  "@babel/cli": "7.28.3",
72
74
  "@babel/core": "7.28.4",
73
- "@react-native-community/cli": "20.0.0",
74
- "@react-native/eslint-config": "0.83.1",
75
+ "@react-native-community/cli": "20.1.0",
76
+ "@react-native/eslint-config": "0.83.0",
75
77
  "@types/jest": "30.0.0",
76
78
  "@types/node": "24.7.0",
77
79
  "@types/react": "19.2.2",
@@ -82,8 +84,8 @@
82
84
  "knip": "5.61.3",
83
85
  "madge": "8.0.0",
84
86
  "prettier": "3.6.2",
85
- "react": "19.2.0",
86
- "react-native": "0.83.1",
87
+ "react": "19.2.3",
88
+ "react-native": "0.84.0-rc.2",
87
89
  "react-native-builder-bob": "0.40.13",
88
90
  "typescript": "5.8.3"
89
91
  },
package/plugin/index.d.ts CHANGED
@@ -1,13 +1,122 @@
1
1
  export interface PluginOptions {
2
+ /**
3
+ * Enables the [Bundle
4
+ * Mode](https://docs.swmansion.com/react-native-worklets/docs/experimental/bundle-mode).
5
+ *
6
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#bundle-mode}
7
+ *
8
+ * - Defaults to `false`.
9
+ */
2
10
  bundleMode?: boolean;
11
+ /**
12
+ * Turning on this option suppresses a helpful warning when you use [inline
13
+ * shared
14
+ * values](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animations-in-inline-styling).
15
+ *
16
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#disableinlinestyleswarning}
17
+ *
18
+ * - Defaults to `false`.
19
+ */
3
20
  disableInlineStylesWarning?: boolean;
21
+ /**
22
+ * This option turns off the source map generation for worklets. Mostly used
23
+ * for testing purposes.
24
+ *
25
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#disablesourcemaps}
26
+ *
27
+ * - Defaults to `false`.
28
+ */
4
29
  disableSourceMaps?: boolean;
30
+ /**
31
+ * Disables [Worklet Classes
32
+ * support](https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/about#experimental-worklet-classes).
33
+ * You might need to disable this feature when using [Custom
34
+ * Serializables](https://docs.swmansion.com/react-native-worklets/docs/memory/registerCustomSerializable).
35
+ *
36
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#disableworkletclasses}
37
+ *
38
+ * - Defaults to `false`.
39
+ */
5
40
  disableWorkletClasses?: boolean;
41
+ /**
42
+ * This is a list of Babel plugins that will be used when transforming
43
+ * worklets' code with Worklets Babel Plugin.
44
+ *
45
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#extraplugins}
46
+ *
47
+ * - Defaults to an empty array `[]`.
48
+ */
6
49
  extraPlugins?: string[];
50
+ /**
51
+ * This is a list of Babel presets that will be used when transforming
52
+ * worklets' code with Worklets Babel Plugin.
53
+ *
54
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#extrapresets}
55
+ *
56
+ * - Defaults to an empty array `[]`.
57
+ */
7
58
  extraPresets?: string[];
59
+ /**
60
+ * This is a list of identifiers (objects) that will not be copied to the UI
61
+ * thread if a worklet requires them.
62
+ *
63
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#globals}
64
+ *
65
+ * - Defaults to an empty array `[]`.
66
+ */
8
67
  globals?: string[];
68
+ /**
69
+ * This option comes in handy for Web apps. Because Babel ordinarily doesn't
70
+ * get information about the target platform, it includes worklet data in
71
+ * the bundle that only Native apps find relevant. If you enable this
72
+ * option, your bundle size will be smaller.
73
+ *
74
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#omitnativeonlydata}
75
+ *
76
+ * - Defaults to `false`.
77
+ */
9
78
  omitNativeOnlyData?: boolean;
79
+ /**
80
+ * This option dictates the passed file location for a worklet's source map.
81
+ * If you enable this option, the file paths will be relative to
82
+ * `process.cwd` (the current directory where Babel executes). This can be
83
+ * handy for Jest test snapshots to ensure consistent results across
84
+ * machines.
85
+ *
86
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#relativesourcelocation}
87
+ *
88
+ * - Defaults to `false`.
89
+ */
10
90
  relativeSourceLocation?: boolean;
91
+ /**
92
+ * This option makes it so no global identifiers are implicitly captured in
93
+ * worklets' closures between runtimes.
94
+ *
95
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#strictglobal}
96
+ *
97
+ * Defaults to `false`.
98
+ */
99
+ strictGlobal?: boolean;
100
+ /**
101
+ * This option can also be useful for Web apps. In Reanimated, there are
102
+ * numerous checks to determine the right function implementation for a
103
+ * specific target platform. Enabling this option changes all the checks
104
+ * that identify if the target is a Web app to `true`. This alteration can
105
+ * aid in tree-shaking and contribute to reducing the bundle size.
106
+ *
107
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#substitutewebplatformchecks}
108
+ *
109
+ * - Defaults to `false`.
110
+ */
11
111
  substituteWebPlatformChecks?: boolean;
112
+ /**
113
+ * This option allows you to register modules as safe to use on Worklet
114
+ * Runtimes in the [Bundle
115
+ * Mode](https://docs.swmansion.com/react-native-worklets/docs/experimental/bundle-mode).
116
+ *
117
+ * {@link https://docs.swmansion.com/react-native-worklets/docs/worklets-babel-plugin/plugin-options#workletizablemodules}
118
+ *
119
+ * - Defaults to an empty array `[]`.
120
+ */
12
121
  workletizableModules?: string[];
13
122
  }
package/plugin/index.js CHANGED
@@ -277,7 +277,7 @@ var require_types = __commonJS({
277
277
  return (0, types_12.isObjectExpression)(node);
278
278
  }
279
279
  exports2.workletClassFactorySuffix = "__classFactory";
280
- exports2.generatedWorkletsDir = "__generatedWorklets";
280
+ exports2.generatedWorkletsDir = ".worklets";
281
281
  }
282
282
  });
283
283
 
@@ -411,10 +411,15 @@ var require_globals = __commonJS({
411
411
  exports2.initializeGlobals = initializeGlobals;
412
412
  exports2.addCustomGlobals = addCustomGlobals;
413
413
  var notCapturedIdentifiers = [
414
+ // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
415
+ // Note that objects' properties don't need to be listed since we always only capture the whole object,
416
+ // e.g. `global.__ErrorUtils` or `Intl.DateTimeFormat`.
417
+ // Value properties
414
418
  "globalThis",
415
419
  "Infinity",
416
420
  "NaN",
417
421
  "undefined",
422
+ // Function properties
418
423
  "eval",
419
424
  "isFinite",
420
425
  "isNaN",
@@ -426,10 +431,12 @@ var require_globals = __commonJS({
426
431
  "encodeURIComponent",
427
432
  "escape",
428
433
  "unescape",
434
+ // Fundamental objects
429
435
  "Object",
430
436
  "Function",
431
437
  "Boolean",
432
438
  "Symbol",
439
+ // Error objects
433
440
  "Error",
434
441
  "AggregateError",
435
442
  "EvalError",
@@ -439,12 +446,15 @@ var require_globals = __commonJS({
439
446
  "TypeError",
440
447
  "URIError",
441
448
  "InternalError",
449
+ // Numbers and dates
442
450
  "Number",
443
451
  "BigInt",
444
452
  "Math",
445
453
  "Date",
454
+ // Text processing
446
455
  "String",
447
456
  "RegExp",
457
+ // Indexed collections
448
458
  "Array",
449
459
  "Int8Array",
450
460
  "Uint8Array",
@@ -457,17 +467,21 @@ var require_globals = __commonJS({
457
467
  "BigUint64Array",
458
468
  "Float32Array",
459
469
  "Float64Array",
470
+ // Keyed collections
460
471
  "Map",
461
472
  "Set",
462
473
  "WeakMap",
463
474
  "WeakSet",
475
+ // Structured data
464
476
  "ArrayBuffer",
465
477
  "SharedArrayBuffer",
466
478
  "DataView",
467
479
  "Atomics",
468
480
  "JSON",
481
+ // Managing memory
469
482
  "WeakRef",
470
483
  "FinalizationRegistry",
484
+ // Control abstraction objects
471
485
  "Iterator",
472
486
  "AsyncIterator",
473
487
  "Promise",
@@ -476,9 +490,12 @@ var require_globals = __commonJS({
476
490
  "Generator",
477
491
  "AsyncGenerator",
478
492
  "AsyncFunction",
493
+ // Reflection
479
494
  "Reflect",
480
495
  "Proxy",
496
+ // Internationalization
481
497
  "Intl",
498
+ // Other stuff
482
499
  "null",
483
500
  "this",
484
501
  "global",
@@ -488,7 +505,12 @@ var require_globals = __commonJS({
488
505
  "console",
489
506
  "performance",
490
507
  "arguments",
508
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
491
509
  "require",
510
+ "fetch",
511
+ "XMLHttpRequest",
512
+ "WebSocket",
513
+ // Run loop
492
514
  "queueMicrotask",
493
515
  "requestAnimationFrame",
494
516
  "cancelAnimationFrame",
@@ -498,7 +520,9 @@ var require_globals = __commonJS({
498
520
  "clearImmediate",
499
521
  "setInterval",
500
522
  "clearInterval",
523
+ // Hermes
501
524
  "HermesInternal",
525
+ // Worklets
502
526
  "_WORKLET"
503
527
  ];
504
528
  exports2.outsideBindingsToCaptureFromGlobalScope = /* @__PURE__ */ new Set([
@@ -511,8 +535,10 @@ var require_globals = __commonJS({
511
535
  function initializeState(state) {
512
536
  state.workletNumber = 1;
513
537
  state.classesToWorkletize = [];
514
- initializeGlobals();
515
- addCustomGlobals(state);
538
+ if (!state.opts.strictGlobal) {
539
+ initializeGlobals();
540
+ addCustomGlobals(state);
541
+ }
516
542
  }
517
543
  exports2.defaultGlobals = new Set(notCapturedIdentifiers.concat(notCapturedIdentifiers_DEPRECATED));
518
544
  function initializeGlobals() {
@@ -561,7 +587,7 @@ var require_closure = __commonJS({
561
587
  binding = idPath.scope.getBinding(name);
562
588
  }
563
589
  if (!binding) {
564
- if (globals_12.globals.has(name)) {
590
+ if (state.opts.strictGlobal || globals_12.globals.has(name)) {
565
591
  return;
566
592
  }
567
593
  capturedNames.add(name);
@@ -614,11 +640,16 @@ var require_closure = __commonJS({
614
640
  return imported.path.parentPath.node.source.value.startsWith(".");
615
641
  }
616
642
  function isAllowedForRelativeImports(filename, workletizableModules) {
617
- return !!filename && (filename.includes("react-native-worklets") || !!(workletizableModules === null || workletizableModules === void 0 ? void 0 : workletizableModules.some((module3) => filename.includes(module3))));
643
+ return !!filename && (alwaysAllowed.some((module3) => filename.includes(module3)) || !!(workletizableModules === null || workletizableModules === void 0 ? void 0 : workletizableModules.some((module3) => filename.includes(module3))));
618
644
  }
619
645
  function isWorkletizableModule(source, workletizableModules) {
620
- return source.startsWith("react-native-worklets") || !!(workletizableModules === null || workletizableModules === void 0 ? void 0 : workletizableModules.some((module3) => source.startsWith(module3)));
646
+ return alwaysAllowed.some((module3) => source.startsWith(module3)) || !!(workletizableModules === null || workletizableModules === void 0 ? void 0 : workletizableModules.some((module3) => source.startsWith(module3)));
621
647
  }
648
+ var alwaysAllowed = [
649
+ "react-native-worklets",
650
+ "react-native/Libraries/Core/setUpXHR"
651
+ // for networking
652
+ ];
622
653
  }
623
654
  });
624
655
 
@@ -979,6 +1010,7 @@ var require_workletFactory = __commonJS({
979
1010
  (0, types_12.newExpression)((0, types_12.memberExpression)((0, types_12.identifier)("global"), (0, types_12.identifier)("Error")), []),
980
1011
  (0, types_12.numericLiteral)(lineOffset),
981
1012
  (0, types_12.numericLiteral)(-27)
1013
+ // the placement of opening bracket after Exception in line that defined '_e' variable
982
1014
  ]))
983
1015
  ]));
984
1016
  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"))));
@@ -1124,6 +1156,7 @@ var require_workletSubstitution = __commonJS({
1124
1156
  }
1125
1157
  function processWorklet(path, state) {
1126
1158
  path.traverse({
1159
+ // @ts-expect-error TypeScript doesn't like this syntax here.
1127
1160
  [types_2.WorkletizableFunction](subPath, passedState) {
1128
1161
  processIfWithWorkletDirective(subPath, passedState);
1129
1162
  }
@@ -1180,7 +1213,14 @@ var require_objectWorklets = __commonJS({
1180
1213
  (0, workletSubstitution_12.processWorklet)(property, state);
1181
1214
  } else if (property.isObjectProperty()) {
1182
1215
  const value = property.get("value");
1183
- tryProcessingNode(value, state, true, false);
1216
+ tryProcessingNode(
1217
+ value,
1218
+ state,
1219
+ true,
1220
+ // acceptWorkletizableFunction
1221
+ false
1222
+ // acceptObject
1223
+ );
1184
1224
  } else {
1185
1225
  throw new Error(`[Reanimated] '${property.type}' as to-be workletized argument is not supported for object hooks.`);
1186
1226
  }
@@ -1213,10 +1253,12 @@ var require_autoworkletization = __commonJS({
1213
1253
  "useDerivedValue",
1214
1254
  "useAnimatedScrollHandler",
1215
1255
  "useAnimatedReaction",
1256
+ // animations' callbacks
1216
1257
  "withTiming",
1217
1258
  "withSpring",
1218
1259
  "withDecay",
1219
1260
  "withRepeat",
1261
+ // scheduling functions
1220
1262
  "runOnUI",
1221
1263
  "executeOnUIRuntimeSync",
1222
1264
  "scheduleOnUI",
@@ -1301,7 +1343,7 @@ var require_bundleMode = __commonJS({
1301
1343
  }
1302
1344
  const object = left.get("object");
1303
1345
  const property = left.get("property");
1304
- if (!object.isIdentifier() || object.node.name !== "globalThis" || !property.isIdentifier() || property.node.name !== "_WORKLETS_BUNDLE_MODE") {
1346
+ if (!object.isIdentifier() || object.node.name !== "globalThis" || !property.isIdentifier() || property.node.name !== "_WORKLETS_BUNDLE_MODE_ENABLED") {
1305
1347
  return;
1306
1348
  }
1307
1349
  const right = expressionPath.get("right");
@@ -1474,7 +1516,15 @@ var require_class = __commonJS({
1474
1516
  stack.delete(current.name);
1475
1517
  }
1476
1518
  function isOutsideDependency(identifierPath, bindingIdentifiers, functionPath) {
1477
- return identifierPath.isReferencedIdentifier() && !(identifierPath.node.name in bindingIdentifiers) && !functionPath.scope.hasOwnBinding(identifierPath.node.name) && functionPath.scope.hasReference(identifierPath.node.name);
1519
+ return (
1520
+ // We don't care about identifiers that were just declared.
1521
+ identifierPath.isReferencedIdentifier() && // We don't care about identifiers that are bound in the scope.
1522
+ !(identifierPath.node.name in bindingIdentifiers) && // This I don't exactly understand, but the function identifier itself isn't in `bindingIdentifiers`,
1523
+ // but it return true on `hasOwnBinding`.
1524
+ !functionPath.scope.hasOwnBinding(identifierPath.node.name) && // `hasReference` returns true for global identifiers, like `Object`,
1525
+ // we don't want to include those.
1526
+ functionPath.scope.hasReference(identifierPath.node.name)
1527
+ );
1478
1528
  }
1479
1529
  function isWorkletizableClass(classPath, state) {
1480
1530
  var _a;
@@ -8,18 +8,18 @@ end
8
8
 
9
9
  def worklets_find_config()
10
10
  result = {
11
- :bundle_mode => nil,
11
+ :bundle_mode_flag => nil,
12
+ :dynamic_frameworks_worklets_dir => nil,
13
+ :feature_flags_flag => nil,
14
+ :fetch_preview_flag => nil,
12
15
  :is_reanimated_example_app => nil,
13
16
  :is_tvos_target => nil,
14
17
  :react_native_version => nil,
15
18
  :react_native_minor_version => nil,
16
19
  :react_native_node_modules_dir => nil,
17
20
  :react_native_common_dir => nil,
18
- :dynamic_frameworks_worklets_dir => nil,
19
21
  }
20
22
 
21
- result[:bundle_mode] = ENV["WORKLETS_BUNDLE_MODE"] == "1"
22
-
23
23
  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')"`), '..')
24
24
  react_native_json = worklets_try_to_parse_react_native_package_json(react_native_node_modules_dir)
25
25
 
@@ -51,6 +51,11 @@ def worklets_find_config()
51
51
  react_native_worklets_dir_relative = Pathname.new(react_native_worklets_dir_absolute).relative_path_from(pods_root).to_s
52
52
  result[:dynamic_frameworks_worklets_dir] = react_native_worklets_dir_relative
53
53
 
54
+ feature_flags = worklets_get_static_feature_flags()
55
+ result[:feature_flags_flag] = worklets_get_static_feature_flags_flag(feature_flags)
56
+ result[:bundle_mode_flag] = worklets_get_flag_from_feature_flags(feature_flags, 'BUNDLE_MODE_ENABLED')
57
+ result[:fetch_preview_flag] = worklets_get_flag_from_feature_flags(feature_flags, 'FETCH_PREVIEW_ENABLED')
58
+
54
59
  return result
55
60
  end
56
61
 
@@ -67,6 +72,14 @@ def worklets_assert_new_architecture_enabled(new_arch_enabled)
67
72
  end
68
73
  end
69
74
 
75
+ def worklets_get_flag_from_feature_flags(feature_flags, flag_name)
76
+ if feature_flags[flag_name] == 'true'
77
+ return "-DWORKLETS_#{flag_name}"
78
+ else
79
+ return ''
80
+ end
81
+ end
82
+
70
83
  def worklets_get_static_feature_flags()
71
84
  feature_flags = {}
72
85
 
@@ -89,6 +102,9 @@ def worklets_get_static_feature_flags()
89
102
  end
90
103
  end
91
104
  end
105
+ return feature_flags
106
+ end
92
107
 
93
- return feature_flags.map { |key, value| "[#{key}:#{value}]" }.join('')
108
+ def worklets_get_static_feature_flags_flag(feature_flags)
109
+ return "-DWORKLETS_FEATURE_FLAGS=\"#{feature_flags.map { |key, value| "[#{key}:#{value}]" }.join('')}\""
94
110
  end
@@ -26,6 +26,11 @@ class NativeWorklets implements IWorkletsModule {
26
26
  globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative
27
27
  ) {
28
28
  WorkletsTurboModule?.installTurboModule();
29
+ if (__DEV__ && globalThis._WORKLETS_BUNDLE_MODE_ENABLED) {
30
+ console.log(
31
+ '[Worklets] Bundle mode initialization: Downloaded the bundle for Worklet Runtimes.'
32
+ );
33
+ }
29
34
  }
30
35
  if (global.__workletsModuleProxy === undefined) {
31
36
  throw new WorkletsError(
@@ -177,10 +182,8 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
177
182
  return this.#workletsModuleProxy.scheduleOnUI(serializable);
178
183
  }
179
184
 
180
- executeOnUIRuntimeSync<TValue, TReturn>(
181
- serializable: SerializableRef<TValue>
182
- ): TReturn {
183
- return this.#workletsModuleProxy.executeOnUIRuntimeSync(serializable);
185
+ runOnUISync<TValue, TReturn>(worklet: SerializableRef<TValue>): TReturn {
186
+ return this.#workletsModuleProxy.runOnUISync(worklet);
184
187
  }
185
188
 
186
189
  createWorkletRuntime(
@@ -209,6 +212,13 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
209
212
  );
210
213
  }
211
214
 
215
+ runOnRuntimeSync<TValue, TReturn>(
216
+ workletRuntime: WorkletRuntime,
217
+ worklet: SerializableRef<TValue>
218
+ ): TReturn {
219
+ return this.#workletsModuleProxy.runOnRuntimeSync(workletRuntime, worklet);
220
+ }
221
+
212
222
  createSynchronizable<TValue>(value: TValue): SynchronizableRef<TValue> {
213
223
  return this.#workletsModuleProxy.createSynchronizable(value);
214
224
  }
@@ -83,9 +83,7 @@ export interface WorkletsModuleProxy {
83
83
 
84
84
  scheduleOnUI<TValue>(serializable: SerializableRef<TValue>): void;
85
85
 
86
- executeOnUIRuntimeSync<TValue, TReturn>(
87
- serializable: SerializableRef<TValue>
88
- ): TReturn;
86
+ runOnUISync<TValue, TReturn>(serializable: SerializableRef<TValue>): TReturn;
89
87
 
90
88
  createWorkletRuntime(
91
89
  name: string,
@@ -100,6 +98,11 @@ export interface WorkletsModuleProxy {
100
98
  worklet: SerializableRef<TValue>
101
99
  ): void;
102
100
 
101
+ runOnRuntimeSync<TValue, TReturn>(
102
+ workletRuntime: WorkletRuntime,
103
+ worklet: SerializableRef<TValue>
104
+ ): TReturn;
105
+
103
106
  reportFatalErrorOnJS(
104
107
  message: string,
105
108
  stack: string,