<commit_before>import FigTextShape from 'kittik-shape-fig-text';
import ImageShape from 'kittik-shape-image';
import RectangleShape from 'kittik-shape-rectangle';
import TextShape from 'kittik-shape-text';

import PrintAnimation from 'kittik-animation-print';
import SlideAnimation from 'kittik-animation-slide';

const shapes = {
  figText: FigTextShape,
  image: ImageShape,
  rectangle: RectangleShape,
  text: TextShape
};

const animations = {
  print: PrintAnimation,
  slide: SlideAnimation
};

/**
 * Creates a new slide with shapes.
 *
 * @since 1.0.0
 * @version 1.0.0
 */
export default class Slide {
  /**
   * Creates new Slide instance.
   * You must pass serialized Object representation of each {@link Shape} as an array to this constructor.
   *
   * @param {Array<Shape>} shapes Array of serialized shapes
   * @constructor
   * @example
   * Slide.create([{
   *   name: 'Rectangle',
   *   options: {}
   * }, {
   *   name: 'Text',
   *   options: {
   *     text: 'Hello there'
   *   }
   * }]);
   */
  constructor(shapes) {
    this._shapes = shapes.map(shape => shapes[shape.type.toLowerCase()].fromObject(shape));
  }

  /**
   * Renders the slide.
   *
   * @param {Cursor} cursor Cursor instance which is using for rendering the slide
   * @returns {Slide}
   */
  render(cursor) {
    this._shapes.forEach(shape => shape.render(cursor));
    return this;
  }

  /**
   * Wrapper around `new Slide()`.
   *
   * @static
   * @param {*} args
   * @returns {Slide}
   */
  static create(...args) {
    return new this(...args);
  }
}<commit_msg>refactor(slide): Update slide class to newest logic of shapes and animations<commit_after>import FigTextShape from 'kittik-shape-fig-text';
import ImageShape from 'kittik-shape-image';
import RectangleShape from 'kittik-shape-rectangle';
import TextShape from 'kittik-shape-text';

import PrintAnimation from 'kittik-animation-print';
import SlideAnimation from 'kittik-animation-slide';

const SHAPES = {
  figText: FigTextShape,
  image: ImageShape,
  rectangle: RectangleShape,
  text: TextShape
};

const ANIMATIONS = {
  print: PrintAnimation,
  slide: SlideAnimation
};

/**
 * Creates a new slide with shapes.
 *
 * @since 1.0.0
 * @version 1.0.0
 */
export default class Slide {
  /**
   * Creates new Slide instance.
   *
   * @param {Object} [declaration] Array of serialized shapes
   * @param {Array<Object>} [declaration.shapes] Array of shapes to render
   * @param {Array<Object>} [declaration.animations] Array of animation to create in this slide
   * @param {Array<String>} [declaration.flow] Array of flow for current slide
   * @constructor
   */
  constructor(declaration = {}) {
    const {shapes, animations, flow} = declaration;

    this._renderedShapes = [];
    this._shapes = shapes.reduce((obj, shape) => (obj[shape.name] = SHAPES[shape.type.toLowerCase()].fromObject(shape)) && obj, {});
    this._animations = animations.reduce((obj, animation) => (obj[animation.name] = ANIMATIONS[animation.type.toLowerCase()].fromObject(animation)) && obj, {});
    this._flow = flow;
    this._currentPlayIndex = 0;
  }

  _parseFlow(flow) {
    const [,shapeName, animationName] = flow.match(/(.*)\((.*)\)/);
    return {shapeName, animationName};
  }

  /**
   * Renders the slide.
   *
   * @param {Cursor} cursor Cursor instance which is using for rendering the slide
   * @returns {Slide}
   */
  render(cursor) {
    const flow = this._parseFlow(this._flow[this._currentPlayIndex]);
    this._shapes[flow.shapeName].render(cursor);

    return this;
  }

  /**
   * Wrapper around `new Slide()`.
   *
   * @static
   * @param {*} args
   * @returns {Slide}
   */
  static create(...args) {
    return new this(...args);
  }
}
{'fraction_non_alphanumeric': 0.14109110454178983, 'fraction_numerical': 0.0034936844934157483, 'mean_word_length': 3.404733727810651, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '858804', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1200, 'n_words': 306}