<commit_before>var Flow = require('./flow/flow');

// init flow with core module
Flow({

    // load module bundles and return the entry-point exports
    module: function (name, callback) {

        // crate script dom elemeent
        var node = document.createElement('script');

        node.onload = function () {
            callback(null, require(name));
        };

        // set url and append dom script elm to the document head
        node.src = '/@/' + name + '/client.js';
        document.head.appendChild(node);
        node.remove();
    },
    composition: '@C',
    markup: '@M',
    cache: function () {},
    log: function (err) {return err} //require('./logs') ||
});

var ws = new WebSocket('wss://' + location.host);

ws.onopen = function () {
    ws.send(JSON.stringify(['instance', 'event', {from: 'client'}]));
};
ws.onmessage = function (msg) {
    console.log(JSON.parse(msg.data));
};<commit_msg>load markup and style draft<commit_after>var Flow = require('./flow/flow');
var socket = require('./socket');

// init flow with core module
var flow = Flow({

    // load module bundles and return the entry-point exports
    // USED IN flow.js
    module: function (name, callback) {

        // crate script dom element
        var node = document.createElement('script');

        node.onload = function () {
            callback(null, require(name));
        };

        // set url and append dom script elm to the document head
        node.src = '/' + name + '/client.js';
        document.head.appendChild(node);
        node.remove();
    },

    // USED IN flow.js
    composition: function () {
        // load composition
        this.flow('getIc');
    },

    /**
     * Load html snippets.
     *
     * @public
     * @param {array} The array containing html snippet file urls.
     */
    // TODO use xhr2 to use browser caching
    // USED IN instance.js
    markup: function (urls) {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', '/@:M/path', true);
        xhr.onload = function(e) {
          if (this.status == 200) {
              return callback(null, this.response);
          }

          callback();
        };

        urls.forEach(function (url) {
            xhr.send(url);
        })
    },

    /**
     * Load css files.
     *
     * @public
     * @param {array} The array containing css file urls.
     */
    // USED IN instance.js
    styles: function (urls) {
        urls.forEach(function (url) {
            var link = document.createElement('link');
            link.setAttribute('rel', 'stylesheet');
            link.setAttribute('href', url);
            global.document.head.appendChild(link);
        });
    },

    cache: function () {},
    log: function (err) {return err}, //require('./logs') ||

    // TODO move this to the server
    message: socket.message
});

flow.load();

{'fraction_non_alphanumeric': 0.14991304347826087, 'fraction_numerical': 0.001391304347826087, 'mean_word_length': 2.024185068349106, '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': '464835', 'n_tokens_mistral': 834, 'n_tokens_neox': 810, 'n_words': 233}