4 lines
79 KiB
JavaScript
4 lines
79 KiB
JavaScript
"use strict";function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Y(e){return new Promise(function(t){var r=new YConfig(e,function(){r.db.whenUserIdSet(function(){t(r)})})})}function copyObject(e){var t={};for(var r in e)t[r]=e[r];return t}function smaller(e,t){return e[0]<t[0]||e[0]===t[0]&&e[1]<t[1]}function compareIds(e,t){return null==e||null==t?null==e&&null==t?!0:!1:e[0]===t[0]&&e[1]===t[1]?!0:!1}function _flushOne(){var e=[];for(var t in globalRoom.buffers)globalRoom.buffers[t].length>0&&e.push(t);if(e.length>0){var r=getRandom(e),n=globalRoom.buffers[r].shift(),i=globalRoom.users[r];return i.receiveMessage(n[0],n[1]),!0}return!1}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();!function(e){function t(e,t,r,i){var a=Object.create((t||n).prototype);return a._invoke=c(e,r||null,new d(i||[])),a}function r(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}function n(){}function i(){}function a(){}function s(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function o(e){this.arg=e}function u(e){function t(t,r){var n=e[t](r),s=n.value;return s instanceof o?Promise.resolve(s.arg).then(i,a):Promise.resolve(s).then(function(e){return n.value=e,n})}function r(e,r){var i=n?n.then(function(){return t(e,r)}):new Promise(function(n){n(t(e,r))});return n=i["catch"](function(e){}),i}"object"==typeof process&&process.domain&&(t=process.domain.bind(t));var n,i=t.bind(e,"next"),a=t.bind(e,"throw");t.bind(e,"return");this._invoke=r}function c(e,t,n){var i=w;return function(a,s){if(i===x)throw new Error("Generator is already running");if(i===R){if("throw"===a)throw s;return f()}for(;;){var o=n.delegate;if(o){if("return"===a||"throw"===a&&o.iterator[a]===g){n.delegate=null;var u=o.iterator["return"];if(u){var c=r(u,o.iterator,s);if("throw"===c.type){a="throw",s=c.arg;continue}}if("return"===a)continue}var c=r(o.iterator[a],o.iterator,s);if("throw"===c.type){n.delegate=null,a="throw",s=c.arg;continue}a="next",s=g;var l=c.arg;if(!l.done)return i=k,l;n[o.resultName]=l.value,n.next=o.nextLoc,n.delegate=null}if("next"===a)i===k?n.sent=s:n.sent=g;else if("throw"===a){if(i===w)throw i=R,s;n.dispatchException(s)&&(a="next",s=g)}else"return"===a&&n.abrupt("return",s);i=x;var c=r(e,t,n);if("normal"===c.type){i=n.done?R:k;var l={value:c.arg,done:n.done};if(c.arg!==Y)return l;n.delegate&&"next"===a&&(s=g)}else"throw"===c.type&&(i=R,a="throw",s=c.arg)}}}function l(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function p(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function d(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(l,this),this.reset(!0)}function h(e){if(e){var t=e[m];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function i(){for(;++r<e.length;)if(y.call(e,r))return i.value=e[r],i.done=!1,i;return i.value=g,i.done=!0,i};return n.next=n}}return{next:f}}function f(){return{value:g,done:!0}}var g,y=Object.prototype.hasOwnProperty,m="function"==typeof Symbol&&Symbol.iterator||"@@iterator",v="object"==typeof module,b=e.regeneratorRuntime;if(b)return void(v&&(module.exports=b));b=e.regeneratorRuntime=v?module.exports:{},b.wrap=t;var w="suspendedStart",k="suspendedYield",x="executing",R="completed",Y={},S=a.prototype=n.prototype;i.prototype=S.constructor=a,a.constructor=i,i.displayName="GeneratorFunction",b.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return t?t===i||"GeneratorFunction"===(t.displayName||t.name):!1},b.mark=function(e){return e.__proto__=a,e.prototype=Object.create(S),e},b.awrap=function(e){return new o(e)},s(u.prototype),b.async=function(e,r,n,i){var a=new u(t(e,r,n,i));return b.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})},s(S),S[m]=function(){return this},S.toString=function(){return"[object Generator]"},b.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},b.values=h,d.prototype={constructor:d,reset:function(e){if(this.prev=0,this.next=0,this.sent=g,this.done=!1,this.delegate=null,this.tryEntries.forEach(p),!e)for(var t in this)"t"===t.charAt(0)&&y.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=g)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,n){return a.type="throw",a.arg=e,r.next=t,!!n}if(this.done)throw e;for(var r=this,n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=this.prev){var s=y.call(i,"catchLoc"),o=y.call(i,"finallyLoc");if(s&&o){if(this.prev<i.catchLoc)return t(i.catchLoc,!0);if(this.prev<i.finallyLoc)return t(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return t(i.catchLoc,!0)}else{if(!o)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return t(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&y.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?this.next=i.finallyLoc:this.complete(a),Y},complete:function(e,t){if("throw"===e.type)throw e.arg;"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=e.arg,this.next="end"):"normal"===e.type&&t&&(this.next=t)},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),p(r),Y}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;p(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:h(e),resultName:t,nextLoc:r},Y}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:void 0);var YConfig=function(){function e(t,r){_classCallCheck(this,e),this.db=new Y[t.db.name](this,t.db),this.connector=new Y[t.connector.name](this,t.connector),this.db.requestTransaction(regeneratorRuntime.mark(function n(){var e,t;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return e={id:["_",0],struct:"Map",type:"Map",map:{}},n.delegateYield(this.store.tryExecute.call(this,e),"t0",2);case 2:return n.delegateYield(this.getType(e.id),"t1",3);case 3:t=n.t1,this.store.y.root=t,r();case 6:case"end":return n.stop()}},n,this)}))}return e.prototype.isConnected=function(){return this.connector.isSynced},e.prototype.disconnect=function(){return this.connector.disconnect()},e.prototype.reconnect=function(){return this.connector.reconnect()},e.prototype.destroy=function(){this.disconnect(),this.db.destroy(),this.connector=null,this.db=null},e}();"undefined"!=typeof YConcurrency_TestingMode&&(g.Y=Y),Y.utils={};var AbstractConnector=function(){function e(t,r){if(_classCallCheck(this,e),this.y=t,null==r&&(r={}),null==r.role||"master"===r.role)this.role="master";else{if("slave"!==r.role)throw new Error("Role must be either 'master' or 'slave'!");this.role="slave"}this.role=r.role,this.connections={},this.isSynced=!1,this.userEventListeners=[],this.whenSyncedListeners=[],this.currentSyncTarget=null,this.syncingClients=[],this.forwardToSyncingClients=r.forwardToSyncingClients!==!1,this.debug=r.debug===!0,this.broadcastedHB=!1,this.syncStep2=Promise.resolve()}return e.prototype.reconnect=function(){},e.prototype.disconnect=function(){return this.connections={},this.isSynced=!1,this.currentSyncTarget=null,this.broadcastedHB=!1,this.syncingClients=[],this.whenSyncedListeners=[],this.y.db.stopGarbageCollector()},e.prototype.setUserId=function(e){return this.userId=e,this.y.db.setUserId(e)},e.prototype.onUserEvent=function(e){this.userEventListeners.push(e)},e.prototype.userLeft=function(e){delete this.connections[e],e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget()),this.syncingClients=this.syncingClients.filter(function(t){return t!==e});for(var t=this.userEventListeners,r=Array.isArray(t),n=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(n>=t.length)break;i=t[n++]}else{if(n=t.next(),n.done)break;i=n.value}var a=i;a({action:"userLeft",user:e})}},e.prototype.userJoined=function(e,t){if(null==t)throw new Error("You must specify the role of the joined user!");if(null!=this.connections[e])throw new Error("This user already joined!");this.connections[e]={isSynced:!1,role:t};for(var r=this.userEventListeners,n=Array.isArray(r),i=0,r=n?r:r[Symbol.iterator]();;){var a;if(n){if(i>=r.length)break;a=r[i++]}else{if(i=r.next(),i.done)break;a=i.value}var s=a;s({action:"userJoined",user:e,role:t})}null==this.currentSyncTarget&&this.findNextSyncTarget()},e.prototype.whenSynced=function(e){this.isSynced?e():this.whenSyncedListeners.push(e)},e.prototype.findNextSyncTarget=function(){if(null==this.currentSyncTarget&&!this.isSynced){var e=null;for(var t in this.connections)if(!this.connections[t].isSynced){e=t;break}if(null!=e){var r=this;this.currentSyncTarget=e,this.y.db.requestTransaction(regeneratorRuntime.mark(function u(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=r,t.t1=e,t.delegateYield(this.getStateSet(),"t2",3);case 3:return t.t3=t.t2,t.delegateYield(this.getDeleteSet(),"t4",5);case 5:t.t5=t.t4,t.t6={type:"sync step 1",stateSet:t.t3,deleteSet:t.t5},t.t0.send.call(t.t0,t.t1,t.t6);case 8:case"end":return t.stop()}},u,this)}))}else{this.isSynced=!0;for(var n=this.whenSyncedListeners,i=Array.isArray(n),a=0,n=i?n:n[Symbol.iterator]();;){var s;if(i){if(a>=n.length)break;s=n[a++]}else{if(a=n.next(),a.done)break;s=a.value}var o=s;o()}this.whenSyncedListeners=[],this.y.db.requestTransaction(regeneratorRuntime.mark(function c(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.garbageCollectAfterSync(),"t0",1);case 1:case"end":return e.stop()}},c,this)}))}}},e.prototype.send=function(e,t){this.debug&&console.log("send "+this.userId+" -> "+e+": "+t.type,m)},e.prototype.receiveMessage=function(e,t){var r=this;if(e!==this.userId)if(this.debug&&console.log("receive "+e+" -> "+this.userId+": "+t.type,JSON.parse(JSON.stringify(t))),"sync step 1"===t.type)!function(){var n=r;r.y.db.requestTransaction(regeneratorRuntime.mark(function i(){var r,a,s;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(this.getStateSet(),"t0",1);case 1:return r=i.t0,i.delegateYield(this.applyDeleteSet(t.deleteSet),"t1",3);case 3:return i.delegateYield(this.getDeleteSet(),"t2",4);case 4:return a=i.t2,i.delegateYield(this.getOperations(t.stateSet),"t3",6);case 6:s=i.t3,n.send(e,{type:"sync step 2",os:s,stateSet:r,deleteSet:a}),this.forwardToSyncingClients?(n.syncingClients.push(e),setTimeout(function(){n.syncingClients=n.syncingClients.filter(function(t){return t!==e}),n.send(e,{type:"sync done"})},n.syncingClientDuration)):n.send(e,{type:"sync done"}),n._setSyncedWith(e);case 10:case"end":return i.stop()}},i,this)}))}();else if("sync step 2"===t.type){var n,i;!function(){var a=r;n=!r.broadcastedHB,r.broadcastedHB=!0,i=r.y.db,r.syncStep2=new Promise(function(r){i.requestTransaction(regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.delegateYield(this.applyDeleteSet(t.deleteSet),"t0",1);case 1:this.store.apply(t.os),i.requestTransaction(regeneratorRuntime.mark(function o(){var i;return regeneratorRuntime.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.delegateYield(this.getOperations(t.stateSet),"t0",1);case 1:i=s.t0,i.length>0&&(t={type:"update",ops:i},n?a.broadcast(t):a.send(e,t)),r();case 4:case"end":return s.stop()}},o,this)}));case 3:case"end":return s.stop()}},s,this)}))})}()}else if("sync done"===t.type){var a=this;this.syncStep2.then(function(){a._setSyncedWith(e)})}else if("update"===t.type){if(this.forwardToSyncingClients)for(var s=this.syncingClients,o=Array.isArray(s),u=0,s=o?s:s[Symbol.iterator]();;){var c;if(o){if(u>=s.length)break;c=s[u++]}else{if(u=s.next(),u.done)break;c=u.value}var l=c;this.send(l,t)}this.y.db.apply(t.ops)}},e.prototype._setSyncedWith=function(e){var t=this.connections[e];null!=t&&(t.isSynced=!0),e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget())},e.prototype.parseMessageFromXml=function(e){function t(e){var t=!0;e:for(;t;){var n=e;i=a=s=i=o=u=void 0,t=!1;for(var i=n.children,a=Array.isArray(i),s=0,i=a?i:i[Symbol.iterator]();;){var o;if(a){if(s>=i.length)break;o=i[s++]}else{if(s=i.next(),s.done)break;o=s.value}var u=o;if("true"===u.getAttribute("isArray")){e=u,t=!0;continue e}return r(u)}}}function r(e){var n={};for(var i in e.attrs){var a=e.attrs[i],s=parseInt(a,10);isNaN(s)||""+s!==a?n[i]=a:n[i]=s}for(var o in e.children){var u=o.name;"true"===o.getAttribute("isArray")?n[u]=t(o):n[u]=r(o)}return n}r(e)},e.prototype.encodeMessageToXml=function(e,t){function r(e,t){for(var i in t){var a=t[i];null==i||(a.constructor===Object?r(e.c(i),a):a.constructor===Array?n(e.c(i),a):e.setAttribute(i,a))}}function n(e,t){e.setAttribute("isArray","true");for(var i=t,a=Array.isArray(i),s=0,i=a?i:i[Symbol.iterator]();;){var o;if(a){if(s>=i.length)break;o=i[s++]}else{if(s=i.next(),s.done)break;o=s.value}var u=o;u.constructor===Object?r(e.c("array-element"),u):n(e.c("array-element"),u)}}if(t.constructor===Object)r(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t);else{if(t.constructor!==Array)throw new Error("I can't encode this json!");n(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t)}},e}();Y.AbstractConnector=AbstractConnector;var AbstractDatabase=function(){function e(t,r){function n(){return new Promise(function(e){i.requestTransaction(regeneratorRuntime.mark(function t(){var r,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null==i.y.connector||!i.y.connector.isSynced){t.next=10;break}t.t0=regeneratorRuntime.keys(i.gc2);case 2:if((t.t1=t.t0()).done){t.next=8;break}return r=t.t1.value,a=i.gc2[r],t.delegateYield(this.garbageCollectOperation(a),"t2",6);case 6:t.next=2;break;case 8:i.gc2=i.gc1,i.gc1=[];case 10:i.gcTimeout>0&&(i.gcInterval=setTimeout(n,i.gcTimeout)),e();case 12:case"end":return t.stop()}},t,this)}))})}_classCallCheck(this,e),this.y=t,this.listenersById={},this.listenersByIdExecuteNow=[],this.listenersByIdRequestPending=!1,this.initializedTypes={},this.whenUserIdSetListener=null,this.waitingTransactions=[],this.transactionInProgress=!1,"undefined"!=typeof YConcurrency_TestingMode&&(this.executeOrder=[]),this.gc1=[],this.gc2=[],this.gcTimeout=r.gcTimeout||5e3;var i=this;this.garbageCollect=n,this.gcTimeout>0&&n()}return e.prototype.addToDebug=function(){if("undefined"!=typeof YConcurrency_TestingMode){var e=Array.prototype.map.call(arguments,function(e){return"string"==typeof e?e:JSON.stringify(e)}).join("").replace(/"/g,"'").replace(/,/g,", ").replace(/:/g,": ");this.executeOrder.push(e)}},e.prototype.getDebugData=function(){console.log(this.executeOrder.join("\n"))},e.prototype.stopGarbageCollector=function(){var e=this;return new Promise(function(t){e.requestTransaction(regeneratorRuntime.mark(function r(){var n,i,a;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:n=e.gc1.concat(e.gc2),e.gc1=[],e.gc2=[],r.t0=regeneratorRuntime.keys(n);case 4:if((r.t1=r.t0()).done){r.next=12;break}return i=r.t1.value,r.delegateYield(this.getOperation(n[i]),"t2",7);case 7:return a=r.t2,delete a.gc,r.delegateYield(this.setOperation(a),"t3",10);case 10:r.next=4;break;case 12:t();case 13:case"end":return r.stop()}},r,this)}))})},e.prototype.addToGarbageCollector=function(e,t){return null==e.gc&&e.deleted===!0&&this.y.connector.isSynced&&null!=t&&t.deleted===!0?(e.gc=!0,this.gc1.push(e.id),!0):!1},e.prototype.removeFromGarbageCollector=function(e){function t(t){return!Y.utils.compareIds(t,e.id)}this.gc1=this.gc1.filter(t),this.gc2=this.gc2.filter(t),delete e.gc},e.prototype.destroy=function(){clearInterval(this.gcInterval),this.gcInterval=null},e.prototype.setUserId=function(e){var t=this;return new Promise(function(r){t.requestTransaction(regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return t.userId=e,n.delegateYield(this.getState(e),"t0",2);case 2:t.opClock=n.t0.clock,null!=t.whenUserIdSetListener&&(t.whenUserIdSetListener(),t.whenUserIdSetListener=null),r();case 5:case"end":return n.stop()}},n,this)}))})},e.prototype.whenUserIdSet=function(e){null!=this.userId?e():this.whenUserIdSetListener=e},e.prototype.getNextOpId=function(){if(null==this.userId)throw new Error("OperationStore not yet initialized!");return[this.userId,this.opClock++]},e.prototype.apply=function(e){for(var t in e){var r=e[t],n=Y.Struct[r.struct].requiredOps(r);this.whenOperationsExist(n,r)}},e.prototype.whenOperationsExist=function(e,t){if(e.length>0){var r={op:t,missing:e.length};for(var n in e){var i=e[n],a=JSON.stringify(i),s=this.listenersById[a];null==s&&(s=[],this.listenersById[a]=s),s.push(r)}}else this.listenersByIdExecuteNow.push({op:t});if(!this.listenersByIdRequestPending){this.listenersByIdRequestPending=!0;var o=this;this.requestTransaction(regeneratorRuntime.mark(function u(){var e,t,r,n,i,a,s,c;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:e=o.listenersByIdExecuteNow,o.listenersByIdExecuteNow=[],t=o.listenersById,o.listenersById={},o.listenersByIdRequestPending=!1,u.t0=regeneratorRuntime.keys(e);case 6:if((u.t1=u.t0()).done){u.next=12;break}return r=u.t1.value,n=e[r].op,u.delegateYield(o.tryExecute.call(this,n),"t2",10);case 10:u.next=6;break;case 12:u.t3=regeneratorRuntime.keys(t);case 13:if((u.t4=u.t3()).done){u.next=34;break}return i=u.t4.value,a=t[i],s=JSON.parse(i),u.delegateYield(this.getOperation(s),"t5",18);case 18:if(u.t6=u.t5,null!=u.t6){u.next=23;break}o.listenersById[i]=a,u.next=32;break;case 23:u.t7=regeneratorRuntime.keys(a);case 24:if((u.t8=u.t7()).done){u.next=32;break}if(r=u.t8.value,c=a[r],n=c.op,0!==--c.missing){u.next=30;break}return u.delegateYield(o.tryExecute.call(this,n),"t9",30);case 30:u.next=24;break;case 32:u.next=13;break;case 34:case"end":return u.stop()}},u,this)}))}},e.prototype.tryExecute=regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.store.addToDebug("yield* this.store.tryExecute.call(this, ",JSON.stringify(e),")"),"Delete"!==e.struct){t.next=6;break}return t.delegateYield(Y.Struct.Delete.execute.call(this,e),"t0",3);case 3:return t.delegateYield(this.store.operationAdded(this,e),"t1",4);case 4:t.next=16;break;case 6:return t.delegateYield(this.getOperation(e.id),"t3",7);case 7:if(t.t4=t.t3,t.t2=null==t.t4,!t.t2){t.next=12;break}return t.delegateYield(this.isGarbageCollected(e.id),"t5",11);case 11:t.t2=!t.t5;case 12:if(!t.t2){t.next=16;break}return t.delegateYield(Y.Struct[e.struct].execute.call(this,e),"t6",14);case 14:return t.delegateYield(this.addOperation(e),"t7",15);case 15:return t.delegateYield(this.store.operationAdded(this,e),"t8",16);case 16:case"end":return t.stop()}},t,this)}),e.prototype.operationAdded=regeneratorRuntime.mark(function r(e,t){var n,i,a,s,o,u,c,l,p,d;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("Delete"!==t.struct){r.next=9;break}return r.delegateYield(e.getOperation(t.target),"t0",2);case 2:if(n=r.t0,null==n){r.next=7;break}if(i=e.store.initializedTypes[JSON.stringify(n.parent)],null==i){r.next=7;break}return r.delegateYield(i._changed(e,{struct:"Delete",target:t.target}),"t1",7);case 7:r.next=36;break;case 9:return a=t,r.delegateYield(e.getState(t.id[0]),"t2",11);case 11:s=r.t2;case 12:if(null==a||a.id[1]!==s.clock||t.id[0]!==a.id[0]){r.next=19;break}return s.clock++,r.delegateYield(e.checkDeleteStoreForState(s),"t3",15);case 15:return r.delegateYield(e.os.findNext(a.id),"t4",16);case 16:a=r.t4,r.next=12;break;case 19:return r.delegateYield(e.setState(s),"t5",20);case 20:if(o=JSON.stringify(t.id),u=this.listenersById[o],delete this.listenersById[o],null!=u)for(c in u)l=u[c],0===--l.missing&&this.whenOperationsExist([],l.op);if(p=this.initializedTypes[JSON.stringify(t.parent)],null==p){r.next=27;break}return r.delegateYield(p._changed(e,Y.utils.copyObject(t)),"t6",27);case 27:if(r.t7=!t.deleted,!r.t7){r.next=31;break}return r.delegateYield(e.isDeleted(t.id),"t8",30);case 30:r.t7=r.t8;case 31:if(!r.t7){r.next=36;break}return d={struct:"Delete",target:t.id},r.delegateYield(Y.Struct.Delete.execute.call(e,d),"t9",34);case 34:if(null==p){r.next=36;break}return r.delegateYield(p._changed(e,d),"t10",36);case 36:case"end":return r.stop()}},r,this)}),e.prototype.getNextRequest=function(){return 0===this.waitingTransactions.length?(this.transactionInProgress=!1,null):this.waitingTransactions.shift()},e.prototype.requestTransaction=function(e,t){if(t)this.transact(e);else if(this.transactionInProgress)this.waitingTransactions.push(e);else{this.transactionInProgress=!0;var r=this;setTimeout(function(){r.transact(e)},0)}},e}();Y.AbstractDatabase=AbstractDatabase;var Transaction=function(){function e(){_classCallCheck(this,e)}return e.prototype.getType=regeneratorRuntime.mark(function t(e){var r,n,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=JSON.stringify(e),n=this.store.initializedTypes[r],null!=n){t.next=9;break}return t.delegateYield(this.getOperation(e),"t0",4);case 4:if(i=t.t0,null==i){t.next=9;break}return t.delegateYield(Y[i.type].initType.call(this,this.store,i),"t1",7);case 7:n=t.t1,this.store.initializedTypes[r]=n;case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}},t,this)}),e.prototype.applyCreatedOperations=regeneratorRuntime.mark(function r(e){var t,n,i;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:t=[],n=0;case 2:if(!(n<e.length)){r.next=9;break}return i=e[n],r.delegateYield(this.store.tryExecute.call(this,i),"t0",5);case 5:t.push(Y.Struct[i.struct].encode(i));case 6:n++,r.next=2;break;case 9:this.store.y.connector.isDisconnected()||this.store.y.connector.broadcast({type:"update",ops:t});case 10:case"end":return r.stop()}},r,this)}),e.prototype.deleteList=regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.store.y.connector.isSynced){t.next=12;break}case 1:if(null==e||!this.store.y.connector.isSynced){t.next=10;break}return t.delegateYield(this.getOperation(e),"t0",3);case 3:return e=t.t0,e.gc=!0,t.delegateYield(this.setOperation(e),"t1",6);case 6:this.store.gc1.push(e.id),e=e.right,t.next=1;break;case 10:t.next=12;break;case 12:case"end":return t.stop()}},n,this)}),e.prototype.deleteOperation=regeneratorRuntime.mark(function i(e,t){var r,n,a,s,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.getOperation(e),"t0",1);case 1:if(r=t.t0,n=!1,null!=r&&r.deleted){t.next=5;break}return t.delegateYield(this.markDeleted(e),"t1",5);case 5:if(null==r||null!=r.gc){t.next=42;break}if(r.deleted){t.next=23;break}if(n=!0,r.deleted=!0,null==r.start){t.next=12;break}return t.delegateYield(this.deleteList(r.start),"t2",11);case 11:return t.delegateYield(this.deleteList(r.id),"t3",12);case 12:if(null==r.map){t.next=20;break}t.t4=regeneratorRuntime.keys(r.map);case 14:if((t.t5=t.t4()).done){t.next=19;break}return a=t.t5.value,t.delegateYield(this.deleteList(r.map[a]),"t6",17);case 17:t.next=14;break;case 19:return t.delegateYield(this.deleteList(r.id),"t7",20);case 20:if(null==r.opContent){t.next=23;break}return t.delegateYield(this.deleteOperation(r.opContent),"t8",22);case 22:r.opContent=null;case 23:if(null==r.left){t.next=28;break}return t.delegateYield(this.getOperation(r.left),"t10",25);case 25:t.t9=t.t10,t.next=29;break;case 28:t.t9=null;case 29:return s=t.t9,this.store.addToGarbageCollector(r,s),t.delegateYield(this.setOperation(r),"t11",32);case 32:if(null==r.right){t.next=37;break}return t.delegateYield(this.getOperation(r.right),"t13",34);case 34:t.t12=t.t13,t.next=38;break;case 37:t.t12=null;case 38:if(o=t.t12,null==o||!this.store.addToGarbageCollector(o,r)){t.next=41;break}return t.delegateYield(this.setOperation(o),"t14",41);case 41:return t.abrupt("return",n);case 42:case"end":return t.stop()}},i,this)}),e.prototype.markGarbageCollected=regeneratorRuntime.mark(function a(e){var t,r,n,i;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.delegateYield(this.markDeleted(e),"t0",1);case 1:if(t=a.t0,t.gc){a.next=25;break}if(!(t.id[1]<e[1])){a.next=9;break}return r=t.len-(e[1]-t.id[1]),t.len-=r,a.delegateYield(this.ds.put(t),"t1",7);case 7:return t={id:e,len:r,gc:!1},a.delegateYield(this.ds.put(t),"t2",9);case 9:return a.delegateYield(this.ds.findPrev(e),"t3",10);case 10:return n=a.t3,a.delegateYield(this.ds.findNext(e),"t4",12);case 12:if(i=a.t4,!(e[1]<t.id[1]+t.len-1)){a.next=16;break}return a.delegateYield(this.ds.put({id:[e[0],e[1]+1],len:t.len-1,gc:!1}),"t5",15);case 15:t.len=1;case 16:if(t.gc=!0,null==n||!n.gc||!Y.utils.compareIds([n.id[0],n.id[1]+n.len],t.id)){a.next=21;break}return n.len+=t.len,a.delegateYield(this.ds["delete"](t.id),"t6",20);case 20:t=n;case 21:if(null==i||!i.gc||!Y.utils.compareIds([t.id[0],t.id[1]+t.len],i.id)){a.next=24;break}return t.len+=i.len,a.delegateYield(this.ds["delete"](i.id),"t7",24);case 24:return a.delegateYield(this.ds.put(t),"t8",25);case 25:case"end":return a.stop()}},a,this)}),e.prototype.markDeleted=regeneratorRuntime.mark(function s(e){var t,r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(this.ds.findWithUpperBound(e),"t0",1);case 1:if(t=n.t0,null==t||t.id[0]!==e[0]){n.next=15;break}if(!(t.id[1]<=e[1]&&e[1]<t.id[1]+t.len)){n.next=7;break}return n.abrupt("return",t);case 7:if(t.id[1]+t.len!==e[1]||t.gc){n.next=11;break}t.len++,n.next=13;break;case 11:return t={id:e,len:1,gc:!1},n.delegateYield(this.ds.put(t),"t1",13);case 13:n.next=17;break;case 15:return t={id:e,len:1,gc:!1},n.delegateYield(this.ds.put(t),"t2",17);case 17:return n.delegateYield(this.ds.findNext(t.id),"t3",18);case 18:if(r=n.t3,null==r||!Y.utils.compareIds([t.id[0],t.id[1]+t.len],r.id)||r.gc){n.next=22;break}return t.len=t.len+r.len,n.delegateYield(this.ds["delete"](r.id),"t4",22);case 22:return n.delegateYield(this.ds.put(t),"t5",23);case 23:return n.abrupt("return",t);case 24:case"end":return n.stop()}},s,this)}),e.prototype.garbageCollectAfterSync=regeneratorRuntime.mark(function o(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.os.iterate(this,null,null,regeneratorRuntime.mark(function t(e){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.deleted||null==e.left){t.next=4;break}return t.delegateYield(this.getOperation(e.left),"t0",2);case 2:r=t.t0,this.store.addToGarbageCollector(e,r);case 4:case"end":return t.stop()}},t,this)})),"t0",1);case 1:case"end":return e.stop()}},o,this)}),e.prototype.garbageCollectOperation=regeneratorRuntime.mark(function u(e){var t,r,n,i,a,s,o,c,l,p;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.store.addToDebug("yield* this.garbageCollectOperation(",e,")"),u.delegateYield(this.getState(e[0]),"t0",2);case 2:if(t=u.t0,t.clock!==e[1]){u.next=7;break}return t.clock++,u.delegateYield(this.checkDeleteStoreForState(t),"t1",6);case 6:return u.delegateYield(this.setState(t),"t2",7);case 7:return u.delegateYield(this.markGarbageCollected(e),"t3",8);case 8:return u.delegateYield(this.getOperation(e),"t4",9);case 9:if(r=u.t4,null==r){u.next=61;break}if(null==r.left){u.next=16;break}return u.delegateYield(this.getOperation(r.left),"t5",13);case 13:return n=u.t5,n.right=r.right,u.delegateYield(this.setOperation(n),"t6",16);case 16:if(null==r.right){u.next=53;break}return u.delegateYield(this.getOperation(r.right),"t7",18);case 18:if(i=u.t7,i.left=r.left,!Y.utils.compareIds(i.origin,r.id)){u.next=52;break}a=r.left;case 22:if(null==a){u.next=30;break}return u.delegateYield(this.getOperation(a),"t8",24);case 24:if(s=u.t8,!s.deleted){u.next=27;break}return u.abrupt("break",30);case 27:a=s.left,u.next=22;break;case 30:if(i.origin=a,null!=i.right){u.next=35;break}u.t9=null,u.next=37;break;case 35:return u.delegateYield(this.getOperation(i.right),"t10",36);case 36:u.t9=u.t10;case 37:o=u.t9,c=[r.id,r.right];case 39:if(null==o||!c.some(function(e){return Y.utils.compareIds(e,o.origin)})){u.next=52;break}if(!Y.utils.compareIds(o.origin,r.id)){u.next=43;break}return o.origin=a,u.delegateYield(this.setOperation(o),"t11",43);case 43:if(null!=o.right){u.next=47;break}u.t12=null,u.next=49;break;case 47:return u.delegateYield(this.getOperation(o.right),"t13",48);case 48:u.t12=u.t13;case 49:o=u.t12,u.next=39;break;case 52:return u.delegateYield(this.setOperation(i),"t14",53);case 53:if(null==r.parent){u.next=60;break}return u.delegateYield(this.getOperation(r.parent),"t15",55);case 55:if(l=u.t15,p=!1,null!=r.parentSub?Y.utils.compareIds(l.map[r.parentSub],r.id)&&(p=!0,l.map[r.parentSub]=r.right):(Y.utils.compareIds(l.start,r.id)&&(p=!0,l.start=r.right),Y.utils.compareIds(l.end,r.id)&&(p=!0,l.end=r.left)),!p){u.next=60;break}return u.delegateYield(this.setOperation(l),"t16",60);case 60:return u.delegateYield(this.removeOperation(r.id),"t17",61);case 61:case"end":return u.stop()}},u,this)}),e.prototype.checkDeleteStoreForState=regeneratorRuntime.mark(function c(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(this.ds.findWithUpperBound([e.user,e.clock]),"t0",1);case 1:t=r.t0,null!=t&&t.id[0]===e.user&&t.gc&&(e.clock=Math.max(e.clock,t.id[1]+t.len));case 3:case"end":return r.stop()}},c,this)}),e.prototype.applyDeleteSet=regeneratorRuntime.mark(function l(e){var t,r,n,i,a,s,o,u,c,p;return regeneratorRuntime.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:r=function(e,r,n,i){for(var a=r;r+n>a;a++)t.push([e,a,i])},t=[],l.t0=regeneratorRuntime.keys(e);case 3:if((l.t1=l.t0()).done){l.next=12;break}return n=l.t1.value,i=e[n],a=0,s=i[a],l.delegateYield(this.ds.iterate(this,[n,0],[n,Number.MAX_VALUE],regeneratorRuntime.mark(function d(e){var t;return regeneratorRuntime.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(null==s){o.next=10;break}if(t=0,!(e.id[1]+e.len<=s[0])){o.next=6;break}return o.abrupt("break",10);case 6:s[0]<e.id[1]?(t=Math.min(e.id[1]-s[0],s[1]),r(n,s[0],t,s[2])):(t=e.id[1]+e.len-s[0],s[2]&&!e.gc&&r(n,s[0],Math.min(t,s[1]),s[2]));case 7:s[1]<=t?s=i[++a]:(s[0]=s[0]+t,s[1]=s[1]-t),o.next=0;break;case 10:case"end":return o.stop()}},d,this)})),"t2",9);case 9:for(;a<i.length;a++)s=i[a],r(n,s[0],s[1],s[2]);l.next=3;break;case 12:l.t3=regeneratorRuntime.keys(t);case 13:if((l.t4=l.t3()).done){l.next=25;break}return o=l.t4.value,u=t[o],c=[u[0],u[1]],l.delegateYield(this.deleteOperation(c),"t5",18);case 18:if(p=l.t5,!p){l.next=21;break}return l.delegateYield(this.store.operationAdded(this,{
|
|
struct:"Delete",target:c}),"t6",21);case 21:if(!u[2]){l.next=23;break}return l.delegateYield(this.garbageCollectOperation(c),"t7",23);case 23:l.next=13;break;case 25:case"end":return l.stop()}},l,this)}),e.prototype.isGarbageCollected=regeneratorRuntime.mark(function p(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(this.ds.findWithUpperBound(e),"t0",1);case 1:return t=r.t0,r.abrupt("return",null!=t&&t.id[0]===e[0]&&e[1]<t.id[1]+t.len&&t.gc);case 3:case"end":return r.stop()}},p,this)}),e.prototype.getDeleteSet=regeneratorRuntime.mark(function d(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e={},t.delegateYield(this.ds.iterate(this,null,null,regeneratorRuntime.mark(function r(t){var n,i,a,s,o;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:n=t.id[0],i=t.id[1],a=t.len,s=t.gc,o=e[n],void 0===o&&(o=[],e[n]=o),o.push([i,a,s]);case 7:case"end":return r.stop()}},r,this)})),"t0",2);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},d,this)}),e.prototype.isDeleted=regeneratorRuntime.mark(function h(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(this.ds.findWithUpperBound(e),"t0",1);case 1:return t=r.t0,r.abrupt("return",null!=t&&t.id[0]===e[0]&&e[1]<t.id[1]+t.len);case 3:case"end":return r.stop()}},h,this)}),e.prototype.setOperation=regeneratorRuntime.mark(function f(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.os.put(e),"t0",1);case 1:return t.abrupt("return",e);case 2:case"end":return t.stop()}},f,this)}),e.prototype.addOperation=regeneratorRuntime.mark(function g(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.os.put(e),"t0",1);case 1:case"end":return t.stop()}},g,this)}),e.prototype.getOperation=regeneratorRuntime.mark(function y(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.os.find(e),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},y,this)}),e.prototype.removeOperation=regeneratorRuntime.mark(function m(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.os["delete"](e),"t0",1);case 1:case"end":return t.stop()}},m,this)}),e.prototype.setState=regeneratorRuntime.mark(function v(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return t={id:[e.user],clock:e.clock},r.delegateYield(this.ss.find([e.user]),"t0",2);case 2:if(!r.t0){r.next=6;break}return r.delegateYield(this.ss.put(t),"t1",4);case 4:r.next=7;break;case 6:return r.delegateYield(this.ss.put(t),"t2",7);case 7:case"end":return r.stop()}},v,this)}),e.prototype.getState=regeneratorRuntime.mark(function b(e){var t,r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(this.ss.find([e]),"t0",1);case 1:if(n.t1=t=n.t0,null!=n.t1){n.next=6;break}n.t2=null,n.next=7;break;case 6:n.t2=t.clock;case 7:return r=n.t2,null==r&&(r=0),n.abrupt("return",{user:e,clock:r});case 10:case"end":return n.stop()}},b,this)}),e.prototype.getStateVector=regeneratorRuntime.mark(function w(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=[],t.delegateYield(this.ss.iterate(this,null,null,regeneratorRuntime.mark(function r(t){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:e.push({user:t.id[0],clock:t.clock});case 1:case"end":return r.stop()}},r,this)})),"t0",2);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},w,this)}),e.prototype.getStateSet=regeneratorRuntime.mark(function k(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e={},t.delegateYield(this.ss.iterate(this,null,null,regeneratorRuntime.mark(function r(t){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:e[t.id[0]]=t.clock;case 1:case"end":return r.stop()}},r,this)})),"t0",2);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},k,this)}),e.prototype.getOperations=regeneratorRuntime.mark(function x(e){var t,r,n,i,a,s,o,u,c,l,p,d,h,f,g;return regeneratorRuntime.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return null==e&&(e={}),t=[],y.delegateYield(this.getStateVector(),"t0",3);case 3:r=y.t0,n=r,i=Array.isArray(n),a=0,n=i?n:n[Symbol.iterator]();case 5:if(!i){y.next=11;break}if(!(a>=n.length)){y.next=8;break}return y.abrupt("break",23);case 8:s=n[a++],y.next=15;break;case 11:if(a=n.next(),!a.done){y.next=14;break}return y.abrupt("break",23);case 14:s=a.value;case 15:if(o=s,u=o.user,"_"!==u){y.next=19;break}return y.abrupt("continue",21);case 19:return c=e[u]||0,y.delegateYield(this.os.iterate(this,[u,c],[u,Number.MAX_VALUE],regeneratorRuntime.mark(function m(e){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:t.push(e);case 1:case"end":return r.stop()}},m,this)})),"t1",21);case 21:y.next=5;break;case 23:l=[],p=t,d=Array.isArray(p),h=0,p=d?p:p[Symbol.iterator]();case 25:if(!d){y.next=31;break}if(!(h>=p.length)){y.next=28;break}return y.abrupt("break",42);case 28:f=p[h++],y.next=35;break;case 31:if(h=p.next(),!h.done){y.next=34;break}return y.abrupt("break",42);case 34:f=h.value;case 35:return g=f,y.t2=l,y.delegateYield(this.makeOperationReady(e,g),"t3",38);case 38:y.t4=y.t3,y.t2.push.call(y.t2,y.t4);case 40:y.next=25;break;case 42:return y.abrupt("return",l);case 43:case"end":return y.stop()}},x,this)}),e.prototype.makeOperationReady=regeneratorRuntime.mark(function R(e,t){var r,n,i;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:t=Y.Struct[t.struct].encode(t),t=Y.utils.copyObject(t),r=t,n=[t.id];case 4:if(null==r.right){a.next=13;break}return a.delegateYield(this.getOperation(r.right),"t0",6);case 6:if(i=a.t0,!(r.right[1]<(e[r.right[0]]||0))&&n.some(function(e){return Y.utils.compareIds(e,i.origin)})){a.next=9;break}return a.abrupt("break",13);case 9:n.push(r.right),r=i,a.next=4;break;case 13:return t.right=r.right,t.left=t.origin,a.abrupt("return",t);case 16:case"end":return a.stop()}},R,this)}),e}();Y.Transaction=Transaction;var Struct={Delete:{encode:function(e){return e},requiredOps:function(e){return[]},execute:regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.deleteOperation(t.target),"t0",1);case 1:return e.abrupt("return",e.t0);case 2:case"end":return e.stop()}},e,this)})},Insert:{encode:function(e){var t={id:e.id,left:e.left,right:e.right,origin:e.origin,parent:e.parent,struct:e.struct};return null!=e.parentSub&&(t.parentSub=e.parentSub),null!=e.opContent?t.opContent=e.opContent:t.content=e.content,t},requiredOps:function(e){var t=[];return null!=e.left&&t.push(e.left),null!=e.right&&t.push(e.right),null==e.origin||Y.utils.compareIds(e.left,e.origin)||t.push(e.origin),t.push(e.parent),null!=e.opContent&&t.push(e.opContent),t},getDistanceToOrigin:regeneratorRuntime.mark(function t(e){var r,n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e.left){t.next=4;break}return t.abrupt("return",0);case 4:return r=0,t.delegateYield(this.getOperation(e.left),"t0",6);case 6:n=t.t0;case 7:if(Y.utils.compareIds(e.origin,n?n.id:null)){t.next=17;break}if(r++,null!=n.left){t.next=13;break}return t.abrupt("break",17);case 13:return t.delegateYield(this.getOperation(n.left),"t1",14);case 14:n=t.t1;case 15:t.next=7;break;case 17:return t.abrupt("return",r);case 18:case"end":return t.stop()}},t,this)}),execute:regeneratorRuntime.mark(function r(e){var t,n,i,a,s,o,u,c,l;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(Struct.Insert.getDistanceToOrigin.call(this,e),"t0",1);case 1:if(n=t=r.t0,null==e.left){r.next=14;break}return r.delegateYield(this.getOperation(e.left),"t1",4);case 4:if(i=r.t1,null!=i.right){r.next=9;break}r.t2=null,r.next=11;break;case 9:return r.delegateYield(this.getOperation(i.right),"t3",10);case 10:r.t2=r.t3;case 11:i=r.t2,r.next=25;break;case 14:return r.delegateYield(this.getOperation(e.parent),"t4",15);case 15:if(a=r.t4,o=e.parentSub?a.map[e.parentSub]:a.start,null!=o){r.next=21;break}r.t5=null,r.next=23;break;case 21:return r.delegateYield(this.getOperation(o),"t6",22);case 22:r.t5=r.t6;case 23:s=r.t5,i=s;case 25:if(null==i||Y.utils.compareIds(i.id,e.right)){r.next=48;break}return r.delegateYield(Struct.Insert.getDistanceToOrigin.call(this,i),"t7",28);case 28:if(u=r.t7,u!==t){r.next=33;break}i.id[0]<e.id[0]&&(e.left=i.id,n=t+1),r.next=38;break;case 33:if(!(t>u)){r.next=37;break}u>=t-n&&(e.left=i.id,n=t+1),r.next=38;break;case 37:return r.abrupt("break",51);case 38:if(t++,!i.right){r.next=44;break}return r.delegateYield(this.getOperation(i.right),"t9",41);case 41:r.t8=r.t9,r.next=45;break;case 44:r.t8=null;case 45:i=r.t8,r.next=49;break;case 48:return r.abrupt("break",51);case 49:r.next=25;break;case 51:if(c=null,l=null,r.t10=a,r.t10){r.next=57;break}return r.delegateYield(this.getOperation(e.parent),"t11",56);case 56:r.t10=r.t11;case 57:if(a=r.t10,null==e.left){r.next=66;break}return r.delegateYield(this.getOperation(e.left),"t12",60);case 60:return c=r.t12,e.right=c.right,c.right=e.id,r.delegateYield(this.setOperation(c),"t13",64);case 64:r.next=67;break;case 66:e.right=e.parentSub?a.map[e.parentSub]||null:a.start;case 67:if(null==e.right){r.next=73;break}return r.delegateYield(this.getOperation(e.right),"t14",69);case 69:return l=r.t14,l.left=e.id,null!=l.gc&&this.store.removeFromGarbageCollector(l),r.delegateYield(this.setOperation(l),"t15",73);case 73:if(null==e.parentSub){r.next=83;break}if(null!=c){r.next=77;break}return a.map[e.parentSub]=e.id,r.delegateYield(this.setOperation(a),"t16",77);case 77:if(null==e.right){r.next=79;break}return r.delegateYield(this.deleteOperation(e.right,!0),"t17",79);case 79:if(null==e.left){r.next=81;break}return r.delegateYield(this.deleteOperation(e.id,!0),"t18",81);case 81:r.next=87;break;case 83:if(null!=l&&null!=c){r.next=87;break}return null==l&&(a.end=e.id),null==c&&(a.start=e.id),r.delegateYield(this.setOperation(a),"t19",87);case 87:case"end":return r.stop()}},r,this)})},List:{encode:function(e){return{struct:"List",id:e.id,type:e.type}},requiredOps:function(){return[]},execute:regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e.start=null,e.end=null;case 2:case"end":return t.stop()}},n,this)}),ref:regeneratorRuntime.mark(function i(e,t){var r,n;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(null!=e.start){i.next=2;break}return i.abrupt("return",null);case 2:return r=null,i.delegateYield(this.getOperation(e.start),"t0",4);case 4:n=i.t0;case 5:if(n.deleted||(r=n,t--),!(t>=0&&null!=n.right)){i.next=12;break}return i.delegateYield(this.getOperation(n.right),"t1",9);case 9:n=i.t1,i.next=13;break;case 12:return i.abrupt("break",15);case 13:i.next=5;break;case 15:return i.abrupt("return",r);case 16:case"end":return i.stop()}},i,this)}),map:regeneratorRuntime.mark(function a(e,t){var r,n;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:e=e.start,r=[];case 2:if(null==e){i.next=9;break}return i.delegateYield(this.getOperation(e),"t0",4);case 4:n=i.t0,n.deleted||r.push(t(n)),e=n.right,i.next=2;break;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}},a,this)})},Map:{encode:function(e){return{struct:"Map",type:e.type,id:e.id,map:{}}},requiredOps:function(){return[]},execute:regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},s,this)}),get:regeneratorRuntime.mark(function o(e,t){var r,n;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(r=e.map[t],null==r){i.next=16;break}return i.delegateYield(this.getOperation(r),"t0",3);case 3:if(n=i.t0,null!=n&&!n.deleted){i.next=8;break}i.t1=void 0,i.next=15;break;case 8:if(null!=n.opContent){i.next=12;break}i.t2=n.content,i.next=14;break;case 12:return i.delegateYield(this.getType(n.opContent),"t3",13);case 13:i.t2=i.t3;case 14:i.t1=i.t2;case 15:return i.abrupt("return",i.t1);case 16:case"end":return i.stop()}},o,this)}),"delete":regeneratorRuntime.mark(function u(e,t){var r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(r=e.map[t]||null,null==r){n.next=3;break}return n.delegateYield(Struct.Delete.create.call(this,{target:r}),"t0",3);case 3:case"end":return n.stop()}},u,this)})}};Y.Struct=Struct;var EventHandler=function(){function e(t){_classCallCheck(this,e),this.waiting=[],this.awaiting=0,this.onevent=t,this.eventListeners=[]}return e.prototype.receivedOp=function(e){this.awaiting<=0?this.onevent([e]):this.waiting.push(Y.utils.copyObject(e))},e.prototype.awaitAndPrematurelyCall=function(e){this.awaiting++,this.onevent(e)},e.prototype.addEventListener=function(e){this.eventListeners.push(e)},e.prototype.removeEventListener=function(e){this.eventListeners=this.eventListeners.filter(function(t){return e!==t})},e.prototype.removeAllEventListeners=function(){this.eventListeners=[]},e.prototype.callEventListeners=function(e){for(var t in this.eventListeners)try{this.eventListeners[t](e)}catch(r){console.log("User events must not throw Errors!")}},e.prototype.awaitedInserts=function(e){for(var t=this.waiting.splice(this.waiting.length-e),r=0;r<t.length;r++)for(var n=t[r],i=this.waiting.length-1;i>=0;i--){var a=this.waiting[i];Y.utils.compareIds(n.left,a.id)?(a.right=n.id,n.left=a.left):Y.utils.compareIds(n.right,a.id)&&(a.left=n.id,n.right=a.right)}this._tryCallEvents()},e.prototype.awaitedDeletes=function(e,t){var r=this.waiting.splice(this.waiting.length-e);for(var n in r){var i=r[n];if(null!=t)for(var a in this.waiting){var s=this.waiting[a];Y.utils.compareIds(i.target,s.left)&&(i.left=t)}}this._tryCallEvents()},e.prototype._tryCallEvents=function(){if(this.awaiting--,this.awaiting<=0&&this.waiting.length>0){var e=this.waiting;this.waiting=[],this.onevent(e)}},e}();Y.utils.EventHandler=EventHandler;var CustomType=function c(e){if(_classCallCheck(this,c),null==e.createType||null==e.initType||null==e["class"])throw new Error("Custom type was not initialized correctly!");this.createType=e.createType,this.initType=e.initType,this["class"]=e["class"]};Y.utils.CustomType=CustomType,Y.utils.copyObject=copyObject,Y.utils.smaller=smaller,Y.utils.compareIds=compareIds;var N=function(){function e(t){if(_classCallCheck(this,e),this.val=t,this.color=!0,this._left=null,this._right=null,this._parent=null,null===t.id)throw new Error("You must define id!")}return e.prototype.isRed=function(){return this.color},e.prototype.isBlack=function(){return!this.color},e.prototype.redden=function(){return this.color=!0,this},e.prototype.blacken=function(){return this.color=!1,this},e.prototype.rotateLeft=function(e){var t=this.parent,r=this.right,n=this.right.left;if(r.left=this,this.right=n,null===t)e.root=r,r._parent=null;else if(t.left===this)t.left=r;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=r}},e.prototype.next=function(){if(null!==this.right){for(var e=this.right;null!==e.left;)e=e.left;return e}for(var t=this;null!==t.parent&&t!==t.parent.left;)t=t.parent;return t.parent},e.prototype.prev=function(){if(null!==this.left){for(var e=this.left;null!==e.right;)e=e.right;return e}for(var t=this;null!==t.parent&&t!==t.parent.right;)t=t.parent;return t.parent},e.prototype.rotateRight=function(e){var t=this.parent,r=this.left,n=this.left.right;if(r.right=this,this.left=n,null===t)e.root=r,r._parent=null;else if(t.left===this)t.left=r;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=r}},e.prototype.getUncle=function(){return this.parent===this.parent.parent.left?this.parent.parent.right:this.parent.parent.left},_createClass(e,[{key:"grandparent",get:function(){return this.parent.parent}},{key:"parent",get:function(){return this._parent}},{key:"sibling",get:function(){return this===this.parent.left?this.parent.right:this.parent.left}},{key:"left",get:function(){return this._left},set:function(e){null!==e&&(e._parent=this),this._left=e}},{key:"right",get:function(){return this._right},set:function(e){null!==e&&(e._parent=this),this._right=e}}]),e}(),RBTree=function(){function e(){_classCallCheck(this,e),this.root=null,this.length=0}return e.prototype.findNext=regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.findWithLowerBound([e[0],e[1]+1]),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t,this)}),e.prototype.findPrev=regeneratorRuntime.mark(function r(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.findWithUpperBound([e[0],e[1]-1]),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},r,this)}),e.prototype.findNodeWithLowerBound=function(e){if(void 0===e)throw new Error("You must define from!");var t=this.root;if(null===t)return null;for(;;)if(null!==e&&!Y.utils.smaller(e,t.val.id)||null===t.left){if(null===e||!Y.utils.smaller(t.val.id,e))return t;if(null===t.right)return t.next();t=t.right}else t=t.left},e.prototype.findNodeWithUpperBound=function(e){if(void 0===e)throw new Error("You must define from!");var t=this.root;if(null===t)return null;for(;;)if(null!==e&&!Y.utils.smaller(t.val.id,e)||null===t.right){if(null===e||!Y.utils.smaller(e,t.val.id))return t;if(null===t.left)return t.prev();t=t.left}else t=t.right},e.prototype.findWithLowerBound=regeneratorRuntime.mark(function n(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.findNodeWithLowerBound(e),r.abrupt("return",null==t?null:t.val);case 2:case"end":return r.stop()}},n,this)}),e.prototype.findWithUpperBound=regeneratorRuntime.mark(function i(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.findNodeWithUpperBound(e),r.abrupt("return",null==t?null:t.val);case 2:case"end":return r.stop()}},i,this)}),e.prototype.iterate=regeneratorRuntime.mark(function a(e,t,r,n){var i;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:i=this.findNodeWithLowerBound(t);case 1:if(null===i||null!==r&&!Y.utils.smaller(i.val.id,r)&&!Y.utils.compareIds(i.val.id,r)){a.next=6;break}return a.delegateYield(n.call(e,i.val),"t0",3);case 3:i=i.next(),a.next=1;break;case 6:return a.abrupt("return",!0);case 7:case"end":return a.stop()}},a,this)}),e.prototype.logTable=regeneratorRuntime.mark(function s(e,t,r){var n;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return null==r&&(r=function(){return!0}),null==e&&(e=null),null==t&&(t=null),n=[],i.delegateYield(this.iterate(this,e,t,regeneratorRuntime.mark(function a(e){var t,i;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(r(e)){t={};for(i in e)"object"==typeof e[i]?t[i]=JSON.stringify(e[i]):t[i]=e[i];n.push(t)}case 1:case"end":return a.stop()}},a,this)})),"t0",5);case 5:null!=console.table&&console.table(n);case 6:case"end":return i.stop()}},s,this)}),e.prototype.find=regeneratorRuntime.mark(function o(e){var t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",(t=this.findNode(e))?t.val:null);case 1:case"end":return r.stop()}},o,this)}),e.prototype.findNode=function(e){if(null==e||e.constructor!==Array)throw new Error("Expect id to be an array!");var t=this.root;if(null===t)return!1;for(;;){if(null===t)return!1;if(Y.utils.smaller(e,t.val.id))t=t.left;else{if(!Y.utils.smaller(t.val.id,e))return t;t=t.right}}},e.prototype["delete"]=regeneratorRuntime.mark(function u(e){var t,r,n,i;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!=e&&e.constructor===Array){a.next=2;break}throw new Error("id is expected to be an Array!");case 2:if(t=this.findNode(e),null!=t){a.next=5;break}throw new Error("Element does not exist!");case 5:if(this.length--,null!==t.left&&null!==t.right){for(r=t.left;null!==r.right;)r=r.right;t.val=r.val,t=r}if(i=t.left||t.right,null===i?(n=!0,i=new N({id:0}),i.blacken(),t.right=i):n=!1,null!==t.parent){a.next=14;break}return n?this.root=null:(this.root=i,i.blacken(),i._parent=null),a.abrupt("return");case 14:if(t.parent.left!==t){a.next=18;break}t.parent.left=i,a.next=23;break;case 18:if(t.parent.right!==t){a.next=22;break}t.parent.right=i,a.next=23;break;case 22:throw new Error("Impossible!");case 23:if(t.isBlack()&&(i.isRed()?i.blacken():this._fixDelete(i)),this.root.blacken(),!n){a.next=35;break}if(i.parent.left!==i){a.next=30;break}i.parent.left=null,a.next=35;break;case 30:if(i.parent.right!==i){a.next=34;break}i.parent.right=null,a.next=35;break;case 34:throw new Error("Impossible #3");case 35:case"end":return a.stop()}},u,this)}),e.prototype._fixDelete=function(e){function t(e){return null!==e?e.isBlack():!0}function r(e){return null!==e?e.isRed():!1}if(null!==e.parent){var n=e.sibling;if(r(n)){if(e.parent.redden(),n.blacken(),e===e.parent.left)e.parent.rotateLeft(this);else{if(e!==e.parent.right)throw new Error("Impossible #2");e.parent.rotateRight(this)}n=e.sibling}e.parent.isBlack()&&n.isBlack()&&t(n.left)&&t(n.right)?(n.redden(),this._fixDelete(e.parent)):e.parent.isRed()&&n.isBlack()&&t(n.left)&&t(n.right)?(n.redden(),e.parent.blacken()):(e===e.parent.left&&n.isBlack()&&r(n.left)&&t(n.right)?(n.redden(),n.left.blacken(),n.rotateRight(this),n=e.sibling):e===e.parent.right&&n.isBlack()&&r(n.right)&&t(n.left)&&(n.redden(),n.right.blacken(),n.rotateLeft(this),n=e.sibling),n.color=e.parent.color,e.parent.blacken(),e===e.parent.left?(n.right.blacken(),e.parent.rotateLeft(this)):(n.left.blacken(),e.parent.rotateRight(this)))}},e.prototype.put=regeneratorRuntime.mark(function c(e){var t,r;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(null!=e&&null!=e.id&&e.id.constructor===Array){n.next=2;break}throw new Error("v is expected to have an id property which is an Array!");case 2:if(t=new N(e),null===this.root){n.next=31;break}r=this.root;case 5:if(!Y.utils.smaller(t.val.id,r.val.id)){n.next=15;break}if(null!==r.left){n.next=12;break}return r.left=t,n.abrupt("break",28);case 12:r=r.left;case 13:n.next=26;break;case 15:if(!Y.utils.smaller(r.val.id,t.val.id)){n.next=24;break}if(null!==r.right){n.next=21;break}return r.right=t,n.abrupt("break",28);case 21:r=r.right;case 22:n.next=26;break;case 24:return r.val=t.val,n.abrupt("return",r);case 26:n.next=5;break;case 28:this._fixInsert(t),n.next=32;break;case 31:this.root=t;case 32:return this.length++,this.root.blacken(),n.abrupt("return",t);case 35:case"end":return n.stop()}},c,this)}),e.prototype._fixInsert=function(e){if(null===e.parent)return void e.blacken();if(!e.parent.isBlack()){var t=e.getUncle();null!==t&&t.isRed()?(e.parent.blacken(),t.blacken(),e.grandparent.redden(),this._fixInsert(e.grandparent)):(e===e.parent.right&&e.parent===e.grandparent.left?(e.parent.rotateLeft(this),e=e.left):e===e.parent.left&&e.parent===e.grandparent.right&&(e.parent.rotateRight(this),e=e.right),e.parent.blacken(),e.grandparent.redden(),e===e.parent.left?e.grandparent.rotateRight(this):e.grandparent.rotateLeft(this))}},e}();Y.utils.RBTree=RBTree,Y.Memory=function(){var e=function(e){function t(r){_classCallCheck(this,t),e.call(this,r),this.store=r,this.ss=r.ss,this.os=r.os,this.ds=r.ds}return _inherits(t,e),t}(Y.Transaction),t=function(t){function r(e,n){_classCallCheck(this,r),t.call(this,e,n),this.os=new Y.utils.RBTree,this.ds=new Y.utils.RBTree,this.ss=new Y.utils.RBTree}return _inherits(r,t),r.prototype.logTable=function(){var e=this;e.requestTransaction(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("User: ",this.store.y.connector.userId,"=============================="),e.t0=console,e.delegateYield(this.getStateSet(),"t1",3);case 3:return e.t2=e.t1,e.t0.log.call(e.t0,"State Set (SS):",e.t2),console.log("Operation Store (OS):"),e.delegateYield(this.os.logTable(),"t3",7);case 7:return console.log("Deletion Store (DS):"),e.delegateYield(this.ds.logTable(),"t4",9);case 9:(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("GC1|2 not empty!",this.store.gc1,this.store.gc2),"{}"!==JSON.stringify(this.store.listenersById)&&console.warn("listenersById not empty!"),"[]"!==JSON.stringify(this.store.listenersByIdExecuteNow)&&console.warn("listenersByIdExecuteNow not empty!"),this.store.transactionInProgress&&console.warn("Transaction still in progress!");case 13:case"end":return e.stop()}},t,this)}),!0)},r.prototype.transact=function(t){for(var r=new e(this);null!==t;){for(var n=t.call(r),i=n.next();!i.done;)i=n.next(i.value);t=this.getNextRequest()}},r.prototype.destroy=regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t.prototype.destroy.call(this),delete this.os,delete this.ss,delete this.ds;case 4:case"end":return e.stop()}},n,this)}),r}(Y.AbstractDatabase);return t}(),Y.IndexedDB=function(){var e=function(){function e(t,r){_classCallCheck(this,e),this.store=t.objectStore(r)}return e.prototype.find=regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}),e.prototype.put=regeneratorRuntime.mark(function r(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.put(e);case 2:case"end":return t.stop()}},r,this)}),e.prototype["delete"]=regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store["delete"](e);case 2:case"end":return t.stop()}},n,this)}),e.prototype.findWithLowerBound=regeneratorRuntime.mark(function i(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.openCursor(window.IDBKeyRange.lowerBound(e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},i,this)}),e.prototype.findWithUpperBound=regeneratorRuntime.mark(function a(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.openCursor(window.IDBKeyRange.upperBound(e),"prev");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},a,this)}),e.prototype.findNext=regeneratorRuntime.mark(function s(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.findWithLowerBound([e[0],e[1]+1]),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},s,this)}),e.prototype.findPrev=regeneratorRuntime.mark(function o(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.findWithUpperBound([e[0],e[1]-1]),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},o,this)}),e.prototype.iterate=regeneratorRuntime.mark(function u(e,t,r,n){var i,a;return regeneratorRuntime.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:i=null,null!=t&&null!=r?i=window.IDBKeyRange.bound(t,r):null!=t?i=window.IDBKeyRange.lowerBound(t):null!=r&&(i=window.IDBKeyRange.upperBound(r)),a=this.store.openCursor(i);case 3:return s.next=5,a;case 5:if(s.t0=s.sent,null==s.t0){s.next=11;break}return s.delegateYield(n.call(e,a.result.value),"t1",8);case 8:a.result["continue"](),s.next=3;break;case 11:case"end":return s.stop()}},u,this)}),e}(),t=function(t){function r(n){_classCallCheck(this,r),t.call(this,n);var i=n.db.transaction(["OperationStore","StateStore","DeleteStore"],"readwrite");this.store=n,this.ss=new e(i,"StateStore"),this.os=new e(i,"OperationStore"),this.ds=new e(i,"DeleteStore")}return _inherits(r,t),r}(Y.Transaction),r=function(e){function r(t,n){if(_classCallCheck(this,r),e.call(this,t,n),null==n&&(n={}),null==n.namespace||"string"!=typeof n.namespace)throw new Error("IndexedDB: expect a string (opts.namespace)!");this.namespace=n.namespace,null!=n.idbVersion?this.idbVersion=n.idbVersion:this.idbVersion=5;var i=this;this.requestTransaction(regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.indexedDB.open(n.namespace,i.idbVersion);case 2:i.db=e.sent;case 3:case"end":return e.stop()}},s,this)})),n.cleanStart&&this.requestTransaction(regeneratorRuntime.mark(function o(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.os.store.clear();case 2:return e.next=4,this.ds.store.clear();case 4:return e.next=6,this.ss.store.clear();case 6:case"end":return e.stop()}},o,this)}));var a=[];window.addEventListener("storage",function(e){e.key==="__YJS__"+i.namespace&&(a.push(e.newValue),1===a.length&&i.requestTransaction(regeneratorRuntime.mark(function t(){var e,r,n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=a,a=[],t.t0=regeneratorRuntime.keys(e);case 3:if((t.t1=t.t0()).done){t.next=12;break}if(r=t.t1.value,n=JSON.parse(e[r]),"Delete"===n.struct){t.next=9;break}return t.delegateYield(this.getOperation(n.id),"t2",8);case 8:n=t.t2;case 9:return t.delegateYield(this.store.operationAdded(this,n,!0),"t3",10);case 10:t.next=3;break;case 12:case"end":return t.stop()}},t,this)})))},!1)}return _inherits(r,e),r.prototype.operationAdded=regeneratorRuntime.mark(function n(t,r,i){return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(e.prototype.operationAdded.call(this,t,r),"t0",1);case 1:i||(window.localStorage["__YJS__"+this.namespace]=JSON.stringify(r));case 2:case"end":return n.stop()}},n,this)}),r.prototype.transact=function(e){function r(s){var o=s.value;return s.done?(e=i.getNextRequest(),void(null!=e&&(null==n&&null!=i.db&&(n=new t(i)),a=e.call(n),r(a.next())))):void(o.constructor===window.IDBRequest?(o.onsuccess=function(){var e=o.result;null!=e&&e.constructor===window.IDBCursorWithValue&&(e=e.value),r(a.next(e))},o.onerror=function(e){a["throw"](e)}):o.constructor===window.IDBCursor?(o.onsuccess=function(){r(a.next(null!=o.result?o.result.value:null))},o.onerror=function(e){a["throw"](e)}):o.constructor===window.IDBOpenDBRequest?(o.onsuccess=function(e){var t=e.target.result;r(a.next(t))},o.onerror=function(){a["throw"]("Couldn't open IndexedDB database!")},o.onupgradeneeded=function(e){var t=e.target.result;try{t.createObjectStore("OperationStore",{keyPath:"id"}),t.createObjectStore("DeleteStore",{keyPath:"id"}),t.createObjectStore("StateStore",{keyPath:"id"})}catch(r){console.log("Store already exists!")}}):a["throw"]("You must not yield this type!"))}var n=null!=this.db?new t(this):null,i=this,a=e.call(n);r(a.next())},r.prototype.destroy=regeneratorRuntime.mark(function i(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.db.close(),e.next=3,window.indexedDB.deleteDatabase(this.namespace);case 3:case"end":return e.stop()}},i,this)}),r}(Y.AbstractDatabase);return r}();var globalRoom={users:{},buffers:{},removeUser:function(e){for(var t in this.users)this.users[t].userLeft(e);delete this.users[e],delete this.buffers[e]},addUser:function(e){this.users[e.userId]=e,this.buffers[e.userId]=[];for(var t in this.users)if(t!==e.userId){var r=this.users[t];r.userJoined(e.userId,"master"),e.userJoined(r.userId,"master")}}};Y.utils.globalRoom=globalRoom;var userIdCounter=0,Test=function(e){
|
|
function t(r,n){var i=this;if(_classCallCheck(this,t),void 0===n)throw new Error("Options must not be undefined!");n.role="master",n.forwardToSyncingClients=!1,e.call(this,r,n),this.setUserId(userIdCounter++ +"").then(function(){globalRoom.addUser(i)}),this.globalRoom=globalRoom,this.syncingClientDuration=0}return _inherits(t,e),t.prototype.receiveMessage=function(t,r){e.prototype.receiveMessage.call(this,t,JSON.parse(JSON.stringify(r)))},t.prototype.send=function(e,t){var r=globalRoom.buffers[e];null!=r&&r.push(JSON.parse(JSON.stringify([this.userId,t])))},t.prototype.broadcast=function(e){for(var t in globalRoom.buffers)globalRoom.buffers[t].push(JSON.parse(JSON.stringify([this.userId,e])))},t.prototype.isDisconnected=function(){return null==globalRoom.users[this.userId]},t.prototype.reconnect=function(){return this.isDisconnected()&&(globalRoom.addUser(this),e.prototype.reconnect.call(this)),this.flushAll()},t.prototype.disconnect=function(){return this.isDisconnected()||(globalRoom.removeUser(this.userId),e.prototype.disconnect.call(this)),wait()},t.prototype.flush=function(){var e=this;return async(regeneratorRuntime.mark(function t(){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,wait();case 2:if(!(globalRoom.buffers[e.userId].length>0)){t.next=9;break}return r=globalRoom.buffers[e.userId].shift(),this.receiveMessage(r[0],r[1]),t.next=7,wait();case 7:t.next=2;break;case 9:case"end":return t.stop()}},t,this)}))},t.prototype.flushAll=function(){return new Promise(function(e){function t(){var r=_flushOne();if(r){for(;_flushOne(););wait().then(t)}else wait().then(function(){e()})}wait().then(t)})},t.prototype.flushOne=function(){_flushOne()},t}(Y.AbstractConnector);Y.Test=Test;var WebRTC=function(e){function t(r,n){if(_classCallCheck(this,t),void 0===n)throw new Error("Options must not be undefined!");if(null==n.room)throw new Error("You must define a room name!");n.role="slave",e.call(this,r,n),this.webrtcOptions={url:n.url||"https://yatta.ninja:8888",room:n.room};var i=new SimpleWebRTC(this.webrtcOptions);this.swr=i;var a=this;i.once("connectionReady",function(e){i.joinRoom(a.webrtcOptions.room),i.once("joinedRoom",function(){a.setUserId(e),i.on("channelMessage",function(e,t,r){null!=r.type&&a.receiveMessage(e.id,r.payload)})}),i.on("createdPeer",function(e){a.userJoined(e.id,"master")}),i.on("peerStreamRemoved",function(e){a.userLeft(e.id)})})}return _inherits(t,e),t.prototype.disconnect=function(){this.swr.leaveRoom(),e.prototype.disconnect.call(this)},t.prototype.reconnect=function(){this.swr.joinRoom(this.webrtcOptions.room),e.prototype.reconnect.call(this)},t.prototype.send=function r(e,t){var n=this,r=function i(){var r,a=n.swr.webrtc.getPeers(e)[0];a&&(r=a.sendDirectly("simplewebrtc","yjs",t)),r||setTimeout(i,500)};r()},t.prototype.broadcast=function(e){this.swr.sendDirectlyToAll("simplewebrtc","yjs",e)},t.prototype.isDisconnected=function(){return!1},t}(Y.AbstractConnector);Y.WebRTC=WebRTC,function(){var e=function(){function e(t,r,n,i){var a=this;_classCallCheck(this,e),this.os=t,this._model=r,this.idArray=n,this.valArray=i,this.eventHandler=new Y.utils.EventHandler(function(e){var t=[];for(var r in e){var n=e[r];if("Insert"===n.struct){var i=void 0;if(null===n.left)i=0;else{var s=JSON.stringify(n.left);if(i=a.idArray.indexOf(s)+1,0>=i)throw new Error("Unexpected operation!")}a.idArray.splice(i,0,JSON.stringify(n.id)),a.valArray.splice(i,0,n.content),t.push({type:"insert",object:a,index:i,length:1})}else{if("Delete"!==n.struct)throw new Error("Unexpected struct!");var i=a.idArray.indexOf(JSON.stringify(n.target));i>=0&&(a.idArray.splice(i,1),a.valArray.splice(i,1),t.push({type:"delete",object:a,index:i,length:1}))}}a.eventHandler.callEventListeners(t)})}return e.prototype.get=function(e){if(null==e||"number"!=typeof e)throw new Error("pos must be a number!");return this.valArray[e]},e.prototype.toArray=function(){return this.valArray.slice()},e.prototype.insert=function(e,t){if("number"!=typeof e)throw new Error("pos must be a number!");if(!(t instanceof Array))throw new Error("contents must be an Array of objects!");if(0!==t.length){if(e>this.idArray.length||0>e)throw new Error("This position exceeds the range of the array!");for(var r=0===e?null:JSON.parse(this.idArray[e-1]),n=[],i=r,a=0;a<t.length;a++){var s={left:i,origin:i,parent:this._model,content:t[a],struct:"Insert",id:this.os.getNextOpId()};n.push(s),i=s.id}var o=this.eventHandler;o.awaitAndPrematurelyCall(n),this.os.requestTransaction(regeneratorRuntime.mark(function u(){var e,t;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(null==r){i.next=5;break}return i.delegateYield(this.getOperation(r),"t0",2);case 2:e=i.t0.right,i.next=7;break;case 5:return i.delegateYield(this.getOperation(n[0].parent),"t1",6);case 6:e=i.t1.start;case 7:for(t in n)n[t].right=e;return i.delegateYield(this.applyCreatedOperations(n),"t2",9);case 9:o.awaitedInserts(n.length);case 10:case"end":return i.stop()}},u,this)}))}},e.prototype["delete"]=function(e,t){if(null==t&&(t=1),"number"!=typeof t)throw new Error("pos must be a number!");if("number"!=typeof e)throw new Error("pos must be a number!");if(e+t>this.idArray.length||0>e||0>t)throw new Error("The deletion range exceeds the range of the array!");if(0!==t){for(var r=this.eventHandler,n=e>0?JSON.parse(this.idArray[e-1]):null,i=[],a=0;t>a;a++)i.push({target:JSON.parse(this.idArray[e+a]),struct:"Delete"});r.awaitAndPrematurelyCall(i),this.os.requestTransaction(regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.applyCreatedOperations(i),"t0",1);case 1:r.awaitedDeletes(i.length,n);case 2:case"end":return e.stop()}},s,this)}))}},e.prototype.observe=function(e){this.eventHandler.addEventListener(e)},e.prototype._changed=regeneratorRuntime.mark(function t(e,r){var n,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r.deleted){t.next=13;break}if("Insert"!==r.struct){t.next=12;break}n=r.left;case 3:if(null==n){t.next=11;break}return t.delegateYield(e.getOperation(n),"t0",5);case 5:if(i=t.t0,i.deleted){t.next=8;break}return t.abrupt("break",11);case 8:n=i.left,t.next=3;break;case 11:r.left=n;case 12:this.eventHandler.receivedOp(r);case 13:case"end":return t.stop()}},t,this)}),_createClass(e,[{key:"length",get:function(){return this.idArray.length}}]),e}();Y.Array=new Y.utils.CustomType({"class":e,createType:regeneratorRuntime.mark(function t(){var e,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.store.getNextOpId(),r={struct:"List",type:"Array",start:null,end:null,id:e},t.delegateYield(this.applyCreatedOperations([r]),"t0",3);case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}},t,this)}),initType:regeneratorRuntime.mark(function r(t,n){var i,a;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return i=[],r.delegateYield(Y.Struct.List.map.call(this,n,function(e){return i.push(e.content),JSON.stringify(e.id)}),"t0",2);case 2:return a=r.t0,r.abrupt("return",new e(t,n.id,a,i));case 4:case"end":return r.stop()}},r,this)})})}(),function(){var e=function(){function e(t,r,n,i){var a=this;_classCallCheck(this,e),this._model=r.id,this.os=t,this.map=Y.utils.copyObject(r.map),this.contents=n,this.opContents=i,this.eventHandler=new Y.utils.EventHandler(function(e){var t=[];for(var r in e){var n,i=e[r],s="Delete"===i.struct?i.key:i.parentSub;if(null!=a.opContents[s]?!function(){var e=a.opContents[s];n=function(){return new Promise(function(t){a.os.requestTransaction(regeneratorRuntime.mark(function r(){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(this.getType(e),"t0",1);case 1:r.t1=r.t0,t(r.t1);case 3:case"end":return r.stop()}},r,this)}))})}}():n=a.contents[s],"Insert"===i.struct){if(null===i.left){null!=i.opContent?(delete a.contents[s],i.deleted?delete a.opContents[s]:a.opContents[s]=i.opContent):(delete a.opContents[s],i.deleted?delete a.contents[s]:a.contents[s]=i.content),a.map[s]=i.id;var o={name:s,object:a};void 0===n?o.type="add":(o.type="update",o.oldValue=n),t.push(o)}}else{if("Delete"!==i.struct)throw new Error("Unexpected Operation!");if(Y.utils.compareIds(a.map[s],i.target)){delete a.opContents[s],delete a.contents[s];var u={name:s,object:a,oldValue:n,type:"delete"};t.push(u)}}}a.eventHandler.callEventListeners(t)})}return e.prototype.get=function(e){var t=this;if(null==e)throw new Error("You must specify key!");return null==this.opContents[e]?this.contents[e]:new Promise(function(r){var n=t.opContents[e];t.os.requestTransaction(regeneratorRuntime.mark(function i(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.getType(n),"t0",1);case 1:e.t1=e.t0,r(e.t1);case 3:case"end":return e.stop()}},i,this)}))})},e.prototype.getPrimitive=function(e){return null==e?Y.utils.copyObject(this.contents):this.contents[e]},e.prototype["delete"]=function(e){var t=this.map[e];if(null!=t){var r={target:t,struct:"Delete"},n=this.eventHandler,i=Y.utils.copyObject(r);i.key=e,n.awaitAndPrematurelyCall([i]),this.os.requestTransaction(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.applyCreatedOperations([r]),"t0",1);case 1:n.awaitedDeletes(1);case 2:case"end":return e.stop()}},a,this)}))}},e.prototype.set=function(e,t){var r=this,n=this.map[e]||null,i={left:null,right:n,origin:null,parent:this._model,parentSub:e,struct:"Insert"};return new Promise(function(e){if(t instanceof Y.utils.CustomType)r.os.requestTransaction(regeneratorRuntime.mark(function a(){var r,n;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.delegateYield(t.createType.call(this),"t0",1);case 1:return r=a.t0,a.delegateYield(this.getType(r),"t1",3);case 3:return n=a.t1,i.opContent=r,i.id=this.store.getNextOpId(),a.delegateYield(this.applyCreatedOperations([i]),"t2",7);case 7:e(n);case 8:case"end":return a.stop()}},a,this)}));else{i.content=t,i.id=r.os.getNextOpId();var n=r.eventHandler;n.awaitAndPrematurelyCall([i]),r.os.requestTransaction(regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.applyCreatedOperations([i]),"t0",1);case 1:n.awaitedInserts(1);case 2:case"end":return e.stop()}},s,this)})),e(t)}})},e.prototype.observe=function(e){this.eventHandler.addEventListener(e)},e.prototype.unobserve=function(e){this.eventHandler.removeEventListener(e)},e.prototype.observePath=function(e,t){function r(e){for(var r=0;r<e.length;r++){var a=e[r];if(a.name===i){var s=n.get(i);s instanceof Promise?s.then(t):t(s)}}}var n=this;if(e.length<1)throw new Error("Path must contain at least one element!");if(1===e.length){var i=e[0],a=n.get(i);return a instanceof Promise?a.then(t):t(a),this.observe(r),Promise.resolve(function(){n.unobserve(t)})}var s,o=function(){var r=n.get(e[0]);return!r instanceof Promise&&(r=n.set(e[0],Y.Map)),r.then(function(r){return r.observePath(e.slice(1),t)}).then(function(e){return s=e,Promise.resolve()})},u=function(t){for(var r in t){var n=t[r];n.name===e[0]&&(s(),("add"===n.type||"update"===n.type)&&o())}};return n.observe(u),o().then(Promise.resolve(function(){s(),n.unobserve(u)}))},e.prototype._changed=regeneratorRuntime.mark(function t(e,r){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if("Delete"!==r.struct){t.next=3;break}return t.delegateYield(e.getOperation(r.target),"t0",2);case 2:r.key=t.t0.parentSub;case 3:this.eventHandler.receivedOp(r);case 4:case"end":return t.stop()}},t,this)}),e}();Y.Map=new Y.utils.CustomType({"class":e,createType:regeneratorRuntime.mark(function t(){var e,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.store.getNextOpId(),r={map:{},struct:"Map",type:"Map",id:e},t.delegateYield(this.applyCreatedOperations([r]),"t0",3);case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}},t,this)}),initType:regeneratorRuntime.mark(function r(t,n){var i,a,s,o,u;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:i={},a={},s=n.map,r.t0=regeneratorRuntime.keys(s);case 4:if((r.t1=r.t0()).done){r.next=11;break}return o=r.t1.value,r.delegateYield(this.getOperation(s[o]),"t2",7);case 7:u=r.t2,null!=u.opContent?a[o]=u.opContent:i[o]=u.content,r.next=4;break;case 11:return r.abrupt("return",new e(t,n,i,a));case 12:case"end":return r.stop()}},r,this)})})}(),function(){var e=function(e){function t(r,n,i,a){_classCallCheck(this,t),e.call(this,r,n,i,a),this.textfields=[]}return _inherits(t,e),t.prototype.toString=function(){return this.valArray.join("")},t.prototype.insert=function(t,r){e.prototype.insert.call(this,t,r.split(""))},t.prototype.bind=function(e,t){t=t||window,null==t.getSelection&&(t=window);for(var r in this.textfields)if(this.textfields[r]===e)return;var n=!1,i=this;e.value=this.toString(),this.textfields.push(e);var a,s,o;null!=e.selectionStart&&null!=e.setSelectionRange?(a=function(t){var r=e.selectionStart,n=e.selectionEnd;return null!=t&&(r=t(r),n=t(n)),{left:r,right:n}},s=function(t){o(i.toString()),e.setSelectionRange(t.left,t.right)},o=function(t){e.value=t}):(a=function(r){var n={},i=t.getSelection(),a=e.textContent.length;n.left=Math.min(i.anchorOffset,a),n.right=Math.min(i.focusOffset,a),null!=r&&(n.left=r(n.left),n.right=r(n.right));var s=i.focusNode;return s===e||s===e.childNodes[0]?n.isReal=!0:n.isReal=!1,n},s=function(t){o(i.toString());var r=e.childNodes[0];if(t.isReal&&null!=r){t.left<0&&(t.left=0),t.right=Math.max(t.left,t.right),t.right>r.length&&(t.right=r.length),t.left=Math.min(t.left,t.right);var n=document.createRange();n.setStart(r,t.left),n.setEnd(r,t.right);var a=window.getSelection();a.removeAllRanges(),a.addRange(n)}},o=function(t){var r=t.replace(new RegExp("\n","g")," ").split(" ");e.innerText="";for(var n in r){var i=r[n];e.innerText+=i,n!==r.length-1&&(e.innerHTML+=" ")}}),o(this.toString()),this.observe(function(e){for(var t in e){var r=e[t];if(!n){var i,o;if("insert"===r.type){i=r.index,o=function(e){return i>=e?e:e+=1};var u=a(o);s(u)}else"delete"===r.type&&(i=r.index,o=function(e){return i>e?e:e-=1},u=a(o),s(u))}}}),e.onkeypress=function(t){if(i.is_deleted)return e.onkeypress=null,!0;n=!0;var r;if(r=13===t.keyCode?"\n":null!=t.key?32===t.charCode?" ":t.key:window.String.fromCharCode(t.keyCode),r.length>1)return!0;if(r.length>0){var o=a(),u=Math.min(o.left,o.right,i.length),c=Math.abs(o.right-o.left);i["delete"](u,c),i.insert(u,r),o.left=u+r.length,o.right=o.left,s(o)}return t.preventDefault(),n=!1,!1},e.onpaste=function(t){return i.is_deleted?(e.onpaste=null,!0):void t.preventDefault()},e.oncut=function(t){return i.is_deleted?(e.oncut=null,!0):void t.preventDefault()},e.onkeydown=function(t){if(n=!0,i.is_deleted)return e.onkeydown=null,!0;var r=a(),o=Math.min(r.left,r.right,i.toString().length),u=Math.abs(r.left-r.right);if(null!=t.keyCode&&8===t.keyCode){if(u>0)i["delete"](o,u),r.left=o,r.right=o,s(r);else if(null!=t.ctrlKey&&t.ctrlKey){var c=i.toString(),l=o,p=0;for(o>0&&(l--,p++);l>0&&" "!==c[l]&&"\n"!==c[l];)l--,p++;i["delete"](l,o-l),r.left=l,r.right=l,s(r)}else o>0&&(i["delete"](o-1,1),r.left=o-1,r.right=o-1,s(r));return t.preventDefault(),n=!1,!1}return null!=t.keyCode&&46===t.keyCode?(u>0?(i["delete"](o,u),r.left=o,r.right=o,s(r)):(i["delete"](o,1),r.left=o,r.right=o,s(r)),t.preventDefault(),n=!1,!1):(n=!1,!0)}},t}(Y.Array["class"]);Y.TextBind=new Y.utils.CustomType({"class":e,createType:regeneratorRuntime.mark(function t(){var e,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.store.getNextOpId(),r={start:null,end:null,struct:"List",type:"TextBind",id:e},t.delegateYield(this.applyCreatedOperations([r]),"t0",3);case 3:return t.abrupt("return",e);case 4:case"end":return t.stop()}},t,this)}),initType:regeneratorRuntime.mark(function r(t,n){var i,a;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return i=[],r.delegateYield(Y.Struct.List.map.call(this,n,function(e){return i.push(e.content),JSON.stringify(e.id)}),"t0",2);case 2:return a=r.t0,r.abrupt("return",new e(t,n.id,a,i));case 4:case"end":return r.stop()}},r,this)})})}();
|
|
//# sourceMappingURL=y.js.map
|