diff --git a/packages/react-native/Libraries/Animated/AnimatedEvent.js b/packages/react-native/Libraries/Animated/AnimatedEvent.js index 6c22b9ca557..b3a5e9698cf 100644 --- a/packages/react-native/Libraries/Animated/AnimatedEvent.js +++ b/packages/react-native/Libraries/Animated/AnimatedEvent.js @@ -29,7 +29,7 @@ export type EventConfig = { platformConfig?: PlatformConfig, }; -export function attachNativeEvent( +export function attachNativeEventImpl( viewRef: any, eventName: string, argMapping: $ReadOnlyArray, @@ -181,7 +181,7 @@ export class AnimatedEvent { 'Only native driven events need to be attached.', ); - this._attachedEvent = attachNativeEvent( + this._attachedEvent = attachNativeEventImpl( viewRef, eventName, this._argMapping, diff --git a/packages/react-native/Libraries/Animated/AnimatedImplementation.js b/packages/react-native/Libraries/Animated/AnimatedImplementation.js index 62d2a3afb57..cdff0a30480 100644 --- a/packages/react-native/Libraries/Animated/AnimatedImplementation.js +++ b/packages/react-native/Libraries/Animated/AnimatedImplementation.js @@ -20,7 +20,7 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation'; import type {SpringAnimationConfig} from './animations/SpringAnimation'; import type {TimingAnimationConfig} from './animations/TimingAnimation'; -import {AnimatedEvent, attachNativeEvent} from './AnimatedEvent'; +import {AnimatedEvent, attachNativeEventImpl} from './AnimatedEvent'; import DecayAnimation from './animations/DecayAnimation'; import SpringAnimation from './animations/SpringAnimation'; import TimingAnimation from './animations/TimingAnimation'; @@ -47,39 +47,39 @@ export type CompositeAnimation = { ... }; -const add = function ( +const addImpl = function ( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedAddition { return new AnimatedAddition(a, b); }; -const subtract = function ( +const subtractImpl = function ( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedSubtraction { return new AnimatedSubtraction(a, b); }; -const divide = function ( +const divideImpl = function ( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedDivision { return new AnimatedDivision(a, b); }; -const multiply = function ( +const multiplyImpl = function ( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedMultiplication { return new AnimatedMultiplication(a, b); }; -const modulo = function (a: AnimatedNode, modulus: number): AnimatedModulo { +const moduloImpl = function (a: AnimatedNode, modulus: number): AnimatedModulo { return new AnimatedModulo(a, modulus); }; -const diffClamp = function ( +const diffClampImpl = function ( a: AnimatedNode, min: number, max: number, @@ -120,7 +120,7 @@ const maybeVectorAnim = function ( const aY = anim((value: AnimatedValueXY).y, configY); // We use `stopTogether: false` here because otherwise tracking will break // because the second animation will get stopped before it can update. - return parallel([aX, aY], {stopTogether: false}); + return parallelImpl([aX, aY], {stopTogether: false}); } else if (value instanceof AnimatedColor) { const configR = {...config}; const configG = {...config}; @@ -146,12 +146,12 @@ const maybeVectorAnim = function ( const aA = anim((value: AnimatedColor).a, configA); // We use `stopTogether: false` here because otherwise tracking will break // because the second animation will get stopped before it can update. - return parallel([aR, aG, aB, aA], {stopTogether: false}); + return parallelImpl([aR, aG, aB, aA], {stopTogether: false}); } return null; }; -const spring = function ( +const springImpl = function ( value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: SpringAnimationConfig, ): CompositeAnimation { @@ -179,7 +179,7 @@ const spring = function ( } }; return ( - maybeVectorAnim(value, config, spring) || { + maybeVectorAnim(value, config, springImpl) || { start: function (callback?: ?EndCallback): void { start(value, config, callback); }, @@ -204,7 +204,7 @@ const spring = function ( ); }; -const timing = function ( +const timingImpl = function ( value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: TimingAnimationConfig, ): CompositeAnimation { @@ -233,7 +233,7 @@ const timing = function ( }; return ( - maybeVectorAnim(value, config, timing) || { + maybeVectorAnim(value, config, timingImpl) || { start: function (callback?: ?EndCallback, isLooping?: boolean): void { start(value, {...config, isLooping}, callback); }, @@ -258,7 +258,7 @@ const timing = function ( ); }; -const decay = function ( +const decayImpl = function ( value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: DecayAnimationConfig, ): CompositeAnimation { @@ -275,7 +275,7 @@ const decay = function ( }; return ( - maybeVectorAnim(value, config, decay) || { + maybeVectorAnim(value, config, decayImpl) || { start: function (callback?: ?EndCallback): void { start(value, config, callback); }, @@ -300,7 +300,7 @@ const decay = function ( ); }; -const sequence = function ( +const sequenceImpl = function ( animations: Array, ): CompositeAnimation { let current = 0; @@ -363,7 +363,7 @@ type ParallelConfig = { stopTogether?: boolean, ... }; -const parallel = function ( +const parallelImpl = function ( animations: Array, config?: ?ParallelConfig, ): CompositeAnimation { @@ -431,9 +431,9 @@ const parallel = function ( return result; }; -const delay = function (time: number): CompositeAnimation { +const delayImpl = function (time: number): CompositeAnimation { // Would be nice to make a specialized implementation - return timing(new AnimatedValue(0), { + return timingImpl(new AnimatedValue(0), { toValue: 0, delay: time, duration: 0, @@ -441,13 +441,13 @@ const delay = function (time: number): CompositeAnimation { }); }; -const stagger = function ( +const staggerImpl = function ( time: number, animations: Array, ): CompositeAnimation { - return parallel( + return parallelImpl( animations.map((animation, i) => { - return sequence([delay(time * i), animation]); + return sequenceImpl([delayImpl(time * i), animation]); }), ); }; @@ -458,7 +458,7 @@ type LoopAnimationConfig = { ... }; -const loop = function ( +const loopImpl = function ( animation: CompositeAnimation, // $FlowFixMe[prop-missing] {iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {}, @@ -514,7 +514,7 @@ const loop = function ( }; }; -function forkEvent( +function forkEventImpl( event: ?AnimatedEvent | ?Function, listener: Function, ): AnimatedEvent | Function { @@ -531,7 +531,7 @@ function forkEvent( } } -function unforkEvent( +function unforkEventImpl( event: ?AnimatedEvent | ?Function, listener: Function, ): void { @@ -540,7 +540,7 @@ function unforkEvent( } } -const event = function ( +const eventImpl = function ( argMapping: $ReadOnlyArray, config: EventConfig, ): any { @@ -606,25 +606,25 @@ export default { * See https://reactnative.dev/docs/animated#node */ Node: AnimatedNode, - decay, - timing, - spring, - add, - subtract, - divide, - multiply, - modulo, - diffClamp, - delay, - sequence, - parallel, - stagger, - loop, - event, + decay: decayImpl, + timing: timingImpl, + spring: springImpl, + add: addImpl, + subtract: subtractImpl, + divide: divideImpl, + multiply: multiplyImpl, + modulo: moduloImpl, + diffClamp: diffClampImpl, + delay: delayImpl, + sequence: sequenceImpl, + parallel: parallelImpl, + stagger: staggerImpl, + loop: loopImpl, + event: eventImpl, createAnimatedComponent, - attachNativeEvent, - forkEvent, - unforkEvent, + attachNativeEvent: attachNativeEventImpl, + forkEvent: forkEventImpl, + unforkEvent: unforkEventImpl, /** * Expose Event class, so it can be used as a type for type checkers. diff --git a/packages/react-native/Libraries/Animated/AnimatedMock.js b/packages/react-native/Libraries/Animated/AnimatedMock.js index 5613f27358a..87338979f96 100644 --- a/packages/react-native/Libraries/Animated/AnimatedMock.js +++ b/packages/react-native/Libraries/Animated/AnimatedMock.js @@ -17,7 +17,7 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation'; import type {SpringAnimationConfig} from './animations/SpringAnimation'; import type {TimingAnimationConfig} from './animations/TimingAnimation'; -import {AnimatedEvent, attachNativeEvent} from './AnimatedEvent'; +import {AnimatedEvent, attachNativeEventImpl} from './AnimatedEvent'; import AnimatedImplementation from './AnimatedImplementation'; import createAnimatedComponent from './createAnimatedComponent'; import AnimatedColor from './nodes/AnimatedColor'; @@ -188,7 +188,7 @@ export default { loop, event: AnimatedImplementation.event, createAnimatedComponent, - attachNativeEvent, + attachNativeEvent: attachNativeEventImpl, forkEvent: AnimatedImplementation.forkEvent, unforkEvent: AnimatedImplementation.unforkEvent, Event: AnimatedEvent, diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index e8404c0c529..3fcf4b025b8 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -136,7 +136,7 @@ export type EventConfig = { useNativeDriver: boolean, platformConfig?: PlatformConfig, }; -declare export function attachNativeEvent( +declare export function attachNativeEventImpl( viewRef: any, eventName: string, argMapping: $ReadOnlyArray, @@ -226,53 +226,53 @@ exports[`public API should not change unintentionally Libraries/Animated/Animate reset: () => void, ... }; -declare const add: ( +declare const addImpl: ( a: AnimatedNode | number, b: AnimatedNode | number ) => AnimatedAddition; -declare const subtract: ( +declare const subtractImpl: ( a: AnimatedNode | number, b: AnimatedNode | number ) => AnimatedSubtraction; -declare const divide: ( +declare const divideImpl: ( a: AnimatedNode | number, b: AnimatedNode | number ) => AnimatedDivision; -declare const multiply: ( +declare const multiplyImpl: ( a: AnimatedNode | number, b: AnimatedNode | number ) => AnimatedMultiplication; -declare const modulo: (a: AnimatedNode, modulus: number) => AnimatedModulo; -declare const diffClamp: ( +declare const moduloImpl: (a: AnimatedNode, modulus: number) => AnimatedModulo; +declare const diffClampImpl: ( a: AnimatedNode, min: number, max: number ) => AnimatedDiffClamp; -declare const spring: ( +declare const springImpl: ( value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: SpringAnimationConfig ) => CompositeAnimation; -declare const timing: ( +declare const timingImpl: ( value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: TimingAnimationConfig ) => CompositeAnimation; -declare const decay: ( +declare const decayImpl: ( value: AnimatedValue | AnimatedValueXY | AnimatedColor, config: DecayAnimationConfig ) => CompositeAnimation; -declare const sequence: ( +declare const sequenceImpl: ( animations: Array ) => CompositeAnimation; type ParallelConfig = { stopTogether?: boolean, ... }; -declare const parallel: ( +declare const parallelImpl: ( animations: Array, config?: ?ParallelConfig ) => CompositeAnimation; -declare const delay: (time: number) => CompositeAnimation; -declare const stagger: ( +declare const delayImpl: (time: number) => CompositeAnimation; +declare const staggerImpl: ( time: number, animations: Array ) => CompositeAnimation; @@ -281,19 +281,19 @@ type LoopAnimationConfig = { resetBeforeIteration?: boolean, ... }; -declare const loop: ( +declare const loopImpl: ( animation: CompositeAnimation, $$PARAM_1$$?: LoopAnimationConfig ) => CompositeAnimation; -declare function forkEvent( +declare function forkEventImpl( event: ?AnimatedEvent | ?Function, listener: Function ): AnimatedEvent | Function; -declare function unforkEvent( +declare function unforkEventImpl( event: ?AnimatedEvent | ?Function, listener: Function ): void; -declare const event: ( +declare const eventImpl: ( argMapping: $ReadOnlyArray, config: EventConfig ) => any; @@ -313,25 +313,25 @@ declare export default { Color: typeof AnimatedColor, Interpolation: typeof AnimatedInterpolation, Node: typeof AnimatedNode, - decay: typeof decay, - timing: typeof timing, - spring: typeof spring, - add: typeof add, - subtract: typeof subtract, - divide: typeof divide, - multiply: typeof multiply, - modulo: typeof modulo, - diffClamp: typeof diffClamp, - delay: typeof delay, - sequence: typeof sequence, - parallel: typeof parallel, - stagger: typeof stagger, - loop: typeof loop, - event: typeof event, + decay: typeof decayImpl, + timing: typeof timingImpl, + spring: typeof springImpl, + add: typeof addImpl, + subtract: typeof subtractImpl, + divide: typeof divideImpl, + multiply: typeof multiplyImpl, + modulo: typeof moduloImpl, + diffClamp: typeof diffClampImpl, + delay: typeof delayImpl, + sequence: typeof sequenceImpl, + parallel: typeof parallelImpl, + stagger: typeof staggerImpl, + loop: typeof loopImpl, + event: typeof eventImpl, createAnimatedComponent: typeof createAnimatedComponent, - attachNativeEvent: typeof attachNativeEvent, - forkEvent: typeof forkEvent, - unforkEvent: typeof unforkEvent, + attachNativeEvent: typeof attachNativeEventImpl, + forkEvent: typeof forkEventImpl, + unforkEvent: typeof unforkEventImpl, Event: typeof AnimatedEvent, }; "