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