react-native-worklets 0.7.1 → 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.
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +32 -28
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +13 -5
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +7 -5
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +5 -4
- package/Common/cpp/worklets/Resources/SynchronizableUnpacker.cpp +5 -5
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +42 -19
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +2 -0
- package/Common/cpp/worklets/Tools/Defs.h +2 -2
- package/Common/cpp/worklets/Tools/ScriptBuffer.h +34 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +24 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +11 -6
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +82 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +12 -0
- package/RNWorklets.podspec +16 -14
- package/android/CMakeLists.txt +8 -2
- package/android/build.gradle +92 -56
- package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.cpp +67 -0
- package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.h +48 -0
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +52 -0
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +43 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +115 -19
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +11 -13
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +6 -0
- package/android/src/main/java/com/swmansion/worklets/ScriptBufferWrapper.java +88 -0
- package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +23 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +30 -0
- package/android/src/{legacyBundling → networking}/com/swmansion/worklets/WorkletsModule.java +52 -2
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +268 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +1084 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +37 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +9 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +98 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +57 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +82 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +177 -0
- package/android/src/{experimentalBundling → no-networking}/com/swmansion/worklets/WorkletsModule.java +10 -15
- package/apple/worklets/apple/Networking/WorkletsNetworking.h +22 -0
- package/apple/worklets/apple/Networking/WorkletsNetworking.mm +706 -0
- package/apple/worklets/apple/WorkletsModule.mm +56 -17
- package/bundleMode/index.js +2 -6
- package/compatibility.json +4 -1
- package/lib/module/WorkletsModule/NativeWorklets.native.js +8 -2
- package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -1
- package/lib/module/bundleMode/metroOverrides.native.js +115 -0
- package/lib/module/bundleMode/metroOverrides.native.js.map +1 -0
- package/lib/module/bundleMode/network.native.js +41 -0
- package/lib/module/bundleMode/network.native.js.map +1 -0
- package/lib/module/debug/jsVersion.js +1 -1
- package/lib/module/debug/jsVersion.js.map +1 -1
- package/lib/module/featureFlags/staticFlags.json +2 -0
- package/lib/module/featureFlags/types.js +3 -1
- package/lib/module/featureFlags/types.js.map +1 -1
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/initializers/initializers.native.js +24 -50
- package/lib/module/initializers/initializers.native.js.map +1 -1
- package/lib/module/initializers/workletRuntimeEntry.native.js +3 -3
- package/lib/module/initializers/workletRuntimeEntry.native.js.map +1 -1
- package/lib/module/memory/bundleUnpacker.native.js +2 -2
- package/lib/module/memory/bundleUnpacker.native.js.map +1 -1
- package/lib/module/memory/serializable.native.js +3 -3
- package/lib/module/memory/serializable.native.js.map +1 -1
- package/lib/module/memory/synchronizableUnpacker.native.js +3 -3
- package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -1
- package/lib/module/platformChecker.js +2 -2
- package/lib/module/platformChecker.js.map +1 -1
- package/lib/module/runtimeKind.js +51 -0
- package/lib/module/runtimeKind.js.map +1 -1
- package/lib/module/runtimes.js +3 -0
- package/lib/module/runtimes.js.map +1 -1
- package/lib/module/runtimes.native.js +34 -3
- package/lib/module/runtimes.native.js.map +1 -1
- package/lib/module/threads.native.js +2 -2
- package/lib/module/threads.native.js.map +1 -1
- package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -1
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +2 -1
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
- package/lib/typescript/bundleMode/metroOverrides.native.d.ts +28 -0
- package/lib/typescript/bundleMode/metroOverrides.native.d.ts.map +1 -0
- package/lib/typescript/bundleMode/network.native.d.ts +7 -0
- package/lib/typescript/bundleMode/network.native.d.ts.map +1 -0
- package/lib/typescript/debug/jsVersion.d.ts +1 -1
- package/lib/typescript/debug/jsVersion.d.ts.map +1 -1
- package/lib/typescript/featureFlags/types.d.ts +3 -1
- package/lib/typescript/featureFlags/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/initializers/initializers.native.d.ts +1 -0
- package/lib/typescript/initializers/initializers.native.d.ts.map +1 -1
- package/lib/typescript/initializers/workletRuntimeEntry.native.d.ts +1 -1
- package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/platformChecker.d.ts.map +1 -1
- package/lib/typescript/runtimeKind.d.ts +31 -0
- package/lib/typescript/runtimeKind.d.ts.map +1 -1
- package/lib/typescript/runtimes.d.ts +1 -0
- package/lib/typescript/runtimes.d.ts.map +1 -1
- package/lib/typescript/runtimes.native.d.ts +20 -2
- package/lib/typescript/runtimes.native.d.ts.map +1 -1
- package/lib/typescript/threads.native.d.ts +1 -1
- package/package.json +17 -6
- package/plugin/index.d.ts +109 -0
- package/plugin/index.js +59 -9
- package/scripts/worklets_utils.rb +21 -5
- package/src/WorkletsModule/NativeWorklets.native.ts +14 -4
- package/src/WorkletsModule/workletsModuleProxy.ts +6 -3
- package/src/bundleMode/metroOverrides.native.ts +151 -0
- package/src/bundleMode/network.native.ts +59 -0
- package/src/debug/jsVersion.ts +1 -1
- package/src/featureFlags/staticFlags.json +2 -0
- package/src/featureFlags/types.ts +3 -1
- package/src/index.ts +10 -1
- package/src/initializers/initializers.native.ts +29 -70
- package/src/initializers/workletRuntimeEntry.native.ts +3 -3
- package/src/memory/bundleUnpacker.native.ts +2 -4
- package/src/memory/serializable.native.ts +3 -3
- package/src/memory/synchronizableUnpacker.native.ts +6 -12
- package/src/platformChecker.ts +3 -2
- package/src/privateGlobals.d.ts +7 -2
- package/src/runtimeKind.ts +47 -0
- package/src/runtimes.native.ts +43 -2
- package/src/runtimes.ts +10 -0
- package/src/threads.native.ts +2 -2
package/src/runtimes.native.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { registerWorkletsError, WorkletsError } from './debug/WorkletsError';
|
|
|
5
5
|
import {
|
|
6
6
|
getMemorySafeCapturableConsole,
|
|
7
7
|
setupConsole,
|
|
8
|
+
setupSerializer,
|
|
8
9
|
} from './initializers/initializers';
|
|
9
10
|
import {
|
|
10
11
|
createSerializable,
|
|
@@ -91,6 +92,7 @@ export function createWorkletRuntime(
|
|
|
91
92
|
createSerializable(() => {
|
|
92
93
|
'worklet';
|
|
93
94
|
setupCallGuard();
|
|
95
|
+
setupSerializer();
|
|
94
96
|
registerWorkletsError();
|
|
95
97
|
setupConsole(runtimeBoundCapturableConsole);
|
|
96
98
|
if (enableEventLoop) {
|
|
@@ -121,8 +123,8 @@ export function createWorkletRuntime(
|
|
|
121
123
|
* or another [Worker
|
|
122
124
|
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime),
|
|
123
125
|
* unless the [Bundle
|
|
124
|
-
* Mode](https://docs.swmansion.com/react-native-worklets/docs/
|
|
125
|
-
*
|
|
126
|
+
* Mode](https://docs.swmansion.com/react-native-worklets/docs/bundleMode/) is
|
|
127
|
+
* enabled.
|
|
126
128
|
*
|
|
127
129
|
* @param workletRuntime - The runtime to schedule the worklet on.
|
|
128
130
|
* @param worklet - The worklet to schedule.
|
|
@@ -196,3 +198,42 @@ export function runOnRuntime<Args extends unknown[], ReturnValue>(
|
|
|
196
198
|
type WorkletRuntimeConfigInternal = WorkletRuntimeConfig & {
|
|
197
199
|
initializer?: WorkletFunction<[], void>;
|
|
198
200
|
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Lets you run a function synchronously on a [Worker
|
|
204
|
+
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime).
|
|
205
|
+
*
|
|
206
|
+
* - This function cannot be called from the [UI
|
|
207
|
+
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime).
|
|
208
|
+
* or another [Worker
|
|
209
|
+
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime),
|
|
210
|
+
* unless the [Bundle
|
|
211
|
+
* Mode](https://docs.swmansion.com/react-native-worklets/docs/bundleMode/) is
|
|
212
|
+
* enabled.
|
|
213
|
+
*
|
|
214
|
+
* @param workletRuntime - The runtime to run the worklet on.
|
|
215
|
+
* @param worklet - The worklet to run.
|
|
216
|
+
* @param args - The arguments to pass to the worklet.
|
|
217
|
+
* @returns The return value of the worklet.
|
|
218
|
+
*/
|
|
219
|
+
export function runOnRuntimeSync<Args extends unknown[], ReturnValue>(
|
|
220
|
+
workletRuntime: WorkletRuntime,
|
|
221
|
+
worklet: (...args: Args) => ReturnValue,
|
|
222
|
+
...args: Args
|
|
223
|
+
): ReturnValue {
|
|
224
|
+
'worklet';
|
|
225
|
+
if (__DEV__ && !isWorkletFunction(worklet)) {
|
|
226
|
+
throw new WorkletsError(
|
|
227
|
+
'The function passed to `runOnRuntimeSync` is not a worklet.'
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return WorkletsModule.runOnRuntimeSync(
|
|
232
|
+
workletRuntime,
|
|
233
|
+
createSerializable(() => {
|
|
234
|
+
'worklet';
|
|
235
|
+
const result = worklet(...args);
|
|
236
|
+
return makeShareableCloneOnUIRecursive(result);
|
|
237
|
+
})
|
|
238
|
+
);
|
|
239
|
+
}
|
package/src/runtimes.ts
CHANGED
|
@@ -38,3 +38,13 @@ export function scheduleOnRuntime<Args extends unknown[], ReturnValue>(
|
|
|
38
38
|
export function scheduleOnRuntime(): never {
|
|
39
39
|
throw new WorkletsError('`scheduleOnRuntime` is not supported on web.');
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
export function runOnRuntimeSync<Args extends unknown[], ReturnValue>(
|
|
43
|
+
workletRuntime: WorkletRuntime,
|
|
44
|
+
worklet: (...args: Args) => ReturnValue,
|
|
45
|
+
...args: Args
|
|
46
|
+
): ReturnValue;
|
|
47
|
+
|
|
48
|
+
export function runOnRuntimeSync(): never {
|
|
49
|
+
throw new WorkletsError('`runOnRuntimeSync` is not supported on web.');
|
|
50
|
+
}
|
package/src/threads.native.ts
CHANGED
|
@@ -66,7 +66,7 @@ export const callMicrotasks = callMicrotasksOnUIThread;
|
|
|
66
66
|
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime)
|
|
67
67
|
* or a [Worker
|
|
68
68
|
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime),
|
|
69
|
-
* unless you have the [Bundle Mode](/docs/
|
|
69
|
+
* unless you have the [Bundle Mode](/docs/bundleMode/) enabled.
|
|
70
70
|
*
|
|
71
71
|
* @param fun - A reference to a function you want to schedule on the [UI
|
|
72
72
|
* Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime).
|
|
@@ -187,7 +187,7 @@ export function runOnUISync<Args extends unknown[], ReturnValue>(
|
|
|
187
187
|
worklet: WorkletFunction<Args, ReturnValue>,
|
|
188
188
|
...args: Args
|
|
189
189
|
): ReturnValue {
|
|
190
|
-
return WorkletsModule.
|
|
190
|
+
return WorkletsModule.runOnUISync(
|
|
191
191
|
createSerializable(() => {
|
|
192
192
|
'worklet';
|
|
193
193
|
const result = worklet(...args);
|