mirror of
https://github.com/yjs/yjs.git
synced 2025-12-16 19:57:45 +01:00
2 lines
32 KiB
JavaScript
2 lines
32 KiB
JavaScript
|
|
!function e(t,n,r){function i(s,p){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!p&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var a=n[s]={exports:{}};t[s][0].call(a.exports,function(e){var n=t[s][1][e];return i(n?n:e)},a,a.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t){var n;n=function(){function e(e,t){this.HB=e,this.parser=t,this.unprocessed_ops=[]}return e.prototype.parseOperation=function(e){var t;if(t=this.parser[e.type],null!=t)return t(e);throw new Error("You forgot to specify a parser for type "+e.type+". The message is "+JSON.stringify(e)+".")},e.prototype.applyOpsBundle=function(e){var t,n,r,i,o,s,p,l;for(n=[],r=0,s=e.length;s>r;r++)t=e[r],n.push(this.parseOperation(t));for(i=0,p=n.length;p>i;i++)t=n[i],this.HB.addOperation(t);for(o=0,l=n.length;l>o;o++)t=n[o],t.execute()||this.unprocessed_ops.push(t);return this.tryUnprocessed()},e.prototype.applyOpsCheckDouble=function(e){var t,n,r,i;for(i=[],n=0,r=e.length;r>n;n++)t=e[n],null==this.HB.getOperation(t.uid)?i.push(this.applyOp(t)):i.push(void 0);return i},e.prototype.applyOps=function(e){var t,n,r,i;for(i=[],n=0,r=e.length;r>n;n++)t=e[n],i.push(this.applyOp(t));return i},e.prototype.applyOp=function(e){var t;return t=this.parseOperation(e),this.HB.addToCounter(t),t.execute()?this.HB.addOperation(t):this.unprocessed_ops.push(t),this.tryUnprocessed()},e.prototype.tryUnprocessed=function(){var e,t,n,r,i,o,s;for(s=[];;){for(e=this.unprocessed_ops.length,n=[],o=this.unprocessed_ops,r=0,i=o.length;i>r;r++)t=o[r],t.execute()?this.HB.addOperation(t):n.push(t);if(this.unprocessed_ops=n,this.unprocessed_ops.length===e)break;s.push(void 0)}return s},e}(),t.exports=n},{}],2:[function(e,t){var n,r,i,o;o=e("../Types/XmlTypes"),r=e("../HistoryBuffer"),n=e("../Engine"),i=function(){function e(e,t){var i,s,p,l,a;this.HB=new r(e),p=o(this.HB),this.types=p.types,this.engine=new n(this.HB,p.parser),this.HB.engine=this.engine,this.connector=new t(this.engine,this.HB,p.execution_listener,this),l=this.HB.getReservedUniqueIdentifier(),a=this.HB.getReservedUniqueIdentifier(),i=this.HB.addOperation(new this.types.Delimiter(l,void 0,a)).execute(),s=this.HB.addOperation(new this.types.Delimiter(a,i,void 0)).execute(),this.root_element=new this.types.ReplaceManager(void 0,this.HB.getReservedUniqueIdentifier(),i,s),this.HB.addOperation(this.root_element).execute()}return e.prototype.getSharedObject=function(){return this.root_element.val()},e.prototype.getConnector=function(){return this.connector},e.prototype.getHistoryBuffer=function(){return this.HB},e.prototype.setMutableDefault=function(e){return this.getSharedObject().setMutableDefault(e)},e.prototype.getUserId=function(){return this.HB.getUserId()},e.prototype.toJson=function(){return this.getSharedObject().toJson()},e.prototype.val=function(){var e;if(0===arguments.length||"boolean"==typeof arguments[0])return this.getSharedObject().val(arguments[0]);if(1===arguments.length)return e=new this.types.XmlType(void 0,void 0,void 0,void 0,arguments[0]),this.HB.addOperation(e).execute(),this.root_element.replace(e),e;throw new Error("can only parse 0, or 1 parameter!")},e.prototype.on=function(){var e;return(e=this.getSharedObject()).on.apply(e,arguments)},e}(),t.exports=i,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.XmlFramework=i)},{"../Engine":1,"../HistoryBuffer":3,"../Types/XmlTypes":8}],3:[function(e,t){var n,r=function(e,t){return function(){return e.apply(t,arguments)}};n=function(){function e(e){this.user_id=e,this.emptyGarbage=r(this.emptyGarbage,this),this.operation_counter={},this.buffer={},this.change_listeners=[],this.garbage=[],this.trash=[],this.performGarbageCollection=!0,this.garbageCollectTimeout=1e3,this.reserved_identifier_counter=0,setTimeout(this.emptyGarbage,this.garbageCollectTimeout)}return e.prototype.emptyGarbage=function(){var e,t,n,r;for(r=this.garbage,t=0,n=r.length;n>t;t++)e=r[t],"function"==typeof e.cleanup&&e.cleanup()
|
||
|
|
s=document.createTextNode(o.val()),this.xml.appendChild(s)}i=i.next_cl}}return this.setXmlProxy(),this.xml}},n.prototype.execute=function(){return n.__super__.execute.apply(this,arguments)},n.prototype.getParent=function(){return this.parent},n.prototype._encode=function(){var e,t,n,r;return e={type:this.type,attributes:this.attributes.getUid(),elements:this.elements.getUid(),tagname:this.tagname,uid:this.getUid(),prev:null!=(t=this.prev_cl)?t.getUid():void 0,next:null!=(n=this.next_cl)?n.getUid():void 0},this.origin!==this.prev_cl&&(e.origin=null!=(r=this.origin)?r.getUid():void 0),e},n}(s.Insert),o.XmlType=function(e){var n,r,i,o,s,p,l;return l=e.uid,n=e.attributes,r=e.elements,p=e.tagname,s=e.prev,i=e.next,o=e.origin,new t(l,p,n,r,void 0,s,i,o)},s.XmlType=t,r}},{"./JsonTypes":5}]},{},[2]);
|