Skip to content

Commit

Permalink
Update npm files
Browse files Browse the repository at this point in the history
  • Loading branch information
pofulu committed May 12, 2021
1 parent 5e8590d commit 5266868
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 101 deletions.
131 changes: 88 additions & 43 deletions index.d.ts → PFTween.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,43 @@ declare const samplers: {
punch: (begin: any, amount: any) => any;
};
declare class PFTweenEvent {
private events;
private subscription;
private _events;
private _subscription;
constructor();
get events(): ((value: any) => void)[];
invoke(arg: any): void;
invokeOnMonitor(signal: any): void;
invokeOnEvent(eventSource: EventSource): void;
invokeOnEvent<T>(eventSource: EventSource<T>): void;
add(callback: (value: any) => void): void;
dispose(): void;
}
declare class PFTweenEvents {
readonly onStartEvent: PFTweenEvent;
readonly onCompleteEvent: PFTweenEvent;
readonly onLoopEvent: PFTweenEvent;
readonly onUpdateEvent: PFTweenEvent;
readonly onStart: PFTweenEvent;
readonly onComplete: PFTweenEvent;
readonly onLoop: PFTweenEvent;
readonly onUpdate: PFTweenEvent;
readonly onFinally: PFTweenEvent;
constructor();
dispose(): void;
}
declare class PFTweenClipCancellation {
readonly value: any;
constructor(value: any);
cancel(): void;
}
interface IPFTweenClip {
(value?: any): Promise<{
value: any;
}>;
}
interface ICurveProvider {
evaluate(progress: number | ScalarSampler): number | ScalarSignal;
}
interface IPFTweenProgress {
readonly durationMilliseconds: number;
setProgress(progress: number): void;
setProgress(progress: ScalarSignal): void;
}
declare type PFTweenConfig = {
loopCount: number;
isMirror: boolean;
Expand All @@ -65,49 +85,54 @@ declare type PFTweenConfig = {
begin: number | number[];
end: number | number[];
};
interface PFTweenClip {
(value?: any): Promise<{
value: any;
}>;
}
export interface ICurveProvider {
evaluate(progress: number): number | ScalarSignal;
}
declare class PFTweenClipCancellation {
readonly value: any;
constructor(value: any);
cancel(): void;
}
declare class PFTween {
declare type SupportType<T> = T extends number[] ? number[] | Point2DSignal | PointSignal | Point4DSignal : T extends ScalarSignal | number ? ScalarSignal | number : T extends Point2DSignal ? Point2DSignal | number[] : T extends PointSignal ? PointSignal | number[] : T extends Point4DSignal ? Point4DSignal | number[] : never;
declare type UpdateValueType<T> = T extends number[] | Point2DSignal | Point4DSignal ? number[] : T extends ScalarSignal | number ? number : never;
declare class PFTween<T extends Number | Number[] | ScalarSignal | Point2DSignal | PointSignal | Point4DSignal> {
private config;
constructor(begin: number, end: number, durationMilliseconds: number);
constructor(begin: number[], end: number[], durationMilliseconds: number);
constructor(begin: ScalarSignal, end: ScalarSignal, durationMilliseconds: number);
constructor(begin: Point2DSignal, end: Point2DSignal, durationMilliseconds: number);
constructor(begin: PointSignal, end: PointSignal, durationMilliseconds: number);
constructor(begin: Point4DSignal, end: Point4DSignal, durationMilliseconds: number);
static combine(clips: PFTweenClip[]): PFTweenClip;
static combine(...clips: PFTweenClip[]): PFTweenClip;
static concat(clips: PFTweenClip[]): PFTweenClip;
static concat(...clips: PFTweenClip[]): PFTweenClip;
constructor(begin: T, end: SupportType<T>, durationMilliseconds: number);
static combine(clips: IPFTweenClip[]): IPFTweenClip;
static combine(...clips: IPFTweenClip[]): IPFTweenClip;
static concat(clips: IPFTweenClip[]): IPFTweenClip;
static concat(...clips: IPFTweenClip[]): IPFTweenClip;
static combineProgress(progresses: IPFTweenProgress[]): IPFTweenProgress;
static combineProgress(...progresses: IPFTweenProgress[]): IPFTweenProgress;
static concatProgerss(progresses: IPFTweenProgress[]): IPFTweenProgress;
static concatProgerss(...progresses: IPFTweenProgress[]): IPFTweenProgress;
/**
* Stop and unsubscribe all events of the animation.
* @param id The id you set for to your animation.
*/
static kill(id: string | symbol): void;
/**
* Check if the animation of this id exist.
* @param id
* @returns
*/
static hasId(id: string | symbol): boolean;
/**
* Create a cancellation used for interrupt clips.
* @param value The args you want to pass to clip.
* @returns
*/
static newClipCancellation(value?: any): PFTweenClipCancellation;
setEase(ease: (begin: number, end: number) => ScalarSampler): PFTween;
setEase(ease: (begin: number[], end: number[]) => ArrayOfScalarSamplers): PFTween;
setEase(curveProvider: ICurveProvider): PFTween;
setLoops(): PFTween;
setLoops(loopCount: number): PFTween;
setLoops(isMirror: boolean): PFTween;
setLoops(loopCount: number, isMirror: boolean): PFTween;
setEase(ease: (begin: number, end: number) => ScalarSampler): PFTween<T>;
setEase(ease: (begin: number[], end: number[]) => ArrayOfScalarSamplers): PFTween<T>;
setEase(curveProvider: ICurveProvider): PFTween<T>;
setLoops(): PFTween<T>;
setLoops(loopCount: number): PFTween<T>;
setLoops(isMirror: boolean): PFTween<T>;
setLoops(loopCount: number, isMirror: boolean): PFTween<T>;
setMirror(isMirror?: boolean): this;
/**
* Delay to start animation, this will only delay the first time.
*/
setDelay(delayMilliseconds: number): this;
setId(id: string | symbol): this;
setAutoKill(): this;
onStart(callback: (value: PFTweenValue) => void): this;
onComplete(callback: () => void): this;
onUpdate(callback: (v: number | number[]) => void): this;
onLoop(callback: (value: PFTweenValue) => void): this;
onUpdate(callback: (v: UpdateValueType<T>) => void): this;
onLoop(callback: (iteration: number) => void): this;
onStartVisible(sceneObject: SceneObjectBase): this;
onAnimatingVisibleOnly(sceneObject: SceneObjectBase): this;
onStartHidden(sceneObject: SceneObjectBase): this;
Expand All @@ -124,14 +149,25 @@ declare class PFTween {
/**
* @deprecated Please use `build()` instead. `apply` is equivalent to `build` now.
*/
apply(autoPlay?: boolean): void;
apply(autoPlay?: boolean): PFTweener;
build(autoPlay?: boolean): PFTweener;
/**
* Take input numbers and output them in a different order.
* Input values correspond to the swizzle value (xyzw) in the order theyre inputted. For example, an input of (1,2,3) and a swizzle value of (yxz) would output (2,1,3). You can also use 0 and 1. For example, a swizzle value of (x01) would output (1,0,1).
*/
swizzle(specifier: string): any;
get clip(): PFTweenClip;
/**
* Convert
* @param name
* @returns
*/
patch(name: string): void;
/**
* Get an evaluable animation controller.
* Please note that the `onCompleteEvent`, `onStartEvent`, `onLoopEvent` won't work.
*/
get progress(): PFTweenProgress;
get clip(): IPFTweenClip;
get scalar(): any;
get pack2(): any;
get pack3(): any;
Expand All @@ -147,6 +183,7 @@ declare class PFTween {
*/
get rotation(): any;
get deg2rad(): any;
get durationMilliseconds(): number;
}
declare class PFTweenValue {
private animate;
Expand All @@ -157,6 +194,7 @@ declare class PFTweenValue {
* Input values correspond to the swizzle value (xyzw) in the order theyre inputted. For example, an input of (1,2,3) and a swizzle value of (yxz) would output (2,1,3). You can also use 0 and 1. For example, a swizzle value of (x01) would output (1,0,1).
*/
swizzle(specifier: any): any;
patch(name: string): void;
get scalar(): any;
get pack2(): any;
get pack3(): any;
Expand All @@ -173,6 +211,13 @@ declare class PFTweenValue {
get rotation(): any;
get deg2rad(): any;
}
declare class PFTweenProgress implements IPFTweenProgress {
readonly durationMilliseconds: number;
private config;
constructor(config: PFTweenConfig);
setProgress(progress: number): any;
setProgress(progress: ScalarSignal): any;
}
declare class PFTweener extends PFTweenValue {
private config;
private driver;
Expand All @@ -185,4 +230,4 @@ declare class PFTweener extends PFTweenValue {
stop(reset?: boolean): void;
get isRunning(): any;
}
export { samplers as Ease, PFTween };
export { samplers as Ease, PFTween, ICurveProvider };
Loading

0 comments on commit 5266868

Please sign in to comment.