import type { Animationable } from "kittik-animation-basic" ; import type { Canvas } from "terminal-canvas" ; import type { ShapeRenderable } from "kittik-shape-basic" ; import { Slide } from "./Slide" ; type TShapeAccumulator < TSlideBuilder , TNextShape > = TSlideBuilder extends SlideBuilder < infer TShapes , infer TAnimations > ? SlideBuilder < TNextShape | TShapes , TAnimations > : never ; type TAnimationAccumulator < TSlideBuilder , TNextAnimation > = TSlideBuilder extends SlideBuilder < infer TShapes , infer TAnimations > ? SlideBuilder < TShapes , TAnimations | TNextAnimation > : never ; export class SlideBuilder < TShape , TAnimation > { private readonly slide : Slide = new Slide ( ) ; public constructor ( shapes = { } , animations = { } ) { Object . keys ( shapes ) . forEach ( ( name ) => { this . slide . addShape ( name , shapes [ name ] ! ) ; } ) ; Object . keys ( animations ) . forEach ( ( name ) => { this . slide . addAnimation ( name , animations [ name ] ! ) ; } ) ; } public static start < TShape extends string = never , TAnimation extends string = never > ( shapes ? , animations ? ) { return new this ( shapes , animations ) ; } public withName ( name ) { this . slide . name = name ; return this ; } public withCanvas ( canvas ) { this . slide . canvas = canvas ; return this ; } public withShape < T extends string > ( name , shape ) { this . slide . addShape ( name , shape ) ; return this as unknown as TShapeAccumulator < this , T > ; } public withAnimation < T extends string > ( name , animation ) { this . slide . addAnimation ( name , animation ) ; return this as unknown as TAnimationAccumulator < this , T > ; } public withOrder ( shape , animations ? ) { this . slide . addOrder ( String ( shape ) , animations ?. map ( String ) ) ; return this ; } public end ( ) { return this . slide ; } }