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