diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h b/packages/react-native-reanimated/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h index efa186252f9a..e3f9f6d91413 100644 --- a/packages/react-native-reanimated/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +++ b/packages/react-native-reanimated/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include #include @@ -15,8 +15,10 @@ using namespace react; namespace reanimated { -using PropsMap = std::unordered_map>; -using ChildrenMap = std::unordered_map>; +using PropsMap = + std::unordered_map>; +using ChildrenMap = + std::unordered_map>; RootShadowNode::Unshared cloneShadowTreeWithNewProps( const RootShadowNode &oldRootNode, diff --git a/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp b/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp index 357e00548c74..990a24c25047 100644 --- a/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp +++ b/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp @@ -233,7 +233,10 @@ ShareableObject::ShareableObject( jsi::Value ShareableObject::toJSValue(jsi::Runtime &rt) { auto obj = jsi::Object(rt); for (size_t i = 0, size = data_.size(); i < size; i++) { - obj.setProperty(rt, jsi::String::createFromUtf8(rt, data_[i].first), data_[i].second->toJSValue(rt)); + obj.setProperty( + rt, + jsi::String::createFromUtf8(rt, data_[i].first), + data_[i].second->toJSValue(rt)); } #if SUPPORTS_NATIVE_STATE if (nativeState_ != nullptr) { diff --git a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp index 249d4bdd3888..19ee03210a11 100644 --- a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +++ b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp @@ -111,7 +111,8 @@ void WorkletRuntimeDecorator::decorate( for (size_t i = 0; i < argsSize; i++) { args[i] = argsArray.getValueAtIndex(rt, i); } - remoteFun.asObject(rt).asFunction(rt).call(rt, const_cast(args.data()), args.size()); + remoteFun.asObject(rt).asFunction(rt).call( + rt, const_cast(args.data()), args.size()); } }); }); diff --git a/packages/react-native-reanimated/src/Bezier.ts b/packages/react-native-reanimated/src/Bezier.ts index a352c17701f7..31ccf4683e71 100644 --- a/packages/react-native-reanimated/src/Bezier.ts +++ b/packages/react-native-reanimated/src/Bezier.ts @@ -1,7 +1,5 @@ 'use strict'; -import { logger } from './logger'; - /** * https://github.com/gre/bezier-easing * BezierEasing - use bezier curve for transition easing function diff --git a/packages/react-native-reanimated/src/ConfigHelper.ts b/packages/react-native-reanimated/src/ConfigHelper.ts index d667508cb8af..5c60594b3fe7 100644 --- a/packages/react-native-reanimated/src/ConfigHelper.ts +++ b/packages/react-native-reanimated/src/ConfigHelper.ts @@ -1,7 +1,7 @@ 'use strict'; import { PropsAllowlists } from './propsAllowlists'; import { jsiConfigureProps } from './core'; -import { logger } from './logger'; + function assertNoOverlapInLists() { for (const key in PropsAllowlists.NATIVE_THREAD_PROPS_WHITELIST) { if (key in PropsAllowlists.UI_THREAD_PROPS_WHITELIST) { diff --git a/packages/react-native-reanimated/src/NativeReanimated/NativeReanimated.ts b/packages/react-native-reanimated/src/NativeReanimated/NativeReanimated.ts index 21f571d23353..ae4eb9f4bc45 100644 --- a/packages/react-native-reanimated/src/NativeReanimated/NativeReanimated.ts +++ b/packages/react-native-reanimated/src/NativeReanimated/NativeReanimated.ts @@ -14,7 +14,6 @@ import type React from 'react'; import { getShadowNodeWrapperFromRef } from '../fabricUtils'; import type { LayoutAnimationBatchItem } from '../layoutReanimation/animationBuilder/commonTypes'; import ReanimatedModule from '../specs/NativeReanimatedModule'; -import { logger } from '../logger'; // this is the type of `__reanimatedModuleProxy` which is injected using JSI export interface NativeReanimatedModule { diff --git a/packages/react-native-reanimated/src/PropsRegistry.ts b/packages/react-native-reanimated/src/PropsRegistry.ts index e0c13fa774f9..7dd9ccd622dd 100644 --- a/packages/react-native-reanimated/src/PropsRegistry.ts +++ b/packages/react-native-reanimated/src/PropsRegistry.ts @@ -1,5 +1,5 @@ 'use strict'; -import { logger } from './logger'; + import { isFabric } from './PlatformChecker'; import { runOnUI } from './threads'; diff --git a/packages/react-native-reanimated/src/UpdateProps.ts b/packages/react-native-reanimated/src/UpdateProps.ts index d34f13978cb7..b8117ff7bf56 100644 --- a/packages/react-native-reanimated/src/UpdateProps.ts +++ b/packages/react-native-reanimated/src/UpdateProps.ts @@ -13,7 +13,6 @@ import type { ReanimatedHTMLElement } from './js-reanimated'; import { _updatePropsJS } from './js-reanimated'; import { isFabric, isJest, shouldBeUseWeb } from './PlatformChecker'; import { runOnUIImmediately } from './threads'; -import { logger } from './logger'; let updateProps: ( viewDescriptor: SharedValue, diff --git a/packages/react-native-reanimated/src/animation/clamp.ts b/packages/react-native-reanimated/src/animation/clamp.ts index 7af1653f4821..db08f1c0a29c 100644 --- a/packages/react-native-reanimated/src/animation/clamp.ts +++ b/packages/react-native-reanimated/src/animation/clamp.ts @@ -12,7 +12,6 @@ import type { ReduceMotion, } from '../commonTypes'; import type { ClampAnimation } from './commonTypes'; -import { logger } from '../logger'; type withClampType = ( config: { diff --git a/packages/react-native-reanimated/src/animation/decay/decay.ts b/packages/react-native-reanimated/src/animation/decay/decay.ts index 4cdbfb8d9935..ad60fa57550b 100644 --- a/packages/react-native-reanimated/src/animation/decay/decay.ts +++ b/packages/react-native-reanimated/src/animation/decay/decay.ts @@ -14,7 +14,6 @@ import type { InnerDecayAnimation, } from './utils'; import { rigidDecay } from './rigidDecay'; -import { logger } from '../../logger'; export type WithDecayConfig = DecayConfig; diff --git a/packages/react-native-reanimated/src/animation/sequence.ts b/packages/react-native-reanimated/src/animation/sequence.ts index 05077ca40399..73f94a50973c 100644 --- a/packages/react-native-reanimated/src/animation/sequence.ts +++ b/packages/react-native-reanimated/src/animation/sequence.ts @@ -8,7 +8,6 @@ import type { ReduceMotion, Timestamp, } from '../commonTypes'; -import { logger } from '../logger'; /** * Lets you run animations in a sequence. diff --git a/packages/react-native-reanimated/src/animation/springUtils.ts b/packages/react-native-reanimated/src/animation/springUtils.ts index fb8d29f72c8f..4ef7be4f8c10 100644 --- a/packages/react-native-reanimated/src/animation/springUtils.ts +++ b/packages/react-native-reanimated/src/animation/springUtils.ts @@ -5,7 +5,6 @@ import type { Timestamp, ReduceMotion, } from '../commonTypes'; -import { logger } from '../logger'; /** * Spring animation configuration. diff --git a/packages/react-native-reanimated/src/animation/transformationMatrix/matrixUtils.tsx b/packages/react-native-reanimated/src/animation/transformationMatrix/matrixUtils.tsx index 92aec5464767..5f9f867b7510 100644 --- a/packages/react-native-reanimated/src/animation/transformationMatrix/matrixUtils.tsx +++ b/packages/react-native-reanimated/src/animation/transformationMatrix/matrixUtils.tsx @@ -1,7 +1,5 @@ 'use strict'; -import { logger } from '../../logger'; - type FixedLengthArray< T, L extends number, diff --git a/packages/react-native-reanimated/src/animation/util.ts b/packages/react-native-reanimated/src/animation/util.ts index e69504dcd8f4..92741241c3a3 100644 --- a/packages/react-native-reanimated/src/animation/util.ts +++ b/packages/react-native-reanimated/src/animation/util.ts @@ -36,7 +36,6 @@ import { import { shouldBeUseWeb } from '../PlatformChecker'; import type { EasingFunctionFactory } from '../Easing'; import { ReducedMotionManager } from '../ReducedMotion'; -import { logger } from '../logger'; let IN_STYLE_UPDATER = false; const SHOULD_BE_USE_WEB = shouldBeUseWeb(); diff --git a/packages/react-native-reanimated/src/animationBuilder.tsx b/packages/react-native-reanimated/src/animationBuilder.tsx index 02f3892b7b7b..58909d25d0dd 100644 --- a/packages/react-native-reanimated/src/animationBuilder.tsx +++ b/packages/react-native-reanimated/src/animationBuilder.tsx @@ -6,7 +6,6 @@ import type { } from './layoutReanimation'; import type { StyleProps } from './commonTypes'; import type { NestedArray } from './createAnimatedComponent/commonTypes'; -import { logger } from './logger'; const mockTargetValues: LayoutAnimationsValues = { targetOriginX: 0, diff --git a/packages/react-native-reanimated/src/component/ReducedMotionConfig.tsx b/packages/react-native-reanimated/src/component/ReducedMotionConfig.tsx index ddc04fc1092d..d23c7c1b03e0 100644 --- a/packages/react-native-reanimated/src/component/ReducedMotionConfig.tsx +++ b/packages/react-native-reanimated/src/component/ReducedMotionConfig.tsx @@ -5,7 +5,6 @@ import { ReducedMotionManager, isReducedMotionEnabledInSystem, } from '../ReducedMotion'; -import { logger } from '../logger'; /** * A component that lets you overwrite default reduce motion behavior globally in your application. diff --git a/packages/react-native-reanimated/src/core.ts b/packages/react-native-reanimated/src/core.ts index 6b1ea318f60b..f0a3dd6c3f25 100644 --- a/packages/react-native-reanimated/src/core.ts +++ b/packages/react-native-reanimated/src/core.ts @@ -13,7 +13,6 @@ import { makeShareableCloneRecursive } from './shareables'; import { initializeUIRuntime } from './initializers'; import type { LayoutAnimationBatchItem } from './layoutReanimation/animationBuilder/commonTypes'; import { SensorContainer } from './SensorContainer'; -import { logger } from './logger'; export { startMapper, stopMapper } from './mappers'; export { runOnJS, runOnUI, executeOnUIRuntimeSync } from './threads'; diff --git a/packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx b/packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx index 0ef8e85d8866..d5982876ea09 100644 --- a/packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx +++ b/packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx @@ -50,7 +50,6 @@ import { addHTMLMutationObserver } from '../layoutReanimation/web/domUtils'; import { getViewInfo } from './getViewInfo'; import { NativeEventsManager } from './NativeEventsManager'; import type { ReanimatedHTMLElement } from '../js-reanimated'; -import { logger } from '../logger'; const IS_WEB = isWeb(); diff --git a/packages/react-native-reanimated/src/fabricUtils.web.ts b/packages/react-native-reanimated/src/fabricUtils.web.ts index 90da56ce288f..a5419aae45b8 100644 --- a/packages/react-native-reanimated/src/fabricUtils.web.ts +++ b/packages/react-native-reanimated/src/fabricUtils.web.ts @@ -1,7 +1,5 @@ 'use strict'; -import { logger } from './logger'; - export function getShadowNodeWrapperFromRef() { throw logger.newError('Trying to call `getShadowNodeWrapperFromRef` on web.'); } diff --git a/packages/react-native-reanimated/src/hook/useAnimatedStyle.ts b/packages/react-native-reanimated/src/hook/useAnimatedStyle.ts index 9e90f43adb2e..ae1fd0fe41f1 100644 --- a/packages/react-native-reanimated/src/hook/useAnimatedStyle.ts +++ b/packages/react-native-reanimated/src/hook/useAnimatedStyle.ts @@ -34,7 +34,6 @@ import type { AnimatedStyle, } from '../commonTypes'; import { isWorkletFunction } from '../commonTypes'; -import { logger } from '../logger'; const SHOULD_BE_USE_WEB = shouldBeUseWeb(); diff --git a/packages/react-native-reanimated/src/hook/utils.ts b/packages/react-native-reanimated/src/hook/utils.ts index 991843b24aae..c65531105bd7 100644 --- a/packages/react-native-reanimated/src/hook/utils.ts +++ b/packages/react-native-reanimated/src/hook/utils.ts @@ -1,6 +1,6 @@ 'use strict'; import type { WorkletFunction } from '../commonTypes'; -import { logger } from '../logger'; + import type { DependencyList } from './commonTypes'; // Builds one big hash from multiple worklets' hashes. diff --git a/packages/react-native-reanimated/src/interpolateColor.ts b/packages/react-native-reanimated/src/interpolateColor.ts index ebe51d8fbfbc..66c807c53d93 100644 --- a/packages/react-native-reanimated/src/interpolateColor.ts +++ b/packages/react-native-reanimated/src/interpolateColor.ts @@ -13,7 +13,6 @@ import { makeMutable } from './core'; import { Extrapolation, interpolate } from './interpolation'; import type { SharedValue } from './commonTypes'; import { useSharedValue } from './hook/useSharedValue'; -import { logger } from './logger'; /** * @deprecated Please use Extrapolation instead diff --git a/packages/react-native-reanimated/src/interpolation.ts b/packages/react-native-reanimated/src/interpolation.ts index 9da87bda3463..6763b29ebbb9 100644 --- a/packages/react-native-reanimated/src/interpolation.ts +++ b/packages/react-native-reanimated/src/interpolation.ts @@ -1,7 +1,5 @@ 'use strict'; -import { logger } from './logger'; - /** * Extrapolation type. * diff --git a/packages/react-native-reanimated/src/jestUtils.ts b/packages/react-native-reanimated/src/jestUtils.ts index 3729e4de1796..fb784d40ad95 100644 --- a/packages/react-native-reanimated/src/jestUtils.ts +++ b/packages/react-native-reanimated/src/jestUtils.ts @@ -9,7 +9,6 @@ import type { } from './createAnimatedComponent/commonTypes'; import { isJest } from './PlatformChecker'; import type { DefaultStyle } from './hook/commonTypes'; -import { logger } from './logger'; declare global { namespace jest { diff --git a/packages/react-native-reanimated/src/js-reanimated/JSReanimated.ts b/packages/react-native-reanimated/src/js-reanimated/JSReanimated.ts index 3d3f9b9bd0fb..75738c9ba994 100644 --- a/packages/react-native-reanimated/src/js-reanimated/JSReanimated.ts +++ b/packages/react-native-reanimated/src/js-reanimated/JSReanimated.ts @@ -10,7 +10,6 @@ import { SensorType } from '../commonTypes'; import type { WebSensor } from './WebSensor'; import { mockedRequestAnimationFrame } from '../mockedRequestAnimationFrame'; import type { WorkletRuntime } from '../runtimes'; -import { logger } from '../logger'; // In Node.js environments (like when static rendering with Expo Router) // requestAnimationFrame is unavailable, so we use our mock. diff --git a/packages/react-native-reanimated/src/js-reanimated/index.ts b/packages/react-native-reanimated/src/js-reanimated/index.ts index 0e4a0cc25c03..cba6e82b38d8 100644 --- a/packages/react-native-reanimated/src/js-reanimated/index.ts +++ b/packages/react-native-reanimated/src/js-reanimated/index.ts @@ -7,7 +7,6 @@ import { createTextShadowValue, } from './webUtils'; import { PropsAllowlists } from '../propsAllowlists'; -import { logger } from '../logger'; const reanimatedJS = new JSReanimated(); diff --git a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts index ced9c3727991..610df7bf2709 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts @@ -8,7 +8,6 @@ import type { import { ReduceMotion } from '../../commonTypes'; import { getReduceMotionFromConfig } from '../../animation/util'; -import { logger } from '../../logger'; export class BaseAnimationBuilder { durationV?: number; diff --git a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/Keyframe.ts b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/Keyframe.ts index 9df0e8c2e255..442db35744d1 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/Keyframe.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/animationBuilder/Keyframe.ts @@ -18,7 +18,6 @@ import { assertEasingIsWorklet, getReduceMotionFromConfig, } from '../../animation/util'; -import { logger } from '../../logger'; interface KeyframePoint { duration: number; diff --git a/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts b/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts index 510a0ba66eed..9420eb9bc945 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts @@ -7,7 +7,6 @@ import type { import { registerEventHandler, unregisterEventHandler } from '../../core'; import { Platform } from 'react-native'; import { isJest, shouldBeUseWeb } from '../../PlatformChecker'; -import { logger } from '../../logger'; type TransitionProgressEvent = { closing: number; diff --git a/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/SharedTransition.ts b/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/SharedTransition.ts index 3360e8f802dd..6b2702e5d82c 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/SharedTransition.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/sharedTransitions/SharedTransition.ts @@ -16,7 +16,6 @@ import { ReduceMotion } from '../../commonTypes'; import { ProgressTransitionManager } from './ProgressTransitionManager'; import { updateLayoutAnimations } from '../../UpdateLayoutAnimations'; import { getReduceMotionFromConfig } from '../../animation/util'; -import { logger } from '../../logger'; const SUPPORTED_PROPS = [ 'width', diff --git a/packages/react-native-reanimated/src/layoutReanimation/web/animationsManager.ts b/packages/react-native-reanimated/src/layoutReanimation/web/animationsManager.ts index 9c6f611339ff..6b354ef7e868 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/web/animationsManager.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/web/animationsManager.ts @@ -30,7 +30,6 @@ import { Keyframe } from '../animationBuilder'; import { makeElementVisible } from './componentStyle'; import { EasingNameSymbol } from '../../Easing'; import type { ReanimatedHTMLElement } from '../../js-reanimated'; -import { logger } from '../../logger'; function chooseConfig>( animationType: LayoutAnimationType, diff --git a/packages/react-native-reanimated/src/layoutReanimation/web/componentUtils.ts b/packages/react-native-reanimated/src/layoutReanimation/web/componentUtils.ts index e9ba6d71bd3c..8db5720d0642 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/web/componentUtils.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/web/componentUtils.ts @@ -23,7 +23,6 @@ import { Keyframe } from '../animationBuilder'; import { ReducedMotionManager } from '../../ReducedMotion'; import { prepareCurvedTransition } from './transition/Curved.web'; import { EasingNameSymbol } from '../../Easing'; -import { logger } from '../../logger'; function getEasingFromConfig(config: CustomConfig): string { if (!config.easingV) { diff --git a/packages/react-native-reanimated/src/layoutReanimation/web/domUtils.ts b/packages/react-native-reanimated/src/layoutReanimation/web/domUtils.ts index 9e21d9a947a3..2457cd5436e3 100644 --- a/packages/react-native-reanimated/src/layoutReanimation/web/domUtils.ts +++ b/packages/react-native-reanimated/src/layoutReanimation/web/domUtils.ts @@ -1,7 +1,7 @@ 'use strict'; import type { ReanimatedHTMLElement } from '../../js-reanimated'; -import { logger } from '../../logger'; + import { isWindowAvailable } from '../../PlatformChecker'; import { setElementPosition, snapshots } from './componentStyle'; import { Animations } from './config'; diff --git a/packages/react-native-reanimated/src/logger/index.ts b/packages/react-native-reanimated/src/logger/index.ts deleted file mode 100644 index 2c08d7295af8..000000000000 --- a/packages/react-native-reanimated/src/logger/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -export { logger } from './logger'; diff --git a/packages/react-native-reanimated/src/logger/logger.ts b/packages/react-native-reanimated/src/logger/logger.ts index 5f063000ae33..58170f1b1592 100644 --- a/packages/react-native-reanimated/src/logger/logger.ts +++ b/packages/react-native-reanimated/src/logger/logger.ts @@ -72,4 +72,4 @@ function createLogger(prefix: string) { }; } -export const logger = createLogger('[Reanimated]'); +global.logger = createLogger('[Reanimated]'); diff --git a/packages/react-native-reanimated/src/mutables.ts b/packages/react-native-reanimated/src/mutables.ts index 02d698fcea7f..8ca7de3ca243 100644 --- a/packages/react-native-reanimated/src/mutables.ts +++ b/packages/react-native-reanimated/src/mutables.ts @@ -1,7 +1,7 @@ 'use strict'; import { shouldBeUseWeb } from './PlatformChecker'; import type { Mutable } from './commonTypes'; -import { logger } from './logger'; + import { shareableMappingCache } from './shareableMappingCache'; import { makeShareableCloneRecursive } from './shareables'; import { executeOnUIRuntimeSync, runOnUI } from './threads'; diff --git a/packages/react-native-reanimated/src/platform-specific/checkCppVersion.ts b/packages/react-native-reanimated/src/platform-specific/checkCppVersion.ts index e04f696307d5..701d229e4e1a 100644 --- a/packages/react-native-reanimated/src/platform-specific/checkCppVersion.ts +++ b/packages/react-native-reanimated/src/platform-specific/checkCppVersion.ts @@ -1,5 +1,5 @@ 'use strict'; -import { logger } from '../logger'; + import { jsVersion } from './jsVersion'; export function checkCppVersion() { diff --git a/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts b/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts index 6061b9232258..f4d8826fd6d0 100644 --- a/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts +++ b/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.ts @@ -12,7 +12,6 @@ import type { AnimatedRefOnUI, } from '../hook/commonTypes'; import type { Component } from 'react'; -import { logger } from '../logger'; type DispatchCommand = ( animatedRef: AnimatedRef, diff --git a/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.web.ts b/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.web.ts index a84a16bfef39..31a4670d335a 100644 --- a/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.web.ts +++ b/packages/react-native-reanimated/src/platformFunctions/dispatchCommand.web.ts @@ -1,7 +1,5 @@ 'use strict'; -import { logger } from '../logger'; - export function dispatchCommand() { logger.warn('dispatchCommand() is not supported on web.'); } diff --git a/packages/react-native-reanimated/src/platformFunctions/measure.ts b/packages/react-native-reanimated/src/platformFunctions/measure.ts index 5058ab432127..9527afefda14 100644 --- a/packages/react-native-reanimated/src/platformFunctions/measure.ts +++ b/packages/react-native-reanimated/src/platformFunctions/measure.ts @@ -12,7 +12,6 @@ import type { AnimatedRefOnUI, } from '../hook/commonTypes'; import type { Component } from 'react'; -import { logger } from '../logger'; type Measure = ( animatedRef: AnimatedRef diff --git a/packages/react-native-reanimated/src/platformFunctions/measure.web.ts b/packages/react-native-reanimated/src/platformFunctions/measure.web.ts index 4ad476f1fed9..9a0c0a6592af 100644 --- a/packages/react-native-reanimated/src/platformFunctions/measure.web.ts +++ b/packages/react-native-reanimated/src/platformFunctions/measure.web.ts @@ -2,7 +2,6 @@ import type { MeasuredDimensions } from '../commonTypes'; import type { AnimatedRef } from '../hook/commonTypes'; import type { Component } from 'react'; -import { logger } from '../logger'; export function measure( animatedRef: AnimatedRef diff --git a/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts b/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts index 808231deb006..7dc24cdcbe49 100644 --- a/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts +++ b/packages/react-native-reanimated/src/platformFunctions/scrollTo.ts @@ -12,7 +12,6 @@ import type { AnimatedRefOnUI, } from '../hook/commonTypes'; import type { Component } from 'react'; -import { logger } from '../logger'; type ScrollTo = ( animatedRef: AnimatedRef, diff --git a/packages/react-native-reanimated/src/platformFunctions/setGestureState.ts b/packages/react-native-reanimated/src/platformFunctions/setGestureState.ts index e3bf4cd24da1..f197f3d20639 100644 --- a/packages/react-native-reanimated/src/platformFunctions/setGestureState.ts +++ b/packages/react-native-reanimated/src/platformFunctions/setGestureState.ts @@ -1,5 +1,5 @@ 'use strict'; -import { logger } from '../logger'; + import { isChromeDebugger, isJest, shouldBeUseWeb } from '../PlatformChecker'; type SetGestureState = (handlerTag: number, newState: number) => void; diff --git a/packages/react-native-reanimated/src/platformFunctions/setGestureState.web.ts b/packages/react-native-reanimated/src/platformFunctions/setGestureState.web.ts index 441be7ed41e6..5291142f0e20 100644 --- a/packages/react-native-reanimated/src/platformFunctions/setGestureState.web.ts +++ b/packages/react-native-reanimated/src/platformFunctions/setGestureState.web.ts @@ -1,7 +1,5 @@ 'use strict'; -import { logger } from '../logger'; - export function setGestureState() { logger.warn('setGestureState() is not available on web.'); } diff --git a/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts b/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts index 277dfab3eed4..973f1083c0e4 100644 --- a/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts +++ b/packages/react-native-reanimated/src/platformFunctions/setNativeProps.ts @@ -13,7 +13,6 @@ import type { } from '../hook/commonTypes'; import type { Component } from 'react'; import { processColorsInProps } from '../Colors'; -import { logger } from '../logger'; type SetNativeProps = ( animatedRef: AnimatedRef, diff --git a/packages/react-native-reanimated/src/publicGlobals.ts b/packages/react-native-reanimated/src/publicGlobals.ts index 1feeb70dd5fc..2d14ab6580d9 100644 --- a/packages/react-native-reanimated/src/publicGlobals.ts +++ b/packages/react-native-reanimated/src/publicGlobals.ts @@ -21,4 +21,16 @@ declare global { * which is the Reanimated UI runtime. */ var _WORKLET_RUNTIME: ArrayBuffer; + + /** + * Logger is set as a global variable for easier usage without the + * necessity of importing it in every file. It also caused circular + * dependencies as it imports runOnJS. + */ + var logger: { + warn: (message: string) => void; + error: (message: string) => void; + fatal: (message: string) => void; + newError: (message: string) => never; + }; } diff --git a/packages/react-native-reanimated/src/runtimes.ts b/packages/react-native-reanimated/src/runtimes.ts index e51d5c0279e0..c737cef68daa 100644 --- a/packages/react-native-reanimated/src/runtimes.ts +++ b/packages/react-native-reanimated/src/runtimes.ts @@ -2,7 +2,7 @@ import { isWorkletFunction } from './commonTypes'; import type { WorkletFunction } from './commonTypes'; import { setupCallGuard, setupConsole } from './initializers'; -import { logger } from './logger'; + import NativeReanimatedModule from './NativeReanimated'; import { shouldBeUseWeb } from './PlatformChecker'; import { diff --git a/packages/react-native-reanimated/src/screenTransition/RNScreensTurboModule.ts b/packages/react-native-reanimated/src/screenTransition/RNScreensTurboModule.ts index 194325fe45aa..f92a9f16ff14 100644 --- a/packages/react-native-reanimated/src/screenTransition/RNScreensTurboModule.ts +++ b/packages/react-native-reanimated/src/screenTransition/RNScreensTurboModule.ts @@ -1,5 +1,5 @@ 'use strict'; -import { logger } from '../logger'; + import type { RNScreensTurboModuleType } from './commonTypes'; function noopFactory(defaultReturnValue?: T): () => T { diff --git a/packages/react-native-reanimated/src/shareables.ts b/packages/react-native-reanimated/src/shareables.ts index 235f35c9b69d..0a3d32aee9c1 100644 --- a/packages/react-native-reanimated/src/shareables.ts +++ b/packages/react-native-reanimated/src/shareables.ts @@ -70,8 +70,8 @@ const INACCESSIBLE_OBJECT = { ); }, set: () => { - throw new Error( - '[Reanimated] Trying to write to an object which cannot be sent to the UI runtime.' + throw logger.newError( + 'Trying to write to an object which cannot be sent to the UI runtime.' ); }, } @@ -116,8 +116,8 @@ export function makeShareableCloneRecursive( if (depth === DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) { processedObjectAtThresholdDepth = value; } else if (value === processedObjectAtThresholdDepth) { - throw new Error( - '[Reanimated] Trying to convert a cyclic object to a shareable. This is not supported.' + throw logger.newError( + 'Trying to convert a cyclic object to a shareable. This is not supported.' ); } } else { diff --git a/packages/react-native-reanimated/src/threads.ts b/packages/react-native-reanimated/src/threads.ts index dd8ff2f4ec65..77b43ccdb250 100644 --- a/packages/react-native-reanimated/src/threads.ts +++ b/packages/react-native-reanimated/src/threads.ts @@ -76,12 +76,12 @@ export function runOnUI( ): (...args: Args) => void { 'worklet'; if (__DEV__ && !SHOULD_BE_USE_WEB && _WORKLET) { - throw new Error( - '[Reanimated] `runOnUI` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.' + throw logger.newError( + '`runOnUI` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.' ); } if (__DEV__ && !SHOULD_BE_USE_WEB && !isWorkletFunction(worklet)) { - throw new Error('[Reanimated] `runOnUI` can only be used on worklets.'); + throw logger.newError('`runOnUI` can only be used on worklets.'); } return (...args) => { if (IS_JEST) { @@ -162,14 +162,12 @@ export function runOnUIImmediately( ): (...args: Args) => void { 'worklet'; if (__DEV__ && !SHOULD_BE_USE_WEB && _WORKLET) { - throw new Error( - '[Reanimated] `runOnUIImmediately` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.' + throw logger.newError( + '`runOnUIImmediately` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.' ); } if (__DEV__ && !SHOULD_BE_USE_WEB && !isWorkletFunction(worklet)) { - throw new Error( - '[Reanimated] `runOnUIImmediately` can only be used on worklets.' - ); + throw logger.newError('`runOnUIImmediately` can only be used on worklets.'); } return (...args) => { NativeReanimatedModule.scheduleOnUI( diff --git a/packages/react-native-reanimated/src/valueUnpacker.ts b/packages/react-native-reanimated/src/valueUnpacker.ts index 26e8dbe356f5..107f4483fc22 100644 --- a/packages/react-native-reanimated/src/valueUnpacker.ts +++ b/packages/react-native-reanimated/src/valueUnpacker.ts @@ -64,14 +64,14 @@ function valueUnpacker( const label = remoteFunctionName ? `function \`${remoteFunctionName}\`` : 'anonymous function'; - throw new Error(`[Reanimated] Tried to synchronously call a non-worklet ${label} on the UI thread. + throw logger.newError(`Tried to synchronously call a non-worklet ${label} on the UI thread. 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.`); }; fun.__remoteFunction = objectToUnpack; return fun; } else { - throw new Error( - `[Reanimated] Data type in category "${category}" not recognized by value unpacker: "${_toString( + throw logger.newError( + `Data type in category "${category}" not recognized by value unpacker: "${_toString( objectToUnpack )}".` ); @@ -88,19 +88,19 @@ if (__DEV__ && !shouldBeUseWeb()) { 'worklet'; }) as WorkletFunction<[], void>; if (!isWorkletFunction(testWorklet)) { - throw new Error( - `[Reanimated] Failed to create a worklet. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#failed-to-create-a-worklet for more details.` + throw logger.newError( + `Failed to create a worklet. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#failed-to-create-a-worklet for more details.` ); } if (!isWorkletFunction(valueUnpacker)) { - throw new Error('[Reanimated] `valueUnpacker` is not a worklet'); + throw logger.newError('`valueUnpacker` is not a worklet'); } const closure = (valueUnpacker as ValueUnpacker).__closure; if (closure === undefined) { - throw new Error('[Reanimated] `valueUnpacker` closure is undefined'); + throw logger.newError('`valueUnpacker` closure is undefined'); } if (Object.keys(closure).length !== 0) { - throw new Error('[Reanimated] `valueUnpacker` must have empty closure'); + throw logger.newError('`valueUnpacker` must have empty closure'); } }