<commit_before>var bridge = require('vigour-native/lib/bridge')
var env = require('vigour-native/lib/env')
// var name = 'plugin'
var id = 'vigour-native-plugin'
var supportedPlatforms = [
  'android',
  'ios'
]
var supportedDevices = [
  'phone',
  'tablet'
]

module.exports = exports = {}

exports.usable = ~supportedDevices.indexOf(env.ua.device) &&
  ~supportedPlatforms.indexOf(env.ua.platform)

exports.act = function (opts, cb) {
  // var error
  if (!cb) {
    cb = opts
    opts = null
  }
  bridge.call(id, 'act', opts, cb)
}
<commit_msg>Call native initialization from js<commit_after>var bridge = require('vigour-native/lib/bridge')
var pkg = require('./package.json')
var pluginId = pkg.vigour.plugin.id

module.exports = exports = {}

exports.bridgeCall = function (fn, opts, cb) {
  if (!cb) {
    cb = opts
    opts = null
  }
  bridge.call(pluginId, fn, opts, cb)
}

// TODO Everything above this line feels like boilerplate
// and should probably be moved to lib/bridge somehow

// If plugin requires initialization on the native side
exports.bridgeCall('init', function (err) {
  if (!err) {
    // Native part is ready
    exports.init()
  } else {
    throw err
  }
})

exports.init = function () {
  // Do something
}

exports.act = function (opts, cb) {
  exports.bridgeCall('act', opts, cb)
}

{'fraction_non_alphanumeric': 0.1441578148710167, 'fraction_numerical': 0.0, 'mean_word_length': 3.456081081081081, 'pattern_counts': {'":': 0, '<': 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': '28167', 'n_tokens_mistral': 445, 'n_tokens_neox': 439, 'n_words': 119}