mirror of
https://github.com/yjs/yjs.git
synced 2025-12-16 19:57:45 +01:00
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
|
!function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var p="function"==typeof require&&require;if(!u&&p)return p(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.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,u,p;for(n=[],r=0,s=e.length;s>r;r++)t=e[r],n.push(this.parseOperation(t));for(i=0,u=n.length;u>i;i++)t=n[i],this.HB.addOperation(t);for(o=0,p=n.length;p>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],i.push(null!=this.HB.getOperation(t.uid)?this.applyOp(t):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/TextTypes"),r=e("../HistoryBuffer"),n=e("../Engine"),i=function(){function e(e,t){var i,s;this.HB=new r(e),s=o(this.HB),this.engine=new n(this.HB,s.parser),this.connector=new t(this.engine,this.HB,s.execution_listener),i=new s.types.Word(void 0),this.HB.addOperation(i).execute(),this.root_element=i}return e.prototype.getRootElement=function(){return this.root_element},e.prototype.getEngine=function(){return this.engine},e.prototype.getConnector=function(){return this.connector},e.prototype.getHistoryBuffer=function(){return this.HB},e.prototype.getUserId=function(){return this.HB.getUserId()},e.prototype.val=function(){return this.root_element.val()},e.prototype.insertText=function(e,t){return this.root_element.insertText(e,t)},e.prototype.deleteText=function(e,t){return this.root_element.deleteText(e,t)},e.prototype.replaceText=function(e){return this.root_element.replaceText(e)},e}(),t.exports=i},{"../Engine":1,"../HistoryBuffer":3,"../Types/TextTypes":6}],3:[function(e,t){var n;n=function(){function e(e){this.user_id=e,this.operation_counter={},this.buffer={},this.change_listeners=[]}return e.prototype.getUserId=function(){return this.user_id},e.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},e.prototype.getOperationCounter=function(){var e,t,n,r;t={},r=this.operation_counter;for(n in r)e=r[n],t[n]=e;return t},e.prototype._encode=function(e){var t,n,r,i,o,s,u,p,c,a;null==e&&(e={}),t=[],p=function(t,n){if(null==t||null==n)throw new Error("dah!");return null==e[t]||e[t]<=n},a=this.buffer;for(u in a){c=a[u];for(o in c)if(n=c[o],!isNaN(parseInt(o))&&p(u,o)){if(r=n._encode(),null!=n.next_cl){for(i=n.next_cl;null!=i.next_cl&&p(i.creator,i.op_number);)i=i.next_cl;r.next=i.getUid()}else if(null!=n.prev_cl){for(s=n.prev_cl;null!=s.prev_cl&&p(i.creator,i.op_number);)s=s.prev_cl;r.prev=s.getUid()}t.push(r)}}return t},e.prototype.getNextOperationIdentifier=function(e){var t;return null==e&&(e=this.user_id),null==this.operation_counter[e]&&(this.operation_counter[e]=0),t={creator:e,op_number:this.operation_counter[e]},this.operation_counter[e]++,t},e.prototype.getOperation=function(e){var t;if(e instanceof Object)return null!=(t=this.buffer[e.creator])?t[e.op_number]:void 0;if(null!=e)throw new
|