react-native-reanimated
Version:
More powerful alternative to Animated library for React Native.
106 lines (97 loc) • 3.45 kB
JavaScript
;
import { logger } from "./common/index.js";
/**
* @deprecated Please use [`createSerializable` from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/memory/createSerializable/)
* instead.
*
* See the [migration
* guide](https://docs.swmansion.com/react-native-reanimated/docs/guides/migration-from-3.x/)
* for more details.
*/
export const makeShareableCloneRecursive = value => value;
/**
* @deprecated Please import [`createWorkletRuntime` directly from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/threading/createWorkletRuntime/)
* instead of `react-native-reanimated`.
*/
export const createWorkletRuntime = () => {
throw new Error('[Reanimated] `createWorkletRuntime` is not supported on web.');
};
/**
* @deprecated Please use [`runOnUISync` from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/threading/scheduleOnRN/)
* instead.
*
* See the [migration
* guide](https://docs.swmansion.com/react-native-reanimated/docs/guides/migration-from-3.x/)
* for more details.
*/
export const executeOnUIRuntimeSync = () => {
throw new Error('[Reanimated] `executeOnUIRuntimeSync` is not supported on web.');
};
/**
* @deprecated Please use [`scheduleOnRN` from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/threading/scheduleOnRN/)
* instead.
*
* See the [migration
* guide](https://docs.swmansion.com/react-native-reanimated/docs/guides/migration-from-3.x/)
* for more details.
*/
export const runOnJS = fun => (...args) => queueMicrotask(() => fun(...args));
/**
* @deprecated Please use [`scheduleOnUI` from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/threading/scheduleOnUI/)
* instead.
*
* See the [migration
* guide](https://docs.swmansion.com/react-native-reanimated/docs/guides/migration-from-3.x/)
* for more details.
*/
export const runOnUI = worklet => (...args) => {
uiJobs.push(() => worklet(...args));
if (uiJobs.length === 1) {
queueMicrotask(flushUIJobs);
}
};
/**
* @deprecated Please use [`scheduleOnRuntime` from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/threading/scheduleOnRuntime/)
* instead.
*
* See the [migration
* guide](https://docs.swmansion.com/react-native-reanimated/docs/guides/migration-from-3.x/)
* for more details.
*/
export const runOnRuntime = () => {
throw new Error('[Reanimated] `runOnRuntime` is not supported on web.');
};
/**
* @deprecated Please import `WorkletRuntime` directly from
* `react-native-worklets` instead of `react-native-reanimated`.
*/
/**
* @deprecated Please import [`isWorkletFunction` directly from
* `react-native-worklets`](https://docs.swmansion.com/react-native-worklets/docs/utility/isWorkletFunction/)
* instead of `react-native-reanimated`.
*/
export const isWorkletFunction = value => typeof value === 'function' && !!value.__workletHash;
let uiJobs = [];
function flushUIJobs() {
const jobs = uiJobs;
uiJobs = [];
requestAnimationFrame(() => {
for (const job of jobs) {
runUIJob(job);
}
});
}
function runUIJob(job) {
try {
job();
} catch (error) {
logger.error(error instanceof Error ? error.stack ?? error.message : String(error));
}
}
//# sourceMappingURL=workletFunctions.js.map