<commit_before>;(function(w) {
  if (!w.riot)
    return

  w.riotHorn = new Horn

  class Horn() {
    constructor() {
      this.root = 'body'
      this.ns = 'components' // Namespace under `window`
    }

    root(el) {
      this.root = el
    }

    mountOne(tagName, locals) {
      return riot.mount(
        this.root,
        tagName, // Component' Name
        locals
      )[0]
    }

    mount(tagName) {
      if (!window[this.ns])
        window[this.ns] = {}

      // Mount a tag
      window[this.ns][tagName] = this.mountOne.apply(this, arguments)

      // Listen for all events
      // todo: find a way to listen all riot events
      riot.on('all', (eventName, opts) => {
        const names = splitNames(eventName)

        if (!names || !window[this.ns][names.component])
          return

        window[this.ns][names.component][names.fn](opts)

        return window[this.ns]
      })
    }
  }

  // Split names like `lightbox.open`
  function splitNames(str) {
    const names = str.split('.')

    if (names.length === 1)
      return null

    return {
      component: names[0],
      fn: names[1],
    }
  }
})(this)
<commit_msg>Rewriting riot-horn as a riot mixin<commit_after>;(riot => {
  if (!riot || !riot.mixin)
    return

  riot.mixin('horn', {
    horn: () => {
      let inited = null
      let argvs = arguments

      walk(this, true)

      function walk(tag, pid) {
        if (tag.parent && pid)
          walk(tag.parent, tag._id)

        if (tag.tags) {
          const children = Object.keys(tag.tags)

          (() => {
            if (children.length === 0)
              return

            children.forEach(child => {
              const invalidTag = !tag.tags[child]
              const mutipleTag = !tag.tags[child]._id && tag.tags[child].length > 0

              if (invalidTag)
                return
              
              if (mutipleTag)
                tag.tags[child].forEach(walkOne)

              // For single tag
              walkOne(tag.tags[child])
            })
          })    
        }

        if (!inited)
          return init()

        // In case of same children
        const tags = tag._id ? [tag] : tag

        tags.forEach(t => 
          t.trigger.apply(t, argvs))
      }

      function walkOne(tag, pid) {
        if (tag._id === pid)
          return

        walk(tag)
      }

      function init() {
        inited = true
        return
      }
    }
  })
})(this.riot);

{'fraction_non_alphanumeric': 0.13408723747980614, 'fraction_numerical': 0.0024232633279483036, 'mean_word_length': 1.5096251266464031, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '4178602', 'n_tokens_mistral': 801, 'n_tokens_neox': 751, 'n_words': 173}