yjs/y.js.map
2016-02-18 16:57:27 +01:00

1 line
389 KiB
Plaintext

{"version":3,"sources":["node_modules/browserify/node_modules/browser-pack/_prelude.js","node_modules/browserify/node_modules/process/browser.js","y.js","node_modules/regenerator/runtime.js","src/Connector.js","src/Connectors/Test.js","src/Database.js","src/Struct.js","src/Transaction.js","src/Utils.js","src/y.js"],"names":["e","t","n","r","s","o","u","a","require","i","f","Error","code","l","exports","call","length",1,"module","cleanUpNextTick","draining","currentQueue","queue","concat","queueIndex","drainQueue","timeout","setTimeout","len","run","clearTimeout","Item","fun","array","this","noop","process","nextTick","args","Array","arguments","push","prototype","apply","title","browser","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","binding","name","cwd","chdir","dir","umask",2,"global","_typeof","obj","Symbol","constructor","wrap","innerFn","outerFn","self","tryLocsList","generator","Object","create","Generator","context","Context","_invoke","makeInvokeMethod","tryCatch","fn","arg","type","err","GeneratorFunction","GeneratorFunctionPrototype","defineIteratorMethods","forEach","method","AwaitArgument","AsyncIterator","invoke","resolve","reject","record","result","value","Promise","then","unwrapped","enqueue","callInvokeWithMethodAndArg","previousPromise","domain","bind","state","GenStateSuspendedStart","GenStateExecuting","GenStateCompleted","doneResult","delegate","iterator","undefined","returnMethod","info","done","GenStateSuspendedYield","resultName","next","nextLoc","sent","dispatchException","abrupt","ContinueSentinel","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","values","iterable","iteratorMethod","iteratorSymbol","isNaN","hasOwn","hasOwnProperty","$Symbol","toStringTagSymbol","toStringTag","inModule","runtime","regeneratorRuntime","Gp","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","async","iter","toString","keys","object","key","reverse","pop","skipTempReset","prev","charAt","slice","stop","rootEntry","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","window","_process",3,"_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","descriptor","enumerable","configurable","writable","defineProperty","protoProps","staticProps","Y","AbstractConnector","y","opts","role","db","forwardAppliedOperations","connections","isSynced","userEventListeners","whenSyncedListeners","currentSyncTarget","syncingClients","forwardToSyncingClients","debug","broadcastedHB","syncStep2","broadcastOpBuffer","stopGarbageCollector","userId","setUserId","user","findNextSyncTarget","filter","cli","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_step","_iterator","action","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_step2","_iterator2","syncUser","uid","conn","requestTransaction","_callee","stateSet","deleteSet","_context","getStateSet","t0","getDeleteSet","t1","send","_iteratorNormalCompletion3","_didIteratorError3","_iteratorError3","_step3","_iterator3","_callee2","_context2","garbageCollectAfterSync","message","console","log","ops","broadcastOperations","broadcast","map","op","Struct","struct","encode","transactionInProgress","whenTransactionsFinished","sender","_this","JSON","parse","stringify","m","_callee3","currentStateSet","ds","_context3","applyDeleteSet","t2","getOperations","t3","os","_setSyncedWith","broadcastHB","defer","promise","_callee5","_context5","store","_callee4","_context4","broadcastOps","_iteratorNormalCompletion4","_didIteratorError4","_iteratorError4","_step4","_iterator4","client","delops","parseArray","node","_iteratorNormalCompletion5","_didIteratorError5","_iteratorError5","_step5","_iterator5","children","getAttribute","parseObject","json","attrName","attrs","int","parseInt","msg","encodeObject","c","encodeArray","setAttribute","_iteratorNormalCompletion6","_didIteratorError6","_iteratorError6","_step6","_iterator6","xmlns",4,"_possibleConstructorReturn","ReferenceError","_inherits","subClass","superClass","_get","get","property","receiver","Function","desc","getOwnPropertyDescriptor","parent","getPrototypeOf","getter","globalRoom","users","buffers","removeUser","userLeft","addUser","connector","uname","userJoined","ps","all","flushOne","bufs","getRandom","shift","receiveMessage","flushAll","nextFlush","utils","userIdCounter","Test","_Y$AbstractConnector","options","syncingClientDuration","buffer","isDisconnected",5,"AbstractDatabase","garbageCollect","gc1","gc2","oid","garbageCollectOperation","gcTimeout","gcInterval","userIdPromise","listenersById","listenersByIdExecuteNow","listenersByIdRequestPending","initializedTypes","waitingTransactions","transactionIsFlushed","YConcurrency_TestingMode","executeOrder","command","join","replace","ungc","getOperation","gc","setOperation","left","deleted","id","compareIds","destroy","clearInterval","_destroy","error","inProgress","getState","opClock","clock","_nextUserId","required","requiredOps","whenOperationsExist","ids","listener","missing","sid","exeNow","ls","tryExecute","defined","isGarbageCollected","_context6","addToDebug","Delete","execute","operationAdded","addOperation","transaction","opIsDeleted","delop","_context7","_changed","checkDeleteStoreForState","findNext","t4","setState","isDeleted","t6","copyObject","transactionsFinished","_context8","flush","makeGen","callImmediately","transact","getNextRequest",6,"deleteOperation","Insert","right","origin","parentSub","opContent","content","getDistanceToOrigin","d","distanceToOrigin","start","startId","oOriginDistance","originOf","t5","t7","t8","t9","t10","t11","t12","t14","removeFromGarbageCollector","end","List","ref","pos","res","operation","Map","getType",7,"TransactionInterface","initType","createType","typedefinition","structname","getNextOpId","applyCreatedOperations","deleteList","targetId","preventCallType","callType","markDeleted","addToGarbageCollector","markGarbageCollected","newlen","put","findPrev","diff","findWithUpperBound","_context9","iterate","neworigin","neworigin_","_i","originsIn","setParent","_context10","_id","removeOperation","_context11","Math","max","deletions","createDeletions","dv","del","_context13","Number","MAX_VALUE","_context12","min","_context14","_context16","counter","_context15","_context17","_context18","_context19","_context20","find","split","_context21","val","_context22","ss","_context23","getStateVector","stateVector","_context25","_context24","_context27","_context26","startSS","endSV","endState","startPos","_context29","_callee6","missing_origins","newright","_context28","_context30","Transaction",8,"smaller","b","id1","id2","createEmptyOpsArray","createSmallLookupBuffer","Store","SmallLookupBuffer","_Store","writeBuffer","readBuffer","write","_delete","findWithLowerBound","_args4","_args5","_args6","_args7","_args8","EventHandler","onevent","waiting","awaiting","eventListeners","g","event","splice","w","_tryCallEvents","newLeft","j","events","CustomType","def",9,"requestModules","modules","extention","promises","modulename","toLowerCase","requiringModules","imported","document","createElement","src","sourceDir","head","appendChild","requireModule","types","share","yconfig","YConfig","whenUserIdSet","init","extend","callback","propertyname","typename","disconnect","reconnect","./Connector.js","./Connectors/Test.js","./Database.js","./Struct.js","./Transaction.js","./Utils.js"],"mappings":"CAAA,QAAAA,GAAAC,EAAAC,EAAAC,GAAA,QAAAC,GAAAC,EAAAC,GAAA,IAAAJ,EAAAG,GAAA,CAAA,IAAAJ,EAAAI,GAAA,CAAA,GAAAE,GAAA,kBAAAC,UAAAA,OAAA,KAAAF,GAAAC,EAAA,MAAAA,GAAAF,GAAA,EAAA,IAAAI,EAAA,MAAAA,GAAAJ,GAAA,EAAA,IAAAK,GAAA,GAAAC,OAAA,uBAAAN,EAAA,IAAA,MAAAK,GAAAE,KAAA,mBAAAF,EAAA,GAAAG,GAAAX,EAAAG,IAAAS,WAAAb,GAAAI,GAAA,GAAAU,KAAAF,EAAAC,QAAA,SAAAd,GAAA,GAAAE,GAAAD,EAAAI,GAAA,GAAAL,EAAA,OAAAI,GAAAF,EAAAA,EAAAF,IAAAa,EAAAA,EAAAC,QAAAd,EAAAC,EAAAC,EAAAC,GAAA,MAAAD,GAAAG,GAAAS,QAAA,IAAA,GAAAL,GAAA,kBAAAD,UAAAA,QAAAH,EAAA,EAAAA,EAAAF,EAAAa,OAAAX,IAAAD,EAAAD,EAAAE,GAAA,OAAAD,KAAAa,GAAA,SAAAT,EAAAU,EAAAJ,GCQA,QAAAK,KACAC,GAAA,EACAC,EAAAL,OACAM,EAAAD,EAAAE,OAAAD,GAEAE,EAAA,GAEAF,EAAAN,QACAS,IAIA,QAAAA,KACA,IAAAL,EAAA,CAGA,GAAAM,GAAAC,WAAAR,EACAC,IAAA,CAGA,KADA,GAAAQ,GAAAN,EAAAN,OACAY,GAAA,CAGA,IAFAP,EAAAC,EACAA,OACAE,EAAAI,GACAP,GACAA,EAAAG,GAAAK,KAGAL,GAAA,GACAI,EAAAN,EAAAN,OAEAK,EAAA,KACAD,GAAA,EACAU,aAAAJ,IAiBA,QAAAK,GAAAC,EAAAC,GACAC,KAAAF,IAAAA,EACAE,KAAAD,MAAAA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,UACLlE,MAAO,WQv5KuB,MAA1BjE,KAAKkU,UAAUiD,QACjBnX,KAAKkU,UAAUiD,UAEfnX,KAAKkU,UAAUsQ,YAEjB,IAAIliB,GAAOtC,IACXA,MAAKiL,GAAGkC,mBAAkB/F,mBAAAM,KAAC,QAAA0F,KRy5KvB,MAAOhG,oBAAmBjF,KAAK,SAAkBgM,GAC/C,OACE,OAAQA,EAAU5F,KAAO4F,EAAU5I,MACjC,IAAK,GACH,MAAO4I,GAAU1E,cQ55KpBnH,EAAK2I,GAAGkM,UAAS,KAAA,ER85KhB,KAAK,GQ75Kb7U,EAAK4R,UAAY,KACjB5R,EAAK2I,GAAK,IRg6KF,KAAK,GACL,IAAK,MACH,MAAOkD,GAAUzF,SAGtB0E,EAASpN,aQz9KdikB,IAyDgB,oBAAXva,UACTA,OAAOkB,EAAIA,KR26KV8Z,iBAAiB,EAAEC,uBAAuB,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,aAAa,SAAS,EAAE","file":"y.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})","// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\n// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n},{}],2:[function(require,module,exports){\n(function (process,global){\n\"use strict\";\n\nfunction _typeof(obj) { return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; }\n\n/**\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 $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n var inModule = (typeof module === \"undefined\" ? \"undefined\" : _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 var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\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 GeneratorFunctionPrototype[toStringTagSymbol] = 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 ? 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\" : false;\n };\n\n runtime.mark = function (genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\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 function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value instanceof AwaitArgument) {\n return Promise.resolve(value.arg).then(function (value) {\n invoke(\"next\", value, resolve, reject);\n }, function (err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function (unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration. If the Promise is rejected, however, the\n // result for this iteration will be rejected with the same\n // reason. Note that rejections of yielded Promises are not\n // thrown back into the generator function, as is the case\n // when an awaited Promise is rejected. This difference in\n // behavior between yield and await is important, because it\n // allows the consumer to decide what to do with the yielded\n // rejection (swallow it and continue, manually .throw it back\n // into the generator, abandon iteration, whatever). With\n // await, by contrast, there is no opportunity to examine the\n // rejection reason outside the generator function, so the\n // only option is to throw it from the await expression, and\n // let the generator function handle the exception.\n result.value = unwrapped;\n resolve(result);\n }, reject);\n }\n }\n\n if ((typeof process === \"undefined\" ? \"undefined\" : _typeof(process)) === \"object\" && process.domain) {\n invoke = process.domain.bind(invoke);\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function (resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\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(callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();\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(wrap(innerFn, outerFn, self, tryLocsList));\n\n return runtime.isGeneratorFunction(outerFn) ? 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 if (method === \"throw\") {\n throw arg;\n }\n\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\" || 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(delegate.iterator[method], delegate.iterator, arg);\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 context.sent = undefined;\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 } 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 ? GenStateCompleted : 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 } 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[toStringTagSymbol] = \"Generator\";\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(true);\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,\n 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 reset(skipTempReset) {\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 if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function stop() {\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 dispatchException(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 } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function abrupt(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 && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry && (type === \"break\" || type === \"continue\") && finallyEntry.tryLoc <= arg && 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 complete(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" || 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 finish(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 _catch(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 delegateYield(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 === \"undefined\" ? \"undefined\" : _typeof(global)) === \"object\" ? global : (typeof window === \"undefined\" ? \"undefined\" : _typeof(window)) === \"object\" ? window : (typeof self === \"undefined\" ? \"undefined\" : _typeof(self)) === \"object\" ? self : undefined);\n\n}).call(this,require('_process'),typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n\n},{\"_process\":1}],3:[function(require,module,exports){\n/* @flow */\n'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nmodule.exports = function (Y /* :any */) {\n var AbstractConnector = (function () {\n /* ::\n y: YConfig;\n role: SyncRole;\n connections: Object;\n isSynced: boolean;\n userEventListeners: Array<Function>;\n whenSyncedListeners: Array<Function>;\n currentSyncTarget: ?UserId;\n syncingClients: Array<UserId>;\n forwardToSyncingClients: boolean;\n debug: boolean;\n broadcastedHB: boolean;\n syncStep2: Promise;\n userId: UserId;\n send: Function;\n broadcast: Function;\n */\n /*\n opts contains the following information:\n role : String Role of this client (\"master\" or \"slave\")\n userId : String Uniquely defines the user.\n debug: Boolean Whether to print debug messages (optional)\n */\n\n function AbstractConnector(y, opts) {\n _classCallCheck(this, AbstractConnector);\n\n this.y = y;\n if (opts == null) {\n opts = {};\n }\n if (opts.role == null || opts.role === 'master') {\n this.role = 'master';\n } else if (opts.role === 'slave') {\n this.role = 'slave';\n } else {\n throw new Error(\"Role must be either 'master' or 'slave'!\");\n }\n this.y.db.forwardAppliedOperations = opts.forwardAppliedOperations || false;\n this.role = opts.role;\n this.connections = {};\n this.isSynced = false;\n this.userEventListeners = [];\n this.whenSyncedListeners = [];\n this.currentSyncTarget = null;\n this.syncingClients = [];\n this.forwardToSyncingClients = opts.forwardToSyncingClients !== false;\n this.debug = opts.debug === true;\n this.broadcastedHB = false;\n this.syncStep2 = Promise.resolve();\n this.broadcastOpBuffer = [];\n }\n\n _createClass(AbstractConnector, [{\n key: 'reconnect',\n value: function reconnect() {}\n }, {\n key: 'disconnect',\n value: function disconnect() {\n this.connections = {};\n this.isSynced = false;\n this.currentSyncTarget = null;\n this.broadcastedHB = false;\n this.syncingClients = [];\n this.whenSyncedListeners = [];\n return this.y.db.stopGarbageCollector();\n }\n }, {\n key: 'setUserId',\n value: function setUserId(userId) {\n if (this.userId == null) {\n this.userId = userId;\n return this.y.db.setUserId(userId);\n } else {\n return null;\n }\n }\n }, {\n key: 'onUserEvent',\n value: function onUserEvent(f) {\n this.userEventListeners.push(f);\n }\n }, {\n key: 'userLeft',\n value: function userLeft(user) {\n if (this.connections[user] != null) {\n delete this.connections[user];\n if (user === this.currentSyncTarget) {\n this.currentSyncTarget = null;\n this.findNextSyncTarget();\n }\n this.syncingClients = this.syncingClients.filter(function (cli) {\n return cli !== user;\n });\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = this.userEventListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var f = _step.value;\n\n f({\n action: 'userLeft',\n user: user\n });\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n }\n }, {\n key: 'userJoined',\n value: function userJoined(user, role) {\n if (role == null) {\n throw new Error('You must specify the role of the joined user!');\n }\n if (this.connections[user] != null) {\n throw new Error('This user already joined!');\n }\n this.connections[user] = {\n isSynced: false,\n role: role\n };\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this.userEventListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var f = _step2.value;\n\n f({\n action: 'userJoined',\n user: user,\n role: role\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (this.currentSyncTarget == null) {\n this.findNextSyncTarget();\n }\n }\n // Execute a function _when_ we are connected.\n // If not connected, wait until connected\n\n }, {\n key: 'whenSynced',\n value: function whenSynced(f) {\n if (this.isSynced) {\n f();\n } else {\n this.whenSyncedListeners.push(f);\n }\n }\n /*\n returns false, if there is no sync target\n true otherwise\n */\n\n }, {\n key: 'findNextSyncTarget',\n value: function findNextSyncTarget() {\n if (this.currentSyncTarget != null || this.isSynced) {\n return; // \"The current sync has not finished!\"\n }\n\n var syncUser = null;\n for (var uid in this.connections) {\n if (!this.connections[uid].isSynced) {\n syncUser = uid;\n break;\n }\n }\n if (syncUser != null) {\n var conn = this;\n this.currentSyncTarget = syncUser;\n this.y.db.requestTransaction(regeneratorRuntime.mark(function _callee() {\n var stateSet, deleteSet;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n return _context.delegateYield(this.getStateSet(), 't0', 1);\n\n case 1:\n stateSet = _context.t0;\n return _context.delegateYield(this.getDeleteSet(), 't1', 3);\n\n case 3:\n deleteSet = _context.t1;\n\n conn.send(syncUser, {\n type: 'sync step 1',\n stateSet: stateSet,\n deleteSet: deleteSet\n });\n\n case 5:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n } else {\n this.isSynced = true;\n // call when synced listeners\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = this.whenSyncedListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var f = _step3.value;\n\n f();\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n this.whenSyncedListeners = [];\n this.y.db.requestTransaction(regeneratorRuntime.mark(function _callee2() {\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n return _context2.delegateYield(this.garbageCollectAfterSync(), 't0', 1);\n\n case 1:\n case 'end':\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n }\n }\n }, {\n key: 'send',\n value: function send(uid, message) {\n if (this.debug) {\n console.log('send ' + this.userId + ' -> ' + uid + ': ' + message.type, message); // eslint-disable-line\n }\n }\n /*\n Buffer operations, and broadcast them when ready.\n */\n\n }, {\n key: 'broadcastOps',\n value: function broadcastOps(ops) {\n ops = ops.map(function (op) {\n return Y.Struct[op.struct].encode(op);\n });\n var self = this;\n function broadcastOperations() {\n if (self.broadcastOpBuffer.length > 0) {\n self.broadcast({\n type: 'update',\n ops: self.broadcastOpBuffer\n });\n self.broadcastOpBuffer = [];\n }\n }\n if (this.broadcastOpBuffer.length === 0) {\n this.broadcastOpBuffer = ops;\n if (this.y.db.transactionInProgress) {\n this.y.db.whenTransactionsFinished().then(broadcastOperations);\n } else {\n setTimeout(broadcastOperations, 0);\n }\n } else {\n this.broadcastOpBuffer = this.broadcastOpBuffer.concat(ops);\n }\n }\n /*\n You received a raw message, and you know that it is intended for Yjs. Then call this function.\n */\n\n }, {\n key: 'receiveMessage',\n value: function receiveMessage(sender /* :UserId */, message /* :Message */) {\n var _this = this;\n\n if (sender === this.userId) {\n return;\n }\n if (this.debug) {\n console.log('receive ' + sender + ' -> ' + this.userId + ': ' + message.type, JSON.parse(JSON.stringify(message))); // eslint-disable-line\n }\n if (message.type === 'sync step 1') {\n (function () {\n // TODO: make transaction, stream the ops\n var conn = _this;\n var m = message;\n _this.y.db.requestTransaction(regeneratorRuntime.mark(function _callee3() {\n var currentStateSet, ds, ops;\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n return _context3.delegateYield(this.getStateSet(), 't0', 1);\n\n case 1:\n currentStateSet = _context3.t0;\n return _context3.delegateYield(this.applyDeleteSet(m.deleteSet), 't1', 3);\n\n case 3:\n return _context3.delegateYield(this.getDeleteSet(), 't2', 4);\n\n case 4:\n ds = _context3.t2;\n return _context3.delegateYield(this.getOperations(m.stateSet), 't3', 6);\n\n case 6:\n ops = _context3.t3;\n\n conn.send(sender, {\n type: 'sync step 2',\n os: ops,\n stateSet: currentStateSet,\n deleteSet: ds\n });\n if (this.forwardToSyncingClients) {\n conn.syncingClients.push(sender);\n setTimeout(function () {\n conn.syncingClients = conn.syncingClients.filter(function (cli) {\n return cli !== sender;\n });\n conn.send(sender, {\n type: 'sync done'\n });\n }, 5000); // TODO: conn.syncingClientDuration)\n } else {\n conn.send(sender, {\n type: 'sync done'\n });\n }\n conn._setSyncedWith(sender);\n\n case 10:\n case 'end':\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n })();\n } else if (message.type === 'sync step 2') {\n var broadcastHB;\n var db;\n var defer;\n\n (function () {\n var conn = _this;\n broadcastHB = !_this.broadcastedHB;\n\n _this.broadcastedHB = true;\n db = _this.y.db;\n defer = {};\n\n defer.promise = new Promise(function (resolve) {\n defer.resolve = resolve;\n });\n _this.syncStep2 = defer.promise;\n var m /* :MessageSyncStep2 */ = message;\n db.requestTransaction(regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n return _context5.delegateYield(this.applyDeleteSet(m.deleteSet), 't0', 1);\n\n case 1:\n this.store.apply(m.os);\n db.requestTransaction(regeneratorRuntime.mark(function _callee4() {\n var ops;\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n return _context4.delegateYield(this.getOperations(m.stateSet), 't0', 1);\n\n case 1:\n ops = _context4.t0;\n\n if (ops.length > 0) {\n if (!broadcastHB) {\n // TODO: consider to broadcast here..\n conn.send(sender, {\n type: 'update',\n ops: ops\n });\n } else {\n // broadcast only once!\n conn.broadcastOps(ops);\n }\n }\n defer.resolve();\n\n case 4:\n case 'end':\n return _context4.stop();\n }\n }\n }, _callee4, this);\n }));\n\n case 3:\n case 'end':\n return _context5.stop();\n }\n }\n }, _callee5, this);\n }));\n })();\n } else if (message.type === 'sync done') {\n var self = this;\n this.syncStep2.then(function () {\n self._setSyncedWith(sender);\n });\n } else if (message.type === 'update') {\n if (this.forwardToSyncingClients) {\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = this.syncingClients[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var client = _step4.value;\n\n this.send(client, message);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n }\n if (this.y.db.forwardAppliedOperations) {\n var delops = message.ops.filter(function (o) {\n return o.struct === 'Delete';\n });\n if (delops.length > 0) {\n this.broadcastOps(delops);\n }\n }\n this.y.db.apply(message.ops);\n }\n }\n }, {\n key: '_setSyncedWith',\n value: function _setSyncedWith(user) {\n var conn = this.connections[user];\n if (conn != null) {\n conn.isSynced = true;\n }\n if (user === this.currentSyncTarget) {\n this.currentSyncTarget = null;\n this.findNextSyncTarget();\n }\n }\n /*\n Currently, the HB encodes operations as JSON. For the moment I want to keep it\n that way. Maybe we support encoding in the HB as XML in the future, but for now I don't want\n too much overhead. Y is very likely to get changed a lot in the future\n Because we don't want to encode JSON as string (with character escaping, wich makes it pretty much unreadable)\n we encode the JSON as XML.\n When the HB support encoding as XML, the format should look pretty much like this.\n does not support primitive values as array elements\n expects an ltx (less than xml) object\n */\n\n }, {\n key: 'parseMessageFromXml',\n value: function parseMessageFromXml(m /* :any */) {\n function parseArray(node) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = node.children[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var n = _step5.value;\n\n if (n.getAttribute('isArray') === 'true') {\n return parseArray(n);\n } else {\n return parseObject(n);\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n function parseObject(node /* :any */) {\n var json = {};\n for (var attrName in node.attrs) {\n var value = node.attrs[attrName];\n var int = parseInt(value, 10);\n if (isNaN(int) || '' + int !== value) {\n json[attrName] = value;\n } else {\n json[attrName] = int;\n }\n }\n for (var n /* :any */ in node.children) {\n var name = n.name;\n if (n.getAttribute('isArray') === 'true') {\n json[name] = parseArray(n);\n } else {\n json[name] = parseObject(n);\n }\n }\n return json;\n }\n parseObject(m);\n }\n /*\n encode message in xml\n we use string because Strophe only accepts an \"xml-string\"..\n So {a:4,b:{c:5}} will look like\n <y a=\"4\">\n <b c=\"5\"></b>\n </y>\n m - ltx element\n json - Object\n */\n\n }, {\n key: 'encodeMessageToXml',\n value: function encodeMessageToXml(msg, obj) {\n // attributes is optional\n function encodeObject(m, json) {\n for (var name in json) {\n var value = json[name];\n if (name == null) {\n // nop\n } else if (value.constructor === Object) {\n encodeObject(m.c(name), value);\n } else if (value.constructor === Array) {\n encodeArray(m.c(name), value);\n } else {\n m.setAttribute(name, value);\n }\n }\n }\n function encodeArray(m, array) {\n m.setAttribute('isArray', 'true');\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = array[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var e = _step6.value;\n\n if (e.constructor === Object) {\n encodeObject(m.c('array-element'), e);\n } else {\n encodeArray(m.c('array-element'), e);\n }\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n }\n if (obj.constructor === Object) {\n encodeObject(msg.c('y', { xmlns: 'http://y.ninja/connector-stanza' }), obj);\n } else if (obj.constructor === Array) {\n encodeArray(msg.c('y', { xmlns: 'http://y.ninja/connector-stanza' }), obj);\n } else {\n throw new Error(\"I can't encode this json!\");\n }\n }\n }]);\n\n return AbstractConnector;\n })();\n\n Y.AbstractConnector = AbstractConnector;\n};\n\n},{}],4:[function(require,module,exports){\n/* global getRandom, async */\n'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nvar _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if (\"value\" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nmodule.exports = function (Y) {\n var globalRoom = {\n users: {},\n buffers: {},\n removeUser: function removeUser(user) {\n for (var i in this.users) {\n this.users[i].userLeft(user);\n }\n delete this.users[user];\n delete this.buffers[user];\n },\n addUser: function addUser(connector) {\n this.users[connector.userId] = connector;\n this.buffers[connector.userId] = [];\n for (var uname in this.users) {\n if (uname !== connector.userId) {\n var u = this.users[uname];\n u.userJoined(connector.userId, 'master');\n connector.userJoined(u.userId, 'master');\n }\n }\n },\n whenTransactionsFinished: function whenTransactionsFinished() {\n var ps = [];\n for (var name in this.users) {\n ps.push(this.users[name].y.db.whenTransactionsFinished());\n }\n return Promise.all(ps);\n },\n flushOne: function flushOne() {\n var bufs = [];\n for (var i in globalRoom.buffers) {\n if (globalRoom.buffers[i].length > 0) {\n bufs.push(i);\n }\n }\n if (bufs.length > 0) {\n var userId = getRandom(bufs);\n var m = globalRoom.buffers[userId].shift();\n var user = globalRoom.users[userId];\n user.receiveMessage(m[0], m[1]);\n return user.y.db.whenTransactionsFinished();\n } else {\n return false;\n }\n },\n flushAll: function flushAll() {\n return new Promise(function (resolve) {\n // flushes may result in more created operations,\n // flush until there is nothing more to flush\n function nextFlush() {\n var c = globalRoom.flushOne();\n if (c) {\n while (c) {\n c = globalRoom.flushOne();\n }\n globalRoom.whenTransactionsFinished().then(nextFlush);\n } else {\n setTimeout(function () {\n var c = globalRoom.flushOne();\n if (c) {\n c.then(function () {\n globalRoom.whenTransactionsFinished().then(nextFlush);\n });\n } else {\n resolve();\n }\n }, 10);\n }\n }\n globalRoom.whenTransactionsFinished().then(nextFlush);\n });\n }\n };\n Y.utils.globalRoom = globalRoom;\n\n var userIdCounter = 0;\n\n var Test = (function (_Y$AbstractConnector) {\n _inherits(Test, _Y$AbstractConnector);\n\n function Test(y, options) {\n _classCallCheck(this, Test);\n\n if (options === undefined) {\n throw new Error('Options must not be undefined!');\n }\n options.role = 'master';\n options.forwardToSyncingClients = false;\n\n var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Test).call(this, y, options));\n\n _this.setUserId(userIdCounter++ + '').then(function () {\n globalRoom.addUser(_this);\n });\n _this.globalRoom = globalRoom;\n _this.syncingClientDuration = 0;\n return _this;\n }\n\n _createClass(Test, [{\n key: 'receiveMessage',\n value: function receiveMessage(sender, m) {\n _get(Object.getPrototypeOf(Test.prototype), 'receiveMessage', this).call(this, sender, JSON.parse(JSON.stringify(m)));\n }\n }, {\n key: 'send',\n value: function send(userId, message) {\n var buffer = globalRoom.buffers[userId];\n if (buffer != null) {\n buffer.push(JSON.parse(JSON.stringify([this.userId, message])));\n }\n }\n }, {\n key: 'broadcast',\n value: function broadcast(message) {\n for (var key in globalRoom.buffers) {\n globalRoom.buffers[key].push(JSON.parse(JSON.stringify([this.userId, message])));\n }\n }\n }, {\n key: 'isDisconnected',\n value: function isDisconnected() {\n return globalRoom.users[this.userId] == null;\n }\n }, {\n key: 'reconnect',\n value: function reconnect() {\n if (this.isDisconnected()) {\n globalRoom.addUser(this);\n _get(Object.getPrototypeOf(Test.prototype), 'reconnect', this).call(this);\n }\n return Y.utils.globalRoom.flushAll();\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n if (!this.isDisconnected()) {\n globalRoom.removeUser(this.userId);\n _get(Object.getPrototypeOf(Test.prototype), 'disconnect', this).call(this);\n }\n return this.y.db.whenTransactionsFinished();\n }\n }, {\n key: 'flush',\n value: function flush() {\n var self = this;\n return async(regeneratorRuntime.mark(function _callee() {\n var m;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n while (globalRoom.buffers[self.userId].length > 0) {\n m = globalRoom.buffers[self.userId].shift();\n\n this.receiveMessage(m[0], m[1]);\n }\n _context.next = 3;\n return self.whenTransactionsFinished();\n\n case 3:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n }\n }]);\n\n return Test;\n })(Y.AbstractConnector);\n\n Y.Test = Test;\n};\n\n},{}],5:[function(require,module,exports){\n/* @flow */\n'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nmodule.exports = function (Y /* :any */) {\n /*\n Partial definition of an OperationStore.\n TODO: name it Database, operation store only holds operations.\n A database definition must alse define the following methods:\n * logTable() (optional)\n - show relevant information information in a table\n * requestTransaction(makeGen)\n - request a transaction\n * destroy()\n - destroy the database\n */\n\n var AbstractDatabase = (function () {\n /* ::\n y: YConfig;\n forwardAppliedOperations: boolean;\n listenersById: Object;\n listenersByIdExecuteNow: Array<Object>;\n listenersByIdRequestPending: boolean;\n initializedTypes: Object;\n whenUserIdSetListener: ?Function;\n waitingTransactions: Array<Transaction>;\n transactionInProgress: boolean;\n executeOrder: Array<Object>;\n gc1: Array<Struct>;\n gc2: Array<Struct>;\n gcTimeout: number;\n gcInterval: any;\n garbageCollect: Function;\n executeOrder: Array<any>; // for debugging only\n userId: UserId;\n opClock: number;\n transactionsFinished: ?{promise: Promise, resolve: any};\n transact: (x: ?Generator) => any;\n */\n\n function AbstractDatabase(y, opts) {\n _classCallCheck(this, AbstractDatabase);\n\n this.y = y;\n var os = this;\n this.userId = null;\n var resolve;\n this.userIdPromise = new Promise(function (r) {\n resolve = r;\n });\n this.userIdPromise.resolve = resolve;\n // whether to broadcast all applied operations (insert & delete hook)\n this.forwardAppliedOperations = false;\n // E.g. this.listenersById[id] : Array<Listener>\n this.listenersById = {};\n // Execute the next time a transaction is requested\n this.listenersByIdExecuteNow = [];\n // A transaction is requested\n this.listenersByIdRequestPending = false;\n /* To make things more clear, the following naming conventions:\n * ls : we put this.listenersById on ls\n * l : Array<Listener>\n * id : Id (can't use as property name)\n * sid : String (converted from id via JSON.stringify\n so we can use it as a property name)\n Always remember to first overwrite\n a property before you iterate over it!\n */\n // TODO: Use ES7 Weak Maps. This way types that are no longer user,\n // wont be kept in memory.\n this.initializedTypes = {};\n this.waitingTransactions = [];\n this.transactionInProgress = false;\n this.transactionIsFlushed = false;\n if (typeof YConcurrency_TestingMode !== 'undefined') {\n this.executeOrder = [];\n }\n this.gc1 = []; // first stage\n this.gc2 = []; // second stage -> after that, remove the op\n this.gcTimeout = opts.gcTimeout || 50000;\n function garbageCollect() {\n return os.whenTransactionsFinished().then(function () {\n if (os.gc1.length > 0 || os.gc2.length > 0) {\n return new Promise(function (resolve) {\n os.requestTransaction(regeneratorRuntime.mark(function _callee() {\n var i, oid;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!(os.y.connector != null && os.y.connector.isSynced)) {\n _context.next = 10;\n break;\n }\n\n i = 0;\n\n case 2:\n if (!(i < os.gc2.length)) {\n _context.next = 8;\n break;\n }\n\n oid = os.gc2[i];\n return _context.delegateYield(this.garbageCollectOperation(oid), 't0', 5);\n\n case 5:\n i++;\n _context.next = 2;\n break;\n\n case 8:\n os.gc2 = os.gc1;\n os.gc1 = [];\n\n case 10:\n // TODO: Use setInterval here instead (when garbageCollect is called several times there will be several timeouts..)\n if (os.gcTimeout > 0) {\n os.gcInterval = setTimeout(garbageCollect, os.gcTimeout);\n }\n resolve();\n\n case 12:\n case 'end':\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n });\n } else {\n // TODO: see above\n if (os.gcTimeout > 0) {\n os.gcInterval = setTimeout(garbageCollect, os.gcTimeout);\n }\n return Promise.resolve();\n }\n });\n }\n this.garbageCollect = garbageCollect;\n if (this.gcTimeout > 0) {\n garbageCollect();\n }\n }\n\n _createClass(AbstractDatabase, [{\n key: 'addToDebug',\n value: function addToDebug() {\n if (typeof YConcurrency_TestingMode !== 'undefined') {\n var command /* :string */ = Array.prototype.map.call(arguments, function (s) {\n if (typeof s === 'string') {\n return s;\n } else {\n return JSON.stringify(s);\n }\n }).join('').replace(/\"/g, \"'\").replace(/,/g, ', ').replace(/:/g, ': ');\n this.executeOrder.push(command);\n }\n }\n }, {\n key: 'getDebugData',\n value: function getDebugData() {\n console.log(this.executeOrder.join('\\n'));\n }\n }, {\n key: 'stopGarbageCollector',\n value: function stopGarbageCollector() {\n var self = this;\n return new Promise(function (resolve) {\n self.requestTransaction(regeneratorRuntime.mark(function _callee2() {\n var ungc /* :Array<Struct> */, i, op;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n ungc = self.gc1.concat(self.gc2);\n\n self.gc1 = [];\n self.gc2 = [];\n i = 0;\n\n case 4:\n if (!(i < ungc.length)) {\n _context2.next = 12;\n break;\n }\n\n return _context2.delegateYield(this.getOperation(ungc[i]), 't0', 6);\n\n case 6:\n op = _context2.t0;\n\n delete op.gc;\n return _context2.delegateYield(this.setOperation(op), 't1', 9);\n\n case 9:\n i++;\n _context2.next = 4;\n break;\n\n case 12:\n resolve();\n\n case 13:\n case 'end':\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n });\n }\n /*\n Try to add to GC.\n TODO: rename this function\n Rulez:\n * Only gc if this user is online\n * The most left element in a list must not be gc'd.\n => There is at least one element in the list\n returns true iff op was added to GC\n */\n\n }, {\n key: 'addToGarbageCollector',\n value: function addToGarbageCollector(op, left) {\n if (op.gc == null && op.deleted === true && this.y.connector.isSynced && left != null && left.deleted === true) {\n op.gc = true;\n this.gc1.push(op.id);\n return true;\n } else {\n return false;\n }\n }\n }, {\n key: 'removeFromGarbageCollector',\n value: function removeFromGarbageCollector(op) {\n function filter(o) {\n return !Y.utils.compareIds(o, op.id);\n }\n this.gc1 = this.gc1.filter(filter);\n this.gc2 = this.gc2.filter(filter);\n delete op.gc;\n }\n }, {\n key: 'destroy',\n value: regeneratorRuntime.mark(function destroy() {\n var key, type;\n return regeneratorRuntime.wrap(function destroy$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n clearInterval(this.gcInterval);\n this.gcInterval = null;\n for (key in this.initializedTypes) {\n type = this.initializedTypes[key];\n\n if (type._destroy != null) {\n type._destroy();\n } else {\n console.error('The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).');\n }\n }\n\n case 3:\n case 'end':\n return _context3.stop();\n }\n }\n }, destroy, this);\n })\n }, {\n key: 'setUserId',\n value: function setUserId(userId) {\n if (!this.userIdPromise.inProgress) {\n this.userIdPromise.inProgress = true;\n var self = this;\n self.requestTransaction(regeneratorRuntime.mark(function _callee3() {\n var state;\n return regeneratorRuntime.wrap(function _callee3$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n self.userId = userId;\n return _context4.delegateYield(this.getState(userId), 't0', 2);\n\n case 2:\n state = _context4.t0;\n\n self.opClock = state.clock;\n self.userIdPromise.resolve(userId);\n\n case 5:\n case 'end':\n return _context4.stop();\n }\n }\n }, _callee3, this);\n }));\n }\n return this.userIdPromise;\n }\n }, {\n key: 'whenUserIdSet',\n value: function whenUserIdSet(f) {\n this.userIdPromise.then(f);\n }\n }, {\n key: 'getNextOpId',\n value: function getNextOpId() {\n if (this._nextUserId != null) {\n return this._nextUserId;\n } else if (this.userId == null) {\n throw new Error('OperationStore not yet initialized!');\n } else {\n return [this.userId, this.opClock++];\n }\n }\n /*\n Apply a list of operations.\n * get a transaction\n * check whether all Struct.*.requiredOps are in the OS\n * check if it is an expected op (otherwise wait for it)\n * check if was deleted, apply a delete operation after op was applied\n */\n\n }, {\n key: 'apply',\n value: function apply(ops) {\n for (var i = 0; i < ops.length; i++) {\n var o = ops[i];\n if (o.id == null || o.id[0] !== this.y.connector.userId) {\n var required = Y.Struct[o.struct].requiredOps(o);\n this.whenOperationsExist(required, o);\n }\n }\n }\n /*\n op is executed as soon as every operation requested is available.\n Note that Transaction can (and should) buffer requests.\n */\n\n }, {\n key: 'whenOperationsExist',\n value: function whenOperationsExist(ids, op) {\n if (ids.length > 0) {\n var listener = {\n op: op,\n missing: ids.length\n };\n\n for (var i = 0; i < ids.length; i++) {\n var id = ids[i];\n var sid = JSON.stringify(id);\n var l = this.listenersById[sid];\n if (l == null) {\n l = [];\n this.listenersById[sid] = l;\n }\n l.push(listener);\n }\n } else {\n this.listenersByIdExecuteNow.push({\n op: op\n });\n }\n\n if (this.listenersByIdRequestPending) {\n return;\n }\n\n this.listenersByIdRequestPending = true;\n var store = this;\n\n this.requestTransaction(regeneratorRuntime.mark(function _callee4() {\n var exeNow, ls, key, o, sid, l, id, op, i, listener;\n return regeneratorRuntime.wrap(function _callee4$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n exeNow = store.listenersByIdExecuteNow;\n\n store.listenersByIdExecuteNow = [];\n\n ls = store.listenersById;\n\n store.listenersById = {};\n\n store.listenersByIdRequestPending = false;\n\n key = 0;\n\n case 6:\n if (!(key < exeNow.length)) {\n _context5.next = 12;\n break;\n }\n\n o = exeNow[key].op;\n return _context5.delegateYield(store.tryExecute.call(this, o), 't0', 9);\n\n case 9:\n key++;\n _context5.next = 6;\n break;\n\n case 12:\n _context5.t1 = regeneratorRuntime.keys(ls);\n\n case 13:\n if ((_context5.t2 = _context5.t1()).done) {\n _context5.next = 34;\n break;\n }\n\n sid = _context5.t2.value;\n l = ls[sid];\n id = JSON.parse(sid);\n return _context5.delegateYield(this.getOperation(id), 't3', 18);\n\n case 18:\n op = _context5.t3;\n\n if (!(op == null)) {\n _context5.next = 23;\n break;\n }\n\n store.listenersById[sid] = l;\n _context5.next = 32;\n break;\n\n case 23:\n i = 0;\n\n case 24:\n if (!(i < l.length)) {\n _context5.next = 32;\n break;\n }\n\n listener = l[i];\n o = listener.op;\n\n if (!(--listener.missing === 0)) {\n _context5.next = 29;\n break;\n }\n\n return _context5.delegateYield(store.tryExecute.call(this, o), 't4', 29);\n\n case 29:\n i++;\n _context5.next = 24;\n break;\n\n case 32:\n _context5.next = 13;\n break;\n\n case 34:\n case 'end':\n return _context5.stop();\n }\n }\n }, _callee4, this);\n }));\n }\n /*\n Actually execute an operation, when all expected operations are available.\n */\n /* :: // TODO: this belongs somehow to transaction\n store: Object;\n getOperation: any;\n isGarbageCollected: any;\n addOperation: any;\n whenOperationsExist: any;\n */\n\n }, {\n key: 'tryExecute',\n value: regeneratorRuntime.mark(function tryExecute(op) {\n var defined, isGarbageCollected;\n return regeneratorRuntime.wrap(function tryExecute$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n this.store.addToDebug('yield* this.store.tryExecute.call(this, ', JSON.stringify(op), ')');\n\n if (!(op.struct === 'Delete')) {\n _context6.next = 6;\n break;\n }\n\n return _context6.delegateYield(Y.Struct.Delete.execute.call(this, op), 't0', 3);\n\n case 3:\n return _context6.delegateYield(this.store.operationAdded(this, op), 't1', 4);\n\n case 4:\n _context6.next = 15;\n break;\n\n case 6:\n return _context6.delegateYield(this.getOperation(op.id), 't2', 7);\n\n case 7:\n defined = _context6.t2;\n\n if (!(defined == null)) {\n _context6.next = 15;\n break;\n }\n\n return _context6.delegateYield(this.isGarbageCollected(op.id), 't3', 10);\n\n case 10:\n isGarbageCollected = _context6.t3;\n\n if (isGarbageCollected) {\n _context6.next = 15;\n break;\n }\n\n return _context6.delegateYield(Y.Struct[op.struct].execute.call(this, op), 't4', 13);\n\n case 13:\n return _context6.delegateYield(this.addOperation(op), 't5', 14);\n\n case 14:\n return _context6.delegateYield(this.store.operationAdded(this, op), 't6', 15);\n\n case 15:\n case 'end':\n return _context6.stop();\n }\n }\n }, tryExecute, this);\n })\n // called by a transaction when an operation is added\n\n }, {\n key: 'operationAdded',\n value: regeneratorRuntime.mark(function operationAdded(transaction, op) {\n var target, type, o, state, sid, l, key, listener, t, opIsDeleted, delop;\n return regeneratorRuntime.wrap(function operationAdded$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (!(op.struct === 'Delete')) {\n _context7.next = 9;\n break;\n }\n\n return _context7.delegateYield(transaction.getOperation(op.target), 't0', 2);\n\n case 2:\n target = _context7.t0;\n\n if (!(target != null)) {\n _context7.next = 7;\n break;\n }\n\n type = transaction.store.initializedTypes[JSON.stringify(target.parent)];\n\n if (!(type != null)) {\n _context7.next = 7;\n break;\n }\n\n return _context7.delegateYield(type._changed(transaction, {\n struct: 'Delete',\n target: op.target\n }), 't1', 7);\n\n case 7:\n _context7.next = 32;\n break;\n\n case 9:\n // increase SS\n o = op;\n return _context7.delegateYield(transaction.getState(op.id[0]), 't2', 11);\n\n case 11:\n state = _context7.t2;\n\n case 12:\n if (!(o != null && o.id[1] === state.clock && op.id[0] === o.id[0])) {\n _context7.next = 19;\n break;\n }\n\n // either its a new operation (1. case), or it is an operation that was deleted, but is not yet in the OS\n state.clock++;\n return _context7.delegateYield(transaction.checkDeleteStoreForState(state), 't3', 15);\n\n case 15:\n return _context7.delegateYield(transaction.os.findNext(o.id), 't4', 16);\n\n case 16:\n o = _context7.t4;\n _context7.next = 12;\n break;\n\n case 19:\n return _context7.delegateYield(transaction.setState(state), 't5', 20);\n\n case 20:\n\n // notify whenOperation listeners (by id)\n sid = JSON.stringify(op.id);\n l = this.listenersById[sid];\n\n delete this.listenersById[sid];\n\n if (l != null) {\n for (key in l) {\n listener = l[key];\n\n if (--listener.missing === 0) {\n this.whenOperationsExist([], listener.op);\n }\n }\n }\n t = this.initializedTypes[JSON.stringify(op.parent)];\n\n // Delete if DS says this is actually deleted\n\n return _context7.delegateYield(transaction.isDeleted(op.id), 't6', 26);\n\n case 26:\n opIsDeleted = _context7.t6;\n\n if (!(!op.deleted && opIsDeleted)) {\n _context7.next = 30;\n break;\n }\n\n delop = {\n struct: 'Delete',\n target: op.id\n };\n return _context7.delegateYield(Y.Struct['Delete'].execute.call(transaction, delop), 't7', 30);\n\n case 30:\n if (!(t != null)) {\n _context7.next = 32;\n break;\n }\n\n return _context7.delegateYield(t._changed(transaction, Y.utils.copyObject(op)), 't8', 32);\n\n case 32:\n case 'end':\n return _context7.stop();\n }\n }\n }, operationAdded, this);\n })\n }, {\n key: 'whenTransactionsFinished',\n value: function whenTransactionsFinished() {\n if (this.transactionInProgress) {\n if (this.transactionsFinished == null) {\n var resolve;\n var promise = new Promise(function (r) {\n resolve = r;\n });\n this.transactionsFinished = {\n resolve: resolve,\n promise: promise\n };\n return promise;\n } else {\n return this.transactionsFinished.promise;\n }\n } else {\n return Promise.resolve();\n }\n }\n // Check if there is another transaction request.\n // * the last transaction is always a flush :)\n\n }, {\n key: 'getNextRequest',\n value: function getNextRequest() {\n if (this.waitingTransactions.length === 0) {\n if (this.transactionIsFlushed) {\n this.transactionInProgress = false;\n this.transactionIsFlushed = false;\n if (this.transactionsFinished != null) {\n this.transactionsFinished.resolve();\n this.transactionsFinished = null;\n }\n return null;\n } else {\n this.transactionIsFlushed = true;\n return regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n return _context8.delegateYield(this.flush(), 't0', 1);\n\n case 1:\n case 'end':\n return _context8.stop();\n }\n }\n }, _callee5, this);\n });\n }\n } else {\n this.transactionIsFlushed = false;\n return this.waitingTransactions.shift();\n }\n }\n }, {\n key: 'requestTransaction',\n value: function requestTransaction(makeGen /* :any */, callImmediately) {\n this.waitingTransactions.push(makeGen);\n if (!this.transactionInProgress) {\n this.transactionInProgress = true;\n if (false || callImmediately) {\n // TODO: decide whether this is ok or not..\n this.transact(this.getNextRequest());\n } else {\n var self = this;\n setTimeout(function () {\n self.transact(self.getNextRequest());\n }, 0);\n }\n }\n }\n }]);\n\n return AbstractDatabase;\n })();\n\n Y.AbstractDatabase = AbstractDatabase;\n};\n\n},{}],6:[function(require,module,exports){\n/* @flow */\n'use strict';\n\n/*\n An operation also defines the structure of a type. This is why operation and\n structure are used interchangeably here.\n\n It must be of the type Object. I hope to achieve some performance\n improvements when working on databases that support the json format.\n\n An operation must have the following properties:\n\n * encode\n - Encode the structure in a readable format (preferably string- todo)\n * decode (todo)\n - decode structure to json\n * execute\n - Execute the semantics of an operation.\n * requiredOps\n - Operations that are required to execute this operation.\n*/\n\nmodule.exports = function (Y /* :any */) {\n var Struct = {\n /* This is the only operation that is actually not a structure, because\n it is not stored in the OS. This is why it _does not_ have an id\n op = {\n target: Id\n }\n */\n Delete: {\n encode: function encode(op) {\n return op;\n },\n requiredOps: function requiredOps(op) {\n return []; // [op.target]\n },\n execute: regeneratorRuntime.mark(function execute(op) {\n return regeneratorRuntime.wrap(function execute$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n return _context.delegateYield(this.deleteOperation(op.target), 't0', 1);\n\n case 1:\n return _context.abrupt('return', _context.t0);\n\n case 2:\n case 'end':\n return _context.stop();\n }\n }\n }, execute, this);\n })\n },\n Insert: {\n /* {\n content: any,\n id: Id,\n left: Id,\n origin: Id,\n right: Id,\n parent: Id,\n parentSub: string (optional), // child of Map type\n }\n */\n encode: function encode(op /* :Insertion */) /* :Insertion */{\n // TODO: you could not send the \"left\" property, then you also have to\n // \"op.left = null\" in $execute or $decode\n var e /* :any */ = {\n id: op.id,\n left: op.left,\n right: op.right,\n origin: op.origin,\n parent: op.parent,\n struct: op.struct\n };\n if (op.parentSub != null) {\n e.parentSub = op.parentSub;\n }\n if (op.opContent != null) {\n e.opContent = op.opContent;\n } else {\n e.content = op.content;\n }\n\n return e;\n },\n requiredOps: function requiredOps(op) {\n var ids = [];\n if (op.left != null) {\n ids.push(op.left);\n }\n if (op.right != null) {\n ids.push(op.right);\n }\n if (op.origin != null && !Y.utils.compareIds(op.left, op.origin)) {\n ids.push(op.origin);\n }\n // if (op.right == null && op.left == null) {\n ids.push(op.parent);\n\n if (op.opContent != null) {\n ids.push(op.opContent);\n }\n return ids;\n },\n getDistanceToOrigin: regeneratorRuntime.mark(function getDistanceToOrigin(op) {\n var d, o;\n return regeneratorRuntime.wrap(function getDistanceToOrigin$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n if (!(op.left == null)) {\n _context2.next = 4;\n break;\n }\n\n return _context2.abrupt('return', 0);\n\n case 4:\n d = 0;\n return _context2.delegateYield(this.getOperation(op.left), 't0', 6);\n\n case 6:\n o = _context2.t0;\n\n case 7:\n if (Y.utils.compareIds(op.origin, o ? o.id : null)) {\n _context2.next = 17;\n break;\n }\n\n d++;\n\n if (!(o.left == null)) {\n _context2.next = 13;\n break;\n }\n\n return _context2.abrupt('break', 17);\n\n case 13:\n return _context2.delegateYield(this.getOperation(o.left), 't1', 14);\n\n case 14:\n o = _context2.t1;\n\n case 15:\n _context2.next = 7;\n break;\n\n case 17:\n return _context2.abrupt('return', d);\n\n case 18:\n case 'end':\n return _context2.stop();\n }\n }\n }, getDistanceToOrigin, this);\n }),\n /*\n # $this has to find a unique position between origin and the next known character\n # case 1: $origin equals $o.origin: the $creator parameter decides if left or right\n # let $OL= [o1,o2,o3,o4], whereby $this is to be inserted between o1 and o4\n # o2,o3 and o4 origin is 1 (the position of o2)\n # there is the case that $this.creator < o2.creator, but o3.creator < $this.creator\n # then o2 knows o3. Since on another client $OL could be [o1,o3,o4] the problem is complex\n # therefore $this would be always to the right of o3\n # case 2: $origin < $o.origin\n # if current $this insert_position > $o origin: $this ins\n # else $insert_position will not change\n # (maybe we encounter case 1 later, then this will be to the right of $o)\n # case 3: $origin > $o.origin\n # $this insert_position is to the left of $o (forever!)\n */\n execute: regeneratorRuntime.mark(function execute(op) {\n var i, distanceToOrigin, origin, o, parent, start, startId, oOriginDistance, left, right;\n return regeneratorRuntime.wrap(function execute$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n return _context3.delegateYield(Struct.Insert.getDistanceToOrigin.call(this, op), 't0', 1);\n\n case 1:\n distanceToOrigin = i = _context3.t0;\n\n if (!(op.origin != null)) {\n _context3.next = 8;\n break;\n }\n\n return _context3.delegateYield(this.getOperation(op.origin), 't1', 4);\n\n case 4:\n origin = _context3.t1;\n\n if (origin.originOf == null) {\n origin.originOf = [];\n }\n origin.originOf.push(op.id);\n return _context3.delegateYield(this.setOperation(origin), 't2', 8);\n\n case 8:\n if (!(op.left != null)) {\n _context3.next = 20;\n break;\n }\n\n return _context3.delegateYield(this.getOperation(op.left), 't3', 10);\n\n case 10:\n o = _context3.t3;\n\n if (!(o.right == null)) {\n _context3.next = 15;\n break;\n }\n\n _context3.t4 = null;\n _context3.next = 17;\n break;\n\n case 15:\n return _context3.delegateYield(this.getOperation(o.right), 't5', 16);\n\n case 16:\n _context3.t4 = _context3.t5;\n\n case 17:\n o = _context3.t4;\n _context3.next = 31;\n break;\n\n case 20:\n return _context3.delegateYield(this.getOperation(op.parent), 't6', 21);\n\n case 21:\n parent = _context3.t6;\n startId = op.parentSub ? parent.map[op.parentSub] : parent.start;\n\n if (!(startId == null)) {\n _context3.next = 27;\n break;\n }\n\n _context3.t7 = null;\n _context3.next = 29;\n break;\n\n case 27:\n return _context3.delegateYield(this.getOperation(startId), 't8', 28);\n\n case 28:\n _context3.t7 = _context3.t8;\n\n case 29:\n start = _context3.t7;\n\n o = start;\n\n case 31:\n if (!true) {\n _context3.next = 56;\n break;\n }\n\n if (!(o != null && !Y.utils.compareIds(o.id, op.right))) {\n _context3.next = 53;\n break;\n }\n\n return _context3.delegateYield(Struct.Insert.getDistanceToOrigin.call(this, o), 't9', 34);\n\n case 34:\n oOriginDistance = _context3.t9;\n\n if (!(oOriginDistance === i)) {\n _context3.next = 39;\n break;\n }\n\n // case 1\n if (o.id[0] < op.id[0]) {\n op.left = o.id;\n distanceToOrigin = i + 1;\n }\n _context3.next = 44;\n break;\n\n case 39:\n if (!(oOriginDistance < i)) {\n _context3.next = 43;\n break;\n }\n\n // case 2\n if (i - distanceToOrigin <= oOriginDistance) {\n op.left = o.id;\n distanceToOrigin = i + 1;\n }\n _context3.next = 44;\n break;\n\n case 43:\n return _context3.abrupt('break', 56);\n\n case 44:\n i++;\n\n if (!(o.right != null)) {\n _context3.next = 50;\n break;\n }\n\n return _context3.delegateYield(this.getOperation(o.right), 't10', 47);\n\n case 47:\n o = _context3.t10;\n _context3.next = 51;\n break;\n\n case 50:\n o = null;\n\n case 51:\n _context3.next = 54;\n break;\n\n case 53:\n return _context3.abrupt('break', 56);\n\n case 54:\n _context3.next = 31;\n break;\n\n case 56:\n\n // reconnect..\n left = null;\n right = null;\n\n if (!(parent == null)) {\n _context3.next = 61;\n break;\n }\n\n return _context3.delegateYield(this.getOperation(op.parent), 't11', 60);\n\n case 60:\n parent = _context3.t11;\n\n case 61:\n if (!(op.left != null)) {\n _context3.next = 69;\n break;\n }\n\n return _context3.delegateYield(this.getOperation(op.left), 't12', 63);\n\n case 63:\n left = _context3.t12;\n\n op.right = left.right;\n left.right = op.id;\n\n return _context3.delegateYield(this.setOperation(left), 't13', 67);\n\n case 67:\n _context3.next = 70;\n break;\n\n case 69:\n op.right = op.parentSub ? parent.map[op.parentSub] || null : parent.start;\n\n case 70:\n if (!(op.right != null)) {\n _context3.next = 76;\n break;\n }\n\n return _context3.delegateYield(this.getOperation(op.right), 't14', 72);\n\n case 72:\n right = _context3.t14;\n\n right.left = op.id;\n\n // if right exists, and it is supposed to be gc'd. Remove it from the gc\n if (right.gc != null) {\n this.store.removeFromGarbageCollector(right);\n }\n return _context3.delegateYield(this.setOperation(right), 't15', 76);\n\n case 76:\n if (!(op.parentSub != null)) {\n _context3.next = 86;\n break;\n }\n\n if (!(left == null)) {\n _context3.next = 80;\n break;\n }\n\n parent.map[op.parentSub] = op.id;\n return _context3.delegateYield(this.setOperation(parent), 't16', 80);\n\n case 80:\n if (!(op.right != null)) {\n _context3.next = 82;\n break;\n }\n\n return _context3.delegateYield(this.deleteOperation(op.right, true), 't17', 82);\n\n case 82:\n if (!(op.left != null)) {\n _context3.next = 84;\n break;\n }\n\n return _context3.delegateYield(this.deleteOperation(op.id, true), 't18', 84);\n\n case 84:\n _context3.next = 90;\n break;\n\n case 86:\n if (!(right == null || left == null)) {\n _context3.next = 90;\n break;\n }\n\n if (right == null) {\n parent.end = op.id;\n }\n if (left == null) {\n parent.start = op.id;\n }\n return _context3.delegateYield(this.setOperation(parent), 't19', 90);\n\n case 90:\n case 'end':\n return _context3.stop();\n }\n }\n }, execute, this);\n })\n },\n List: {\n /*\n {\n start: null,\n end: null,\n struct: \"List\",\n type: \"\",\n id: this.os.getNextOpId()\n }\n */\n create: function create(id) {\n return {\n start: null,\n end: null,\n struct: 'List',\n id: id\n };\n },\n encode: function encode(op) {\n return {\n struct: 'List',\n id: op.id,\n type: op.type\n };\n },\n requiredOps: function requiredOps() {\n /*\n var ids = []\n if (op.start != null) {\n ids.push(op.start)\n }\n if (op.end != null){\n ids.push(op.end)\n }\n return ids\n */\n return [];\n },\n execute: regeneratorRuntime.mark(function execute(op) {\n return regeneratorRuntime.wrap(function execute$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n op.start = null;\n op.end = null;\n\n case 2:\n case 'end':\n return _context4.stop();\n }\n }\n }, execute, this);\n }),\n ref: regeneratorRuntime.mark(function ref(op, pos) {\n var res, o;\n return regeneratorRuntime.wrap(function ref$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n if (!(op.start == null)) {\n _context5.next = 2;\n break;\n }\n\n return _context5.abrupt('return', null);\n\n case 2:\n res = null;\n return _context5.delegateYield(this.getOperation(op.start), 't0', 4);\n\n case 4:\n o = _context5.t0;\n\n case 5:\n if (!true) {\n _context5.next = 15;\n break;\n }\n\n if (!o.deleted) {\n res = o;\n pos--;\n }\n\n if (!(pos >= 0 && o.right != null)) {\n _context5.next = 12;\n break;\n }\n\n return _context5.delegateYield(this.getOperation(o.right), 't1', 9);\n\n case 9:\n o = _context5.t1;\n _context5.next = 13;\n break;\n\n case 12:\n return _context5.abrupt('break', 15);\n\n case 13:\n _context5.next = 5;\n break;\n\n case 15:\n return _context5.abrupt('return', res);\n\n case 16:\n case 'end':\n return _context5.stop();\n }\n }\n }, ref, this);\n }),\n map: regeneratorRuntime.mark(function map(o, f) {\n var res, operation;\n return regeneratorRuntime.wrap(function map$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n o = o.start;\n res = [];\n\n case 2:\n if (!(o != null)) {\n _context6.next = 9;\n break;\n }\n\n return _context6.delegateYield(this.getOperation(o), 't0', 4);\n\n case 4:\n operation = _context6.t0;\n\n if (!operation.deleted) {\n res.push(f(operation));\n }\n o = operation.right;\n _context6.next = 2;\n break;\n\n case 9:\n return _context6.abrupt('return', res);\n\n case 10:\n case 'end':\n return _context6.stop();\n }\n }\n }, map, this);\n })\n },\n Map: {\n /*\n {\n map: {},\n struct: \"Map\",\n type: \"\",\n id: this.os.getNextOpId()\n }\n */\n create: function create(id) {\n return {\n id: id,\n map: {},\n struct: 'Map'\n };\n },\n encode: function encode(op) {\n return {\n struct: 'Map',\n type: op.type,\n id: op.id,\n map: {} // overwrite map!!\n };\n },\n requiredOps: function requiredOps() {\n return [];\n },\n execute: regeneratorRuntime.mark(function execute() {\n return regeneratorRuntime.wrap(function execute$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n case 'end':\n return _context7.stop();\n }\n }\n }, execute, this);\n }),\n /*\n Get a property by name\n */\n get: regeneratorRuntime.mark(function get(op, name) {\n var oid, res;\n return regeneratorRuntime.wrap(function get$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n oid = op.map[name];\n\n if (!(oid != null)) {\n _context8.next = 14;\n break;\n }\n\n return _context8.delegateYield(this.getOperation(oid), 't0', 3);\n\n case 3:\n res = _context8.t0;\n\n if (!(res == null || res.deleted)) {\n _context8.next = 8;\n break;\n }\n\n return _context8.abrupt('return', void 0);\n\n case 8:\n if (!(res.opContent == null)) {\n _context8.next = 12;\n break;\n }\n\n return _context8.abrupt('return', res.content);\n\n case 12:\n return _context8.delegateYield(this.getType(res.opContent), 't1', 13);\n\n case 13:\n return _context8.abrupt('return', _context8.t1);\n\n case 14:\n case 'end':\n return _context8.stop();\n }\n }\n }, get, this);\n })\n }\n };\n Y.Struct = Struct;\n};\n\n},{}],7:[function(require,module,exports){\n/* @flow */\n'use strict';\n\n/*\n Partial definition of a transaction\n\n A transaction provides all the the async functionality on a database.\n\n By convention, a transaction has the following properties:\n * ss for StateSet\n * os for OperationStore\n * ds for DeleteStore\n\n A transaction must also define the following methods:\n * checkDeleteStoreForState(state)\n - When increasing the state of a user, an operation with an higher id\n may already be garbage collected, and therefore it will never be received.\n update the state to reflect this knowledge. This won't call a method to save the state!\n * getDeleteSet(id)\n - Get the delete set in a readable format:\n {\n \"userX\": [\n [5,1], // starting from position 5, one operations is deleted\n [9,4] // starting from position 9, four operations are deleted\n ],\n \"userY\": ...\n }\n * getOpsFromDeleteSet(ds) -- TODO: just call this.deleteOperation(id) here\n - get a set of deletions that need to be applied in order to get to\n achieve the state of the supplied ds\n * setOperation(op)\n - write `op` to the database.\n Note: this is allowed to return an in-memory object.\n E.g. the Memory adapter returns the object that it has in-memory.\n Changing values on this object will be stored directly in the database\n without calling this function. Therefore,\n setOperation may have no functionality in some adapters. This also has\n implications on the way we use operations that were served from the database.\n We try not to call copyObject, if not necessary.\n * addOperation(op)\n - add an operation to the database.\n This may only be called once for every op.id\n Must return a function that returns the next operation in the database (ordered by id)\n * getOperation(id)\n * removeOperation(id)\n - remove an operation from the database. This is called when an operation\n is garbage collected.\n * setState(state)\n - `state` is of the form\n {\n user: \"1\",\n clock: 4\n } <- meaning that we have four operations from user \"1\"\n (with these id's respectively: 0, 1, 2, and 3)\n * getState(user)\n * getStateVector()\n - Get the state of the OS in the form\n [{\n user: \"userX\",\n clock: 11\n },\n ..\n ]\n * getStateSet()\n - Get the state of the OS in the form\n {\n \"userX\": 11,\n \"userY\": 22\n }\n * getOperations(startSS)\n - Get the all the operations that are necessary in order to achive the\n stateSet of this user, starting from a stateSet supplied by another user\n * makeOperationReady(ss, op)\n - this is called only by `getOperations(startSS)`. It makes an operation\n applyable on a given SS.\n*/\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nmodule.exports = function (Y /* :any */) {\n var TransactionInterface = (function () {\n function TransactionInterface() {\n _classCallCheck(this, TransactionInterface);\n }\n\n _createClass(TransactionInterface, [{\n key: 'getType',\n\n /* ::\n store: Y.AbstractDatabase;\n ds: Store;\n os: Store;\n ss: Store;\n */\n /*\n Get a type based on the id of its model.\n If it does not exist yes, create it.\n TODO: delete type from store.initializedTypes[id] when corresponding id was deleted!\n */\n value: regeneratorRuntime.mark(function getType(id) {\n var sid, t, op /* :MapStruct | ListStruct */;\n return regeneratorRuntime.wrap(function getType$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n sid = JSON.stringify(id);\n t = this.store.initializedTypes[sid];\n\n if (!(t == null)) {\n _context.next = 9;\n break;\n }\n\n return _context.delegateYield(this.getOperation(id), 't0', 4);\n\n case 4:\n op = _context.t0;\n\n if (!(op != null)) {\n _context.next = 9;\n break;\n }\n\n return _context.delegateYield(Y[op.type].initType.call(this, this.store, op), 't1', 7);\n\n case 7:\n t = _context.t1;\n\n this.store.initializedTypes[sid] = t;\n\n case 9:\n return _context.abrupt('return', t);\n\n case 10:\n case 'end':\n return _context.stop();\n }\n }\n }, getType, this);\n })\n }, {\n key: 'createType',\n value: regeneratorRuntime.mark(function createType(typedefinition) {\n var structname, id, op;\n return regeneratorRuntime.wrap(function createType$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n structname = typedefinition.struct;\n id = this.store.getNextOpId();\n op = Y.Struct[structname].create(id);\n\n op.type = typedefinition.name;\n return _context2.delegateYield(this.applyCreatedOperations([op]), 't0', 5);\n\n case 5:\n return _context2.delegateYield(this.getType(id), 't1', 6);\n\n case 6:\n return _context2.abrupt('return', _context2.t1);\n\n case 7:\n case 'end':\n return _context2.stop();\n }\n }\n }, createType, this);\n })\n /*\n Apply operations that this user created (no remote ones!)\n * does not check for Struct.*.requiredOps()\n * also broadcasts it through the connector\n */\n\n }, {\n key: 'applyCreatedOperations',\n value: regeneratorRuntime.mark(function applyCreatedOperations(ops) {\n var send, i, op;\n return regeneratorRuntime.wrap(function applyCreatedOperations$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n send = [];\n i = 0;\n\n case 2:\n if (!(i < ops.length)) {\n _context3.next = 9;\n break;\n }\n\n op = ops[i];\n return _context3.delegateYield(this.store.tryExecute.call(this, op), 't0', 5);\n\n case 5:\n if (op.id == null || op.id[0] !== '_') {\n send.push(Y.Struct[op.struct].encode(op));\n }\n\n case 6:\n i++;\n _context3.next = 2;\n break;\n\n case 9:\n if (!this.store.y.connector.isDisconnected() && send.length > 0) {\n // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops)\n // is connected, and this is not going to be send in addOperation\n this.store.y.connector.broadcastOps(send);\n }\n\n case 10:\n case 'end':\n return _context3.stop();\n }\n }\n }, applyCreatedOperations, this);\n })\n }, {\n key: 'deleteList',\n value: regeneratorRuntime.mark(function deleteList(start) {\n return regeneratorRuntime.wrap(function deleteList$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n if (!this.store.y.connector.isSynced) {\n _context4.next = 12;\n break;\n }\n\n case 1:\n if (!(start != null && this.store.y.connector.isSynced)) {\n _context4.next = 10;\n break;\n }\n\n return _context4.delegateYield(this.getOperation(start), 't0', 3);\n\n case 3:\n start = _context4.t0;\n\n start.gc = true;\n return _context4.delegateYield(this.setOperation(start), 't1', 6);\n\n case 6:\n // TODO: will always reset the parent..\n this.store.gc1.push(start.id);\n start = start.right;\n _context4.next = 1;\n break;\n\n case 10:\n _context4.next = 12;\n break;\n\n case 12:\n case 'end':\n return _context4.stop();\n }\n }\n }, deleteList, this);\n })\n\n /*\n Mark an operation as deleted, and add it to the GC, if possible.\n */\n\n }, {\n key: 'deleteOperation',\n\n // TODO: when not possible??? do later in (gcWhenSynced)\n value: regeneratorRuntime.mark(function deleteOperation(targetId, preventCallType) {\n var target, callType, name, left, right;\n return regeneratorRuntime.wrap(function deleteOperation$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n return _context5.delegateYield(this.getOperation(targetId), 't0', 1);\n\n case 1:\n target = _context5.t0;\n callType = false;\n\n if (!(target == null || !target.deleted)) {\n _context5.next = 5;\n break;\n }\n\n return _context5.delegateYield(this.markDeleted(targetId, 1), 't1', 5);\n\n case 5:\n if (!(target != null && target.gc == null)) {\n _context5.next = 40;\n break;\n }\n\n if (target.deleted) {\n _context5.next = 23;\n break;\n }\n\n callType = true;\n // set deleted & notify type\n target.deleted = true;\n /*\n if (!preventCallType) {\n var type = this.store.initializedTypes[JSON.stringify(target.parent)]\n if (type != null) {\n yield* type._changed(this, {\n struct: 'Delete',\n target: targetId\n })\n }\n }\n */\n // delete containing lists\n\n if (!(target.start != null)) {\n _context5.next = 12;\n break;\n }\n\n return _context5.delegateYield(this.deleteList(target.start), 't2', 11);\n\n case 11:\n return _context5.delegateYield(this.deleteList(target.id), 't3', 12);\n\n case 12:\n if (!(target.map != null)) {\n _context5.next = 20;\n break;\n }\n\n _context5.t4 = regeneratorRuntime.keys(target.map);\n\n case 14:\n if ((_context5.t5 = _context5.t4()).done) {\n _context5.next = 19;\n break;\n }\n\n name = _context5.t5.value;\n return _context5.delegateYield(this.deleteList(target.map[name]), 't6', 17);\n\n case 17:\n _context5.next = 14;\n break;\n\n case 19:\n return _context5.delegateYield(this.deleteList(target.id), 't7', 20);\n\n case 20:\n if (!(target.opContent != null)) {\n _context5.next = 23;\n break;\n }\n\n return _context5.delegateYield(this.deleteOperation(target.opContent), 't8', 22);\n\n case 22:\n target.opContent = null;\n\n case 23:\n if (!(target.left != null)) {\n _context5.next = 28;\n break;\n }\n\n return _context5.delegateYield(this.getOperation(target.left), 't9', 25);\n\n case 25:\n left = _context5.t9;\n _context5.next = 29;\n break;\n\n case 28:\n left = null;\n\n case 29:\n\n this.store.addToGarbageCollector(target, left);\n\n // set here because it was deleted and/or gc'd\n return _context5.delegateYield(this.setOperation(target), 't10', 31);\n\n case 31:\n if (!(target.right != null)) {\n _context5.next = 36;\n break;\n }\n\n return _context5.delegateYield(this.getOperation(target.right), 't11', 33);\n\n case 33:\n right = _context5.t11;\n _context5.next = 37;\n break;\n\n case 36:\n right = null;\n\n case 37:\n if (!(right != null && this.store.addToGarbageCollector(right, target))) {\n _context5.next = 39;\n break;\n }\n\n return _context5.delegateYield(this.setOperation(right), 't12', 39);\n\n case 39:\n return _context5.abrupt('return', callType);\n\n case 40:\n case 'end':\n return _context5.stop();\n }\n }\n }, deleteOperation, this);\n })\n /*\n Mark an operation as deleted&gc'd\n */\n\n }, {\n key: 'markGarbageCollected',\n value: regeneratorRuntime.mark(function markGarbageCollected(id, len) {\n var n, newlen, prev, next;\n return regeneratorRuntime.wrap(function markGarbageCollected$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n return _context6.delegateYield(this.markDeleted(id, len), 't0', 1);\n\n case 1:\n n = _context6.t0;\n\n if (!(n.id[1] < id[1] && !n.gc)) {\n _context6.next = 8;\n break;\n }\n\n // un-extend left\n newlen = n.len - (id[1] - n.id[1]);\n\n n.len -= newlen;\n return _context6.delegateYield(this.ds.put(n), 't1', 6);\n\n case 6:\n n = { id: id, len: newlen, gc: false };\n return _context6.delegateYield(this.ds.put(n), 't2', 8);\n\n case 8:\n return _context6.delegateYield(this.ds.findPrev(id), 't3', 9);\n\n case 9:\n prev = _context6.t3;\n return _context6.delegateYield(this.ds.findNext(id), 't4', 11);\n\n case 11:\n next = _context6.t4;\n\n if (!(id[1] < n.id[1] + n.len - len && !n.gc)) {\n _context6.next = 15;\n break;\n }\n\n return _context6.delegateYield(this.ds.put({ id: [id[0], id[1] + 1], len: n.len - 1, gc: false }), 't5', 14);\n\n case 14:\n n.len = 1;\n\n case 15:\n // set gc'd\n n.gc = true;\n // can extend left?\n\n if (!(prev != null && prev.gc && Y.utils.compareIds([prev.id[0], prev.id[1] + prev.len], n.id))) {\n _context6.next = 20;\n break;\n }\n\n prev.len += n.len;\n return _context6.delegateYield(this.ds.delete(n.id), 't6', 19);\n\n case 19:\n n = prev;\n // ds.put n here?\n\n case 20:\n if (!(next != null && next.gc && Y.utils.compareIds([n.id[0], n.id[1] + n.len], next.id))) {\n _context6.next = 23;\n break;\n }\n\n n.len += next.len;\n return _context6.delegateYield(this.ds.delete(next.id), 't7', 23);\n\n case 23:\n return _context6.delegateYield(this.ds.put(n), 't8', 24);\n\n case 24:\n case 'end':\n return _context6.stop();\n }\n }\n }, markGarbageCollected, this);\n })\n /*\n Mark an operation as deleted.\n returns the delete node\n */\n\n }, {\n key: 'markDeleted',\n value: regeneratorRuntime.mark(function markDeleted(id, length) {\n var n, diff, next;\n return regeneratorRuntime.wrap(function markDeleted$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n if (length == null) {\n length = 1;\n }\n // this.mem.push([\"del\", id]);\n return _context7.delegateYield(this.ds.findWithUpperBound(id), 't0', 2);\n\n case 2:\n n = _context7.t0;\n\n if (!(n != null && n.id[0] === id[0])) {\n _context7.next = 27;\n break;\n }\n\n if (!(n.id[1] <= id[1] && id[1] <= n.id[1] + n.len)) {\n _context7.next = 23;\n break;\n }\n\n // id is in n's range\n diff = id[1] + length - (n.id[1] + n.len); // overlapping right\n\n if (!(diff > 0)) {\n _context7.next = 20;\n break;\n }\n\n if (n.gc) {\n _context7.next = 11;\n break;\n }\n\n n.len += diff;\n _context7.next = 18;\n break;\n\n case 11:\n diff = n.id[1] + n.len - id[1]; // overlapping left (id till n.end)\n\n if (!(diff < length)) {\n _context7.next = 17;\n break;\n }\n\n // a partial deletion\n n = { id: [id[0], id[1] + diff], len: length - diff, gc: false };\n return _context7.delegateYield(this.ds.put(n), 't1', 15);\n\n case 15:\n _context7.next = 18;\n break;\n\n case 17:\n throw new Error('Cannot happen! (it dit though.. :()');\n\n case 18:\n _context7.next = 21;\n break;\n\n case 20:\n return _context7.abrupt('return', n);\n\n case 21:\n _context7.next = 25;\n break;\n\n case 23:\n // cannot extend left (there is no left!)\n n = { id: id, len: length, gc: false };\n return _context7.delegateYield(this.ds.put(n), 't2', 25);\n\n case 25:\n _context7.next = 29;\n break;\n\n case 27:\n // cannot extend left\n n = { id: id, len: length, gc: false };\n return _context7.delegateYield(this.ds.put(n), 't3', 29);\n\n case 29:\n return _context7.delegateYield(this.ds.findNext(n.id), 't4', 30);\n\n case 30:\n next = _context7.t4;\n\n if (!(next != null && n.id[0] === next.id[0] && n.id[1] + n.len >= next.id[1])) {\n _context7.next = 45;\n break;\n }\n\n diff = n.id[1] + n.len - next.id[1]; // from next.start to n.end\n\n if (!next.gc) {\n _context7.next = 40;\n break;\n }\n\n if (!(diff >= 0)) {\n _context7.next = 38;\n break;\n }\n\n n.len -= diff;\n\n if (!(diff > next.len)) {\n _context7.next = 38;\n break;\n }\n\n throw new Error('This case is not handled (on purpose!)');\n\n case 38:\n _context7.next = 45;\n break;\n\n case 40:\n if (!(diff >= 0)) {\n _context7.next = 45;\n break;\n }\n\n if (!(diff > next.len)) {\n _context7.next = 43;\n break;\n }\n\n throw new Error('This case is not handled (on purpose!)');\n\n case 43:\n n.len += next.len - diff;\n return _context7.delegateYield(this.ds.delete(next.id), 't5', 45);\n\n case 45:\n return _context7.delegateYield(this.ds.put(n), 't6', 46);\n\n case 46:\n return _context7.abrupt('return', n);\n\n case 47:\n case 'end':\n return _context7.stop();\n }\n }\n }, markDeleted, this);\n })\n /*\n Call this method when the client is connected&synced with the\n other clients (e.g. master). This will query the database for\n operations that can be gc'd and add them to the garbage collector.\n */\n\n }, {\n key: 'garbageCollectAfterSync',\n value: regeneratorRuntime.mark(function garbageCollectAfterSync() {\n return regeneratorRuntime.wrap(function garbageCollectAfterSync$(_context9) {\n while (1) {\n switch (_context9.prev = _context9.next) {\n case 0:\n return _context9.delegateYield(this.os.iterate(this, null, null, regeneratorRuntime.mark(function _callee(op) {\n var left;\n return regeneratorRuntime.wrap(function _callee$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n if (!(op.deleted && op.left != null)) {\n _context8.next = 4;\n break;\n }\n\n return _context8.delegateYield(this.getOperation(op.left), 't0', 2);\n\n case 2:\n left = _context8.t0;\n\n this.store.addToGarbageCollector(op, left);\n\n case 4:\n case 'end':\n return _context8.stop();\n }\n }\n }, _callee, this);\n })), 't0', 1);\n\n case 1:\n case 'end':\n return _context9.stop();\n }\n }\n }, garbageCollectAfterSync, this);\n })\n /*\n Really remove an op and all its effects.\n The complicated case here is the Insert operation:\n * reset left\n * reset right\n * reset parent.start\n * reset parent.end\n * reset origins of all right ops\n */\n\n }, {\n key: 'garbageCollectOperation',\n value: regeneratorRuntime.mark(function garbageCollectOperation(id) {\n var o, left, right, neworigin, neworigin_, _i, originsIn, origin, parent /* MapOperation */, setParent;\n\n return regeneratorRuntime.wrap(function garbageCollectOperation$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n this.store.addToDebug('yield* this.garbageCollectOperation(', id, ')');\n return _context10.delegateYield(this.getOperation(id), 't0', 2);\n\n case 2:\n o = _context10.t0;\n return _context10.delegateYield(this.markGarbageCollected(id, 1), 't1', 4);\n\n case 4:\n if (!(o != null)) {\n _context10.next = 54;\n break;\n }\n\n if (!(o.left != null)) {\n _context10.next = 10;\n break;\n }\n\n return _context10.delegateYield(this.getOperation(o.left), 't2', 7);\n\n case 7:\n left = _context10.t2;\n\n left.right = o.right;\n return _context10.delegateYield(this.setOperation(left), 't3', 10);\n\n case 10:\n if (!(o.right != null)) {\n _context10.next = 46;\n break;\n }\n\n return _context10.delegateYield(this.getOperation(o.right), 't4', 12);\n\n case 12:\n right = _context10.t4;\n\n right.left = o.left;\n\n if (!(o.originOf != null && o.originOf.length > 0)) {\n _context10.next = 40;\n break;\n }\n\n // find new origin of right ops\n // origin is the first left deleted operation\n neworigin = o.left;\n neworigin_ = null;\n\n case 17:\n if (!(neworigin != null)) {\n _context10.next = 25;\n break;\n }\n\n return _context10.delegateYield(this.getOperation(neworigin), 't5', 19);\n\n case 19:\n neworigin_ = _context10.t5;\n\n if (!neworigin_.deleted) {\n _context10.next = 22;\n break;\n }\n\n return _context10.abrupt('break', 25);\n\n case 22:\n neworigin = neworigin_.left;\n _context10.next = 17;\n break;\n\n case 25:\n _context10.t6 = regeneratorRuntime.keys(o.originOf);\n\n case 26:\n if ((_context10.t7 = _context10.t6()).done) {\n _context10.next = 35;\n break;\n }\n\n _i = _context10.t7.value;\n return _context10.delegateYield(this.getOperation(o.originOf[_i]), 't8', 29);\n\n case 29:\n originsIn = _context10.t8;\n\n if (!(originsIn != null)) {\n _context10.next = 33;\n break;\n }\n\n originsIn.origin = neworigin;\n return _context10.delegateYield(this.setOperation(originsIn), 't9', 33);\n\n case 33:\n _context10.next = 26;\n break;\n\n case 35:\n if (!(neworigin != null)) {\n _context10.next = 38;\n break;\n }\n\n if (neworigin_.originOf == null) {\n neworigin_.originOf = o.originOf;\n } else {\n neworigin_.originOf = o.originOf.concat(neworigin_.originOf);\n }\n return _context10.delegateYield(this.setOperation(neworigin_), 't10', 38);\n\n case 38:\n _context10.next = 41;\n break;\n\n case 40:\n return _context10.delegateYield(this.setOperation(right), 't11', 41);\n\n case 41:\n if (!(o.origin != null)) {\n _context10.next = 46;\n break;\n }\n\n return _context10.delegateYield(this.getOperation(o.origin), 't12', 43);\n\n case 43:\n origin = _context10.t12;\n\n origin.originOf = origin.originOf.filter(function (_id) {\n return !Y.utils.compareIds(id, _id);\n });\n return _context10.delegateYield(this.setOperation(origin), 't13', 46);\n\n case 46:\n if (!(o.parent != null)) {\n _context10.next = 53;\n break;\n }\n\n return _context10.delegateYield(this.getOperation(o.parent), 't14', 48);\n\n case 48:\n parent = _context10.t14;\n setParent = false; // whether to save parent to the os\n\n if (o.parentSub != null) {\n if (Y.utils.compareIds(parent.map[o.parentSub], o.id)) {\n setParent = true;\n parent.map[o.parentSub] = o.right;\n }\n } else {\n if (Y.utils.compareIds(parent.start, o.id)) {\n // gc'd op is the start\n setParent = true;\n parent.start = o.right;\n }\n if (Y.utils.compareIds(parent.end, o.id)) {\n // gc'd op is the end\n setParent = true;\n parent.end = o.left;\n }\n }\n\n if (!setParent) {\n _context10.next = 53;\n break;\n }\n\n return _context10.delegateYield(this.setOperation(parent), 't15', 53);\n\n case 53:\n return _context10.delegateYield(this.removeOperation(o.id), 't16', 54);\n\n case 54:\n case 'end':\n return _context10.stop();\n }\n }\n }, garbageCollectOperation, this);\n })\n }, {\n key: 'checkDeleteStoreForState',\n value: regeneratorRuntime.mark(function checkDeleteStoreForState(state) {\n var n;\n return regeneratorRuntime.wrap(function checkDeleteStoreForState$(_context11) {\n while (1) {\n switch (_context11.prev = _context11.next) {\n case 0:\n return _context11.delegateYield(this.ds.findWithUpperBound([state.user, state.clock]), 't0', 1);\n\n case 1:\n n = _context11.t0;\n\n if (n != null && n.id[0] === state.user && n.gc) {\n state.clock = Math.max(state.clock, n.id[1] + n.len);\n }\n\n case 3:\n case 'end':\n return _context11.stop();\n }\n }\n }, checkDeleteStoreForState, this);\n })\n /*\n apply a delete set in order to get\n the state of the supplied ds\n */\n\n }, {\n key: 'applyDeleteSet',\n value: regeneratorRuntime.mark(function applyDeleteSet(ds) {\n var deletions, createDeletions, user, dv, pos, d, i, del, state, c, id, addOperation, ops;\n return regeneratorRuntime.wrap(function applyDeleteSet$(_context13) {\n while (1) {\n switch (_context13.prev = _context13.next) {\n case 0:\n createDeletions = function createDeletions(user, start, len, gc) {\n deletions.push([user, start, len, gc]);\n };\n\n deletions = [];\n _context13.t0 = regeneratorRuntime.keys(ds);\n\n case 3:\n if ((_context13.t1 = _context13.t0()).done) {\n _context13.next = 12;\n break;\n }\n\n user = _context13.t1.value;\n dv = ds[user];\n pos = 0;\n d = dv[pos];\n return _context13.delegateYield(this.ds.iterate(this, [user, 0], [user, Number.MAX_VALUE], regeneratorRuntime.mark(function _callee2(n) {\n var diff;\n return regeneratorRuntime.wrap(function _callee2$(_context12) {\n while (1) {\n switch (_context12.prev = _context12.next) {\n case 0:\n if (!(d != null)) {\n _context12.next = 10;\n break;\n }\n\n diff = 0; // describe the diff of length in 1) and 2)\n\n if (!(n.id[1] + n.len <= d[0])) {\n _context12.next = 6;\n break;\n }\n\n return _context12.abrupt('break', 10);\n\n case 6:\n if (d[0] < n.id[1]) {\n // 2)\n // delete maximum the len of d\n // else delete as much as possible\n diff = Math.min(n.id[1] - d[0], d[1]);\n createDeletions(user, d[0], diff, d[2]);\n } else {\n // 3)\n diff = n.id[1] + n.len - d[0]; // never null (see 1)\n if (d[2] && !n.gc) {\n // d marks as gc'd but n does not\n // then delete either way\n createDeletions(user, d[0], Math.min(diff, d[1]), d[2]);\n }\n }\n\n case 7:\n if (d[1] <= diff) {\n // d doesn't delete anything anymore\n d = dv[++pos];\n } else {\n d[0] = d[0] + diff; // reset pos\n d[1] = d[1] - diff; // reset length\n }\n _context12.next = 0;\n break;\n\n case 10:\n case 'end':\n return _context12.stop();\n }\n }\n }, _callee2, this);\n })), 't2', 9);\n\n case 9:\n // for the rest.. just apply it\n for (; pos < dv.length; pos++) {\n d = dv[pos];\n createDeletions(user, d[0], d[1], d[2]);\n }\n _context13.next = 3;\n break;\n\n case 12:\n i = 0;\n\n case 13:\n if (!(i < deletions.length)) {\n _context13.next = 46;\n break;\n }\n\n del = deletions[i];\n // always try to delete..\n\n return _context13.delegateYield(this.getState(del[0]), 't3', 16);\n\n case 16:\n state = _context13.t3;\n\n if (!(del[1] < state.clock)) {\n _context13.next = 32;\n break;\n }\n\n c = del[1];\n\n case 19:\n if (!(c < del[1] + del[2])) {\n _context13.next = 30;\n break;\n }\n\n id = [del[0], c];\n return _context13.delegateYield(this.deleteOperation(id), 't4', 22);\n\n case 22:\n addOperation = _context13.t4;\n\n if (!addOperation) {\n _context13.next = 25;\n break;\n }\n\n return _context13.delegateYield(this.store.operationAdded(this, { struct: 'Delete', target: id }), 't5', 25);\n\n case 25:\n if (!del[3]) {\n _context13.next = 27;\n break;\n }\n\n return _context13.delegateYield(this.garbageCollectOperation(id), 't6', 27);\n\n case 27:\n c++;\n _context13.next = 19;\n break;\n\n case 30:\n _context13.next = 37;\n break;\n\n case 32:\n if (!del[3]) {\n _context13.next = 36;\n break;\n }\n\n return _context13.delegateYield(this.markGarbageCollected([del[0], del[1]], del[2]), 't7', 34);\n\n case 34:\n _context13.next = 37;\n break;\n\n case 36:\n return _context13.delegateYield(this.markDeleted([del[0], del[1]], del[2]), 't8', 37);\n\n case 37:\n if (!del[3]) {\n _context13.next = 42;\n break;\n }\n\n if (!(state.clock >= del[1] && state.clock < del[1] + del[2])) {\n _context13.next = 42;\n break;\n }\n\n state.clock = del[1] + del[2];\n // also check if more expected operations were gc'd\n return _context13.delegateYield(this.checkDeleteStoreForState(state), 't9', 41);\n\n case 41:\n return _context13.delegateYield(this.setState(state), 't10', 42);\n\n case 42:\n if (this.store.forwardAppliedOperations) {\n ops = [];\n\n for (c = del[1]; c < del[1] + del[2]; c++) {\n ops.push({ struct: 'Delete', target: [d[0], c] }); // TODO: implement Delete with deletion length!\n }\n this.store.y.connector.broadcastOps(ops);\n }\n\n case 43:\n i++;\n _context13.next = 13;\n break;\n\n case 46:\n case 'end':\n return _context13.stop();\n }\n }\n }, applyDeleteSet, this);\n })\n }, {\n key: 'isGarbageCollected',\n value: regeneratorRuntime.mark(function isGarbageCollected(id) {\n var n;\n return regeneratorRuntime.wrap(function isGarbageCollected$(_context14) {\n while (1) {\n switch (_context14.prev = _context14.next) {\n case 0:\n return _context14.delegateYield(this.ds.findWithUpperBound(id), 't0', 1);\n\n case 1:\n n = _context14.t0;\n return _context14.abrupt('return', n != null && n.id[0] === id[0] && id[1] < n.id[1] + n.len && n.gc);\n\n case 3:\n case 'end':\n return _context14.stop();\n }\n }\n }, isGarbageCollected, this);\n })\n /*\n A DeleteSet (ds) describes all the deleted ops in the OS\n */\n\n }, {\n key: 'getDeleteSet',\n value: regeneratorRuntime.mark(function getDeleteSet() {\n var ds;\n return regeneratorRuntime.wrap(function getDeleteSet$(_context16) {\n while (1) {\n switch (_context16.prev = _context16.next) {\n case 0:\n ds = {};\n return _context16.delegateYield(this.ds.iterate(this, null, null, regeneratorRuntime.mark(function _callee3(n) {\n var user, counter, len, gc, dv;\n return regeneratorRuntime.wrap(function _callee3$(_context15) {\n while (1) {\n switch (_context15.prev = _context15.next) {\n case 0:\n user = n.id[0];\n counter = n.id[1];\n len = n.len;\n gc = n.gc;\n dv = ds[user];\n\n if (dv === void 0) {\n dv = [];\n ds[user] = dv;\n }\n dv.push([counter, len, gc]);\n\n case 7:\n case 'end':\n return _context15.stop();\n }\n }\n }, _callee3, this);\n })), 't0', 2);\n\n case 2:\n return _context16.abrupt('return', ds);\n\n case 3:\n case 'end':\n return _context16.stop();\n }\n }\n }, getDeleteSet, this);\n })\n }, {\n key: 'isDeleted',\n value: regeneratorRuntime.mark(function isDeleted(id) {\n var n;\n return regeneratorRuntime.wrap(function isDeleted$(_context17) {\n while (1) {\n switch (_context17.prev = _context17.next) {\n case 0:\n return _context17.delegateYield(this.ds.findWithUpperBound(id), 't0', 1);\n\n case 1:\n n = _context17.t0;\n return _context17.abrupt('return', n != null && n.id[0] === id[0] && id[1] < n.id[1] + n.len);\n\n case 3:\n case 'end':\n return _context17.stop();\n }\n }\n }, isDeleted, this);\n })\n }, {\n key: 'setOperation',\n value: regeneratorRuntime.mark(function setOperation(op) {\n return regeneratorRuntime.wrap(function setOperation$(_context18) {\n while (1) {\n switch (_context18.prev = _context18.next) {\n case 0:\n return _context18.delegateYield(this.os.put(op), 't0', 1);\n\n case 1:\n return _context18.abrupt('return', op);\n\n case 2:\n case 'end':\n return _context18.stop();\n }\n }\n }, setOperation, this);\n })\n }, {\n key: 'addOperation',\n value: regeneratorRuntime.mark(function addOperation(op) {\n return regeneratorRuntime.wrap(function addOperation$(_context19) {\n while (1) {\n switch (_context19.prev = _context19.next) {\n case 0:\n return _context19.delegateYield(this.os.put(op), 't0', 1);\n\n case 1:\n if (!this.store.y.connector.isDisconnected() && this.store.forwardAppliedOperations && op.id[0] !== '_') {\n // is connected, and this is not going to be send in addOperation\n this.store.y.connector.broadcastOps([op]);\n }\n\n case 2:\n case 'end':\n return _context19.stop();\n }\n }\n }, addOperation, this);\n })\n }, {\n key: 'getOperation',\n value: regeneratorRuntime.mark(function getOperation(id /* :any */) {\n var o, struct, op;\n return regeneratorRuntime.wrap(function getOperation$(_context20) {\n while (1) {\n switch (_context20.prev = _context20.next) {\n case 0:\n return _context20.delegateYield(this.os.find(id), 't0', 1);\n\n case 1:\n o = _context20.t0;\n\n if (!(o != null || id[0] !== '_')) {\n _context20.next = 6;\n break;\n }\n\n return _context20.abrupt('return', o);\n\n case 6:\n if (!(this.store._nextUserId == null)) {\n _context20.next = 13;\n break;\n }\n\n struct = id[1].split('_')[0];\n // this.store._nextUserId = id\n\n op = Y.Struct[struct].create(id);\n return _context20.delegateYield(this.setOperation(op), 't1', 10);\n\n case 10:\n return _context20.abrupt('return', op);\n\n case 13:\n return _context20.abrupt('return', null);\n\n case 14:\n case 'end':\n return _context20.stop();\n }\n }\n }, getOperation, this);\n })\n }, {\n key: 'removeOperation',\n value: regeneratorRuntime.mark(function removeOperation(id) {\n return regeneratorRuntime.wrap(function removeOperation$(_context21) {\n while (1) {\n switch (_context21.prev = _context21.next) {\n case 0:\n return _context21.delegateYield(this.os.delete(id), 't0', 1);\n\n case 1:\n case 'end':\n return _context21.stop();\n }\n }\n }, removeOperation, this);\n })\n }, {\n key: 'setState',\n value: regeneratorRuntime.mark(function setState(state) {\n var val;\n return regeneratorRuntime.wrap(function setState$(_context22) {\n while (1) {\n switch (_context22.prev = _context22.next) {\n case 0:\n val = {\n id: [state.user],\n clock: state.clock\n };\n return _context22.delegateYield(this.ss.put(val), 't0', 2);\n\n case 2:\n case 'end':\n return _context22.stop();\n }\n }\n }, setState, this);\n })\n }, {\n key: 'getState',\n value: regeneratorRuntime.mark(function getState(user) {\n var n, clock;\n return regeneratorRuntime.wrap(function getState$(_context23) {\n while (1) {\n switch (_context23.prev = _context23.next) {\n case 0:\n return _context23.delegateYield(this.ss.find([user]), 't0', 1);\n\n case 1:\n n = _context23.t0;\n clock = n == null ? null : n.clock;\n\n if (clock == null) {\n clock = 0;\n }\n return _context23.abrupt('return', {\n user: user,\n clock: clock\n });\n\n case 5:\n case 'end':\n return _context23.stop();\n }\n }\n }, getState, this);\n })\n }, {\n key: 'getStateVector',\n value: regeneratorRuntime.mark(function getStateVector() {\n var stateVector;\n return regeneratorRuntime.wrap(function getStateVector$(_context25) {\n while (1) {\n switch (_context25.prev = _context25.next) {\n case 0:\n stateVector = [];\n return _context25.delegateYield(this.ss.iterate(this, null, null, regeneratorRuntime.mark(function _callee4(n) {\n return regeneratorRuntime.wrap(function _callee4$(_context24) {\n while (1) {\n switch (_context24.prev = _context24.next) {\n case 0:\n stateVector.push({\n user: n.id[0],\n clock: n.clock\n });\n\n case 1:\n case 'end':\n return _context24.stop();\n }\n }\n }, _callee4, this);\n })), 't0', 2);\n\n case 2:\n return _context25.abrupt('return', stateVector);\n\n case 3:\n case 'end':\n return _context25.stop();\n }\n }\n }, getStateVector, this);\n })\n }, {\n key: 'getStateSet',\n value: regeneratorRuntime.mark(function getStateSet() {\n var ss;\n return regeneratorRuntime.wrap(function getStateSet$(_context27) {\n while (1) {\n switch (_context27.prev = _context27.next) {\n case 0:\n ss = {};\n return _context27.delegateYield(this.ss.iterate(this, null, null, regeneratorRuntime.mark(function _callee5(n) {\n return regeneratorRuntime.wrap(function _callee5$(_context26) {\n while (1) {\n switch (_context26.prev = _context26.next) {\n case 0:\n ss[n.id[0]] = n.clock;\n\n case 1:\n case 'end':\n return _context26.stop();\n }\n }\n }, _callee5, this);\n })), 't0', 2);\n\n case 2:\n return _context27.abrupt('return', ss);\n\n case 3:\n case 'end':\n return _context27.stop();\n }\n }\n }, getStateSet, this);\n })\n /*\n Here, we make all missing operations executable for the receiving user.\n Notes:\n startSS: denotes to the SV that the remote user sent\n currSS: denotes to the state vector that the user should have if he\n applies all already sent operations (increases is each step)\n We face several problems:\n * Execute op as is won't work because ops depend on each other\n -> find a way so that they do not anymore\n * When changing left, must not go more to the left than the origin\n * When changing right, you have to consider that other ops may have op\n as their origin, this means that you must not set one of these ops\n as the new right (interdependencies of ops)\n * can't just go to the right until you find the first known operation,\n With currSS\n -> interdependency of ops is a problem\n With startSS\n -> leads to inconsistencies when two users join at the same time.\n Then the position depends on the order of execution -> error!\n Solution:\n -> re-create originial situation\n -> set op.left = op.origin (which never changes)\n -> set op.right\n to the first operation that is known (according to startSS)\n or to the first operation that has an origin that is not to the\n right of op.\n -> Enforces unique execution order -> happy user\n Improvements: TODO\n * Could set left to origin, or the first known operation\n (startSS or currSS.. ?)\n -> Could be necessary when I turn GC again.\n -> Is a bad(ish) idea because it requires more computation\n What we do:\n * Iterate over all missing operations.\n * When there is an operation, where the right op is known, send this op all missing ops to the left to the user\n * I explained above what we have to do with each operation. Here is how we do it efficiently:\n 1. Go to the left until you find either op.origin, or a known operation (let o denote current operation in the iteration)\n 2. Found a known operation -> set op.left = o, and send it to the user. stop\n 3. Found o = op.origin -> set op.left = op.origin, and send it to the user. start again from 1. (set op = o)\n 4. Found some o -> set o.right = op, o.left = o.origin, send it to the user, continue\n */\n\n }, {\n key: 'getOperations',\n value: regeneratorRuntime.mark(function getOperations(startSS) {\n var send, endSV, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, endState, user, startPos;\n\n return regeneratorRuntime.wrap(function getOperations$(_context29) {\n while (1) {\n switch (_context29.prev = _context29.next) {\n case 0:\n // TODO: use bounds here!\n if (startSS == null) {\n startSS = {};\n }\n send = [];\n return _context29.delegateYield(this.getStateVector(), 't0', 3);\n\n case 3:\n endSV = _context29.t0;\n _iteratorNormalCompletion = true;\n _didIteratorError = false;\n _iteratorError = undefined;\n _context29.prev = 7;\n _iterator = endSV[Symbol.iterator]();\n\n case 9:\n if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {\n _context29.next = 19;\n break;\n }\n\n endState = _step.value;\n user = endState.user;\n\n if (!(user === '_')) {\n _context29.next = 14;\n break;\n }\n\n return _context29.abrupt('continue', 16);\n\n case 14:\n startPos = startSS[user] || 0;\n return _context29.delegateYield(this.os.iterate(this, [user, startPos], [user, Number.MAX_VALUE], regeneratorRuntime.mark(function _callee6(op) {\n var o, missing_origins, newright, s;\n return regeneratorRuntime.wrap(function _callee6$(_context28) {\n while (1) {\n switch (_context28.prev = _context28.next) {\n case 0:\n op = Y.Struct[op.struct].encode(op);\n\n if (!(op.struct !== 'Insert')) {\n _context28.next = 5;\n break;\n }\n\n send.push(op);\n _context28.next = 27;\n break;\n\n case 5:\n if (!(op.right == null || op.right[1] < (startSS[op.right[0]] || 0))) {\n _context28.next = 27;\n break;\n }\n\n // case 1. op.right is known\n o = op;\n // Remember: ?\n // -> set op.right\n // 1. to the first operation that is known (according to startSS)\n // 2. or to the first operation that has an origin that is not to the\n // right of op.\n // For this we maintain a list of ops which origins are not found yet.\n\n missing_origins = [op];\n newright = op.right;\n\n case 9:\n if (!true) {\n _context28.next = 27;\n break;\n }\n\n if (!(o.left == null)) {\n _context28.next = 15;\n break;\n }\n\n op.left = null;\n send.push(op);\n if (!Y.utils.compareIds(o.id, op.id)) {\n o = Y.Struct[op.struct].encode(o);\n o.right = missing_origins[missing_origins.length - 1].id;\n send.push(o);\n }\n return _context28.abrupt('break', 27);\n\n case 15:\n return _context28.delegateYield(this.getOperation(o.left), 't0', 16);\n\n case 16:\n o = _context28.t0;\n\n // we set another o, check if we can reduce $missing_origins\n while (missing_origins.length > 0 && Y.utils.compareIds(missing_origins[missing_origins.length - 1].origin, o.id)) {\n missing_origins.pop();\n }\n\n if (!(o.id[1] < (startSS[o.id[0]] || 0))) {\n _context28.next = 24;\n break;\n }\n\n // case 2. o is known\n op.left = o.id;\n send.push(op);\n return _context28.abrupt('break', 27);\n\n case 24:\n if (Y.utils.compareIds(o.id, op.origin)) {\n // case 3. o is op.origin\n op.left = op.origin;\n send.push(op);\n op = Y.Struct[op.struct].encode(o);\n op.right = newright;\n if (missing_origins.length > 0) {\n console.log('This should not happen .. :( please report this');\n }\n missing_origins = [op];\n } else {\n // case 4. send o, continue to find op.origin\n s = Y.Struct[op.struct].encode(o);\n\n s.right = missing_origins[missing_origins.length - 1].id;\n s.left = s.origin;\n send.push(s);\n missing_origins.push(o);\n }\n\n case 25:\n _context28.next = 9;\n break;\n\n case 27:\n case 'end':\n return _context28.stop();\n }\n }\n }, _callee6, this);\n })), 't1', 16);\n\n case 16:\n _iteratorNormalCompletion = true;\n _context29.next = 9;\n break;\n\n case 19:\n _context29.next = 25;\n break;\n\n case 21:\n _context29.prev = 21;\n _context29.t2 = _context29['catch'](7);\n _didIteratorError = true;\n _iteratorError = _context29.t2;\n\n case 25:\n _context29.prev = 25;\n _context29.prev = 26;\n\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n\n case 28:\n _context29.prev = 28;\n\n if (!_didIteratorError) {\n _context29.next = 31;\n break;\n }\n\n throw _iteratorError;\n\n case 31:\n return _context29.finish(28);\n\n case 32:\n return _context29.finish(25);\n\n case 33:\n return _context29.abrupt('return', send.reverse());\n\n case 34:\n case 'end':\n return _context29.stop();\n }\n }\n }, getOperations, this, [[7, 21, 25, 33], [26,, 28, 32]]);\n })\n /* this is what we used before.. use this as a reference..\n * makeOperationReady (startSS, op) {\n op = Y.Struct[op.struct].encode(op)\n op = Y.utils.copyObject(op)\n var o = op\n var ids = [op.id]\n // search for the new op.right\n // it is either the first known op (according to startSS)\n // or the o that has no origin to the right of op\n // (this is why we use the ids array)\n while (o.right != null) {\n var right = yield* this.getOperation(o.right)\n if (o.right[1] < (startSS[o.right[0]] || 0) || !ids.some(function (id) {\n return Y.utils.compareIds(id, right.origin)\n })) {\n break\n }\n ids.push(o.right)\n o = right\n }\n op.right = o.right\n op.left = op.origin\n return op\n }\n */\n\n }, {\n key: 'flush',\n value: regeneratorRuntime.mark(function flush() {\n return regeneratorRuntime.wrap(function flush$(_context30) {\n while (1) {\n switch (_context30.prev = _context30.next) {\n case 0:\n return _context30.delegateYield(this.os.flush(), 't0', 1);\n\n case 1:\n return _context30.delegateYield(this.ss.flush(), 't1', 2);\n\n case 2:\n return _context30.delegateYield(this.ds.flush(), 't2', 3);\n\n case 3:\n case 'end':\n return _context30.stop();\n }\n }\n }, flush, this);\n })\n }]);\n\n return TransactionInterface;\n })();\n\n Y.Transaction = TransactionInterface;\n};\n\n},{}],8:[function(require,module,exports){\n/* @flow */\n'use strict';\n\n/*\n EventHandler is an helper class for constructing custom types.\n\n Why: When constructing custom types, you sometimes want your types to work\n synchronous: E.g.\n ``` Synchronous\n mytype.setSomething(\"yay\")\n mytype.getSomething() === \"yay\"\n ```\n versus\n ``` Asynchronous\n mytype.setSomething(\"yay\")\n mytype.getSomething() === undefined\n mytype.waitForSomething().then(function(){\n mytype.getSomething() === \"yay\"\n })\n ```\n\n The structures usually work asynchronously (you have to wait for the\n database request to finish). EventHandler helps you to make your type\n synchronous.\n*/\n\nvar _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if (\"value\" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nfunction _typeof(obj) { return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nmodule.exports = function (Y /* : any*/) {\n Y.utils = {};\n\n var EventHandler = (function () {\n /* ::\n waiting: Array<Insertion | Deletion>;\n awaiting: number;\n onevent: Function;\n eventListeners: Array<Function>;\n */\n /*\n onevent: is called when the structure changes.\n Note: \"awaiting opertations\" is used to denote operations that were\n prematurely called. Events for received operations can not be executed until\n all prematurely called operations were executed (\"waiting operations\")\n */\n\n function EventHandler(onevent /* : Function */) {\n _classCallCheck(this, EventHandler);\n\n this.waiting = [];\n this.awaiting = 0;\n this.onevent = onevent;\n this.eventListeners = [];\n }\n\n _createClass(EventHandler, [{\n key: 'destroy',\n value: function destroy() {\n this.waiting = null;\n this.awaiting = null;\n this.onevent = null;\n this.eventListeners = null;\n }\n /*\n Call this when a new operation arrives. It will be executed right away if\n there are no waiting operations, that you prematurely executed\n */\n\n }, {\n key: 'receivedOp',\n value: function receivedOp(op) {\n if (this.awaiting <= 0) {\n this.onevent([op]);\n } else {\n this.waiting.push(Y.utils.copyObject(op));\n }\n }\n /*\n You created some operations, and you want the `onevent` function to be\n called right away. Received operations will not be executed untill all\n prematurely called operations are executed\n */\n\n }, {\n key: 'awaitAndPrematurelyCall',\n value: function awaitAndPrematurelyCall(ops) {\n this.awaiting++;\n this.onevent(ops);\n }\n /*\n Basic event listener boilerplate...\n TODO: maybe put this in a different type..\n */\n\n }, {\n key: 'addEventListener',\n value: function addEventListener(f) {\n this.eventListeners.push(f);\n }\n }, {\n key: 'removeEventListener',\n value: function removeEventListener(f) {\n this.eventListeners = this.eventListeners.filter(function (g) {\n return f !== g;\n });\n }\n }, {\n key: 'removeAllEventListeners',\n value: function removeAllEventListeners() {\n this.eventListeners = [];\n }\n }, {\n key: 'callEventListeners',\n value: function callEventListeners(event) {\n for (var i = 0; i < this.eventListeners.length; i++) {\n try {\n this.eventListeners[i](event);\n } catch (e) {\n console.log('User events must not throw Errors!'); // eslint-disable-line\n }\n }\n }\n /*\n Call this when you successfully awaited the execution of n Insert operations\n */\n\n }, {\n key: 'awaitedInserts',\n value: function awaitedInserts(n) {\n var ops = this.waiting.splice(this.waiting.length - n);\n for (var oid = 0; oid < ops.length; oid++) {\n var op = ops[oid];\n if (op.struct === 'Insert') {\n for (var i = this.waiting.length - 1; i >= 0; i--) {\n var w = this.waiting[i];\n if (w.struct === 'Insert') {\n if (Y.utils.compareIds(op.left, w.id)) {\n // include the effect of op in w\n w.right = op.id;\n // exclude the effect of w in op\n op.left = w.left;\n } else if (Y.utils.compareIds(op.right, w.id)) {\n // similar..\n w.left = op.id;\n op.right = w.right;\n }\n }\n }\n } else {\n throw new Error('Expected Insert Operation!');\n }\n }\n this._tryCallEvents();\n }\n /*\n Call this when you successfully awaited the execution of n Delete operations\n */\n\n }, {\n key: 'awaitedDeletes',\n value: function awaitedDeletes(n, newLeft) {\n var ops = this.waiting.splice(this.waiting.length - n);\n for (var j = 0; j < ops.length; j++) {\n var del = ops[j];\n if (del.struct === 'Delete') {\n if (newLeft != null) {\n for (var i = 0; i < this.waiting.length; i++) {\n var w = this.waiting[i];\n // We will just care about w.left\n if (w.struct === 'Insert' && Y.utils.compareIds(del.target, w.left)) {\n w.left = newLeft;\n }\n }\n }\n } else {\n throw new Error('Expected Delete Operation!');\n }\n }\n this._tryCallEvents();\n }\n /* (private)\n Try to execute the events for the waiting operations\n */\n\n }, {\n key: '_tryCallEvents',\n value: function _tryCallEvents() {\n this.awaiting--;\n if (this.awaiting <= 0 && this.waiting.length > 0) {\n var events = this.waiting;\n this.waiting = [];\n this.onevent(events);\n }\n }\n }]);\n\n return EventHandler;\n })();\n\n Y.utils.EventHandler = EventHandler;\n\n /*\n A wrapper for the definition of a custom type.\n Every custom type must have three properties:\n * struct\n - Structname of this type\n * initType\n - Given a model, creates a custom type\n * class\n - the constructor of the custom type (e.g. in order to inherit from a type)\n */\n\n var CustomType = // eslint-disable-line\n /* ::\n struct: any;\n initType: any;\n class: Function;\n name: String;\n */\n function CustomType(def) {\n _classCallCheck(this, CustomType);\n\n if (def.struct == null || def.initType == null || def.class == null || def.name == null) {\n throw new Error('Custom type was not initialized correctly!');\n }\n this.struct = def.struct;\n this.initType = def.initType;\n this.class = def.class;\n this.name = def.name;\n };\n\n Y.utils.CustomType = CustomType;\n\n /*\n Make a flat copy of an object\n (just copy properties)\n */\n function copyObject(o) {\n var c = {};\n for (var key in o) {\n c[key] = o[key];\n }\n return c;\n }\n Y.utils.copyObject = copyObject;\n\n /*\n Defines a smaller relation on Id's\n */\n function smaller(a, b) {\n return a[0] < b[0] || a[0] === b[0] && (a[1] < b[1] || _typeof(a[1]) < _typeof(b[1]));\n }\n Y.utils.smaller = smaller;\n\n function compareIds(id1, id2) {\n if (id1 == null || id2 == null) {\n if (id1 == null && id2 == null) {\n return true;\n }\n return false;\n }\n if (id1[0] === id2[0] && id1[1] === id2[1]) {\n return true;\n } else {\n return false;\n }\n }\n Y.utils.compareIds = compareIds;\n\n function createEmptyOpsArray(n) {\n var a = new Array(n);\n for (var i = 0; i < a.length; i++) {\n a[i] = {\n id: [null, null]\n };\n }\n return a;\n }\n\n function createSmallLookupBuffer(Store) {\n /*\n This buffer implements a very small buffer that temporarily stores operations\n after they are read / before they are written.\n The buffer basically implements FIFO. Often requested lookups will be re-queued every time they are looked up / written.\n It can speed up lookups on Operation Stores and State Stores. But it does not require notable use of memory or processing power.\n Good for os and ss, bot not for ds (because it often uses methods that require a flush)\n I tried to optimize this for performance, therefore no highlevel operations.\n */\n\n var SmallLookupBuffer = (function (_Store) {\n _inherits(SmallLookupBuffer, _Store);\n\n function SmallLookupBuffer() {\n _classCallCheck(this, SmallLookupBuffer);\n\n var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(SmallLookupBuffer).apply(this, arguments));\n\n _this.writeBuffer = createEmptyOpsArray(5);\n _this.readBuffer = createEmptyOpsArray(10);\n return _this;\n }\n\n _createClass(SmallLookupBuffer, [{\n key: 'find',\n value: regeneratorRuntime.mark(function find(id) {\n var i, r, o;\n return regeneratorRuntime.wrap(function find$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n i = this.readBuffer.length - 1;\n\n case 1:\n if (!(i >= 0)) {\n _context.next = 10;\n break;\n }\n\n r = this.readBuffer[i];\n // we don't have to use compareids, because id is always defined!\n\n if (!(r.id[1] === id[1] && r.id[0] === id[0])) {\n _context.next = 7;\n break;\n }\n\n // found r\n // move r to the end of readBuffer\n for (; i < this.readBuffer.length - 1; i++) {\n this.readBuffer[i] = this.readBuffer[i + 1];\n }\n this.readBuffer[this.readBuffer.length - 1] = r;\n return _context.abrupt('return', r);\n\n case 7:\n i--;\n _context.next = 1;\n break;\n\n case 10:\n i = this.writeBuffer.length - 1;\n\n case 11:\n if (!(i >= 0)) {\n _context.next = 19;\n break;\n }\n\n r = this.writeBuffer[i];\n\n if (!(r.id[1] === id[1] && r.id[0] === id[0])) {\n _context.next = 16;\n break;\n }\n\n o = r;\n return _context.abrupt('break', 19);\n\n case 16:\n i--;\n _context.next = 11;\n break;\n\n case 19:\n if (!(i < 0)) {\n _context.next = 22;\n break;\n }\n\n return _context.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'find', this).call(this, id), 't0', 21);\n\n case 21:\n o = _context.t0;\n\n case 22:\n if (o != null) {\n for (i = 0; i < this.readBuffer.length - 1; i++) {\n this.readBuffer[i] = this.readBuffer[i + 1];\n }\n this.readBuffer[this.readBuffer.length - 1] = o;\n }\n return _context.abrupt('return', o);\n\n case 24:\n case 'end':\n return _context.stop();\n }\n }\n }, find, this);\n })\n }, {\n key: 'put',\n value: regeneratorRuntime.mark(function put(o) {\n var id, i, r, write;\n return regeneratorRuntime.wrap(function put$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n id = o.id;\n i = this.writeBuffer.length - 1;\n\n case 2:\n if (!(i >= 0)) {\n _context2.next = 11;\n break;\n }\n\n r = this.writeBuffer[i];\n\n if (!(r.id[1] === id[1] && r.id[0] === id[0])) {\n _context2.next = 8;\n break;\n }\n\n // is already in buffer\n // forget r, and move o to the end of writeBuffer\n for (; i < this.writeBuffer.length - 1; i++) {\n this.writeBuffer[i] = this.writeBuffer[i + 1];\n }\n this.writeBuffer[this.writeBuffer.length - 1] = o;\n return _context2.abrupt('break', 11);\n\n case 8:\n i--;\n _context2.next = 2;\n break;\n\n case 11:\n if (!(i < 0)) {\n _context2.next = 17;\n break;\n }\n\n // did not reach break in last loop\n // write writeBuffer[0]\n write = this.writeBuffer[0];\n\n if (!(write.id[0] !== null)) {\n _context2.next = 15;\n break;\n }\n\n return _context2.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'put', this).call(this, write), 't0', 15);\n\n case 15:\n // put o to the end of writeBuffer\n for (i = 0; i < this.writeBuffer.length - 1; i++) {\n this.writeBuffer[i] = this.writeBuffer[i + 1];\n }\n this.writeBuffer[this.writeBuffer.length - 1] = o;\n\n case 17:\n // check readBuffer for every occurence of o.id, overwrite if found\n // whether found or not, we'll append o to the readbuffer\n for (i = 0; i < this.readBuffer.length - 1; i++) {\n r = this.readBuffer[i + 1];\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n this.readBuffer[i] = o;\n } else {\n this.readBuffer[i] = r;\n }\n }\n this.readBuffer[this.readBuffer.length - 1] = o;\n\n case 19:\n case 'end':\n return _context2.stop();\n }\n }\n }, put, this);\n })\n }, {\n key: 'delete',\n value: regeneratorRuntime.mark(function _delete(id) {\n var i, r;\n return regeneratorRuntime.wrap(function _delete$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n for (i = 0; i < this.readBuffer.length; i++) {\n r = this.readBuffer[i];\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n this.readBuffer[i] = {\n id: [null, null]\n };\n }\n }\n return _context3.delegateYield(this.flush(), 't0', 2);\n\n case 2:\n return _context3.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'delete', this).call(this, id), 't1', 3);\n\n case 3:\n case 'end':\n return _context3.stop();\n }\n }\n }, _delete, this);\n })\n }, {\n key: 'findWithLowerBound',\n value: regeneratorRuntime.mark(function findWithLowerBound() {\n var _args4 = arguments;\n return regeneratorRuntime.wrap(function findWithLowerBound$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n return _context4.delegateYield(this.flush(), 't0', 1);\n\n case 1:\n return _context4.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'findWithLowerBound', this).apply(this, _args4), 't1', 2);\n\n case 2:\n return _context4.abrupt('return', _context4.t1);\n\n case 3:\n case 'end':\n return _context4.stop();\n }\n }\n }, findWithLowerBound, this);\n })\n }, {\n key: 'findWithUpperBound',\n value: regeneratorRuntime.mark(function findWithUpperBound() {\n var _args5 = arguments;\n return regeneratorRuntime.wrap(function findWithUpperBound$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n return _context5.delegateYield(this.flush(), 't0', 1);\n\n case 1:\n return _context5.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'findWithUpperBound', this).apply(this, _args5), 't1', 2);\n\n case 2:\n return _context5.abrupt('return', _context5.t1);\n\n case 3:\n case 'end':\n return _context5.stop();\n }\n }\n }, findWithUpperBound, this);\n })\n }, {\n key: 'findNext',\n value: regeneratorRuntime.mark(function findNext() {\n var _args6 = arguments;\n return regeneratorRuntime.wrap(function findNext$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n return _context6.delegateYield(this.flush(), 't0', 1);\n\n case 1:\n return _context6.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'findNext', this).apply(this, _args6), 't1', 2);\n\n case 2:\n return _context6.abrupt('return', _context6.t1);\n\n case 3:\n case 'end':\n return _context6.stop();\n }\n }\n }, findNext, this);\n })\n }, {\n key: 'findPrev',\n value: regeneratorRuntime.mark(function findPrev() {\n var _args7 = arguments;\n return regeneratorRuntime.wrap(function findPrev$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n return _context7.delegateYield(this.flush(), 't0', 1);\n\n case 1:\n return _context7.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'findPrev', this).apply(this, _args7), 't1', 2);\n\n case 2:\n return _context7.abrupt('return', _context7.t1);\n\n case 3:\n case 'end':\n return _context7.stop();\n }\n }\n }, findPrev, this);\n })\n }, {\n key: 'iterate',\n value: regeneratorRuntime.mark(function iterate() {\n var _args8 = arguments;\n return regeneratorRuntime.wrap(function iterate$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n return _context8.delegateYield(this.flush(), 't0', 1);\n\n case 1:\n return _context8.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'iterate', this).apply(this, _args8), 't1', 2);\n\n case 2:\n case 'end':\n return _context8.stop();\n }\n }\n }, iterate, this);\n })\n }, {\n key: 'flush',\n value: regeneratorRuntime.mark(function flush() {\n var i, write;\n return regeneratorRuntime.wrap(function flush$(_context9) {\n while (1) {\n switch (_context9.prev = _context9.next) {\n case 0:\n i = 0;\n\n case 1:\n if (!(i < this.writeBuffer.length)) {\n _context9.next = 9;\n break;\n }\n\n write = this.writeBuffer[i];\n\n if (!(write.id[0] !== null)) {\n _context9.next = 6;\n break;\n }\n\n return _context9.delegateYield(_get(Object.getPrototypeOf(SmallLookupBuffer.prototype), 'put', this).call(this, write), 't0', 5);\n\n case 5:\n this.writeBuffer[i] = {\n id: [null, null]\n };\n\n case 6:\n i++;\n _context9.next = 1;\n break;\n\n case 9:\n case 'end':\n return _context9.stop();\n }\n }\n }, flush, this);\n })\n }]);\n\n return SmallLookupBuffer;\n })(Store);\n\n return SmallLookupBuffer;\n }\n Y.utils.createSmallLookupBuffer = createSmallLookupBuffer;\n};\n\n},{}],9:[function(require,module,exports){\n/* @flow */\n'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nrequire('./Connector.js')(Y);\nrequire('./Database.js')(Y);\nrequire('./Transaction.js')(Y);\nrequire('./Struct.js')(Y);\nrequire('./Utils.js')(Y);\nrequire('./Connectors/Test.js')(Y);\n\nvar requiringModules = {};\n\nmodule.exports = Y;\nY.requiringModules = requiringModules;\n\nY.extend = function (name, value) {\n Y[name] = value;\n if (requiringModules[name] != null) {\n requiringModules[name].resolve();\n delete requiringModules[name];\n }\n};\n\nY.requestModules = requestModules;\nfunction requestModules(modules) {\n // determine if this module was compiled for es5 or es6 (y.js vs. y.es6)\n // if Insert.execute is a Function, then it isnt a generator..\n // then load the es5(.js) files..\n var extention = typeof regeneratorRuntime !== 'undefined' ? '.js' : '.es6';\n var promises = [];\n for (var i = 0; i < modules.length; i++) {\n var modulename = 'y-' + modules[i].toLowerCase();\n if (Y[modules[i]] == null) {\n if (requiringModules[modules[i]] == null) {\n // module does not exist\n if (typeof window !== 'undefined' && window.Y !== 'undefined') {\n var imported;\n\n (function () {\n imported = document.createElement('script');\n\n imported.src = Y.sourceDir + '/' + modulename + '/' + modulename + extention;\n document.head.appendChild(imported);\n\n var requireModule = {};\n requiringModules[modules[i]] = requireModule;\n requireModule.promise = new Promise(function (resolve) {\n requireModule.resolve = resolve;\n });\n promises.push(requireModule.promise);\n })();\n } else {\n require(modulename)(Y);\n }\n } else {\n promises.push(requiringModules[modules[i]].promise);\n }\n }\n }\n return Promise.all(promises);\n}\n\n/* ::\ntype MemoryOptions = {\n name: 'memory'\n}\ntype IndexedDBOptions = {\n name: 'indexeddb',\n namespace: string\n}\ntype DbOptions = MemoryOptions | IndexedDBOptions\n\ntype WebRTCOptions = {\n name: 'webrtc',\n room: string\n}\ntype WebsocketsClientOptions = {\n name: 'websockets-client',\n room: string\n}\ntype ConnectionOptions = WebRTCOptions | WebsocketsClientOptions\n\ntype YOptions = {\n connector: ConnectionOptions,\n db: DbOptions,\n types: Array<TypeName>,\n sourceDir: string,\n share: {[key: string]: TypeName}\n}\n*/\n\nfunction Y(opts /* :YOptions */) /* :Promise<YConfig> */{\n opts.types = opts.types != null ? opts.types : [];\n var modules = [opts.db.name, opts.connector.name].concat(opts.types);\n for (var name in opts.share) {\n modules.push(opts.share[name]);\n }\n Y.sourceDir = opts.sourceDir;\n return Y.requestModules(modules).then(function () {\n return new Promise(function (resolve) {\n var yconfig = new YConfig(opts);\n yconfig.db.whenUserIdSet(function () {\n yconfig.init(function () {\n resolve(yconfig);\n });\n });\n });\n });\n}\n\nvar YConfig = (function () {\n /* ::\n db: Y.AbstractDatabase;\n connector: Y.AbstractConnector;\n share: {[key: string]: any};\n options: Object;\n */\n\n function YConfig(opts, callback) {\n _classCallCheck(this, YConfig);\n\n this.options = opts;\n this.db = new Y[opts.db.name](this, opts.db);\n this.connector = new Y[opts.connector.name](this, opts.connector);\n }\n\n _createClass(YConfig, [{\n key: 'init',\n value: function init(callback) {\n var opts = this.options;\n var share = {};\n this.share = share;\n this.db.requestTransaction(regeneratorRuntime.mark(function requestTransaction() {\n var propertyname, typename, id, op;\n return regeneratorRuntime.wrap(function requestTransaction$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.t0 = regeneratorRuntime.keys(opts.share);\n\n case 1:\n if ((_context.t1 = _context.t0()).done) {\n _context.next = 14;\n break;\n }\n\n propertyname = _context.t1.value;\n typename = opts.share[propertyname];\n id = ['_', Y[typename].struct + '_' + propertyname];\n return _context.delegateYield(this.getOperation(id), 't2', 6);\n\n case 6:\n op = _context.t2;\n\n if (!(op.type !== typename)) {\n _context.next = 10;\n break;\n }\n\n // not already in the db\n op.type = typename;\n return _context.delegateYield(this.setOperation(op), 't3', 10);\n\n case 10:\n return _context.delegateYield(this.getType(id), 't4', 11);\n\n case 11:\n share[propertyname] = _context.t4;\n _context.next = 1;\n break;\n\n case 14:\n this.store.whenTransactionsFinished().then(callback);\n\n case 15:\n case 'end':\n return _context.stop();\n }\n }\n }, requestTransaction, this);\n }));\n }\n }, {\n key: 'isConnected',\n value: function isConnected() {\n return this.connector.isSynced;\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n return this.connector.disconnect();\n }\n }, {\n key: 'reconnect',\n value: function reconnect() {\n return this.connector.reconnect();\n }\n }, {\n key: 'destroy',\n value: function destroy() {\n if (this.connector.destroy != null) {\n this.connector.destroy();\n } else {\n this.connector.disconnect();\n }\n var self = this;\n this.db.requestTransaction(regeneratorRuntime.mark(function _callee() {\n return regeneratorRuntime.wrap(function _callee$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n return _context2.delegateYield(self.db.destroy(), 't0', 1);\n\n case 1:\n self.connector = null;\n self.db = null;\n\n case 3:\n case 'end':\n return _context2.stop();\n }\n }\n }, _callee, this);\n }));\n }\n }]);\n\n return YConfig;\n})();\n\nif (typeof window !== 'undefined') {\n window.Y = Y;\n}\n\n},{\"./Connector.js\":3,\"./Connectors/Test.js\":4,\"./Database.js\":5,\"./Struct.js\":6,\"./Transaction.js\":7,\"./Utils.js\":8}]},{},[2,9])\n\n","/**\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 $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\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 var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\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 GeneratorFunctionPrototype[toStringTagSymbol] = 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 if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\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 function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value instanceof AwaitArgument) {\n return Promise.resolve(value.arg).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration. If the Promise is rejected, however, the\n // result for this iteration will be rejected with the same\n // reason. Note that rejections of yielded Promises are not\n // thrown back into the generator function, as is the case\n // when an awaited Promise is rejected. This difference in\n // behavior between yield and await is important, because it\n // allows the consumer to decide what to do with the yielded\n // rejection (swallow it and continue, manually .throw it back\n // into the generator, abandon iteration, whatever). With\n // await, by contrast, there is no opportunity to examine the\n // rejection reason outside the generator function, so the\n // only option is to throw it from the await expression, and\n // let the generator function handle the exception.\n result.value = unwrapped;\n resolve(result);\n }, reject);\n }\n }\n\n if (typeof process === \"object\" && process.domain) {\n invoke = process.domain.bind(invoke);\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\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(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\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 if (method === \"throw\") {\n throw arg;\n }\n\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 context.sent = undefined;\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[toStringTagSymbol] = \"Generator\";\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(true);\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(skipTempReset) {\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 if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\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","/* @flow */\n'use strict'\n\nmodule.exports = function (Y/* :any */) {\n class AbstractConnector {\n /* ::\n y: YConfig;\n role: SyncRole;\n connections: Object;\n isSynced: boolean;\n userEventListeners: Array<Function>;\n whenSyncedListeners: Array<Function>;\n currentSyncTarget: ?UserId;\n syncingClients: Array<UserId>;\n forwardToSyncingClients: boolean;\n debug: boolean;\n broadcastedHB: boolean;\n syncStep2: Promise;\n userId: UserId;\n send: Function;\n broadcast: Function;\n */\n /*\n opts contains the following information:\n role : String Role of this client (\"master\" or \"slave\")\n userId : String Uniquely defines the user.\n debug: Boolean Whether to print debug messages (optional)\n */\n constructor (y, opts) {\n this.y = y\n if (opts == null) {\n opts = {}\n }\n if (opts.role == null || opts.role === 'master') {\n this.role = 'master'\n } else if (opts.role === 'slave') {\n this.role = 'slave'\n } else {\n throw new Error(\"Role must be either 'master' or 'slave'!\")\n }\n this.y.db.forwardAppliedOperations = opts.forwardAppliedOperations || false\n this.role = opts.role\n this.connections = {}\n this.isSynced = false\n this.userEventListeners = []\n this.whenSyncedListeners = []\n this.currentSyncTarget = null\n this.syncingClients = []\n this.forwardToSyncingClients = opts.forwardToSyncingClients !== false\n this.debug = opts.debug === true\n this.broadcastedHB = false\n this.syncStep2 = Promise.resolve()\n this.broadcastOpBuffer = []\n }\n reconnect () {\n }\n disconnect () {\n this.connections = {}\n this.isSynced = false\n this.currentSyncTarget = null\n this.broadcastedHB = false\n this.syncingClients = []\n this.whenSyncedListeners = []\n return this.y.db.stopGarbageCollector()\n }\n setUserId (userId) {\n if (this.userId == null) {\n this.userId = userId\n return this.y.db.setUserId(userId)\n } else {\n return null\n }\n }\n onUserEvent (f) {\n this.userEventListeners.push(f)\n }\n userLeft (user) {\n if (this.connections[user] != null) {\n delete this.connections[user]\n if (user === this.currentSyncTarget) {\n this.currentSyncTarget = null\n this.findNextSyncTarget()\n }\n this.syncingClients = this.syncingClients.filter(function (cli) {\n return cli !== user\n })\n for (var f of this.userEventListeners) {\n f({\n action: 'userLeft',\n user: user\n })\n }\n }\n }\n userJoined (user, role) {\n if (role == null) {\n throw new Error('You must specify the role of the joined user!')\n }\n if (this.connections[user] != null) {\n throw new Error('This user already joined!')\n }\n this.connections[user] = {\n isSynced: false,\n role: role\n }\n for (var f of this.userEventListeners) {\n f({\n action: 'userJoined',\n user: user,\n role: role\n })\n }\n if (this.currentSyncTarget == null) {\n this.findNextSyncTarget()\n }\n }\n // Execute a function _when_ we are connected.\n // If not connected, wait until connected\n whenSynced (f) {\n if (this.isSynced) {\n f()\n } else {\n this.whenSyncedListeners.push(f)\n }\n }\n /*\n\n returns false, if there is no sync target\n true otherwise\n */\n findNextSyncTarget () {\n if (this.currentSyncTarget != null || this.isSynced) {\n return // \"The current sync has not finished!\"\n }\n\n var syncUser = null\n for (var uid in this.connections) {\n if (!this.connections[uid].isSynced) {\n syncUser = uid\n break\n }\n }\n if (syncUser != null) {\n var conn = this\n this.currentSyncTarget = syncUser\n this.y.db.requestTransaction(function *() {\n var stateSet = yield* this.getStateSet()\n var deleteSet = yield* this.getDeleteSet()\n conn.send(syncUser, {\n type: 'sync step 1',\n stateSet: stateSet,\n deleteSet: deleteSet\n })\n })\n } else {\n this.isSynced = true\n // call when synced listeners\n for (var f of this.whenSyncedListeners) {\n f()\n }\n this.whenSyncedListeners = []\n this.y.db.requestTransaction(function *() {\n yield* this.garbageCollectAfterSync()\n })\n }\n }\n send (uid, message) {\n if (this.debug) {\n console.log(`send ${this.userId} -> ${uid}: ${message.type}`, message) // eslint-disable-line\n }\n }\n /*\n Buffer operations, and broadcast them when ready.\n */\n broadcastOps (ops) {\n ops = ops.map(function (op) {\n return Y.Struct[op.struct].encode(op)\n })\n var self = this\n function broadcastOperations () {\n if (self.broadcastOpBuffer.length > 0) {\n self.broadcast({\n type: 'update',\n ops: self.broadcastOpBuffer\n })\n self.broadcastOpBuffer = []\n }\n }\n if (this.broadcastOpBuffer.length === 0) {\n this.broadcastOpBuffer = ops\n if (this.y.db.transactionInProgress) {\n this.y.db.whenTransactionsFinished().then(broadcastOperations)\n } else {\n setTimeout(broadcastOperations, 0)\n }\n } else {\n this.broadcastOpBuffer = this.broadcastOpBuffer.concat(ops)\n }\n }\n /*\n You received a raw message, and you know that it is intended for Yjs. Then call this function.\n */\n receiveMessage (sender/* :UserId */, message/* :Message */) {\n if (sender === this.userId) {\n return\n }\n if (this.debug) {\n console.log(`receive ${sender} -> ${this.userId}: ${message.type}`, JSON.parse(JSON.stringify(message))) // eslint-disable-line\n }\n if (message.type === 'sync step 1') {\n // TODO: make transaction, stream the ops\n let conn = this\n let m = message\n this.y.db.requestTransaction(function *() {\n var currentStateSet = yield* this.getStateSet()\n yield* this.applyDeleteSet(m.deleteSet)\n\n var ds = yield* this.getDeleteSet()\n var ops = yield* this.getOperations(m.stateSet)\n conn.send(sender, {\n type: 'sync step 2',\n os: ops,\n stateSet: currentStateSet,\n deleteSet: ds\n })\n if (this.forwardToSyncingClients) {\n conn.syncingClients.push(sender)\n setTimeout(function () {\n conn.syncingClients = conn.syncingClients.filter(function (cli) {\n return cli !== sender\n })\n conn.send(sender, {\n type: 'sync done'\n })\n }, 5000) // TODO: conn.syncingClientDuration)\n } else {\n conn.send(sender, {\n type: 'sync done'\n })\n }\n conn._setSyncedWith(sender)\n })\n } else if (message.type === 'sync step 2') {\n let conn = this\n var broadcastHB = !this.broadcastedHB\n this.broadcastedHB = true\n var db = this.y.db\n var defer = {}\n defer.promise = new Promise(function (resolve) {\n defer.resolve = resolve\n })\n this.syncStep2 = defer.promise\n let m /* :MessageSyncStep2 */ = message\n db.requestTransaction(function * () {\n yield* this.applyDeleteSet(m.deleteSet)\n this.store.apply(m.os)\n db.requestTransaction(function * () {\n var ops = yield* this.getOperations(m.stateSet)\n if (ops.length > 0) {\n if (!broadcastHB) { // TODO: consider to broadcast here..\n conn.send(sender, {\n type: 'update',\n ops: ops\n })\n } else {\n // broadcast only once!\n conn.broadcastOps(ops)\n }\n }\n defer.resolve()\n })\n })\n } else if (message.type === 'sync done') {\n var self = this\n this.syncStep2.then(function () {\n self._setSyncedWith(sender)\n })\n } else if (message.type === 'update') {\n if (this.forwardToSyncingClients) {\n for (var client of this.syncingClients) {\n this.send(client, message)\n }\n }\n if (this.y.db.forwardAppliedOperations) {\n var delops = message.ops.filter(function (o) {\n return o.struct === 'Delete'\n })\n if (delops.length > 0) {\n this.broadcastOps(delops)\n }\n }\n this.y.db.apply(message.ops)\n }\n }\n _setSyncedWith (user) {\n var conn = this.connections[user]\n if (conn != null) {\n conn.isSynced = true\n }\n if (user === this.currentSyncTarget) {\n this.currentSyncTarget = null\n this.findNextSyncTarget()\n }\n }\n /*\n Currently, the HB encodes operations as JSON. For the moment I want to keep it\n that way. Maybe we support encoding in the HB as XML in the future, but for now I don't want\n too much overhead. Y is very likely to get changed a lot in the future\n\n Because we don't want to encode JSON as string (with character escaping, wich makes it pretty much unreadable)\n we encode the JSON as XML.\n\n When the HB support encoding as XML, the format should look pretty much like this.\n\n does not support primitive values as array elements\n expects an ltx (less than xml) object\n */\n parseMessageFromXml (m/* :any */) {\n function parseArray (node) {\n for (var n of node.children) {\n if (n.getAttribute('isArray') === 'true') {\n return parseArray(n)\n } else {\n return parseObject(n)\n }\n }\n }\n function parseObject (node/* :any */) {\n var json = {}\n for (var attrName in node.attrs) {\n var value = node.attrs[attrName]\n var int = parseInt(value, 10)\n if (isNaN(int) || ('' + int) !== value) {\n json[attrName] = value\n } else {\n json[attrName] = int\n }\n }\n for (var n/* :any */ in node.children) {\n var name = n.name\n if (n.getAttribute('isArray') === 'true') {\n json[name] = parseArray(n)\n } else {\n json[name] = parseObject(n)\n }\n }\n return json\n }\n parseObject(m)\n }\n /*\n encode message in xml\n we use string because Strophe only accepts an \"xml-string\"..\n So {a:4,b:{c:5}} will look like\n <y a=\"4\">\n <b c=\"5\"></b>\n </y>\n m - ltx element\n json - Object\n */\n encodeMessageToXml (msg, obj) {\n // attributes is optional\n function encodeObject (m, json) {\n for (var name in json) {\n var value = json[name]\n if (name == null) {\n // nop\n } else if (value.constructor === Object) {\n encodeObject(m.c(name), value)\n } else if (value.constructor === Array) {\n encodeArray(m.c(name), value)\n } else {\n m.setAttribute(name, value)\n }\n }\n }\n function encodeArray (m, array) {\n m.setAttribute('isArray', 'true')\n for (var e of array) {\n if (e.constructor === Object) {\n encodeObject(m.c('array-element'), e)\n } else {\n encodeArray(m.c('array-element'), e)\n }\n }\n }\n if (obj.constructor === Object) {\n encodeObject(msg.c('y', { xmlns: 'http://y.ninja/connector-stanza' }), obj)\n } else if (obj.constructor === Array) {\n encodeArray(msg.c('y', { xmlns: 'http://y.ninja/connector-stanza' }), obj)\n } else {\n throw new Error(\"I can't encode this json!\")\n }\n }\n }\n Y.AbstractConnector = AbstractConnector\n}\n","/* global getRandom, async */\n'use strict'\n\nmodule.exports = function (Y) {\n var globalRoom = {\n users: {},\n buffers: {},\n removeUser: function (user) {\n for (var i in this.users) {\n this.users[i].userLeft(user)\n }\n delete this.users[user]\n delete this.buffers[user]\n },\n addUser: function (connector) {\n this.users[connector.userId] = connector\n this.buffers[connector.userId] = []\n for (var uname in this.users) {\n if (uname !== connector.userId) {\n var u = this.users[uname]\n u.userJoined(connector.userId, 'master')\n connector.userJoined(u.userId, 'master')\n }\n }\n },\n whenTransactionsFinished: function () {\n var ps = []\n for (var name in this.users) {\n ps.push(this.users[name].y.db.whenTransactionsFinished())\n }\n return Promise.all(ps)\n },\n flushOne: function flushOne () {\n var bufs = []\n for (var i in globalRoom.buffers) {\n if (globalRoom.buffers[i].length > 0) {\n bufs.push(i)\n }\n }\n if (bufs.length > 0) {\n var userId = getRandom(bufs)\n var m = globalRoom.buffers[userId].shift()\n var user = globalRoom.users[userId]\n user.receiveMessage(m[0], m[1])\n return user.y.db.whenTransactionsFinished()\n } else {\n return false\n }\n },\n flushAll: function () {\n return new Promise(function (resolve) {\n // flushes may result in more created operations,\n // flush until there is nothing more to flush\n function nextFlush () {\n var c = globalRoom.flushOne()\n if (c) {\n while (c) {\n c = globalRoom.flushOne()\n }\n globalRoom.whenTransactionsFinished().then(nextFlush)\n } else {\n setTimeout(function () {\n var c = globalRoom.flushOne()\n if (c) {\n c.then(function () {\n globalRoom.whenTransactionsFinished().then(nextFlush)\n })\n } else {\n resolve()\n }\n }, 10)\n }\n }\n globalRoom.whenTransactionsFinished().then(nextFlush)\n })\n }\n }\n Y.utils.globalRoom = globalRoom\n\n var userIdCounter = 0\n\n class Test extends Y.AbstractConnector {\n constructor (y, options) {\n if (options === undefined) {\n throw new Error('Options must not be undefined!')\n }\n options.role = 'master'\n options.forwardToSyncingClients = false\n super(y, options)\n this.setUserId((userIdCounter++) + '').then(() => {\n globalRoom.addUser(this)\n })\n this.globalRoom = globalRoom\n this.syncingClientDuration = 0\n }\n receiveMessage (sender, m) {\n super.receiveMessage(sender, JSON.parse(JSON.stringify(m)))\n }\n send (userId, message) {\n var buffer = globalRoom.buffers[userId]\n if (buffer != null) {\n buffer.push(JSON.parse(JSON.stringify([this.userId, message])))\n }\n }\n broadcast (message) {\n for (var key in globalRoom.buffers) {\n globalRoom.buffers[key].push(JSON.parse(JSON.stringify([this.userId, message])))\n }\n }\n isDisconnected () {\n return globalRoom.users[this.userId] == null\n }\n reconnect () {\n if (this.isDisconnected()) {\n globalRoom.addUser(this)\n super.reconnect()\n }\n return Y.utils.globalRoom.flushAll()\n }\n disconnect () {\n if (!this.isDisconnected()) {\n globalRoom.removeUser(this.userId)\n super.disconnect()\n }\n return this.y.db.whenTransactionsFinished()\n }\n flush () {\n var self = this\n return async(function * () {\n while (globalRoom.buffers[self.userId].length > 0) {\n var m = globalRoom.buffers[self.userId].shift()\n this.receiveMessage(m[0], m[1])\n }\n yield self.whenTransactionsFinished()\n })\n }\n }\n\n Y.Test = Test\n}\n","/* @flow */\n'use strict'\n\nmodule.exports = function (Y /* :any */) {\n /*\n Partial definition of an OperationStore.\n TODO: name it Database, operation store only holds operations.\n\n A database definition must alse define the following methods:\n * logTable() (optional)\n - show relevant information information in a table\n * requestTransaction(makeGen)\n - request a transaction\n * destroy()\n - destroy the database\n */\n class AbstractDatabase {\n /* ::\n y: YConfig;\n forwardAppliedOperations: boolean;\n listenersById: Object;\n listenersByIdExecuteNow: Array<Object>;\n listenersByIdRequestPending: boolean;\n initializedTypes: Object;\n whenUserIdSetListener: ?Function;\n waitingTransactions: Array<Transaction>;\n transactionInProgress: boolean;\n executeOrder: Array<Object>;\n gc1: Array<Struct>;\n gc2: Array<Struct>;\n gcTimeout: number;\n gcInterval: any;\n garbageCollect: Function;\n executeOrder: Array<any>; // for debugging only\n userId: UserId;\n opClock: number;\n transactionsFinished: ?{promise: Promise, resolve: any};\n transact: (x: ?Generator) => any;\n */\n constructor (y, opts) {\n this.y = y\n var os = this\n this.userId = null\n var resolve\n this.userIdPromise = new Promise(function (r) {\n resolve = r\n })\n this.userIdPromise.resolve = resolve\n // whether to broadcast all applied operations (insert & delete hook)\n this.forwardAppliedOperations = false\n // E.g. this.listenersById[id] : Array<Listener>\n this.listenersById = {}\n // Execute the next time a transaction is requested\n this.listenersByIdExecuteNow = []\n // A transaction is requested\n this.listenersByIdRequestPending = false\n /* To make things more clear, the following naming conventions:\n * ls : we put this.listenersById on ls\n * l : Array<Listener>\n * id : Id (can't use as property name)\n * sid : String (converted from id via JSON.stringify\n so we can use it as a property name)\n\n Always remember to first overwrite\n a property before you iterate over it!\n */\n // TODO: Use ES7 Weak Maps. This way types that are no longer user,\n // wont be kept in memory.\n this.initializedTypes = {}\n this.waitingTransactions = []\n this.transactionInProgress = false\n this.transactionIsFlushed = false\n if (typeof YConcurrency_TestingMode !== 'undefined') {\n this.executeOrder = []\n }\n this.gc1 = [] // first stage\n this.gc2 = [] // second stage -> after that, remove the op\n this.gcTimeout = opts.gcTimeout || 50000\n function garbageCollect () {\n return os.whenTransactionsFinished().then(function () {\n if (os.gc1.length > 0 || os.gc2.length > 0) {\n return new Promise((resolve) => {\n os.requestTransaction(function * () {\n if (os.y.connector != null && os.y.connector.isSynced) {\n for (var i = 0; i < os.gc2.length; i++) {\n var oid = os.gc2[i]\n yield* this.garbageCollectOperation(oid)\n }\n os.gc2 = os.gc1\n os.gc1 = []\n }\n // TODO: Use setInterval here instead (when garbageCollect is called several times there will be several timeouts..)\n if (os.gcTimeout > 0) {\n os.gcInterval = setTimeout(garbageCollect, os.gcTimeout)\n }\n resolve()\n })\n })\n } else {\n // TODO: see above\n if (os.gcTimeout > 0) {\n os.gcInterval = setTimeout(garbageCollect, os.gcTimeout)\n }\n return Promise.resolve()\n }\n })\n }\n this.garbageCollect = garbageCollect\n if (this.gcTimeout > 0) {\n garbageCollect()\n }\n }\n addToDebug () {\n if (typeof YConcurrency_TestingMode !== 'undefined') {\n var command /* :string */ = Array.prototype.map.call(arguments, function (s) {\n if (typeof s === 'string') {\n return s\n } else {\n return JSON.stringify(s)\n }\n }).join('').replace(/\"/g, \"'\").replace(/,/g, ', ').replace(/:/g, ': ')\n this.executeOrder.push(command)\n }\n }\n getDebugData () {\n console.log(this.executeOrder.join('\\n'))\n }\n stopGarbageCollector () {\n var self = this\n return new Promise(function (resolve) {\n self.requestTransaction(function * () {\n var ungc /* :Array<Struct> */ = self.gc1.concat(self.gc2)\n self.gc1 = []\n self.gc2 = []\n for (var i = 0; i < ungc.length; i++) {\n var op = yield* this.getOperation(ungc[i])\n delete op.gc\n yield* this.setOperation(op)\n }\n resolve()\n })\n })\n }\n /*\n Try to add to GC.\n\n TODO: rename this function\n\n Rulez:\n * Only gc if this user is online\n * The most left element in a list must not be gc'd.\n => There is at least one element in the list\n\n returns true iff op was added to GC\n */\n addToGarbageCollector (op, left) {\n if (\n op.gc == null &&\n op.deleted === true &&\n this.y.connector.isSynced &&\n left != null &&\n left.deleted === true\n ) {\n op.gc = true\n this.gc1.push(op.id)\n return true\n } else {\n return false\n }\n }\n removeFromGarbageCollector (op) {\n function filter (o) {\n return !Y.utils.compareIds(o, op.id)\n }\n this.gc1 = this.gc1.filter(filter)\n this.gc2 = this.gc2.filter(filter)\n delete op.gc\n }\n * destroy () {\n clearInterval(this.gcInterval)\n this.gcInterval = null\n for (var key in this.initializedTypes) {\n var type = this.initializedTypes[key]\n if (type._destroy != null) {\n type._destroy()\n } else {\n console.error('The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).')\n }\n }\n }\n setUserId (userId) {\n if (!this.userIdPromise.inProgress) {\n this.userIdPromise.inProgress = true\n var self = this\n self.requestTransaction(function * () {\n self.userId = userId\n var state = yield* this.getState(userId)\n self.opClock = state.clock\n self.userIdPromise.resolve(userId)\n })\n }\n return this.userIdPromise\n }\n whenUserIdSet (f) {\n this.userIdPromise.then(f)\n }\n getNextOpId () {\n if (this._nextUserId != null) {\n return this._nextUserId\n } else if (this.userId == null) {\n throw new Error('OperationStore not yet initialized!')\n } else {\n return [this.userId, this.opClock++]\n }\n }\n /*\n Apply a list of operations.\n\n * get a transaction\n * check whether all Struct.*.requiredOps are in the OS\n * check if it is an expected op (otherwise wait for it)\n * check if was deleted, apply a delete operation after op was applied\n */\n apply (ops) {\n for (var i = 0; i < ops.length; i++) {\n var o = ops[i]\n if (o.id == null || o.id[0] !== this.y.connector.userId) {\n var required = Y.Struct[o.struct].requiredOps(o)\n this.whenOperationsExist(required, o)\n }\n }\n }\n /*\n op is executed as soon as every operation requested is available.\n Note that Transaction can (and should) buffer requests.\n */\n whenOperationsExist (ids, op) {\n if (ids.length > 0) {\n let listener = {\n op: op,\n missing: ids.length\n }\n\n for (let i = 0; i < ids.length; i++) {\n let id = ids[i]\n let sid = JSON.stringify(id)\n let l = this.listenersById[sid]\n if (l == null) {\n l = []\n this.listenersById[sid] = l\n }\n l.push(listener)\n }\n } else {\n this.listenersByIdExecuteNow.push({\n op: op\n })\n }\n\n if (this.listenersByIdRequestPending) {\n return\n }\n\n this.listenersByIdRequestPending = true\n var store = this\n\n this.requestTransaction(function * () {\n var exeNow = store.listenersByIdExecuteNow\n store.listenersByIdExecuteNow = []\n\n var ls = store.listenersById\n store.listenersById = {}\n\n store.listenersByIdRequestPending = false\n\n for (let key = 0; key < exeNow.length; key++) {\n let o = exeNow[key].op\n yield* store.tryExecute.call(this, o)\n }\n\n for (var sid in ls) {\n var l = ls[sid]\n var id = JSON.parse(sid)\n var op = yield* this.getOperation(id)\n if (op == null) {\n store.listenersById[sid] = l\n } else {\n for (let i = 0; i < l.length; i++) {\n let listener = l[i]\n let o = listener.op\n if (--listener.missing === 0) {\n yield* store.tryExecute.call(this, o)\n }\n }\n }\n }\n })\n }\n /*\n Actually execute an operation, when all expected operations are available.\n */\n /* :: // TODO: this belongs somehow to transaction\n store: Object;\n getOperation: any;\n isGarbageCollected: any;\n addOperation: any;\n whenOperationsExist: any;\n */\n * tryExecute (op) {\n this.store.addToDebug('yield* this.store.tryExecute.call(this, ', JSON.stringify(op), ')')\n if (op.struct === 'Delete') {\n yield* Y.Struct.Delete.execute.call(this, op)\n yield* this.store.operationAdded(this, op)\n } else {\n var defined = yield* this.getOperation(op.id)\n if (defined == null) {\n var isGarbageCollected = yield* this.isGarbageCollected(op.id)\n if (!isGarbageCollected) {\n yield* Y.Struct[op.struct].execute.call(this, op)\n yield* this.addOperation(op)\n yield* this.store.operationAdded(this, op)\n }\n }\n }\n }\n // called by a transaction when an operation is added\n * operationAdded (transaction, op) {\n if (op.struct === 'Delete') {\n var target = yield* transaction.getOperation(op.target)\n if (target != null) {\n var type = transaction.store.initializedTypes[JSON.stringify(target.parent)]\n if (type != null) {\n yield* type._changed(transaction, {\n struct: 'Delete',\n target: op.target\n })\n }\n }\n } else {\n // increase SS\n var o = op\n var state = yield* transaction.getState(op.id[0])\n while (o != null && o.id[1] === state.clock && op.id[0] === o.id[0]) {\n // either its a new operation (1. case), or it is an operation that was deleted, but is not yet in the OS\n state.clock++\n yield* transaction.checkDeleteStoreForState(state)\n o = yield* transaction.os.findNext(o.id)\n }\n yield* transaction.setState(state)\n\n // notify whenOperation listeners (by id)\n var sid = JSON.stringify(op.id)\n var l = this.listenersById[sid]\n delete this.listenersById[sid]\n\n if (l != null) {\n for (var key in l) {\n var listener = l[key]\n if (--listener.missing === 0) {\n this.whenOperationsExist([], listener.op)\n }\n }\n }\n var t = this.initializedTypes[JSON.stringify(op.parent)]\n\n // Delete if DS says this is actually deleted\n var opIsDeleted = yield* transaction.isDeleted(op.id)\n if (!op.deleted && opIsDeleted) {\n var delop = {\n struct: 'Delete',\n target: op.id\n }\n yield* Y.Struct['Delete'].execute.call(transaction, delop)\n }\n\n // notify parent, if it was instanciated as a custom type\n if (t != null) {\n yield* t._changed(transaction, Y.utils.copyObject(op))\n }\n }\n }\n whenTransactionsFinished () {\n if (this.transactionInProgress) {\n if (this.transactionsFinished == null) {\n var resolve\n var promise = new Promise(function (r) {\n resolve = r\n })\n this.transactionsFinished = {\n resolve: resolve,\n promise: promise\n }\n return promise\n } else {\n return this.transactionsFinished.promise\n }\n } else {\n return Promise.resolve()\n }\n }\n // Check if there is another transaction request.\n // * the last transaction is always a flush :)\n getNextRequest () {\n if (this.waitingTransactions.length === 0) {\n if (this.transactionIsFlushed) {\n this.transactionInProgress = false\n this.transactionIsFlushed = false\n if (this.transactionsFinished != null) {\n this.transactionsFinished.resolve()\n this.transactionsFinished = null\n }\n return null\n } else {\n this.transactionIsFlushed = true\n return function * () {\n yield* this.flush()\n }\n }\n } else {\n this.transactionIsFlushed = false\n return this.waitingTransactions.shift()\n }\n }\n requestTransaction (makeGen/* :any */, callImmediately) {\n this.waitingTransactions.push(makeGen)\n if (!this.transactionInProgress) {\n this.transactionInProgress = true\n if (false || callImmediately) { // TODO: decide whether this is ok or not..\n this.transact(this.getNextRequest())\n } else {\n var self = this\n setTimeout(function () {\n self.transact(self.getNextRequest())\n }, 0)\n }\n }\n }\n }\n Y.AbstractDatabase = AbstractDatabase\n}\n","/* @flow */\n'use strict'\n\n/*\n An operation also defines the structure of a type. This is why operation and\n structure are used interchangeably here.\n\n It must be of the type Object. I hope to achieve some performance\n improvements when working on databases that support the json format.\n\n An operation must have the following properties:\n\n * encode\n - Encode the structure in a readable format (preferably string- todo)\n * decode (todo)\n - decode structure to json\n * execute\n - Execute the semantics of an operation.\n * requiredOps\n - Operations that are required to execute this operation.\n*/\nmodule.exports = function (Y/* :any */) {\n var Struct = {\n /* This is the only operation that is actually not a structure, because\n it is not stored in the OS. This is why it _does not_ have an id\n\n op = {\n target: Id\n }\n */\n Delete: {\n encode: function (op) {\n return op\n },\n requiredOps: function (op) {\n return [] // [op.target]\n },\n execute: function * (op) {\n return yield* this.deleteOperation(op.target)\n }\n },\n Insert: {\n /* {\n content: any,\n id: Id,\n left: Id,\n origin: Id,\n right: Id,\n parent: Id,\n parentSub: string (optional), // child of Map type\n }\n */\n encode: function (op/* :Insertion */) /* :Insertion */ {\n // TODO: you could not send the \"left\" property, then you also have to\n // \"op.left = null\" in $execute or $decode\n var e/* :any */ = {\n id: op.id,\n left: op.left,\n right: op.right,\n origin: op.origin,\n parent: op.parent,\n struct: op.struct\n }\n if (op.parentSub != null) {\n e.parentSub = op.parentSub\n }\n if (op.opContent != null) {\n e.opContent = op.opContent\n } else {\n e.content = op.content\n }\n\n return e\n },\n requiredOps: function (op) {\n var ids = []\n if (op.left != null) {\n ids.push(op.left)\n }\n if (op.right != null) {\n ids.push(op.right)\n }\n if (op.origin != null && !Y.utils.compareIds(op.left, op.origin)) {\n ids.push(op.origin)\n }\n // if (op.right == null && op.left == null) {\n ids.push(op.parent)\n\n if (op.opContent != null) {\n ids.push(op.opContent)\n }\n return ids\n },\n getDistanceToOrigin: function * (op) {\n if (op.left == null) {\n return 0\n } else {\n var d = 0\n var o = yield* this.getOperation(op.left)\n while (!Y.utils.compareIds(op.origin, (o ? o.id : null))) {\n d++\n if (o.left == null) {\n break\n } else {\n o = yield* this.getOperation(o.left)\n }\n }\n return d\n }\n },\n /*\n # $this has to find a unique position between origin and the next known character\n # case 1: $origin equals $o.origin: the $creator parameter decides if left or right\n # let $OL= [o1,o2,o3,o4], whereby $this is to be inserted between o1 and o4\n # o2,o3 and o4 origin is 1 (the position of o2)\n # there is the case that $this.creator < o2.creator, but o3.creator < $this.creator\n # then o2 knows o3. Since on another client $OL could be [o1,o3,o4] the problem is complex\n # therefore $this would be always to the right of o3\n # case 2: $origin < $o.origin\n # if current $this insert_position > $o origin: $this ins\n # else $insert_position will not change\n # (maybe we encounter case 1 later, then this will be to the right of $o)\n # case 3: $origin > $o.origin\n # $this insert_position is to the left of $o (forever!)\n */\n execute: function *(op) {\n var i // loop counter\n var distanceToOrigin = i = yield* Struct.Insert.getDistanceToOrigin.call(this, op) // most cases: 0 (starts from 0)\n\n if (op.origin != null) { // TODO: !== instead of !=\n // we save in origin that op originates in it\n // we need that later when we eventually garbage collect origin (see transaction)\n var origin = yield* this.getOperation(op.origin)\n if (origin.originOf == null) {\n origin.originOf = []\n }\n origin.originOf.push(op.id)\n yield* this.setOperation(origin)\n }\n\n // now we begin to insert op in the list of insertions..\n var o\n var parent\n var start\n\n // find o. o is the first conflicting operation\n if (op.left != null) {\n o = yield* this.getOperation(op.left)\n o = (o.right == null) ? null : yield* this.getOperation(o.right)\n } else { // left == null\n parent = yield* this.getOperation(op.parent)\n let startId = op.parentSub ? parent.map[op.parentSub] : parent.start\n start = startId == null ? null : yield* this.getOperation(startId)\n o = start\n }\n\n // handle conflicts\n while (true) {\n if (o != null && !Y.utils.compareIds(o.id, op.right)) {\n var oOriginDistance = yield* Struct.Insert.getDistanceToOrigin.call(this, o)\n if (oOriginDistance === i) {\n // case 1\n if (o.id[0] < op.id[0]) {\n op.left = o.id\n distanceToOrigin = i + 1\n }\n } else if (oOriginDistance < i) {\n // case 2\n if (i - distanceToOrigin <= oOriginDistance) {\n op.left = o.id\n distanceToOrigin = i + 1\n }\n } else {\n break\n }\n i++\n if (o.right != null) {\n o = yield* this.getOperation(o.right)\n } else {\n o = null\n }\n } else {\n break\n }\n }\n\n // reconnect..\n var left = null\n var right = null\n if (parent == null) {\n parent = yield* this.getOperation(op.parent)\n }\n\n // reconnect left and set right of op\n if (op.left != null) {\n left = yield* this.getOperation(op.left)\n op.right = left.right\n left.right = op.id\n\n yield* this.setOperation(left)\n } else {\n op.right = op.parentSub ? parent.map[op.parentSub] || null : parent.start\n }\n // reconnect right\n if (op.right != null) {\n right = yield* this.getOperation(op.right)\n right.left = op.id\n\n // if right exists, and it is supposed to be gc'd. Remove it from the gc\n if (right.gc != null) {\n this.store.removeFromGarbageCollector(right)\n }\n yield* this.setOperation(right)\n }\n\n // update parents .map/start/end properties\n if (op.parentSub != null) {\n if (left == null) {\n parent.map[op.parentSub] = op.id\n yield* this.setOperation(parent)\n }\n // is a child of a map struct.\n // Then also make sure that only the most left element is not deleted\n if (op.right != null) {\n yield* this.deleteOperation(op.right, true)\n }\n if (op.left != null) {\n yield* this.deleteOperation(op.id, true)\n }\n } else {\n if (right == null || left == null) {\n if (right == null) {\n parent.end = op.id\n }\n if (left == null) {\n parent.start = op.id\n }\n yield* this.setOperation(parent)\n }\n }\n }\n },\n List: {\n /*\n {\n start: null,\n end: null,\n struct: \"List\",\n type: \"\",\n id: this.os.getNextOpId()\n }\n */\n create: function (id) {\n return {\n start: null,\n end: null,\n struct: 'List',\n id: id\n }\n },\n encode: function (op) {\n return {\n struct: 'List',\n id: op.id,\n type: op.type\n }\n },\n requiredOps: function () {\n /*\n var ids = []\n if (op.start != null) {\n ids.push(op.start)\n }\n if (op.end != null){\n ids.push(op.end)\n }\n return ids\n */\n return []\n },\n execute: function * (op) {\n op.start = null\n op.end = null\n },\n ref: function * (op, pos) {\n if (op.start == null) {\n return null\n }\n var res = null\n var o = yield* this.getOperation(op.start)\n\n while (true) {\n if (!o.deleted) {\n res = o\n pos--\n }\n if (pos >= 0 && o.right != null) {\n o = yield* this.getOperation(o.right)\n } else {\n break\n }\n }\n return res\n },\n map: function * (o, f) {\n o = o.start\n var res = []\n while (o != null) { // TODO: change to != (at least some convention)\n var operation = yield* this.getOperation(o)\n if (!operation.deleted) {\n res.push(f(operation))\n }\n o = operation.right\n }\n return res\n }\n },\n Map: {\n /*\n {\n map: {},\n struct: \"Map\",\n type: \"\",\n id: this.os.getNextOpId()\n }\n */\n create: function (id) {\n return {\n id: id,\n map: {},\n struct: 'Map'\n }\n },\n encode: function (op) {\n return {\n struct: 'Map',\n type: op.type,\n id: op.id,\n map: {} // overwrite map!!\n }\n },\n requiredOps: function () {\n return []\n },\n execute: function * () {},\n /*\n Get a property by name\n */\n get: function * (op, name) {\n var oid = op.map[name]\n if (oid != null) {\n var res = yield* this.getOperation(oid)\n if (res == null || res.deleted) {\n return void 0\n } else if (res.opContent == null) {\n return res.content\n } else {\n return yield* this.getType(res.opContent)\n }\n }\n }\n }\n }\n Y.Struct = Struct\n}\n","/* @flow */\n'use strict'\n\n/*\n Partial definition of a transaction\n\n A transaction provides all the the async functionality on a database.\n\n By convention, a transaction has the following properties:\n * ss for StateSet\n * os for OperationStore\n * ds for DeleteStore\n\n A transaction must also define the following methods:\n * checkDeleteStoreForState(state)\n - When increasing the state of a user, an operation with an higher id\n may already be garbage collected, and therefore it will never be received.\n update the state to reflect this knowledge. This won't call a method to save the state!\n * getDeleteSet(id)\n - Get the delete set in a readable format:\n {\n \"userX\": [\n [5,1], // starting from position 5, one operations is deleted\n [9,4] // starting from position 9, four operations are deleted\n ],\n \"userY\": ...\n }\n * getOpsFromDeleteSet(ds) -- TODO: just call this.deleteOperation(id) here\n - get a set of deletions that need to be applied in order to get to\n achieve the state of the supplied ds\n * setOperation(op)\n - write `op` to the database.\n Note: this is allowed to return an in-memory object.\n E.g. the Memory adapter returns the object that it has in-memory.\n Changing values on this object will be stored directly in the database\n without calling this function. Therefore,\n setOperation may have no functionality in some adapters. This also has\n implications on the way we use operations that were served from the database.\n We try not to call copyObject, if not necessary.\n * addOperation(op)\n - add an operation to the database.\n This may only be called once for every op.id\n Must return a function that returns the next operation in the database (ordered by id)\n * getOperation(id)\n * removeOperation(id)\n - remove an operation from the database. This is called when an operation\n is garbage collected.\n * setState(state)\n - `state` is of the form\n {\n user: \"1\",\n clock: 4\n } <- meaning that we have four operations from user \"1\"\n (with these id's respectively: 0, 1, 2, and 3)\n * getState(user)\n * getStateVector()\n - Get the state of the OS in the form\n [{\n user: \"userX\",\n clock: 11\n },\n ..\n ]\n * getStateSet()\n - Get the state of the OS in the form\n {\n \"userX\": 11,\n \"userY\": 22\n }\n * getOperations(startSS)\n - Get the all the operations that are necessary in order to achive the\n stateSet of this user, starting from a stateSet supplied by another user\n * makeOperationReady(ss, op)\n - this is called only by `getOperations(startSS)`. It makes an operation\n applyable on a given SS.\n*/\nmodule.exports = function (Y/* :any */) {\n class TransactionInterface {\n /* ::\n store: Y.AbstractDatabase;\n ds: Store;\n os: Store;\n ss: Store;\n */\n /*\n Get a type based on the id of its model.\n If it does not exist yes, create it.\n TODO: delete type from store.initializedTypes[id] when corresponding id was deleted!\n */\n * getType (id) {\n var sid = JSON.stringify(id)\n var t = this.store.initializedTypes[sid]\n if (t == null) {\n var op/* :MapStruct | ListStruct */ = yield* this.getOperation(id)\n if (op != null) {\n t = yield* Y[op.type].initType.call(this, this.store, op)\n this.store.initializedTypes[sid] = t\n }\n }\n return t\n }\n * createType (typedefinition) {\n var structname = typedefinition.struct\n var id = this.store.getNextOpId()\n var op = Y.Struct[structname].create(id)\n op.type = typedefinition.name\n yield* this.applyCreatedOperations([op])\n return yield* this.getType(id)\n }\n /*\n Apply operations that this user created (no remote ones!)\n * does not check for Struct.*.requiredOps()\n * also broadcasts it through the connector\n */\n * applyCreatedOperations (ops) {\n var send = []\n for (var i = 0; i < ops.length; i++) {\n var op = ops[i]\n yield* this.store.tryExecute.call(this, op)\n if (op.id == null || op.id[0] !== '_') {\n send.push(Y.Struct[op.struct].encode(op))\n }\n }\n if (!this.store.y.connector.isDisconnected() && send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops)\n // is connected, and this is not going to be send in addOperation\n this.store.y.connector.broadcastOps(send)\n }\n }\n\n * deleteList (start) {\n if (this.store.y.connector.isSynced) {\n while (start != null && this.store.y.connector.isSynced) {\n start = yield* this.getOperation(start)\n start.gc = true\n yield* this.setOperation(start)\n // TODO: will always reset the parent..\n this.store.gc1.push(start.id)\n start = start.right\n }\n } else {\n // TODO: when not possible??? do later in (gcWhenSynced)\n }\n }\n\n /*\n Mark an operation as deleted, and add it to the GC, if possible.\n */\n * deleteOperation (targetId, preventCallType) /* :Generator<any, any, any> */ {\n var target = yield* this.getOperation(targetId)\n var callType = false\n\n if (target == null || !target.deleted) {\n yield* this.markDeleted(targetId, 1)\n }\n\n if (target != null && target.gc == null) {\n if (!target.deleted) {\n callType = true\n // set deleted & notify type\n target.deleted = true\n /*\n if (!preventCallType) {\n var type = this.store.initializedTypes[JSON.stringify(target.parent)]\n if (type != null) {\n yield* type._changed(this, {\n struct: 'Delete',\n target: targetId\n })\n }\n }\n */\n // delete containing lists\n if (target.start != null) {\n // TODO: don't do it like this .. -.-\n yield* this.deleteList(target.start)\n yield* this.deleteList(target.id)\n }\n if (target.map != null) {\n for (var name in target.map) {\n yield* this.deleteList(target.map[name])\n }\n // TODO: here to.. (see above)\n yield* this.deleteList(target.id)\n }\n if (target.opContent != null) {\n yield* this.deleteOperation(target.opContent)\n target.opContent = null\n }\n }\n var left\n if (target.left != null) {\n left = yield* this.getOperation(target.left)\n } else {\n left = null\n }\n\n this.store.addToGarbageCollector(target, left)\n\n // set here because it was deleted and/or gc'd\n yield* this.setOperation(target)\n\n /*\n Check if it is possible to add right to the gc.\n Because this delete can't be responsible for left being gc'd,\n we don't have to add left to the gc..\n */\n var right\n if (target.right != null) {\n right = yield* this.getOperation(target.right)\n } else {\n right = null\n }\n if (\n right != null &&\n this.store.addToGarbageCollector(right, target)\n ) {\n yield* this.setOperation(right)\n }\n return callType\n }\n }\n /*\n Mark an operation as deleted&gc'd\n */\n * markGarbageCollected (id, len) {\n // this.mem.push([\"gc\", id]);\n var n = yield* this.markDeleted(id, len)\n if (n.id[1] < id[1] && !n.gc) {\n // un-extend left\n var newlen = n.len - (id[1] - n.id[1])\n n.len -= newlen\n yield* this.ds.put(n)\n n = {id: id, len: newlen, gc: false}\n yield* this.ds.put(n)\n }\n // get prev&next before adding a new operation\n var prev = yield* this.ds.findPrev(id)\n var next = yield* this.ds.findNext(id)\n\n if (id[1] < n.id[1] + n.len - len && !n.gc) {\n // un-extend right\n yield* this.ds.put({id: [id[0], id[1] + 1], len: n.len - 1, gc: false})\n n.len = 1\n }\n // set gc'd\n n.gc = true\n // can extend left?\n if (\n prev != null &&\n prev.gc &&\n Y.utils.compareIds([prev.id[0], prev.id[1] + prev.len], n.id)\n ) {\n prev.len += n.len\n yield* this.ds.delete(n.id)\n n = prev\n // ds.put n here?\n }\n // can extend right?\n if (\n next != null &&\n next.gc &&\n Y.utils.compareIds([n.id[0], n.id[1] + n.len], next.id)\n ) {\n n.len += next.len\n yield* this.ds.delete(next.id)\n }\n yield* this.ds.put(n)\n }\n /*\n Mark an operation as deleted.\n\n returns the delete node\n */\n * markDeleted (id, length) {\n if (length == null) {\n length = 1\n }\n // this.mem.push([\"del\", id]);\n var n = yield* this.ds.findWithUpperBound(id)\n if (n != null && n.id[0] === id[0]) {\n if (n.id[1] <= id[1] && id[1] <= n.id[1] + n.len) {\n // id is in n's range\n var diff = id[1] + length - (n.id[1] + n.len) // overlapping right\n if (diff > 0) {\n // id+length overlaps n\n if (!n.gc) {\n n.len += diff\n } else {\n diff = n.id[1] + n.len - id[1] // overlapping left (id till n.end)\n if (diff < length) {\n // a partial deletion\n n = {id: [id[0], id[1] + diff], len: length - diff, gc: false}\n yield* this.ds.put(n)\n } else {\n // already gc'd\n throw new Error('Cannot happen! (it dit though.. :()')\n // return n\n }\n }\n } else {\n // no overlapping, already deleted\n return n\n }\n } else {\n // cannot extend left (there is no left!)\n n = {id: id, len: length, gc: false}\n yield* this.ds.put(n) // TODO: you double-put !!\n }\n } else {\n // cannot extend left\n n = {id: id, len: length, gc: false}\n yield* this.ds.put(n)\n }\n // can extend right?\n var next = yield* this.ds.findNext(n.id)\n if (\n next != null &&\n n.id[0] === next.id[0] &&\n n.id[1] + n.len >= next.id[1]\n ) {\n diff = n.id[1] + n.len - next.id[1] // from next.start to n.end\n if (next.gc) {\n if (diff >= 0) {\n n.len -= diff\n if (diff > next.len) {\n // need to create another deletion after $next\n // TODO: (may not be necessary, because this case shouldn't happen!)\n // also this is supposed to return a deletion range. which one to choose? n or the new created deletion?\n throw new Error('This case is not handled (on purpose!)')\n }\n } // else: everything is fine :)\n } else {\n if (diff >= 0) {\n if (diff > next.len) {\n // may be neccessary to extend next.next!\n // TODO: (may not be necessary, because this case shouldn't happen!)\n throw new Error('This case is not handled (on purpose!)')\n }\n n.len += next.len - diff\n yield* this.ds.delete(next.id)\n }\n }\n }\n yield* this.ds.put(n)\n return n\n }\n /*\n Call this method when the client is connected&synced with the\n other clients (e.g. master). This will query the database for\n operations that can be gc'd and add them to the garbage collector.\n */\n * garbageCollectAfterSync () {\n yield* this.os.iterate(this, null, null, function * (op) {\n if (op.deleted && op.left != null) {\n var left = yield* this.getOperation(op.left)\n this.store.addToGarbageCollector(op, left)\n }\n })\n }\n /*\n Really remove an op and all its effects.\n The complicated case here is the Insert operation:\n * reset left\n * reset right\n * reset parent.start\n * reset parent.end\n * reset origins of all right ops\n */\n * garbageCollectOperation (id) {\n this.store.addToDebug('yield* this.garbageCollectOperation(', id, ')')\n var o = yield* this.getOperation(id)\n yield* this.markGarbageCollected(id, 1) // always mark gc'd\n // if op exists, then clean that mess up..\n if (o != null) {\n /*\n if (!o.deleted) {\n yield* this.deleteOperation(id)\n o = yield* this.getOperation(id)\n }\n */\n\n // remove gc'd op from the left op, if it exists\n if (o.left != null) {\n var left = yield* this.getOperation(o.left)\n left.right = o.right\n yield* this.setOperation(left)\n }\n // remove gc'd op from the right op, if it exists\n // also reset origins of right ops\n if (o.right != null) {\n var right = yield* this.getOperation(o.right)\n right.left = o.left\n\n if (o.originOf != null && o.originOf.length > 0) {\n // find new origin of right ops\n // origin is the first left deleted operation\n var neworigin = o.left\n var neworigin_ = null\n while (neworigin != null) {\n neworigin_ = yield* this.getOperation(neworigin)\n if (neworigin_.deleted) {\n break\n }\n neworigin = neworigin_.left\n }\n\n // reset origin of all right ops (except first right - duh!),\n\n /* ** The following code does not rely on the the originOf property **\n I recently added originOf to all Insert Operations (see Struct.Insert.execute),\n which saves which operations originate in a Insert operation.\n Garbage collecting without originOf is more memory efficient, but is nearly impossible for large texts, or lists!\n But I keep this code for now\n ```\n // reset origin of right\n right.origin = neworigin\n // search until you find origin pointer to the left of o\n if (right.right != null) {\n var i = yield* this.getOperation(right.right)\n var ids = [o.id, o.right]\n while (ids.some(function (id) {\n return Y.utils.compareIds(id, i.origin)\n })) {\n if (Y.utils.compareIds(i.origin, o.id)) {\n // reset origin of i\n i.origin = neworigin\n yield* this.setOperation(i)\n }\n // get next i\n if (i.right == null) {\n break\n } else {\n ids.push(i.id)\n i = yield* this.getOperation(i.right)\n }\n }\n }\n ```\n */\n // ** Now the new implementation starts **\n // reset neworigin of all originOf[*]\n for (var _i in o.originOf) {\n var originsIn = yield* this.getOperation(o.originOf[_i])\n if (originsIn != null) {\n originsIn.origin = neworigin\n yield* this.setOperation(originsIn)\n }\n }\n if (neworigin != null) {\n if (neworigin_.originOf == null) {\n neworigin_.originOf = o.originOf\n } else {\n neworigin_.originOf = o.originOf.concat(neworigin_.originOf)\n }\n yield* this.setOperation(neworigin_)\n }\n // we don't need to set right here, because\n // right should be in o.originOf => it is set it the previous for loop\n } else {\n // we didn't need to reset the origin of right\n // so we have to set right here\n yield* this.setOperation(right)\n }\n // o may originate in another operation.\n // Since o is deleted, we have to reset o.origin's `originOf` property\n if (o.origin != null) {\n var origin = yield* this.getOperation(o.origin)\n origin.originOf = origin.originOf.filter(function (_id) {\n return !Y.utils.compareIds(id, _id)\n })\n yield* this.setOperation(origin)\n }\n }\n\n if (o.parent != null) {\n // remove gc'd op from parent, if it exists\n var parent /* MapOperation */ = yield* this.getOperation(o.parent)\n var setParent = false // whether to save parent to the os\n if (o.parentSub != null) {\n if (Y.utils.compareIds(parent.map[o.parentSub], o.id)) {\n setParent = true\n parent.map[o.parentSub] = o.right\n }\n } else {\n if (Y.utils.compareIds(parent.start, o.id)) {\n // gc'd op is the start\n setParent = true\n parent.start = o.right\n }\n if (Y.utils.compareIds(parent.end, o.id)) {\n // gc'd op is the end\n setParent = true\n parent.end = o.left\n }\n }\n if (setParent) {\n yield* this.setOperation(parent)\n }\n }\n // finally remove it from the os\n yield* this.removeOperation(o.id)\n }\n }\n * checkDeleteStoreForState (state) {\n var n = yield* this.ds.findWithUpperBound([state.user, state.clock])\n if (n != null && n.id[0] === state.user && n.gc) {\n state.clock = Math.max(state.clock, n.id[1] + n.len)\n }\n }\n /*\n apply a delete set in order to get\n the state of the supplied ds\n */\n * applyDeleteSet (ds) {\n var deletions = []\n function createDeletions (user, start, len, gc) {\n deletions.push([user, start, len, gc])\n }\n\n for (var user in ds) {\n var dv = ds[user]\n var pos = 0\n var d = dv[pos]\n yield* this.ds.iterate(this, [user, 0], [user, Number.MAX_VALUE], function * (n) {\n // cases:\n // 1. d deletes something to the right of n\n // => go to next n (break)\n // 2. d deletes something to the left of n\n // => create deletions\n // => reset d accordingly\n // *)=> if d doesn't delete anything anymore, go to next d (continue)\n // 3. not 2) and d deletes something that also n deletes\n // => reset d so that it doesn't contain n's deletion\n // *)=> if d does not delete anything anymore, go to next d (continue)\n while (d != null) {\n var diff = 0 // describe the diff of length in 1) and 2)\n if (n.id[1] + n.len <= d[0]) {\n // 1)\n break\n } else if (d[0] < n.id[1]) {\n // 2)\n // delete maximum the len of d\n // else delete as much as possible\n diff = Math.min(n.id[1] - d[0], d[1])\n createDeletions(user, d[0], diff, d[2])\n } else {\n // 3)\n diff = n.id[1] + n.len - d[0] // never null (see 1)\n if (d[2] && !n.gc) {\n // d marks as gc'd but n does not\n // then delete either way\n createDeletions(user, d[0], Math.min(diff, d[1]), d[2])\n }\n }\n if (d[1] <= diff) {\n // d doesn't delete anything anymore\n d = dv[++pos]\n } else {\n d[0] = d[0] + diff // reset pos\n d[1] = d[1] - diff // reset length\n }\n }\n })\n // for the rest.. just apply it\n for (; pos < dv.length; pos++) {\n d = dv[pos]\n createDeletions(user, d[0], d[1], d[2])\n }\n }\n for (var i = 0; i < deletions.length; i++) {\n var del = deletions[i]\n // always try to delete..\n var state = yield* this.getState(del[0])\n if (del[1] < state.clock) {\n for (let c = del[1]; c < del[1] + del[2]; c++) {\n var id = [del[0], c]\n var addOperation = yield* this.deleteOperation(id)\n if (addOperation) {\n // TODO:.. really .. here? You could prevent calling all these functions in operationAdded\n yield* this.store.operationAdded(this, {struct: 'Delete', target: id})\n }\n if (del[3]) {\n // gc\n yield* this.garbageCollectOperation(id)\n }\n }\n } else {\n if (del[3]) {\n yield* this.markGarbageCollected([del[0], del[1]], del[2])\n } else {\n yield* this.markDeleted([del[0], del[1]], del[2])\n }\n }\n if (del[3]) {\n // check to increase the state of the respective user\n if (state.clock >= del[1] && state.clock < del[1] + del[2]) {\n state.clock = del[1] + del[2]\n // also check if more expected operations were gc'd\n yield* this.checkDeleteStoreForState(state) // TODO: unneccessary?\n // then set the state\n yield* this.setState(state)\n }\n }\n if (this.store.forwardAppliedOperations) {\n var ops = []\n for (let c = del[1]; c < del[1] + del[2]; c++) {\n ops.push({struct: 'Delete', target: [d[0], c]}) // TODO: implement Delete with deletion length!\n }\n this.store.y.connector.broadcastOps(ops)\n }\n }\n }\n * isGarbageCollected (id) {\n var n = yield* this.ds.findWithUpperBound(id)\n return n != null && n.id[0] === id[0] && id[1] < n.id[1] + n.len && n.gc\n }\n /*\n A DeleteSet (ds) describes all the deleted ops in the OS\n */\n * getDeleteSet () {\n var ds = {}\n yield* this.ds.iterate(this, null, null, function * (n) {\n var user = n.id[0]\n var counter = n.id[1]\n var len = n.len\n var gc = n.gc\n var dv = ds[user]\n if (dv === void 0) {\n dv = []\n ds[user] = dv\n }\n dv.push([counter, len, gc])\n })\n return ds\n }\n * isDeleted (id) {\n var n = yield* this.ds.findWithUpperBound(id)\n return n != null && n.id[0] === id[0] && id[1] < n.id[1] + n.len\n }\n * setOperation (op) {\n yield* this.os.put(op)\n return op\n }\n * addOperation (op) {\n yield* this.os.put(op)\n if (!this.store.y.connector.isDisconnected() && this.store.forwardAppliedOperations && op.id[0] !== '_') {\n // is connected, and this is not going to be send in addOperation\n this.store.y.connector.broadcastOps([op])\n }\n }\n * getOperation (id/* :any */)/* :Transaction<any> */ {\n var o = yield* this.os.find(id)\n if (o != null || id[0] !== '_') {\n return o\n } else {\n // need to generate this operation\n if (this.store._nextUserId == null) {\n var struct = id[1].split('_')[0]\n // this.store._nextUserId = id\n var op = Y.Struct[struct].create(id)\n yield* this.setOperation(op)\n // delete this.store._nextUserId\n return op\n } else {\n // Can only generate one operation at a time\n return null\n }\n }\n }\n * removeOperation (id) {\n yield* this.os.delete(id)\n }\n * setState (state) {\n var val = {\n id: [state.user],\n clock: state.clock\n }\n yield* this.ss.put(val)\n }\n * getState (user) {\n var n = yield* this.ss.find([user])\n var clock = n == null ? null : n.clock\n if (clock == null) {\n clock = 0\n }\n return {\n user: user,\n clock: clock\n }\n }\n * getStateVector () {\n var stateVector = []\n yield* this.ss.iterate(this, null, null, function * (n) {\n stateVector.push({\n user: n.id[0],\n clock: n.clock\n })\n })\n return stateVector\n }\n * getStateSet () {\n var ss = {}\n yield* this.ss.iterate(this, null, null, function * (n) {\n ss[n.id[0]] = n.clock\n })\n return ss\n }\n /*\n Here, we make all missing operations executable for the receiving user.\n\n Notes:\n startSS: denotes to the SV that the remote user sent\n currSS: denotes to the state vector that the user should have if he\n applies all already sent operations (increases is each step)\n\n We face several problems:\n * Execute op as is won't work because ops depend on each other\n -> find a way so that they do not anymore\n * When changing left, must not go more to the left than the origin\n * When changing right, you have to consider that other ops may have op\n as their origin, this means that you must not set one of these ops\n as the new right (interdependencies of ops)\n * can't just go to the right until you find the first known operation,\n With currSS\n -> interdependency of ops is a problem\n With startSS\n -> leads to inconsistencies when two users join at the same time.\n Then the position depends on the order of execution -> error!\n\n Solution:\n -> re-create originial situation\n -> set op.left = op.origin (which never changes)\n -> set op.right\n to the first operation that is known (according to startSS)\n or to the first operation that has an origin that is not to the\n right of op.\n -> Enforces unique execution order -> happy user\n\n Improvements: TODO\n * Could set left to origin, or the first known operation\n (startSS or currSS.. ?)\n -> Could be necessary when I turn GC again.\n -> Is a bad(ish) idea because it requires more computation\n\n What we do:\n * Iterate over all missing operations.\n * When there is an operation, where the right op is known, send this op all missing ops to the left to the user\n * I explained above what we have to do with each operation. Here is how we do it efficiently:\n 1. Go to the left until you find either op.origin, or a known operation (let o denote current operation in the iteration)\n 2. Found a known operation -> set op.left = o, and send it to the user. stop\n 3. Found o = op.origin -> set op.left = op.origin, and send it to the user. start again from 1. (set op = o)\n 4. Found some o -> set o.right = op, o.left = o.origin, send it to the user, continue\n */\n * getOperations (startSS) {\n // TODO: use bounds here!\n if (startSS == null) {\n startSS = {}\n }\n var send = []\n\n var endSV = yield* this.getStateVector()\n for (var endState of endSV) {\n var user = endState.user\n if (user === '_') {\n continue\n }\n var startPos = startSS[user] || 0\n\n yield* this.os.iterate(this, [user, startPos], [user, Number.MAX_VALUE], function * (op) {\n op = Y.Struct[op.struct].encode(op)\n if (op.struct !== 'Insert') {\n send.push(op)\n } else if (op.right == null || op.right[1] < (startSS[op.right[0]] || 0)) {\n // case 1. op.right is known\n var o = op\n // Remember: ?\n // -> set op.right\n // 1. to the first operation that is known (according to startSS)\n // 2. or to the first operation that has an origin that is not to the\n // right of op.\n // For this we maintain a list of ops which origins are not found yet.\n var missing_origins = [op]\n var newright = op.right\n while (true) {\n if (o.left == null) {\n op.left = null\n send.push(op)\n if (!Y.utils.compareIds(o.id, op.id)) {\n o = Y.Struct[op.struct].encode(o)\n o.right = missing_origins[missing_origins.length - 1].id\n send.push(o)\n }\n break\n }\n o = yield* this.getOperation(o.left)\n // we set another o, check if we can reduce $missing_origins\n while (missing_origins.length > 0 && Y.utils.compareIds(missing_origins[missing_origins.length - 1].origin, o.id)) {\n missing_origins.pop()\n }\n if (o.id[1] < (startSS[o.id[0]] || 0)) {\n // case 2. o is known\n op.left = o.id\n send.push(op)\n break\n } else if (Y.utils.compareIds(o.id, op.origin)) {\n // case 3. o is op.origin\n op.left = op.origin\n send.push(op)\n op = Y.Struct[op.struct].encode(o)\n op.right = newright\n if (missing_origins.length > 0) {\n console.log('This should not happen .. :( please report this')\n }\n missing_origins = [op]\n } else {\n // case 4. send o, continue to find op.origin\n var s = Y.Struct[op.struct].encode(o)\n s.right = missing_origins[missing_origins.length - 1].id\n s.left = s.origin\n send.push(s)\n missing_origins.push(o)\n }\n }\n }\n })\n }\n return send.reverse()\n }\n /* this is what we used before.. use this as a reference..\n * makeOperationReady (startSS, op) {\n op = Y.Struct[op.struct].encode(op)\n op = Y.utils.copyObject(op)\n var o = op\n var ids = [op.id]\n // search for the new op.right\n // it is either the first known op (according to startSS)\n // or the o that has no origin to the right of op\n // (this is why we use the ids array)\n while (o.right != null) {\n var right = yield* this.getOperation(o.right)\n if (o.right[1] < (startSS[o.right[0]] || 0) || !ids.some(function (id) {\n return Y.utils.compareIds(id, right.origin)\n })) {\n break\n }\n ids.push(o.right)\n o = right\n }\n op.right = o.right\n op.left = op.origin\n return op\n }\n */\n * flush () {\n yield* this.os.flush()\n yield* this.ss.flush()\n yield* this.ds.flush()\n }\n }\n Y.Transaction = TransactionInterface\n}\n","/* @flow */\n'use strict'\n\n/*\n EventHandler is an helper class for constructing custom types.\n\n Why: When constructing custom types, you sometimes want your types to work\n synchronous: E.g.\n ``` Synchronous\n mytype.setSomething(\"yay\")\n mytype.getSomething() === \"yay\"\n ```\n versus\n ``` Asynchronous\n mytype.setSomething(\"yay\")\n mytype.getSomething() === undefined\n mytype.waitForSomething().then(function(){\n mytype.getSomething() === \"yay\"\n })\n ```\n\n The structures usually work asynchronously (you have to wait for the\n database request to finish). EventHandler helps you to make your type\n synchronous.\n*/\nmodule.exports = function (Y /* : any*/) {\n Y.utils = {}\n\n class EventHandler {\n /* ::\n waiting: Array<Insertion | Deletion>;\n awaiting: number;\n onevent: Function;\n eventListeners: Array<Function>;\n */\n /*\n onevent: is called when the structure changes.\n\n Note: \"awaiting opertations\" is used to denote operations that were\n prematurely called. Events for received operations can not be executed until\n all prematurely called operations were executed (\"waiting operations\")\n */\n constructor (onevent /* : Function */) {\n this.waiting = []\n this.awaiting = 0\n this.onevent = onevent\n this.eventListeners = []\n }\n destroy () {\n this.waiting = null\n this.awaiting = null\n this.onevent = null\n this.eventListeners = null\n }\n /*\n Call this when a new operation arrives. It will be executed right away if\n there are no waiting operations, that you prematurely executed\n */\n receivedOp (op) {\n if (this.awaiting <= 0) {\n this.onevent([op])\n } else {\n this.waiting.push(Y.utils.copyObject(op))\n }\n }\n /*\n You created some operations, and you want the `onevent` function to be\n called right away. Received operations will not be executed untill all\n prematurely called operations are executed\n */\n awaitAndPrematurelyCall (ops) {\n this.awaiting++\n this.onevent(ops)\n }\n /*\n Basic event listener boilerplate...\n TODO: maybe put this in a different type..\n */\n addEventListener (f) {\n this.eventListeners.push(f)\n }\n removeEventListener (f) {\n this.eventListeners = this.eventListeners.filter(function (g) {\n return f !== g\n })\n }\n removeAllEventListeners () {\n this.eventListeners = []\n }\n callEventListeners (event) {\n for (var i = 0; i < this.eventListeners.length; i++) {\n try {\n this.eventListeners[i](event)\n } catch (e) {\n console.log('User events must not throw Errors!') // eslint-disable-line\n }\n }\n }\n /*\n Call this when you successfully awaited the execution of n Insert operations\n */\n awaitedInserts (n) {\n var ops = this.waiting.splice(this.waiting.length - n)\n for (var oid = 0; oid < ops.length; oid++) {\n var op = ops[oid]\n if (op.struct === 'Insert') {\n for (var i = this.waiting.length - 1; i >= 0; i--) {\n let w = this.waiting[i]\n if (w.struct === 'Insert') {\n if (Y.utils.compareIds(op.left, w.id)) {\n // include the effect of op in w\n w.right = op.id\n // exclude the effect of w in op\n op.left = w.left\n } else if (Y.utils.compareIds(op.right, w.id)) {\n // similar..\n w.left = op.id\n op.right = w.right\n }\n }\n }\n } else {\n throw new Error('Expected Insert Operation!')\n }\n }\n this._tryCallEvents()\n }\n /*\n Call this when you successfully awaited the execution of n Delete operations\n */\n awaitedDeletes (n, newLeft) {\n var ops = this.waiting.splice(this.waiting.length - n)\n for (var j = 0; j < ops.length; j++) {\n var del = ops[j]\n if (del.struct === 'Delete') {\n if (newLeft != null) {\n for (var i = 0; i < this.waiting.length; i++) {\n let w = this.waiting[i]\n // We will just care about w.left\n if (w.struct === 'Insert' && Y.utils.compareIds(del.target, w.left)) {\n w.left = newLeft\n }\n }\n }\n } else {\n throw new Error('Expected Delete Operation!')\n }\n }\n this._tryCallEvents()\n }\n /* (private)\n Try to execute the events for the waiting operations\n */\n _tryCallEvents () {\n this.awaiting--\n if (this.awaiting <= 0 && this.waiting.length > 0) {\n var events = this.waiting\n this.waiting = []\n this.onevent(events)\n }\n }\n }\n Y.utils.EventHandler = EventHandler\n\n /*\n A wrapper for the definition of a custom type.\n Every custom type must have three properties:\n\n * struct\n - Structname of this type\n * initType\n - Given a model, creates a custom type\n * class\n - the constructor of the custom type (e.g. in order to inherit from a type)\n */\n class CustomType { // eslint-disable-line\n /* ::\n struct: any;\n initType: any;\n class: Function;\n name: String;\n */\n constructor (def) {\n if (def.struct == null ||\n def.initType == null ||\n def.class == null ||\n def.name == null\n ) {\n throw new Error('Custom type was not initialized correctly!')\n }\n this.struct = def.struct\n this.initType = def.initType\n this.class = def.class\n this.name = def.name\n }\n }\n Y.utils.CustomType = CustomType\n\n /*\n Make a flat copy of an object\n (just copy properties)\n */\n function copyObject (o) {\n var c = {}\n for (var key in o) {\n c[key] = o[key]\n }\n return c\n }\n Y.utils.copyObject = copyObject\n\n /*\n Defines a smaller relation on Id's\n */\n function smaller (a, b) {\n return a[0] < b[0] || (a[0] === b[0] && (a[1] < b[1] || typeof a[1] < typeof b[1]))\n }\n Y.utils.smaller = smaller\n\n function compareIds (id1, id2) {\n if (id1 == null || id2 == null) {\n if (id1 == null && id2 == null) {\n return true\n }\n return false\n }\n if (id1[0] === id2[0] && id1[1] === id2[1]) {\n return true\n } else {\n return false\n }\n }\n Y.utils.compareIds = compareIds\n\n function createEmptyOpsArray (n) {\n var a = new Array(n)\n for (var i = 0; i < a.length; i++) {\n a[i] = {\n id: [null, null]\n }\n }\n return a\n }\n\n function createSmallLookupBuffer (Store) {\n /*\n This buffer implements a very small buffer that temporarily stores operations\n after they are read / before they are written.\n The buffer basically implements FIFO. Often requested lookups will be re-queued every time they are looked up / written.\n\n It can speed up lookups on Operation Stores and State Stores. But it does not require notable use of memory or processing power.\n\n Good for os and ss, bot not for ds (because it often uses methods that require a flush)\n\n I tried to optimize this for performance, therefore no highlevel operations.\n */\n class SmallLookupBuffer extends Store {\n constructor () {\n super(...arguments)\n this.writeBuffer = createEmptyOpsArray(5)\n this.readBuffer = createEmptyOpsArray(10)\n }\n * find (id) {\n var i, r\n for (i = this.readBuffer.length - 1; i >= 0; i--) {\n r = this.readBuffer[i]\n // we don't have to use compareids, because id is always defined!\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n // found r\n // move r to the end of readBuffer\n for (; i < this.readBuffer.length - 1; i++) {\n this.readBuffer[i] = this.readBuffer[i + 1]\n }\n this.readBuffer[this.readBuffer.length - 1] = r\n return r\n }\n }\n var o\n for (i = this.writeBuffer.length - 1; i >= 0; i--) {\n r = this.writeBuffer[i]\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n o = r\n break\n }\n }\n if (i < 0) {\n // did not reach break in last loop\n // read id and put it to the end of readBuffer\n o = yield* super.find(id)\n }\n if (o != null) {\n for (i = 0; i < this.readBuffer.length - 1; i++) {\n this.readBuffer[i] = this.readBuffer[i + 1]\n }\n this.readBuffer[this.readBuffer.length - 1] = o\n }\n return o\n }\n * put (o) {\n var id = o.id\n var i, r // helper variables\n for (i = this.writeBuffer.length - 1; i >= 0; i--) {\n r = this.writeBuffer[i]\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n // is already in buffer\n // forget r, and move o to the end of writeBuffer\n for (; i < this.writeBuffer.length - 1; i++) {\n this.writeBuffer[i] = this.writeBuffer[i + 1]\n }\n this.writeBuffer[this.writeBuffer.length - 1] = o\n break\n }\n }\n if (i < 0) {\n // did not reach break in last loop\n // write writeBuffer[0]\n var write = this.writeBuffer[0]\n if (write.id[0] !== null) {\n yield* super.put(write)\n }\n // put o to the end of writeBuffer\n for (i = 0; i < this.writeBuffer.length - 1; i++) {\n this.writeBuffer[i] = this.writeBuffer[i + 1]\n }\n this.writeBuffer[this.writeBuffer.length - 1] = o\n }\n // check readBuffer for every occurence of o.id, overwrite if found\n // whether found or not, we'll append o to the readbuffer\n for (i = 0; i < this.readBuffer.length - 1; i++) {\n r = this.readBuffer[i + 1]\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n this.readBuffer[i] = o\n } else {\n this.readBuffer[i] = r\n }\n }\n this.readBuffer[this.readBuffer.length - 1] = o\n }\n * delete (id) {\n var i, r\n for (i = 0; i < this.readBuffer.length; i++) {\n r = this.readBuffer[i]\n if (r.id[1] === id[1] && r.id[0] === id[0]) {\n this.readBuffer[i] = {\n id: [null, null]\n }\n }\n }\n yield* this.flush()\n yield* super.delete(id)\n }\n * findWithLowerBound () {\n yield* this.flush()\n return yield* super.findWithLowerBound.apply(this, arguments)\n }\n * findWithUpperBound () {\n yield* this.flush()\n return yield* super.findWithUpperBound.apply(this, arguments)\n }\n * findNext () {\n yield* this.flush()\n return yield* super.findNext.apply(this, arguments)\n }\n * findPrev () {\n yield* this.flush()\n return yield* super.findPrev.apply(this, arguments)\n }\n * iterate () {\n yield* this.flush()\n yield* super.iterate.apply(this, arguments)\n }\n * flush () {\n for (var i = 0; i < this.writeBuffer.length; i++) {\n var write = this.writeBuffer[i]\n if (write.id[0] !== null) {\n yield* super.put(write)\n this.writeBuffer[i] = {\n id: [null, null]\n }\n }\n }\n }\n }\n return SmallLookupBuffer\n }\n Y.utils.createSmallLookupBuffer = createSmallLookupBuffer\n}\n","/* @flow */\n'use strict'\n\nrequire('./Connector.js')(Y)\nrequire('./Database.js')(Y)\nrequire('./Transaction.js')(Y)\nrequire('./Struct.js')(Y)\nrequire('./Utils.js')(Y)\nrequire('./Connectors/Test.js')(Y)\n\nvar requiringModules = {}\n\nmodule.exports = Y\nY.requiringModules = requiringModules\n\nY.extend = function (name, value) {\n Y[name] = value\n if (requiringModules[name] != null) {\n requiringModules[name].resolve()\n delete requiringModules[name]\n }\n}\n\nY.requestModules = requestModules\nfunction requestModules (modules) {\n // determine if this module was compiled for es5 or es6 (y.js vs. y.es6)\n // if Insert.execute is a Function, then it isnt a generator..\n // then load the es5(.js) files..\n var extention = typeof regeneratorRuntime !== 'undefined' ? '.js' : '.es6'\n var promises = []\n for (var i = 0; i < modules.length; i++) {\n var modulename = 'y-' + modules[i].toLowerCase()\n if (Y[modules[i]] == null) {\n if (requiringModules[modules[i]] == null) {\n // module does not exist\n if (typeof window !== 'undefined' && window.Y !== 'undefined') {\n var imported = document.createElement('script')\n imported.src = Y.sourceDir + '/' + modulename + '/' + modulename + extention\n document.head.appendChild(imported)\n\n let requireModule = {}\n requiringModules[modules[i]] = requireModule\n requireModule.promise = new Promise(function (resolve) {\n requireModule.resolve = resolve\n })\n promises.push(requireModule.promise)\n } else {\n require(modulename)(Y)\n }\n } else {\n promises.push(requiringModules[modules[i]].promise)\n }\n }\n }\n return Promise.all(promises)\n}\n\n/* ::\ntype MemoryOptions = {\n name: 'memory'\n}\ntype IndexedDBOptions = {\n name: 'indexeddb',\n namespace: string\n}\ntype DbOptions = MemoryOptions | IndexedDBOptions\n\ntype WebRTCOptions = {\n name: 'webrtc',\n room: string\n}\ntype WebsocketsClientOptions = {\n name: 'websockets-client',\n room: string\n}\ntype ConnectionOptions = WebRTCOptions | WebsocketsClientOptions\n\ntype YOptions = {\n connector: ConnectionOptions,\n db: DbOptions,\n types: Array<TypeName>,\n sourceDir: string,\n share: {[key: string]: TypeName}\n}\n*/\n\nfunction Y (opts/* :YOptions */) /* :Promise<YConfig> */ {\n opts.types = opts.types != null ? opts.types : []\n var modules = [opts.db.name, opts.connector.name].concat(opts.types)\n for (var name in opts.share) {\n modules.push(opts.share[name])\n }\n Y.sourceDir = opts.sourceDir\n return Y.requestModules(modules).then(function () {\n return new Promise(function (resolve) {\n var yconfig = new YConfig(opts)\n yconfig.db.whenUserIdSet(function () {\n yconfig.init(function () {\n resolve(yconfig)\n })\n })\n })\n })\n}\n\nclass YConfig {\n /* ::\n db: Y.AbstractDatabase;\n connector: Y.AbstractConnector;\n share: {[key: string]: any};\n options: Object;\n */\n constructor (opts, callback) {\n this.options = opts\n this.db = new Y[opts.db.name](this, opts.db)\n this.connector = new Y[opts.connector.name](this, opts.connector)\n }\n init (callback) {\n var opts = this.options\n var share = {}\n this.share = share\n this.db.requestTransaction(function * requestTransaction () {\n // create shared object\n for (var propertyname in opts.share) {\n var typename = opts.share[propertyname]\n var id = ['_', Y[typename].struct + '_' + propertyname]\n var op = yield* this.getOperation(id)\n if (op.type !== typename) {\n // not already in the db\n op.type = typename\n yield* this.setOperation(op)\n }\n share[propertyname] = yield* this.getType(id)\n }\n this.store.whenTransactionsFinished()\n .then(callback)\n })\n }\n isConnected () {\n return this.connector.isSynced\n }\n disconnect () {\n return this.connector.disconnect()\n }\n reconnect () {\n return this.connector.reconnect()\n }\n destroy () {\n if (this.connector.destroy != null) {\n this.connector.destroy()\n } else {\n this.connector.disconnect()\n }\n var self = this\n this.db.requestTransaction(function * () {\n yield* self.db.destroy()\n self.connector = null\n self.db = null\n })\n }\n}\n\nif (typeof window !== 'undefined') {\n window.Y = Y\n}\n"],"sourceRoot":"/source/"}