2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
!function e(t,r,n){function o(i,s){if(!r[i]){if(!t[i]){var u="function"==typeof require&&require;if(!s&&u)return u(i,!0);if(a)return a(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[i]={exports:{}};t[i][0].call(l.exports,function(e){var r=t[i][1][e];return o(r?r:e)},l,l.exports,e,t,r,n)}return r[i].exports}for(var a="function"==typeof require&&require,i=0;i<n.length;i++)o(n[i]);return o}({1:[function(e,t,r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){e.requestModules(["memory"]).then(function(){function t(e){var t=function(e){function t(){a(this,t);var e=n(this,Object.getPrototypeOf(t).apply(this,arguments));return e.buffer=[],e._copyTo=null,e}return o(t,e),u(t,[{key:"copyTo",value:function(e){return this._copyTo=e,this}},{key:"put",value:regeneratorRuntime.mark(function r(e,n){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return n||this.buffer.push(this._copyTo.put(e)),r.delegateYield(s(Object.getPrototypeOf(t.prototype),"put",this).call(this,e),"t0",2);case 2:case"end":return r.stop()}},r,this)})},{key:"delete",value:regeneratorRuntime.mark(function i(e){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return this.buffer.push(this._copyTo["delete"](e)),r.delegateYield(s(Object.getPrototypeOf(t.prototype),"delete",this).call(this,e),"t0",2);case 2:case"end":return r.stop()}},i,this)})},{key:"flush",value:regeneratorRuntime.mark(function c(){var e;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(s(Object.getPrototypeOf(t.prototype),"flush",this).call(this),"t0",1);case 1:e=0;case 2:if(!(e<this.buffer.length)){r.next=7;break}return r.delegateYield(this.buffer[e],"t1",4);case 4:e++,r.next=2;break;case 7:return r.delegateYield(this._copyTo.flush(),"t2",8);case 8:case"end":return r.stop()}},c,this)})}]),t}(e);return t}var r=function(){function e(t,r){a(this,e),this.store=t.objectStore(r)}return u(e,[{key:"find",value:regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.get(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)})},{key:"put",value:regeneratorRuntime.mark(function r(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.put(e);case 2:case"end":return t.stop()}},r,this)})},{key:"delete",value:regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store["delete"](e);case 2:case"end":return t.stop()}},n,this)})},{key:"findWithLowerBound",value:regeneratorRuntime.mark(function o(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.openCursor(window.IDBKeyRange.lowerBound(e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},o,this)})},{key:"findWithUpperBound",value:regeneratorRuntime.mark(function i(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.store.openCursor(window.IDBKeyRange.upperBound(e),"prev");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},i,this)})},{key:"findNext",value:regeneratorRuntime.mark(function s(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.findWithLowerBound([e[0],e[1]+1]),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},s,this)})},{key:"findPrev",value:regeneratorRuntime.mark(function c(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.findWithUpperBound([e[0],e[1]-1]),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},c,this)})},{key:"iterate",value:regeneratorRuntime.mark(function l(e,t,r,n){var o,a;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:o=null,null!=t&&null!=r?o=window.IDBKeyRange.bound(t,r):null!=t?o=window.IDBKeyRange.lowerBound(t):null!=r&&(o=window.IDBKeyRange.upperBound(r)),a=null!=o?this.store.openCursor(o):this.store.openCursor();case 3:return i.next=5,a;case 5:if(i.t0=i.sent,null==i.t0){i.next=11;break}return i.delegateYield(n.call(e,a.result.value),"t1",8);case 8:a.result["continue"](),i.next=3;break;case 11:case"end":return i.stop()}},l,this)})},{key:"flush",value:regeneratorRuntime.mark(function d(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},d,this)})}]),e}();e.utils.createStoreClone=t;var i=e.utils.createSmallLookupBuffer(r),c=e.utils.createStoreClone(e.utils.RBTree),l=function(e){function t(e){a(this,t);var r=n(this,Object.getPrototypeOf(t).call(this,e)),o=e.db.transaction(["OperationStore","StateStore","DeleteStore"],"readwrite");return r.store=e,r.ss=new i(o,"StateStore"),r.os=new i(o,"OperationStore"),r._ds=new i(o,"DeleteStore"),r.ds=e.dsClone.copyTo(r._ds),r}return o(t,e),t}(e.Transaction),d=function(t){function r(t,o){a(this,r);var i=n(this,Object.getPrototypeOf(r).call(this,t,o));if(i.dsClone=new c,null==o&&(o={}),i.options=o,null==o.namespace){if(null==t.options.connector.room)throw new Error("IndexedDB: expect a string (options.namespace)! (you can also skip this step if your connector has a room property)");o.namespace=t.options.connector.room}null!=o.idbVersion?i.idbVersion=o.idbVersion:i.idbVersion=5;var s=i;i.requestTransaction(regeneratorRuntime.mark(function l(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.indexedDB.open(o.namespace,s.idbVersion);case 2:s.db=e.sent;case 3:case"end":return e.stop()}},l,this)})),o.cleanStart&&(delete window.localStorage[JSON.stringify(["Yjs_indexeddb",o.namespace])],i.requestTransaction(regeneratorRuntime.mark(function d(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.os.store.clear();case 2:return e.next=4,this._ds.store.clear();case 4:return e.next=6,this.ss.store.clear();case 6:case"end":return e.stop()}},d,this)}))),i.whenUserIdSet(function(e){null==window.localStorage[JSON.stringify(["Yjs_indexeddb",o.namespace])]&&(window.localStorage[JSON.stringify(["Yjs_indexeddb",o.namespace])]=JSON.stringify([e,0]))}),i.requestTransaction(regeneratorRuntime.mark(function p(){var e,t;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return e=window.localStorage[JSON.stringify(["Yjs_indexeddb",o.namespace])],null!=e&&(s.setUserId(e),t=JSON.parse(e),t[1]=t[1]+1,window.localStorage[JSON.stringify(["Yjs_indexeddb",o.namespace])]=JSON.stringify(t)),r.delegateYield(this._ds.iterate(this,null,null,regeneratorRuntime.mark(function n(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(this.ds.put(e,!0),"t0",1);case 1:case"end":return t.stop()}},n,this)})),"t0",3);case 3:case"end":return r.stop()}},p,this)})),i.operationAddedNamespace=JSON.stringify(["__YJS__",i.options.namespace]);var u=[];return window.addEventListener("storage",function(t){if(t.key===s.operationAddedNamespace){u.push(JSON.parse(t.newValue));var r,n;1===u.length&&s.requestTransaction(regeneratorRuntime.mark(function o(){var t,a,i,s,c,l;return regeneratorRuntime.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:t=[],n=0;case 2:if(!(n<u.length)){o.next=19;break}if(r=u[n],"Delete"===r.struct){o.next=15;break}return o.delegateYield(this.getOperation(r.id),"t0",6);case 6:r=o.t0;case 7:if(null==r.left){o.next=15;break}return o.delegateYield(this.getOperation(r.left),"t1",9);case 9:if(a=o.t1,a.deleted){o.next=12;break}return o.abrupt("break",15);case 12:r.left=a.left,o.next=7;break;case 15:t.push(r);case 16:n++,o.next=2;break;case 19:u=[];case 20:if(!(t.length>0)){o.next=56;break}i=t,t=[],n=0;case 24:if(!(n<i.length)){o.next=54;break}if(r=i[n],"Insert"!==r.struct){o.next=50;break}s=!0,c=n+1;case 29:if(!(c<i.length)){o.next=37;break}if(l=i[c],!e.utils.compareIds(l.id,r.left)){o.next=34;break}return s=!1,o.abrupt("break",37);case 34:c++,o.next=29;break;case 37:if(!s){o.next=47;break}c=0;case 39:if(!(c<t.length)){o.next=47;break}if(l=i[c],!e.utils.compareIds(l.id,r.left)){o.next=44;break}return s=!1,o.abrupt("break",47);case 44:c++,o.next=39;break;case 47:if(s){o.next=50;break}return t.push(r),o.abrupt("continue",51);case 50:return o.delegateYield(this.store.operationAdded(this,r,!0),"t2",51);case 51:n++,o.next=24;break;case 54:o.next=20;break;case 56:case"end":return o.stop()}},o,this)}))}},!1),i}return o(r,t),u(r,[{key:"operationAdded",value:regeneratorRuntime.mark(function i(e,t,n){return regeneratorRuntime.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.delegateYield(s(Object.getPrototypeOf(r.prototype),"operationAdded",this).call(this,e,t),"t0",1);case 1:n||(window.localStorage[this.operationAddedNamespace]=JSON.stringify(t));case 2:case"end":return o.stop()}},i,this)})},{key:"transact",value:function(e){function t(a){var i=a.value;return a.done?(e=n.getNextRequest(),void(null!=e&&(null==r&&null!=n.db&&(r=new l(n)),o=e.call(r),t(o.next())))):(console.log("new request",null!=i.source?i.source.name:null),void(i.constructor===window.IDBRequest?(i.onsuccess=function(){var e=i.result;null!=e&&e.constructor===window.IDBCursorWithValue&&(e=e.value),t(o.next(e))},i.onerror=function(e){o["throw"](e)}):i.constructor===window.IDBCursor?(i.onsuccess=function(){t(o.next(null!=i.result?i.result.value:null))},i.onerror=function(e){o["throw"](e)}):i.constructor===window.IDBOpenDBRequest?(i.onsuccess=function(e){var r=e.target.result;t(o.next(r))},i.onerror=function(){o["throw"]("Couldn't open IndexedDB database!")},i.onupgradeneeded=function(e){var t=e.target.result;try{delete window.localStorage[JSON.stringify(["Yjs_indexeddb",n.options.namespace])],t.deleteObjectStore("OperationStore"),t.deleteObjectStore("DeleteStore"),t.deleteObjectStore("StateStore")}catch(r){}t.createObjectStore("OperationStore",{keyPath:"id"}),t.createObjectStore("DeleteStore",{keyPath:"id"}),t.createObjectStore("StateStore",{keyPath:"id"})}):o["throw"]("You must not yield this type!")))}var r=null!=this.db?new l(this):null,n=this,o=e.call(r);t(o.next())}},{key:"destroy",value:regeneratorRuntime.mark(function d(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.db.close(),e.next=3,window.indexedDB.deleteDatabase(this.options.namespace);case 3:case"end":return e.stop()}},d,this)})}]),r}(e.AbstractDatabase);e.extend("indexeddb",d)})}var s=function c(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:c(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)},u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.exports=i,"undefined"!=typeof Y&&i(Y)},{}]},{},[1]);
|
|
//# sourceMappingURL=y-indexeddb.js.map
|