<commit_before>
/**
 * Expose `Component`.
 */

module.exports = Component;

/**
 * A component is a stateful virtual dom element.
 *
 * @api public
 */

function Component(opts) {
  if (!(this instanceof Component)) return new Component(opts);
  this.options = {};
  this.layers = {};
  this.props = {};
  if ('function' == typeof opts) {
    this.layers.main = {
      template: opts,
      states: {}
    };
  } else if ('string' == typeof opts) {
    this.name = opts;
  } else if (opts) {
    // TODO: come back to multiple layers
    this.layers.main = {
      template: opts.render,
      states: {}
    };
    if (opts.props) this.props = opts.props;
    // TODO: cleanup or potentially deprecate
    if (opts.beforeMount) this.beforeMount = opts.beforeMount;
    if (opts.afterMount) this.afterMount = opts.afterMount;<commit_msg>added comment about component spec<commit_after>
/**
 * Expose `Component`.
 */

module.exports = Component;

/**
 * A component is a stateful virtual dom element.
 *
 * TODO: Remove this DSL. The component will just be a JSON object,
 * with functions for templates. Then you can write your own wrapper
 * around it to give a nice DSL or whatever.
 *
 * For the moment, we're leaving this DSL in here so we don't have
 * to change a bunch of existing code at once. Once the formal spec is all
 * working, then we'll remove out the DSL :)
 *
 * A component is just this:
 *
 *   {
 *     "name": "Button",
 *     "properties": {},
 *     "options": {},
 *     "layers": {
 *       "main": {
 *         "template": fn,
 *         "states": {
 *           "name": {}
 *         }
 *       }
 *     }
 *   }
 *
 * @api public
 */

function Component(opts) {
  if (!(this instanceof Component)) return new Component(opts);
  this.options = {};
  this.layers = {};
  this.props = {};
  if ('function' == typeof opts) {
    this.layers.main = {
      template: opts,
      states: {}
    };
  } else if ('string' == typeof opts) {
    this.name = opts;
  } else if (opts) {
    // TODO: come back to multiple layers
    this.layers.main = {
      template: opts.render,
      states: {}
    };
    if (opts.props) this.props = opts.props;
    // TODO: cleanup or potentially deprecate
    if (opts.beforeMount) this.beforeMount = opts.beforeMount;
    if (opts.afterMount) this.afterMount = opts.afterMount;
{'fraction_non_alphanumeric': 0.14017094017094017, 'fraction_numerical': 0.0, 'mean_word_length': 2.499252615844544, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, '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': '6575223', 'n_tokens_mistral': 714, 'n_tokens_neox': 703, 'n_words': 229}