yjs/y.js
2015-06-18 15:11:22 +02:00

2 lines
8.4 KiB
JavaScript

"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}!function(t){function e(t,e,r,o){var i=Object.create((e||n).prototype);return i._invoke=s(t,r||null,new h(o||[])),i}function r(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(n){return{type:"throw",arg:n}}}function n(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function c(t){this.arg=t}function u(t){function e(e,r){var n=t[e](r),a=n.value;return a instanceof c?Promise.resolve(a.arg).then(o,i):Promise.resolve(a).then(function(t){return n.value=t,n},i)}function r(t,r){var o=n?n.then(function(){return e(t,r)}):new Promise(function(n){n(e(t,r))});return n=o["catch"](a),o}"object"==typeof process&&process.domain&&(e=process.domain.bind(e));var n,o=e.bind(t,"next"),i=e.bind(t,"throw"),a=e.bind(t,"return");this._invoke=r}function s(t,e,n){var o=x;return function(i,a){if(o===L)throw new Error("Generator is already running");if(o===k)return y();for(;;){var c=n.delegate;if(c){if("return"===i||"throw"===i&&c.iterator[i]===v){n.delegate=null;var u=c.iterator["return"];if(u){var s=r(u,c.iterator,a);if("throw"===s.type){i="throw",a=s.arg;continue}}if("return"===i)continue}var s=r(c.iterator[i],c.iterator,a);if("throw"===s.type){n.delegate=null,i="throw",a=s.arg;continue}i="next",a=v;var f=s.arg;if(!f.done)return o=b,f;n[c.resultName]=f.value,n.next=c.nextLoc,n.delegate=null}if("next"===i)o===b?n.sent=a:delete n.sent;else if("throw"===i){if(o===x)throw o=k,a;n.dispatchException(a)&&(i="next",a=v)}else"return"===i&&n.abrupt("return",a);o=L;var s=r(t,e,n);if("normal"===s.type){o=n.done?k:b;var f={value:s.arg,done:n.done};if(s.arg!==E)return f;n.delegate&&"next"===i&&(a=v)}else"throw"===s.type&&(o=k,i="throw",a=s.arg)}}}function f(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function l(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset()}function p(t){if(t){var e=t[g];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function o(){for(;++r<t.length;)if(d.call(t,r))return o.value=t[r],o.done=!1,o;return o.value=v,o.done=!0,o};return n.next=n}}return{next:y}}function y(){return{value:v,done:!0}}var v,d=Object.prototype.hasOwnProperty,g="function"==typeof Symbol&&Symbol.iterator||"@@iterator",w="object"==typeof module,m=t.regeneratorRuntime;if(m)return void(w&&(module.exports=m));m=t.regeneratorRuntime=w?module.exports:{},m.wrap=e;var x="suspendedStart",b="suspendedYield",L="executing",k="completed",E={},O=i.prototype=n.prototype;o.prototype=O.constructor=i,i.constructor=o,o.displayName="GeneratorFunction",m.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return e?e===o||"GeneratorFunction"===(e.displayName||e.name):!1},m.mark=function(t){return t.__proto__=i,t.prototype=Object.create(O),t},m.awrap=function(t){return new c(t)},a(u.prototype),m.async=function(t,r,n,o){var i=new u(e(t,r,n,o));return m.isGeneratorFunction(r)?i:i.next().then(function(t){return t.done?t.value:i.next()})},a(O),O[g]=function(){return this},O.toString=function(){return"[object Generator]"},m.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},m.values=p,h.prototype={constructor:h,reset:function(){this.prev=0,this.next=0,this.sent=v,this.done=!1,this.delegate=null,this.tryEntries.forEach(l);for(var t,e=0;d.call(this,t="t"+e)||20>e;++e)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){function e(e,n){return i.type="throw",i.arg=t,r.next=e,!!n}if(this.done)throw t;for(var r=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=d.call(o,"catchLoc"),c=d.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return e(o.catchLoc,!0);if(this.prev<o.finallyLoc)return e(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return e(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return e(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&d.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?this.next=o.finallyLoc:this.complete(i),E},complete:function(t,e){if("throw"===t.type)throw t.arg;"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=t.arg,this.next="end"):"normal"===t.type&&e&&(this.next=e)},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),l(r),E}},"catch":function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;l(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:p(t),resultName:e,nextLoc:r},E}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:void 0);var IndexedDB=function(){var t=function(){function t(e){_classCallCheck(this,t),this.transaction=e,this.sv=e.objectStore("StateVector"),this.ob=e.objectStore("OperationBuffer")}return t.prototype.setOperation=regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ob.put(t);case 2:return e.abrupt("return",t);case 3:case"end":return e.stop()}},e,this)}),t.prototype.getOperation=regeneratorRuntime.mark(function r(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ob.get(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},r,this)}),t.prototype.setState=regeneratorRuntime.mark(function n(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sv.put(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},n,this)}),t.prototype.getState=regeneratorRuntime.mark(function o(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sv.get(t);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0={user:t,clock:0};case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},o,this)}),t.prototype.getStateVector=regeneratorRuntime.mark(function i(){var t,e;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return t=[],r.next=3,this.sv.openCursor();case 3:e=r.sent;case 4:return r.next=6,e["continue"];case 6:if(r.t0=e=r.sent,null==r.t0){r.next=11;break}t.push(e.value),r.next=4;break;case 11:return r.abrupt("return",t);case 12:case"end":return r.stop()}},i,this)}),t.prototype.getOperations=function(){return regeneratorRuntime.mark(function t(){var e;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getOperation(["u1",0]);case 2:return e=t.sent,t.abrupt("return",e.uid);case 4:case"end":return t.stop()}},t,this)})},t}(),e=function(){function e(t){_classCallCheck(this,e),this.namespace=t,this.ready=new Promise(function(e,r){var n=indexedDB.open(t);n.onerror=function(){r("Couldn't open the IndexedDB database!")},n.onsuccess=function(t){e(t.target.result)},n.onupgradeneeded=function(t){var e=t.target.result;e.createObjectStore("OperationBuffer",{keyPath:"uid"}),e.createObjectStore("StateVector",{keyPath:"user"})}})["catch"](function(t){throw new Error(t)})}return e.prototype.requestTransaction=function(e){this.ready.then(function(r){function n(t){var e=t.value;t.done||(e.constructor===IDBRequest?(e.onsuccess=function(){n(i.next(e.result))},e.onerror=function(t){i["throw"](t)}):i["throw"]("You may not yield this type!"))}var o=new t(r.transaction(["OperationBuffer","StateVector"],"readwrite")),i=e.apply(o);return n(i.next())})},e}();return e}(),OperationBuffer=function t(){_classCallCheck(this,t),this.i=4},Operation=function(){function t(e){_classCallCheck(this,t),this.i=e.i}return t.prototype.yay=function(){return this.i},t}();
//# sourceMappingURL=y.js.map