fixes issue #1 and #2

This commit is contained in:
Kevin Jahns
2014-08-21 04:19:55 +02:00
parent 465a2f18e6
commit ad5898a77a
29 changed files with 323 additions and 77 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
(function(){var t,e={}.hasOwnProperty,r=function(t,r){function o(){this.constructor=t}for(var n in r)e.call(r,n)&&(t[n]=r[n]);return o.prototype=r.prototype,t.prototype=new o,t.__super__=r.prototype,t};t=require("./TextTypes"),module.exports=function(e){var o,n,u,i,a;return i=t(e),a=i.types,u=i.parser,n=function(t){var e;return new(e=function(){function t(e){var r,u,i,l;l=e.map,i=function(r,u){return Object.defineProperty(t.prototype,r,{get:function(){var t;return t=u.val(),t instanceof o?n(t):t instanceof a.ImmutableObject?t.val():t},set:function(t){var o,n,u,i;if(u=e.val(r),t.constructor==={}.constructor&&u instanceof a.Operation){i=[];for(o in t)n=t[o],i.push(u.val(o,n,"immutable"));return i}return e.val(r,t,"immutable")},enumerable:!0,configurable:!1})};for(r in l)u=l[r],i(r,u)}return t}())(t)},o=function(t){function o(t,e,r){var n,u;if(o.__super__.constructor.call(this,t),null!=e){if("object"!=typeof e)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof e+")");for(n in e)u=e[n],this.val(n,u,r)}}return r(o,t),o.prototype.toJson=function(){var t,e,r,o;o=this.val(),t={};for(e in o)if(r=o[e],r.constructor==={}.constructor)t[e]=this.val(e).toJson();else if(r instanceof a.Operation){for(;r instanceof a.Operation;)r=r.val();t[e]=r}else t[e]=r;return t},o.prototype.mutable_default=!0,o.prototype.setMutableDefault=function(t){if(t===!0||"mutable"===t)o.prototype.mutable_default=!0;else{if(t!==!1&&"immutable"!==t)throw new Error('Set mutable either "mutable" or "immutable"!');o.prototype.mutable_default=!1}return"OK"},o.prototype.val=function(t,r,n){var u,i,l,c,s;if("object"==typeof t){for(l in t)i=t[l],this.val(l,i,r);return this}if(null!=t&&null!=r){if(n=null!=n?n===!0||"mutable"===n?!0:!1:this.mutable_default,"function"==typeof r)return this;if(n&&"number"!=typeof r||r.constructor===Object){if("string"==typeof r)return s=e.addOperation(new a.Word(void 0)).execute(),s.insertText(0,r),o.__super__.val.call(this,t,s);if(r.constructor===Object)return u=e.addOperation(new o(void 0,r,n)).execute(),o.__super__.val.call(this,t,u);throw new Error("You must not set "+typeof r+"-types in collaborative Json-objects!")}return c=e.addOperation(new a.ImmutableObject(void 0,r)).execute(),o.__super__.val.call(this,t,c)}return o.__super__.val.call(this,t,r)},Object.defineProperty(o.prototype,"value",{get:function(){return n(this)},set:function(t){var e,r,o;if(t.constructor==={}.constructor){o=[];for(e in t)r=t[e],o.push(this.val(e,r,"immutable"));return o}throw new Error("You must only set Object values!")}}),o.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},o}(a.MapManager),u.JsonType=function(t){var e;return e=t.uid,new o(e)},a.JsonType=o,i}}).call(this);
(function(){var t,e={}.hasOwnProperty,r=function(t,r){function n(){this.constructor=t}for(var o in r)e.call(r,o)&&(t[o]=r[o]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t},n=[].slice;t=require("./TextTypes"),module.exports=function(e){var o,u,a,i,c;return i=t(e),c=i.types,a=i.parser,u=function(t){var e;return new(e=function(){function t(e){var r,n,a,i;i=e.map,a=function(r,n){return Object.defineProperty(t.prototype,r,{get:function(){var t;return t=n.val(),t instanceof o?u(t):t instanceof c.ImmutableObject?t.val():t},set:function(t){var n,o,u,a;if(u=e.val(r),t.constructor==={}.constructor&&u instanceof c.Operation){a=[];for(n in t)o=t[n],a.push(u.val(n,o,"immutable"));return a}return e.val(r,t,"immutable")},enumerable:!0,configurable:!1})};for(r in i)n=i[r],a(r,n)}return t}())(t)},o=function(t){function o(t,e,r){var n,u;if(o.__super__.constructor.call(this,t),null!=e){if("object"!=typeof e)throw new Error("The initial value of JsonTypes must be of type Object! (current type: "+typeof e+")");for(n in e)u=e[n],this.val(n,u,r)}}return r(o,t),o.prototype.toJson=function(){var t,e,r,n;n=this.val(),t={};for(e in n)if(r=n[e],r.constructor==={}.constructor)t[e]=this.val(e).toJson();else if(r instanceof c.Operation){for(;r instanceof c.Operation;)r=r.val();t[e]=r}else t[e]=r;return t},o.prototype.setReplaceManager=function(t){return this.parent=t.parent,this.on(["change","addProperty"],function(){var e;return(e=t.parent).forwardEvent.apply(e,[this].concat(n.call(arguments)))})},o.prototype.getParent=function(){return this.parent},o.prototype.mutable_default=!0,o.prototype.setMutableDefault=function(t){if(t===!0||"mutable"===t)o.prototype.mutable_default=!0;else{if(t!==!1&&"immutable"!==t)throw new Error('Set mutable either "mutable" or "immutable"!');o.prototype.mutable_default=!1}return"OK"},o.prototype.val=function(t,r,n){var u,a,i,l,p;if("object"==typeof t){for(i in t)a=t[i],this.val(i,a,r);return this}if(null!=t&&null!=r){if(n=null!=n?n===!0||"mutable"===n?!0:!1:this.mutable_default,"function"==typeof r)return this;if(n&&"number"!=typeof r||r.constructor===Object){if("string"==typeof r)return p=e.addOperation(new c.Word(void 0)).execute(),p.insertText(0,r),o.__super__.val.call(this,t,p);if(r.constructor===Object)return u=e.addOperation(new o(void 0,r,n)).execute(),o.__super__.val.call(this,t,u);throw new Error("You must not set "+typeof r+"-types in collaborative Json-objects!")}return l=e.addOperation(new c.ImmutableObject(void 0,r)).execute(),o.__super__.val.call(this,t,l)}return o.__super__.val.call(this,t,r)},Object.defineProperty(o.prototype,"value",{get:function(){return u(this)},set:function(t){var e,r,n;if(t.constructor==={}.constructor){n=[];for(e in t)r=t[e],n.push(this.val(e,r,"immutable"));return n}throw new Error("You must only set Object values!")}}),o.prototype._encode=function(){return{type:"JsonType",uid:this.getUid()}},o}(c.MapManager),a.JsonType=function(t){var e;return e=t.uid,new o(e)},c.JsonType=o,i}}).call(this);
//# sourceMappingURL=../Types/JsonTypes.js.map

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