<commit_before>/**
 * Manages the scene state for Homenet.
 * Injecting {@link module:scene|scene} will provide a {@link module:scene~SceneManager|SceneManager} instance.
 * @module scene
 * @example
 * function (scene) {
 *   console.log(scene.current);
 *   scene.set('away');
 * }
 */

var MODULE_NAME = 'scene';
module.exports = exports = factory;
exports.$service = MODULE_NAME;
exports.$inject = ['logger', 'storage', 'config', 'eventBus', 'states'];
var STATE_TYPE = MODULE_NAME;
var DEFAULT_SCENE = 'default';

var SceneManager = require('./scene-manager.ts');

function factory(services) {

  var scenes = services.config.scenes;
  var states = services.states;
  var storage = services.storage;
  var logger = services.logger.getLogger('scene');

  logger.debug('Initializing scene service');

  return storage.get('scene:active')
    .then(function(result) {

      logger.debug('Initial scene loaded from storage: ' + result);

      var opts = {
      
        eventBus: services.eventBus,
        // sceneLogic: services['scenelogic'],
        // initialScene: (services['sunlight'].isLight() ? 'normal' : 'night'),
        // initialScene: services.persistence.get('scene') || (services.sunlight.isLight() ? 'normal' : 'night'),
        // notifications: services.notifications,
        
        initialScene: result || DEFAULT_SCENE,
        storage: services.storage,
        logger: logger
      
      };

      var manager = new SceneManager(scenes || [], opts);
      states.addType(STATE_TYPE, {
        getCurrent: function() {
          return manager.current;
        },
        setCurrent: function(state) {
          manager.set(state);
        },
        emitOnSet: false
      });
      manager.onChanged(function(state) {
        states.emitState(STATE_TYPE, state);
      });
      return manager;
    });
}
<commit_msg>only emit id in event<commit_after>/**
 * Manages the scene state for Homenet.
 * Injecting {@link module:scene|scene} will provide a {@link module:scene~SceneManager|SceneManager} instance.
 * @module scene
 * @example
 * function (scene) {
 *   console.log(scene.current);
 *   scene.set('away');
 * }
 */

var MODULE_NAME = 'scene';
module.exports = exports = factory;
exports.$service = MODULE_NAME;
exports.$inject = ['logger', 'storage', 'config', 'eventBus', 'states'];
var STATE_TYPE = MODULE_NAME;
var DEFAULT_SCENE = 'default';

var SceneManager = require('./scene-manager.ts');

function factory(services) {

  var scenes = services.config.scenes;
  var states = services.states;
  var storage = services.storage;
  var logger = services.logger.getLogger('scene');

  logger.debug('Initializing scene service');

  return storage.get('scene:active')
    .then(function(result) {

      logger.debug('Initial scene loaded from storage: ' + result);

      var opts = {
      
        eventBus: services.eventBus,
        // sceneLogic: services['scenelogic'],
        // initialScene: (services['sunlight'].isLight() ? 'normal' : 'night'),
        // initialScene: services.persistence.get('scene') || (services.sunlight.isLight() ? 'normal' : 'night'),
        // notifications: services.notifications,
        
        initialScene: result || DEFAULT_SCENE,
        storage: services.storage,
        logger: logger
      
      };

      var manager = new SceneManager(scenes || [], opts);
      states.addType(STATE_TYPE, {
        getCurrent: function() {
          return manager.current;
        },
        setCurrent: function(state) {
          manager.set(state);
        },
        emitOnSet: false
      });
      manager.onChanged(function(state) {
        states.emitState(STATE_TYPE, state.id);
      });
      return manager;
    });
}

{'fraction_non_alphanumeric': 0.14247239429033126, 'fraction_numerical': 0.0, 'mean_word_length': 2.967948717948718, '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': '7513549', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1054, 'n_words': 236}