diff --git a/packages/kittik-slide/src/slide/Slide.ts b/packages/kittik-slide/src/slide/Slide.ts index ed84911..0c01e3e 100644 --- a/packages/kittik-slide/src/slide/Slide.ts +++ b/packages/kittik-slide/src/slide/Slide.ts @@ -10,22 +10,24 @@ import { SlideDeclaration } from './SlideDeclaration'; export { AnimationBuilder } from '../animation/AnimationBuilder'; export { AnimationDeclaration } from '../animation/AnimationDeclaration'; -export { AnimationType } from '../animation/Animations'; +export { AnimationType, AnimationObject, AnimationOptions } from '../animation/Animations'; export { OrderDeclaration } from './OrderDeclaration'; export { ShapeBuilder } from '../shape/ShapeBuilder'; export { ShapeDeclaration } from '../shape/ShapeDeclaration'; -export { ShapeType } from '../shape/Shapes'; +export { ShapeType, ShapeObject, ShapeOptions } from '../shape/Shapes'; export { SlideBuilder } from './SlideBuilder'; export { SlideDeclaration } from './SlideDeclaration'; -export class Slide { - public canvas: Canvas = Canvas.create(); +export class Slide< + C extends Canvas = Canvas +> { + public canvas: C = Canvas.create() as C; public name = 'Untitled Slide'; public readonly shapes: Map = new Map(); public readonly animations: Map = new Map(); public readonly order: OrderDeclaration[] = []; - public constructor (canvas?: Canvas, declaration?: SlideDeclaration) { + public constructor (canvas?: C, declaration?: SlideDeclaration) { if (typeof canvas !== 'undefined') { this.canvas = canvas; } @@ -47,15 +49,15 @@ export class Slide { } } - public static create (canvas?: Canvas, declaration?: SlideDeclaration): Slide { + public static create (canvas?: C, declaration?: SlideDeclaration): Slide { return new this(canvas, declaration); } - public static fromObject (obj: SlideDeclaration, canvas?: Canvas): Slide { + public static fromObject (obj: SlideDeclaration, canvas?: C): Slide { return this.create(canvas, obj); } - public static fromJSON (json: string, canvas?: Canvas): Slide { + public static fromJSON (json: string, canvas?: C): Slide { return this.fromObject(JSON.parse(json), canvas); } diff --git a/packages/kittik-slide/src/slide/SlideBuilder.ts b/packages/kittik-slide/src/slide/SlideBuilder.ts index 27cb09e..709069d 100644 --- a/packages/kittik-slide/src/slide/SlideBuilder.ts +++ b/packages/kittik-slide/src/slide/SlideBuilder.ts @@ -3,44 +3,39 @@ import { Canvas } from 'terminal-canvas'; import { ShapeRenderable } from 'kittik-shape-basic'; import { Slide } from './Slide'; -export class SlideBuilder { - private readonly slide: Slide = new Slide(); +export class SlideBuilder { + private readonly slide: Slide = new Slide(); - public static start (): SlideBuilder { + public static start (): SlideBuilder { return new this(); } public withName (name: string): this { this.slide.name = name; - return this; } - public withCanvas (canvas: Readonly): this { + public withCanvas (canvas: Readonly): this { this.slide.canvas = canvas; - return this; } public withShape (name: string, shape: ShapeRenderable): this { this.slide.addShape(name, shape); - return this; } public withAnimation (name: string, animation: Animationable): this { this.slide.addAnimation(name, animation); - return this; } public withOrder (shape: string, animations?: string[]): this { this.slide.addOrder(shape, animations); - return this; } - public end (): Slide { + public end (): Slide { return this.slide; } }