react-native-worklets 0.11.1 → 0.12.0-nightly-20260717-55ef079be
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 +13 -9
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +7 -4
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +2 -1
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +15 -4
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +19 -5
- package/android/build.gradle.kts +19 -5
- package/compatibility.json +4 -1
- package/lib/module/WorkletsModule/NativeWorklets.native.js +2 -2
- package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -1
- package/lib/module/debug/jsVersion.js +1 -1
- package/lib/module/debug/jsVersion.js.map +1 -1
- package/lib/module/memory/serializable.native.js +2 -1
- package/lib/module/memory/serializable.native.js.map +1 -1
- package/lib/module/runtimes.native.js +7 -2
- package/lib/module/runtimes.native.js.map +1 -1
- package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -1
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +1 -1
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
- package/lib/typescript/debug/jsVersion.d.ts +1 -1
- package/lib/typescript/debug/jsVersion.d.ts.map +1 -1
- package/lib/typescript/memory/serializable.native.d.ts.map +1 -1
- package/lib/typescript/runtimes.native.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +38 -8
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/plugin/index.js +1624 -1595
- package/src/WorkletsModule/NativeWorklets.native.ts +4 -2
- package/src/WorkletsModule/workletsModuleProxy.ts +2 -1
- package/src/debug/jsVersion.ts +1 -1
- package/src/memory/serializable.native.ts +6 -2
- package/src/runtimes.native.ts +12 -2
- package/src/types.ts +42 -8
|
@@ -270,14 +270,16 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
270
270
|
initializer: SerializableRef<() => void>,
|
|
271
271
|
useDefaultQueue: boolean,
|
|
272
272
|
customQueue: object | undefined,
|
|
273
|
-
enableEventLoop: boolean
|
|
273
|
+
enableEventLoop: boolean,
|
|
274
|
+
enableLocking: boolean
|
|
274
275
|
) {
|
|
275
276
|
return this.#workletsModuleProxy.createWorkletRuntime(
|
|
276
277
|
name,
|
|
277
278
|
initializer,
|
|
278
279
|
useDefaultQueue,
|
|
279
280
|
customQueue,
|
|
280
|
-
enableEventLoop
|
|
281
|
+
enableEventLoop,
|
|
282
|
+
enableLocking
|
|
281
283
|
);
|
|
282
284
|
}
|
|
283
285
|
|
|
@@ -160,7 +160,8 @@ export interface WorkletsModuleProxy {
|
|
|
160
160
|
initializer: SerializableRef<() => void>,
|
|
161
161
|
useDefaultQueue: boolean,
|
|
162
162
|
customQueue: object | undefined,
|
|
163
|
-
enableEventLoop: boolean
|
|
163
|
+
enableEventLoop: boolean,
|
|
164
|
+
enableLocking: boolean
|
|
164
165
|
): WorkletRuntime;
|
|
165
166
|
|
|
166
167
|
scheduleOnRuntime<TValue>(
|
package/src/debug/jsVersion.ts
CHANGED
|
@@ -210,8 +210,12 @@ export function createSerializable<TValue>(
|
|
|
210
210
|
return cloneCustom(value, pack, i) as SerializableRef<TValue>;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
const constructorName =
|
|
214
|
+
(value as { constructor?: { name?: string } })?.constructor?.name ||
|
|
215
|
+
'unknown';
|
|
216
|
+
throw new Error(
|
|
217
|
+
`[Worklets] Cannot copy value of type \`${constructorName}\`.`
|
|
218
|
+
);
|
|
215
219
|
}
|
|
216
220
|
|
|
217
221
|
if (isBundleModeEnabled()) {
|
package/src/runtimes.native.ts
CHANGED
|
@@ -81,6 +81,7 @@ export function createWorkletRuntime(
|
|
|
81
81
|
let queue: 'default' | object | null = 'default';
|
|
82
82
|
let animationQueuePollingRate: number;
|
|
83
83
|
let enableEventLoop = true;
|
|
84
|
+
let enableLocking = true;
|
|
84
85
|
if (typeof nameOrConfig === 'string') {
|
|
85
86
|
name = nameOrConfig;
|
|
86
87
|
initializerFn = initializer;
|
|
@@ -96,7 +97,15 @@ export function createWorkletRuntime(
|
|
|
96
97
|
animationQueuePollingRate = Math.round(
|
|
97
98
|
nameOrConfig?.animationQueuePollingRate ?? 16
|
|
98
99
|
);
|
|
99
|
-
|
|
100
|
+
enableLocking = nameOrConfig?.enableLocking ?? true;
|
|
101
|
+
if (__DEV__ && !enableLocking && nameOrConfig?.enableEventLoop) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
'[Worklets] The Event Loop cannot be enabled on a runtime with locking disabled.'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
enableEventLoop = enableLocking
|
|
107
|
+
? (nameOrConfig?.enableEventLoop ?? true)
|
|
108
|
+
: false;
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
const useDefaultQueue = queue === 'default';
|
|
@@ -126,7 +135,8 @@ export function createWorkletRuntime(
|
|
|
126
135
|
}),
|
|
127
136
|
useDefaultQueue,
|
|
128
137
|
customQueue,
|
|
129
|
-
enableEventLoop
|
|
138
|
+
enableEventLoop,
|
|
139
|
+
enableLocking
|
|
130
140
|
);
|
|
131
141
|
}
|
|
132
142
|
|
package/src/types.ts
CHANGED
|
@@ -121,18 +121,52 @@ type WorkletRuntimeConfigBase = {
|
|
|
121
121
|
* by requestAnimationFrame. If not specified, it defaults to 16 ms.
|
|
122
122
|
*/
|
|
123
123
|
animationQueuePollingRate?: number;
|
|
124
|
-
/**
|
|
125
|
-
* Determines whether to enable the default Event Loop or not. The Event Loop
|
|
126
|
-
* provides implementations for `setTimeout`, `setImmediate`, `setInterval`,
|
|
127
|
-
* `requestAnimationFrame`, `queueMicrotask`, `clearTimeout`, `clearInterval`,
|
|
128
|
-
* `clearImmediate`, and `cancelAnimationFrame` methods. If not specified, it
|
|
129
|
-
* defaults to `true`.
|
|
130
|
-
*/
|
|
131
|
-
enableEventLoop?: boolean;
|
|
132
124
|
};
|
|
133
125
|
|
|
134
126
|
/** Configuration object for creating a worklet runtime. */
|
|
135
127
|
export type WorkletRuntimeConfig = WorkletRuntimeConfigBase &
|
|
128
|
+
(
|
|
129
|
+
| {
|
|
130
|
+
/**
|
|
131
|
+
* Determines whether to enable the default Event Loop, which provides
|
|
132
|
+
* `setTimeout`, `setInterval`, `requestAnimationFrame` and other
|
|
133
|
+
* scheduling APIs. If not specified, it defaults to `true`. Cannot be
|
|
134
|
+
* enabled when {@link enableLocking} is set to `false`.
|
|
135
|
+
*/
|
|
136
|
+
enableEventLoop?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Determines whether access to the underlying JS runtime is
|
|
139
|
+
* synchronized with a mutex around every JSI operation. If not
|
|
140
|
+
* specified, it defaults to `true`. Can be disabled only together
|
|
141
|
+
* with the Event Loop.
|
|
142
|
+
*
|
|
143
|
+
* Runtime without locking doesn't receive HMR updates
|
|
144
|
+
* and new Custom Serializable registrations.
|
|
145
|
+
*
|
|
146
|
+
* Disable only when you can guarantee thread safety of all access to the runtime.
|
|
147
|
+
*/
|
|
148
|
+
enableLocking?: true;
|
|
149
|
+
}
|
|
150
|
+
| {
|
|
151
|
+
/**
|
|
152
|
+
* The Event Loop cannot be enabled on a runtime with
|
|
153
|
+
* {@link enableLocking} set to `false`.
|
|
154
|
+
*/
|
|
155
|
+
enableEventLoop?: false;
|
|
156
|
+
/**
|
|
157
|
+
* Determines whether access to the underlying JS runtime is
|
|
158
|
+
* synchronized with a mutex around every JSI operation. If not
|
|
159
|
+
* specified, it defaults to `true`. Can be disabled only together
|
|
160
|
+
* with the Event Loop.
|
|
161
|
+
*
|
|
162
|
+
* Runtime without locking doesn't receive HMR updates
|
|
163
|
+
* and new Custom Serializable registrations.
|
|
164
|
+
*
|
|
165
|
+
* Disable only when you can guarantee thread safety of all access to the runtime.
|
|
166
|
+
*/
|
|
167
|
+
enableLocking: false;
|
|
168
|
+
}
|
|
169
|
+
) &
|
|
136
170
|
(
|
|
137
171
|
| {
|
|
138
172
|
/**
|