Skip to content

Commit d5175ec

Browse files
committed
More code relocation
1 parent 2f1954d commit d5175ec

File tree

16 files changed

+107
-100
lines changed

16 files changed

+107
-100
lines changed

packages/react-native-reanimated/src/common/types.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
import type { AnyRecord, Maybe, NonMutable } from './helpers';
4+
5+
export type ValueProcessor<V, R = V> = (
6+
value: NonMutable<V>
7+
) => Maybe<R> | Record<string, R>;
8+
9+
export type ConfigPropertyAlias<P extends AnyRecord> = {
10+
as: keyof P;
11+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
'use strict';
3+
4+
import type { ComponentType } from 'react';
5+
6+
export type Maybe<T> = T | null | undefined;
7+
8+
/**
9+
* Makes only mutable types (objects, arrays) readonly while leaving primitive
10+
* types unchanged. This prevents type issues caused by making other types
11+
* readonly, like Readonly<string> which isn't the same as string.
12+
*/
13+
export type NonMutable<T> = T extends object ? Readonly<T> : T;
14+
15+
export type AnyRecord = Record<string, any>;
16+
17+
export type AnyComponent = ComponentType<any>;
18+
19+
type Simplify<T> = {
20+
[K in keyof T]: T[K];
21+
} & {};
22+
23+
type ConvertValueToArray<T> = Simplify<(T extends any[] ? T[number] : T)[]>;
24+
25+
export type ConvertValuesToArrays<T> = {
26+
[K in keyof T]-?: ConvertValueToArray<Exclude<T[K], undefined>>;
27+
};
28+
29+
export type ConvertValuesToArraysWithUndefined<T> = {
30+
[K in keyof T]-?: ConvertValueToArray<T[K]>;
31+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
export type * from './config';
4+
export type * from './helpers';
5+
export type * from './style';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
import type {
4+
ImageStyle,
5+
TextStyle,
6+
TransformsStyle,
7+
ViewStyle,
8+
} from 'react-native';
9+
10+
export type TransformOrigin = string | Array<string | number>;
11+
12+
export type NormalizedTransformOrigin = [
13+
`${number}%` | number,
14+
`${number}%` | number,
15+
number,
16+
];
17+
18+
type DeprecatedProps =
19+
| 'transformMatrix'
20+
| 'rotation'
21+
| 'scaleX'
22+
| 'scaleY'
23+
| 'translateX'
24+
| 'translateY';
25+
26+
export type PlainStyle = Omit<
27+
ViewStyle & TextStyle & ImageStyle,
28+
DeprecatedProps
29+
>;
30+
31+
export type TransformsArray = Exclude<
32+
TransformsStyle['transform'],
33+
string | undefined
34+
>;

packages/react-native-reanimated/src/common/utils/conversions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
import type { ConvertValuesToArrays } from '../../css/types';
3-
import type { AnyRecord } from '../types';
2+
import type { AnyRecord, ConvertValuesToArrays } from '../types';
43

54
export function convertPropertyToArray<T>(value: T | undefined): T[] {
65
return value !== undefined ? (Array.isArray(value) ? value : [value]) : [];

packages/react-native-reanimated/src/css/native/normalization/animation/properties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2+
import { convertPropertiesToArrays } from '../../../../common';
23
import type {
34
ExistingCSSAnimationProperties,
45
SingleCSSAnimationProperties,
56
} from '../../../types';
6-
import { convertPropertiesToArrays } from '../../../utils';
77

88
export function createSingleCSSAnimationProperties(
99
properties: ExistingCSSAnimationProperties

packages/react-native-reanimated/src/css/native/normalization/transition/config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
'use strict';
22
import type { AnyRecord } from '../../../../common';
3-
import { ReanimatedError } from '../../../../common';
3+
import { convertPropertyToArray, ReanimatedError } from '../../../../common';
44
import type {
55
CSSTransitionProperties,
66
CSSTransitionProperty,
77
} from '../../../types';
8-
import {
9-
areArraysEqual,
10-
convertPropertyToArray,
11-
deepEqual,
12-
} from '../../../utils';
8+
import { areArraysEqual, deepEqual } from '../../../utils';
139
import type {
1410
NormalizedCSSTransitionConfig,
1511
NormalizedCSSTransitionConfigUpdates,

packages/react-native-reanimated/src/css/native/normalization/transition/shorthand.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict';
2-
import { isPercentage, ReanimatedError } from '../../../../common';
2+
import type { ConvertValuesToArraysWithUndefined } from '../../../../common';
3+
import {
4+
camelizeKebabCase,
5+
isPercentage,
6+
ReanimatedError,
7+
} from '../../../../common';
38
import type { ControlPoint, CSSTimingFunction } from '../../../easing';
49
import { cubicBezier, linear, steps } from '../../../easing';
5-
import type {
6-
ConvertValuesToArraysWithUndefined,
7-
CSSTransitionProperties,
8-
} from '../../../types';
10+
import type { CSSTransitionProperties } from '../../../types';
911
import {
10-
camelizeKebabCase,
1112
isArrayOfLength,
1213
isPredefinedTimingFunction,
1314
isStepsModifier,

packages/react-native-reanimated/src/css/types/helpers.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
'use strict';
32

43
type NoUndef<T> = T extends undefined ? never : T;
@@ -9,20 +8,6 @@ export type Repeat<
98
R extends T[] = [],
109
> = R['length'] extends N ? R : Repeat<T, N, [...R, T]>;
1110

12-
type Simplify<T> = {
13-
[K in keyof T]: T[K];
14-
} & {};
15-
16-
type ConvertValueToArray<T> = Simplify<(T extends any[] ? T[number] : T)[]>;
17-
18-
export type ConvertValuesToArrays<T> = {
19-
[K in keyof T]-?: ConvertValueToArray<Exclude<T[K], undefined>>;
20-
};
21-
22-
export type ConvertValuesToArraysWithUndefined<T> = {
23-
[K in keyof T]-?: ConvertValueToArray<T[K]>;
24-
};
25-
2611
export type AddArrayPropertyType<T> = T | T[];
2712

2813
export type AddArrayPropertyTypes<T> = {

0 commit comments

Comments
 (0)