Skip to content

Commit 3ce964a

Browse files
authored
Merge pull request #83 from inokawa/strip-internal
Remove internal types from bundle
2 parents ea6977b + b6eeec7 commit 3ce964a

File tree

8 files changed

+88
-1
lines changed

8 files changed

+88
-1
lines changed

src/core/utils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
/** @internal */
12
export const noop = () => {};
3+
/** @internal */
24
export const getKeys: <T extends object>(item: T) => (keyof T)[] = Object.keys;
5+
/** @internal */
36
export const assign = Object.assign;
7+
/** @internal */
48
export const isArray = Array.isArray;
9+
/** @internal */
510
export const getStyle = (e: Element) => getComputedStyle(e);
611

12+
/**
13+
* @internal
14+
*/
715
export const isSameObject = (
816
target: object = {},
917
prev: object = {}
@@ -13,6 +21,9 @@ export const isSameObject = (
1321
return keys.every((k) => (target as any)[k] === (prev as any)[k]);
1422
};
1523

24+
/**
25+
* @internal
26+
*/
1627
export const isSameObjectArray = (
1728
target: object[],
1829
prev: object[]
@@ -21,9 +32,15 @@ export const isSameObjectArray = (
2132
return target.every((t, i) => isSameObject(t, prev[i]));
2233
};
2334

35+
/**
36+
* @internal
37+
*/
2438
export const toArray = <T>(items: T | T[]): T[] =>
2539
isArray(items) ? items : [items];
2640

41+
/**
42+
* @internal
43+
*/
2744
export const uniq = <T extends string | number>(items: T[]): T[] => {
2845
return Array.from(new Set(items));
2946
};

src/core/waapi.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export interface TypedKeyframeEffectOptions
4141
easing?: TypedEasing;
4242
}
4343

44+
/**
45+
* @internal
46+
*/
4447
export const getKeyframeKeys = (keyframes: TypedKeyframe[]): string[] =>
4548
uniq(keyframes.flatMap(getKeys)).reduce((acc, k) => {
4649
if (["offset", "easing", "composite"].includes(k)) {
@@ -55,6 +58,9 @@ export const getKeyframeKeys = (keyframes: TypedKeyframe[]): string[] =>
5558
return acc;
5659
}, [] as string[]);
5760

61+
/**
62+
* @internal
63+
*/
5864
export const createAnimation = (
5965
el: Element | null,
6066
keyframes: Keyframe[] | null,
@@ -83,6 +89,9 @@ export type PlayOptions = {
8389
restart?: boolean;
8490
};
8591

92+
/**
93+
* @internal
94+
*/
8695
export const _play = (animation: Animation, opts: PlayOptions = {}) => {
8796
// Reset reversed playback direction if completed
8897
if (animation.playbackRate < 0 && animation.playState === "finished") {
@@ -93,22 +102,41 @@ export const _play = (animation: Animation, opts: PlayOptions = {}) => {
93102
}
94103
animation.play();
95104
};
105+
106+
/**
107+
* @internal
108+
*/
96109
export const _reverse = (animation: Animation | undefined) => {
97110
if (!animation) return;
98111
animation.reverse();
99112
};
113+
114+
/**
115+
* @internal
116+
*/
100117
export const _cancel = (animation: Animation | undefined) => {
101118
if (!animation) return;
102119
animation.cancel();
103120
};
121+
122+
/**
123+
* @internal
124+
*/
104125
export const _finish = (animation: Animation | undefined) => {
105126
if (!animation) return;
106127
animation.finish();
107128
};
129+
130+
/**
131+
* @internal
132+
*/
108133
export const _pause = (animation: Animation | undefined) => {
109134
if (!animation) return;
110135
animation.pause();
111136
};
137+
// /**
138+
// * @internal
139+
// */
112140
// export const _persist = (
113141
// animation: Animation | undefined,
114142
// el: Element,
@@ -127,6 +155,9 @@ export const _pause = (animation: Animation | undefined) => {
127155
// }
128156
// animation.cancel();
129157
// };
158+
/**
159+
* @internal
160+
*/
130161
export const _setTime = (
131162
animation: Animation | undefined,
132163
arg: number | ((endTime: number) => number)
@@ -137,6 +168,10 @@ export const _setTime = (
137168
? arg(animation.effect!.getComputedTiming().endTime! as number)
138169
: arg;
139170
};
171+
172+
/**
173+
* @internal
174+
*/
140175
export const _setRate = (
141176
animation: Animation | undefined,
142177
arg: number | ((prevRate: number) => number)
@@ -148,6 +183,10 @@ export const _setRate = (
148183
};
149184

150185
export type WaitingAnimationEventName = "finish" | "reverseFinish";
186+
187+
/**
188+
* @internal
189+
*/
151190
export const _waitFor = (
152191
animation: Animation | undefined,
153192
name: WaitingAnimationEventName

src/react/components/TransitionGroup.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,23 @@ const toMap = (elements: ReactElement[]) =>
1616
return acc;
1717
}, {} as { [key: string]: ReactElement });
1818

19+
/** @internal */
1920
export type TransitionState = "update" | "enter" | "exit";
21+
/** @internal */
2022
export const TransitionStateContext = createContext<TransitionState>("update");
2123

24+
/** @internal */
2225
export const NOT_EXIT = 0;
26+
/** @internal */
2327
export const EXITING = 1;
28+
/** @internal */
2429
export const EXITED = 2;
30+
/** @internal */
2531
export type TransitionExitState =
2632
| typeof NOT_EXIT
2733
| typeof EXITING
2834
| typeof EXITED;
35+
/** @internal */
2936
export const TransitionNotifierContext =
3037
createContext<(state: TransitionExitState) => void>(noop);
3138

src/react/hooks/state.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { isSameObject, isSameObjectArray } from "../../core/utils";
22
import { createAnimation } from "../../core/waapi";
33

4+
/**
5+
* @internal
6+
*/
47
export interface AnimationObject {
58
readonly _keyframes: Keyframe[];
69
readonly _options: KeyframeEffectOptions | undefined;
@@ -9,7 +12,14 @@ export interface AnimationObject {
912

1013
const animations = new WeakMap<AnimationObject, Animation>();
1114

15+
/**
16+
* @internal
17+
*/
1218
export const getAnimation = (target: AnimationObject) => animations.get(target);
19+
20+
/**
21+
* @internal
22+
*/
1323
export const deleteAnimation = (target: AnimationObject) => {
1424
getAnimation(target)?.cancel();
1525
animations.delete(target);
@@ -22,6 +32,9 @@ const isEqual = (a: AnimationObject, b: AnimationObject): boolean => {
2232
);
2333
};
2434

35+
/**
36+
* @internal
37+
*/
2538
export const initAnimation = (
2639
el: Element,
2740
target: AnimationObject,
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { useEffect, useLayoutEffect } from "react";
22

3-
// https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
3+
/**
4+
* https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
5+
* @internal
6+
*/
47
export const useIsomorphicLayoutEffect =
58
typeof window !== "undefined" ? useLayoutEffect : useEffect;

src/react/hooks/useLatestRef.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { useRef } from "react";
22
import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
33

4+
/**
5+
* @internal
6+
*/
47
export const useLatestRef = <T>(value: T) => {
58
const ref = useRef<T>(value);
69

src/react/hooks/useStatic.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { useRef } from "react";
22

3+
/**
4+
* @internal
5+
*/
36
export const useStatic = <T>(init: () => T): T => {
47
const ref = useRef<T>();
58
return ref.current || (ref.current = init());

src/react/types/internal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
/** @internal */
12
export const SCROLL_TIMELINE = 1;
3+
/** @internal */
24
export const VIEW_TIMELINE = 2;

0 commit comments

Comments
 (0)