Skip to content

Commit

Permalink
chore: pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaellis committed Dec 11, 2023
1 parent 2c46221 commit e486c12
Show file tree
Hide file tree
Showing 30 changed files with 180 additions and 174 deletions.
2 changes: 1 addition & 1 deletion demo/src/sandboxes/notification-hub/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function MessageHub({
})
)
},
config: (item, index, phase) => key => phase === 'enter' && key === 'life' ? { duration: timeout } : config,
config: (item, index, phase) => key => (phase === 'enter' && key === 'life' ? { duration: timeout } : config),
})

React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/app/components/Code/H.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface HProps {
export const H = ({ index, id, ...props }: HProps) => {
const getHighlightedWords = (): [
targetIndex: number[],
allHighlightWords: Element[]
allHighlightWords: Element[],
] => {
const codeBlock = document.getElementById(id)
if (!codeBlock) return [[], []]
Expand Down
2 changes: 1 addition & 1 deletion docs/app/helpers/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export enum EventNames {

type EventFactory<
TEventName extends EventNames,
TAdditionalProps extends object = object
TAdditionalProps extends object = object,
> = {
name: TEventName
additionalProps?: TAdditionalProps
Expand Down
2 changes: 1 addition & 1 deletion docs/app/hooks/useAnimatedHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useAnimatedHeader = ({
styles: { top: SpringValue<number> },
isStuck: boolean,
scrollTop: number,
direction: SCROLL_DIR | undefined
direction: SCROLL_DIR | undefined,
] => {
const [direction, scrollTop] = useWindowScrolling({
active: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/animated/src/AnimatedArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Source = AnimatedValue<Value>[]

/** An array of animated nodes */
export class AnimatedArray<
T extends ReadonlyArray<Value> = Value[]
T extends ReadonlyArray<Value> = Value[],
> extends AnimatedObject {
protected declare source: Source
constructor(source: T) {
Expand Down
4 changes: 2 additions & 2 deletions packages/animated/src/createHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ const getDisplayName = (arg: AnimatableComponent) =>
is.str(arg)
? arg
: arg && is.str(arg.displayName)
? arg.displayName
: (is.fun(arg) && arg.name) || null
? arg.displayName
: (is.fun(arg) && arg.name) || null
8 changes: 4 additions & 4 deletions packages/animated/src/getAnimatedType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function getAnimatedType(value: any): AnimatedType {
return parentNode
? (parentNode.constructor as any)
: is.arr(value)
? AnimatedArray
: isAnimatedString(value)
? AnimatedString
: AnimatedValue
? AnimatedArray
: isAnimatedString(value)
? AnimatedString
: AnimatedValue
}
5 changes: 4 additions & 1 deletion packages/animated/src/withAnimated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export const withAnimated = (Component: any, host: HostConfig) => {
}

class PropsObserver {
constructor(readonly update: () => void, readonly deps: Set<FluidValue>) {}
constructor(
readonly update: () => void,
readonly deps: Set<FluidValue>
) {}
eventObserved(event: FluidEvent) {
if (event.type == 'change') {
raf.write(this.update)
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/AnimationResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export const getCombinedResult = <T extends Readable>(
results.length == 1
? results[0]
: results.some(result => result.cancelled)
? getCancelledResult(target.get())
: results.every(result => result.noop)
? getNoopResult(target.get())
: getFinishedResult(
target.get(),
results.every(result => result.finished)
)
? getCancelledResult(target.get())
: results.every(result => result.noop)
? getNoopResult(target.get())
: getFinishedResult(
target.get(),
results.every(result => result.finished)
)

/** No-op results are for updates that never start an animation. */
export const getNoopResult = (value: any) => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Interpolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
*/
export class Interpolation<
Input = any,
Output = any
Output = any,
> extends FrameValue<Output> {
/** Useful for debugging. */
key?: string
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/SpringRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export interface ControllerUpdateFn<State extends Lookup = Lookup> {
}

export interface SpringRef<State extends Lookup = Lookup> {
(props?: ControllerUpdate<State> | ControllerUpdateFn<State>): AsyncResult<
Controller<State>
>[]
(
props?: ControllerUpdate<State> | ControllerUpdateFn<State>
): AsyncResult<Controller<State>>[]
current: Controller<State>[]

/** Add a controller to this ref */
Expand Down Expand Up @@ -77,7 +77,7 @@ export interface SpringRef<State extends Lookup = Lookup> {
}

export const SpringRef = <
State extends Lookup = Lookup
State extends Lookup = Lookup,
>(): SpringRef<State> => {
const current: Controller<State>[] = []

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/SpringValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export class SpringValue<T = any> extends FrameValue<T> {
node.constructor == AnimatedString
? 1
: payload
? payload[i].lastPosition
: toValues![i]
? payload[i].lastPosition
: toValues![i]

let finished = anim.immediate
let position = to
Expand Down Expand Up @@ -800,8 +800,8 @@ export class SpringValue<T = any> extends FrameValue<T> {
anim.toValues = hasFluidValue(to)
? null
: goalType == AnimatedString
? [1]
: toArray(goal)
? [1]
: toArray(goal)
}

if (anim.immediate != immediate) {
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export const getDefaultProp = <T extends Lookup, P extends keyof T>(
props.default === true
? props[key]
: props.default
? props.default[key]
: undefined
? props.default[key]
: undefined

const noopTransform = (value: any) => value

Expand Down Expand Up @@ -187,11 +187,11 @@ export function computeGoal<T>(value: T | FluidValue<T>): T {
return is.arr(value)
? value.map(computeGoal)
: isAnimatedString(value)
? (G.createStringInterpolator({
range: [0, 1],
output: [value, value] as any,
})(1) as any)
: value
? (G.createStringInterpolator({
range: [0, 1],
output: [value, value] as any,
})(1) as any)
: value
}

export function hasProps(props: object) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export type RawValues<T extends object> = {
export type IsPlainObject<T> = T extends ReadonlyArray<any>
? Any
: T extends object
? object
: Any
? object
: Any

export type StringKeys<T> = T extends IsPlainObject<T>
? string & keyof T
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/types/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type SpringUpdateFn<T = any> = T extends IsPlainObject<T>
interface AnyUpdateFn<
T extends SpringValue | Controller<any>,
Props extends object = InferProps<T>,
State = InferState<T>
State = InferState<T>,
> {
(to: SpringTo<State>, props?: Props): AsyncResult<T>
(props: { to?: SpringToFn<T> | Falsy } & Props): AsyncResult<T>
Expand Down Expand Up @@ -82,7 +82,7 @@ interface UpdateValueFn<T = any> extends AnyUpdateFn<SpringValue<T>> {
type EventHandler<
TResult extends Readable = any,
TSource = unknown,
Item = undefined
Item = undefined,
> = Item extends undefined
? (result: AnimationResult<TResult>, ctrl: TSource, item?: Item) => void
: (result: AnimationResult<TResult>, ctrl: TSource, item: Item) => void
Expand All @@ -94,39 +94,39 @@ type EventHandler<
export type OnStart<
TResult extends Readable,
TSource,
Item = undefined
Item = undefined,
> = EventHandler<TResult, TSource, Item>

/** Called when a `SpringValue` changes */
export type OnChange<
TResult extends Readable,
TSource,
Item = undefined
Item = undefined,
> = EventHandler<TResult, TSource, Item>

export type OnPause<
TResult extends Readable,
TSource,
Item = undefined
Item = undefined,
> = EventHandler<TResult, TSource, Item>

export type OnResume<
TResult extends Readable,
TSource,
Item = undefined
Item = undefined,
> = EventHandler<TResult, TSource, Item>

/** Called once the animation comes to a halt */
export type OnRest<
TResult extends Readable,
TSource,
Item = undefined
Item = undefined,
> = EventHandler<TResult, TSource, Item>

export type OnResolve<
TResult extends Readable,
TSource,
Item = undefined
Item = undefined,
> = EventHandler<TResult, TSource, Item>

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export interface Readable<T = any> {
export type InferState<T extends Readable> = T extends Controller<infer State>
? State
: T extends SpringValue<infer U>
? U
: unknown
? U
: unknown

/** @internal */
export type InferProps<T extends Readable> = T extends Controller<infer State>
? ControllerUpdate<State>
: T extends SpringValue<infer U>
? SpringUpdate<U>
: Lookup
? SpringUpdate<U>
: Lookup

/** @internal */
export type InferTarget<T> = T extends object
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type SpringValues<T extends Lookup = any> = [T] extends [Any]
// Wrap a type with `SpringValue`
type SpringWrap<T> = [
Exclude<T, FluidValue>,
Extract<T, readonly any[]> // Arrays are animated.
Extract<T, readonly any[]>, // Arrays are animated.
] extends [object | void, never]
? never // Object literals cannot be animated.
: SpringValue<Exclude<T, FluidValue | void>> | Extract<T, void>
24 changes: 12 additions & 12 deletions packages/core/src/types/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ export type SpringTo<T = any> =

export type ControllerUpdate<
State extends Lookup = Lookup,
Item = undefined
Item = undefined,
> = unknown & ToProps<State> & ControllerProps<State, Item>

/**
* Props for `Controller` methods and constructor.
*/
export interface ControllerProps<
State extends Lookup = Lookup,
Item = undefined
Item = undefined,
> extends AnimationProps<State> {
ref?: SpringRef<State>
from?: GoalValues<State> | Falsy
Expand Down Expand Up @@ -350,16 +350,16 @@ export type PickAnimated<Props extends object, Fwd = true> = unknown &
([Props] extends [Any]
? Lookup // Preserve "any" instead of resolving to "{}"
: [object] extends [Props]
? Lookup
: ObjectFromUnion<
Props extends { from: infer From } // extract prop from the `from` prop if it exists
? From extends () => any
? ReturnType<From>
: ObjectType<From>
: TransitionKey & keyof Props extends never
? ToValues<Props, Fwd>
: TransitionValues<Props>
>)
? Lookup
: ObjectFromUnion<
Props extends { from: infer From } // extract prop from the `from` prop if it exists
? From extends () => any
? ReturnType<From>
: ObjectType<From>
: TransitionKey & keyof Props extends never
? ToValues<Props, Fwd>
: TransitionValues<Props>
>)

/**
* Pick the values of the `to` prop. Forward props are *not* included.
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/types/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export type TransitionValues<Props extends object> = unknown &
? T extends ReadonlyArray<infer Element>
? Element
: T extends (...args: any[]) => infer Return
? Return extends ReadonlyArray<infer ReturnElement>
? ReturnElement
: Return
: T
? Return extends ReadonlyArray<infer ReturnElement>
? ReturnElement
: Return
: T
: never
>,
{}
Expand Down Expand Up @@ -97,7 +97,7 @@ export type UseTransitionProps<Item = any> = Merge<

export type TransitionComponentProps<
Item,
Props extends object = any
Props extends object = any,
> = unknown &
UseTransitionProps<Item> & {
keys?: ItemKeys<NoInfer<Item>>
Expand Down
25 changes: 13 additions & 12 deletions packages/shared/src/easings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ export const easings: EasingDictionary = {
x === 0
? 0
: x === 1
? 1
: x < 0.5
? Math.pow(2, 20 * x - 10) / 2
: (2 - Math.pow(2, -20 * x + 10)) / 2,
? 1
: x < 0.5
? Math.pow(2, 20 * x - 10) / 2
: (2 - Math.pow(2, -20 * x + 10)) / 2,
easeInCirc: x => 1 - Math.sqrt(1 - Math.pow(x, 2)),
easeOutCirc: x => Math.sqrt(1 - Math.pow(x - 1, 2)),
easeInOutCirc: x =>
Expand All @@ -126,22 +126,23 @@ export const easings: EasingDictionary = {
x === 0
? 0
: x === 1
? 1
: -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
? 1
: -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
easeOutElastic: x =>
x === 0
? 0
: x === 1
? 1
: Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
? 1
: Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
easeInOutElastic: x =>
x === 0
? 0
: x === 1
? 1
: x < 0.5
? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2
: (Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5)) / 2 + 1,
? 1
: x < 0.5
? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2
: (Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5)) / 2 +
1,
easeInBounce: x => 1 - bounceOut(1 - x),
easeOutBounce: bounceOut,
easeInOutBounce: x =>
Expand Down
Loading

0 comments on commit e486c12

Please sign in to comment.