diff --git a/.eslintrc b/.eslintrc index 556740f4..fdd4aef0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,6 +9,7 @@ "parser": "babel-eslint", "globals": { "OperationBuffer": true, - "IndexedDB": true + "IndexedDB": true, + "IDBRequest": true } } diff --git a/src/IndexedDB.js b/src/IndexedDB.js index 6283b98f..62fa4cca 100644 --- a/src/IndexedDB.js +++ b/src/IndexedDB.js @@ -1,32 +1,46 @@ +type State = { + user: string, + clock: number +}; + +type StateVector = Array; + +type StateSet = Object; + var IndexedDB = (function(){ //eslint-disable-line no-unused-vars - var GeneratorFunction = (function*(){}).constructor; - class Transaction { + constructor (transaction) { this.transaction = transaction; + this.sv = transaction.objectStore("StateVector"); + this.ob = transaction.objectStore("OperationBuffer"); } - setOperation (op) { - return new Promise((resolve, reject)=> { - var req = this.transaction.objectStore("OperationBuffer").put(op); - req.onsuccess = function () { - resolve(op); - }; - req.onerror = function () { - reject("Could not set Operation!"); - }; - }); + *setOperation (op) { + yield this.ob.put(op); + return op; } - getOperation (uid) { - return new Promise((resolve, reject)=>{ - var req = this.transaction.objectStore("OperationBuffer").get(uid); - req.onsuccess = function () { - resolve(req.result); - }; - req.onerror = function () { - reject("Could not get Operation"); - }; - }); + *getOperation (uid) { + return yield this.ob.get(uid); + } + *setState (state : State) : State { + return yield this.sv.put(state); + } + *getState (user : string) : State { + return (yield this.sv.get(user)) || { + user: user, + clock: 0 + }; + } + *getStateVector () : StateVector { + var stateVector = []; + var cursor = yield this.sv.openCursor(); + while ((cursor = yield cursor.continue) != null) { + stateVector.push(cursor.value); + } + return stateVector; + } + *getStateSet () : StateSet { } getOperations () { return function* () { @@ -86,22 +100,23 @@ var IndexedDB = (function(){ //eslint-disable-line no-unused-vars this.ready.then(function(db){ var transaction = new Transaction(db.transaction(["OperationBuffer", "StateVector"], "readwrite")); var gen = makeGen.apply(transaction); - function handle(result : Object){ - var v = result.value; - if (result.done) { - return v; - } else if (v.constructor === Promise) { - return result.value.then(function(res){ - return handle(gen.next(res)); - }, function(err){ - return handle(gen.throw(err)); - }); - } else if (v.constructor === GeneratorFunction){ - return handle(v.apply(transaction).next()); + + function handle(res){ + var request = res.value; + if (res.done){ + return; + } else if (request.constructor === IDBRequest) { + request.onsuccess = function(){ + handle(gen.next(request.result)); + }; + request.onerror = function(err){ + gen.throw(err); + }; } else { - throw new Error("I do only accept Promises and Generators!"); + gen.throw("You may not yield this type!"); } } + return handle(gen.next()); }); } diff --git a/src/IndexedDB.spec.js b/src/IndexedDB.spec.js index 279a24de..f99c9527 100644 --- a/src/IndexedDB.spec.js +++ b/src/IndexedDB.spec.js @@ -7,23 +7,35 @@ if(typeof window !== "undefined"){ it("can create transactions", function(done) { ob.requestTransaction(function*(){ - var op = yield this.setOperation({ + var op = yield* this.setOperation({ "uid": ["u1", 0], "stuff": true }); - expect(yield this.getOperation(["u1", 0])) + expect(yield* this.getOperation(["u1", 0])) .toEqual(op); done(); }); }); - it("receive remaining operations", function(done){ + it("getOperation(op) returns undefined if op does not exist", function(done){ ob.requestTransaction(function*(){ - expect(yield this.getOperations(["u1", 0])) - .toEqual({ - "uid": ["u1", 0], - "stuff": true - }); + var op = yield* this.getOperation("plzDon'tBeThere"); + expect(op).toBeUndefined(); + done(); + }); + }); + + it("yield throws if request is unknown", function(done){ + + ob.requestTransaction(function*(){ + try { + yield this.getOperations(["u1", 0]); + } catch (e) { + expect(true).toEqual(true); + done(); + return; + } + expect("Expected an Error!").toEqual(true); done(); }); }); diff --git a/y.js b/y.js index 922f7c44..9e043b44 100644 --- a/y.js +++ b/y.js @@ -1,2 +1,2 @@ -"use strict";function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}!function(t){function r(t,r,e,o){var i=Object.create((r||n).prototype);return i._invoke=s(t,e||null,new h(o||[])),i}function e(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(n){return{type:"throw",arg:n}}}function n(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function c(t){this.arg=t}function u(t){function r(r,e){var n=t[r](e),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 e(t,e){var o=n?n.then(function(){return r(t,e)}):new Promise(function(n){n(r(t,e))});return n=o["catch"](a),o}"object"==typeof process&&process.domain&&(r=process.domain.bind(r));var n,o=r.bind(t,"next"),i=r.bind(t,"throw"),a=r.bind(t,"return");this._invoke=e}function s(t,r,n){var o=x;return function(i,a){if(o===L)throw new Error("Generator is already running");if(o===E)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=e(u,c.iterator,a);if("throw"===s.type){i="throw",a=s.arg;continue}}if("return"===i)continue}var s=e(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=E,a;n.dispatchException(a)&&(i="next",a=v)}else"return"===i&&n.abrupt("return",a);o=L;var s=e(t,r,n);if("normal"===s.type){o=n.done?E:b;var f={value:s.arg,done:n.done};if(s.arg!==O)return f;n.delegate&&"next"===i&&(a=v)}else"throw"===s.type&&(o=E,i="throw",a=s.arg)}}}function f(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function l(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset()}function p(t){if(t){var r=t[g];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function o(){for(;++er;++r)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],r=t.completion;if("throw"===r.type)throw r.arg;return this.rval},dispatchException:function(t){function r(r,n){return i.type="throw",i.arg=t,e.next=r,!!n}if(this.done)throw t;for(var e=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=d.call(o,"catchLoc"),c=d.call(o,"finallyLoc");if(a&&c){if(this.prev=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&d.call(n,"finallyLoc")&&this.prev=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),l(e),O}},"catch":function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;l(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:p(t),resultName:r,nextLoc:e},O}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:void 0);var IndexedDB=function(){var t=regeneratorRuntime.mark(function n(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}},n,this)}).constructor,r=function(){function t(r){_classCallCheck(this,t),this.transaction=r}return t.prototype.setOperation=function(t){var r=this;return new Promise(function(e,n){var o=r.transaction.objectStore("OperationBuffer").put(t);o.onsuccess=function(){e(t)},o.onerror=function(){n("Could not set Operation!")}})},t.prototype.getOperation=function(t){var r=this;return new Promise(function(e,n){var o=r.transaction.objectStore("OperationBuffer").get(t);o.onsuccess=function(){e(o.result)},o.onerror=function(){n("Could not get Operation")}})},t.prototype.getOperations=function(){this.transaction.objectStore("OperationBuffer");return regeneratorRuntime.mark(function t(){var r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getOperation(["u1",0]);case 2:return r=t.sent,t.abrupt("return",r.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(r,e){var n=indexedDB.open(t);n.onerror=function(){e("Couldn't open the IndexedDB database!")},n.onsuccess=function(t){r(t.target.result)},n.onupgradeneeded=function(t){var r=t.target.result;r.createObjectStore("OperationBuffer",{keyPath:"uid"}),r.createObjectStore("StateVector",{keyPath:"user"})}})["catch"](function(t){throw new Error(t)})}return e.prototype.requestTransaction=function(e){this.ready.then(function(n){function o(r){for(var e=!0;e;){var n=r;c=void 0,e=!1;var c=n.value;if(n.done)return c;if(c.constructor===Promise)return n.value.then(function(t){return o(a.next(t))},function(t){return o(a["throw"](t))});if(c.constructor!==t)throw new Error("I do only accept Promises and Generators!");r=c.apply(i).next(),e=!0}}var i=new r(n.transaction(["OperationBuffer","StateVector"],"readwrite")),a=e.apply(i);return o(a.next())})},e}();return e}(),OperationBuffer=function t(){_classCallCheck(this,t),this.i=4},Operation=function(){function t(r){_classCallCheck(this,t),this.i=r.i}return t.prototype.yay=function(){return this.i},t}(); +"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(;++re;++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=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&d.call(n,"finallyLoc")&&this.prev=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 \ No newline at end of file diff --git a/y.js.map b/y.js.map index 6a9dd9d0..03e8554b 100644 --- a/y.js.map +++ b/y.js.map @@ -1 +1 @@ -{"version":3,"sources":["y.js","runtime.js","IndexedDB.js","OperationBuffer.js","Operations.js"],"names":["_classCallCheck","instance","Constructor","TypeError","global","wrap","innerFn","outerFn","self","tryLocsList","generator","Object","create","Generator","prototype","_invoke","makeInvokeMethod","Context","tryCatch","fn","obj","arg","type","call","err","GeneratorFunction","GeneratorFunctionPrototype","defineIteratorMethods","forEach","method","this","AwaitArgument","AsyncIterator","invoke","result","value","Promise","resolve","then","invokeNext","invokeThrow","unwrapped","enqueue","enqueueResult","previousPromise","invokeReturn","process","domain","bind","context","state","GenStateSuspendedStart","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","iterator","undefined","returnMethod","record","info","done","GenStateSuspendedYield","resultName","next","nextLoc","sent","dispatchException","abrupt","ContinueSentinel","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","values","iterable","iteratorMethod","iteratorSymbol","isNaN","length","i","hasOwn","hasOwnProperty","Symbol","inModule","module","runtime","regeneratorRuntime","exports","Gp","constructor","displayName","isGeneratorFunction","genFun","ctor","name","mark","__proto__","awrap","async","iter","toString","keys","object","key","reverse","pop","prev","tempName","tempIndex","stop","rootEntry","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","window","IndexedDB","callee$1$0","context$2$0","Transaction","transaction","setOperation","op","_this","reject","req","objectStore","put","onsuccess","onerror","getOperation","uid","_this2","get","getOperations","callee$3$0","context$4$0","DB","namespace","ready","yay","nay","indexedDB","open","event","target","onupgradeneeded","db","createObjectStore","keyPath","message","requestTransaction","makeGen","_x","_again","v","res","gen","apply","OperationBuffer","Operation"],"mappings":"AAUA,YAEA,SAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,sCCFhH,SAAAC,GAyBA,QAAAC,GAAAC,EAAAC,EAAAC,EAAAC,GAEA,GAAAC,GAAAC,OAAAC,QAAAL,GAAAM,GAAAC,UAOA,OALAJ,GAAAK,QAAAC,EACAV,EAAAE,GAAA,KACA,GAAAS,GAAAR,QAGAC,EAcA,QAAAQ,GAAAC,EAAAC,EAAAC,GACA,IACA,OAAAC,KAAA,SAAAD,IAAAF,EAAAI,KAAAH,EAAAC,IACA,MAAAG,GACA,OAAAF,KAAA,QAAAD,IAAAG,IAiBA,QAAAX,MACA,QAAAY,MACA,QAAAC,MASA,QAAAC,GAAAb,IACA,OAAA,QAAA,UAAAc,QAAA,SAAAC,GACAf,EAAAe,GAAA,SAAAR,GACA,MAAAS,MAAAf,QAAAc,EAAAR,MA8BA,QAAAU,GAAAV,GACAS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A,GAEAtC,GJmwBI9I,gBAAgB8B,KIrwBpBsJ,GAGAtJ,KAAA2D,EAAAqD,EAAArD,EJ2wBE,MI9wBF2F,GAAAtK,UAKAkJ,IAAA,WACA,MAAAlI,MAAA2D,GANA2F","file":"y.js","sourcesContent":[null,"/**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * https://raw.github.com/facebook/regenerator/master/LICENSE file. An\n * additional grant of patent rights can be found in the PATENTS file in\n * the same directory.\n */\n\n!(function(global) {\n \"use strict\";\n\n var hasOwn = Object.prototype.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var iteratorSymbol =\n typeof Symbol === \"function\" && Symbol.iterator || \"@@iterator\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided, then outerFn.prototype instanceof Generator.\n var generator = Object.create((outerFn || Generator).prototype);\n\n generator._invoke = makeInvokeMethod(\n innerFn, self || null,\n new Context(tryLocsList || [])\n );\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n genFun.__proto__ = GeneratorFunctionPrototype;\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `value instanceof AwaitArgument` to determine if the yielded value is\n // meant to be awaited. Some may consider the name of this method too\n // cutesy, but they are curmudgeons.\n runtime.awrap = function(arg) {\n return new AwaitArgument(arg);\n };\n\n function AwaitArgument(arg) {\n this.arg = arg;\n }\n\n function AsyncIterator(generator) {\n // This invoke function is written in a style that assumes some\n // calling function (or Promise) will handle exceptions.\n function invoke(method, arg) {\n var result = generator[method](arg);\n var value = result.value;\n return value instanceof AwaitArgument\n ? Promise.resolve(value.arg).then(invokeNext, invokeThrow)\n : Promise.resolve(value).then(function(unwrapped) {\n result.value = unwrapped;\n return result;\n }, invokeThrow);\n }\n\n if (typeof process === \"object\" && process.domain) {\n invoke = process.domain.bind(invoke);\n }\n\n var invokeNext = invoke.bind(generator, \"next\");\n var invokeThrow = invoke.bind(generator, \"throw\");\n var invokeReturn = invoke.bind(generator, \"return\");\n var previousPromise;\n\n function enqueue(method, arg) {\n var enqueueResult =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(function() {\n return invoke(method, arg);\n }) : new Promise(function(resolve) {\n resolve(invoke(method, arg));\n });\n\n // Avoid propagating enqueueResult failures to Promises returned by\n // later invocations of the iterator, and call generator.return() to\n // allow the generator a chance to clean up.\n previousPromise = enqueueResult[\"catch\"](invokeReturn);\n\n return enqueueResult;\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n if (method === \"return\" ||\n (method === \"throw\" && delegate.iterator[method] === undefined)) {\n // A return or throw (when the delegate iterator has no throw\n // method) always terminates the yield* loop.\n context.delegate = null;\n\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n var returnMethod = delegate.iterator[\"return\"];\n if (returnMethod) {\n var record = tryCatch(returnMethod, delegate.iterator, arg);\n if (record.type === \"throw\") {\n // If the return method threw an exception, let that\n // exception prevail over the original return or throw.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n }\n\n if (method === \"return\") {\n // Continue with the outer return, now that the delegate\n // iterator has been terminated.\n continue;\n }\n }\n\n var record = tryCatch(\n delegate.iterator[method],\n delegate.iterator,\n arg\n );\n\n if (record.type === \"throw\") {\n context.delegate = null;\n\n // Like returning generator.throw(uncaught), but without the\n // overhead of an extra function call.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n\n // Delegate generator ran and handled its own exceptions so\n // regardless of what the method was, we continue as if it is\n // \"next\" with an undefined arg.\n method = \"next\";\n arg = undefined;\n\n var info = record.arg;\n if (info.done) {\n context[delegate.resultName] = info.value;\n context.next = delegate.nextLoc;\n } else {\n state = GenStateSuspendedYield;\n return info;\n }\n\n context.delegate = null;\n }\n\n if (method === \"next\") {\n if (state === GenStateSuspendedYield) {\n context.sent = arg;\n } else {\n delete context.sent;\n }\n\n } else if (method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw arg;\n }\n\n if (context.dispatchException(arg)) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n method = \"next\";\n arg = undefined;\n }\n\n } else if (method === \"return\") {\n context.abrupt(\"return\", arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n var info = {\n value: record.arg,\n done: context.done\n };\n\n if (record.arg === ContinueSentinel) {\n if (context.delegate && method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n arg = undefined;\n }\n } else {\n return info;\n }\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(arg) call above.\n method = \"throw\";\n arg = record.arg;\n }\n }\n };\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset();\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function() {\n this.prev = 0;\n this.next = 0;\n this.sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.tryEntries.forEach(resetTryEntry);\n\n // Pre-initialize at least 20 temporary variables to enable hidden\n // class optimizations for simple generators.\n for (var tempIndex = 0, tempName;\n hasOwn.call(this, tempName = \"t\" + tempIndex) || tempIndex < 20;\n ++tempIndex) {\n this[tempName] = null;\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n return !!caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.next = finallyEntry.finallyLoc;\n } else {\n this.complete(record);\n }\n\n return ContinueSentinel;\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = record.arg;\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n return ContinueSentinel;\n }\n };\n})(\n // Among the various tricks for obtaining a reference to the global\n // object, this seems to be the most reliable technique that does not\n // use indirect eval (which violates Content Security Policy).\n typeof global === \"object\" ? global :\n typeof window === \"object\" ? window :\n typeof self === \"object\" ? self : this\n);\n","\nvar IndexedDB = (function(){ //eslint-disable-line no-unused-vars\n var GeneratorFunction = (function*(){}).constructor;\n\n class Transaction {\n constructor (transaction) {\n this.transaction = transaction;\n }\n setOperation (op) {\n return new Promise((resolve, reject)=> {\n var req = this.transaction.objectStore(\"OperationBuffer\").put(op);\n req.onsuccess = function () {\n resolve(op);\n };\n req.onerror = function () {\n reject(\"Could not set Operation!\");\n };\n });\n }\n getOperation (uid) {\n return new Promise((resolve, reject)=>{\n var req = this.transaction.objectStore(\"OperationBuffer\").get(uid);\n req.onsuccess = function () {\n resolve(req.result);\n };\n req.onerror = function () {\n reject(\"Could not get Operation\");\n };\n });\n }\n getOperations () {\n var ops = [];\n var ob = this.transaction.objectStore(\"OperationBuffer\");\n\n return function* () {\n var op = yield this.getOperation([\"u1\",0]);\n return op.uid;\n };\n }\n /*\n getOperations: (state_map)->\n flow = Promise.resolve()\n ops = []\n that = this\n hb = that.t.objectStore(\"HistoryBuffer\")\n\n that.getStateVector().then (end_state_vector)->\n for end_state of end_state_vector\n # convert to the db-structure\n do (end_state = end_state)->\n start_state =\n user: end_state.name\n state: state_map[end_state] ? 0\n\n flow = flow.then ()->\n from = [start_state.user, start_state.number]\n to = [end_state.user, end_state.number]\n cursor = event.target.result\n if cursor?\n ops.push cursor.value # add Operation\n cursor.continue()\n else\n # got all ops from this user\n defer.resolve ops\n defer.promise\n */\n }\n class DB {\n constructor (namespace : string) {\n this.namespace = namespace;\n this.ready = new Promise(function(yay, nay){\n var req = indexedDB.open(namespace); //eslint-disable-line no-undef\n req.onerror = function(){\n nay(\"Couldn't open the IndexedDB database!\");\n };\n req.onsuccess = function(event){\n yay(event.target.result);\n };\n req.onupgradeneeded = function(event){\n var db = event.target.result;\n db.createObjectStore(\"OperationBuffer\", {keyPath: \"uid\"});\n db.createObjectStore(\"StateVector\", {keyPath: \"user\"});\n };\n }).catch(function(message){\n throw new Error(message);\n });\n }\n requestTransaction (makeGen : Function) {\n this.ready.then(function(db){\n var transaction = new Transaction(db.transaction([\"OperationBuffer\", \"StateVector\"], \"readwrite\"));\n var gen = makeGen.apply(transaction);\n function handle(result : Object){\n var v = result.value\n if (result.done) {\n return v;\n } else if (v.constructor === Promise) {\n return result.value.then(function(res){\n return handle(gen.next(res));\n }, function(err){\n return handle(gen.throw(err));\n });\n } else if (v.constructor === GeneratorFunction){\n return handle(v.apply(transaction).next());\n } else {\n throw new Error(\"I do only accept Promises and Generators!\")\n }\n }\n return handle(gen.next());\n });\n }\n }\n return DB;\n})();\n","/* @flow */\n\nclass OperationBuffer { //eslint-disable-line no-unused-vars\n i : number;\n constructor () {\n this.i = 4;\n }\n}\n","/* @flow */\n\nclass Operation { //eslint-disable-line no-unused-vars\n i : number;\n constructor (op) {\n this.i = op.i;\n }\n yay () {\n return this.i;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["y.js","runtime.js","IndexedDB.js","OperationBuffer.js","Operations.js"],"names":["_classCallCheck","instance","Constructor","TypeError","global","wrap","innerFn","outerFn","self","tryLocsList","generator","Object","create","Generator","prototype","_invoke","makeInvokeMethod","Context","tryCatch","fn","obj","arg","type","call","err","GeneratorFunction","GeneratorFunctionPrototype","defineIteratorMethods","forEach","method","this","AwaitArgument","AsyncIterator","invoke","result","value","Promise","resolve","then","invokeNext","invokeThrow","unwrapped","enqueue","enqueueResult","previousPromise","invokeReturn","process","domain","bind","context","state","GenStateSuspendedStart","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","iterator","undefined","returnMethod","record","info","done","GenStateSuspendedYield","resultName","next","nextLoc","sent","dispatchException","abrupt","ContinueSentinel","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","values","iterable","iteratorMethod","iteratorSymbol","isNaN","length","i","hasOwn","hasOwnProperty","Symbol","inModule","module","runtime","regeneratorRuntime","exports","Gp","constructor","displayName","isGeneratorFunction","genFun","ctor","name","mark","__proto__","awrap","async","iter","toString","keys","object","key","reverse","pop","prev","tempName","tempIndex","stop","rootEntry","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","window","IndexedDB","Transaction","transaction","sv","objectStore","ob","setOperation","op","context$3$0","put","getOperation","uid","get","setState","getState","user","t0","clock","getStateVector","stateVector","cursor","openCursor","getOperations","callee$3$0","context$4$0","DB","namespace","ready","yay","nay","req","indexedDB","open","onerror","onsuccess","event","target","onupgradeneeded","db","createObjectStore","keyPath","message","requestTransaction","makeGen","res","request","IDBRequest","gen","apply","OperationBuffer","Operation"],"mappings":"AAUA,YAEA,SAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,sCCFhH,SAAAC,GAyBA,QAAAC,GAAAC,EAAAC,EAAAC,EAAAC,GAEA,GAAAC,GAAAC,OAAAC,QAAAL,GAAAM,GAAAC,UAOA,OALAJ,GAAAK,QAAAC,EACAV,EAAAE,GAAA,KACA,GAAAS,GAAAR,QAGAC,EAcA,QAAAQ,GAAAC,EAAAC,EAAAC,GACA,IACA,OAAAC,KAAA,SAAAD,IAAAF,EAAAI,KAAAH,EAAAC,IACA,MAAAG,GACA,OAAAF,KAAA,QAAAD,IAAAG,IAiBA,QAAAX,MACA,QAAAY,MACA,QAAAC,MASA,QAA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,GAAA7C,GAAA,GAAAD,GAAAqC,EAAApC,aAAA,kBAAA,eAAA,cACA6C,EAAAJ,EAAAK,MAAA9C,EAkBA,OAAAd,GAAA2D,EAAAtH,WAzCAgG,IA6CA,OAAAA,MCvHAwB,gBAEA,QAFAA,KHg0BEzL,gBAAgB8B,KGh0BlB2J,GAGA3J,KAAA2D,EAAA,GCHAiG,UAAA,WAEA,QAFAA,GAEA3C,GJu0BI/I,gBAAgB8B,KIz0BpB4J,GAGA5J,KAAA2D,EAAAsD,EAAAtD,EJ+0BE,MIl1BFiG,GAAA5K,UAKAsJ,IAAA,WACA,MAAAtI,MAAA2D,GANAiG","file":"y.js","sourcesContent":[null,"/**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * https://raw.github.com/facebook/regenerator/master/LICENSE file. An\n * additional grant of patent rights can be found in the PATENTS file in\n * the same directory.\n */\n\n!(function(global) {\n \"use strict\";\n\n var hasOwn = Object.prototype.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var iteratorSymbol =\n typeof Symbol === \"function\" && Symbol.iterator || \"@@iterator\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided, then outerFn.prototype instanceof Generator.\n var generator = Object.create((outerFn || Generator).prototype);\n\n generator._invoke = makeInvokeMethod(\n innerFn, self || null,\n new Context(tryLocsList || [])\n );\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n genFun.__proto__ = GeneratorFunctionPrototype;\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `value instanceof AwaitArgument` to determine if the yielded value is\n // meant to be awaited. Some may consider the name of this method too\n // cutesy, but they are curmudgeons.\n runtime.awrap = function(arg) {\n return new AwaitArgument(arg);\n };\n\n function AwaitArgument(arg) {\n this.arg = arg;\n }\n\n function AsyncIterator(generator) {\n // This invoke function is written in a style that assumes some\n // calling function (or Promise) will handle exceptions.\n function invoke(method, arg) {\n var result = generator[method](arg);\n var value = result.value;\n return value instanceof AwaitArgument\n ? Promise.resolve(value.arg).then(invokeNext, invokeThrow)\n : Promise.resolve(value).then(function(unwrapped) {\n result.value = unwrapped;\n return result;\n }, invokeThrow);\n }\n\n if (typeof process === \"object\" && process.domain) {\n invoke = process.domain.bind(invoke);\n }\n\n var invokeNext = invoke.bind(generator, \"next\");\n var invokeThrow = invoke.bind(generator, \"throw\");\n var invokeReturn = invoke.bind(generator, \"return\");\n var previousPromise;\n\n function enqueue(method, arg) {\n var enqueueResult =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(function() {\n return invoke(method, arg);\n }) : new Promise(function(resolve) {\n resolve(invoke(method, arg));\n });\n\n // Avoid propagating enqueueResult failures to Promises returned by\n // later invocations of the iterator, and call generator.return() to\n // allow the generator a chance to clean up.\n previousPromise = enqueueResult[\"catch\"](invokeReturn);\n\n return enqueueResult;\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n if (method === \"return\" ||\n (method === \"throw\" && delegate.iterator[method] === undefined)) {\n // A return or throw (when the delegate iterator has no throw\n // method) always terminates the yield* loop.\n context.delegate = null;\n\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n var returnMethod = delegate.iterator[\"return\"];\n if (returnMethod) {\n var record = tryCatch(returnMethod, delegate.iterator, arg);\n if (record.type === \"throw\") {\n // If the return method threw an exception, let that\n // exception prevail over the original return or throw.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n }\n\n if (method === \"return\") {\n // Continue with the outer return, now that the delegate\n // iterator has been terminated.\n continue;\n }\n }\n\n var record = tryCatch(\n delegate.iterator[method],\n delegate.iterator,\n arg\n );\n\n if (record.type === \"throw\") {\n context.delegate = null;\n\n // Like returning generator.throw(uncaught), but without the\n // overhead of an extra function call.\n method = \"throw\";\n arg = record.arg;\n continue;\n }\n\n // Delegate generator ran and handled its own exceptions so\n // regardless of what the method was, we continue as if it is\n // \"next\" with an undefined arg.\n method = \"next\";\n arg = undefined;\n\n var info = record.arg;\n if (info.done) {\n context[delegate.resultName] = info.value;\n context.next = delegate.nextLoc;\n } else {\n state = GenStateSuspendedYield;\n return info;\n }\n\n context.delegate = null;\n }\n\n if (method === \"next\") {\n if (state === GenStateSuspendedYield) {\n context.sent = arg;\n } else {\n delete context.sent;\n }\n\n } else if (method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw arg;\n }\n\n if (context.dispatchException(arg)) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n method = \"next\";\n arg = undefined;\n }\n\n } else if (method === \"return\") {\n context.abrupt(\"return\", arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n var info = {\n value: record.arg,\n done: context.done\n };\n\n if (record.arg === ContinueSentinel) {\n if (context.delegate && method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n arg = undefined;\n }\n } else {\n return info;\n }\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(arg) call above.\n method = \"throw\";\n arg = record.arg;\n }\n }\n };\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset();\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function() {\n this.prev = 0;\n this.next = 0;\n this.sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.tryEntries.forEach(resetTryEntry);\n\n // Pre-initialize at least 20 temporary variables to enable hidden\n // class optimizations for simple generators.\n for (var tempIndex = 0, tempName;\n hasOwn.call(this, tempName = \"t\" + tempIndex) || tempIndex < 20;\n ++tempIndex) {\n this[tempName] = null;\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n return !!caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.next = finallyEntry.finallyLoc;\n } else {\n this.complete(record);\n }\n\n return ContinueSentinel;\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = record.arg;\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n return ContinueSentinel;\n }\n };\n})(\n // Among the various tricks for obtaining a reference to the global\n // object, this seems to be the most reliable technique that does not\n // use indirect eval (which violates Content Security Policy).\n typeof global === \"object\" ? global :\n typeof window === \"object\" ? window :\n typeof self === \"object\" ? self : this\n);\n","\ntype State = {\n user: string,\n clock: number\n};\n\ntype StateVector = Array;\n\ntype StateSet = Object;\n\nvar IndexedDB = (function(){ //eslint-disable-line no-unused-vars\n class Transaction {\n\n constructor (transaction) {\n this.transaction = transaction;\n this.sv = transaction.objectStore(\"StateVector\");\n this.ob = transaction.objectStore(\"OperationBuffer\");\n }\n *setOperation (op) {\n yield this.ob.put(op);\n return op;\n }\n *getOperation (uid) {\n return yield this.ob.get(uid);\n }\n *setState (state : State) : State {\n return yield this.sv.put(state);\n }\n *getState (user : string) : State {\n return (yield this.sv.get(user)) || {\n user: user,\n clock: 0\n };\n }\n *getStateVector () : StateVector {\n var stateVector = [];\n var cursor = yield this.sv.openCursor();\n while ((cursor = yield cursor.continue) != null) {\n stateVector.push(cursor.value);\n }\n return stateVector;\n }\n getOperations () {\n return function* () {\n var op = yield this.getOperation([\"u1\", 0]);\n return op.uid;\n };\n }\n /*\n getOperations: (state_map)->\n flow = Promise.resolve()\n ops = []\n that = this\n hb = that.t.objectStore(\"HistoryBuffer\")\n\n that.getStateVector().then (end_state_vector)->\n for end_state of end_state_vector\n # convert to the db-structure\n do (end_state = end_state)->\n start_state =\n user: end_state.name\n state: state_map[end_state] ? 0\n\n flow = flow.then ()->\n from = [start_state.user, start_state.number]\n to = [end_state.user, end_state.number]\n cursor = event.target.result\n if cursor?\n ops.push cursor.value # add Operation\n cursor.continue()\n else\n # got all ops from this user\n defer.resolve ops\n defer.promise\n */\n }\n class DB {\n constructor (namespace : string) {\n this.namespace = namespace;\n this.ready = new Promise(function(yay, nay){\n var req = indexedDB.open(namespace); //eslint-disable-line no-undef\n req.onerror = function(){\n nay(\"Couldn't open the IndexedDB database!\");\n };\n req.onsuccess = function(event){\n yay(event.target.result);\n };\n req.onupgradeneeded = function(event){\n var db = event.target.result;\n db.createObjectStore(\"OperationBuffer\", {keyPath: \"uid\"});\n db.createObjectStore(\"StateVector\", {keyPath: \"user\"});\n };\n }).catch(function(message){\n throw new Error(message);\n });\n }\n requestTransaction (makeGen : Function) {\n this.ready.then(function(db){\n var transaction = new Transaction(db.transaction([\"OperationBuffer\", \"StateVector\"], \"readwrite\"));\n var gen = makeGen.apply(transaction);\n\n function handle(res){\n var request = res.value;\n if (res.done){\n return;\n } else if (request.constructor === IDBRequest) {\n request.onsuccess = function(){\n handle(gen.next(request.result));\n };\n request.onerror = function(err){\n gen.throw(err);\n };\n } else {\n gen.throw(\"You may not yield this type!\");\n }\n }\n\n return handle(gen.next());\n });\n }\n }\n return DB;\n})();\n","/* @flow */\n\nclass OperationBuffer { //eslint-disable-line no-unused-vars\n i : number;\n constructor () {\n this.i = 4;\n }\n}\n","/* @flow */\n\nclass Operation { //eslint-disable-line no-unused-vars\n i : number;\n constructor (op) {\n this.i = op.i;\n }\n yay () {\n return this.i;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file