references & composition value
fixing bugs with references composition type parses now composition value
This commit is contained in:
		
							parent
							
								
									757bb118ce
								
							
						
					
					
						commit
						f44f463e9d
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -19,22 +19,22 @@ adaptConnector = function(connector, engine, HB, execution_listener) {
 | 
			
		||||
  }
 | 
			
		||||
  execution_listener.push(send_);
 | 
			
		||||
  encode_state_vector = function(v) {
 | 
			
		||||
    var value, _results;
 | 
			
		||||
    _results = [];
 | 
			
		||||
    var results, value;
 | 
			
		||||
    results = [];
 | 
			
		||||
    for (name in v) {
 | 
			
		||||
      value = v[name];
 | 
			
		||||
      _results.push({
 | 
			
		||||
      results.push({
 | 
			
		||||
        user: name,
 | 
			
		||||
        state: value
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
    return _results;
 | 
			
		||||
    return results;
 | 
			
		||||
  };
 | 
			
		||||
  parse_state_vector = function(v) {
 | 
			
		||||
    var s, state_vector, _i, _len;
 | 
			
		||||
    var i, len, s, state_vector;
 | 
			
		||||
    state_vector = {};
 | 
			
		||||
    for (_i = 0, _len = v.length; _i < _len; _i++) {
 | 
			
		||||
      s = v[_i];
 | 
			
		||||
    for (i = 0, len = v.length; i < len; i++) {
 | 
			
		||||
      s = v[i];
 | 
			
		||||
      state_vector[s.user] = s.state;
 | 
			
		||||
    }
 | 
			
		||||
    return state_vector;
 | 
			
		||||
 | 
			
		||||
@ -47,12 +47,12 @@ module.exports = {
 | 
			
		||||
    return this.role === "slave";
 | 
			
		||||
  },
 | 
			
		||||
  findNewSyncTarget: function() {
 | 
			
		||||
    var c, user, _ref;
 | 
			
		||||
    var c, ref, user;
 | 
			
		||||
    this.current_sync_target = null;
 | 
			
		||||
    if (this.syncMethod === "syncAll") {
 | 
			
		||||
      _ref = this.connections;
 | 
			
		||||
      for (user in _ref) {
 | 
			
		||||
        c = _ref[user];
 | 
			
		||||
      ref = this.connections;
 | 
			
		||||
      for (user in ref) {
 | 
			
		||||
        c = ref[user];
 | 
			
		||||
        if (!c.is_synced) {
 | 
			
		||||
          this.performSync(user);
 | 
			
		||||
          break;
 | 
			
		||||
@ -69,12 +69,12 @@ module.exports = {
 | 
			
		||||
    return this.findNewSyncTarget();
 | 
			
		||||
  },
 | 
			
		||||
  userJoined: function(user, role) {
 | 
			
		||||
    var _base;
 | 
			
		||||
    var base;
 | 
			
		||||
    if (role == null) {
 | 
			
		||||
      throw new Error("Internal: You must specify the role of the joined user! E.g. userJoined('uid:3939','slave')");
 | 
			
		||||
    }
 | 
			
		||||
    if ((_base = this.connections)[user] == null) {
 | 
			
		||||
      _base[user] = {};
 | 
			
		||||
    if ((base = this.connections)[user] == null) {
 | 
			
		||||
      base[user] = {};
 | 
			
		||||
    }
 | 
			
		||||
    this.connections[user].is_synced = false;
 | 
			
		||||
    if ((!this.is_synced) || this.syncMethod === "syncAll") {
 | 
			
		||||
@ -116,7 +116,7 @@ module.exports = {
 | 
			
		||||
    throw new Error "You must implement send!"
 | 
			
		||||
   */
 | 
			
		||||
  performSync: function(user) {
 | 
			
		||||
    var hb, o, _hb, _i, _len;
 | 
			
		||||
    var _hb, hb, i, len, o;
 | 
			
		||||
    if (this.current_sync_target == null) {
 | 
			
		||||
      this.current_sync_target = user;
 | 
			
		||||
      this.send(user, {
 | 
			
		||||
@ -128,8 +128,8 @@ module.exports = {
 | 
			
		||||
        this.sent_hb_to_all_users = true;
 | 
			
		||||
        hb = this.getHB([]).hb;
 | 
			
		||||
        _hb = [];
 | 
			
		||||
        for (_i = 0, _len = hb.length; _i < _len; _i++) {
 | 
			
		||||
          o = hb[_i];
 | 
			
		||||
        for (i = 0, len = hb.length; i < len; i++) {
 | 
			
		||||
          o = hb[i];
 | 
			
		||||
          _hb.push(o);
 | 
			
		||||
          if (_hb.length > 10) {
 | 
			
		||||
            this.broadcast({
 | 
			
		||||
@ -147,7 +147,7 @@ module.exports = {
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  performSyncWithMaster: function(user) {
 | 
			
		||||
    var hb, o, _hb, _i, _len;
 | 
			
		||||
    var _hb, hb, i, len, o;
 | 
			
		||||
    this.current_sync_target = user;
 | 
			
		||||
    this.send(user, {
 | 
			
		||||
      sync_step: "getHB",
 | 
			
		||||
@ -156,8 +156,8 @@ module.exports = {
 | 
			
		||||
    });
 | 
			
		||||
    hb = this.getHB([]).hb;
 | 
			
		||||
    _hb = [];
 | 
			
		||||
    for (_i = 0, _len = hb.length; _i < _len; _i++) {
 | 
			
		||||
      o = hb[_i];
 | 
			
		||||
    for (i = 0, len = hb.length; i < len; i++) {
 | 
			
		||||
      o = hb[i];
 | 
			
		||||
      _hb.push(o);
 | 
			
		||||
      if (_hb.length > 10) {
 | 
			
		||||
        this.broadcast({
 | 
			
		||||
@ -173,13 +173,13 @@ module.exports = {
 | 
			
		||||
    });
 | 
			
		||||
  },
 | 
			
		||||
  setStateSynced: function() {
 | 
			
		||||
    var f, _i, _len, _ref;
 | 
			
		||||
    var f, i, len, ref;
 | 
			
		||||
    if (!this.is_synced) {
 | 
			
		||||
      this.is_synced = true;
 | 
			
		||||
      if (this.compute_when_synced != null) {
 | 
			
		||||
        _ref = this.compute_when_synced;
 | 
			
		||||
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
          f = _ref[_i];
 | 
			
		||||
        ref = this.compute_when_synced;
 | 
			
		||||
        for (i = 0, len = ref.length; i < len; i++) {
 | 
			
		||||
          f = ref[i];
 | 
			
		||||
          f();
 | 
			
		||||
        }
 | 
			
		||||
        delete this.compute_when_synced;
 | 
			
		||||
@ -188,15 +188,15 @@ module.exports = {
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  receiveMessage: function(sender, res) {
 | 
			
		||||
    var data, f, hb, o, sendApplyHB, send_again, _hb, _i, _j, _len, _len1, _ref, _results;
 | 
			
		||||
    var _hb, data, f, hb, i, j, len, len1, o, ref, results, sendApplyHB, send_again;
 | 
			
		||||
    if (res.sync_step == null) {
 | 
			
		||||
      _ref = this.receive_handlers;
 | 
			
		||||
      _results = [];
 | 
			
		||||
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
        f = _ref[_i];
 | 
			
		||||
        _results.push(f(sender, res));
 | 
			
		||||
      ref = this.receive_handlers;
 | 
			
		||||
      results = [];
 | 
			
		||||
      for (i = 0, len = ref.length; i < len; i++) {
 | 
			
		||||
        f = ref[i];
 | 
			
		||||
        results.push(f(sender, res));
 | 
			
		||||
      }
 | 
			
		||||
      return _results;
 | 
			
		||||
      return results;
 | 
			
		||||
    } else {
 | 
			
		||||
      if (sender === this.user_id) {
 | 
			
		||||
        return;
 | 
			
		||||
@ -218,8 +218,8 @@ module.exports = {
 | 
			
		||||
            };
 | 
			
		||||
          })(this);
 | 
			
		||||
        }
 | 
			
		||||
        for (_j = 0, _len1 = hb.length; _j < _len1; _j++) {
 | 
			
		||||
          o = hb[_j];
 | 
			
		||||
        for (j = 0, len1 = hb.length; j < len1; j++) {
 | 
			
		||||
          o = hb[j];
 | 
			
		||||
          _hb.push(o);
 | 
			
		||||
          if (_hb.length > 10) {
 | 
			
		||||
            sendApplyHB({
 | 
			
		||||
@ -262,25 +262,25 @@ module.exports = {
 | 
			
		||||
  parseMessageFromXml: function(m) {
 | 
			
		||||
    var parse_array, parse_object;
 | 
			
		||||
    parse_array = function(node) {
 | 
			
		||||
      var n, _i, _len, _ref, _results;
 | 
			
		||||
      _ref = node.children;
 | 
			
		||||
      _results = [];
 | 
			
		||||
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
        n = _ref[_i];
 | 
			
		||||
      var i, len, n, ref, results;
 | 
			
		||||
      ref = node.children;
 | 
			
		||||
      results = [];
 | 
			
		||||
      for (i = 0, len = ref.length; i < len; i++) {
 | 
			
		||||
        n = ref[i];
 | 
			
		||||
        if (n.getAttribute("isArray") === "true") {
 | 
			
		||||
          _results.push(parse_array(n));
 | 
			
		||||
          results.push(parse_array(n));
 | 
			
		||||
        } else {
 | 
			
		||||
          _results.push(parse_object(n));
 | 
			
		||||
          results.push(parse_object(n));
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return _results;
 | 
			
		||||
      return results;
 | 
			
		||||
    };
 | 
			
		||||
    parse_object = function(node) {
 | 
			
		||||
      var int, json, n, name, value, _i, _len, _ref, _ref1;
 | 
			
		||||
      var i, int, json, len, n, name, ref, ref1, value;
 | 
			
		||||
      json = {};
 | 
			
		||||
      _ref = node.attrs;
 | 
			
		||||
      for (name in _ref) {
 | 
			
		||||
        value = _ref[name];
 | 
			
		||||
      ref = node.attrs;
 | 
			
		||||
      for (name in ref) {
 | 
			
		||||
        value = ref[name];
 | 
			
		||||
        int = parseInt(value);
 | 
			
		||||
        if (isNaN(int) || ("" + int) !== value) {
 | 
			
		||||
          json[name] = value;
 | 
			
		||||
@ -288,9 +288,9 @@ module.exports = {
 | 
			
		||||
          json[name] = int;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      _ref1 = node.children;
 | 
			
		||||
      for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
 | 
			
		||||
        n = _ref1[_i];
 | 
			
		||||
      ref1 = node.children;
 | 
			
		||||
      for (i = 0, len = ref1.length; i < len; i++) {
 | 
			
		||||
        n = ref1[i];
 | 
			
		||||
        name = n.name;
 | 
			
		||||
        if (n.getAttribute("isArray") === "true") {
 | 
			
		||||
          json[name] = parse_array(n);
 | 
			
		||||
@ -321,10 +321,10 @@ module.exports = {
 | 
			
		||||
      return m;
 | 
			
		||||
    };
 | 
			
		||||
    encode_array = function(m, array) {
 | 
			
		||||
      var e, _i, _len;
 | 
			
		||||
      var e, i, len;
 | 
			
		||||
      m.setAttribute("isArray", "true");
 | 
			
		||||
      for (_i = 0, _len = array.length; _i < _len; _i++) {
 | 
			
		||||
        e = array[_i];
 | 
			
		||||
      for (i = 0, len = array.length; i < len; i++) {
 | 
			
		||||
        e = array[i];
 | 
			
		||||
        if (e.constructor === Object) {
 | 
			
		||||
          encode_object(m.c("array-element"), e);
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
@ -13,9 +13,9 @@ if (typeof window !== "undefined" && window !== null) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Engine = (function() {
 | 
			
		||||
  function Engine(_at_HB, _at_types) {
 | 
			
		||||
    this.HB = _at_HB;
 | 
			
		||||
    this.types = _at_types;
 | 
			
		||||
  function Engine(HB, types) {
 | 
			
		||||
    this.HB = HB;
 | 
			
		||||
    this.types = types;
 | 
			
		||||
    this.unprocessed_ops = [];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -42,17 +42,17 @@ Engine = (function() {
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  Engine.prototype.applyOpsCheckDouble = function(ops_json) {
 | 
			
		||||
    var o, _i, _len, _results;
 | 
			
		||||
    _results = [];
 | 
			
		||||
    for (_i = 0, _len = ops_json.length; _i < _len; _i++) {
 | 
			
		||||
      o = ops_json[_i];
 | 
			
		||||
    var i, len, o, results;
 | 
			
		||||
    results = [];
 | 
			
		||||
    for (i = 0, len = ops_json.length; i < len; i++) {
 | 
			
		||||
      o = ops_json[i];
 | 
			
		||||
      if (this.HB.getOperation(o.uid) == null) {
 | 
			
		||||
        _results.push(this.applyOp(o));
 | 
			
		||||
        results.push(this.applyOp(o));
 | 
			
		||||
      } else {
 | 
			
		||||
        _results.push(void 0);
 | 
			
		||||
        results.push(void 0);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return _results;
 | 
			
		||||
    return results;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  Engine.prototype.applyOps = function(ops_json) {
 | 
			
		||||
@ -60,15 +60,15 @@ Engine = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  Engine.prototype.applyOp = function(op_json_array, fromHB) {
 | 
			
		||||
    var o, op_json, _i, _len;
 | 
			
		||||
    var i, len, o, op_json;
 | 
			
		||||
    if (fromHB == null) {
 | 
			
		||||
      fromHB = false;
 | 
			
		||||
    }
 | 
			
		||||
    if (op_json_array.constructor !== Array) {
 | 
			
		||||
      op_json_array = [op_json_array];
 | 
			
		||||
    }
 | 
			
		||||
    for (_i = 0, _len = op_json_array.length; _i < _len; _i++) {
 | 
			
		||||
      op_json = op_json_array[_i];
 | 
			
		||||
    for (i = 0, len = op_json_array.length; i < len; i++) {
 | 
			
		||||
      op_json = op_json_array[i];
 | 
			
		||||
      if (fromHB) {
 | 
			
		||||
        op_json.fromHB = "true";
 | 
			
		||||
      }
 | 
			
		||||
@ -90,13 +90,13 @@ Engine = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  Engine.prototype.tryUnprocessed = function() {
 | 
			
		||||
    var old_length, op, unprocessed, _i, _len, _ref;
 | 
			
		||||
    var i, len, old_length, op, ref, unprocessed;
 | 
			
		||||
    while (true) {
 | 
			
		||||
      old_length = this.unprocessed_ops.length;
 | 
			
		||||
      unprocessed = [];
 | 
			
		||||
      _ref = this.unprocessed_ops;
 | 
			
		||||
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
        op = _ref[_i];
 | 
			
		||||
      ref = this.unprocessed_ops;
 | 
			
		||||
      for (i = 0, len = ref.length; i < len; i++) {
 | 
			
		||||
        op = ref[i];
 | 
			
		||||
        if (this.HB.getOperation(op) != null) {
 | 
			
		||||
 | 
			
		||||
        } else if ((!this.HB.isExpectedOperation(op) && (op.fromHB == null)) || (!op.execute())) {
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
var HistoryBuffer,
 | 
			
		||||
  __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
 | 
			
		||||
  bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
 | 
			
		||||
 | 
			
		||||
HistoryBuffer = (function() {
 | 
			
		||||
  function HistoryBuffer(_at_user_id) {
 | 
			
		||||
    this.user_id = _at_user_id;
 | 
			
		||||
    this.emptyGarbage = __bind(this.emptyGarbage, this);
 | 
			
		||||
  function HistoryBuffer(user_id1) {
 | 
			
		||||
    this.user_id = user_id1;
 | 
			
		||||
    this.emptyGarbage = bind(this.emptyGarbage, this);
 | 
			
		||||
    this.operation_counter = {};
 | 
			
		||||
    this.buffer = {};
 | 
			
		||||
    this.change_listeners = [];
 | 
			
		||||
@ -43,10 +43,10 @@ HistoryBuffer = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.emptyGarbage = function() {
 | 
			
		||||
    var o, _i, _len, _ref;
 | 
			
		||||
    _ref = this.garbage;
 | 
			
		||||
    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
      o = _ref[_i];
 | 
			
		||||
    var i, len, o, ref;
 | 
			
		||||
    ref = this.garbage;
 | 
			
		||||
    for (i = 0, len = ref.length; i < len; i++) {
 | 
			
		||||
      o = ref[i];
 | 
			
		||||
      if (typeof o.cleanup === "function") {
 | 
			
		||||
        o.cleanup();
 | 
			
		||||
      }
 | 
			
		||||
@ -64,18 +64,18 @@ HistoryBuffer = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.addToGarbageCollector = function() {
 | 
			
		||||
    var o, _i, _len, _results;
 | 
			
		||||
    var i, len, o, results;
 | 
			
		||||
    if (this.performGarbageCollection) {
 | 
			
		||||
      _results = [];
 | 
			
		||||
      for (_i = 0, _len = arguments.length; _i < _len; _i++) {
 | 
			
		||||
        o = arguments[_i];
 | 
			
		||||
      results = [];
 | 
			
		||||
      for (i = 0, len = arguments.length; i < len; i++) {
 | 
			
		||||
        o = arguments[i];
 | 
			
		||||
        if (o != null) {
 | 
			
		||||
          _results.push(this.garbage.push(o));
 | 
			
		||||
          results.push(this.garbage.push(o));
 | 
			
		||||
        } else {
 | 
			
		||||
          _results.push(void 0);
 | 
			
		||||
          results.push(void 0);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return _results;
 | 
			
		||||
      return results;
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
@ -92,8 +92,8 @@ HistoryBuffer = (function() {
 | 
			
		||||
    return this.garbageCollectTimeoutId = void 0;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.setGarbageCollectTimeout = function(_at_garbageCollectTimeout) {
 | 
			
		||||
    this.garbageCollectTimeout = _at_garbageCollectTimeout;
 | 
			
		||||
  HistoryBuffer.prototype.setGarbageCollectTimeout = function(garbageCollectTimeout) {
 | 
			
		||||
    this.garbageCollectTimeout = garbageCollectTimeout;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.getReservedUniqueIdentifier = function() {
 | 
			
		||||
@ -104,12 +104,12 @@ HistoryBuffer = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.getOperationCounter = function(user_id) {
 | 
			
		||||
    var ctn, res, user, _ref;
 | 
			
		||||
    var ctn, ref, res, user;
 | 
			
		||||
    if (user_id == null) {
 | 
			
		||||
      res = {};
 | 
			
		||||
      _ref = this.operation_counter;
 | 
			
		||||
      for (user in _ref) {
 | 
			
		||||
        ctn = _ref[user];
 | 
			
		||||
      ref = this.operation_counter;
 | 
			
		||||
      for (user in ref) {
 | 
			
		||||
        ctn = ref[user];
 | 
			
		||||
        res[user] = ctn;
 | 
			
		||||
      }
 | 
			
		||||
      return res;
 | 
			
		||||
@ -119,16 +119,16 @@ HistoryBuffer = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.isExpectedOperation = function(o) {
 | 
			
		||||
    var _base, _name;
 | 
			
		||||
    if ((_base = this.operation_counter)[_name = o.uid.creator] == null) {
 | 
			
		||||
      _base[_name] = 0;
 | 
			
		||||
    var base, name;
 | 
			
		||||
    if ((base = this.operation_counter)[name = o.uid.creator] == null) {
 | 
			
		||||
      base[name] = 0;
 | 
			
		||||
    }
 | 
			
		||||
    o.uid.op_number <= this.operation_counter[o.uid.creator];
 | 
			
		||||
    return true;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype._encode = function(state_vector) {
 | 
			
		||||
    var json, o, o_json, o_next, o_number, o_prev, u_name, unknown, user, _ref;
 | 
			
		||||
    var json, o, o_json, o_next, o_number, o_prev, ref, u_name, unknown, user;
 | 
			
		||||
    if (state_vector == null) {
 | 
			
		||||
      state_vector = {};
 | 
			
		||||
    }
 | 
			
		||||
@ -139,9 +139,9 @@ HistoryBuffer = (function() {
 | 
			
		||||
      }
 | 
			
		||||
      return (state_vector[user] == null) || state_vector[user] <= o_number;
 | 
			
		||||
    };
 | 
			
		||||
    _ref = this.buffer;
 | 
			
		||||
    for (u_name in _ref) {
 | 
			
		||||
      user = _ref[u_name];
 | 
			
		||||
    ref = this.buffer;
 | 
			
		||||
    for (u_name in ref) {
 | 
			
		||||
      user = ref[u_name];
 | 
			
		||||
      if (u_name === "_") {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
@ -186,11 +186,11 @@ HistoryBuffer = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.getOperation = function(uid) {
 | 
			
		||||
    var o, _ref;
 | 
			
		||||
    var o, ref;
 | 
			
		||||
    if (uid.uid != null) {
 | 
			
		||||
      uid = uid.uid;
 | 
			
		||||
    }
 | 
			
		||||
    o = (_ref = this.buffer[uid.creator]) != null ? _ref[uid.op_number] : void 0;
 | 
			
		||||
    o = (ref = this.buffer[uid.creator]) != null ? ref[uid.op_number] : void 0;
 | 
			
		||||
    if ((uid.sub != null) && (o != null)) {
 | 
			
		||||
      return o.retrieveSub(uid.sub);
 | 
			
		||||
    } else {
 | 
			
		||||
@ -214,8 +214,8 @@ HistoryBuffer = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.removeOperation = function(o) {
 | 
			
		||||
    var _ref;
 | 
			
		||||
    return (_ref = this.buffer[o.uid.creator]) != null ? delete _ref[o.uid.op_number] : void 0;
 | 
			
		||||
    var ref;
 | 
			
		||||
    return (ref = this.buffer[o.uid.creator]) != null ? delete ref[o.uid.op_number] : void 0;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.setInvokeSyncHandler = function(f) {
 | 
			
		||||
@ -225,23 +225,23 @@ HistoryBuffer = (function() {
 | 
			
		||||
  HistoryBuffer.prototype.invokeSync = function() {};
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.renewStateVector = function(state_vector) {
 | 
			
		||||
    var state, user, _results;
 | 
			
		||||
    _results = [];
 | 
			
		||||
    var results, state, user;
 | 
			
		||||
    results = [];
 | 
			
		||||
    for (user in state_vector) {
 | 
			
		||||
      state = state_vector[user];
 | 
			
		||||
      if (((this.operation_counter[user] == null) || (this.operation_counter[user] < state_vector[user])) && (state_vector[user] != null)) {
 | 
			
		||||
        _results.push(this.operation_counter[user] = state_vector[user]);
 | 
			
		||||
        results.push(this.operation_counter[user] = state_vector[user]);
 | 
			
		||||
      } else {
 | 
			
		||||
        _results.push(void 0);
 | 
			
		||||
        results.push(void 0);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return _results;
 | 
			
		||||
    return results;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  HistoryBuffer.prototype.addToCounter = function(o) {
 | 
			
		||||
    var _base, _name;
 | 
			
		||||
    if ((_base = this.operation_counter)[_name = o.uid.creator] == null) {
 | 
			
		||||
      _base[_name] = 0;
 | 
			
		||||
    var base, name;
 | 
			
		||||
    if ((base = this.operation_counter)[name = o.uid.creator] == null) {
 | 
			
		||||
      base[name] = 0;
 | 
			
		||||
    }
 | 
			
		||||
    if (o.uid.creator !== this.getUserId()) {
 | 
			
		||||
      if (o.uid.op_number === this.operation_counter[o.uid.creator]) {
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
var YObject;
 | 
			
		||||
 | 
			
		||||
YObject = (function() {
 | 
			
		||||
  function YObject(_at__object) {
 | 
			
		||||
    var name, val, _ref;
 | 
			
		||||
    this._object = _at__object != null ? _at__object : {};
 | 
			
		||||
  function YObject(_object) {
 | 
			
		||||
    var name, ref, val;
 | 
			
		||||
    this._object = _object != null ? _object : {};
 | 
			
		||||
    if (this._object.constructor === Object) {
 | 
			
		||||
      _ref = this._object;
 | 
			
		||||
      for (name in _ref) {
 | 
			
		||||
        val = _ref[name];
 | 
			
		||||
      ref = this._object;
 | 
			
		||||
      for (name in ref) {
 | 
			
		||||
        val = ref[name];
 | 
			
		||||
        if (val.constructor === Object) {
 | 
			
		||||
          this._object[name] = new YObject(val);
 | 
			
		||||
        }
 | 
			
		||||
@ -20,12 +20,12 @@ YObject = (function() {
 | 
			
		||||
  YObject.prototype._name = "Object";
 | 
			
		||||
 | 
			
		||||
  YObject.prototype._getModel = function(types, ops) {
 | 
			
		||||
    var n, o, _ref;
 | 
			
		||||
    var n, o, ref;
 | 
			
		||||
    if (this._model == null) {
 | 
			
		||||
      this._model = new ops.MapManager(this).execute();
 | 
			
		||||
      _ref = this._object;
 | 
			
		||||
      for (n in _ref) {
 | 
			
		||||
        o = _ref[n];
 | 
			
		||||
      ref = this._object;
 | 
			
		||||
      for (n in ref) {
 | 
			
		||||
        o = ref[n];
 | 
			
		||||
        this._model.val(n, o);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@ -33,8 +33,8 @@ YObject = (function() {
 | 
			
		||||
    return this._model;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  YObject.prototype._setModel = function(_at__model) {
 | 
			
		||||
    this._model = _at__model;
 | 
			
		||||
  YObject.prototype._setModel = function(_model) {
 | 
			
		||||
    this._model = _model;
 | 
			
		||||
    return delete this._object;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
@ -49,7 +49,7 @@ YObject = (function() {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  YObject.prototype.val = function(name, content) {
 | 
			
		||||
    var n, res, v, _ref;
 | 
			
		||||
    var n, ref, res, v;
 | 
			
		||||
    if (this._model != null) {
 | 
			
		||||
      return this._model.val.apply(this._model, arguments);
 | 
			
		||||
    } else {
 | 
			
		||||
@ -59,9 +59,9 @@ YObject = (function() {
 | 
			
		||||
        return this._object[name];
 | 
			
		||||
      } else {
 | 
			
		||||
        res = {};
 | 
			
		||||
        _ref = this._object;
 | 
			
		||||
        for (n in _ref) {
 | 
			
		||||
          v = _ref[n];
 | 
			
		||||
        ref = this._object;
 | 
			
		||||
        for (n in ref) {
 | 
			
		||||
          v = ref[n];
 | 
			
		||||
          res[n] = v;
 | 
			
		||||
        }
 | 
			
		||||
        return res;
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
var __slice = [].slice,
 | 
			
		||||
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
 | 
			
		||||
  __hasProp = {}.hasOwnProperty;
 | 
			
		||||
var slice = [].slice,
 | 
			
		||||
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
 | 
			
		||||
  hasProp = {}.hasOwnProperty;
 | 
			
		||||
 | 
			
		||||
module.exports = function() {
 | 
			
		||||
  var execution_listener, ops;
 | 
			
		||||
@ -51,19 +51,19 @@ module.exports = function() {
 | 
			
		||||
      } else {
 | 
			
		||||
        callon = this;
 | 
			
		||||
      }
 | 
			
		||||
      return this.forwardEvent.apply(this, [callon].concat(__slice.call(arguments)));
 | 
			
		||||
      return this.forwardEvent.apply(this, [callon].concat(slice.call(arguments)));
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.forwardEvent = function() {
 | 
			
		||||
      var args, f, op, _i, _len, _ref, _results;
 | 
			
		||||
      op = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
 | 
			
		||||
      _ref = this.event_listeners;
 | 
			
		||||
      _results = [];
 | 
			
		||||
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
        f = _ref[_i];
 | 
			
		||||
        _results.push(f.call.apply(f, [op].concat(__slice.call(args))));
 | 
			
		||||
      var args, f, j, len, op, ref, results;
 | 
			
		||||
      op = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
 | 
			
		||||
      ref = this.event_listeners;
 | 
			
		||||
      results = [];
 | 
			
		||||
      for (j = 0, len = ref.length; j < len; j++) {
 | 
			
		||||
        f = ref[j];
 | 
			
		||||
        results.push(f.call.apply(f, [op].concat(slice.call(args))));
 | 
			
		||||
      }
 | 
			
		||||
      return _results;
 | 
			
		||||
      return results;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.isDeleted = function() {
 | 
			
		||||
@ -88,8 +88,8 @@ module.exports = function() {
 | 
			
		||||
      return this.deleteAllObservers();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.setParent = function(_at_parent) {
 | 
			
		||||
      this.parent = _at_parent;
 | 
			
		||||
    Operation.prototype.setParent = function(parent1) {
 | 
			
		||||
      this.parent = parent1;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.getParent = function() {
 | 
			
		||||
@ -112,26 +112,26 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.cloneUid = function() {
 | 
			
		||||
      var n, uid, v, _ref;
 | 
			
		||||
      var n, ref, uid, v;
 | 
			
		||||
      uid = {};
 | 
			
		||||
      _ref = this.getUid();
 | 
			
		||||
      for (n in _ref) {
 | 
			
		||||
        v = _ref[n];
 | 
			
		||||
      ref = this.getUid();
 | 
			
		||||
      for (n in ref) {
 | 
			
		||||
        v = ref[n];
 | 
			
		||||
        uid[n] = v;
 | 
			
		||||
      }
 | 
			
		||||
      return uid;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.execute = function() {
 | 
			
		||||
      var l, _i, _len;
 | 
			
		||||
      var j, l, len;
 | 
			
		||||
      this.is_executed = true;
 | 
			
		||||
      if (this.uid == null) {
 | 
			
		||||
        this.uid = this.HB.getNextOperationIdentifier();
 | 
			
		||||
      }
 | 
			
		||||
      if (this.uid.noOperation == null) {
 | 
			
		||||
        this.HB.addOperation(this);
 | 
			
		||||
        for (_i = 0, _len = execution_listener.length; _i < _len; _i++) {
 | 
			
		||||
          l = execution_listener[_i];
 | 
			
		||||
        for (j = 0, len = execution_listener.length; j < len; j++) {
 | 
			
		||||
          l = execution_listener[j];
 | 
			
		||||
          l(this._encode());
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
@ -168,12 +168,12 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.validateSavedOperations = function() {
 | 
			
		||||
      var name, op, op_uid, success, uninstantiated, _ref;
 | 
			
		||||
      var name, op, op_uid, ref, success, uninstantiated;
 | 
			
		||||
      uninstantiated = {};
 | 
			
		||||
      success = this;
 | 
			
		||||
      _ref = this.unchecked;
 | 
			
		||||
      for (name in _ref) {
 | 
			
		||||
        op_uid = _ref[name];
 | 
			
		||||
      ref = this.unchecked;
 | 
			
		||||
      for (name in ref) {
 | 
			
		||||
        op_uid = ref[name];
 | 
			
		||||
        op = this.HB.getOperation(op_uid);
 | 
			
		||||
        if (op) {
 | 
			
		||||
          this[name] = op;
 | 
			
		||||
@ -190,15 +190,15 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Operation.prototype.getCustomType = function() {
 | 
			
		||||
      var Type, t, _i, _len, _ref;
 | 
			
		||||
      var Type, j, len, ref, t;
 | 
			
		||||
      if (this.custom_type == null) {
 | 
			
		||||
        return this;
 | 
			
		||||
      } else {
 | 
			
		||||
        if (this.custom_type.constructor === String) {
 | 
			
		||||
          Type = this.custom_types;
 | 
			
		||||
          _ref = this.custom_type.split(".");
 | 
			
		||||
          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
            t = _ref[_i];
 | 
			
		||||
          ref = this.custom_type.split(".");
 | 
			
		||||
          for (j = 0, len = ref.length; j < len; j++) {
 | 
			
		||||
            t = ref[j];
 | 
			
		||||
            Type = Type[t];
 | 
			
		||||
          }
 | 
			
		||||
          this.custom_type = new Type();
 | 
			
		||||
@ -211,8 +211,8 @@ module.exports = function() {
 | 
			
		||||
    return Operation;
 | 
			
		||||
 | 
			
		||||
  })();
 | 
			
		||||
  ops.Delete = (function(_super) {
 | 
			
		||||
    __extends(Delete, _super);
 | 
			
		||||
  ops.Delete = (function(superClass) {
 | 
			
		||||
    extend(Delete, superClass);
 | 
			
		||||
 | 
			
		||||
    function Delete(custom_type, uid, deletes) {
 | 
			
		||||
      this.saveOperation('deletes', deletes);
 | 
			
		||||
@ -250,8 +250,8 @@ module.exports = function() {
 | 
			
		||||
    uid = o['uid'], deletes_uid = o['deletes'];
 | 
			
		||||
    return new this(null, uid, deletes_uid);
 | 
			
		||||
  };
 | 
			
		||||
  ops.Insert = (function(_super) {
 | 
			
		||||
    __extends(Insert, _super);
 | 
			
		||||
  ops.Insert = (function(superClass) {
 | 
			
		||||
    extend(Insert, superClass);
 | 
			
		||||
 | 
			
		||||
    function Insert(custom_type, content, parent, uid, prev_cl, next_cl, origin) {
 | 
			
		||||
      if (content === void 0) {
 | 
			
		||||
@ -313,7 +313,7 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Insert.prototype.applyDelete = function(o) {
 | 
			
		||||
      var callLater, garbagecollect, _ref;
 | 
			
		||||
      var callLater, garbagecollect, ref;
 | 
			
		||||
      if (this.deleted_by == null) {
 | 
			
		||||
        this.deleted_by = [];
 | 
			
		||||
      }
 | 
			
		||||
@ -332,17 +332,17 @@ module.exports = function() {
 | 
			
		||||
      if (callLater) {
 | 
			
		||||
        this.parent.callOperationSpecificDeleteEvents(this, o);
 | 
			
		||||
      }
 | 
			
		||||
      if ((_ref = this.prev_cl) != null ? _ref.isDeleted() : void 0) {
 | 
			
		||||
      if ((ref = this.prev_cl) != null ? ref.isDeleted() : void 0) {
 | 
			
		||||
        return this.prev_cl.applyDelete();
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Insert.prototype.cleanup = function() {
 | 
			
		||||
      var d, o, _i, _len, _ref;
 | 
			
		||||
      var d, j, len, o, ref;
 | 
			
		||||
      if (this.next_cl.isDeleted()) {
 | 
			
		||||
        _ref = this.deleted_by;
 | 
			
		||||
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
 | 
			
		||||
          d = _ref[_i];
 | 
			
		||||
        ref = this.deleted_by;
 | 
			
		||||
        for (j = 0, len = ref.length; j < len; j++) {
 | 
			
		||||
          d = ref[j];
 | 
			
		||||
          d.cleanup();
 | 
			
		||||
        }
 | 
			
		||||
        o = this.next_cl;
 | 
			
		||||
@ -380,14 +380,14 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Insert.prototype.execute = function() {
 | 
			
		||||
      var distance_to_origin, i, o, _base;
 | 
			
		||||
      var base, distance_to_origin, i, o;
 | 
			
		||||
      if (!this.validateSavedOperations()) {
 | 
			
		||||
        return false;
 | 
			
		||||
      } else {
 | 
			
		||||
        if (this.content instanceof ops.Operation) {
 | 
			
		||||
          this.content.insert_parent = this;
 | 
			
		||||
          if ((_base = this.content).referenced_by == null) {
 | 
			
		||||
            _base.referenced_by = 0;
 | 
			
		||||
          if ((base = this.content).referenced_by == null) {
 | 
			
		||||
            base.referenced_by = 0;
 | 
			
		||||
          }
 | 
			
		||||
          this.content.referenced_by++;
 | 
			
		||||
        }
 | 
			
		||||
@ -461,19 +461,19 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Insert.prototype._encode = function(json) {
 | 
			
		||||
      var _ref;
 | 
			
		||||
      var ref;
 | 
			
		||||
      if (json == null) {
 | 
			
		||||
        json = {};
 | 
			
		||||
      }
 | 
			
		||||
      json.prev = this.prev_cl.getUid();
 | 
			
		||||
      json.next = this.next_cl.getUid();
 | 
			
		||||
      json.parent = this.parent.getUid();
 | 
			
		||||
      if (this.origin.type === "Delimiter") {
 | 
			
		||||
        json.origin = "Delimiter";
 | 
			
		||||
      } else if (this.origin !== this.prev_cl) {
 | 
			
		||||
        json.origin = this.origin.getUid();
 | 
			
		||||
      }
 | 
			
		||||
      if (((_ref = this.content) != null ? _ref.getUid : void 0) != null) {
 | 
			
		||||
      json.parent = this.parent.getUid();
 | 
			
		||||
      if (((ref = this.content) != null ? ref.getUid : void 0) != null) {
 | 
			
		||||
        json['content'] = this.content.getUid();
 | 
			
		||||
      } else {
 | 
			
		||||
        json['content'] = JSON.stringify(this.content);
 | 
			
		||||
@ -492,8 +492,8 @@ module.exports = function() {
 | 
			
		||||
    }
 | 
			
		||||
    return new this(null, content, parent, uid, prev, next, origin);
 | 
			
		||||
  };
 | 
			
		||||
  ops.Delimiter = (function(_super) {
 | 
			
		||||
    __extends(Delimiter, _super);
 | 
			
		||||
  ops.Delimiter = (function(superClass) {
 | 
			
		||||
    extend(Delimiter, superClass);
 | 
			
		||||
 | 
			
		||||
    function Delimiter(prev_cl, next_cl, origin) {
 | 
			
		||||
      this.saveOperation('prev_cl', prev_cl);
 | 
			
		||||
@ -522,10 +522,10 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Delimiter.prototype.execute = function() {
 | 
			
		||||
      var _ref, _ref1;
 | 
			
		||||
      if (((_ref = this.unchecked) != null ? _ref['next_cl'] : void 0) != null) {
 | 
			
		||||
      var ref, ref1;
 | 
			
		||||
      if (((ref = this.unchecked) != null ? ref['next_cl'] : void 0) != null) {
 | 
			
		||||
        return Delimiter.__super__.execute.apply(this, arguments);
 | 
			
		||||
      } else if ((_ref1 = this.unchecked) != null ? _ref1['prev_cl'] : void 0) {
 | 
			
		||||
      } else if ((ref1 = this.unchecked) != null ? ref1['prev_cl'] : void 0) {
 | 
			
		||||
        if (this.validateSavedOperations()) {
 | 
			
		||||
          if (this.prev_cl.next_cl != null) {
 | 
			
		||||
            throw new Error("Probably duplicated operations");
 | 
			
		||||
@ -545,12 +545,12 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Delimiter.prototype._encode = function() {
 | 
			
		||||
      var _ref, _ref1;
 | 
			
		||||
      var ref, ref1;
 | 
			
		||||
      return {
 | 
			
		||||
        'type': this.type,
 | 
			
		||||
        'uid': this.getUid(),
 | 
			
		||||
        'prev': (_ref = this.prev_cl) != null ? _ref.getUid() : void 0,
 | 
			
		||||
        'next': (_ref1 = this.next_cl) != null ? _ref1.getUid() : void 0
 | 
			
		||||
        'prev': (ref = this.prev_cl) != null ? ref.getUid() : void 0,
 | 
			
		||||
        'next': (ref1 = this.next_cl) != null ? ref1.getUid() : void 0
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
var basic_ops_uninitialized,
 | 
			
		||||
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
 | 
			
		||||
  __hasProp = {}.hasOwnProperty;
 | 
			
		||||
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
 | 
			
		||||
  hasProp = {}.hasOwnProperty;
 | 
			
		||||
 | 
			
		||||
basic_ops_uninitialized = require("./Basic");
 | 
			
		||||
 | 
			
		||||
@ -8,8 +8,8 @@ module.exports = function() {
 | 
			
		||||
  var basic_ops, ops;
 | 
			
		||||
  basic_ops = basic_ops_uninitialized();
 | 
			
		||||
  ops = basic_ops.operations;
 | 
			
		||||
  ops.MapManager = (function(_super) {
 | 
			
		||||
    __extends(MapManager, _super);
 | 
			
		||||
  ops.MapManager = (function(superClass) {
 | 
			
		||||
    extend(MapManager, superClass);
 | 
			
		||||
 | 
			
		||||
    function MapManager(custom_type, uid) {
 | 
			
		||||
      this._map = {};
 | 
			
		||||
@ -19,10 +19,10 @@ module.exports = function() {
 | 
			
		||||
    MapManager.prototype.type = "MapManager";
 | 
			
		||||
 | 
			
		||||
    MapManager.prototype.applyDelete = function() {
 | 
			
		||||
      var name, p, _ref;
 | 
			
		||||
      _ref = this._map;
 | 
			
		||||
      for (name in _ref) {
 | 
			
		||||
        p = _ref[name];
 | 
			
		||||
      var name, p, ref;
 | 
			
		||||
      ref = this._map;
 | 
			
		||||
      for (name in ref) {
 | 
			
		||||
        p = ref[name];
 | 
			
		||||
        p.applyDelete();
 | 
			
		||||
      }
 | 
			
		||||
      return MapManager.__super__.applyDelete.call(this);
 | 
			
		||||
@ -33,17 +33,17 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    MapManager.prototype.map = function(f) {
 | 
			
		||||
      var n, v, _ref;
 | 
			
		||||
      _ref = this._map;
 | 
			
		||||
      for (n in _ref) {
 | 
			
		||||
        v = _ref[n];
 | 
			
		||||
      var n, ref, v;
 | 
			
		||||
      ref = this._map;
 | 
			
		||||
      for (n in ref) {
 | 
			
		||||
        v = ref[n];
 | 
			
		||||
        f(n, v);
 | 
			
		||||
      }
 | 
			
		||||
      return void 0;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    MapManager.prototype.val = function(name, content) {
 | 
			
		||||
      var o, prop, rep, res, result, _ref;
 | 
			
		||||
      var o, prop, ref, rep, res, result;
 | 
			
		||||
      if (arguments.length > 1) {
 | 
			
		||||
        if ((content != null) && (content._getModel != null)) {
 | 
			
		||||
          rep = content._getModel(this.custom_types, this.operations);
 | 
			
		||||
@ -66,9 +66,9 @@ module.exports = function() {
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        result = {};
 | 
			
		||||
        _ref = this._map;
 | 
			
		||||
        for (name in _ref) {
 | 
			
		||||
          o = _ref[name];
 | 
			
		||||
        ref = this._map;
 | 
			
		||||
        for (name in ref) {
 | 
			
		||||
          o = ref[name];
 | 
			
		||||
          if (!o.isContentDeleted()) {
 | 
			
		||||
            result[name] = o.val();
 | 
			
		||||
          }
 | 
			
		||||
@ -78,9 +78,9 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    MapManager.prototype["delete"] = function(name) {
 | 
			
		||||
      var _ref;
 | 
			
		||||
      if ((_ref = this._map[name]) != null) {
 | 
			
		||||
        _ref.deleteContent();
 | 
			
		||||
      var ref;
 | 
			
		||||
      if ((ref = this._map[name]) != null) {
 | 
			
		||||
        ref.deleteContent();
 | 
			
		||||
      }
 | 
			
		||||
      return this;
 | 
			
		||||
    };
 | 
			
		||||
@ -113,8 +113,8 @@ module.exports = function() {
 | 
			
		||||
    uid = json['uid'], custom_type = json['custom_type'];
 | 
			
		||||
    return new this(custom_type, uid);
 | 
			
		||||
  };
 | 
			
		||||
  ops.ListManager = (function(_super) {
 | 
			
		||||
    __extends(ListManager, _super);
 | 
			
		||||
  ops.ListManager = (function(superClass) {
 | 
			
		||||
    extend(ListManager, superClass);
 | 
			
		||||
 | 
			
		||||
    function ListManager(custom_type, uid) {
 | 
			
		||||
      this.beginning = new ops.Delimiter(void 0, void 0);
 | 
			
		||||
@ -142,25 +142,25 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    ListManager.prototype.toJson = function(transform_to_value) {
 | 
			
		||||
      var i, o, val, _i, _len, _results;
 | 
			
		||||
      var i, j, len, o, results, val;
 | 
			
		||||
      if (transform_to_value == null) {
 | 
			
		||||
        transform_to_value = false;
 | 
			
		||||
      }
 | 
			
		||||
      val = this.val();
 | 
			
		||||
      _results = [];
 | 
			
		||||
      for (o = _i = 0, _len = val.length; _i < _len; o = ++_i) {
 | 
			
		||||
      results = [];
 | 
			
		||||
      for (o = j = 0, len = val.length; j < len; o = ++j) {
 | 
			
		||||
        i = val[o];
 | 
			
		||||
        if (o instanceof ops.Object) {
 | 
			
		||||
          _results.push(o.toJson(transform_to_value));
 | 
			
		||||
          results.push(o.toJson(transform_to_value));
 | 
			
		||||
        } else if (o instanceof ops.ListManager) {
 | 
			
		||||
          _results.push(o.toJson(transform_to_value));
 | 
			
		||||
          results.push(o.toJson(transform_to_value));
 | 
			
		||||
        } else if (transform_to_value && o instanceof ops.Operation) {
 | 
			
		||||
          _results.push(o.val());
 | 
			
		||||
          results.push(o.val());
 | 
			
		||||
        } else {
 | 
			
		||||
          _results.push(o);
 | 
			
		||||
          results.push(o);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return _results;
 | 
			
		||||
      return results;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    ListManager.prototype.execute = function() {
 | 
			
		||||
@ -274,7 +274,7 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    ListManager.prototype.insertAfter = function(left, contents) {
 | 
			
		||||
      var c, right, tmp, _i, _len;
 | 
			
		||||
      var c, j, len, right, tmp;
 | 
			
		||||
      right = left.next_cl;
 | 
			
		||||
      while (right.isDeleted()) {
 | 
			
		||||
        right = right.next_cl;
 | 
			
		||||
@ -283,8 +283,8 @@ module.exports = function() {
 | 
			
		||||
      if (contents instanceof ops.Operation) {
 | 
			
		||||
        (new ops.Insert(null, content, void 0, void 0, left, right)).execute();
 | 
			
		||||
      } else {
 | 
			
		||||
        for (_i = 0, _len = contents.length; _i < _len; _i++) {
 | 
			
		||||
          c = contents[_i];
 | 
			
		||||
        for (j = 0, len = contents.length; j < len; j++) {
 | 
			
		||||
          c = contents[j];
 | 
			
		||||
          if ((c != null) && (c._name != null) && (c._getModel != null)) {
 | 
			
		||||
            c = c._getModel(this.custom_types, this.operations);
 | 
			
		||||
          }
 | 
			
		||||
@ -302,13 +302,13 @@ module.exports = function() {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    ListManager.prototype["delete"] = function(position, length) {
 | 
			
		||||
      var d, delete_ops, i, o, _i;
 | 
			
		||||
      var d, delete_ops, i, j, o, ref;
 | 
			
		||||
      if (length == null) {
 | 
			
		||||
        length = 1;
 | 
			
		||||
      }
 | 
			
		||||
      o = this.getOperationByPosition(position + 1);
 | 
			
		||||
      delete_ops = [];
 | 
			
		||||
      for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {
 | 
			
		||||
      for (i = j = 0, ref = length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
 | 
			
		||||
        if (o instanceof ops.Delimiter) {
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
@ -363,27 +363,36 @@ module.exports = function() {
 | 
			
		||||
    uid = json['uid'], custom_type = json['custom_type'];
 | 
			
		||||
    return new this(custom_type, uid);
 | 
			
		||||
  };
 | 
			
		||||
  ops.Composition = (function(_super) {
 | 
			
		||||
    __extends(Composition, _super);
 | 
			
		||||
  ops.Composition = (function(superClass) {
 | 
			
		||||
    extend(Composition, superClass);
 | 
			
		||||
 | 
			
		||||
    function Composition(custom_type, _at_composition_value, uid, composition_ref) {
 | 
			
		||||
      this.composition_value = _at_composition_value;
 | 
			
		||||
    function Composition(custom_type, composition_value, uid, tmp_composition_ref) {
 | 
			
		||||
      Composition.__super__.constructor.call(this, custom_type, uid);
 | 
			
		||||
      if (composition_ref) {
 | 
			
		||||
        this.saveOperation('composition_ref', composition_ref);
 | 
			
		||||
      if (tmp_composition_ref != null) {
 | 
			
		||||
        this.tmp_composition_ref = tmp_composition_ref;
 | 
			
		||||
      } else {
 | 
			
		||||
        this.composition_ref = this.beginning;
 | 
			
		||||
        this.composition_ref = this.end.prev_cl;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Composition.prototype.type = "Composition";
 | 
			
		||||
 | 
			
		||||
    Composition.prototype.val = function() {
 | 
			
		||||
      return this.composition_value;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Composition.prototype.callOperationSpecificInsertEvents = function(op) {
 | 
			
		||||
      var o;
 | 
			
		||||
      if (this.tmp_composition_ref != null) {
 | 
			
		||||
        if (op.uid.creator === this.tmp_composition_ref.creator && op.uid.op_number === this.tmp_composition_ref.op_number) {
 | 
			
		||||
          this.composition_ref = op;
 | 
			
		||||
          delete this.tmp_composition_ref;
 | 
			
		||||
          o = op.next_cl;
 | 
			
		||||
          while (o.next_cl != null) {
 | 
			
		||||
            if (!o.isDeleted()) {
 | 
			
		||||
              this.callOperationSpecificInsertEvents(o);
 | 
			
		||||
            }
 | 
			
		||||
            o = o.next_cl;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      if (this.composition_ref.next_cl === op) {
 | 
			
		||||
        op.undo_delta = this.getCustomType()._apply(op.content);
 | 
			
		||||
      } else {
 | 
			
		||||
@ -418,8 +427,12 @@ module.exports = function() {
 | 
			
		||||
      if (json == null) {
 | 
			
		||||
        json = {};
 | 
			
		||||
      }
 | 
			
		||||
      json.composition_value = JSON.stringify(this.composition_value);
 | 
			
		||||
      json.composition_ref = this.composition_ref.getUid();
 | 
			
		||||
      json.composition_value = JSON.stringify(this.getCustomType()._getCompositionValue());
 | 
			
		||||
      if (this.composition_ref != null) {
 | 
			
		||||
        json.composition_ref = this.composition_ref.getUid();
 | 
			
		||||
      } else {
 | 
			
		||||
        json.composition_ref = this.tmp_composition_ref;
 | 
			
		||||
      }
 | 
			
		||||
      return Composition.__super__._encode.call(this, json);
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -431,12 +444,12 @@ module.exports = function() {
 | 
			
		||||
    uid = json['uid'], custom_type = json['custom_type'], composition_value = json['composition_value'], composition_ref = json['composition_ref'];
 | 
			
		||||
    return new this(custom_type, JSON.parse(composition_value), uid, composition_ref);
 | 
			
		||||
  };
 | 
			
		||||
  ops.ReplaceManager = (function(_super) {
 | 
			
		||||
    __extends(ReplaceManager, _super);
 | 
			
		||||
  ops.ReplaceManager = (function(superClass) {
 | 
			
		||||
    extend(ReplaceManager, superClass);
 | 
			
		||||
 | 
			
		||||
    function ReplaceManager(custom_type, _at_event_properties, _at_event_this, uid) {
 | 
			
		||||
      this.event_properties = _at_event_properties;
 | 
			
		||||
      this.event_this = _at_event_this;
 | 
			
		||||
    function ReplaceManager(custom_type, event_properties1, event_this1, uid) {
 | 
			
		||||
      this.event_properties = event_properties1;
 | 
			
		||||
      this.event_this = event_this1;
 | 
			
		||||
      if (this.event_properties['object'] == null) {
 | 
			
		||||
        this.event_properties['object'] = this.event_this.getCustomType();
 | 
			
		||||
      }
 | 
			
		||||
@ -446,13 +459,13 @@ module.exports = function() {
 | 
			
		||||
    ReplaceManager.prototype.type = "ReplaceManager";
 | 
			
		||||
 | 
			
		||||
    ReplaceManager.prototype.callEventDecorator = function(events) {
 | 
			
		||||
      var event, name, prop, _i, _len, _ref;
 | 
			
		||||
      var event, j, len, name, prop, ref;
 | 
			
		||||
      if (!this.isDeleted()) {
 | 
			
		||||
        for (_i = 0, _len = events.length; _i < _len; _i++) {
 | 
			
		||||
          event = events[_i];
 | 
			
		||||
          _ref = this.event_properties;
 | 
			
		||||
          for (name in _ref) {
 | 
			
		||||
            prop = _ref[name];
 | 
			
		||||
        for (j = 0, len = events.length; j < len; j++) {
 | 
			
		||||
          event = events[j];
 | 
			
		||||
          ref = this.event_properties;
 | 
			
		||||
          for (name in ref) {
 | 
			
		||||
            prop = ref[name];
 | 
			
		||||
            event[name] = prop;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -3,42 +3,42 @@ var Y, bindToChildren;
 | 
			
		||||
Y = require('./y');
 | 
			
		||||
 | 
			
		||||
bindToChildren = function(that) {
 | 
			
		||||
  var attr, i, _i, _ref;
 | 
			
		||||
  for (i = _i = 0, _ref = that.children.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
 | 
			
		||||
  var attr, i, j, ref;
 | 
			
		||||
  for (i = j = 0, ref = that.children.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
 | 
			
		||||
    attr = that.children.item(i);
 | 
			
		||||
    if (attr.name != null) {
 | 
			
		||||
      attr.val = that.val.val(attr.name);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return that.val.observe(function(events) {
 | 
			
		||||
    var event, newVal, _j, _len, _results;
 | 
			
		||||
    _results = [];
 | 
			
		||||
    for (_j = 0, _len = events.length; _j < _len; _j++) {
 | 
			
		||||
      event = events[_j];
 | 
			
		||||
    var event, k, len, newVal, results;
 | 
			
		||||
    results = [];
 | 
			
		||||
    for (k = 0, len = events.length; k < len; k++) {
 | 
			
		||||
      event = events[k];
 | 
			
		||||
      if (event.name != null) {
 | 
			
		||||
        _results.push((function() {
 | 
			
		||||
          var _k, _ref1, _results1;
 | 
			
		||||
          _results1 = [];
 | 
			
		||||
          for (i = _k = 0, _ref1 = that.children.length; 0 <= _ref1 ? _k < _ref1 : _k > _ref1; i = 0 <= _ref1 ? ++_k : --_k) {
 | 
			
		||||
        results.push((function() {
 | 
			
		||||
          var l, ref1, results1;
 | 
			
		||||
          results1 = [];
 | 
			
		||||
          for (i = l = 0, ref1 = that.children.length; 0 <= ref1 ? l < ref1 : l > ref1; i = 0 <= ref1 ? ++l : --l) {
 | 
			
		||||
            attr = that.children.item(i);
 | 
			
		||||
            if ((attr.name != null) && attr.name === event.name) {
 | 
			
		||||
              newVal = that.val.val(attr.name);
 | 
			
		||||
              if (attr.val !== newVal) {
 | 
			
		||||
                _results1.push(attr.val = newVal);
 | 
			
		||||
                results1.push(attr.val = newVal);
 | 
			
		||||
              } else {
 | 
			
		||||
                _results1.push(void 0);
 | 
			
		||||
                results1.push(void 0);
 | 
			
		||||
              }
 | 
			
		||||
            } else {
 | 
			
		||||
              _results1.push(void 0);
 | 
			
		||||
              results1.push(void 0);
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          return _results1;
 | 
			
		||||
          return results1;
 | 
			
		||||
        })());
 | 
			
		||||
      } else {
 | 
			
		||||
        _results.push(void 0);
 | 
			
		||||
        results.push(void 0);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return _results;
 | 
			
		||||
    return results;
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -78,13 +78,13 @@ Polymer("y-property", {
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  valChanged: function() {
 | 
			
		||||
    var _ref;
 | 
			
		||||
    var ref;
 | 
			
		||||
    if ((this.val != null) && (this.name != null)) {
 | 
			
		||||
      if (this.val.constructor === Object) {
 | 
			
		||||
        return this.val = this.parentElement.val.val(this.name, this.val).val(this.name);
 | 
			
		||||
      } else if (this.val.type === "Object") {
 | 
			
		||||
        return bindToChildren(this);
 | 
			
		||||
      } else if ((((_ref = this.parentElement.val) != null ? _ref.val : void 0) != null) && this.val !== this.parentElement.val.val(this.name)) {
 | 
			
		||||
      } else if ((((ref = this.parentElement.val) != null ? ref.val : void 0) != null) && this.val !== this.parentElement.val.val(this.name)) {
 | 
			
		||||
        return this.parentElement.val.val(this.name, this.val);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user