@onlynative/inertia 0.0.1-alpha.7 → 0.0.1-alpha.9
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/README.md +1 -1
- package/dist/gestureLayer/index.d.mts +119 -0
- package/dist/gestureLayer/index.d.ts +119 -0
- package/dist/gestureLayer/index.js +346 -0
- package/dist/gestureLayer/index.js.map +1 -0
- package/dist/gestureLayer/index.mjs +344 -0
- package/dist/gestureLayer/index.mjs.map +1 -0
- package/dist/index.d.mts +114 -74
- package/dist/index.d.ts +114 -74
- package/dist/index.js +388 -1542
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +388 -1545
- package/dist/index.mjs.map +1 -1
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +244 -1462
- package/dist/motion/Image.js.map +1 -1
- package/dist/motion/Image.mjs +247 -1465
- package/dist/motion/Image.mjs.map +1 -1
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +244 -1462
- package/dist/motion/Pressable.js.map +1 -1
- package/dist/motion/Pressable.mjs +247 -1465
- package/dist/motion/Pressable.mjs.map +1 -1
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +244 -1462
- package/dist/motion/ScrollView.js.map +1 -1
- package/dist/motion/ScrollView.mjs +247 -1465
- package/dist/motion/ScrollView.mjs.map +1 -1
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +244 -1462
- package/dist/motion/Text.js.map +1 -1
- package/dist/motion/Text.mjs +247 -1465
- package/dist/motion/Text.mjs.map +1 -1
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +244 -1462
- package/dist/motion/View.js.map +1 -1
- package/dist/motion/View.mjs +247 -1465
- package/dist/motion/View.mjs.map +1 -1
- package/dist/touch/index.d.mts +146 -0
- package/dist/touch/index.d.ts +146 -0
- package/dist/touch/index.js +166 -0
- package/dist/touch/index.js.map +1 -0
- package/dist/touch/index.mjs +164 -0
- package/dist/touch/index.mjs.map +1 -0
- package/dist/{types-NmNeJjo1.d.mts → types-cU43dEmH.d.mts} +64 -17
- package/dist/{types-NmNeJjo1.d.ts → types-cU43dEmH.d.ts} +64 -17
- package/dist/useGesture-B7A_1DVg.d.ts +84 -0
- package/dist/useGesture-cimMrzC1.d.mts +84 -0
- package/jest-setup.js +4 -0
- package/llms.txt +12 -3
- package/package.json +22 -2
- package/src/__type-tests__/variants.test-d.tsx +67 -0
- package/src/gestureLayer/index.ts +21 -0
- package/src/gestureLayer/useGestureLayer.ts +285 -0
- package/src/index.ts +7 -0
- package/src/layout/index.ts +15 -0
- package/src/layout/sharedRegistry.ts +111 -0
- package/src/layout/useSharedLayout.ts +289 -0
- package/src/motion/createMotionComponent.tsx +123 -37
- package/src/motion/installCheck.ts +7 -11
- package/src/touch/index.ts +18 -0
- package/src/touch/useTouchDrag.ts +289 -0
- package/src/types.ts +79 -20
- package/src/values/index.ts +11 -0
- package/src/values/useBooleanSpring.ts +33 -0
- package/src/values/useColorTransition.ts +72 -0
- package/src/values/useShadow.ts +116 -0
package/dist/index.js
CHANGED
|
@@ -4,1465 +4,66 @@ var reactNative = require('react-native');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var Animated = require('react-native-reanimated');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var reactNativeWorklets = require('react-native-worklets');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
10
11
|
var Animated__default = /*#__PURE__*/_interopDefault(Animated);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
22
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
23
|
-
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);
|
|
24
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
25
|
-
var DEFAULT_MOTION_CONFIG = {
|
|
26
|
-
reducedMotion: "user"
|
|
27
|
-
};
|
|
28
|
-
var MotionConfigContext = react.createContext(
|
|
29
|
-
DEFAULT_MOTION_CONFIG
|
|
30
|
-
);
|
|
31
|
-
function useMotionConfig() {
|
|
32
|
-
return react.useContext(MotionConfigContext);
|
|
33
|
-
}
|
|
34
|
-
function useShouldReduceMotion() {
|
|
35
|
-
const { reducedMotion } = useMotionConfig();
|
|
36
|
-
const osReduced = Animated.useReducedMotion();
|
|
37
|
-
if (reducedMotion === "never") return false;
|
|
38
|
-
if (reducedMotion === "always") return true;
|
|
39
|
-
return osReduced;
|
|
40
|
-
}
|
|
41
|
-
function MotionConfig({
|
|
42
|
-
reducedMotion = "user",
|
|
43
|
-
children
|
|
44
|
-
}) {
|
|
45
|
-
const value = react.useMemo(
|
|
46
|
-
() => ({ reducedMotion }),
|
|
47
|
-
[reducedMotion]
|
|
48
|
-
);
|
|
49
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MotionConfigContext.Provider, { value, children });
|
|
50
|
-
}
|
|
51
|
-
var modality = "keyboard";
|
|
52
|
-
var installed = false;
|
|
53
|
-
function setKeyboard() {
|
|
54
|
-
modality = "keyboard";
|
|
55
|
-
}
|
|
56
|
-
function setPointer() {
|
|
57
|
-
modality = "pointer";
|
|
58
|
-
}
|
|
59
|
-
function ensureInstalled() {
|
|
60
|
-
if (installed) return;
|
|
61
|
-
if (reactNative.Platform.OS !== "web") return;
|
|
62
|
-
if (typeof document === "undefined") return;
|
|
63
|
-
document.addEventListener("keydown", setKeyboard, true);
|
|
64
|
-
document.addEventListener("mousedown", setPointer, true);
|
|
65
|
-
document.addEventListener("pointerdown", setPointer, true);
|
|
66
|
-
document.addEventListener("touchstart", setPointer, true);
|
|
67
|
-
installed = true;
|
|
68
|
-
}
|
|
69
|
-
function isFocusVisible() {
|
|
70
|
-
if (reactNative.Platform.OS !== "web") return true;
|
|
71
|
-
ensureInstalled();
|
|
72
|
-
return modality === "keyboard";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ../../node_modules/react-native-worklets/lib/module/logger.js
|
|
76
|
-
var PREFIX = "[Worklets]";
|
|
77
|
-
function formatMessage(message) {
|
|
78
|
-
return `${PREFIX} ${message}`;
|
|
79
|
-
}
|
|
80
|
-
var logger = {
|
|
81
|
-
warn(message) {
|
|
82
|
-
console.warn(formatMessage(message));
|
|
83
|
-
},
|
|
84
|
-
error(message) {
|
|
85
|
-
console.error(formatMessage(message));
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// ../../node_modules/react-native-worklets/lib/module/runtimeKind.js
|
|
90
|
-
var RuntimeKind = /* @__PURE__ */ (function(RuntimeKind2) {
|
|
91
|
-
RuntimeKind2[RuntimeKind2["ReactNative"] = 1] = "ReactNative";
|
|
92
|
-
RuntimeKind2[RuntimeKind2["UI"] = 2] = "UI";
|
|
93
|
-
RuntimeKind2[RuntimeKind2["Worker"] = 3] = "Worker";
|
|
94
|
-
return RuntimeKind2;
|
|
95
|
-
})({});
|
|
96
|
-
if (globalThis.__RUNTIME_KIND === void 0) {
|
|
97
|
-
globalThis.__RUNTIME_KIND = RuntimeKind.ReactNative;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ../../node_modules/react-native-worklets/lib/module/WorkletsError.js
|
|
101
|
-
function WorkletsErrorConstructor(message) {
|
|
102
|
-
"worklet";
|
|
103
|
-
const prefix = "[Worklets]";
|
|
104
|
-
const errorInstance = new Error(message ? `${prefix} ${message}` : prefix);
|
|
105
|
-
errorInstance.name = `WorkletsError`;
|
|
106
|
-
return errorInstance;
|
|
107
|
-
}
|
|
108
|
-
function registerWorkletsError() {
|
|
109
|
-
"worklet";
|
|
110
|
-
if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
|
|
111
|
-
globalThis.WorkletsError = WorkletsErrorConstructor;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
var WorkletsError = WorkletsErrorConstructor;
|
|
115
|
-
|
|
116
|
-
// ../../node_modules/react-native-worklets/lib/module/bundleUnpacker.js
|
|
117
|
-
var handleCache = /* @__PURE__ */ new WeakMap();
|
|
118
|
-
function bundleValueUnpacker(objectToUnpack, category, remoteFunctionName) {
|
|
119
|
-
const workletHash = objectToUnpack.__workletHash;
|
|
120
|
-
if (workletHash !== void 0) {
|
|
121
|
-
return getWorklet(workletHash, objectToUnpack.__closure);
|
|
122
|
-
} else if (objectToUnpack.__init !== void 0) {
|
|
123
|
-
let value = handleCache.get(objectToUnpack);
|
|
124
|
-
if (value === void 0) {
|
|
125
|
-
value = objectToUnpack.__init();
|
|
126
|
-
handleCache.set(objectToUnpack, value);
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
} else if (category === "RemoteFunction") {
|
|
130
|
-
const remoteFunctionHolder = () => {
|
|
131
|
-
const label = remoteFunctionName ? `function \`${remoteFunctionName}\`` : "anonymous function";
|
|
132
|
-
throw new WorkletsError(`Tried to synchronously call a non-worklet ${label} on the UI thread.
|
|
133
|
-
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.`);
|
|
134
|
-
};
|
|
135
|
-
remoteFunctionHolder.__remoteFunction = objectToUnpack;
|
|
136
|
-
return remoteFunctionHolder;
|
|
137
|
-
} else {
|
|
138
|
-
throw new WorkletsError(`Data type in category "${category}" not recognized by value unpacker: "${globalThis._toString(objectToUnpack)}".`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function getWorklet(workletHash, closureVariables) {
|
|
142
|
-
let worklet;
|
|
143
|
-
if (__DEV__) {
|
|
144
|
-
try {
|
|
145
|
-
worklet = getWorkletFromMetroRequire(workletHash, closureVariables);
|
|
146
|
-
} catch (_e) {
|
|
147
|
-
logger.error("Unable to resolve worklet with hash " + workletHash + ". Try reloading the app.");
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
worklet = getWorkletFromMetroRequire(workletHash, closureVariables);
|
|
151
|
-
}
|
|
152
|
-
return worklet;
|
|
153
|
-
}
|
|
154
|
-
var metroRequire = globalThis.__r;
|
|
155
|
-
function getWorkletFromMetroRequire(workletHash, closureVariables) {
|
|
156
|
-
const factory = metroRequire(workletHash).default;
|
|
157
|
-
return factory(closureVariables);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// ../../node_modules/react-native-worklets/lib/module/callGuard.js
|
|
161
|
-
function callGuardDEV(fn, ...args) {
|
|
162
|
-
"worklet";
|
|
163
|
-
try {
|
|
164
|
-
return fn(...args);
|
|
165
|
-
} catch (error) {
|
|
166
|
-
if (globalThis.__workletsModuleProxy) {
|
|
167
|
-
const {
|
|
168
|
-
message,
|
|
169
|
-
stack,
|
|
170
|
-
name,
|
|
171
|
-
jsEngine
|
|
172
|
-
} = error;
|
|
173
|
-
globalThis.__workletsModuleProxy.reportFatalErrorOnJS(message, stack ?? "", name ?? "WorkletsError", jsEngine ?? "Worklets");
|
|
174
|
-
} else {
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function setupCallGuard() {
|
|
180
|
-
"worklet";
|
|
181
|
-
if (!globalThis.__callGuardDEV) {
|
|
182
|
-
globalThis.__callGuardDEV = callGuardDEV;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// ../../node_modules/react-native-worklets/lib/module/errors.js
|
|
187
|
-
var _workletStackDetails = /* @__PURE__ */ new Map();
|
|
188
|
-
function registerWorkletStackDetails(hash, stackDetails) {
|
|
189
|
-
_workletStackDetails.set(hash, stackDetails);
|
|
190
|
-
}
|
|
191
|
-
function getBundleOffset(error) {
|
|
192
|
-
const frame = error.stack?.split("\n")?.[0];
|
|
193
|
-
if (frame) {
|
|
194
|
-
const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
|
|
195
|
-
if (parsedFrame) {
|
|
196
|
-
const [, file, line, col] = parsedFrame;
|
|
197
|
-
return [file, Number(line), Number(col)];
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return ["unknown", 0, 0];
|
|
201
|
-
}
|
|
202
|
-
function processStack(stack) {
|
|
203
|
-
if (stack === "" || stack === void 0) {
|
|
204
|
-
return void 0;
|
|
205
|
-
}
|
|
206
|
-
const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
|
|
207
|
-
let result = stack;
|
|
208
|
-
workletStackEntries?.forEach((match) => {
|
|
209
|
-
const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
|
|
210
|
-
const errorDetails = _workletStackDetails.get(hash);
|
|
211
|
-
if (!errorDetails) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const [error, lineOffset, colOffset] = errorDetails;
|
|
215
|
-
const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
|
|
216
|
-
const line = origLine + bundleLine + lineOffset;
|
|
217
|
-
const col = origCol + bundleCol + colOffset;
|
|
218
|
-
result = result.replace(match, `${bundleFile}:${line}:${col}`);
|
|
219
|
-
});
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
function reportFatalRemoteError({
|
|
223
|
-
message,
|
|
224
|
-
stack,
|
|
225
|
-
name,
|
|
226
|
-
jsEngine
|
|
227
|
-
}, force) {
|
|
228
|
-
const error = new WorkletsError();
|
|
229
|
-
error.message = message;
|
|
230
|
-
error.stack = processStack(stack);
|
|
231
|
-
error.name = name;
|
|
232
|
-
error.jsEngine = jsEngine;
|
|
233
|
-
if (force) {
|
|
234
|
-
throw error;
|
|
235
|
-
} else {
|
|
236
|
-
globalThis.ErrorUtils.reportFatalError(error);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
function registerReportFatalRemoteError() {
|
|
240
|
-
globalThis.__reportFatalRemoteError = reportFatalRemoteError;
|
|
241
|
-
}
|
|
242
|
-
var IS_JEST = !!process.env.JEST_WORKER_ID;
|
|
243
|
-
var IS_WEB = reactNative.Platform.OS === "web";
|
|
244
|
-
var IS_WINDOWS = reactNative.Platform.OS === "windows";
|
|
245
|
-
var SHOULD_BE_USE_WEB = IS_JEST || IS_WEB || IS_WINDOWS;
|
|
246
|
-
|
|
247
|
-
// ../../node_modules/react-native-worklets/lib/module/PlatformChecker/index.js
|
|
248
|
-
var IS_JEST2 = false;
|
|
249
|
-
var SHOULD_BE_USE_WEB2 = false;
|
|
250
|
-
if (globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
|
|
251
|
-
IS_JEST2 = IS_JEST;
|
|
252
|
-
SHOULD_BE_USE_WEB2 = SHOULD_BE_USE_WEB;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ../../node_modules/react-native-worklets/lib/module/runLoop/common/setImmediatePolyfill.js
|
|
256
|
-
function setupSetImmediate() {
|
|
257
|
-
"worklet";
|
|
258
|
-
const setImmediatePolyfill = (callback, ...args) => {
|
|
259
|
-
return setTimeout(callback, 0, ...args);
|
|
260
|
-
};
|
|
261
|
-
const clearImmediatePolyfill = (immediateHandle) => {
|
|
262
|
-
clearTimeout(immediateHandle);
|
|
263
|
-
};
|
|
264
|
-
globalThis.setImmediate = setImmediatePolyfill;
|
|
265
|
-
globalThis.clearImmediate = clearImmediatePolyfill;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// ../../node_modules/react-native-worklets/lib/module/runLoop/common/setIntervalPolyfill.js
|
|
269
|
-
function setupSetInterval() {
|
|
270
|
-
"worklet";
|
|
271
|
-
const intervalHandleToTimeoutHandle = /* @__PURE__ */ new Map();
|
|
272
|
-
const setIntervalPolyfill = (callback, delay = 0, ...args) => {
|
|
273
|
-
let intervalHandle = 0;
|
|
274
|
-
const repeatingCallback = () => {
|
|
275
|
-
const timeoutHandle = setTimeout(repeatingCallback, delay);
|
|
276
|
-
intervalHandleToTimeoutHandle.set(intervalHandle, timeoutHandle);
|
|
277
|
-
callback(...args);
|
|
278
|
-
};
|
|
279
|
-
intervalHandle = setTimeout(repeatingCallback, delay);
|
|
280
|
-
intervalHandleToTimeoutHandle.set(intervalHandle, intervalHandle);
|
|
281
|
-
return intervalHandle;
|
|
282
|
-
};
|
|
283
|
-
const clearIntervalPolyfill = (intervalHandle) => {
|
|
284
|
-
const timeoutHandle = intervalHandleToTimeoutHandle.get(intervalHandle);
|
|
285
|
-
clearTimeout(timeoutHandle);
|
|
286
|
-
intervalHandleToTimeoutHandle.delete(intervalHandle);
|
|
287
|
-
};
|
|
288
|
-
globalThis.setInterval = setIntervalPolyfill;
|
|
289
|
-
globalThis.clearInterval = clearIntervalPolyfill;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// ../../node_modules/react-native-worklets/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js
|
|
293
|
-
function mockedRequestAnimationFrame(callback) {
|
|
294
|
-
return setTimeout(() => callback(performance.now()), 0);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// ../../node_modules/react-native-worklets/lib/module/isSynchronizable.js
|
|
298
|
-
function isSynchronizable(value) {
|
|
299
|
-
return typeof value === "object" && value !== null && "__synchronizableRef" in value && value.__synchronizableRef === true;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// ../../node_modules/react-native-worklets/lib/module/serializableMappingCache.js
|
|
303
|
-
var serializableMappingFlag = /* @__PURE__ */ Symbol("serializable flag");
|
|
304
|
-
var cache = SHOULD_BE_USE_WEB2 ? null : /* @__PURE__ */ new WeakMap();
|
|
305
|
-
var serializableMappingCache = SHOULD_BE_USE_WEB2 ? {
|
|
306
|
-
set() {
|
|
307
|
-
},
|
|
308
|
-
get() {
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
} : {
|
|
312
|
-
set(serializable, serializableRef) {
|
|
313
|
-
cache.set(serializable, serializableRef || serializableMappingFlag);
|
|
314
|
-
},
|
|
315
|
-
get: cache.get.bind(cache)
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
// ../../node_modules/react-native-worklets/lib/module/utils/jsVersion.js
|
|
319
|
-
var jsVersion = "0.5.1";
|
|
320
|
-
|
|
321
|
-
// ../../node_modules/react-native-worklets/lib/module/workletFunction.js
|
|
322
|
-
function isWorkletFunction(value) {
|
|
323
|
-
"worklet";
|
|
324
|
-
return (
|
|
325
|
-
// `__workletHash` isn't extracted in Worklet Runtimes.
|
|
326
|
-
typeof value === "function" && !!value.__workletHash
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ../../node_modules/react-native-worklets/lib/module/WorkletsModule/JSWorklets.js
|
|
331
|
-
function createJSWorkletsModule() {
|
|
332
|
-
return new JSWorklets();
|
|
333
|
-
}
|
|
334
|
-
var requestAnimationFrameImpl = IS_JEST2 || !globalThis.requestAnimationFrame ? mockedRequestAnimationFrame : globalThis.requestAnimationFrame;
|
|
335
|
-
var JSWorklets = class {
|
|
336
|
-
createSerializable() {
|
|
337
|
-
throw new WorkletsError("createSerializable should never be called in JSWorklets.");
|
|
338
|
-
}
|
|
339
|
-
createSerializableString() {
|
|
340
|
-
throw new WorkletsError("createSerializableString should never be called in JSWorklets.");
|
|
341
|
-
}
|
|
342
|
-
createSerializableNumber() {
|
|
343
|
-
throw new WorkletsError("createSerializableNumber should never be called in JSWorklets.");
|
|
344
|
-
}
|
|
345
|
-
createSerializableBoolean() {
|
|
346
|
-
throw new WorkletsError("createSerializableBoolean should never be called in JSWorklets.");
|
|
347
|
-
}
|
|
348
|
-
createSerializableBigInt() {
|
|
349
|
-
throw new WorkletsError("createSerializableBigInt should never be called in JSWorklets.");
|
|
350
|
-
}
|
|
351
|
-
createSerializableUndefined() {
|
|
352
|
-
throw new WorkletsError("createSerializableUndefined should never be called in JSWorklets.");
|
|
353
|
-
}
|
|
354
|
-
createSerializableNull() {
|
|
355
|
-
throw new WorkletsError("createSerializableNull should never be called in JSWorklets.");
|
|
356
|
-
}
|
|
357
|
-
createSerializableTurboModuleLike() {
|
|
358
|
-
throw new WorkletsError("createSerializableTurboModuleLike should never be called in JSWorklets.");
|
|
359
|
-
}
|
|
360
|
-
createSerializableObject() {
|
|
361
|
-
throw new WorkletsError("createSerializableObject should never be called in JSWorklets.");
|
|
362
|
-
}
|
|
363
|
-
createSerializableMap() {
|
|
364
|
-
throw new WorkletsError("createSerializableMap should never be called in JSWorklets.");
|
|
365
|
-
}
|
|
366
|
-
createSerializableSet() {
|
|
367
|
-
throw new WorkletsError("createSerializableSet should never be called in JSWorklets.");
|
|
368
|
-
}
|
|
369
|
-
createSerializableImport() {
|
|
370
|
-
throw new WorkletsError("createSerializableImport should never be called in JSWorklets.");
|
|
371
|
-
}
|
|
372
|
-
createSerializableHostObject() {
|
|
373
|
-
throw new WorkletsError("createSerializableHostObject should never be called in JSWorklets.");
|
|
374
|
-
}
|
|
375
|
-
createSerializableArray() {
|
|
376
|
-
throw new WorkletsError("createSerializableArray should never be called in JSWorklets.");
|
|
377
|
-
}
|
|
378
|
-
createSerializableInitializer() {
|
|
379
|
-
throw new WorkletsError("createSerializableInitializer should never be called in JSWorklets.");
|
|
380
|
-
}
|
|
381
|
-
createSerializableFunction() {
|
|
382
|
-
throw new WorkletsError("createSerializableFunction should never be called in JSWorklets.");
|
|
383
|
-
}
|
|
384
|
-
createSerializableWorklet() {
|
|
385
|
-
throw new WorkletsError("createSerializableWorklet should never be called in JSWorklets.");
|
|
386
|
-
}
|
|
387
|
-
scheduleOnUI(worklet) {
|
|
388
|
-
requestAnimationFrameImpl(worklet);
|
|
389
|
-
}
|
|
390
|
-
executeOnUIRuntimeSync() {
|
|
391
|
-
throw new WorkletsError("`executeOnUIRuntimeSync` is not available in JSWorklets.");
|
|
392
|
-
}
|
|
393
|
-
createWorkletRuntime() {
|
|
394
|
-
throw new WorkletsError("createWorkletRuntime is not available in JSWorklets.");
|
|
395
|
-
}
|
|
396
|
-
scheduleOnRuntime() {
|
|
397
|
-
throw new WorkletsError("scheduleOnRuntime is not available in JSWorklets.");
|
|
398
|
-
}
|
|
399
|
-
createSynchronizable() {
|
|
400
|
-
throw new WorkletsError("createSynchronizable should never be called in JSWorklets.");
|
|
401
|
-
}
|
|
402
|
-
synchronizableGetDirty() {
|
|
403
|
-
throw new WorkletsError("synchronizableGetDirty should never be called in JSWorklets.");
|
|
404
|
-
}
|
|
405
|
-
synchronizableGetBlocking() {
|
|
406
|
-
throw new WorkletsError("synchronizableGetBlocking should never be called in JSWorklets.");
|
|
407
|
-
}
|
|
408
|
-
synchronizableSetBlocking() {
|
|
409
|
-
throw new WorkletsError("synchronizableSetBlocking should never be called in JSWorklets.");
|
|
410
|
-
}
|
|
411
|
-
synchronizableLock() {
|
|
412
|
-
throw new WorkletsError("synchronizableLock should never be called in JSWorklets.");
|
|
413
|
-
}
|
|
414
|
-
synchronizableUnlock() {
|
|
415
|
-
throw new WorkletsError("synchronizableUnlock should never be called in JSWorklets.");
|
|
416
|
-
}
|
|
417
|
-
reportFatalErrorOnJS() {
|
|
418
|
-
throw new WorkletsError("reportFatalErrorOnJS should never be called in JSWorklets.");
|
|
419
|
-
}
|
|
420
|
-
getStaticFeatureFlag() {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
setDynamicFeatureFlag() {
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
var NativeWorkletsModule_default = reactNative.TurboModuleRegistry.get("WorkletsModule");
|
|
427
|
-
|
|
428
|
-
// ../../node_modules/react-native-worklets/lib/module/specs/index.js
|
|
429
|
-
var WorkletsTurboModule = globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative ? NativeWorkletsModule_default : (
|
|
430
|
-
// In Bundle Mode, on Worklet Runtimes `RNWorkletsTurboModule` isn't
|
|
431
|
-
// available and shouldn't be accessed. We return null here
|
|
432
|
-
// to keep the same codebase for the Bundle Mode and legacy behavior.
|
|
433
|
-
null
|
|
434
|
-
);
|
|
435
|
-
|
|
436
|
-
// ../../node_modules/react-native-worklets/lib/module/utils/checkCppVersion.js
|
|
437
|
-
function checkCppVersion() {
|
|
438
|
-
const cppVersion = global._WORKLETS_VERSION_CPP;
|
|
439
|
-
if (cppVersion === void 0) {
|
|
440
|
-
logger.warn(`Couldn't determine the version of the native part of Worklets.
|
|
441
|
-
See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#couldnt-determine-the-version-of-the-native-part-of-worklets\` for more details.`);
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
const ok = matchVersion(jsVersion, cppVersion);
|
|
445
|
-
if (!ok) {
|
|
446
|
-
throw new WorkletsError(`Mismatch between JavaScript part and native part of Worklets (${jsVersion} vs ${cppVersion}).
|
|
447
|
-
See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#mismatch-between-javascript-part-and-native-part-of-worklets\` for more details.`);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function matchVersion(version1, version2) {
|
|
451
|
-
if (version1.match(/^\d+\.\d+\.\d+$/) && version2.match(/^\d+\.\d+\.\d+$/)) {
|
|
452
|
-
const [major1, minor1] = version1.split(".");
|
|
453
|
-
const [major2, minor2] = version2.split(".");
|
|
454
|
-
return major1 === major2 && minor1 === minor2;
|
|
455
|
-
} else {
|
|
456
|
-
return version1 === version2;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// ../../node_modules/react-native-worklets/lib/module/WorkletsModule/NativeWorklets.js
|
|
461
|
-
function createNativeWorkletsModule() {
|
|
462
|
-
return new NativeWorklets();
|
|
463
|
-
}
|
|
464
|
-
var _workletsModuleProxy, _serializableUndefined, _serializableNull, _serializableTrue, _serializableFalse;
|
|
465
|
-
var NativeWorklets = class {
|
|
466
|
-
constructor() {
|
|
467
|
-
__privateAdd(this, _workletsModuleProxy);
|
|
468
|
-
__privateAdd(this, _serializableUndefined);
|
|
469
|
-
__privateAdd(this, _serializableNull);
|
|
470
|
-
__privateAdd(this, _serializableTrue);
|
|
471
|
-
__privateAdd(this, _serializableFalse);
|
|
472
|
-
globalThis._WORKLETS_VERSION_JS = jsVersion;
|
|
473
|
-
if (global.__workletsModuleProxy === void 0 && globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
|
|
474
|
-
WorkletsTurboModule?.installTurboModule();
|
|
475
|
-
}
|
|
476
|
-
if (global.__workletsModuleProxy === void 0) {
|
|
477
|
-
throw new WorkletsError(`Native part of Worklets doesn't seem to be initialized.
|
|
478
|
-
See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#native-part-of-worklets-doesnt-seem-to-be-initialized for more details.`);
|
|
479
|
-
}
|
|
480
|
-
if (__DEV__) {
|
|
481
|
-
checkCppVersion();
|
|
482
|
-
}
|
|
483
|
-
__privateSet(this, _workletsModuleProxy, global.__workletsModuleProxy);
|
|
484
|
-
__privateSet(this, _serializableNull, __privateGet(this, _workletsModuleProxy).createSerializableNull());
|
|
485
|
-
__privateSet(this, _serializableUndefined, __privateGet(this, _workletsModuleProxy).createSerializableUndefined());
|
|
486
|
-
__privateSet(this, _serializableTrue, __privateGet(this, _workletsModuleProxy).createSerializableBoolean(true));
|
|
487
|
-
__privateSet(this, _serializableFalse, __privateGet(this, _workletsModuleProxy).createSerializableBoolean(false));
|
|
488
|
-
}
|
|
489
|
-
createSerializable(value, shouldPersistRemote, nativeStateSource) {
|
|
490
|
-
return __privateGet(this, _workletsModuleProxy).createSerializable(value, shouldPersistRemote, nativeStateSource);
|
|
491
|
-
}
|
|
492
|
-
createSerializableImport(from, to) {
|
|
493
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableImport(from, to);
|
|
494
|
-
}
|
|
495
|
-
createSerializableString(str) {
|
|
496
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableString(str);
|
|
497
|
-
}
|
|
498
|
-
createSerializableNumber(num) {
|
|
499
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableNumber(num);
|
|
500
|
-
}
|
|
501
|
-
createSerializableBoolean(bool) {
|
|
502
|
-
return bool ? __privateGet(this, _serializableTrue) : __privateGet(this, _serializableFalse);
|
|
503
|
-
}
|
|
504
|
-
createSerializableBigInt(bigInt) {
|
|
505
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableBigInt(bigInt);
|
|
506
|
-
}
|
|
507
|
-
createSerializableUndefined() {
|
|
508
|
-
return __privateGet(this, _serializableUndefined);
|
|
509
|
-
}
|
|
510
|
-
createSerializableNull() {
|
|
511
|
-
return __privateGet(this, _serializableNull);
|
|
512
|
-
}
|
|
513
|
-
createSerializableTurboModuleLike(props, proto) {
|
|
514
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableTurboModuleLike(props, proto);
|
|
515
|
-
}
|
|
516
|
-
createSerializableObject(obj, shouldRetainRemote, nativeStateSource) {
|
|
517
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableObject(obj, shouldRetainRemote, nativeStateSource);
|
|
518
|
-
}
|
|
519
|
-
createSerializableHostObject(obj) {
|
|
520
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableHostObject(obj);
|
|
521
|
-
}
|
|
522
|
-
createSerializableArray(array, shouldRetainRemote) {
|
|
523
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableArray(array, shouldRetainRemote);
|
|
524
|
-
}
|
|
525
|
-
createSerializableMap(keys, values) {
|
|
526
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableMap(keys, values);
|
|
527
|
-
}
|
|
528
|
-
createSerializableSet(values) {
|
|
529
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableSet(values);
|
|
530
|
-
}
|
|
531
|
-
createSerializableInitializer(obj) {
|
|
532
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableInitializer(obj);
|
|
533
|
-
}
|
|
534
|
-
createSerializableFunction(func) {
|
|
535
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableFunction(func);
|
|
536
|
-
}
|
|
537
|
-
createSerializableWorklet(worklet, shouldPersistRemote) {
|
|
538
|
-
return __privateGet(this, _workletsModuleProxy).createSerializableWorklet(worklet, shouldPersistRemote);
|
|
539
|
-
}
|
|
540
|
-
scheduleOnUI(serializable) {
|
|
541
|
-
return __privateGet(this, _workletsModuleProxy).scheduleOnUI(serializable);
|
|
542
|
-
}
|
|
543
|
-
executeOnUIRuntimeSync(serializable) {
|
|
544
|
-
return __privateGet(this, _workletsModuleProxy).executeOnUIRuntimeSync(serializable);
|
|
545
|
-
}
|
|
546
|
-
createWorkletRuntime(name, initializer, useDefaultQueue, customQueue, enableEventLoop) {
|
|
547
|
-
return __privateGet(this, _workletsModuleProxy).createWorkletRuntime(name, initializer, useDefaultQueue, customQueue, enableEventLoop);
|
|
548
|
-
}
|
|
549
|
-
scheduleOnRuntime(workletRuntime, serializableWorklet) {
|
|
550
|
-
return __privateGet(this, _workletsModuleProxy).scheduleOnRuntime(workletRuntime, serializableWorklet);
|
|
551
|
-
}
|
|
552
|
-
createSynchronizable(value) {
|
|
553
|
-
return __privateGet(this, _workletsModuleProxy).createSynchronizable(value);
|
|
554
|
-
}
|
|
555
|
-
synchronizableGetDirty(synchronizableRef) {
|
|
556
|
-
return __privateGet(this, _workletsModuleProxy).synchronizableGetDirty(synchronizableRef);
|
|
557
|
-
}
|
|
558
|
-
synchronizableGetBlocking(synchronizableRef) {
|
|
559
|
-
return __privateGet(this, _workletsModuleProxy).synchronizableGetBlocking(synchronizableRef);
|
|
560
|
-
}
|
|
561
|
-
synchronizableSetBlocking(synchronizableRef, value) {
|
|
562
|
-
return __privateGet(this, _workletsModuleProxy).synchronizableSetBlocking(synchronizableRef, value);
|
|
563
|
-
}
|
|
564
|
-
synchronizableLock(synchronizableRef) {
|
|
565
|
-
return __privateGet(this, _workletsModuleProxy).synchronizableLock(synchronizableRef);
|
|
566
|
-
}
|
|
567
|
-
synchronizableUnlock(synchronizableRef) {
|
|
568
|
-
return __privateGet(this, _workletsModuleProxy).synchronizableUnlock(synchronizableRef);
|
|
569
|
-
}
|
|
570
|
-
reportFatalErrorOnJS(message, stack, name, jsEngine) {
|
|
571
|
-
return __privateGet(this, _workletsModuleProxy).reportFatalErrorOnJS(message, stack, name, jsEngine);
|
|
572
|
-
}
|
|
573
|
-
getStaticFeatureFlag(name) {
|
|
574
|
-
return __privateGet(this, _workletsModuleProxy).getStaticFeatureFlag(name);
|
|
575
|
-
}
|
|
576
|
-
setDynamicFeatureFlag(name, value) {
|
|
577
|
-
__privateGet(this, _workletsModuleProxy).setDynamicFeatureFlag(name, value);
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
_workletsModuleProxy = new WeakMap();
|
|
581
|
-
_serializableUndefined = new WeakMap();
|
|
582
|
-
_serializableNull = new WeakMap();
|
|
583
|
-
_serializableTrue = new WeakMap();
|
|
584
|
-
_serializableFalse = new WeakMap();
|
|
585
|
-
|
|
586
|
-
// ../../node_modules/react-native-worklets/lib/module/WorkletsModule/workletsModuleInstance.js
|
|
587
|
-
var WorkletsModule = SHOULD_BE_USE_WEB2 ? createJSWorkletsModule() : createNativeWorkletsModule();
|
|
588
|
-
|
|
589
|
-
// ../../node_modules/react-native-worklets/lib/module/serializable.js
|
|
590
|
-
var MAGIC_KEY = "REANIMATED_MAGIC_KEY";
|
|
591
|
-
function isHostObject(value) {
|
|
592
|
-
"worklet";
|
|
593
|
-
return MAGIC_KEY in value;
|
|
594
|
-
}
|
|
595
|
-
function isPlainJSObject(object) {
|
|
596
|
-
"worklet";
|
|
597
|
-
return Object.getPrototypeOf(object) === Object.prototype;
|
|
598
|
-
}
|
|
599
|
-
function isTurboModuleLike(object) {
|
|
600
|
-
return isHostObject(Object.getPrototypeOf(object));
|
|
601
|
-
}
|
|
602
|
-
function getFromCache(value) {
|
|
603
|
-
const cached = serializableMappingCache.get(value);
|
|
604
|
-
if (cached === serializableMappingFlag) {
|
|
605
|
-
return value;
|
|
606
|
-
}
|
|
607
|
-
return cached;
|
|
608
|
-
}
|
|
609
|
-
var INACCESSIBLE_OBJECT = {
|
|
610
|
-
__init: () => {
|
|
611
|
-
"worklet";
|
|
612
|
-
return new Proxy({}, {
|
|
613
|
-
get: (_, prop) => {
|
|
614
|
-
if (prop === "_isReanimatedSharedValue" || prop === "__remoteFunction") {
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
throw new WorkletsError(`Trying to access property \`${String(prop)}\` of an object which cannot be sent to the UI runtime.`);
|
|
618
|
-
},
|
|
619
|
-
set: () => {
|
|
620
|
-
throw new WorkletsError("Trying to write to an object which cannot be sent to the UI runtime.");
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
var VALID_ARRAY_VIEWS_NAMES = ["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array", "DataView"];
|
|
626
|
-
var DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD = 30;
|
|
627
|
-
var processedObjectAtThresholdDepth;
|
|
628
|
-
function createSerializableWeb(value) {
|
|
629
|
-
return value;
|
|
630
|
-
}
|
|
631
|
-
function createSerializableNative(value, shouldPersistRemote = false, depth = 0) {
|
|
632
|
-
detectCyclicObject(value, depth);
|
|
633
|
-
const isObject = typeof value === "object";
|
|
634
|
-
const isFunction = typeof value === "function";
|
|
635
|
-
if (typeof value === "string") {
|
|
636
|
-
return cloneString(value);
|
|
637
|
-
}
|
|
638
|
-
if (typeof value === "number") {
|
|
639
|
-
return cloneNumber(value);
|
|
640
|
-
}
|
|
641
|
-
if (typeof value === "boolean") {
|
|
642
|
-
return cloneBoolean(value);
|
|
643
|
-
}
|
|
644
|
-
if (typeof value === "bigint") {
|
|
645
|
-
return cloneBigInt(value);
|
|
646
|
-
}
|
|
647
|
-
if (value === void 0) {
|
|
648
|
-
return cloneUndefined();
|
|
649
|
-
}
|
|
650
|
-
if (value === null) {
|
|
651
|
-
return cloneNull();
|
|
652
|
-
}
|
|
653
|
-
if (!isObject && !isFunction || value === null) {
|
|
654
|
-
return clonePrimitive(value, shouldPersistRemote);
|
|
655
|
-
}
|
|
656
|
-
const cached = getFromCache(value);
|
|
657
|
-
if (cached !== void 0) {
|
|
658
|
-
return cached;
|
|
659
|
-
}
|
|
660
|
-
if (Array.isArray(value)) {
|
|
661
|
-
return cloneArray(value, shouldPersistRemote, depth);
|
|
662
|
-
}
|
|
663
|
-
if (globalThis._WORKLETS_BUNDLE_MODE && isFunction && value.__bundleData) {
|
|
664
|
-
return cloneImport(value);
|
|
665
|
-
}
|
|
666
|
-
if (isFunction && !isWorkletFunction(value)) {
|
|
667
|
-
return cloneRemoteFunction(value);
|
|
668
|
-
}
|
|
669
|
-
if (isTurboModuleLike(value)) {
|
|
670
|
-
return cloneTurboModuleLike(value, shouldPersistRemote, depth);
|
|
671
|
-
}
|
|
672
|
-
if (isHostObject(value)) {
|
|
673
|
-
return cloneHostObject(value);
|
|
674
|
-
}
|
|
675
|
-
if (isPlainJSObject(value) && value.__init) {
|
|
676
|
-
return cloneInitializer(value, shouldPersistRemote, depth);
|
|
677
|
-
}
|
|
678
|
-
if (isPlainJSObject(value) && value.__workletContextObjectFactory) {
|
|
679
|
-
return cloneContextObject(value);
|
|
680
|
-
}
|
|
681
|
-
if ((isPlainJSObject(value) || isFunction) && isWorkletFunction(value)) {
|
|
682
|
-
return cloneWorklet(value, shouldPersistRemote, depth);
|
|
683
|
-
}
|
|
684
|
-
if (isSynchronizable(value)) {
|
|
685
|
-
return cloneSynchronizable(value);
|
|
686
|
-
}
|
|
687
|
-
if (isPlainJSObject(value) || isFunction) {
|
|
688
|
-
return clonePlainJSObject(value, shouldPersistRemote, depth);
|
|
689
|
-
}
|
|
690
|
-
if (value instanceof Set) {
|
|
691
|
-
return cloneSet(value);
|
|
692
|
-
}
|
|
693
|
-
if (value instanceof Map) {
|
|
694
|
-
return cloneMap(value);
|
|
695
|
-
}
|
|
696
|
-
if (value instanceof RegExp) {
|
|
697
|
-
return cloneRegExp(value);
|
|
698
|
-
}
|
|
699
|
-
if (value instanceof Error) {
|
|
700
|
-
return cloneError(value);
|
|
701
|
-
}
|
|
702
|
-
if (value instanceof ArrayBuffer) {
|
|
703
|
-
return cloneArrayBuffer(value, shouldPersistRemote);
|
|
704
|
-
}
|
|
705
|
-
if (ArrayBuffer.isView(value)) {
|
|
706
|
-
return cloneArrayBufferView(value);
|
|
707
|
-
}
|
|
708
|
-
return inaccessibleObject(value);
|
|
709
|
-
}
|
|
710
|
-
if (globalThis._WORKLETS_BUNDLE_MODE) {
|
|
711
|
-
createSerializableNative.__bundleData = {
|
|
712
|
-
imported: "createSerializable",
|
|
713
|
-
// @ts-expect-error resolveWeak is defined by Metro
|
|
714
|
-
source: __require.resolveWeak("./index")
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
var createSerializable = SHOULD_BE_USE_WEB2 ? createSerializableWeb : createSerializableNative;
|
|
718
|
-
function detectCyclicObject(value, depth) {
|
|
719
|
-
if (depth >= DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {
|
|
720
|
-
if (depth === DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {
|
|
721
|
-
processedObjectAtThresholdDepth = value;
|
|
722
|
-
} else if (value === processedObjectAtThresholdDepth) {
|
|
723
|
-
throw new WorkletsError("Trying to convert a cyclic object to a serializable. This is not supported.");
|
|
724
|
-
}
|
|
725
|
-
} else {
|
|
726
|
-
processedObjectAtThresholdDepth = void 0;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
function clonePrimitive(value, shouldPersistRemote) {
|
|
730
|
-
return WorkletsModule.createSerializable(value, shouldPersistRemote);
|
|
731
|
-
}
|
|
732
|
-
function cloneString(value) {
|
|
733
|
-
return WorkletsModule.createSerializableString(value);
|
|
734
|
-
}
|
|
735
|
-
function cloneNumber(value) {
|
|
736
|
-
return WorkletsModule.createSerializableNumber(value);
|
|
737
|
-
}
|
|
738
|
-
function cloneBoolean(value) {
|
|
739
|
-
return WorkletsModule.createSerializableBoolean(value);
|
|
740
|
-
}
|
|
741
|
-
function cloneBigInt(value) {
|
|
742
|
-
return WorkletsModule.createSerializableBigInt(value);
|
|
743
|
-
}
|
|
744
|
-
function cloneUndefined() {
|
|
745
|
-
return WorkletsModule.createSerializableUndefined();
|
|
746
|
-
}
|
|
747
|
-
function cloneNull() {
|
|
748
|
-
return WorkletsModule.createSerializableNull();
|
|
749
|
-
}
|
|
750
|
-
function cloneObjectProperties(value, shouldPersistRemote, depth) {
|
|
751
|
-
const clonedProps = {};
|
|
752
|
-
for (const [key, element] of Object.entries(value)) {
|
|
753
|
-
if (key === "__initData" && clonedProps.__initData !== void 0) {
|
|
754
|
-
continue;
|
|
755
|
-
}
|
|
756
|
-
clonedProps[key] = createSerializable(element, shouldPersistRemote, depth + 1);
|
|
757
|
-
}
|
|
758
|
-
return clonedProps;
|
|
759
|
-
}
|
|
760
|
-
function cloneInitializer(value, shouldPersistRemote = false, depth = 0) {
|
|
761
|
-
const clonedProps = cloneObjectProperties(value, shouldPersistRemote, depth);
|
|
762
|
-
return WorkletsModule.createSerializableInitializer(clonedProps);
|
|
763
|
-
}
|
|
764
|
-
function cloneArray(value, shouldPersistRemote, depth) {
|
|
765
|
-
const clonedElements = value.map((element) => createSerializable(element, shouldPersistRemote, depth + 1));
|
|
766
|
-
const clone = WorkletsModule.createSerializableArray(clonedElements, shouldPersistRemote);
|
|
767
|
-
serializableMappingCache.set(value, clone);
|
|
768
|
-
serializableMappingCache.set(clone);
|
|
769
|
-
freezeObjectInDev(value);
|
|
770
|
-
return clone;
|
|
771
|
-
}
|
|
772
|
-
function cloneRemoteFunction(value) {
|
|
773
|
-
const clone = WorkletsModule.createSerializableFunction(value);
|
|
774
|
-
serializableMappingCache.set(value, clone);
|
|
775
|
-
serializableMappingCache.set(clone);
|
|
776
|
-
freezeObjectInDev(value);
|
|
777
|
-
return clone;
|
|
778
|
-
}
|
|
779
|
-
function cloneHostObject(value) {
|
|
780
|
-
const clone = WorkletsModule.createSerializableHostObject(value);
|
|
781
|
-
serializableMappingCache.set(value, clone);
|
|
782
|
-
serializableMappingCache.set(clone);
|
|
783
|
-
return clone;
|
|
784
|
-
}
|
|
785
|
-
function cloneWorklet(value, shouldPersistRemote, depth) {
|
|
786
|
-
if (__DEV__) {
|
|
787
|
-
const babelVersion = value.__pluginVersion;
|
|
788
|
-
if (babelVersion !== void 0 && babelVersion !== jsVersion) {
|
|
789
|
-
throw new WorkletsError(`Mismatch between JavaScript code version and Worklets Babel plugin version (${jsVersion} vs. ${babelVersion}).
|
|
790
|
-
See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#mismatch-between-javascript-code-version-and-worklets-babel-plugin-version\` for more details.
|
|
791
|
-
Offending code was: \`${getWorkletCode(value)}\``);
|
|
792
|
-
}
|
|
793
|
-
registerWorkletStackDetails(value.__workletHash, value.__stackDetails);
|
|
794
|
-
}
|
|
795
|
-
if (value.__stackDetails) {
|
|
796
|
-
delete value.__stackDetails;
|
|
797
|
-
}
|
|
798
|
-
const clonedProps = cloneObjectProperties(value, true, depth);
|
|
799
|
-
clonedProps.__initData = createSerializable(value.__initData, true, depth + 1);
|
|
800
|
-
const clone = WorkletsModule.createSerializableWorklet(
|
|
801
|
-
clonedProps,
|
|
802
|
-
// TODO: Check after refactor if we can remove shouldPersistRemote parameter (imho it's redundant here since worklets are always persistent)
|
|
803
|
-
// retain all worklets
|
|
804
|
-
true
|
|
805
|
-
);
|
|
806
|
-
serializableMappingCache.set(value, clone);
|
|
807
|
-
serializableMappingCache.set(clone);
|
|
808
|
-
freezeObjectInDev(value);
|
|
809
|
-
return clone;
|
|
810
|
-
}
|
|
811
|
-
function cloneTurboModuleLike(value, shouldPersistRemote, depth) {
|
|
812
|
-
const proto = Object.getPrototypeOf(value);
|
|
813
|
-
const clonedProps = cloneObjectProperties(value, shouldPersistRemote, depth);
|
|
814
|
-
const clone = WorkletsModule.createSerializableTurboModuleLike(clonedProps, proto);
|
|
815
|
-
return clone;
|
|
816
|
-
}
|
|
817
|
-
function cloneContextObject(value) {
|
|
818
|
-
const workletContextObjectFactory = value.__workletContextObjectFactory;
|
|
819
|
-
const handle = cloneInitializer({
|
|
820
|
-
__init: () => {
|
|
821
|
-
"worklet";
|
|
822
|
-
return workletContextObjectFactory();
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
serializableMappingCache.set(value, handle);
|
|
826
|
-
return handle;
|
|
827
|
-
}
|
|
828
|
-
function clonePlainJSObject(value, shouldPersistRemote, depth) {
|
|
829
|
-
const clonedProps = cloneObjectProperties(value, shouldPersistRemote, depth);
|
|
830
|
-
const clone = WorkletsModule.createSerializableObject(clonedProps, shouldPersistRemote, value);
|
|
831
|
-
serializableMappingCache.set(value, clone);
|
|
832
|
-
serializableMappingCache.set(clone);
|
|
833
|
-
freezeObjectInDev(value);
|
|
834
|
-
return clone;
|
|
835
|
-
}
|
|
836
|
-
function cloneMap(value) {
|
|
837
|
-
const clonedKeys = [];
|
|
838
|
-
const clonedValues = [];
|
|
839
|
-
for (const [key, element] of value.entries()) {
|
|
840
|
-
clonedKeys.push(createSerializable(key));
|
|
841
|
-
clonedValues.push(createSerializable(element));
|
|
842
|
-
}
|
|
843
|
-
const clone = WorkletsModule.createSerializableMap(clonedKeys, clonedValues);
|
|
844
|
-
serializableMappingCache.set(value, clone);
|
|
845
|
-
serializableMappingCache.set(clone);
|
|
846
|
-
freezeObjectInDev(value);
|
|
847
|
-
return clone;
|
|
848
|
-
}
|
|
849
|
-
function cloneSet(value) {
|
|
850
|
-
const clonedElements = [];
|
|
851
|
-
for (const element of value) {
|
|
852
|
-
clonedElements.push(createSerializable(element));
|
|
853
|
-
}
|
|
854
|
-
const clone = WorkletsModule.createSerializableSet(clonedElements);
|
|
855
|
-
serializableMappingCache.set(value, clone);
|
|
856
|
-
serializableMappingCache.set(clone);
|
|
857
|
-
freezeObjectInDev(value);
|
|
858
|
-
return clone;
|
|
859
|
-
}
|
|
860
|
-
function cloneRegExp(value) {
|
|
861
|
-
const pattern = value.source;
|
|
862
|
-
const flags = value.flags;
|
|
863
|
-
const handle = cloneInitializer({
|
|
864
|
-
__init: () => {
|
|
865
|
-
"worklet";
|
|
866
|
-
return new RegExp(pattern, flags);
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
serializableMappingCache.set(value, handle);
|
|
870
|
-
return handle;
|
|
871
|
-
}
|
|
872
|
-
function cloneError(value) {
|
|
873
|
-
const {
|
|
874
|
-
name,
|
|
875
|
-
message,
|
|
876
|
-
stack
|
|
877
|
-
} = value;
|
|
878
|
-
const handle = cloneInitializer({
|
|
879
|
-
__init: () => {
|
|
880
|
-
"worklet";
|
|
881
|
-
const error = new Error();
|
|
882
|
-
error.name = name;
|
|
883
|
-
error.message = message;
|
|
884
|
-
error.stack = stack;
|
|
885
|
-
return error;
|
|
886
|
-
}
|
|
887
|
-
});
|
|
888
|
-
serializableMappingCache.set(value, handle);
|
|
889
|
-
return handle;
|
|
890
|
-
}
|
|
891
|
-
function cloneArrayBuffer(value, shouldPersistRemote) {
|
|
892
|
-
const clone = WorkletsModule.createSerializable(value, shouldPersistRemote, value);
|
|
893
|
-
serializableMappingCache.set(value, clone);
|
|
894
|
-
serializableMappingCache.set(clone);
|
|
895
|
-
return clone;
|
|
896
|
-
}
|
|
897
|
-
function cloneArrayBufferView(value) {
|
|
898
|
-
const buffer = value.buffer;
|
|
899
|
-
const typeName = value.constructor.name;
|
|
900
|
-
const handle = cloneInitializer({
|
|
901
|
-
__init: () => {
|
|
902
|
-
"worklet";
|
|
903
|
-
if (!VALID_ARRAY_VIEWS_NAMES.includes(typeName)) {
|
|
904
|
-
throw new WorkletsError(`Invalid array view name \`${typeName}\`.`);
|
|
905
|
-
}
|
|
906
|
-
const constructor = global[typeName];
|
|
907
|
-
if (constructor === void 0) {
|
|
908
|
-
throw new WorkletsError(`Constructor for \`${typeName}\` not found.`);
|
|
909
|
-
}
|
|
910
|
-
return new constructor(buffer);
|
|
911
|
-
}
|
|
912
|
-
});
|
|
913
|
-
serializableMappingCache.set(value, handle);
|
|
914
|
-
return handle;
|
|
915
|
-
}
|
|
916
|
-
function cloneSynchronizable(value) {
|
|
917
|
-
serializableMappingCache.set(value);
|
|
918
|
-
return value;
|
|
919
|
-
}
|
|
920
|
-
function cloneImport(value) {
|
|
921
|
-
const {
|
|
922
|
-
source,
|
|
923
|
-
imported
|
|
924
|
-
} = value.__bundleData;
|
|
925
|
-
const clone = WorkletsModule.createSerializableImport(source, imported);
|
|
926
|
-
serializableMappingCache.set(value, clone);
|
|
927
|
-
serializableMappingCache.set(clone);
|
|
928
|
-
return clone;
|
|
929
|
-
}
|
|
930
|
-
function inaccessibleObject(value) {
|
|
931
|
-
const clone = createSerializable(INACCESSIBLE_OBJECT);
|
|
932
|
-
serializableMappingCache.set(value, clone);
|
|
933
|
-
return clone;
|
|
934
|
-
}
|
|
935
|
-
var WORKLET_CODE_THRESHOLD = 255;
|
|
936
|
-
function getWorkletCode(value) {
|
|
937
|
-
const code = value?.__initData?.code;
|
|
938
|
-
if (!code) {
|
|
939
|
-
return "unknown";
|
|
940
|
-
}
|
|
941
|
-
if (code.length > WORKLET_CODE_THRESHOLD) {
|
|
942
|
-
return `${code.substring(0, WORKLET_CODE_THRESHOLD)}...`;
|
|
943
|
-
}
|
|
944
|
-
return code;
|
|
945
|
-
}
|
|
946
|
-
function isRemoteFunction(value) {
|
|
947
|
-
"worklet";
|
|
948
|
-
return !!value.__remoteFunction;
|
|
949
|
-
}
|
|
950
|
-
function freezeObjectInDev(value) {
|
|
951
|
-
if (!__DEV__) {
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
Object.entries(value).forEach(([key, element]) => {
|
|
955
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
956
|
-
if (!descriptor.configurable) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
Object.defineProperty(value, key, {
|
|
960
|
-
get() {
|
|
961
|
-
return element;
|
|
962
|
-
},
|
|
963
|
-
set() {
|
|
964
|
-
logger.warn(`Tried to modify key \`${key}\` of an object which has been already passed to a worklet. See
|
|
965
|
-
https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-modify-key-of-an-object-which-has-been-converted-to-a-serializable
|
|
966
|
-
for more details.`);
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
});
|
|
970
|
-
Object.preventExtensions(value);
|
|
971
|
-
}
|
|
972
|
-
function makeShareableCloneOnUIRecursiveLEGACY(value) {
|
|
973
|
-
"worklet";
|
|
974
|
-
if (SHOULD_BE_USE_WEB2) {
|
|
975
|
-
return value;
|
|
976
|
-
}
|
|
977
|
-
function cloneRecursive(value2) {
|
|
978
|
-
if (typeof value2 === "object" && value2 !== null || typeof value2 === "function") {
|
|
979
|
-
if (isHostObject(value2)) {
|
|
980
|
-
return global._createSerializableHostObject(value2);
|
|
981
|
-
}
|
|
982
|
-
if (isRemoteFunction(value2)) {
|
|
983
|
-
return value2.__remoteFunction;
|
|
984
|
-
}
|
|
985
|
-
if (Array.isArray(value2)) {
|
|
986
|
-
return global._createSerializableArray(value2.map(cloneRecursive));
|
|
987
|
-
}
|
|
988
|
-
if (value2.__synchronizableRef) {
|
|
989
|
-
return global._createSerializableSynchronizable(value2);
|
|
990
|
-
}
|
|
991
|
-
const toAdapt = {};
|
|
992
|
-
for (const [key, element] of Object.entries(value2)) {
|
|
993
|
-
toAdapt[key] = cloneRecursive(element);
|
|
994
|
-
}
|
|
995
|
-
return global._createSerializable(toAdapt, value2);
|
|
996
|
-
}
|
|
997
|
-
if (typeof value2 === "string") {
|
|
998
|
-
return global._createSerializableString(value2);
|
|
999
|
-
}
|
|
1000
|
-
if (typeof value2 === "number") {
|
|
1001
|
-
return global._createSerializableNumber(value2);
|
|
1002
|
-
}
|
|
1003
|
-
if (typeof value2 === "boolean") {
|
|
1004
|
-
return global._createSerializableBoolean(value2);
|
|
1005
|
-
}
|
|
1006
|
-
if (typeof value2 === "bigint") {
|
|
1007
|
-
return global._createSerializableBigInt(value2);
|
|
1008
|
-
}
|
|
1009
|
-
if (value2 === void 0) {
|
|
1010
|
-
return global._createSerializableUndefined();
|
|
1011
|
-
}
|
|
1012
|
-
if (value2 === null) {
|
|
1013
|
-
return global._createSerializableNull();
|
|
1014
|
-
}
|
|
1015
|
-
return global._createSerializable(value2, void 0);
|
|
1016
|
-
}
|
|
1017
|
-
return cloneRecursive(value);
|
|
1018
|
-
}
|
|
1019
|
-
var makeShareableCloneOnUIRecursive = globalThis._WORKLETS_BUNDLE_MODE ? createSerializable : makeShareableCloneOnUIRecursiveLEGACY;
|
|
1020
|
-
|
|
1021
|
-
// ../../node_modules/react-native-worklets/lib/module/threads.js
|
|
1022
|
-
var runOnUIQueue = [];
|
|
1023
|
-
function setupMicrotasks() {
|
|
1024
|
-
"worklet";
|
|
1025
|
-
let microtasksQueue = [];
|
|
1026
|
-
let isExecutingMicrotasksQueue = false;
|
|
1027
|
-
global.queueMicrotask = (callback) => {
|
|
1028
|
-
microtasksQueue.push(callback);
|
|
1029
|
-
};
|
|
1030
|
-
global._microtaskQueueFinalizers = [];
|
|
1031
|
-
global.__callMicrotasks = () => {
|
|
1032
|
-
if (isExecutingMicrotasksQueue) {
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
try {
|
|
1036
|
-
isExecutingMicrotasksQueue = true;
|
|
1037
|
-
for (let index = 0; index < microtasksQueue.length; index += 1) {
|
|
1038
|
-
microtasksQueue[index]();
|
|
1039
|
-
}
|
|
1040
|
-
microtasksQueue = [];
|
|
1041
|
-
global._microtaskQueueFinalizers.forEach((finalizer) => finalizer());
|
|
1042
|
-
} finally {
|
|
1043
|
-
isExecutingMicrotasksQueue = false;
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
function callMicrotasksOnUIThread() {
|
|
1048
|
-
"worklet";
|
|
1049
|
-
global.__callMicrotasks();
|
|
1050
|
-
}
|
|
1051
|
-
var callMicrotasks = SHOULD_BE_USE_WEB2 ? () => {
|
|
1052
|
-
} : callMicrotasksOnUIThread;
|
|
1053
|
-
function runOnUI(worklet) {
|
|
1054
|
-
if (__DEV__ && !SHOULD_BE_USE_WEB2 && !isWorkletFunction(worklet) && !worklet.__bundleData) {
|
|
1055
|
-
throw new WorkletsError("`runOnUI` can only be used with worklets.");
|
|
1056
|
-
}
|
|
1057
|
-
return (...args) => {
|
|
1058
|
-
if (IS_JEST2) {
|
|
1059
|
-
WorkletsModule.scheduleOnUI(createSerializable(() => {
|
|
1060
|
-
"worklet";
|
|
1061
|
-
worklet(...args);
|
|
1062
|
-
}));
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
if (__DEV__) {
|
|
1066
|
-
createSerializable(worklet);
|
|
1067
|
-
createSerializable(args);
|
|
1068
|
-
}
|
|
1069
|
-
enqueueUI(worklet, args);
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
if (__DEV__) {
|
|
1073
|
-
let runOnUIWorklet = function() {
|
|
1074
|
-
"worklet";
|
|
1075
|
-
throw new WorkletsError("`runOnUI` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.");
|
|
1076
|
-
};
|
|
1077
|
-
const serializableRunOnUIWorklet = createSerializable(runOnUIWorklet);
|
|
1078
|
-
serializableMappingCache.set(runOnUI, serializableRunOnUIWorklet);
|
|
1079
|
-
}
|
|
1080
|
-
function executeOnUIRuntimeSync(worklet) {
|
|
1081
|
-
return (...args) => {
|
|
1082
|
-
return WorkletsModule.executeOnUIRuntimeSync(createSerializable(() => {
|
|
1083
|
-
"worklet";
|
|
1084
|
-
const result = worklet(...args);
|
|
1085
|
-
return makeShareableCloneOnUIRecursive(result);
|
|
1086
|
-
}));
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
function runWorkletOnJS(worklet, ...args) {
|
|
1090
|
-
worklet(...args);
|
|
1091
|
-
}
|
|
1092
|
-
function runOnJS(fun) {
|
|
1093
|
-
"worklet";
|
|
1094
|
-
if (SHOULD_BE_USE_WEB2 || globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
|
|
1095
|
-
return (...args) => queueMicrotask(args.length ? () => fun(...args) : fun);
|
|
1096
|
-
}
|
|
1097
|
-
if (isWorkletFunction(fun)) {
|
|
1098
|
-
return (...args) => runOnJS(runWorkletOnJS)(fun, ...args);
|
|
1099
|
-
}
|
|
1100
|
-
if (fun.__remoteFunction) {
|
|
1101
|
-
fun = fun.__remoteFunction;
|
|
1102
|
-
}
|
|
1103
|
-
const scheduleOnJS = typeof fun === "function" ? global._scheduleHostFunctionOnJS : global._scheduleRemoteFunctionOnJS;
|
|
1104
|
-
return (...args) => {
|
|
1105
|
-
scheduleOnJS(fun, args.length > 0 ? makeShareableCloneOnUIRecursive(args) : void 0);
|
|
1106
|
-
};
|
|
1107
|
-
}
|
|
1108
|
-
function runOnUIAsync(worklet) {
|
|
1109
|
-
if (__DEV__ && !SHOULD_BE_USE_WEB2 && !isWorkletFunction(worklet)) {
|
|
1110
|
-
throw new WorkletsError("`runOnUIAsync` can only be used with worklets.");
|
|
1111
|
-
}
|
|
1112
|
-
return (...args) => {
|
|
1113
|
-
return new Promise((resolve) => {
|
|
1114
|
-
if (IS_JEST2) {
|
|
1115
|
-
WorkletsModule.scheduleOnUI(createSerializable(() => {
|
|
1116
|
-
"worklet";
|
|
1117
|
-
worklet(...args);
|
|
1118
|
-
}));
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
if (__DEV__) {
|
|
1122
|
-
createSerializable(worklet);
|
|
1123
|
-
createSerializable(args);
|
|
1124
|
-
}
|
|
1125
|
-
enqueueUI(worklet, args, resolve);
|
|
1126
|
-
});
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
|
-
if (__DEV__) {
|
|
1130
|
-
let runOnUIAsyncWorklet = function() {
|
|
1131
|
-
"worklet";
|
|
1132
|
-
throw new WorkletsError("`runOnUIAsync` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.");
|
|
1133
|
-
};
|
|
1134
|
-
const serializableRunOnUIAsyncWorklet = createSerializable(runOnUIAsyncWorklet);
|
|
1135
|
-
serializableMappingCache.set(runOnUIAsync, serializableRunOnUIAsyncWorklet);
|
|
1136
|
-
}
|
|
1137
|
-
function enqueueUI(worklet, args, resolve) {
|
|
1138
|
-
const job = [worklet, args, resolve];
|
|
1139
|
-
runOnUIQueue.push(job);
|
|
1140
|
-
if (runOnUIQueue.length === 1) {
|
|
1141
|
-
flushUIQueue();
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
function flushUIQueue() {
|
|
1145
|
-
queueMicrotask(() => {
|
|
1146
|
-
const queue = runOnUIQueue;
|
|
1147
|
-
runOnUIQueue = [];
|
|
1148
|
-
WorkletsModule.scheduleOnUI(createSerializable(() => {
|
|
1149
|
-
"worklet";
|
|
1150
|
-
queue.forEach(([workletFunction, workletArgs, jobResolve]) => {
|
|
1151
|
-
const result = workletFunction(...workletArgs);
|
|
1152
|
-
if (jobResolve) {
|
|
1153
|
-
runOnJS(jobResolve)(result);
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
callMicrotasks();
|
|
1157
|
-
}));
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
// ../../node_modules/react-native-worklets/lib/module/runLoop/uiRuntime/requestAnimationFrame.js
|
|
1162
|
-
function setupRequestAnimationFrame() {
|
|
1163
|
-
"worklet";
|
|
1164
|
-
const nativeRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
1165
|
-
let queuedCallbacks = [];
|
|
1166
|
-
let queuedCallbacksBegin = 0;
|
|
1167
|
-
let queuedCallbacksEnd = 0;
|
|
1168
|
-
let flushedCallbacks = queuedCallbacks;
|
|
1169
|
-
let flushedCallbacksBegin = 0;
|
|
1170
|
-
let flushedCallbacksEnd = 0;
|
|
1171
|
-
let flushRequested = false;
|
|
1172
|
-
globalThis.__flushAnimationFrame = (timestamp) => {
|
|
1173
|
-
flushedCallbacks = queuedCallbacks;
|
|
1174
|
-
queuedCallbacks = [];
|
|
1175
|
-
flushedCallbacksBegin = queuedCallbacksBegin;
|
|
1176
|
-
flushedCallbacksEnd = queuedCallbacksEnd;
|
|
1177
|
-
queuedCallbacksBegin = queuedCallbacksEnd;
|
|
1178
|
-
for (const callback of flushedCallbacks) {
|
|
1179
|
-
callback(timestamp);
|
|
1180
|
-
}
|
|
1181
|
-
flushedCallbacksBegin = flushedCallbacksEnd;
|
|
1182
|
-
callMicrotasks();
|
|
1183
|
-
};
|
|
1184
|
-
globalThis.requestAnimationFrame = (callback) => {
|
|
1185
|
-
const handle = queuedCallbacksEnd++;
|
|
1186
|
-
queuedCallbacks.push(callback);
|
|
1187
|
-
if (!flushRequested) {
|
|
1188
|
-
flushRequested = true;
|
|
1189
|
-
nativeRequestAnimationFrame((timestamp) => {
|
|
1190
|
-
flushRequested = false;
|
|
1191
|
-
globalThis.__frameTimestamp = timestamp;
|
|
1192
|
-
globalThis.__flushAnimationFrame(timestamp);
|
|
1193
|
-
globalThis.__frameTimestamp = void 0;
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
|
-
return handle;
|
|
1197
|
-
};
|
|
1198
|
-
globalThis.cancelAnimationFrame = (handle) => {
|
|
1199
|
-
if (handle < flushedCallbacksBegin || handle >= queuedCallbacksEnd) {
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
if (handle < flushedCallbacksEnd) {
|
|
1203
|
-
flushedCallbacks[handle - flushedCallbacksBegin] = () => {
|
|
1204
|
-
};
|
|
1205
|
-
} else {
|
|
1206
|
-
queuedCallbacks[handle - queuedCallbacksBegin] = () => {
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1209
|
-
};
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
// ../../node_modules/react-native-worklets/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js
|
|
1213
|
-
function setupSetTimeout() {
|
|
1214
|
-
"worklet";
|
|
1215
|
-
const timeoutHandleToRafHandle = /* @__PURE__ */ new Map();
|
|
1216
|
-
const setTimeoutPolyfill = (callback, delay = 0, ...args) => {
|
|
1217
|
-
const start = performance.now();
|
|
1218
|
-
let timeoutHandle = 0;
|
|
1219
|
-
const rafCallback = () => {
|
|
1220
|
-
const now = performance.now();
|
|
1221
|
-
if (now - start >= delay) {
|
|
1222
|
-
callback(...args);
|
|
1223
|
-
timeoutHandleToRafHandle.delete(timeoutHandle);
|
|
1224
|
-
} else {
|
|
1225
|
-
const rafHandle = requestAnimationFrame(rafCallback);
|
|
1226
|
-
timeoutHandleToRafHandle.set(timeoutHandle, rafHandle);
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
timeoutHandle = requestAnimationFrame(rafCallback);
|
|
1230
|
-
timeoutHandleToRafHandle.set(timeoutHandle, timeoutHandle);
|
|
1231
|
-
return timeoutHandle;
|
|
1232
|
-
};
|
|
1233
|
-
const clearTimeoutPolyfill = (timeoutHandle) => {
|
|
1234
|
-
const rafHandle = timeoutHandleToRafHandle.get(timeoutHandle);
|
|
1235
|
-
timeoutHandleToRafHandle.delete(timeoutHandle);
|
|
1236
|
-
cancelAnimationFrame(rafHandle);
|
|
1237
|
-
};
|
|
1238
|
-
globalThis.setTimeout = setTimeoutPolyfill;
|
|
1239
|
-
globalThis.clearTimeout = clearTimeoutPolyfill;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
// ../../node_modules/react-native-worklets/lib/module/synchronizableUnpacker.js
|
|
1243
|
-
function __installUnpacker() {
|
|
1244
|
-
const serializer = !globalThis._WORKLET || globalThis._WORKLETS_BUNDLE_MODE ? (value, _) => createSerializable(value) : globalThis._createSerializable;
|
|
1245
|
-
function synchronizableUnpacker(synchronizableRef) {
|
|
1246
|
-
const synchronizable = synchronizableRef;
|
|
1247
|
-
const proxy = globalThis.__workletsModuleProxy;
|
|
1248
|
-
synchronizable.__synchronizableRef = true;
|
|
1249
|
-
synchronizable.getDirty = () => {
|
|
1250
|
-
return proxy.synchronizableGetDirty(synchronizable);
|
|
1251
|
-
};
|
|
1252
|
-
synchronizable.getBlocking = () => {
|
|
1253
|
-
return proxy.synchronizableGetBlocking(synchronizable);
|
|
1254
|
-
};
|
|
1255
|
-
synchronizable.setBlocking = (valueOrFunction) => {
|
|
1256
|
-
let newValue;
|
|
1257
|
-
if (typeof valueOrFunction === "function") {
|
|
1258
|
-
const func = valueOrFunction;
|
|
1259
|
-
synchronizable.lock();
|
|
1260
|
-
const prev = synchronizable.getBlocking();
|
|
1261
|
-
newValue = func(prev);
|
|
1262
|
-
proxy.synchronizableSetBlocking(synchronizable, serializer(newValue, void 0));
|
|
1263
|
-
synchronizable.unlock();
|
|
1264
|
-
} else {
|
|
1265
|
-
const value = valueOrFunction;
|
|
1266
|
-
newValue = value;
|
|
1267
|
-
proxy.synchronizableSetBlocking(synchronizable, serializer(newValue, void 0));
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
synchronizable.lock = () => {
|
|
1271
|
-
proxy.synchronizableLock(synchronizable);
|
|
1272
|
-
};
|
|
1273
|
-
synchronizable.unlock = () => {
|
|
1274
|
-
proxy.synchronizableUnlock(synchronizable);
|
|
1275
|
-
};
|
|
1276
|
-
return synchronizable;
|
|
1277
|
-
}
|
|
1278
|
-
globalThis.__synchronizableUnpacker = synchronizableUnpacker;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
// ../../node_modules/react-native-worklets/lib/module/initializers.js
|
|
1282
|
-
var capturableConsole;
|
|
1283
|
-
function getMemorySafeCapturableConsole() {
|
|
1284
|
-
if (capturableConsole) {
|
|
1285
|
-
return capturableConsole;
|
|
1286
|
-
}
|
|
1287
|
-
const consoleCopy = Object.fromEntries(Object.entries(console).map(([methodName, method]) => {
|
|
1288
|
-
const methodWrapper = function methodWrapper2(...args) {
|
|
1289
|
-
return method(...args);
|
|
1290
|
-
};
|
|
1291
|
-
if (method.name) {
|
|
1292
|
-
Object.defineProperty(methodWrapper, "name", {
|
|
1293
|
-
value: method.name,
|
|
1294
|
-
writable: false
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
return [methodName, methodWrapper];
|
|
1298
|
-
}));
|
|
1299
|
-
capturableConsole = consoleCopy;
|
|
1300
|
-
return consoleCopy;
|
|
1301
|
-
}
|
|
1302
|
-
function setupConsole(boundCapturableConsole) {
|
|
1303
|
-
"worklet";
|
|
1304
|
-
globalThis.console = {
|
|
1305
|
-
assert: runOnJS(boundCapturableConsole.assert),
|
|
1306
|
-
debug: runOnJS(boundCapturableConsole.debug),
|
|
1307
|
-
log: runOnJS(boundCapturableConsole.log),
|
|
1308
|
-
warn: runOnJS(boundCapturableConsole.warn),
|
|
1309
|
-
error: runOnJS(boundCapturableConsole.error),
|
|
1310
|
-
info: runOnJS(boundCapturableConsole.info)
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
var initialized = false;
|
|
1314
|
-
function init() {
|
|
1315
|
-
if (initialized) {
|
|
1316
|
-
return;
|
|
1317
|
-
}
|
|
1318
|
-
initialized = true;
|
|
1319
|
-
if (globalThis.__RUNTIME_KIND === void 0) {
|
|
1320
|
-
globalThis.__RUNTIME_KIND = RuntimeKind.ReactNative;
|
|
1321
|
-
}
|
|
1322
|
-
initializeRuntime();
|
|
1323
|
-
if (SHOULD_BE_USE_WEB2) {
|
|
1324
|
-
initializeRuntimeOnWeb();
|
|
1325
|
-
}
|
|
1326
|
-
if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
|
|
1327
|
-
initializeWorkletRuntime();
|
|
1328
|
-
} else {
|
|
1329
|
-
initializeRNRuntime();
|
|
1330
|
-
if (!SHOULD_BE_USE_WEB2) {
|
|
1331
|
-
installRNBindingsOnUIRuntime();
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
function initializeRuntime() {
|
|
1336
|
-
if (globalThis._WORKLETS_BUNDLE_MODE) {
|
|
1337
|
-
globalThis.__valueUnpacker = bundleValueUnpacker;
|
|
1338
|
-
}
|
|
1339
|
-
__installUnpacker();
|
|
13
|
+
// src/motion/Image.tsx
|
|
14
|
+
var DEFAULT_MOTION_CONFIG = {
|
|
15
|
+
reducedMotion: "user"
|
|
16
|
+
};
|
|
17
|
+
var MotionConfigContext = react.createContext(
|
|
18
|
+
DEFAULT_MOTION_CONFIG
|
|
19
|
+
);
|
|
20
|
+
function useMotionConfig() {
|
|
21
|
+
return react.useContext(MotionConfigContext);
|
|
1340
22
|
}
|
|
1341
|
-
function
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
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.`);
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
registerReportFatalRemoteError();
|
|
23
|
+
function useShouldReduceMotion() {
|
|
24
|
+
const { reducedMotion } = useMotionConfig();
|
|
25
|
+
const osReduced = Animated.useReducedMotion();
|
|
26
|
+
if (reducedMotion === "never") return false;
|
|
27
|
+
if (reducedMotion === "always") return true;
|
|
28
|
+
return osReduced;
|
|
1351
29
|
}
|
|
1352
|
-
function
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
});
|
|
1362
|
-
globalThis.__r.Refresh = Refresh;
|
|
1363
|
-
const modules = __require.getModules();
|
|
1364
|
-
const ReactNativeModuleId = __require.resolveWeak("react-native");
|
|
1365
|
-
const factory = function(_global, _require, _importDefault, _importAll, module, _exports, _dependencyMap) {
|
|
1366
|
-
module.exports = new Proxy({}, {
|
|
1367
|
-
get: function get(_target, prop) {
|
|
1368
|
-
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.`);
|
|
1369
|
-
return {
|
|
1370
|
-
get() {
|
|
1371
|
-
return void 0;
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1375
|
-
});
|
|
1376
|
-
};
|
|
1377
|
-
const mod = {
|
|
1378
|
-
dependencyMap: [],
|
|
1379
|
-
factory,
|
|
1380
|
-
hasError: false,
|
|
1381
|
-
importedAll: {},
|
|
1382
|
-
importedDefault: {},
|
|
1383
|
-
isInitialized: false,
|
|
1384
|
-
publicModule: {
|
|
1385
|
-
exports: {}
|
|
1386
|
-
}
|
|
1387
|
-
};
|
|
1388
|
-
modules.set(ReactNativeModuleId, mod);
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
30
|
+
function MotionConfig({
|
|
31
|
+
reducedMotion = "user",
|
|
32
|
+
children
|
|
33
|
+
}) {
|
|
34
|
+
const value = react.useMemo(
|
|
35
|
+
() => ({ reducedMotion }),
|
|
36
|
+
[reducedMotion]
|
|
37
|
+
);
|
|
38
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MotionConfigContext.Provider, { value, children });
|
|
1391
39
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
if (IS_JEST2) {
|
|
1397
|
-
globalThis.requestAnimationFrame = mockedRequestAnimationFrame;
|
|
1398
|
-
}
|
|
40
|
+
var modality = "keyboard";
|
|
41
|
+
var installed = false;
|
|
42
|
+
function setKeyboard() {
|
|
43
|
+
modality = "keyboard";
|
|
1399
44
|
}
|
|
1400
|
-
function
|
|
1401
|
-
|
|
1402
|
-
throw new WorkletsError("Worklets are trying to initialize the UI runtime without a valid WorkletsModule");
|
|
1403
|
-
}
|
|
1404
|
-
const runtimeBoundCapturableConsole = getMemorySafeCapturableConsole();
|
|
1405
|
-
if (!globalThis._WORKLETS_BUNDLE_MODE) {
|
|
1406
|
-
executeOnUIRuntimeSync(setupCallGuard)();
|
|
1407
|
-
executeOnUIRuntimeSync(registerWorkletsError)();
|
|
1408
|
-
}
|
|
1409
|
-
executeOnUIRuntimeSync(() => {
|
|
1410
|
-
"worklet";
|
|
1411
|
-
setupConsole(runtimeBoundCapturableConsole);
|
|
1412
|
-
setupMicrotasks();
|
|
1413
|
-
setupRequestAnimationFrame();
|
|
1414
|
-
setupSetTimeout();
|
|
1415
|
-
setupSetImmediate();
|
|
1416
|
-
setupSetInterval();
|
|
1417
|
-
})();
|
|
45
|
+
function setPointer() {
|
|
46
|
+
modality = "pointer";
|
|
1418
47
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
if (
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
init();
|
|
1429
|
-
throw new WorkletsError("Worklets initialized successfully");
|
|
1430
|
-
}
|
|
48
|
+
function ensureInstalled() {
|
|
49
|
+
if (installed) return;
|
|
50
|
+
if (reactNative.Platform.OS !== "web") return;
|
|
51
|
+
if (typeof document === "undefined") return;
|
|
52
|
+
document.addEventListener("keydown", setKeyboard, true);
|
|
53
|
+
document.addEventListener("mousedown", setPointer, true);
|
|
54
|
+
document.addEventListener("pointerdown", setPointer, true);
|
|
55
|
+
document.addEventListener("touchstart", setPointer, true);
|
|
56
|
+
installed = true;
|
|
1431
57
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
EXAMPLE_DYNAMIC_FLAG: true,
|
|
1437
|
-
init() {
|
|
1438
|
-
Object.keys(DynamicFlags).forEach((key) => {
|
|
1439
|
-
if (key !== "init" && key !== "setFlag") {
|
|
1440
|
-
WorkletsModule.setDynamicFeatureFlag(key, DynamicFlags[key]);
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
},
|
|
1444
|
-
setFlag(name, value) {
|
|
1445
|
-
if (name in DynamicFlags) {
|
|
1446
|
-
DynamicFlags[name] = value;
|
|
1447
|
-
WorkletsModule.setDynamicFeatureFlag(name, value);
|
|
1448
|
-
} else {
|
|
1449
|
-
logger.warn(`The feature flag: '${name}' no longer exists, you can safely remove invocation of \`setDynamicFeatureFlag('${name}')\` from your code.`);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
};
|
|
1453
|
-
DynamicFlags.init();
|
|
1454
|
-
|
|
1455
|
-
// ../../node_modules/react-native-worklets/lib/module/index.js
|
|
1456
|
-
init();
|
|
1457
|
-
if (globalThis._ALWAYS_FALSE) {
|
|
1458
|
-
bundleModeInit();
|
|
58
|
+
function isFocusVisible() {
|
|
59
|
+
if (reactNative.Platform.OS !== "web") return true;
|
|
60
|
+
ensureInstalled();
|
|
61
|
+
return modality === "keyboard";
|
|
1459
62
|
}
|
|
1460
|
-
|
|
1461
|
-
// src/transitions/easing.ts
|
|
1462
63
|
function ensureWorkletEasing(easing) {
|
|
1463
64
|
if (!easing) return void 0;
|
|
1464
65
|
const fn = isEasingFactory(easing) ? easing.factory() : easing;
|
|
1465
|
-
if (isWorkletFunction(fn)) return fn;
|
|
66
|
+
if (reactNativeWorklets.isWorkletFunction(fn)) return fn;
|
|
1466
67
|
const wrapped = (t) => {
|
|
1467
68
|
"worklet";
|
|
1468
69
|
return fn(t);
|
|
@@ -1512,6 +113,157 @@ function resolveLayoutTransition(layout) {
|
|
|
1512
113
|
if ("delay" in spring && spring.delay) builder = builder.delay(spring.delay);
|
|
1513
114
|
return builder;
|
|
1514
115
|
}
|
|
116
|
+
|
|
117
|
+
// src/layout/sharedRegistry.ts
|
|
118
|
+
var REGISTRY = /* @__PURE__ */ new Map();
|
|
119
|
+
var SHARED_LAYOUT_TTL_MS = 1e3;
|
|
120
|
+
var now = () => Date.now();
|
|
121
|
+
function registerLayout(id, rect) {
|
|
122
|
+
REGISTRY.set(id, { rect, expiresAt: now() + SHARED_LAYOUT_TTL_MS });
|
|
123
|
+
}
|
|
124
|
+
function releaseLayout(id, rect) {
|
|
125
|
+
REGISTRY.set(id, { rect, expiresAt: now() + SHARED_LAYOUT_TTL_MS });
|
|
126
|
+
}
|
|
127
|
+
function consumeLayout(id) {
|
|
128
|
+
const entry = REGISTRY.get(id);
|
|
129
|
+
if (!entry) return void 0;
|
|
130
|
+
REGISTRY.delete(id);
|
|
131
|
+
if (entry.expiresAt < now()) return void 0;
|
|
132
|
+
return entry.rect;
|
|
133
|
+
}
|
|
134
|
+
function useSharedLayout(options) {
|
|
135
|
+
const { layoutId, userRef, transition, shouldReduceMotion, userOnLayout } = options;
|
|
136
|
+
const dx = Animated.useSharedValue(0);
|
|
137
|
+
const dy = Animated.useSharedValue(0);
|
|
138
|
+
const sx = Animated.useSharedValue(1);
|
|
139
|
+
const sy = Animated.useSharedValue(1);
|
|
140
|
+
const lastRectRef = react.useRef(null);
|
|
141
|
+
const consumedRef = react.useRef(false);
|
|
142
|
+
const transitionRef = react.useRef(transition);
|
|
143
|
+
transitionRef.current = transition;
|
|
144
|
+
const reducedMotionRef = react.useRef(shouldReduceMotion);
|
|
145
|
+
reducedMotionRef.current = shouldReduceMotion;
|
|
146
|
+
const setRef = react.useCallback(
|
|
147
|
+
(node) => {
|
|
148
|
+
if (typeof userRef === "function") userRef(node);
|
|
149
|
+
else if (userRef) userRef.current = node;
|
|
150
|
+
},
|
|
151
|
+
[userRef]
|
|
152
|
+
);
|
|
153
|
+
const onLayout = react.useCallback(
|
|
154
|
+
(event) => {
|
|
155
|
+
userOnLayout?.(event);
|
|
156
|
+
if (!layoutId) return;
|
|
157
|
+
const { x, y, width, height } = event.nativeEvent.layout;
|
|
158
|
+
const rect = { x, y, width, height };
|
|
159
|
+
lastRectRef.current = rect;
|
|
160
|
+
let source;
|
|
161
|
+
if (!consumedRef.current) {
|
|
162
|
+
consumedRef.current = true;
|
|
163
|
+
source = consumeLayout(layoutId);
|
|
164
|
+
}
|
|
165
|
+
registerLayout(layoutId, rect);
|
|
166
|
+
if (source) {
|
|
167
|
+
applyFlip({
|
|
168
|
+
source,
|
|
169
|
+
target: rect,
|
|
170
|
+
dx,
|
|
171
|
+
dy,
|
|
172
|
+
sx,
|
|
173
|
+
sy,
|
|
174
|
+
transition: transitionRef.current,
|
|
175
|
+
shouldReduceMotion: reducedMotionRef.current
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
// dx/dy/sx/sy are stable refs from useSharedValue, but eslint's
|
|
180
|
+
// exhaustive-deps would flag them — including them is harmless and
|
|
181
|
+
// silences the warning.
|
|
182
|
+
[layoutId, userOnLayout, dx, dy, sx, sy]
|
|
183
|
+
);
|
|
184
|
+
react.useEffect(() => {
|
|
185
|
+
consumedRef.current = false;
|
|
186
|
+
}, [layoutId]);
|
|
187
|
+
react.useEffect(() => {
|
|
188
|
+
return () => {
|
|
189
|
+
if (!layoutId) return;
|
|
190
|
+
const rect = lastRectRef.current;
|
|
191
|
+
if (!rect) return;
|
|
192
|
+
releaseLayout(layoutId, rect);
|
|
193
|
+
};
|
|
194
|
+
}, [layoutId]);
|
|
195
|
+
return react.useMemo(
|
|
196
|
+
() => ({
|
|
197
|
+
flip: { dx, dy, sx, sy },
|
|
198
|
+
setRef,
|
|
199
|
+
onLayout
|
|
200
|
+
}),
|
|
201
|
+
[dx, dy, sx, sy, setRef, onLayout]
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
function applyFlip(args) {
|
|
205
|
+
const { source, target, dx, dy, sx, sy, transition, shouldReduceMotion } = args;
|
|
206
|
+
const sourceCenterX = source.x + source.width / 2;
|
|
207
|
+
const sourceCenterY = source.y + source.height / 2;
|
|
208
|
+
const targetCenterX = target.x + target.width / 2;
|
|
209
|
+
const targetCenterY = target.y + target.height / 2;
|
|
210
|
+
const deltaX = sourceCenterX - targetCenterX;
|
|
211
|
+
const deltaY = sourceCenterY - targetCenterY;
|
|
212
|
+
const scaleX = target.width > 0 ? source.width / target.width : 1;
|
|
213
|
+
const scaleY = target.height > 0 ? source.height / target.height : 1;
|
|
214
|
+
if (shouldReduceMotion) {
|
|
215
|
+
dx.value = 0;
|
|
216
|
+
dy.value = 0;
|
|
217
|
+
sx.value = 1;
|
|
218
|
+
sy.value = 1;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (transition?.type === "no-animation") {
|
|
222
|
+
dx.value = 0;
|
|
223
|
+
dy.value = 0;
|
|
224
|
+
sx.value = 1;
|
|
225
|
+
sy.value = 1;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (transition?.type === "timing") {
|
|
229
|
+
const duration = transition.duration ?? 300;
|
|
230
|
+
dx.value = Animated.withSequence(
|
|
231
|
+
Animated.withTiming(deltaX, { duration: 0 }),
|
|
232
|
+
Animated.withTiming(0, { duration })
|
|
233
|
+
);
|
|
234
|
+
dy.value = Animated.withSequence(
|
|
235
|
+
Animated.withTiming(deltaY, { duration: 0 }),
|
|
236
|
+
Animated.withTiming(0, { duration })
|
|
237
|
+
);
|
|
238
|
+
sx.value = Animated.withSequence(
|
|
239
|
+
Animated.withTiming(scaleX, { duration: 0 }),
|
|
240
|
+
Animated.withTiming(1, { duration })
|
|
241
|
+
);
|
|
242
|
+
sy.value = Animated.withSequence(
|
|
243
|
+
Animated.withTiming(scaleY, { duration: 0 }),
|
|
244
|
+
Animated.withTiming(1, { duration })
|
|
245
|
+
);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const springCfg = transition?.type === "spring" ? { ...DEFAULT_SPRING, ...transition } : { ...DEFAULT_SPRING };
|
|
249
|
+
const springParams = springToReanimated(springCfg);
|
|
250
|
+
dx.value = Animated.withSequence(
|
|
251
|
+
Animated.withTiming(deltaX, { duration: 0 }),
|
|
252
|
+
Animated.withSpring(0, springParams)
|
|
253
|
+
);
|
|
254
|
+
dy.value = Animated.withSequence(
|
|
255
|
+
Animated.withTiming(deltaY, { duration: 0 }),
|
|
256
|
+
Animated.withSpring(0, springParams)
|
|
257
|
+
);
|
|
258
|
+
sx.value = Animated.withSequence(
|
|
259
|
+
Animated.withTiming(scaleX, { duration: 0 }),
|
|
260
|
+
Animated.withSpring(1, springParams)
|
|
261
|
+
);
|
|
262
|
+
sy.value = Animated.withSequence(
|
|
263
|
+
Animated.withTiming(scaleY, { duration: 0 }),
|
|
264
|
+
Animated.withSpring(1, springParams)
|
|
265
|
+
);
|
|
266
|
+
}
|
|
1515
267
|
var PresenceContext = react.createContext(null);
|
|
1516
268
|
function usePresence() {
|
|
1517
269
|
return react.useContext(PresenceContext);
|
|
@@ -1779,8 +531,6 @@ function stableStringify(v) {
|
|
|
1779
531
|
const keys = Object.keys(obj).sort();
|
|
1780
532
|
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
1781
533
|
}
|
|
1782
|
-
|
|
1783
|
-
// src/motion/installCheck.ts
|
|
1784
534
|
var alreadyChecked = false;
|
|
1785
535
|
function ensureReanimatedInstalled() {
|
|
1786
536
|
if (!__DEV__ || alreadyChecked) return;
|
|
@@ -1788,12 +538,7 @@ function ensureReanimatedInstalled() {
|
|
|
1788
538
|
return;
|
|
1789
539
|
}
|
|
1790
540
|
alreadyChecked = true;
|
|
1791
|
-
|
|
1792
|
-
try {
|
|
1793
|
-
const pkg = __require("react-native-reanimated/package.json");
|
|
1794
|
-
version = pkg.version;
|
|
1795
|
-
} catch {
|
|
1796
|
-
}
|
|
541
|
+
const version = Animated.reanimatedVersion;
|
|
1797
542
|
if (version) {
|
|
1798
543
|
const major = parseInt(version.split(".")[0] ?? "0", 10);
|
|
1799
544
|
if (major < 4) {
|
|
@@ -1913,10 +658,17 @@ function createMotionComponent(Component) {
|
|
|
1913
658
|
controller,
|
|
1914
659
|
gesture,
|
|
1915
660
|
layout,
|
|
661
|
+
layoutId,
|
|
1916
662
|
onAnimationEnd,
|
|
1917
663
|
style,
|
|
664
|
+
onLayout: userOnLayout,
|
|
1918
665
|
...rest
|
|
1919
666
|
} = props;
|
|
667
|
+
if (__DEV__ && typeof style === "function") {
|
|
668
|
+
throw new Error(
|
|
669
|
+
"[inertia] `style` must be a style object or array of style objects, not a function. The function-form `style={(state) => ...}` Pressable API is not supported \u2014 use `gesture.pressed` (or `gesture.focused`, etc.) to drive state-dependent styling instead."
|
|
670
|
+
);
|
|
671
|
+
}
|
|
1920
672
|
const presence = usePresence();
|
|
1921
673
|
const isExiting = presence !== null && presence.isPresent === false;
|
|
1922
674
|
const shouldReduceMotion = useShouldReduceMotion();
|
|
@@ -1935,37 +687,51 @@ function createMotionComponent(Component) {
|
|
|
1935
687
|
const [focused, setFocused] = react.useState(false);
|
|
1936
688
|
const [focusVisible, setFocusVisible] = react.useState(false);
|
|
1937
689
|
const [hovered, setHovered] = react.useState(false);
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
if (!variant) continue;
|
|
1946
|
-
collectTouchedKeys(touched, variant);
|
|
1947
|
-
}
|
|
690
|
+
const touched = /* @__PURE__ */ new Set();
|
|
691
|
+
collectTouchedKeys(touched, animateRecord);
|
|
692
|
+
if (initialRecord) collectTouchedKeys(touched, initialRecord);
|
|
693
|
+
if (variants) {
|
|
694
|
+
for (const variant of Object.values(variants)) {
|
|
695
|
+
if (!variant) continue;
|
|
696
|
+
collectTouchedKeys(touched, variant);
|
|
1948
697
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
698
|
+
}
|
|
699
|
+
if (gesture) {
|
|
700
|
+
for (const subState of [
|
|
701
|
+
gesture.pressed,
|
|
702
|
+
gesture.focused,
|
|
703
|
+
gesture.focusVisible,
|
|
704
|
+
gesture.hovered
|
|
705
|
+
]) {
|
|
706
|
+
if (!subState) continue;
|
|
707
|
+
collectTouchedKeys(touched, subState);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
if (exitRecord) collectTouchedKeys(touched, exitRecord);
|
|
711
|
+
const activeKeysRef = react.useRef(null);
|
|
712
|
+
const hasTransformRef = react.useRef(false);
|
|
713
|
+
const hasShadowOffsetRef = react.useRef(false);
|
|
714
|
+
const prevActive = activeKeysRef.current;
|
|
715
|
+
let grew = prevActive === null;
|
|
716
|
+
if (!grew && prevActive) {
|
|
717
|
+
for (const k of touched) {
|
|
718
|
+
if (!prevActive.includes(k)) {
|
|
719
|
+
grew = true;
|
|
720
|
+
break;
|
|
1958
721
|
}
|
|
1959
722
|
}
|
|
1960
|
-
if (exitRecord) collectTouchedKeys(touched, exitRecord);
|
|
1961
|
-
activeKeysRef.current = ALL_KEYS.filter((k) => touched.has(k));
|
|
1962
723
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
activeKeysRef.current.some(
|
|
1968
|
-
|
|
724
|
+
if (grew) {
|
|
725
|
+
const merged = new Set(prevActive ?? []);
|
|
726
|
+
for (const k of touched) merged.add(k);
|
|
727
|
+
activeKeysRef.current = ALL_KEYS.filter((k) => merged.has(k));
|
|
728
|
+
hasTransformRef.current = activeKeysRef.current.some(
|
|
729
|
+
(k) => TRANSFORM_KEY_SET.has(k)
|
|
730
|
+
);
|
|
731
|
+
hasShadowOffsetRef.current = activeKeysRef.current.some(
|
|
732
|
+
(k) => SHADOW_OFFSET_KEY_SET.has(k)
|
|
733
|
+
);
|
|
734
|
+
}
|
|
1969
735
|
const sharedValues = useAnimatableSharedValues((key) => {
|
|
1970
736
|
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
1971
737
|
const axis = shadowOffsetAxisFor(key);
|
|
@@ -2090,6 +856,15 @@ function createMotionComponent(Component) {
|
|
|
2090
856
|
isExiting,
|
|
2091
857
|
shouldReduceMotion
|
|
2092
858
|
);
|
|
859
|
+
const sharedLayout = useSharedLayout({
|
|
860
|
+
layoutId,
|
|
861
|
+
userRef: ref,
|
|
862
|
+
transition: isTopLevelTransition(transition) ? transition : void 0,
|
|
863
|
+
shouldReduceMotion,
|
|
864
|
+
userOnLayout
|
|
865
|
+
});
|
|
866
|
+
const flip = sharedLayout.flip;
|
|
867
|
+
const hasLayoutId = layoutId !== void 0;
|
|
2093
868
|
const animatedStyle = Animated.useAnimatedStyle(() => {
|
|
2094
869
|
const activeKeys = activeKeysRef.current;
|
|
2095
870
|
const hasTransform = hasTransformRef.current;
|
|
@@ -2138,7 +913,13 @@ function createMotionComponent(Component) {
|
|
|
2138
913
|
out[key] = v;
|
|
2139
914
|
}
|
|
2140
915
|
}
|
|
2141
|
-
if (
|
|
916
|
+
if (hasLayoutId) {
|
|
917
|
+
transform.push({ translateX: flip.dx.value });
|
|
918
|
+
transform.push({ translateY: flip.dy.value });
|
|
919
|
+
transform.push({ scaleX: flip.sx.value });
|
|
920
|
+
transform.push({ scaleY: flip.sy.value });
|
|
921
|
+
}
|
|
922
|
+
if (hasTransform || hasLayoutId) out.transform = transform;
|
|
2142
923
|
if (hasShadowOffset) {
|
|
2143
924
|
out.shadowOffset = { width: shadowOffsetW, height: shadowOffsetH };
|
|
2144
925
|
}
|
|
@@ -2165,9 +946,10 @@ function createMotionComponent(Component) {
|
|
|
2165
946
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2166
947
|
AnimatedComponent,
|
|
2167
948
|
{
|
|
2168
|
-
ref,
|
|
949
|
+
ref: sharedLayout.setRef,
|
|
2169
950
|
...rest,
|
|
2170
951
|
...gestureHandlers,
|
|
952
|
+
onLayout: sharedLayout.onLayout,
|
|
2171
953
|
layout: layoutTransition,
|
|
2172
954
|
style: mergedStyle
|
|
2173
955
|
}
|
|
@@ -2176,34 +958,34 @@ function createMotionComponent(Component) {
|
|
|
2176
958
|
Motion2.displayName = `Motion(${Component.displayName ?? Component.name ?? "Component"})`;
|
|
2177
959
|
return Motion2;
|
|
2178
960
|
}
|
|
2179
|
-
function useAnimatableSharedValues(
|
|
2180
|
-
const translateX = Animated.useSharedValue(
|
|
2181
|
-
const translateY = Animated.useSharedValue(
|
|
2182
|
-
const scale = Animated.useSharedValue(
|
|
2183
|
-
const scaleX = Animated.useSharedValue(
|
|
2184
|
-
const scaleY = Animated.useSharedValue(
|
|
2185
|
-
const rotate = Animated.useSharedValue(
|
|
2186
|
-
const rotateX = Animated.useSharedValue(
|
|
2187
|
-
const rotateY = Animated.useSharedValue(
|
|
2188
|
-
const opacity = Animated.useSharedValue(
|
|
2189
|
-
const width = Animated.useSharedValue(
|
|
2190
|
-
const height = Animated.useSharedValue(
|
|
2191
|
-
const borderRadius = Animated.useSharedValue(
|
|
2192
|
-
const shadowOpacity = Animated.useSharedValue(
|
|
2193
|
-
const shadowRadius = Animated.useSharedValue(
|
|
2194
|
-
const elevation = Animated.useSharedValue(
|
|
961
|
+
function useAnimatableSharedValues(init) {
|
|
962
|
+
const translateX = Animated.useSharedValue(init("translateX"));
|
|
963
|
+
const translateY = Animated.useSharedValue(init("translateY"));
|
|
964
|
+
const scale = Animated.useSharedValue(init("scale"));
|
|
965
|
+
const scaleX = Animated.useSharedValue(init("scaleX"));
|
|
966
|
+
const scaleY = Animated.useSharedValue(init("scaleY"));
|
|
967
|
+
const rotate = Animated.useSharedValue(init("rotate"));
|
|
968
|
+
const rotateX = Animated.useSharedValue(init("rotateX"));
|
|
969
|
+
const rotateY = Animated.useSharedValue(init("rotateY"));
|
|
970
|
+
const opacity = Animated.useSharedValue(init("opacity"));
|
|
971
|
+
const width = Animated.useSharedValue(init("width"));
|
|
972
|
+
const height = Animated.useSharedValue(init("height"));
|
|
973
|
+
const borderRadius = Animated.useSharedValue(init("borderRadius"));
|
|
974
|
+
const shadowOpacity = Animated.useSharedValue(init("shadowOpacity"));
|
|
975
|
+
const shadowRadius = Animated.useSharedValue(init("shadowRadius"));
|
|
976
|
+
const elevation = Animated.useSharedValue(init("elevation"));
|
|
2195
977
|
const backgroundColor = Animated.useSharedValue(
|
|
2196
|
-
|
|
978
|
+
init("backgroundColor")
|
|
2197
979
|
);
|
|
2198
|
-
const borderColor = Animated.useSharedValue(
|
|
2199
|
-
const color = Animated.useSharedValue(
|
|
2200
|
-
const tintColor = Animated.useSharedValue(
|
|
2201
|
-
const shadowColor = Animated.useSharedValue(
|
|
980
|
+
const borderColor = Animated.useSharedValue(init("borderColor"));
|
|
981
|
+
const color = Animated.useSharedValue(init("color"));
|
|
982
|
+
const tintColor = Animated.useSharedValue(init("tintColor"));
|
|
983
|
+
const shadowColor = Animated.useSharedValue(init("shadowColor"));
|
|
2202
984
|
const shadowOffsetWidth = Animated.useSharedValue(
|
|
2203
|
-
|
|
985
|
+
init("shadowOffsetWidth")
|
|
2204
986
|
);
|
|
2205
987
|
const shadowOffsetHeight = Animated.useSharedValue(
|
|
2206
|
-
|
|
988
|
+
init("shadowOffsetHeight")
|
|
2207
989
|
);
|
|
2208
990
|
const ref = react.useRef(null);
|
|
2209
991
|
if (ref.current === null) {
|
|
@@ -2496,6 +1278,57 @@ function useAnimation(target, transition) {
|
|
|
2496
1278
|
}, [target, cfgSig, shouldReduceMotion]);
|
|
2497
1279
|
return output;
|
|
2498
1280
|
}
|
|
1281
|
+
function useSpring(target, config) {
|
|
1282
|
+
const reanimConfig = react.useMemo(
|
|
1283
|
+
() => springToReanimated(config ?? {}),
|
|
1284
|
+
[
|
|
1285
|
+
config?.tension,
|
|
1286
|
+
config?.friction,
|
|
1287
|
+
config?.mass,
|
|
1288
|
+
config?.velocity,
|
|
1289
|
+
config?.restSpeedThreshold,
|
|
1290
|
+
config?.restDisplacementThreshold
|
|
1291
|
+
]
|
|
1292
|
+
);
|
|
1293
|
+
const isSharedTarget = isSharedValue(target);
|
|
1294
|
+
const initial = isSharedTarget ? target.value : target;
|
|
1295
|
+
const output = Animated.useSharedValue(initial);
|
|
1296
|
+
react.useEffect(() => {
|
|
1297
|
+
if (isSharedTarget) return;
|
|
1298
|
+
output.value = Animated.withSpring(target, reanimConfig);
|
|
1299
|
+
}, [isSharedTarget, target, reanimConfig]);
|
|
1300
|
+
Animated.useAnimatedReaction(
|
|
1301
|
+
() => {
|
|
1302
|
+
"worklet";
|
|
1303
|
+
if (!isSharedTarget) return null;
|
|
1304
|
+
return target.value;
|
|
1305
|
+
},
|
|
1306
|
+
(next, prev) => {
|
|
1307
|
+
"worklet";
|
|
1308
|
+
if (next === null || next === prev) return;
|
|
1309
|
+
output.value = Animated.withSpring(next, reanimConfig);
|
|
1310
|
+
},
|
|
1311
|
+
[isSharedTarget, reanimConfig]
|
|
1312
|
+
);
|
|
1313
|
+
return output;
|
|
1314
|
+
}
|
|
1315
|
+
function isSharedValue(v) {
|
|
1316
|
+
return typeof v === "object" && v !== null && "value" in v;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// src/values/useBooleanSpring.ts
|
|
1320
|
+
function useBooleanSpring(active, springConfig) {
|
|
1321
|
+
return useSpring(active ? 1 : 0, springConfig);
|
|
1322
|
+
}
|
|
1323
|
+
function useColorTransition(progress, range, options) {
|
|
1324
|
+
const key = options?.key ?? "backgroundColor";
|
|
1325
|
+
const from = range[0];
|
|
1326
|
+
const to = range[1];
|
|
1327
|
+
return Animated.useAnimatedStyle(() => {
|
|
1328
|
+
"worklet";
|
|
1329
|
+
return { [key]: Animated.interpolateColor(progress.value, [0, 1], [from, to]) };
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
2499
1332
|
function useGesture(transition) {
|
|
2500
1333
|
const pressed = Animated.useSharedValue(0);
|
|
2501
1334
|
const focused = Animated.useSharedValue(0);
|
|
@@ -2543,48 +1376,11 @@ function layerTransition(layer, transition) {
|
|
|
2543
1376
|
function useMotionValue(initial) {
|
|
2544
1377
|
return Animated.useSharedValue(initial);
|
|
2545
1378
|
}
|
|
2546
|
-
function useSpring(target, config) {
|
|
2547
|
-
const reanimConfig = react.useMemo(
|
|
2548
|
-
() => springToReanimated(config ?? {}),
|
|
2549
|
-
[
|
|
2550
|
-
config?.tension,
|
|
2551
|
-
config?.friction,
|
|
2552
|
-
config?.mass,
|
|
2553
|
-
config?.velocity,
|
|
2554
|
-
config?.restSpeedThreshold,
|
|
2555
|
-
config?.restDisplacementThreshold
|
|
2556
|
-
]
|
|
2557
|
-
);
|
|
2558
|
-
const isSharedTarget = isSharedValue(target);
|
|
2559
|
-
const initial = isSharedTarget ? target.value : target;
|
|
2560
|
-
const output = Animated.useSharedValue(initial);
|
|
2561
|
-
react.useEffect(() => {
|
|
2562
|
-
if (isSharedTarget) return;
|
|
2563
|
-
output.value = Animated.withSpring(target, reanimConfig);
|
|
2564
|
-
}, [isSharedTarget, target, reanimConfig]);
|
|
2565
|
-
Animated.useAnimatedReaction(
|
|
2566
|
-
() => {
|
|
2567
|
-
"worklet";
|
|
2568
|
-
if (!isSharedTarget) return null;
|
|
2569
|
-
return target.value;
|
|
2570
|
-
},
|
|
2571
|
-
(next, prev) => {
|
|
2572
|
-
"worklet";
|
|
2573
|
-
if (next === null || next === prev) return;
|
|
2574
|
-
output.value = Animated.withSpring(next, reanimConfig);
|
|
2575
|
-
},
|
|
2576
|
-
[isSharedTarget, reanimConfig]
|
|
2577
|
-
);
|
|
2578
|
-
return output;
|
|
2579
|
-
}
|
|
2580
|
-
function isSharedValue(v) {
|
|
2581
|
-
return typeof v === "object" && v !== null && "value" in v;
|
|
2582
|
-
}
|
|
2583
1379
|
function useTransform(arg1, inputRange, outputRange, options) {
|
|
2584
1380
|
let producer;
|
|
2585
1381
|
if (typeof arg1 === "function") {
|
|
2586
1382
|
const userFn = arg1;
|
|
2587
|
-
producer = isWorkletFunction(userFn) ? userFn : () => {
|
|
1383
|
+
producer = reactNativeWorklets.isWorkletFunction(userFn) ? userFn : () => {
|
|
2588
1384
|
"worklet";
|
|
2589
1385
|
return userFn();
|
|
2590
1386
|
};
|
|
@@ -2635,6 +1431,53 @@ function useScroll() {
|
|
|
2635
1431
|
onScroll: handler
|
|
2636
1432
|
};
|
|
2637
1433
|
}
|
|
1434
|
+
function useShadow({
|
|
1435
|
+
from,
|
|
1436
|
+
to,
|
|
1437
|
+
progress
|
|
1438
|
+
}) {
|
|
1439
|
+
const hasOpacity = from.shadowOpacity !== void 0 || to.shadowOpacity !== void 0;
|
|
1440
|
+
const hasRadius = from.shadowRadius !== void 0 || to.shadowRadius !== void 0;
|
|
1441
|
+
const hasElevation = from.elevation !== void 0 || to.elevation !== void 0;
|
|
1442
|
+
const hasColor = from.shadowColor !== void 0 || to.shadowColor !== void 0;
|
|
1443
|
+
const hasOffset = from.shadowOffset !== void 0 || to.shadowOffset !== void 0;
|
|
1444
|
+
const opacityFrom = from.shadowOpacity ?? 0;
|
|
1445
|
+
const opacityTo = to.shadowOpacity ?? 0;
|
|
1446
|
+
const radiusFrom = from.shadowRadius ?? 0;
|
|
1447
|
+
const radiusTo = to.shadowRadius ?? 0;
|
|
1448
|
+
const elevationFrom = from.elevation ?? 0;
|
|
1449
|
+
const elevationTo = to.elevation ?? 0;
|
|
1450
|
+
const colorFrom = from.shadowColor ?? "transparent";
|
|
1451
|
+
const colorTo = to.shadowColor ?? "transparent";
|
|
1452
|
+
const offsetWFrom = from.shadowOffset?.width ?? 0;
|
|
1453
|
+
const offsetWTo = to.shadowOffset?.width ?? 0;
|
|
1454
|
+
const offsetHFrom = from.shadowOffset?.height ?? 0;
|
|
1455
|
+
const offsetHTo = to.shadowOffset?.height ?? 0;
|
|
1456
|
+
return Animated.useAnimatedStyle(() => {
|
|
1457
|
+
"worklet";
|
|
1458
|
+
const t = progress.value;
|
|
1459
|
+
const out = {};
|
|
1460
|
+
if (hasOpacity) {
|
|
1461
|
+
out.shadowOpacity = Animated.interpolate(t, [0, 1], [opacityFrom, opacityTo]);
|
|
1462
|
+
}
|
|
1463
|
+
if (hasRadius) {
|
|
1464
|
+
out.shadowRadius = Animated.interpolate(t, [0, 1], [radiusFrom, radiusTo]);
|
|
1465
|
+
}
|
|
1466
|
+
if (hasElevation) {
|
|
1467
|
+
out.elevation = Animated.interpolate(t, [0, 1], [elevationFrom, elevationTo]);
|
|
1468
|
+
}
|
|
1469
|
+
if (hasColor) {
|
|
1470
|
+
out.shadowColor = Animated.interpolateColor(t, [0, 1], [colorFrom, colorTo]);
|
|
1471
|
+
}
|
|
1472
|
+
if (hasOffset) {
|
|
1473
|
+
out.shadowOffset = {
|
|
1474
|
+
width: Animated.interpolate(t, [0, 1], [offsetWFrom, offsetWTo]),
|
|
1475
|
+
height: Animated.interpolate(t, [0, 1], [offsetHFrom, offsetHTo])
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
return out;
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
2638
1481
|
function useVariants(variants, initial) {
|
|
2639
1482
|
const variantsRef = react.useRef(variants);
|
|
2640
1483
|
return react.useMemo(() => {
|
|
@@ -2682,11 +1525,14 @@ exports.ensureWorkletEasing = ensureWorkletEasing;
|
|
|
2682
1525
|
exports.resolveAnimatableValue = resolveAnimatableValue;
|
|
2683
1526
|
exports.resolveTransition = resolveTransition;
|
|
2684
1527
|
exports.useAnimation = useAnimation;
|
|
1528
|
+
exports.useBooleanSpring = useBooleanSpring;
|
|
1529
|
+
exports.useColorTransition = useColorTransition;
|
|
2685
1530
|
exports.useGesture = useGesture;
|
|
2686
1531
|
exports.useMotionConfig = useMotionConfig;
|
|
2687
1532
|
exports.useMotionValue = useMotionValue;
|
|
2688
1533
|
exports.usePresence = usePresence;
|
|
2689
1534
|
exports.useScroll = useScroll;
|
|
1535
|
+
exports.useShadow = useShadow;
|
|
2690
1536
|
exports.useShouldReduceMotion = useShouldReduceMotion;
|
|
2691
1537
|
exports.useSpring = useSpring;
|
|
2692
1538
|
exports.useTransform = useTransform;
|