<commit_before>var co = require('co'),
  debug = require('debug'),
  React = require('react'),
  log = debug('bshed:client')

var navigate = require('./actions/navigate'),
  app = require('./app')

// needed for onTouchTap
require('react-tap-event-plugin')()

// assets
require('./assets/styles/index.less')

var mountNode = document.getElementById('bshed') // render node

if (process.env.NODE_ENV !== 'production') {
  window.React = React // For chrome dev tool support
  debug.enable('*')
}

log('rehydrating application')
app.rehydrate(window.BSHED, (err, context) => {
  if (err) throw err
  if (process.env.NODE_ENV !== 'production')
    window.context = context // For debugging

  log('starting router')
  context.getComponentContext().router.run(co.wrap(routerAction(context)))
})

function routerAction (context) {
  return function* (Handler, state) {
    try {
      log('executing navigate action')
      yield context.executeAction(navigate, state)
    } catch (err) {
      console.error('Error executing navigate action', err)
      throw err
    }

    log('rendering application')
    yield render({context, Handler})

    log('navigation and rendering finished')
  }
}

function render ({context, Handler}={}) {
  var element = React.createElement(Handler, {context: context.getComponentContext()})
  return new Promise(resolve => {
    React.render(element, mountNode, resolve)
  })
}
<commit_msg>one-liner<commit_after>var co = require('co'),
  debug = require('debug'),
  React = require('react'),
  log = debug('bshed:client')

var navigate = require('./actions/navigate'),
  app = require('./app')

// needed for onTouchTap
require('react-tap-event-plugin')()

// assets
require('./assets/styles/index.less')

var mountNode = document.getElementById('bshed') // render node

if (process.env.NODE_ENV !== 'production') {
  window.React = React // For chrome dev tool support
  debug.enable('*')
}

log('rehydrating application')
app.rehydrate(window.BSHED, (err, context) => {
  if (err) throw err
  if (process.env.NODE_ENV !== 'production')
    window.context = context // For debugging

  log('starting router')
  context.getComponentContext().router.run(co.wrap(routerAction(context)))
})

function routerAction (context) {
  return function* (Handler, state) {
    try {
      log('executing navigate action')
      yield context.executeAction(navigate, state)
    } catch (err) {
      console.error('Error executing navigate action', err)
      throw err
    }

    log('rendering application')
    yield render({context, Handler})

    log('navigation and rendering finished')
  }
}

function render ({context, Handler}={}) {
  var element = React.createElement(Handler, {context: context.getComponentContext()})
  return new Promise(resolve => React.render(element, mountNode, resolve))
}

{'fraction_non_alphanumeric': 0.1527285613040397, 'fraction_numerical': 0.0, 'mean_word_length': 4.170329670329671, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '569139', 'n_tokens_mistral': 842, 'n_tokens_neox': 821, 'n_words': 204}