<commit_before>"use strict";

let _ = require('lodash');
let Changesets = require('runway-compiler/changesets.js');
let React = require('react');
let ReactDOM = require('react-dom');

let View = function(controller, elem, module) {

let ExecutionView = React.createClass({

  getInitialState: function() {
    return {
      changes: [''],
    };
  },

  /*
  shouldComponentUpdate: function(nextProps, nextState) {
    return Changesets.affected(nextState.changes, '');
  },
  */

  render: function() {
    let renderEvent = (event, i) => {
      let style = {};
      if (event.passedInvariants === false) {
        style = {color: 'red'};
      }
      let time = '';
      if (controller.clockUnits !== undefined) {
        time = `${_.round(event.clock / 1000, 3)} ${controller.clockUnits}: `;
      }
      return <li key={i}>
        <a href=""
          onClick={e => {
            e.preventDefault();
            controller.workspace.setClock(event.clock);
          }}
          style={style}>
            {`${time}${event.msg}`}
        </a>
      </li>;
    };

    return <ol
      start={controller.workspace.cursor.index()}
      reversed="1">
        {controller.workspace.cursor.map(renderEvent).reverse()}
    </ol>;
  }

});

let reactComponent = ReactDOM.render(<ExecutionView />, elem);

return {
  name: 'Execution',
  tab: 'execution',
  update: function(changes) {
    reactComponent.setState({changes: changes});
  }
};
<commit_msg>executionview: show future events<commit_after>"use strict";

let _ = require('lodash');
let Changesets = require('runway-compiler/changesets.js');
let React = require('react');
let ReactDOM = require('react-dom');

let View = function(controller, elem, module) {

let ExecutionView = React.createClass({

  getInitialState: function() {
    return {
      changes: [''],
    };
  },

  /*
  shouldComponentUpdate: function(nextProps, nextState) {
    return Changesets.affected(nextState.changes, '');
  },
  */

  render: function() {
    let renderEvent = (event, i) => {
      let style = {};
      if (event.passedInvariants === false) {
        style = {color: 'red'};
      }
      let time = '';
      if (controller.clockUnits !== undefined) {
        time = `${_.round(event.clock / 1000, 3)} ${controller.clockUnits}: `;
      }
      let background;
      if (i === current) {
        background = '#ddd';
      }
      return <li key={i} style={{background: background}}>
        <a href=""
          onClick={e => {
            e.preventDefault();
            controller.workspace.setClock(event.clock);
          }}
          style={style}>
            {`${time}${event.msg}`}
        </a>
      </li>;
    };
    let cursor = controller.workspace.cursor.execution.last();
    let current = controller.workspace.cursor.index();

    return <ol
      start={cursor.index()}
      reversed="1">
        {cursor.map(renderEvent).reverse()}
    </ol>;
  }

});

let reactComponent = ReactDOM.render(<ExecutionView />, elem);

return {
  name: 'Execution',
  tab: 'execution',
  update: function(changes) {
    reactComponent.setState({changes: changes});
  }
};

{'fraction_non_alphanumeric': 0.1702331523474928, 'fraction_numerical': 0.0038326413286489938, 'mean_word_length': 2.6, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '3779669', 'n_tokens_mistral': 966, 'n_tokens_neox': 952, 'n_words': 188}