<commit_before>/* globals CONFIG, GC, logger */

var dispatchWindowEvent = function(eventName) {
  var e = document.createEvent('Event');
  e.initEvent(eventName, true, true);
  window.dispatchEvent(e);
};

exports.onLaunch = function () {
  var deviceId = CONFIG.simulator.deviceId;
  var deviceType = CONFIG.simulator.deviceType;
  var deviceInfo = CONFIG.simulator.deviceInfo;

  import .simulateDevice;
  simulateDevice.simulate(deviceInfo);

  import devkit.debugging;
  var channel = devkit.debugging.getChannel('devkit-simulator');

  var _isHomeScreen = false;
  channel.on('button:home', function () {
    var app = GC.app;

    _isHomeScreen = !_isHomeScreen;
    if (_isHomeScreen) {
      dispatchWindowEvent('pagehide');
      app.engine.pause();

      var canvas = document.getElementsByTagName('canvas');
      if (canvas.length) {
        canvas = canvas[0];
        if (canvas.getContext) {
          var ctx = canvas.getContext('2d');
          ctx.fillStyle = '#000000';
          ctx.fillRect(0, 0, canvas.width, canvas.height);
        }
      }
    } else {
      dispatchWindowEvent('pageshow');
      app.engine.resume();
    }
  });

  channel.on('button:back', function (evt) {
    GLOBAL.NATIVE.onBackButton && GLOBAL.NATIVE.onBackButton(evt);
  });

  channel.on('screenshot', function (req) {
    devkit.debugging.screenshot(function (err, res) {
      if (err) {
        req.error(err);
      } else {
        req.send(res);
      }
    });
  });

  channel.on('mute', function (evt) {
    console.log('MUTE', evt.shouldMute);
    import AudioManager;
    AudioManager.muteAll(evt.shouldMute);
  });

  channel.on('pause', function () { exports.setPaused(true); });
  channel.on('resume', function () { exports.setPaused(false); });
  channel.on('step', function () { GC.app.engine.stepFrame(); });

  logger.log('waiting for devkit simulator client...');

  import device;

  return channel.connect()<commit_msg>fix screenshot button<commit_after>/* globals CONFIG, GC, logger */

var dispatchWindowEvent = function(eventName) {
  var e = document.createEvent('Event');
  e.initEvent(eventName, true, true);
  window.dispatchEvent(e);
};

exports.onLaunch = function () {
  var deviceId = CONFIG.simulator.deviceId;
  var deviceType = CONFIG.simulator.deviceType;
  var deviceInfo = CONFIG.simulator.deviceInfo;

  import .simulateDevice;
  simulateDevice.simulate(deviceInfo);

  import devkit.debugging;
  var channel = devkit.debugging.getChannel('devkit-simulator');

  var _isHomeScreen = false;
  channel.on('button:home', function () {
    var app = GC.app;

    _isHomeScreen = !_isHomeScreen;
    if (_isHomeScreen) {
      dispatchWindowEvent('pagehide');
      app.engine.pause();

      var canvas = document.getElementsByTagName('canvas');
      if (canvas.length) {
        canvas = canvas[0];
        if (canvas.getContext) {
          var ctx = canvas.getContext('2d');
          ctx.fillStyle = '#000000';
          ctx.fillRect(0, 0, canvas.width, canvas.height);
        }
      }
    } else {
      dispatchWindowEvent('pageshow');
      app.engine.resume();
    }
  });

  channel.on('button:back', function (evt) {
    GLOBAL.NATIVE.onBackButton && GLOBAL.NATIVE.onBackButton(evt);
  });

  channel.on('screenshot', function (data, req) {
    devkit.debugging.screenshot(function (err, res) {
      if (err) {
        req.error(err);
      } else {
        req.send(res);
      }
    });
  });

  channel.on('mute', function (evt) {
    console.log('MUTE', evt.shouldMute);
    import AudioManager;
    AudioManager.muteAll(evt.shouldMute);
  });

  channel.on('pause', function () { exports.setPaused(true); });
  channel.on('resume', function () { exports.setPaused(false); });
  channel.on('step', function () { GC.app.engine.stepFrame(); });

  logger.log('waiting for devkit simulator client...');

  import device;

  return channel.connect()
{'fraction_non_alphanumeric': 0.15197334700153767, 'fraction_numerical': 0.005125576627370579, 'mean_word_length': 3.2240259740259742, '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': '2753821', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1242, 'n_words': 224}