@onlynative/inertia 0.0.1-alpha.3 → 0.0.1-alpha.4

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 (60) hide show
  1. package/README.md +19 -5
  2. package/dist/index.d.mts +259 -3
  3. package/dist/index.d.ts +259 -3
  4. package/dist/index.js +1711 -118
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1709 -122
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/motion/Image.d.mts +1 -1
  9. package/dist/motion/Image.d.ts +1 -1
  10. package/dist/motion/Image.js +1502 -64
  11. package/dist/motion/Image.js.map +1 -1
  12. package/dist/motion/Image.mjs +1504 -66
  13. package/dist/motion/Image.mjs.map +1 -1
  14. package/dist/motion/Pressable.d.mts +1 -1
  15. package/dist/motion/Pressable.d.ts +1 -1
  16. package/dist/motion/Pressable.js +1502 -64
  17. package/dist/motion/Pressable.js.map +1 -1
  18. package/dist/motion/Pressable.mjs +1504 -66
  19. package/dist/motion/Pressable.mjs.map +1 -1
  20. package/dist/motion/ScrollView.d.mts +1 -1
  21. package/dist/motion/ScrollView.d.ts +1 -1
  22. package/dist/motion/ScrollView.js +1502 -64
  23. package/dist/motion/ScrollView.js.map +1 -1
  24. package/dist/motion/ScrollView.mjs +1504 -66
  25. package/dist/motion/ScrollView.mjs.map +1 -1
  26. package/dist/motion/Text.d.mts +1 -1
  27. package/dist/motion/Text.d.ts +1 -1
  28. package/dist/motion/Text.js +1502 -64
  29. package/dist/motion/Text.js.map +1 -1
  30. package/dist/motion/Text.mjs +1504 -66
  31. package/dist/motion/Text.mjs.map +1 -1
  32. package/dist/motion/View.d.mts +1 -1
  33. package/dist/motion/View.d.ts +1 -1
  34. package/dist/motion/View.js +1502 -64
  35. package/dist/motion/View.js.map +1 -1
  36. package/dist/motion/View.mjs +1504 -66
  37. package/dist/motion/View.mjs.map +1 -1
  38. package/dist/{types-DAhX3fC2.d.mts → types-CjztO3RW.d.mts} +49 -4
  39. package/dist/{types-DAhX3fC2.d.ts → types-CjztO3RW.d.ts} +49 -4
  40. package/llms.txt +29 -4
  41. package/package.json +1 -1
  42. package/src/__type-tests__/animate.test-d.tsx +88 -0
  43. package/src/index.ts +16 -1
  44. package/src/layout/index.ts +1 -0
  45. package/src/layout/resolveLayout.ts +54 -0
  46. package/src/motion/createMotionComponent.tsx +38 -60
  47. package/src/transitions/easing.ts +3 -1
  48. package/src/transitions/index.ts +3 -0
  49. package/src/transitions/keys.ts +32 -0
  50. package/src/transitions/resolve.ts +1 -24
  51. package/src/transitions/sig.ts +40 -0
  52. package/src/transitions/spring.ts +41 -0
  53. package/src/types.ts +52 -2
  54. package/src/values/index.ts +14 -0
  55. package/src/values/useAnimation.ts +69 -0
  56. package/src/values/useGesture.ts +144 -0
  57. package/src/values/useMotionValue.ts +33 -0
  58. package/src/values/useScroll.ts +72 -0
  59. package/src/values/useSpring.ts +93 -0
  60. package/src/values/useTransform.ts +132 -0
@@ -1,14 +1,21 @@
1
- import { Image, Platform } from 'react-native';
1
+ import { Platform, TurboModuleRegistry, Image } from 'react-native';
2
2
  import { createContext, forwardRef, useRef, useState, useEffect, useMemo, useContext } from 'react';
3
- import Animated, { useSharedValue, useAnimatedStyle, interpolateColor, useReducedMotion, withSequence, runOnJS, withRepeat, withDelay, withDecay, withTiming, Easing, withSpring, isWorkletFunction } from 'react-native-reanimated';
3
+ import Animated, { useSharedValue, useAnimatedStyle, interpolateColor, useReducedMotion, withSequence, LinearTransition, runOnJS as runOnJS$1, withRepeat, withDelay, withDecay, withTiming, Easing, withSpring } from 'react-native-reanimated';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
6
+ var __typeError = (msg) => {
7
+ throw TypeError(msg);
8
+ };
6
9
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
10
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
8
11
  }) : x)(function(x) {
9
12
  if (typeof require !== "undefined") return require.apply(this, arguments);
10
13
  throw Error('Dynamic require of "' + x + '" is not supported');
11
14
  });
15
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
16
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
17
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
18
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
12
19
  var DEFAULT_MOTION_CONFIG = {
13
20
  reducedMotion: "user"
14
21
  };
@@ -48,10 +55,1394 @@ function isFocusVisible() {
48
55
  ensureInstalled();
49
56
  return modality === "keyboard";
50
57
  }
51
- var PresenceContext = createContext(null);
52
- function usePresence() {
53
- return useContext(PresenceContext);
58
+
59
+ // ../../node_modules/react-native-worklets/lib/module/logger.js
60
+ var PREFIX = "[Worklets]";
61
+ function formatMessage(message) {
62
+ return `${PREFIX} ${message}`;
63
+ }
64
+ var logger = {
65
+ warn(message) {
66
+ console.warn(formatMessage(message));
67
+ },
68
+ error(message) {
69
+ console.error(formatMessage(message));
70
+ }
71
+ };
72
+
73
+ // ../../node_modules/react-native-worklets/lib/module/runtimeKind.js
74
+ var RuntimeKind = /* @__PURE__ */ (function(RuntimeKind2) {
75
+ RuntimeKind2[RuntimeKind2["ReactNative"] = 1] = "ReactNative";
76
+ RuntimeKind2[RuntimeKind2["UI"] = 2] = "UI";
77
+ RuntimeKind2[RuntimeKind2["Worker"] = 3] = "Worker";
78
+ return RuntimeKind2;
79
+ })({});
80
+ if (globalThis.__RUNTIME_KIND === void 0) {
81
+ globalThis.__RUNTIME_KIND = RuntimeKind.ReactNative;
82
+ }
83
+
84
+ // ../../node_modules/react-native-worklets/lib/module/WorkletsError.js
85
+ function WorkletsErrorConstructor(message) {
86
+ "worklet";
87
+ const prefix = "[Worklets]";
88
+ const errorInstance = new Error(message ? `${prefix} ${message}` : prefix);
89
+ errorInstance.name = `WorkletsError`;
90
+ return errorInstance;
91
+ }
92
+ function registerWorkletsError() {
93
+ "worklet";
94
+ if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
95
+ globalThis.WorkletsError = WorkletsErrorConstructor;
96
+ }
97
+ }
98
+ var WorkletsError = WorkletsErrorConstructor;
99
+
100
+ // ../../node_modules/react-native-worklets/lib/module/bundleUnpacker.js
101
+ var handleCache = /* @__PURE__ */ new WeakMap();
102
+ function bundleValueUnpacker(objectToUnpack, category, remoteFunctionName) {
103
+ const workletHash = objectToUnpack.__workletHash;
104
+ if (workletHash !== void 0) {
105
+ return getWorklet(workletHash, objectToUnpack.__closure);
106
+ } else if (objectToUnpack.__init !== void 0) {
107
+ let value = handleCache.get(objectToUnpack);
108
+ if (value === void 0) {
109
+ value = objectToUnpack.__init();
110
+ handleCache.set(objectToUnpack, value);
111
+ }
112
+ return value;
113
+ } else if (category === "RemoteFunction") {
114
+ const remoteFunctionHolder = () => {
115
+ const label = remoteFunctionName ? `function \`${remoteFunctionName}\`` : "anonymous function";
116
+ throw new WorkletsError(`Tried to synchronously call a non-worklet ${label} on the UI thread.
117
+ See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-synchronously-call-a-non-worklet-function-on-the-ui-thread for more details.`);
118
+ };
119
+ remoteFunctionHolder.__remoteFunction = objectToUnpack;
120
+ return remoteFunctionHolder;
121
+ } else {
122
+ throw new WorkletsError(`Data type in category "${category}" not recognized by value unpacker: "${globalThis._toString(objectToUnpack)}".`);
123
+ }
124
+ }
125
+ function getWorklet(workletHash, closureVariables) {
126
+ let worklet;
127
+ if (__DEV__) {
128
+ try {
129
+ worklet = getWorkletFromMetroRequire(workletHash, closureVariables);
130
+ } catch (_e) {
131
+ logger.error("Unable to resolve worklet with hash " + workletHash + ". Try reloading the app.");
132
+ }
133
+ } else {
134
+ worklet = getWorkletFromMetroRequire(workletHash, closureVariables);
135
+ }
136
+ return worklet;
137
+ }
138
+ var metroRequire = globalThis.__r;
139
+ function getWorkletFromMetroRequire(workletHash, closureVariables) {
140
+ const factory = metroRequire(workletHash).default;
141
+ return factory(closureVariables);
142
+ }
143
+
144
+ // ../../node_modules/react-native-worklets/lib/module/callGuard.js
145
+ function callGuardDEV(fn, ...args) {
146
+ "worklet";
147
+ try {
148
+ return fn(...args);
149
+ } catch (error) {
150
+ if (globalThis.__workletsModuleProxy) {
151
+ const {
152
+ message,
153
+ stack,
154
+ name,
155
+ jsEngine
156
+ } = error;
157
+ globalThis.__workletsModuleProxy.reportFatalErrorOnJS(message, stack ?? "", name ?? "WorkletsError", jsEngine ?? "Worklets");
158
+ } else {
159
+ throw error;
160
+ }
161
+ }
162
+ }
163
+ function setupCallGuard() {
164
+ "worklet";
165
+ if (!globalThis.__callGuardDEV) {
166
+ globalThis.__callGuardDEV = callGuardDEV;
167
+ }
168
+ }
169
+
170
+ // ../../node_modules/react-native-worklets/lib/module/errors.js
171
+ var _workletStackDetails = /* @__PURE__ */ new Map();
172
+ function registerWorkletStackDetails(hash, stackDetails) {
173
+ _workletStackDetails.set(hash, stackDetails);
174
+ }
175
+ function getBundleOffset(error) {
176
+ const frame = error.stack?.split("\n")?.[0];
177
+ if (frame) {
178
+ const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
179
+ if (parsedFrame) {
180
+ const [, file, line, col] = parsedFrame;
181
+ return [file, Number(line), Number(col)];
182
+ }
183
+ }
184
+ return ["unknown", 0, 0];
185
+ }
186
+ function processStack(stack) {
187
+ if (stack === "" || stack === void 0) {
188
+ return void 0;
189
+ }
190
+ const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
191
+ let result = stack;
192
+ workletStackEntries?.forEach((match) => {
193
+ const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
194
+ const errorDetails = _workletStackDetails.get(hash);
195
+ if (!errorDetails) {
196
+ return;
197
+ }
198
+ const [error, lineOffset, colOffset] = errorDetails;
199
+ const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
200
+ const line = origLine + bundleLine + lineOffset;
201
+ const col = origCol + bundleCol + colOffset;
202
+ result = result.replace(match, `${bundleFile}:${line}:${col}`);
203
+ });
204
+ return result;
205
+ }
206
+ function reportFatalRemoteError({
207
+ message,
208
+ stack,
209
+ name,
210
+ jsEngine
211
+ }, force) {
212
+ const error = new WorkletsError();
213
+ error.message = message;
214
+ error.stack = processStack(stack);
215
+ error.name = name;
216
+ error.jsEngine = jsEngine;
217
+ if (force) {
218
+ throw error;
219
+ } else {
220
+ globalThis.ErrorUtils.reportFatalError(error);
221
+ }
222
+ }
223
+ function registerReportFatalRemoteError() {
224
+ globalThis.__reportFatalRemoteError = reportFatalRemoteError;
225
+ }
226
+ var IS_JEST = !!process.env.JEST_WORKER_ID;
227
+ var IS_WEB = Platform.OS === "web";
228
+ var IS_WINDOWS = Platform.OS === "windows";
229
+ var SHOULD_BE_USE_WEB = IS_JEST || IS_WEB || IS_WINDOWS;
230
+
231
+ // ../../node_modules/react-native-worklets/lib/module/PlatformChecker/index.js
232
+ var IS_JEST2 = false;
233
+ var SHOULD_BE_USE_WEB2 = false;
234
+ if (globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
235
+ IS_JEST2 = IS_JEST;
236
+ SHOULD_BE_USE_WEB2 = SHOULD_BE_USE_WEB;
237
+ }
238
+
239
+ // ../../node_modules/react-native-worklets/lib/module/runLoop/common/setImmediatePolyfill.js
240
+ function setupSetImmediate() {
241
+ "worklet";
242
+ const setImmediatePolyfill = (callback, ...args) => {
243
+ return setTimeout(callback, 0, ...args);
244
+ };
245
+ const clearImmediatePolyfill = (immediateHandle) => {
246
+ clearTimeout(immediateHandle);
247
+ };
248
+ globalThis.setImmediate = setImmediatePolyfill;
249
+ globalThis.clearImmediate = clearImmediatePolyfill;
250
+ }
251
+
252
+ // ../../node_modules/react-native-worklets/lib/module/runLoop/common/setIntervalPolyfill.js
253
+ function setupSetInterval() {
254
+ "worklet";
255
+ const intervalHandleToTimeoutHandle = /* @__PURE__ */ new Map();
256
+ const setIntervalPolyfill = (callback, delay = 0, ...args) => {
257
+ let intervalHandle = 0;
258
+ const repeatingCallback = () => {
259
+ const timeoutHandle = setTimeout(repeatingCallback, delay);
260
+ intervalHandleToTimeoutHandle.set(intervalHandle, timeoutHandle);
261
+ callback(...args);
262
+ };
263
+ intervalHandle = setTimeout(repeatingCallback, delay);
264
+ intervalHandleToTimeoutHandle.set(intervalHandle, intervalHandle);
265
+ return intervalHandle;
266
+ };
267
+ const clearIntervalPolyfill = (intervalHandle) => {
268
+ const timeoutHandle = intervalHandleToTimeoutHandle.get(intervalHandle);
269
+ clearTimeout(timeoutHandle);
270
+ intervalHandleToTimeoutHandle.delete(intervalHandle);
271
+ };
272
+ globalThis.setInterval = setIntervalPolyfill;
273
+ globalThis.clearInterval = clearIntervalPolyfill;
274
+ }
275
+
276
+ // ../../node_modules/react-native-worklets/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js
277
+ function mockedRequestAnimationFrame(callback) {
278
+ return setTimeout(() => callback(performance.now()), 0);
279
+ }
280
+
281
+ // ../../node_modules/react-native-worklets/lib/module/isSynchronizable.js
282
+ function isSynchronizable(value) {
283
+ return typeof value === "object" && value !== null && "__synchronizableRef" in value && value.__synchronizableRef === true;
284
+ }
285
+
286
+ // ../../node_modules/react-native-worklets/lib/module/serializableMappingCache.js
287
+ var serializableMappingFlag = /* @__PURE__ */ Symbol("serializable flag");
288
+ var cache = SHOULD_BE_USE_WEB2 ? null : /* @__PURE__ */ new WeakMap();
289
+ var serializableMappingCache = SHOULD_BE_USE_WEB2 ? {
290
+ set() {
291
+ },
292
+ get() {
293
+ return null;
294
+ }
295
+ } : {
296
+ set(serializable, serializableRef) {
297
+ cache.set(serializable, serializableRef || serializableMappingFlag);
298
+ },
299
+ get: cache.get.bind(cache)
300
+ };
301
+
302
+ // ../../node_modules/react-native-worklets/lib/module/utils/jsVersion.js
303
+ var jsVersion = "0.5.1";
304
+
305
+ // ../../node_modules/react-native-worklets/lib/module/workletFunction.js
306
+ function isWorkletFunction(value) {
307
+ "worklet";
308
+ return (
309
+ // `__workletHash` isn't extracted in Worklet Runtimes.
310
+ typeof value === "function" && !!value.__workletHash
311
+ );
312
+ }
313
+
314
+ // ../../node_modules/react-native-worklets/lib/module/WorkletsModule/JSWorklets.js
315
+ function createJSWorkletsModule() {
316
+ return new JSWorklets();
317
+ }
318
+ var requestAnimationFrameImpl = IS_JEST2 || !globalThis.requestAnimationFrame ? mockedRequestAnimationFrame : globalThis.requestAnimationFrame;
319
+ var JSWorklets = class {
320
+ createSerializable() {
321
+ throw new WorkletsError("createSerializable should never be called in JSWorklets.");
322
+ }
323
+ createSerializableString() {
324
+ throw new WorkletsError("createSerializableString should never be called in JSWorklets.");
325
+ }
326
+ createSerializableNumber() {
327
+ throw new WorkletsError("createSerializableNumber should never be called in JSWorklets.");
328
+ }
329
+ createSerializableBoolean() {
330
+ throw new WorkletsError("createSerializableBoolean should never be called in JSWorklets.");
331
+ }
332
+ createSerializableBigInt() {
333
+ throw new WorkletsError("createSerializableBigInt should never be called in JSWorklets.");
334
+ }
335
+ createSerializableUndefined() {
336
+ throw new WorkletsError("createSerializableUndefined should never be called in JSWorklets.");
337
+ }
338
+ createSerializableNull() {
339
+ throw new WorkletsError("createSerializableNull should never be called in JSWorklets.");
340
+ }
341
+ createSerializableTurboModuleLike() {
342
+ throw new WorkletsError("createSerializableTurboModuleLike should never be called in JSWorklets.");
343
+ }
344
+ createSerializableObject() {
345
+ throw new WorkletsError("createSerializableObject should never be called in JSWorklets.");
346
+ }
347
+ createSerializableMap() {
348
+ throw new WorkletsError("createSerializableMap should never be called in JSWorklets.");
349
+ }
350
+ createSerializableSet() {
351
+ throw new WorkletsError("createSerializableSet should never be called in JSWorklets.");
352
+ }
353
+ createSerializableImport() {
354
+ throw new WorkletsError("createSerializableImport should never be called in JSWorklets.");
355
+ }
356
+ createSerializableHostObject() {
357
+ throw new WorkletsError("createSerializableHostObject should never be called in JSWorklets.");
358
+ }
359
+ createSerializableArray() {
360
+ throw new WorkletsError("createSerializableArray should never be called in JSWorklets.");
361
+ }
362
+ createSerializableInitializer() {
363
+ throw new WorkletsError("createSerializableInitializer should never be called in JSWorklets.");
364
+ }
365
+ createSerializableFunction() {
366
+ throw new WorkletsError("createSerializableFunction should never be called in JSWorklets.");
367
+ }
368
+ createSerializableWorklet() {
369
+ throw new WorkletsError("createSerializableWorklet should never be called in JSWorklets.");
370
+ }
371
+ scheduleOnUI(worklet) {
372
+ requestAnimationFrameImpl(worklet);
373
+ }
374
+ executeOnUIRuntimeSync() {
375
+ throw new WorkletsError("`executeOnUIRuntimeSync` is not available in JSWorklets.");
376
+ }
377
+ createWorkletRuntime() {
378
+ throw new WorkletsError("createWorkletRuntime is not available in JSWorklets.");
379
+ }
380
+ scheduleOnRuntime() {
381
+ throw new WorkletsError("scheduleOnRuntime is not available in JSWorklets.");
382
+ }
383
+ createSynchronizable() {
384
+ throw new WorkletsError("createSynchronizable should never be called in JSWorklets.");
385
+ }
386
+ synchronizableGetDirty() {
387
+ throw new WorkletsError("synchronizableGetDirty should never be called in JSWorklets.");
388
+ }
389
+ synchronizableGetBlocking() {
390
+ throw new WorkletsError("synchronizableGetBlocking should never be called in JSWorklets.");
391
+ }
392
+ synchronizableSetBlocking() {
393
+ throw new WorkletsError("synchronizableSetBlocking should never be called in JSWorklets.");
394
+ }
395
+ synchronizableLock() {
396
+ throw new WorkletsError("synchronizableLock should never be called in JSWorklets.");
397
+ }
398
+ synchronizableUnlock() {
399
+ throw new WorkletsError("synchronizableUnlock should never be called in JSWorklets.");
400
+ }
401
+ reportFatalErrorOnJS() {
402
+ throw new WorkletsError("reportFatalErrorOnJS should never be called in JSWorklets.");
403
+ }
404
+ getStaticFeatureFlag() {
405
+ return false;
406
+ }
407
+ setDynamicFeatureFlag() {
408
+ }
409
+ };
410
+ var NativeWorkletsModule_default = TurboModuleRegistry.get("WorkletsModule");
411
+
412
+ // ../../node_modules/react-native-worklets/lib/module/specs/index.js
413
+ var WorkletsTurboModule = globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative ? NativeWorkletsModule_default : (
414
+ // In Bundle Mode, on Worklet Runtimes `RNWorkletsTurboModule` isn't
415
+ // available and shouldn't be accessed. We return null here
416
+ // to keep the same codebase for the Bundle Mode and legacy behavior.
417
+ null
418
+ );
419
+
420
+ // ../../node_modules/react-native-worklets/lib/module/utils/checkCppVersion.js
421
+ function checkCppVersion() {
422
+ const cppVersion = global._WORKLETS_VERSION_CPP;
423
+ if (cppVersion === void 0) {
424
+ logger.warn(`Couldn't determine the version of the native part of Worklets.
425
+ See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#couldnt-determine-the-version-of-the-native-part-of-worklets\` for more details.`);
426
+ return;
427
+ }
428
+ const ok = matchVersion(jsVersion, cppVersion);
429
+ if (!ok) {
430
+ throw new WorkletsError(`Mismatch between JavaScript part and native part of Worklets (${jsVersion} vs ${cppVersion}).
431
+ See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#mismatch-between-javascript-part-and-native-part-of-worklets\` for more details.`);
432
+ }
433
+ }
434
+ function matchVersion(version1, version2) {
435
+ if (version1.match(/^\d+\.\d+\.\d+$/) && version2.match(/^\d+\.\d+\.\d+$/)) {
436
+ const [major1, minor1] = version1.split(".");
437
+ const [major2, minor2] = version2.split(".");
438
+ return major1 === major2 && minor1 === minor2;
439
+ } else {
440
+ return version1 === version2;
441
+ }
442
+ }
443
+
444
+ // ../../node_modules/react-native-worklets/lib/module/WorkletsModule/NativeWorklets.js
445
+ function createNativeWorkletsModule() {
446
+ return new NativeWorklets();
447
+ }
448
+ var _workletsModuleProxy, _serializableUndefined, _serializableNull, _serializableTrue, _serializableFalse;
449
+ var NativeWorklets = class {
450
+ constructor() {
451
+ __privateAdd(this, _workletsModuleProxy);
452
+ __privateAdd(this, _serializableUndefined);
453
+ __privateAdd(this, _serializableNull);
454
+ __privateAdd(this, _serializableTrue);
455
+ __privateAdd(this, _serializableFalse);
456
+ globalThis._WORKLETS_VERSION_JS = jsVersion;
457
+ if (global.__workletsModuleProxy === void 0 && globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
458
+ WorkletsTurboModule?.installTurboModule();
459
+ }
460
+ if (global.__workletsModuleProxy === void 0) {
461
+ throw new WorkletsError(`Native part of Worklets doesn't seem to be initialized.
462
+ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#native-part-of-worklets-doesnt-seem-to-be-initialized for more details.`);
463
+ }
464
+ if (__DEV__) {
465
+ checkCppVersion();
466
+ }
467
+ __privateSet(this, _workletsModuleProxy, global.__workletsModuleProxy);
468
+ __privateSet(this, _serializableNull, __privateGet(this, _workletsModuleProxy).createSerializableNull());
469
+ __privateSet(this, _serializableUndefined, __privateGet(this, _workletsModuleProxy).createSerializableUndefined());
470
+ __privateSet(this, _serializableTrue, __privateGet(this, _workletsModuleProxy).createSerializableBoolean(true));
471
+ __privateSet(this, _serializableFalse, __privateGet(this, _workletsModuleProxy).createSerializableBoolean(false));
472
+ }
473
+ createSerializable(value, shouldPersistRemote, nativeStateSource) {
474
+ return __privateGet(this, _workletsModuleProxy).createSerializable(value, shouldPersistRemote, nativeStateSource);
475
+ }
476
+ createSerializableImport(from, to) {
477
+ return __privateGet(this, _workletsModuleProxy).createSerializableImport(from, to);
478
+ }
479
+ createSerializableString(str) {
480
+ return __privateGet(this, _workletsModuleProxy).createSerializableString(str);
481
+ }
482
+ createSerializableNumber(num) {
483
+ return __privateGet(this, _workletsModuleProxy).createSerializableNumber(num);
484
+ }
485
+ createSerializableBoolean(bool) {
486
+ return bool ? __privateGet(this, _serializableTrue) : __privateGet(this, _serializableFalse);
487
+ }
488
+ createSerializableBigInt(bigInt) {
489
+ return __privateGet(this, _workletsModuleProxy).createSerializableBigInt(bigInt);
490
+ }
491
+ createSerializableUndefined() {
492
+ return __privateGet(this, _serializableUndefined);
493
+ }
494
+ createSerializableNull() {
495
+ return __privateGet(this, _serializableNull);
496
+ }
497
+ createSerializableTurboModuleLike(props, proto) {
498
+ return __privateGet(this, _workletsModuleProxy).createSerializableTurboModuleLike(props, proto);
499
+ }
500
+ createSerializableObject(obj, shouldRetainRemote, nativeStateSource) {
501
+ return __privateGet(this, _workletsModuleProxy).createSerializableObject(obj, shouldRetainRemote, nativeStateSource);
502
+ }
503
+ createSerializableHostObject(obj) {
504
+ return __privateGet(this, _workletsModuleProxy).createSerializableHostObject(obj);
505
+ }
506
+ createSerializableArray(array, shouldRetainRemote) {
507
+ return __privateGet(this, _workletsModuleProxy).createSerializableArray(array, shouldRetainRemote);
508
+ }
509
+ createSerializableMap(keys, values) {
510
+ return __privateGet(this, _workletsModuleProxy).createSerializableMap(keys, values);
511
+ }
512
+ createSerializableSet(values) {
513
+ return __privateGet(this, _workletsModuleProxy).createSerializableSet(values);
514
+ }
515
+ createSerializableInitializer(obj) {
516
+ return __privateGet(this, _workletsModuleProxy).createSerializableInitializer(obj);
517
+ }
518
+ createSerializableFunction(func) {
519
+ return __privateGet(this, _workletsModuleProxy).createSerializableFunction(func);
520
+ }
521
+ createSerializableWorklet(worklet, shouldPersistRemote) {
522
+ return __privateGet(this, _workletsModuleProxy).createSerializableWorklet(worklet, shouldPersistRemote);
523
+ }
524
+ scheduleOnUI(serializable) {
525
+ return __privateGet(this, _workletsModuleProxy).scheduleOnUI(serializable);
526
+ }
527
+ executeOnUIRuntimeSync(serializable) {
528
+ return __privateGet(this, _workletsModuleProxy).executeOnUIRuntimeSync(serializable);
529
+ }
530
+ createWorkletRuntime(name, initializer, useDefaultQueue, customQueue, enableEventLoop) {
531
+ return __privateGet(this, _workletsModuleProxy).createWorkletRuntime(name, initializer, useDefaultQueue, customQueue, enableEventLoop);
532
+ }
533
+ scheduleOnRuntime(workletRuntime, serializableWorklet) {
534
+ return __privateGet(this, _workletsModuleProxy).scheduleOnRuntime(workletRuntime, serializableWorklet);
535
+ }
536
+ createSynchronizable(value) {
537
+ return __privateGet(this, _workletsModuleProxy).createSynchronizable(value);
538
+ }
539
+ synchronizableGetDirty(synchronizableRef) {
540
+ return __privateGet(this, _workletsModuleProxy).synchronizableGetDirty(synchronizableRef);
541
+ }
542
+ synchronizableGetBlocking(synchronizableRef) {
543
+ return __privateGet(this, _workletsModuleProxy).synchronizableGetBlocking(synchronizableRef);
544
+ }
545
+ synchronizableSetBlocking(synchronizableRef, value) {
546
+ return __privateGet(this, _workletsModuleProxy).synchronizableSetBlocking(synchronizableRef, value);
547
+ }
548
+ synchronizableLock(synchronizableRef) {
549
+ return __privateGet(this, _workletsModuleProxy).synchronizableLock(synchronizableRef);
550
+ }
551
+ synchronizableUnlock(synchronizableRef) {
552
+ return __privateGet(this, _workletsModuleProxy).synchronizableUnlock(synchronizableRef);
553
+ }
554
+ reportFatalErrorOnJS(message, stack, name, jsEngine) {
555
+ return __privateGet(this, _workletsModuleProxy).reportFatalErrorOnJS(message, stack, name, jsEngine);
556
+ }
557
+ getStaticFeatureFlag(name) {
558
+ return __privateGet(this, _workletsModuleProxy).getStaticFeatureFlag(name);
559
+ }
560
+ setDynamicFeatureFlag(name, value) {
561
+ __privateGet(this, _workletsModuleProxy).setDynamicFeatureFlag(name, value);
562
+ }
563
+ };
564
+ _workletsModuleProxy = new WeakMap();
565
+ _serializableUndefined = new WeakMap();
566
+ _serializableNull = new WeakMap();
567
+ _serializableTrue = new WeakMap();
568
+ _serializableFalse = new WeakMap();
569
+
570
+ // ../../node_modules/react-native-worklets/lib/module/WorkletsModule/workletsModuleInstance.js
571
+ var WorkletsModule = SHOULD_BE_USE_WEB2 ? createJSWorkletsModule() : createNativeWorkletsModule();
572
+
573
+ // ../../node_modules/react-native-worklets/lib/module/serializable.js
574
+ var MAGIC_KEY = "REANIMATED_MAGIC_KEY";
575
+ function isHostObject(value) {
576
+ "worklet";
577
+ return MAGIC_KEY in value;
578
+ }
579
+ function isPlainJSObject(object) {
580
+ "worklet";
581
+ return Object.getPrototypeOf(object) === Object.prototype;
582
+ }
583
+ function isTurboModuleLike(object) {
584
+ return isHostObject(Object.getPrototypeOf(object));
585
+ }
586
+ function getFromCache(value) {
587
+ const cached = serializableMappingCache.get(value);
588
+ if (cached === serializableMappingFlag) {
589
+ return value;
590
+ }
591
+ return cached;
592
+ }
593
+ var INACCESSIBLE_OBJECT = {
594
+ __init: () => {
595
+ "worklet";
596
+ return new Proxy({}, {
597
+ get: (_, prop) => {
598
+ if (prop === "_isReanimatedSharedValue" || prop === "__remoteFunction") {
599
+ return false;
600
+ }
601
+ throw new WorkletsError(`Trying to access property \`${String(prop)}\` of an object which cannot be sent to the UI runtime.`);
602
+ },
603
+ set: () => {
604
+ throw new WorkletsError("Trying to write to an object which cannot be sent to the UI runtime.");
605
+ }
606
+ });
607
+ }
608
+ };
609
+ var VALID_ARRAY_VIEWS_NAMES = ["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array", "DataView"];
610
+ var DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD = 30;
611
+ var processedObjectAtThresholdDepth;
612
+ function createSerializableWeb(value) {
613
+ return value;
614
+ }
615
+ function createSerializableNative(value, shouldPersistRemote = false, depth = 0) {
616
+ detectCyclicObject(value, depth);
617
+ const isObject = typeof value === "object";
618
+ const isFunction = typeof value === "function";
619
+ if (typeof value === "string") {
620
+ return cloneString(value);
621
+ }
622
+ if (typeof value === "number") {
623
+ return cloneNumber(value);
624
+ }
625
+ if (typeof value === "boolean") {
626
+ return cloneBoolean(value);
627
+ }
628
+ if (typeof value === "bigint") {
629
+ return cloneBigInt(value);
630
+ }
631
+ if (value === void 0) {
632
+ return cloneUndefined();
633
+ }
634
+ if (value === null) {
635
+ return cloneNull();
636
+ }
637
+ if (!isObject && !isFunction || value === null) {
638
+ return clonePrimitive(value, shouldPersistRemote);
639
+ }
640
+ const cached = getFromCache(value);
641
+ if (cached !== void 0) {
642
+ return cached;
643
+ }
644
+ if (Array.isArray(value)) {
645
+ return cloneArray(value, shouldPersistRemote, depth);
646
+ }
647
+ if (globalThis._WORKLETS_BUNDLE_MODE && isFunction && value.__bundleData) {
648
+ return cloneImport(value);
649
+ }
650
+ if (isFunction && !isWorkletFunction(value)) {
651
+ return cloneRemoteFunction(value);
652
+ }
653
+ if (isTurboModuleLike(value)) {
654
+ return cloneTurboModuleLike(value, shouldPersistRemote, depth);
655
+ }
656
+ if (isHostObject(value)) {
657
+ return cloneHostObject(value);
658
+ }
659
+ if (isPlainJSObject(value) && value.__init) {
660
+ return cloneInitializer(value, shouldPersistRemote, depth);
661
+ }
662
+ if (isPlainJSObject(value) && value.__workletContextObjectFactory) {
663
+ return cloneContextObject(value);
664
+ }
665
+ if ((isPlainJSObject(value) || isFunction) && isWorkletFunction(value)) {
666
+ return cloneWorklet(value, shouldPersistRemote, depth);
667
+ }
668
+ if (isSynchronizable(value)) {
669
+ return cloneSynchronizable(value);
670
+ }
671
+ if (isPlainJSObject(value) || isFunction) {
672
+ return clonePlainJSObject(value, shouldPersistRemote, depth);
673
+ }
674
+ if (value instanceof Set) {
675
+ return cloneSet(value);
676
+ }
677
+ if (value instanceof Map) {
678
+ return cloneMap(value);
679
+ }
680
+ if (value instanceof RegExp) {
681
+ return cloneRegExp(value);
682
+ }
683
+ if (value instanceof Error) {
684
+ return cloneError(value);
685
+ }
686
+ if (value instanceof ArrayBuffer) {
687
+ return cloneArrayBuffer(value, shouldPersistRemote);
688
+ }
689
+ if (ArrayBuffer.isView(value)) {
690
+ return cloneArrayBufferView(value);
691
+ }
692
+ return inaccessibleObject(value);
693
+ }
694
+ if (globalThis._WORKLETS_BUNDLE_MODE) {
695
+ createSerializableNative.__bundleData = {
696
+ imported: "createSerializable",
697
+ // @ts-expect-error resolveWeak is defined by Metro
698
+ source: __require.resolveWeak("./index")
699
+ };
700
+ }
701
+ var createSerializable = SHOULD_BE_USE_WEB2 ? createSerializableWeb : createSerializableNative;
702
+ function detectCyclicObject(value, depth) {
703
+ if (depth >= DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {
704
+ if (depth === DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {
705
+ processedObjectAtThresholdDepth = value;
706
+ } else if (value === processedObjectAtThresholdDepth) {
707
+ throw new WorkletsError("Trying to convert a cyclic object to a serializable. This is not supported.");
708
+ }
709
+ } else {
710
+ processedObjectAtThresholdDepth = void 0;
711
+ }
54
712
  }
713
+ function clonePrimitive(value, shouldPersistRemote) {
714
+ return WorkletsModule.createSerializable(value, shouldPersistRemote);
715
+ }
716
+ function cloneString(value) {
717
+ return WorkletsModule.createSerializableString(value);
718
+ }
719
+ function cloneNumber(value) {
720
+ return WorkletsModule.createSerializableNumber(value);
721
+ }
722
+ function cloneBoolean(value) {
723
+ return WorkletsModule.createSerializableBoolean(value);
724
+ }
725
+ function cloneBigInt(value) {
726
+ return WorkletsModule.createSerializableBigInt(value);
727
+ }
728
+ function cloneUndefined() {
729
+ return WorkletsModule.createSerializableUndefined();
730
+ }
731
+ function cloneNull() {
732
+ return WorkletsModule.createSerializableNull();
733
+ }
734
+ function cloneObjectProperties(value, shouldPersistRemote, depth) {
735
+ const clonedProps = {};
736
+ for (const [key, element] of Object.entries(value)) {
737
+ if (key === "__initData" && clonedProps.__initData !== void 0) {
738
+ continue;
739
+ }
740
+ clonedProps[key] = createSerializable(element, shouldPersistRemote, depth + 1);
741
+ }
742
+ return clonedProps;
743
+ }
744
+ function cloneInitializer(value, shouldPersistRemote = false, depth = 0) {
745
+ const clonedProps = cloneObjectProperties(value, shouldPersistRemote, depth);
746
+ return WorkletsModule.createSerializableInitializer(clonedProps);
747
+ }
748
+ function cloneArray(value, shouldPersistRemote, depth) {
749
+ const clonedElements = value.map((element) => createSerializable(element, shouldPersistRemote, depth + 1));
750
+ const clone = WorkletsModule.createSerializableArray(clonedElements, shouldPersistRemote);
751
+ serializableMappingCache.set(value, clone);
752
+ serializableMappingCache.set(clone);
753
+ freezeObjectInDev(value);
754
+ return clone;
755
+ }
756
+ function cloneRemoteFunction(value) {
757
+ const clone = WorkletsModule.createSerializableFunction(value);
758
+ serializableMappingCache.set(value, clone);
759
+ serializableMappingCache.set(clone);
760
+ freezeObjectInDev(value);
761
+ return clone;
762
+ }
763
+ function cloneHostObject(value) {
764
+ const clone = WorkletsModule.createSerializableHostObject(value);
765
+ serializableMappingCache.set(value, clone);
766
+ serializableMappingCache.set(clone);
767
+ return clone;
768
+ }
769
+ function cloneWorklet(value, shouldPersistRemote, depth) {
770
+ if (__DEV__) {
771
+ const babelVersion = value.__pluginVersion;
772
+ if (babelVersion !== void 0 && babelVersion !== jsVersion) {
773
+ throw new WorkletsError(`Mismatch between JavaScript code version and Worklets Babel plugin version (${jsVersion} vs. ${babelVersion}).
774
+ See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#mismatch-between-javascript-code-version-and-worklets-babel-plugin-version\` for more details.
775
+ Offending code was: \`${getWorkletCode(value)}\``);
776
+ }
777
+ registerWorkletStackDetails(value.__workletHash, value.__stackDetails);
778
+ }
779
+ if (value.__stackDetails) {
780
+ delete value.__stackDetails;
781
+ }
782
+ const clonedProps = cloneObjectProperties(value, true, depth);
783
+ clonedProps.__initData = createSerializable(value.__initData, true, depth + 1);
784
+ const clone = WorkletsModule.createSerializableWorklet(
785
+ clonedProps,
786
+ // TODO: Check after refactor if we can remove shouldPersistRemote parameter (imho it's redundant here since worklets are always persistent)
787
+ // retain all worklets
788
+ true
789
+ );
790
+ serializableMappingCache.set(value, clone);
791
+ serializableMappingCache.set(clone);
792
+ freezeObjectInDev(value);
793
+ return clone;
794
+ }
795
+ function cloneTurboModuleLike(value, shouldPersistRemote, depth) {
796
+ const proto = Object.getPrototypeOf(value);
797
+ const clonedProps = cloneObjectProperties(value, shouldPersistRemote, depth);
798
+ const clone = WorkletsModule.createSerializableTurboModuleLike(clonedProps, proto);
799
+ return clone;
800
+ }
801
+ function cloneContextObject(value) {
802
+ const workletContextObjectFactory = value.__workletContextObjectFactory;
803
+ const handle = cloneInitializer({
804
+ __init: () => {
805
+ "worklet";
806
+ return workletContextObjectFactory();
807
+ }
808
+ });
809
+ serializableMappingCache.set(value, handle);
810
+ return handle;
811
+ }
812
+ function clonePlainJSObject(value, shouldPersistRemote, depth) {
813
+ const clonedProps = cloneObjectProperties(value, shouldPersistRemote, depth);
814
+ const clone = WorkletsModule.createSerializableObject(clonedProps, shouldPersistRemote, value);
815
+ serializableMappingCache.set(value, clone);
816
+ serializableMappingCache.set(clone);
817
+ freezeObjectInDev(value);
818
+ return clone;
819
+ }
820
+ function cloneMap(value) {
821
+ const clonedKeys = [];
822
+ const clonedValues = [];
823
+ for (const [key, element] of value.entries()) {
824
+ clonedKeys.push(createSerializable(key));
825
+ clonedValues.push(createSerializable(element));
826
+ }
827
+ const clone = WorkletsModule.createSerializableMap(clonedKeys, clonedValues);
828
+ serializableMappingCache.set(value, clone);
829
+ serializableMappingCache.set(clone);
830
+ freezeObjectInDev(value);
831
+ return clone;
832
+ }
833
+ function cloneSet(value) {
834
+ const clonedElements = [];
835
+ for (const element of value) {
836
+ clonedElements.push(createSerializable(element));
837
+ }
838
+ const clone = WorkletsModule.createSerializableSet(clonedElements);
839
+ serializableMappingCache.set(value, clone);
840
+ serializableMappingCache.set(clone);
841
+ freezeObjectInDev(value);
842
+ return clone;
843
+ }
844
+ function cloneRegExp(value) {
845
+ const pattern = value.source;
846
+ const flags = value.flags;
847
+ const handle = cloneInitializer({
848
+ __init: () => {
849
+ "worklet";
850
+ return new RegExp(pattern, flags);
851
+ }
852
+ });
853
+ serializableMappingCache.set(value, handle);
854
+ return handle;
855
+ }
856
+ function cloneError(value) {
857
+ const {
858
+ name,
859
+ message,
860
+ stack
861
+ } = value;
862
+ const handle = cloneInitializer({
863
+ __init: () => {
864
+ "worklet";
865
+ const error = new Error();
866
+ error.name = name;
867
+ error.message = message;
868
+ error.stack = stack;
869
+ return error;
870
+ }
871
+ });
872
+ serializableMappingCache.set(value, handle);
873
+ return handle;
874
+ }
875
+ function cloneArrayBuffer(value, shouldPersistRemote) {
876
+ const clone = WorkletsModule.createSerializable(value, shouldPersistRemote, value);
877
+ serializableMappingCache.set(value, clone);
878
+ serializableMappingCache.set(clone);
879
+ return clone;
880
+ }
881
+ function cloneArrayBufferView(value) {
882
+ const buffer = value.buffer;
883
+ const typeName = value.constructor.name;
884
+ const handle = cloneInitializer({
885
+ __init: () => {
886
+ "worklet";
887
+ if (!VALID_ARRAY_VIEWS_NAMES.includes(typeName)) {
888
+ throw new WorkletsError(`Invalid array view name \`${typeName}\`.`);
889
+ }
890
+ const constructor = global[typeName];
891
+ if (constructor === void 0) {
892
+ throw new WorkletsError(`Constructor for \`${typeName}\` not found.`);
893
+ }
894
+ return new constructor(buffer);
895
+ }
896
+ });
897
+ serializableMappingCache.set(value, handle);
898
+ return handle;
899
+ }
900
+ function cloneSynchronizable(value) {
901
+ serializableMappingCache.set(value);
902
+ return value;
903
+ }
904
+ function cloneImport(value) {
905
+ const {
906
+ source,
907
+ imported
908
+ } = value.__bundleData;
909
+ const clone = WorkletsModule.createSerializableImport(source, imported);
910
+ serializableMappingCache.set(value, clone);
911
+ serializableMappingCache.set(clone);
912
+ return clone;
913
+ }
914
+ function inaccessibleObject(value) {
915
+ const clone = createSerializable(INACCESSIBLE_OBJECT);
916
+ serializableMappingCache.set(value, clone);
917
+ return clone;
918
+ }
919
+ var WORKLET_CODE_THRESHOLD = 255;
920
+ function getWorkletCode(value) {
921
+ const code = value?.__initData?.code;
922
+ if (!code) {
923
+ return "unknown";
924
+ }
925
+ if (code.length > WORKLET_CODE_THRESHOLD) {
926
+ return `${code.substring(0, WORKLET_CODE_THRESHOLD)}...`;
927
+ }
928
+ return code;
929
+ }
930
+ function isRemoteFunction(value) {
931
+ "worklet";
932
+ return !!value.__remoteFunction;
933
+ }
934
+ function freezeObjectInDev(value) {
935
+ if (!__DEV__) {
936
+ return;
937
+ }
938
+ Object.entries(value).forEach(([key, element]) => {
939
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
940
+ if (!descriptor.configurable) {
941
+ return;
942
+ }
943
+ Object.defineProperty(value, key, {
944
+ get() {
945
+ return element;
946
+ },
947
+ set() {
948
+ logger.warn(`Tried to modify key \`${key}\` of an object which has been already passed to a worklet. See
949
+ https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-modify-key-of-an-object-which-has-been-converted-to-a-serializable
950
+ for more details.`);
951
+ }
952
+ });
953
+ });
954
+ Object.preventExtensions(value);
955
+ }
956
+ function makeShareableCloneOnUIRecursiveLEGACY(value) {
957
+ "worklet";
958
+ if (SHOULD_BE_USE_WEB2) {
959
+ return value;
960
+ }
961
+ function cloneRecursive(value2) {
962
+ if (typeof value2 === "object" && value2 !== null || typeof value2 === "function") {
963
+ if (isHostObject(value2)) {
964
+ return global._createSerializableHostObject(value2);
965
+ }
966
+ if (isRemoteFunction(value2)) {
967
+ return value2.__remoteFunction;
968
+ }
969
+ if (Array.isArray(value2)) {
970
+ return global._createSerializableArray(value2.map(cloneRecursive));
971
+ }
972
+ if (value2.__synchronizableRef) {
973
+ return global._createSerializableSynchronizable(value2);
974
+ }
975
+ const toAdapt = {};
976
+ for (const [key, element] of Object.entries(value2)) {
977
+ toAdapt[key] = cloneRecursive(element);
978
+ }
979
+ return global._createSerializable(toAdapt, value2);
980
+ }
981
+ if (typeof value2 === "string") {
982
+ return global._createSerializableString(value2);
983
+ }
984
+ if (typeof value2 === "number") {
985
+ return global._createSerializableNumber(value2);
986
+ }
987
+ if (typeof value2 === "boolean") {
988
+ return global._createSerializableBoolean(value2);
989
+ }
990
+ if (typeof value2 === "bigint") {
991
+ return global._createSerializableBigInt(value2);
992
+ }
993
+ if (value2 === void 0) {
994
+ return global._createSerializableUndefined();
995
+ }
996
+ if (value2 === null) {
997
+ return global._createSerializableNull();
998
+ }
999
+ return global._createSerializable(value2, void 0);
1000
+ }
1001
+ return cloneRecursive(value);
1002
+ }
1003
+ var makeShareableCloneOnUIRecursive = globalThis._WORKLETS_BUNDLE_MODE ? createSerializable : makeShareableCloneOnUIRecursiveLEGACY;
1004
+
1005
+ // ../../node_modules/react-native-worklets/lib/module/threads.js
1006
+ var runOnUIQueue = [];
1007
+ function setupMicrotasks() {
1008
+ "worklet";
1009
+ let microtasksQueue = [];
1010
+ let isExecutingMicrotasksQueue = false;
1011
+ global.queueMicrotask = (callback) => {
1012
+ microtasksQueue.push(callback);
1013
+ };
1014
+ global._microtaskQueueFinalizers = [];
1015
+ global.__callMicrotasks = () => {
1016
+ if (isExecutingMicrotasksQueue) {
1017
+ return;
1018
+ }
1019
+ try {
1020
+ isExecutingMicrotasksQueue = true;
1021
+ for (let index = 0; index < microtasksQueue.length; index += 1) {
1022
+ microtasksQueue[index]();
1023
+ }
1024
+ microtasksQueue = [];
1025
+ global._microtaskQueueFinalizers.forEach((finalizer) => finalizer());
1026
+ } finally {
1027
+ isExecutingMicrotasksQueue = false;
1028
+ }
1029
+ };
1030
+ }
1031
+ function callMicrotasksOnUIThread() {
1032
+ "worklet";
1033
+ global.__callMicrotasks();
1034
+ }
1035
+ var callMicrotasks = SHOULD_BE_USE_WEB2 ? () => {
1036
+ } : callMicrotasksOnUIThread;
1037
+ function runOnUI(worklet) {
1038
+ if (__DEV__ && !SHOULD_BE_USE_WEB2 && !isWorkletFunction(worklet) && !worklet.__bundleData) {
1039
+ throw new WorkletsError("`runOnUI` can only be used with worklets.");
1040
+ }
1041
+ return (...args) => {
1042
+ if (IS_JEST2) {
1043
+ WorkletsModule.scheduleOnUI(createSerializable(() => {
1044
+ "worklet";
1045
+ worklet(...args);
1046
+ }));
1047
+ return;
1048
+ }
1049
+ if (__DEV__) {
1050
+ createSerializable(worklet);
1051
+ createSerializable(args);
1052
+ }
1053
+ enqueueUI(worklet, args);
1054
+ };
1055
+ }
1056
+ if (__DEV__) {
1057
+ let runOnUIWorklet = function() {
1058
+ "worklet";
1059
+ throw new WorkletsError("`runOnUI` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.");
1060
+ };
1061
+ const serializableRunOnUIWorklet = createSerializable(runOnUIWorklet);
1062
+ serializableMappingCache.set(runOnUI, serializableRunOnUIWorklet);
1063
+ }
1064
+ function executeOnUIRuntimeSync(worklet) {
1065
+ return (...args) => {
1066
+ return WorkletsModule.executeOnUIRuntimeSync(createSerializable(() => {
1067
+ "worklet";
1068
+ const result = worklet(...args);
1069
+ return makeShareableCloneOnUIRecursive(result);
1070
+ }));
1071
+ };
1072
+ }
1073
+ function runWorkletOnJS(worklet, ...args) {
1074
+ worklet(...args);
1075
+ }
1076
+ function runOnJS(fun) {
1077
+ "worklet";
1078
+ if (SHOULD_BE_USE_WEB2 || globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
1079
+ return (...args) => queueMicrotask(args.length ? () => fun(...args) : fun);
1080
+ }
1081
+ if (isWorkletFunction(fun)) {
1082
+ return (...args) => runOnJS(runWorkletOnJS)(fun, ...args);
1083
+ }
1084
+ if (fun.__remoteFunction) {
1085
+ fun = fun.__remoteFunction;
1086
+ }
1087
+ const scheduleOnJS = typeof fun === "function" ? global._scheduleHostFunctionOnJS : global._scheduleRemoteFunctionOnJS;
1088
+ return (...args) => {
1089
+ scheduleOnJS(fun, args.length > 0 ? makeShareableCloneOnUIRecursive(args) : void 0);
1090
+ };
1091
+ }
1092
+ function runOnUIAsync(worklet) {
1093
+ if (__DEV__ && !SHOULD_BE_USE_WEB2 && !isWorkletFunction(worklet)) {
1094
+ throw new WorkletsError("`runOnUIAsync` can only be used with worklets.");
1095
+ }
1096
+ return (...args) => {
1097
+ return new Promise((resolve) => {
1098
+ if (IS_JEST2) {
1099
+ WorkletsModule.scheduleOnUI(createSerializable(() => {
1100
+ "worklet";
1101
+ worklet(...args);
1102
+ }));
1103
+ return;
1104
+ }
1105
+ if (__DEV__) {
1106
+ createSerializable(worklet);
1107
+ createSerializable(args);
1108
+ }
1109
+ enqueueUI(worklet, args, resolve);
1110
+ });
1111
+ };
1112
+ }
1113
+ if (__DEV__) {
1114
+ let runOnUIAsyncWorklet = function() {
1115
+ "worklet";
1116
+ throw new WorkletsError("`runOnUIAsync` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.");
1117
+ };
1118
+ const serializableRunOnUIAsyncWorklet = createSerializable(runOnUIAsyncWorklet);
1119
+ serializableMappingCache.set(runOnUIAsync, serializableRunOnUIAsyncWorklet);
1120
+ }
1121
+ function enqueueUI(worklet, args, resolve) {
1122
+ const job = [worklet, args, resolve];
1123
+ runOnUIQueue.push(job);
1124
+ if (runOnUIQueue.length === 1) {
1125
+ flushUIQueue();
1126
+ }
1127
+ }
1128
+ function flushUIQueue() {
1129
+ queueMicrotask(() => {
1130
+ const queue = runOnUIQueue;
1131
+ runOnUIQueue = [];
1132
+ WorkletsModule.scheduleOnUI(createSerializable(() => {
1133
+ "worklet";
1134
+ queue.forEach(([workletFunction, workletArgs, jobResolve]) => {
1135
+ const result = workletFunction(...workletArgs);
1136
+ if (jobResolve) {
1137
+ runOnJS(jobResolve)(result);
1138
+ }
1139
+ });
1140
+ callMicrotasks();
1141
+ }));
1142
+ });
1143
+ }
1144
+
1145
+ // ../../node_modules/react-native-worklets/lib/module/runLoop/uiRuntime/requestAnimationFrame.js
1146
+ function setupRequestAnimationFrame() {
1147
+ "worklet";
1148
+ const nativeRequestAnimationFrame = globalThis.requestAnimationFrame;
1149
+ let queuedCallbacks = [];
1150
+ let queuedCallbacksBegin = 0;
1151
+ let queuedCallbacksEnd = 0;
1152
+ let flushedCallbacks = queuedCallbacks;
1153
+ let flushedCallbacksBegin = 0;
1154
+ let flushedCallbacksEnd = 0;
1155
+ let flushRequested = false;
1156
+ globalThis.__flushAnimationFrame = (timestamp) => {
1157
+ flushedCallbacks = queuedCallbacks;
1158
+ queuedCallbacks = [];
1159
+ flushedCallbacksBegin = queuedCallbacksBegin;
1160
+ flushedCallbacksEnd = queuedCallbacksEnd;
1161
+ queuedCallbacksBegin = queuedCallbacksEnd;
1162
+ for (const callback of flushedCallbacks) {
1163
+ callback(timestamp);
1164
+ }
1165
+ flushedCallbacksBegin = flushedCallbacksEnd;
1166
+ callMicrotasks();
1167
+ };
1168
+ globalThis.requestAnimationFrame = (callback) => {
1169
+ const handle = queuedCallbacksEnd++;
1170
+ queuedCallbacks.push(callback);
1171
+ if (!flushRequested) {
1172
+ flushRequested = true;
1173
+ nativeRequestAnimationFrame((timestamp) => {
1174
+ flushRequested = false;
1175
+ globalThis.__frameTimestamp = timestamp;
1176
+ globalThis.__flushAnimationFrame(timestamp);
1177
+ globalThis.__frameTimestamp = void 0;
1178
+ });
1179
+ }
1180
+ return handle;
1181
+ };
1182
+ globalThis.cancelAnimationFrame = (handle) => {
1183
+ if (handle < flushedCallbacksBegin || handle >= queuedCallbacksEnd) {
1184
+ return;
1185
+ }
1186
+ if (handle < flushedCallbacksEnd) {
1187
+ flushedCallbacks[handle - flushedCallbacksBegin] = () => {
1188
+ };
1189
+ } else {
1190
+ queuedCallbacks[handle - queuedCallbacksBegin] = () => {
1191
+ };
1192
+ }
1193
+ };
1194
+ }
1195
+
1196
+ // ../../node_modules/react-native-worklets/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js
1197
+ function setupSetTimeout() {
1198
+ "worklet";
1199
+ const timeoutHandleToRafHandle = /* @__PURE__ */ new Map();
1200
+ const setTimeoutPolyfill = (callback, delay = 0, ...args) => {
1201
+ const start = performance.now();
1202
+ let timeoutHandle = 0;
1203
+ const rafCallback = () => {
1204
+ const now = performance.now();
1205
+ if (now - start >= delay) {
1206
+ callback(...args);
1207
+ timeoutHandleToRafHandle.delete(timeoutHandle);
1208
+ } else {
1209
+ const rafHandle = requestAnimationFrame(rafCallback);
1210
+ timeoutHandleToRafHandle.set(timeoutHandle, rafHandle);
1211
+ }
1212
+ };
1213
+ timeoutHandle = requestAnimationFrame(rafCallback);
1214
+ timeoutHandleToRafHandle.set(timeoutHandle, timeoutHandle);
1215
+ return timeoutHandle;
1216
+ };
1217
+ const clearTimeoutPolyfill = (timeoutHandle) => {
1218
+ const rafHandle = timeoutHandleToRafHandle.get(timeoutHandle);
1219
+ timeoutHandleToRafHandle.delete(timeoutHandle);
1220
+ cancelAnimationFrame(rafHandle);
1221
+ };
1222
+ globalThis.setTimeout = setTimeoutPolyfill;
1223
+ globalThis.clearTimeout = clearTimeoutPolyfill;
1224
+ }
1225
+
1226
+ // ../../node_modules/react-native-worklets/lib/module/synchronizableUnpacker.js
1227
+ function __installUnpacker() {
1228
+ const serializer = !globalThis._WORKLET || globalThis._WORKLETS_BUNDLE_MODE ? (value, _) => createSerializable(value) : globalThis._createSerializable;
1229
+ function synchronizableUnpacker(synchronizableRef) {
1230
+ const synchronizable = synchronizableRef;
1231
+ const proxy = globalThis.__workletsModuleProxy;
1232
+ synchronizable.__synchronizableRef = true;
1233
+ synchronizable.getDirty = () => {
1234
+ return proxy.synchronizableGetDirty(synchronizable);
1235
+ };
1236
+ synchronizable.getBlocking = () => {
1237
+ return proxy.synchronizableGetBlocking(synchronizable);
1238
+ };
1239
+ synchronizable.setBlocking = (valueOrFunction) => {
1240
+ let newValue;
1241
+ if (typeof valueOrFunction === "function") {
1242
+ const func = valueOrFunction;
1243
+ synchronizable.lock();
1244
+ const prev = synchronizable.getBlocking();
1245
+ newValue = func(prev);
1246
+ proxy.synchronizableSetBlocking(synchronizable, serializer(newValue, void 0));
1247
+ synchronizable.unlock();
1248
+ } else {
1249
+ const value = valueOrFunction;
1250
+ newValue = value;
1251
+ proxy.synchronizableSetBlocking(synchronizable, serializer(newValue, void 0));
1252
+ }
1253
+ };
1254
+ synchronizable.lock = () => {
1255
+ proxy.synchronizableLock(synchronizable);
1256
+ };
1257
+ synchronizable.unlock = () => {
1258
+ proxy.synchronizableUnlock(synchronizable);
1259
+ };
1260
+ return synchronizable;
1261
+ }
1262
+ globalThis.__synchronizableUnpacker = synchronizableUnpacker;
1263
+ }
1264
+
1265
+ // ../../node_modules/react-native-worklets/lib/module/initializers.js
1266
+ var capturableConsole;
1267
+ function getMemorySafeCapturableConsole() {
1268
+ if (capturableConsole) {
1269
+ return capturableConsole;
1270
+ }
1271
+ const consoleCopy = Object.fromEntries(Object.entries(console).map(([methodName, method]) => {
1272
+ const methodWrapper = function methodWrapper2(...args) {
1273
+ return method(...args);
1274
+ };
1275
+ if (method.name) {
1276
+ Object.defineProperty(methodWrapper, "name", {
1277
+ value: method.name,
1278
+ writable: false
1279
+ });
1280
+ }
1281
+ return [methodName, methodWrapper];
1282
+ }));
1283
+ capturableConsole = consoleCopy;
1284
+ return consoleCopy;
1285
+ }
1286
+ function setupConsole(boundCapturableConsole) {
1287
+ "worklet";
1288
+ globalThis.console = {
1289
+ assert: runOnJS(boundCapturableConsole.assert),
1290
+ debug: runOnJS(boundCapturableConsole.debug),
1291
+ log: runOnJS(boundCapturableConsole.log),
1292
+ warn: runOnJS(boundCapturableConsole.warn),
1293
+ error: runOnJS(boundCapturableConsole.error),
1294
+ info: runOnJS(boundCapturableConsole.info)
1295
+ };
1296
+ }
1297
+ var initialized = false;
1298
+ function init() {
1299
+ if (initialized) {
1300
+ return;
1301
+ }
1302
+ initialized = true;
1303
+ if (globalThis.__RUNTIME_KIND === void 0) {
1304
+ globalThis.__RUNTIME_KIND = RuntimeKind.ReactNative;
1305
+ }
1306
+ initializeRuntime();
1307
+ if (SHOULD_BE_USE_WEB2) {
1308
+ initializeRuntimeOnWeb();
1309
+ }
1310
+ if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
1311
+ initializeWorkletRuntime();
1312
+ } else {
1313
+ initializeRNRuntime();
1314
+ if (!SHOULD_BE_USE_WEB2) {
1315
+ installRNBindingsOnUIRuntime();
1316
+ }
1317
+ }
1318
+ }
1319
+ function initializeRuntime() {
1320
+ if (globalThis._WORKLETS_BUNDLE_MODE) {
1321
+ globalThis.__valueUnpacker = bundleValueUnpacker;
1322
+ }
1323
+ __installUnpacker();
1324
+ }
1325
+ function initializeRNRuntime() {
1326
+ if (__DEV__) {
1327
+ const testWorklet = () => {
1328
+ "worklet";
1329
+ };
1330
+ if (!isWorkletFunction(testWorklet)) {
1331
+ throw new WorkletsError(`Failed to create a worklet. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#failed-to-create-a-worklet for more details.`);
1332
+ }
1333
+ }
1334
+ registerReportFatalRemoteError();
1335
+ }
1336
+ function initializeWorkletRuntime() {
1337
+ if (globalThis._WORKLETS_BUNDLE_MODE) {
1338
+ setupCallGuard();
1339
+ if (__DEV__) {
1340
+ const Refresh = new Proxy({}, {
1341
+ get() {
1342
+ return () => {
1343
+ };
1344
+ }
1345
+ });
1346
+ globalThis.__r.Refresh = Refresh;
1347
+ const modules = __require.getModules();
1348
+ const ReactNativeModuleId = __require.resolveWeak("react-native");
1349
+ const factory = function(_global, _require, _importDefault, _importAll, module, _exports, _dependencyMap) {
1350
+ module.exports = new Proxy({}, {
1351
+ get: function get(_target, prop) {
1352
+ globalThis.console.warn(`You tried to import '${String(prop)}' from 'react-native' module on a Worklet Runtime. Using 'react-native' module on a Worklet Runtime is not allowed.`);
1353
+ return {
1354
+ get() {
1355
+ return void 0;
1356
+ }
1357
+ };
1358
+ }
1359
+ });
1360
+ };
1361
+ const mod = {
1362
+ dependencyMap: [],
1363
+ factory,
1364
+ hasError: false,
1365
+ importedAll: {},
1366
+ importedDefault: {},
1367
+ isInitialized: false,
1368
+ publicModule: {
1369
+ exports: {}
1370
+ }
1371
+ };
1372
+ modules.set(ReactNativeModuleId, mod);
1373
+ }
1374
+ }
1375
+ }
1376
+ function initializeRuntimeOnWeb() {
1377
+ globalThis._WORKLET = false;
1378
+ globalThis._log = console.log;
1379
+ globalThis._getAnimationTimestamp = () => performance.now();
1380
+ if (IS_JEST2) {
1381
+ globalThis.requestAnimationFrame = mockedRequestAnimationFrame;
1382
+ }
1383
+ }
1384
+ function installRNBindingsOnUIRuntime() {
1385
+ if (!WorkletsModule) {
1386
+ throw new WorkletsError("Worklets are trying to initialize the UI runtime without a valid WorkletsModule");
1387
+ }
1388
+ const runtimeBoundCapturableConsole = getMemorySafeCapturableConsole();
1389
+ if (!globalThis._WORKLETS_BUNDLE_MODE) {
1390
+ executeOnUIRuntimeSync(setupCallGuard)();
1391
+ executeOnUIRuntimeSync(registerWorkletsError)();
1392
+ }
1393
+ executeOnUIRuntimeSync(() => {
1394
+ "worklet";
1395
+ setupConsole(runtimeBoundCapturableConsole);
1396
+ setupMicrotasks();
1397
+ setupRequestAnimationFrame();
1398
+ setupSetTimeout();
1399
+ setupSetImmediate();
1400
+ setupSetInterval();
1401
+ })();
1402
+ }
1403
+
1404
+ // ../../node_modules/react-native-worklets/lib/module/workletRuntimeEntry.js
1405
+ function bundleModeInit() {
1406
+ if (SHOULD_BE_USE_WEB2) {
1407
+ return;
1408
+ }
1409
+ globalThis._WORKLETS_BUNDLE_MODE = true;
1410
+ const runtimeKind = globalThis.__RUNTIME_KIND;
1411
+ if (runtimeKind && runtimeKind !== RuntimeKind.ReactNative) {
1412
+ init();
1413
+ throw new WorkletsError("Worklets initialized successfully");
1414
+ }
1415
+ }
1416
+ bundleModeInit();
1417
+
1418
+ // ../../node_modules/react-native-worklets/lib/module/featureFlags/index.js
1419
+ var DynamicFlags = {
1420
+ EXAMPLE_DYNAMIC_FLAG: true,
1421
+ init() {
1422
+ Object.keys(DynamicFlags).forEach((key) => {
1423
+ if (key !== "init" && key !== "setFlag") {
1424
+ WorkletsModule.setDynamicFeatureFlag(key, DynamicFlags[key]);
1425
+ }
1426
+ });
1427
+ },
1428
+ setFlag(name, value) {
1429
+ if (name in DynamicFlags) {
1430
+ DynamicFlags[name] = value;
1431
+ WorkletsModule.setDynamicFeatureFlag(name, value);
1432
+ } else {
1433
+ logger.warn(`The feature flag: '${name}' no longer exists, you can safely remove invocation of \`setDynamicFeatureFlag('${name}')\` from your code.`);
1434
+ }
1435
+ }
1436
+ };
1437
+ DynamicFlags.init();
1438
+
1439
+ // ../../node_modules/react-native-worklets/lib/module/index.js
1440
+ init();
1441
+ if (globalThis._ALWAYS_FALSE) {
1442
+ bundleModeInit();
1443
+ }
1444
+
1445
+ // src/transitions/easing.ts
55
1446
  function ensureWorkletEasing(easing) {
56
1447
  if (!easing) return void 0;
57
1448
  if (isWorkletFunction(easing)) return easing;
@@ -62,13 +1453,12 @@ function ensureWorkletEasing(easing) {
62
1453
  return wrapped;
63
1454
  }
64
1455
 
65
- // src/transitions/resolve.ts
1456
+ // src/transitions/spring.ts
66
1457
  var DEFAULT_SPRING = {
67
1458
  tension: 170,
68
1459
  friction: 26,
69
1460
  mass: 1
70
1461
  };
71
- var DEFAULT_TIMING_DURATION = 250;
72
1462
  function springToReanimated(t) {
73
1463
  return {
74
1464
  stiffness: t.tension ?? DEFAULT_SPRING.tension,
@@ -79,6 +1469,33 @@ function springToReanimated(t) {
79
1469
  restDisplacementThreshold: t.restDisplacementThreshold
80
1470
  };
81
1471
  }
1472
+
1473
+ // src/layout/resolveLayout.ts
1474
+ function resolveLayoutTransition(layout) {
1475
+ if (!layout) return void 0;
1476
+ const cfg = layout === true ? { type: "spring" } : layout;
1477
+ if (cfg.type === "no-animation") return void 0;
1478
+ if (cfg.type === "timing") {
1479
+ let builder2 = LinearTransition.duration(cfg.duration ?? 300);
1480
+ const easing = ensureWorkletEasing(cfg.easing);
1481
+ if (easing) builder2 = builder2.easing(easing);
1482
+ if (cfg.delay) builder2 = builder2.delay(cfg.delay);
1483
+ return builder2;
1484
+ }
1485
+ const spring = cfg.type === "decay" ? { type: "spring" } : cfg;
1486
+ const { stiffness, damping, mass } = springToReanimated({
1487
+ ...DEFAULT_SPRING,
1488
+ ...spring
1489
+ });
1490
+ let builder = LinearTransition.springify().stiffness(stiffness).damping(damping).mass(mass);
1491
+ if ("delay" in spring && spring.delay) builder = builder.delay(spring.delay);
1492
+ return builder;
1493
+ }
1494
+ var PresenceContext = createContext(null);
1495
+ function usePresence() {
1496
+ return useContext(PresenceContext);
1497
+ }
1498
+ var DEFAULT_TIMING_DURATION = 250;
82
1499
  function buildSpring(cfg, toValue, cb) {
83
1500
  return withSpring(toValue, springToReanimated(cfg), cb);
84
1501
  }
@@ -184,6 +1601,51 @@ function mergeTransition(base, override) {
184
1601
  return { ...base ?? { type: "spring" }, ...override };
185
1602
  }
186
1603
 
1604
+ // src/transitions/keys.ts
1605
+ var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
1606
+ "type",
1607
+ "tension",
1608
+ "friction",
1609
+ "mass",
1610
+ "velocity",
1611
+ "restSpeedThreshold",
1612
+ "restDisplacementThreshold",
1613
+ "duration",
1614
+ "easing",
1615
+ "delay",
1616
+ "repeat",
1617
+ "deceleration",
1618
+ "clamp"
1619
+ ]);
1620
+ function isTopLevelTransition(t) {
1621
+ if (t === null || typeof t !== "object") return false;
1622
+ const keys = Object.keys(t);
1623
+ if (keys.length === 0) return false;
1624
+ return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
1625
+ }
1626
+
1627
+ // src/transitions/sig.ts
1628
+ function stableSig(value) {
1629
+ if (value === void 0) return "";
1630
+ try {
1631
+ return stableStringify(value);
1632
+ } catch {
1633
+ return String(value);
1634
+ }
1635
+ }
1636
+ function stableStringify(v) {
1637
+ if (v === null || typeof v !== "object") {
1638
+ if (typeof v === "function" || v === void 0) return "null";
1639
+ return JSON.stringify(v);
1640
+ }
1641
+ if (Array.isArray(v)) {
1642
+ return "[" + v.map(stableStringify).join(",") + "]";
1643
+ }
1644
+ const obj = v;
1645
+ const keys = Object.keys(obj).sort();
1646
+ return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
1647
+ }
1648
+
187
1649
  // src/motion/installCheck.ts
188
1650
  var alreadyChecked = false;
189
1651
  function ensureReanimatedInstalled() {
@@ -223,8 +1685,11 @@ var TRANSFORM_KEYS = [
223
1685
  "scale",
224
1686
  "scaleX",
225
1687
  "scaleY",
226
- "rotate"
1688
+ "rotate",
1689
+ "rotateX",
1690
+ "rotateY"
227
1691
  ];
1692
+ var ROTATION_KEYS = /* @__PURE__ */ new Set(["rotate", "rotateX", "rotateY"]);
228
1693
  var NUMERIC_TOP_LEVEL_KEYS = [
229
1694
  "opacity",
230
1695
  "width",
@@ -259,6 +1724,8 @@ var DEFAULT_RESTING = {
259
1724
  scaleX: 1,
260
1725
  scaleY: 1,
261
1726
  rotate: 0,
1727
+ rotateX: 0,
1728
+ rotateY: 0,
262
1729
  opacity: 1,
263
1730
  width: 0,
264
1731
  height: 0,
@@ -272,27 +1739,6 @@ var DEFAULT_RESTING = {
272
1739
  color: "transparent",
273
1740
  tintColor: "transparent"
274
1741
  };
275
- var TRANSITION_KEYS = /* @__PURE__ */ new Set([
276
- "type",
277
- "tension",
278
- "friction",
279
- "mass",
280
- "velocity",
281
- "restSpeedThreshold",
282
- "restDisplacementThreshold",
283
- "duration",
284
- "easing",
285
- "delay",
286
- "repeat",
287
- "deceleration",
288
- "clamp"
289
- ]);
290
- function isTopLevelTransition(t) {
291
- if (t === null || typeof t !== "object") return false;
292
- const keys = Object.keys(t);
293
- if (keys.length === 0) return false;
294
- return keys.every((k) => TRANSITION_KEYS.has(k));
295
- }
296
1742
  function transitionFor(prop, transition) {
297
1743
  if (!transition) return void 0;
298
1744
  if (isTopLevelTransition(transition)) return transition;
@@ -319,6 +1765,7 @@ function createMotionComponent(Component) {
319
1765
  variants,
320
1766
  controller,
321
1767
  gesture,
1768
+ layout,
322
1769
  onAnimationEnd,
323
1770
  style,
324
1771
  ...rest
@@ -522,7 +1969,7 @@ function createMotionComponent(Component) {
522
1969
  }
523
1970
  if (TRANSFORM_KEY_SET.has(key)) {
524
1971
  transform.push(
525
- key === "rotate" ? { rotate: `${v}deg` } : { [key]: v }
1972
+ ROTATION_KEYS.has(key) ? { [key]: `${v}deg` } : { [key]: v }
526
1973
  );
527
1974
  } else {
528
1975
  out[key] = v;
@@ -543,12 +1990,19 @@ function createMotionComponent(Component) {
543
1990
  setFocusVisible,
544
1991
  setHovered
545
1992
  );
1993
+ const layoutSig = stableSig(layout);
1994
+ const layoutTransition = useMemo(
1995
+ () => shouldReduceMotion ? void 0 : resolveLayoutTransition(layout),
1996
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1997
+ [layoutSig, shouldReduceMotion]
1998
+ );
546
1999
  return /* @__PURE__ */ jsx(
547
2000
  AnimatedComponent,
548
2001
  {
549
2002
  ref,
550
2003
  ...rest,
551
2004
  ...gestureHandlers,
2005
+ layout: layoutTransition,
552
2006
  style: mergedStyle
553
2007
  }
554
2008
  );
@@ -556,23 +2010,25 @@ function createMotionComponent(Component) {
556
2010
  Motion.displayName = `Motion(${Component.displayName ?? Component.name ?? "Component"})`;
557
2011
  return Motion;
558
2012
  }
559
- function useAnimatableSharedValues(init) {
560
- const translateX = useSharedValue(init("translateX"));
561
- const translateY = useSharedValue(init("translateY"));
562
- const scale = useSharedValue(init("scale"));
563
- const scaleX = useSharedValue(init("scaleX"));
564
- const scaleY = useSharedValue(init("scaleY"));
565
- const rotate = useSharedValue(init("rotate"));
566
- const opacity = useSharedValue(init("opacity"));
567
- const width = useSharedValue(init("width"));
568
- const height = useSharedValue(init("height"));
569
- const borderRadius = useSharedValue(init("borderRadius"));
2013
+ function useAnimatableSharedValues(init2) {
2014
+ const translateX = useSharedValue(init2("translateX"));
2015
+ const translateY = useSharedValue(init2("translateY"));
2016
+ const scale = useSharedValue(init2("scale"));
2017
+ const scaleX = useSharedValue(init2("scaleX"));
2018
+ const scaleY = useSharedValue(init2("scaleY"));
2019
+ const rotate = useSharedValue(init2("rotate"));
2020
+ const rotateX = useSharedValue(init2("rotateX"));
2021
+ const rotateY = useSharedValue(init2("rotateY"));
2022
+ const opacity = useSharedValue(init2("opacity"));
2023
+ const width = useSharedValue(init2("width"));
2024
+ const height = useSharedValue(init2("height"));
2025
+ const borderRadius = useSharedValue(init2("borderRadius"));
570
2026
  const backgroundColor = useSharedValue(
571
- init("backgroundColor")
2027
+ init2("backgroundColor")
572
2028
  );
573
- const borderColor = useSharedValue(init("borderColor"));
574
- const color = useSharedValue(init("color"));
575
- const tintColor = useSharedValue(init("tintColor"));
2029
+ const borderColor = useSharedValue(init2("borderColor"));
2030
+ const color = useSharedValue(init2("color"));
2031
+ const tintColor = useSharedValue(init2("tintColor"));
576
2032
  const ref = useRef(null);
577
2033
  if (ref.current === null) {
578
2034
  ref.current = {
@@ -582,6 +2038,8 @@ function useAnimatableSharedValues(init) {
582
2038
  scaleX,
583
2039
  scaleY,
584
2040
  rotate,
2041
+ rotateX,
2042
+ rotateY,
585
2043
  opacity,
586
2044
  width,
587
2045
  height,
@@ -652,7 +2110,7 @@ function makeKeyCallbackFactory(key, sharedValue, target, onAnimationEndRef, met
652
2110
  return (rawPhase, step) => {
653
2111
  const cb = (finished) => {
654
2112
  "worklet";
655
- runOnJS(dispatch)(rawPhase, step, !!finished, sharedValue.value);
2113
+ runOnJS$1(dispatch)(rawPhase, step, !!finished, sharedValue.value);
656
2114
  };
657
2115
  return cb;
658
2116
  };
@@ -718,26 +2176,6 @@ function restValue(v) {
718
2176
  }
719
2177
  return void 0;
720
2178
  }
721
- function stableSig(value) {
722
- if (value === void 0) return "";
723
- try {
724
- return stableStringify(value);
725
- } catch {
726
- return String(value);
727
- }
728
- }
729
- function stableStringify(v) {
730
- if (v === null || typeof v !== "object") {
731
- if (typeof v === "function" || v === void 0) return "null";
732
- return JSON.stringify(v);
733
- }
734
- if (Array.isArray(v)) {
735
- return "[" + v.map(stableStringify).join(",") + "]";
736
- }
737
- const obj = v;
738
- const keys = Object.keys(obj).sort();
739
- return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
740
- }
741
2179
  function resolveGestureLayers(gesture) {
742
2180
  if (!gesture) return null;
743
2181
  const out = {};