Comparing version 1.3.1 to 1.3.2
@@ -1,5 +0,5 @@ | ||
// Type definitions for Dexie 1.3.0 | ||
// Date Mon Mar 07 2016 | ||
// Type definitions for Dexie v1.3.2 | ||
// Project: https://github.com/dfahlander/Dexie.js | ||
// Definitions by: David Fahlander <http://github.com/dfahlander> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -6,0 +6,0 @@ interface Thenable<R> { |
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Dexie=t()}(this,function(){"use strict";function n(n,t){return"object"!=typeof t&&(t=t()),R(t).forEach(function(e){n[e]=t[e]}),n}function t(t){return{from:function(e){return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,{extend:function(r){n(t.prototype,"object"!=typeof r?r(e.prototype):r)}}}}}function e(n,t,e){return U.call(n,t,e)}function r(n,t){return t(n)}function o(a,h){function y(){qn.on("versionchange",function(n){qn.close(),qn.on("error").fire(new kn("Database version changed by other database connection."))})}function b(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function P(n,t,o,i){if(0===n){R(On).forEach(function(n){U(t,n,On[n].primKey,On[n].indexes)});var u=qn._createTransaction(Fn,jn,On);u.idbtrans=t,u.idbtrans.onerror=j(o,["populating database"]),u.on("error").subscribe(o),J.newPSD(function(){J.PSD.trans=u;try{qn.on("populate").fire(u)}catch(n){i.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(e){}t.db.close(),o(n)}})}else{var c=[],a=En.filter(function(t){return t._cfg.version===n})[0];if(!a)throw new kn("Dexie specification of currently installed DB version is missing");On=qn._dbSchema=a._cfg.dbschema;var s=!1,f=En.filter(function(t){return t._cfg.version>n});f.forEach(function(n){var i=On,u=n._cfg.dbschema;wn(i,t),wn(u,t),On=qn._dbSchema=u;var a=O(i,u);a.add.forEach(function(n){c.push(function(t,e){U(t,n[0],n[1].primKey,n[1].indexes),e()})}),a.change.forEach(function(n){if(n.recreate)throw new kn("Not yet support for changing primary key");c.push(function(t,e){var r=t.objectStore(n.name);n.add.forEach(function(n){Q(r,n)}),n.change.forEach(function(n){r.deleteIndex(n.name),Q(r,n)}),n.del.forEach(function(n){r.deleteIndex(n)}),e()})}),n._cfg.contentUpgrade&&c.push(function(t,i){s=!0;var c=qn._createTransaction(Fn,e(t.db.objectStoreNames),u);c.idbtrans=t;var a=0;c._promise=r(c._promise,function(n){return function(t,e,r){function o(n){return function(){n.apply(this,arguments),0===--a&&i()}}return++a,n.call(this,t,function(n,t,r){arguments[0]=o(n),arguments[1]=o(t),e.apply(this,arguments)},r)}}),t.onerror=j(o,["running upgrader function for version",n._cfg.version]),c.on("error").subscribe(o),n._cfg.contentUpgrade(c),0===a&&i()}),s&&bn()||c.push(function(n,t){G(u,n),t()})});var h=function(){try{c.length?c.shift()(t,h):W(On,t)}catch(n){i.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(e){}t.db.close(),o(n)}};h()}}function O(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(var r in t){var o=n[r],i=t[r];if(o){var u={name:r,def:t[r],recreate:!1,del:[],add:[],change:[]};if(o.primKey.src!==i.primKey.src)u.recreate=!0,e.change.push(u);else{var c=o.indexes.reduce(function(n,t){return n[t.name]=t,n},{}),a=i.indexes.reduce(function(n,t){return n[t.name]=t,n},{});for(var s in c)a[s]||u.del.push(s);for(var s in a){var f=c[s],h=a[s];f?f.src!==h.src&&u.change.push(h):u.add.push(h)}(u.recreate||u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,i])}return e}function U(n,t,e,r){var o=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){Q(o,n)}),o}function W(n,t){R(n).forEach(function(e){t.db.objectStoreNames.contains(e)||U(t,e,n[e].primKey,n[e].indexes)})}function G(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null!==n[r]&&void 0!==n[r]||t.db.deleteObjectStore(r)}}function Q(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function X(n,t){throw new kn("Table "+t[0]+" not part of transaction. Original Scope Function Source: "+o.Promise.PSD.trans.scopeFunc.toString())}function Z(n,t,e,r){this.name=n,this.schema=e,this.hook=Cn[n]?Cn[n].hook:v(null,{creating:[s,i],reading:[c,u],updating:[f,i],deleting:[d,i]}),this._tpf=t,this._collClass=r||en}function $(n,t,e,r){Z.call(this,n,t,e,r||rn)}function nn(n,t,e,r){function o(n,t,e,r){return i._promise(n,e,r)}var i=this;this.db=qn,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=v(this,["complete","error"],"abort"),this._reculock=0,this._blockedFuncs=[],this._psd=null,this.active=!0,this._dbschema=e,r&&(this.parent=r),this._tpf=o,this.tables=Object.create(Tn);for(var u=t.length-1;-1!==u;--u){var c=t[u],a=qn._tableFactory(n,e[c],o);this.tables[c]=a,this[c]||(this[c]=a)}}function tn(n,t,e){this._ctx={table:n,index:":id"===t?null:t,collClass:n._collClass,or:e}}function en(n,t){var e=null,r=null;if(t)try{e=t()}catch(o){try{throw new kn(o)}catch(i){r=i}}var u=n._ctx;this._ctx={table:u.table,index:u.index,isPrimKey:!u.index||u.table.schema.primKey.keyPath&&u.index===u.table.schema.primKey.name,range:e,op:"openCursor",dir:"next",unique:"",algorithm:null,filter:null,isMatch:null,offset:0,limit:1/0,error:r,or:u.or}}function rn(){en.apply(this,arguments)}function on(n,t){return n._cfg.version-t._cfg.version}function un(n,t,e,r,o,i){e.forEach(function(e){var u=qn._tableFactory(r,o[e],t);n.forEach(function(n){n[e]||(i?Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var n=J.PSD&&J.PSD.trans;return n&&n.db===qn?n.tables[e]:u}}):n[e]=u)})})}function cn(n){n.forEach(function(n){for(var t in n)n[t]instanceof Z&&delete n[t]})}function an(n,t,e,r,o,i){var c=J.PSD;i=i||u,n.onerror||(n.onerror=j(o)),t?n.onsuccess=g(function(u){var c=n.result;if(c){var a=function(){c["continue"]()};t(c,function(n){a=n},r,o)&&e(i(c.value),c,function(n){a=n}),a()}else r()},o,c):n.onsuccess=g(function(t){var o=n.result;if(o){var u=function(){o["continue"]()};e(i(o.value),o,function(n){u=n}),u()}else r()},o,c)}function sn(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace("&","").replace("++","").replace("*",""),r=0!==e.indexOf("[")?e:n.substring(n.indexOf("[")+1,n.indexOf("]")).split("+");t.push(new A(e,r||null,-1!==n.indexOf("&"),-1!==n.indexOf("*"),-1!==n.indexOf("++"),M(r),-1!==r.indexOf(".")))}),t}function fn(n,t){return Pn.cmp(n,t)}function hn(n,t){return fn(n,t)<0?n:t}function ln(n,t){return fn(n,t)>0?n:t}function dn(n,t){return Pn.cmp(n,t)}function pn(n,t){return Pn.cmp(t,n)}function vn(n,t){return t>n?-1:n===t?0:1}function yn(n,t){return n>t?-1:n===t?0:1}function mn(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function bn(){return navigator.userAgent.indexOf("Trident")>=0||navigator.userAgent.indexOf("MSIE")>=0}function gn(){if(qn.verno=Kn.version/10,qn._dbSchema=On={},jn=e(Kn.objectStoreNames,0),0!==jn.length){var n=Kn.transaction(F(jn),"readonly");jn.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf("."),i=new A(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,o),u=[],c=0;c<e.indexNames.length;++c){var a=e.index(e.indexNames[c]);r=a.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf(".");var s=new A(a.name,r,!!a.unique,!!a.multiEntry,!1,r&&"string"!=typeof r,o);u.push(s)}On[t]=new B(t,i,u,{})}),un([Cn],qn._transPromiseFactory,R(On),Fn,On)}}function wn(n,t){for(var r=t.db.objectStoreNames,o=0;o<r.length;++o)for(var i=r[o],u=t.objectStore(i),c=0;c<u.indexNames.length;++c){var a=u.indexNames[c],s=u.index(a).keyPath,f="string"==typeof s?s:"["+e(s).join("+")+"]";if(n[i]){var h=n[i].idxByName[f];h&&(h.name=a)}}}var _n=h&&h.addons||o.addons,xn=o.dependencies,Pn=xn.indexedDB,Sn=xn.IDBKeyRange,Dn=xn.TypeError,kn=xn.Error,On=this._dbSchema={},En=[],jn=[],Cn={},Tn={},Kn=null,In=!0,An=null,Bn=!1,Nn="readonly",Fn="readwrite",qn=this,Rn=[],Mn=!0,Un=!!q();this.version=function(n){if(Kn)throw new kn("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=En.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new b(n),En.push(t),En.sort(on),t)},n(b.prototype,{stores:function(t){this._cfg.storesSource=this._cfg.storesSource?n(this._cfg.storesSource,t):t;var e={};En.forEach(function(t){n(e,t._cfg.storesSource)});var r=this._cfg.dbschema={};return this._parseStoresSpec(e,r),On=qn._dbSchema=r,cn([Cn,qn,Tn]),un([Tn],X,R(r),Fn,r),un([Cn,qn,this._cfg.tables],qn._transPromiseFactory,R(r),Fn,r,!0),jn=R(r),this},upgrade:function(n){var t=this;return H(function(){n(qn._createTransaction(Fn,R(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){R(n).forEach(function(e){if(null!==n[e]){var r={},o=sn(n[e]),i=o.shift();if(i.multi)throw new kn("Primary key cannot be multi-valued");i.keyPath&&x(r,i.keyPath,i.auto?0:i.keyPath),o.forEach(function(n){if(n.auto)throw new kn("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new kn("Index must have a name and cannot be an empty string");x(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new B(e,i,o,r)}})}}),this._allTables=Cn,this._tableFactory=function(n,t,e){return n===Nn?new Z(t.name,e,t,en):new $(t.name,e,t)},this._createTransaction=function(n,t,e,r){return new nn(n,t,e,r)},this._transPromiseFactory=function(n,t,e){if(!In||J.PSD&&J.PSD.letThrough){var r=qn._createTransaction(n,t,On);return r._promise(n,function(n,t){r.error(function(n){qn.on("error").fire(n)}),J.newPSD(function(){J.PSD.trans=r,e(function(t){r.complete(function(){n(t)})},t,r)})})}Bn||qn.open();var o=new J(function(r,i){Rn.push({resume:function(){var u=qn._transPromiseFactory(n,t,e);o.onuncatched=u.onuncatched,u.then(r,i)}})});return o},this._whenReady=function(n){return Y||!In||J.PSD&&J.PSD.letThrough?new J(n):(Bn||qn.open(),new J(function(t,e){Rn.push({resume:function(){n(t,e)}})}))},this.verno=0,this.open=function(){return new J(function(n,t){function e(n){try{r.transaction.abort()}catch(e){}if(Kn)try{Kn.close()}catch(e){}Kn=null,Bn=!1,An=n,In=!1,t(An),Rn.forEach(function(n){n.resume()}),Rn=[]}if(Y&&n(qn),Kn)return void n(qn);if(Bn)return void qn._whenReady(function(){n(qn)},function(n){t(n)});var r,o=!1;try{if(An=null,Bn=!0,En.length>0&&(Mn=!1),!Pn)throw new kn("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using Safari, make sure to include indexedDB polyfill.");if(r=Mn?Pn.open(a):Pn.open(a,Math.round(10*qn.verno)),!r)throw new kn("IndexedDB API not available");r.onerror=j(e,["opening database",a]),r.onblocked=function(n){qn.on("blocked").fire(n)},r.onupgradeneeded=g(function(n){if(Mn&&!qn._allowEmptyDB){r.onerror=function(n){n.preventDefault()},r.transaction.abort(),r.result.close();var t=Pn.deleteDatabase(a);t.onsuccess=t.onerror=function(){e(new kn("Database '"+a+"' doesnt exist"))}}else{0===n.oldVersion&&(o=!0),r.transaction.onerror=j(e);var i=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;P(i/10,r.transaction,e,r)}},e),r.onsuccess=g(function(t){if(Bn=!1,Kn=r.result,Mn)gn();else if(Kn.objectStoreNames.length>0)try{wn(On,Kn.transaction(F(Kn.objectStoreNames),Nn))}catch(t){}Kn.onversionchange=qn.on("versionchange").fire,Un||K(function(n){return-1===n.indexOf(a)?n.push(a):void 0}),J.newPSD(function(){function t(){In=!1,Rn.forEach(function(n){n.resume()}),Rn=[],n(qn)}J.PSD.letThrough=!0;try{var r=qn.on.ready.fire();r&&"function"==typeof r.then?r.then(t,function(n){Kn.close(),Kn=null,e(n)}):m(t)}catch(o){e(o)}})},e)}catch(i){e(i)}})},this.close=function(){Kn&&(Kn.close(),Kn=null,In=!0,An=null)},this["delete"]=function(){var n=arguments;return new J(function(t,e){function r(){qn.close();var n=Pn.deleteDatabase(a);n.onsuccess=function(){Un||K(function(n){var t=n.indexOf(a);return t>=0?n.splice(t,1):void 0}),t()},n.onerror=j(e,["deleting",a]),n.onblocked=function(){qn.on("blocked").fire()}}if(n.length>0)throw new kn("Arguments not allowed in db.delete()");Bn?Rn.push({resume:r}):r()})},this.backendDB=function(){return Kn},this.isOpen=function(){return null!==Kn},this.hasFailed=function(){return null!==An},this.dynamicallyOpened=function(){return Mn},this.name=a,Object.defineProperty(this,"tables",{get:function(){return R(Cn).map(function(n){return Cn[n]})}}),this.on=v(this,"error","populate","blocked",{ready:[p,i],versionchange:[l,i]}),this.on.ready.subscribe=r(this.on.ready.subscribe,function(n){return function(t,e){function r(){return e||qn.on.ready.unsubscribe(r),t.apply(this,arguments)}n.call(this,r),qn.isOpen()&&(In?Rn.push({resume:r}):r())}}),H(function(){qn.on("populate").fire(qn._createTransaction(Fn,jn,On)),qn.on("error").fire(new kn)}),this.transaction=function(n,t,o){function i(t,e){var i=null;try{if(s)throw s;i=qn._createTransaction(n,f,On,u);var c=f.map(function(n){return i.tables[n]});c.push(i);var a,h=0;J.newPSD(function(){J.PSD.trans=i,i.scopeFunc=o,u&&(i.idbtrans=u.idbtrans,i._promise=r(i._promise,function(n){return function(t,e,r){function o(n){return function(t){var e;return J._rootExec(function(){e=n(t),J._tickFinalize(function(){0===--h&&i.active&&(i.active=!1,i.on.complete.fire())})}),e}}return++h,n.call(this,t,function(n,t,r){return e(o(n),o(t),r)},r)}})),i.complete(function(){t(a)}),i.error(function(n){i.idbtrans&&(i.idbtrans.onerror=T);try{i.abort()}catch(t){}u&&(u.active=!1,u.on.error.fire(n));var r=e(n);u||r||qn.on.error.fire(n)}),J._rootExec(function(){a=o.apply(i,c),a&&"function"==typeof a.next&&"function"==typeof a["throw"]&&(a=I(a))})}),(!i.idbtrans||u&&0===h)&&i._nop()}catch(l){i&&i.idbtrans&&(i.idbtrans.onerror=T),i&&i.abort(),u&&u.on.error.fire(l),m(function(){e(l)||qn.on("error").fire(l)})}}t=e(arguments,1,arguments.length-1),o=arguments[arguments.length-1];var u=J.PSD&&J.PSD.trans;u&&u.db===qn&&-1===n.indexOf("!")||(u=null);var c=-1!==n.indexOf("?");n=n.replace("!","").replace("?","");var a=M(t[0])?t.reduce(function(n,t){return n.concat(t)}):t,s=null,f=a.map(function(n){return"string"==typeof n?n:(n instanceof Z||(s=s||new Dn("Invalid type. Arguments following mode must be instances of Table or String")),n.name)});return"r"==n||n==Nn?n=Nn:"rw"==n||n==Fn?n=Fn:s=new kn("Invalid transaction mode: "+n),u&&(s||(u&&u.mode===Nn&&n===Fn&&(c?u=null:s=s||new kn("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY")),u&&f.forEach(function(n){u.tables.hasOwnProperty(n)||(c?u=null:s=s||new kn("Table "+n+" not included in parent transaction. Parent Transaction function: "+u.scopeFunc.toString()))}))),u?u._promise(n,i,"lock"):qn._whenReady(i)},this.table=function(n){if(Y&&Mn)return new $(n);if(!Cn.hasOwnProperty(n))throw new kn("Table does not exist");return Cn[n]},n(Z.prototype,function(){function n(){throw new kn("Current Transaction is READONLY")}return{_trans:function(n,t,e){return this._tpf(n,[this.name],t,e)},_idbstore:function(n,t,e){if(Y)return new J(t);var r=this;return this._tpf(n,[this.name],function(n,e,o){t(n,e,o.idbtrans.objectStore(r.name),o)},e)},get:function(n,t){var e=this;return this._idbstore(Nn,function(t,r,o){Y&&t(e.schema.instanceTemplate);var i=o.get(n);i.onerror=j(r,["getting",n,"from",e.name]),i.onsuccess=function(){t(e.hook.reading.fire(i.result))}}).then(t)},where:function(n){return new tn(this,n)},count:function(n){return this.toCollection().count(n)},offset:function(n){return this.toCollection().offset(n)},limit:function(n){return this.toCollection().limit(n)},reverse:function(){return this.toCollection().reverse()},filter:function(n){return this.toCollection().and(n)},each:function(n){var t=this;return Y&&n(t.schema.instanceTemplate),this._idbstore(Nn,function(e,r,o){var i=o.openCursor();i.onerror=j(r,["calling","Table.each()","on",t.name]),an(i,null,n,e,r,t.hook.reading.fire)})},toArray:function(n){var t=this;return this._idbstore(Nn,function(n,e,r){Y&&n([t.schema.instanceTemplate]);var o=[],i=r.openCursor();i.onerror=j(e,["calling","Table.toArray()","on",t.name]),an(i,null,function(n){o.push(n)},function(){n(o)},e,t.hook.reading.fire)}).then(n)},orderBy:function(n){return new this._collClass(new tn(this,n))},toCollection:function(){return new this._collClass(new tn(this))},mapToClass:function(n,t){this.schema.mappedClass=n;var e=Object.create(n.prototype);t&&E(e,t),this.schema.instanceTemplate=e;var r=function(t){if(!t)return t;var e=Object.create(n.prototype);for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),n},defineClass:function(n){return this.mapToClass(o.defineClass(n),n)},add:n,put:n,"delete":n,clear:n,update:n}}),t($).from(Z).extend(function(){function n(n,t,e,r){return function(o){o.stopPropagation&&o.stopPropagation(),o.preventDefault&&o.preventDefault(),n.push(o.target.error),e&&e.onerror&&J.newPSD(function(){J.PSD.trans=r,e.onerror(o.target.error)}),t&&t(n)}}function t(n,t,e,r){return e?function(o){e.onsuccess&&J.newPSD(function(){J.PSD.trans=r,e.onsuccess(o.target.result)}),t&&t(n)}:function(){t(n)}}return{bulkAdd:function(e){var r=this.hook.creating.fire;return this._idbstore(Fn,function(o,u,c,a){if(!c.keyPath)throw new kn("bulkAdd() only support inbound keys");if(0===e.length)return o([]);var s,f,h,l=[];if(r!==i){var d=c.keyPath,p={onerror:null,onsuccess:null};f=n(l,null,p,a),h=t(l,null,p,a);for(var v=0,y=e.length;y>v;++v){var m=e[v],b=_(m,d),g=r.call(p,b,m,a);void 0===b&&void 0!==g&&(m=D(m),x(m,d,g)),s=c.add(m),y-1>v&&(s.onerror=f,p.onsuccess&&(s.onsuccess=h),p.onerror=null,p.onsuccess=null)}s.onerror=n(l,o,p,a),s.onsuccess=t(l,o,p,a)}else{f=n(l);for(var v=0,y=e.length;y>v;++v)s=c.add(e[v]),s.onerror=f;s.onerror=n(l,o),s.onsuccess=t(l,o)}})},add:function(n,t){var e=this,r=this.hook.creating.fire;return this._idbstore(Fn,function(o,u,c,a){var s={onsuccess:null,onerror:null};if(r!==i){var f=t||(c.keyPath?_(n,c.keyPath):void 0),h=r.call(s,f,n,a);void 0===f&&void 0!==h&&(c.keyPath?x(n,c.keyPath,h):t=h)}var l=void 0!==t?c.add(n,t):c.add(n);l.onerror=j(function(n){return s.onerror&&J.newPSD(function(){J.PSD.trans=a,s.onerror(n)}),u(n)},["adding",n,"into",e.name]),l.onsuccess=function(t){var e=c.keyPath;e&&x(n,e,t.target.result),s.onsuccess&&J.newPSD(function(){J.PSD.trans=a,s.onsuccess(t.target.result)}),o(l.result)}})},put:function(n,t){var e=this,r=this.hook.creating.fire,o=this.hook.updating.fire;return r!==i||o!==i?this._trans(Fn,function(r,o,i){var u=t||e.schema.primKey.keyPath&&_(n,e.schema.primKey.keyPath);void 0===u?i.tables[e.name].add(n).then(r,o):(i._lock(),n=D(n),i.tables[e.name].where(":id").equals(u).modify(function(t){this.value=n}).then(function(r){return 0===r?i.tables[e.name].add(n,t):u})["finally"](function(){i._unlock()}).then(r,o))}):this._idbstore(Fn,function(r,o,i){var u=void 0!==t?i.put(n,t):i.put(n);u.onerror=j(o,["putting",n,"into",e.name]),u.onsuccess=function(t){var e=i.keyPath;e&&x(n,e,t.target.result),r(u.result)}})},"delete":function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n)["delete"]():this._idbstore(Fn,function(t,e,r){var o=r["delete"](n);o.onerror=j(e,["deleting",n,"from",r.name]),o.onsuccess=function(n){t(o.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection()["delete"]():this._idbstore(Fn,function(n,t,e){var r=e.clear();r.onerror=j(t,["clearing",e.name]),r.onsuccess=function(t){n(r.result)}})},update:function(n,t){if("object"!=typeof t||M(t))throw new kn("db.update(keyOrObject, modifications). modifications must be an object.");if("object"!=typeof n||M(n))return this.where(":id").equals(n).modify(t);R(t).forEach(function(e){x(n,e,t[e])});var e=_(n,this.schema.primKey.keyPath);return void 0===e&&J.reject(new kn("Object does not contain its primary key")),this.where(":id").equals(e).modify(t)}}}),n(nn.prototype,{_lock:function(){return++this._reculock,1===this._reculock&&J.PSD&&(J.PSD.lockOwnerFor=this),this},_unlock:function(){if(0===--this._reculock)for(J.PSD&&(J.PSD.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(t){}}return this},_locked:function(){return this._reculock&&(!J.PSD||J.PSD.lockOwnerFor!==this)},_nop:function(n){this.tables[this.storeNames[0]].get(0).then(n)},_promise:function(n,t,e){var r=this;return J.newPSD(function(){var i;return r._locked()?i=new J(function(o,i){r._blockedFuncs.push(function(){r._promise(n,t,e).then(o,i)})}):(i=r.active?new J(function(i,u){if(!r.idbtrans&&n){if(!Kn)throw new kn(An?"Database not open. Following error in populate, ready or upgrade function made Dexie.open() fail: "+An:"Database not open");var c=r.idbtrans=Kn.transaction(F(r.storeNames),r.mode);c.onerror=function(n){r.on("error").fire(n&&n.target.error),n.preventDefault(),r.abort()},c.onabort=function(n){m(function(){r.on("error").fire(new kn("Transaction aborted for unknown reason"))}),r.active=!1,r.on("abort").fire(n)},c.oncomplete=function(n){r.active=!1,r.on("complete").fire(n)}}e&&r._lock();try{t(i,u,r)}catch(a){o.ignoreTransaction(function(){r.on("error").fire(a)}),r.abort();try{throw new kn(a)}catch(s){u(s)}}}):J.reject(C(new kn("Transaction is inactive. Original Scope Function Source: "+r.scopeFunc.toString()))),r.active&&e&&i["finally"](function(){r._unlock()})),i.onuncatched=function(n){o.ignoreTransaction(function(){r.on("error").fire(n)}),r.abort()},i})},complete:function(n){return this.on("complete",n)},error:function(n){return this.on("error",n)},abort:function(){if(this.idbtrans&&this.active)try{this.active=!1,this.idbtrans.abort(),this.on.error.fire(new kn("Transaction Aborted"))}catch(n){}},table:function(n){if(!this.tables.hasOwnProperty(n))throw new kn("Table "+n+" not in transaction");return this.tables[n]}}),n(tn.prototype,function(){function n(n,t,e){var r=n instanceof tn?new n._ctx.collClass(n):n;try{throw e?new e(t):new Dn(t)}catch(o){r._ctx.error=o}return r}function t(n){return new n._ctx.collClass(n,function(){return Sn.only("")}).limit(0)}function r(n){return e(1===n.length&&M(n[0])?n[0]:n)}function o(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function i(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function u(n,t,e,r,o,i){for(var u=Math.min(n.length,r.length),c=-1,a=0;u>a;++a){var s=t[a];if(s!==r[a])return o(n[a],e[a])<0?n.substr(0,a)+e[a]+e.substr(a+1):o(n[a],r[a])<0?n.substr(0,a)+r[a]+e.substr(a+1):c>=0?n.substr(0,c)+t[c]+e.substr(c+1):null;o(n[a],s)<0&&(c=a)}return u<r.length&&"next"===i?n+e.substr(n.length):u<n.length&&"prev"===i?n.substr(0,e.length):0>c?null:n.substr(0,c)+r[c]+e.substr(c+1)}function c(n,t,e,r){function c(n){a=o(n),s=i(n),f="next"===n?vn:yn;var t=e.map(function(n){return{lower:s(n),upper:a(n)}}).sort(function(n,t){return f(n.lower,t.lower)});h=t.map(function(n){return n.upper}),l=t.map(function(n){return n.lower}),d=n,p="next"===n?"":r}var a,s,f,h,l,d,p,v=e.length;c("next");var y=new n._ctx.collClass(n,function(){return Sn.bound(h[0],l[v-1]+r)});y._ondirectionchange=function(n){c(n)};var m=0;return y._addAlgorithm(function(n,e,r){var o=n.key;if("string"!=typeof o)return!1;var i=s(o);if(t(i,l,m))return!0;for(var c=null,a=m;v>a;++a){var y=u(o,i,h[a],l[a],f,d);null===y&&null===c?m=a+1:(null===c||f(c,y)>0)&&(c=y)}return e(null!==c?function(){n["continue"](c+p)}:r),!1}),y}return{between:function(e,r,o,i){o=o!==!1,i=i===!0;try{return fn(e,r)>0||0===fn(e,r)&&(o||i)&&(!o||!i)?t(this):new this._ctx.collClass(this,function(){return Sn.bound(e,r,!o,!i)})}catch(u){return n(this,z)}},equals:function(n){return new this._ctx.collClass(this,function(){return Sn.only(n)})},above:function(n){return new this._ctx.collClass(this,function(){return Sn.lowerBound(n,!0)})},aboveOrEqual:function(n){return new this._ctx.collClass(this,function(){return Sn.lowerBound(n)})},below:function(n){return new this._ctx.collClass(this,function(){return Sn.upperBound(n,!0)})},belowOrEqual:function(n){return new this._ctx.collClass(this,function(){return Sn.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,"String expected"):this.between(t,t+L,!0,!0)},startsWithIgnoreCase:function(t){return"string"!=typeof t?n(this,"String expected"):""===t?this.startsWith(t):c(this,function(n,t){return 0===n.indexOf(t[0])},[t],L)},equalsIgnoreCase:function(t){return"string"!=typeof t?n(this,"String expected"):c(this,function(n,t){return n===t[0]},[t],"")},anyOfIgnoreCase:function(e){var o=r(arguments);return 0===o.length?t(this):o.every(function(n){return"string"==typeof n})?c(this,function(n,t){return-1!==t.indexOf(n)},o,""):n(this,"anyOfIgnoreCase() only works with strings")},startsWithAnyOfIgnoreCase:function(e){var o=r(arguments);return 0===o.length?t(this):o.every(function(n){return"string"==typeof n})?c(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},o,L):n(this,"anyOfIgnoreCase() only works with strings")},anyOf:function(e){var o=r(arguments),i=dn;try{o.sort(i)}catch(u){return n(this,z)}if(0===o.length)return t(this);var c=new this._ctx.collClass(this,function(){return Sn.bound(o[0],o[o.length-1])});c._ondirectionchange=function(n){i="next"===n?dn:pn,o.sort(i)};var a=0;return c._addAlgorithm(function(n,t,e){for(var r=n.key;i(r,o[a])>0;)if(++a,a===o.length)return t(e),!1;return 0===i(r,o[a])?!0:(t(function(){n["continue"](o[a])}),!1)}),c},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,V]],{includeLowers:!1,includeUppers:!1})},noneOf:function(t){var e=r(arguments);if(0===e.length)return new this._ctx.collClass(this);try{e.sort(dn)}catch(o){return n(this,z)}var i=e.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return i.push([e[e.length-1],V]),this.inAnyRange(i,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function o(n,t){for(var e=0,r=n.length;r>e;++e){var o=n[e];if(fn(t[0],o[1])<0&&fn(t[1],o[0])>0){o[0]=hn(o[0],t[0]),o[1]=ln(o[1],t[1]);break}}return e===r&&n.push(t),n}function i(n,t){return h(n[0],t[0])}function u(n){return!p(n)&&!v(n)}var c=this._ctx;if(0===e.length)return t(this);if(!e.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&dn(n[0],n[1])<=0}))return n(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",kn);var a,s=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,h=dn;try{a=e.reduce(o,[]),a.sort(i)}catch(l){return n(this,z)}var d=0,p=f?function(n){return dn(n,a[d][1])>0}:function(n){return dn(n,a[d][1])>=0},v=s?function(n){return pn(n,a[d][0])>0}:function(n){return pn(n,a[d][0])>=0},y=p,m=new c.collClass(this,function(){return Sn.bound(a[0][0],a[a.length-1][1],!s,!f)});return m._ondirectionchange=function(n){"next"===n?(y=p,h=dn):(y=v,h=pn),a.sort(i)},m._addAlgorithm(function(n,t,e){for(var r=n.key;y(r);)if(++d,d===a.length)return t(e),!1;return u(r)?!0:0===fn(r,a[d][1])||0===fn(r,a[d][0])?!1:(t(function(){h===dn?n["continue"](a[d][0]):n["continue"](a[d][1])}),!1)}),m},startsWithAnyOf:function(e){var o=r(arguments);return o.every(function(n){return"string"==typeof n})?0===o.length?t(this):this.inAnyRange(o.map(function(n){return[n,n+L]})):n(this,"startsWithAnyOf() only works with strings")}}}),n(en.prototype,function(){function n(n,t){n.filter=mn(n.filter,t)}function t(n,t){n.isMatch=mn(n.isMatch,t)}function e(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new kn("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return n.isPrimKey?t:t.index(e.name)}function r(n,t){return e(n,t)[n.op](n.range||null,n.dir+n.unique)}function o(n,t,e,o,i){n.or?!function(){function u(){2===++f&&e()}function c(n,e,r){if(!a||a(e,r,u,o)){var i=e.primaryKey.toString();s.hasOwnProperty(i)||(s[i]=!0,t(n,e,r))}}var a=n.filter,s={},f=0;n.or._iterate(c,u,o,i),an(r(n,i),n.algorithm,c,u,o,n.table.hook.reading.fire)}():an(r(n,i),mn(n.algorithm,n.filter),t,e,o,n.table.hook.reading.fire)}function i(n){return n.table.schema.instanceTemplate}return{_read:function(n,t){var e=this._ctx;return e.error?e.table._trans(null,function(n,t){t(e.error)}):e.table._idbstore(Nn,n).then(t)},_write:function(n){var t=this._ctx;return t.error?t.table._trans(null,function(n,e){e(t.error)}):t.table._idbstore(Fn,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=mn(t.algorithm,n)},_iterate:function(n,t,e,r){return o(this._ctx,n,t,e,r)},each:function(n){var t=this._ctx;return Y&&n(i(t)),this._read(function(e,r,i){o(t,n,e,r,i)})},count:function(n){if(Y)return J.resolve(0).then(n);var t=this,r=this._ctx;if(r.filter||r.algorithm||r.or){var i=0;return this._read(function(n,t,e){o(r,function(){return++i,!1},function(){n(i)},t,e)},n)}return this._read(function(n,o,i){var u=e(r,i),c=r.range?u.count(r.range):u.count();c.onerror=j(o,["calling","count()","on",t.name]),c.onsuccess=function(t){n(Math.min(t.target.result,Math.max(0,r.limit-r.offset)))}},n)},sortBy:function(n,t){function e(n,t){return t?e(n[o[t]],t-1):n[i]}function r(n,t){var r=e(n,u),o=e(t,u);return o>r?-c:r>o?c:0}var o=n.split(".").reverse(),i=o[0],u=o.length-1,c="next"===this._ctx.dir?1:-1;return this.toArray(function(n){return n.sort(r)}).then(t)},toArray:function(n){var t=this._ctx;return this._read(function(n,e,r){Y&&n([i(t)]);var u=[];o(t,function(n){u.push(n)},function(){n(u)},e,r)},n)},offset:function(t){var e=this._ctx;return 0>=t?this:(e.offset+=t,e.or||e.algorithm||e.filter?n(e,function(n,e,r){return--t<0}):n(e,function(n,e,r){return 0===t?!0:1===t?(--t,!1):(e(function(){n.advance(t),t=0}),!1)}),this)},limit:function(t){return this._ctx.limit=Math.min(this._ctx.limit,t),n(this._ctx,function(n,e,r){return--t<=0&&e(r),t>=0}),this},until:function(t,e){var r=this._ctx;return Y&&t(i(r)),n(this._ctx,function(n,r,o){return t(n.value)?(r(o),e):!0}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},and:function(e){return Y&&e(i(this._ctx)),n(this._ctx,function(n){return e(n.value)}),t(this._ctx,e),this},or:function(n){return new tn(this._ctx.table,n,this)},reverse:function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},desc:function(){return this.reverse()},eachKey:function(n){var t=this._ctx;return Y&&n(_(i(this._ctx),this._ctx.index?this._ctx.table.schema.idxByName[this._ctx.index].keyPath:this._ctx.table.schema.primKey.keyPath)),t.isPrimKey||(t.op="openKeyCursor"),this.each(function(t,e){n(e.key,e)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},keys:function(n){var t=this._ctx;t.isPrimKey||(t.op="openKeyCursor");var e=[];return Y?new J(this.eachKey.bind(this)).then(function(n){return[n]}).then(n):this.each(function(n,t){e.push(t.key)}).then(function(){return e}).then(n)},uniqueKeys:function(n){return this._ctx.unique="unique",this.keys(n)},firstKey:function(n){return this.limit(1).keys(function(n){return n[0]}).then(n)},lastKey:function(n){return this.reverse().firstKey(n)},distinct:function(){var t={};return n(this._ctx,function(n){var e=n.primaryKey.toString(),r=t.hasOwnProperty(e);return t[e]=!0,!r}),this}}}),t(rn).from(en).extend({modify:function(t){var e=this,r=this._ctx,o=r.table.hook,u=o.updating.fire,c=o.deleting.fire;return Y&&"function"==typeof t&&t.call({value:r.table.schema.instanceTemplate},r.table.schema.instanceTemplate),this._write(function(o,a,s,f){function h(n,t,e){function o(n){return O.push(n),E.push(i.primKey),i.onerror&&J.newPSD(function(){J.PSD.trans=f,i.onerror(n)}),d(),!0}C=t.primaryKey;var i={primKey:t.primaryKey,value:n,onsuccess:null,onerror:null};if(p.call(i,n)!==!1){var u=!i.hasOwnProperty("value");++b,w(function(){var e=u?t["delete"]():t.update(i.value);e.onerror=j(o,u?["deleting",n,"from",r.table.name]:["modifying",n,"on",r.table.name]),e.onsuccess=function(n){i.onsuccess&&J.newPSD(function(){J.PSD.trans=f,i.onsuccess(i.value)}),++g,d()}},o)}else i.onsuccess&&i.onsuccess(i.value)}function l(n){return n&&(O.push(n),E.push(C)),a(new N("Error modifying one or more objects",O,g,E))}function d(){P&&g+O.length===b&&(O.length>0?l():o(g))}var p;if("function"==typeof t)p=u===i&&c===i?t:function(n){var e=D(n);if(t.call(this,n)===!1)return!1; | ||
if(this.hasOwnProperty("value")){var r=k(e,this.value),o=u.call(this,r,this.primKey,e,f);o&&(n=this.value,R(o).forEach(function(t){x(n,t,o[t])}))}else c.call(this,this.primKey,n,f)};else if(u===i){var v=R(t),y=v.length;p=function(n){for(var e=!1,r=0;y>r;++r){var o=v[r],i=t[o];_(n,o)!==i&&(x(n,o,i),e=!0)}return e}}else{var m=t;t=S(m),p=function(e){var r=!1,o=u.call(this,t,this.primKey,D(e),f);return o&&n(t,o),R(t).forEach(function(n){var o=t[n];_(e,n)!==o&&(x(e,n,o),r=!0)}),o&&(t=S(m)),r}}var b=0,g=0,P=!1,O=[],E=[],C=null;e._iterate(h,function(){P=!0,d()},l,s)})},"delete":function(){return this.modify(function(){delete this.value})}}),n(this,{Collection:en,Table:Z,Transaction:nn,Version:b,WhereClause:tn,WriteableCollection:rn,WriteableTable:$}),y(),_n.forEach(function(n){n(qn)})}function i(){}function u(n){return n}function c(n,t){return n===u?t:function(e){return t(n(e))}}function a(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function s(n,t){return n===i?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?a(r,this.onsuccess):r),o&&(this.onerror=this.onerror?a(o,this.onerror):o),void 0!==i?i:e}}function f(t,e){return t===i?e:function(){var r=t.apply(this,arguments);void 0!==r&&n(arguments[0],r);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var u=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?a(o,this.onsuccess):o),i&&(this.onerror=this.onerror?a(i,this.onerror):i),void 0===r?void 0===u?void 0:u:void 0===u?r:n(r,u)}}function h(n,t){return n===i?t:function(){return n.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function l(n,t){return n===i?t:function(){return t.apply(this,arguments)===!1?!1:n.apply(this,arguments)}}function d(n,t){return n===i?t:function(){n.apply(this,arguments),t.apply(this,arguments)}}function p(n,t){return n===i?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){var r=this,o=arguments;return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function v(n,t){function r(n,t,e){if(M(n))return u(n);if("object"==typeof n)return o(n);t||(t=h),e||(e=i);var r={subscribers:[],fire:e,subscribe:function(n){r.subscribers.push(n),r.fire=t(r.fire,n)},unsubscribe:function(n){r.subscribers=r.subscribers.filter(function(t){return t!==n}),r.fire=r.subscribers.reduce(t,e)}};return a[n]=s[n]=r,r}function o(n){R(n).forEach(function(t){var e=n[t];if(M(e))r(t,n[t][0],n[t][1]);else{if("asap"!==e)throw new Error("Invalid event config");var o=r(t,null,function(){var n=arguments;o.subscribers.forEach(function(t){m(function(){t.apply(W,n)})})});o.subscribe=function(n){-1===o.subscribers.indexOf(n)&&o.subscribers.push(n)},o.unsubscribe=function(n){var t=o.subscribers.indexOf(n);-1!==t&&o.subscribers.splice(t,1)}}})}function u(n){function t(){return e?!1:void(e=!0)}var e=!1;n.forEach(function(n){r(n).subscribe(t)})}var c=arguments,a={},s=function(t,r){if(r){var o=e(arguments,1),i=a[t];return i.subscribe.apply(i,o),n}return"string"==typeof t?a[t]:void 0};s.addEventType=r;for(var f=1,l=c.length;l>f;++f)r(c[f]);return s}function y(n){if(!n)throw new Error("Assertion failed")}function m(n){W.setImmediate?setImmediate(n):setTimeout(n,0)}function b(n){var t=setTimeout(n,1e3);clearTimeout(t)}function g(n,t,e){return function(){var r=J.PSD;J.PSD=e;try{n.apply(this,arguments)}catch(o){t(o)}finally{J.PSD=r}}}function w(n,t){try{n()}catch(e){t(e)}}function _(n,t){if(n.hasOwnProperty(t))return n[t];if(!t)return n;if("string"!=typeof t){for(var e=[],r=0,o=t.length;o>r;++r){var i=_(n,t[r]);e.push(i)}return e}var u=t.indexOf(".");if(-1!==u){var c=n[t.substr(0,u)];return void 0===c?void 0:_(c,t.substr(u+1))}}function x(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){y("string"!=typeof e&&"length"in e);for(var r=0,o=t.length;o>r;++r)x(n,t[r],e[r])}else{var i=t.indexOf(".");if(-1!==i){var u=t.substr(0,i),c=t.substr(i+1);if(""===c)void 0===e?delete n[u]:n[u]=e;else{var a=n[u];a||(a=n[u]={}),x(a,c,e)}}else void 0===e?delete n[t]:n[t]=e}}function P(n,t){"string"==typeof t?x(n,t,void 0):"length"in t&&[].map.call(t,function(t){x(n,t,void 0)})}function S(n){var t={};for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t}function D(n){if(!n||"object"!=typeof n)return n;var t;if(M(n)){t=[];for(var e=0,r=n.length;r>e;++e)t.push(D(n[e]))}else if(n instanceof Date)t=new Date,t.setTime(n.getTime());else{t=n.constructor?Object.create(n.constructor.prototype):{};for(var o in n)n.hasOwnProperty(o)&&(t[o]=D(n[o]))}return t}function k(n,t){var e={};for(var r in n)n.hasOwnProperty(r)&&(t.hasOwnProperty(r)?n[r]!==t[r]&&JSON.stringify(n[r])!=JSON.stringify(t[r])&&(e[r]=t[r]):e[r]=void 0);for(var r in t)t.hasOwnProperty(r)&&!n.hasOwnProperty(r)&&(e[r]=t[r]);return e}function O(n){if("function"==typeof n)return new n;if(M(n))return[O(n[0])];if(n&&"object"==typeof n){var t={};return E(t,n),t}return n}function E(n,t){return R(t).forEach(function(e){var r=O(t[e]);n[e]=r}),n}function j(n,t){return function(e){var r=e&&e.target.error||new Error;if(t){var o=" occurred when "+t.map(function(n){switch(typeof n){case"function":return n();case"string":return n;default:return JSON.stringify(n)}}).join(" ");r.name?r.toString=function(){return r.name+o+(r.message?". "+r.message:"")}:r+=o}return n(r),e&&(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()),!1}}function C(n){try{throw n}catch(t){return t}}function T(n){n.preventDefault()}function K(n){var t,e=o.dependencies.localStorage;if(!e)return n([]);try{t=JSON.parse(e.getItem("Dexie.DatabaseNames")||"[]")}catch(r){t=[]}n(t)&&e.setItem("Dexie.DatabaseNames",JSON.stringify(t))}function I(n){function t(n){return function(t){var r=n(t),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(i,u):Array.isArray(o)?e(o,0):i(o)}}function e(n,t){if(t===n.length)return i(n);var r=n[t];return r.constructor&&"function"==typeof r.constructor.all?r.constructor.all(n).then(i,u):e(n,t+1)}var r=function(t){return n.next(t)},o=function(t){return n["throw"](t)},i=t(r),u=t(o);return t(r)()}function A(n,t,e,r,o,i,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=o,this.compound=i,this.dotted=u;var c="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(o?"++":"")+c}function B(n,t,e,r){this.name=n,this.primKey=t||new A,this.indexes=e||[new A],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=e.reduce(function(n,t){return n[t.name]=t,n},{})}function N(n,t,e,r){this.name="ModifyError",this.failures=t,this.failedKeys=r,this.successCount=e,this.message=t.join("\n")}function F(n){return 1===n.length?n[0]:n}function q(){var n=o.dependencies.indexedDB,t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var R=Object.keys,M=Array.isArray,U=[].slice;if("undefined"==typeof W)var W=self||window;var L=String.fromCharCode(65535),V=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return L}}(),z="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",J=function(){function n(n,t){m.push([n,e(arguments,1)])}function t(){var n=m;m=[];for(var t=0,e=n.length;e>t;++t){var r=n[t];r[0].apply(W,r[1])}}function r(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],this._catched=!1;var t=this,e=!0;this._PSD=r.PSD;try{l(this,n,function(n){e?p(a,t,n):a(t,n)},function(n){return e?(p(s,t,n),!1):s(t,n)})}finally{e=!1}}function o(e,o){if(null===e._state)return void e._deferreds.push(o);var i=e._state?o.onFulfilled:o.onRejected;if(null===i)return(e._state?o.resolve:o.reject)(e._value);var u,a=y;y=!1,p=n;try{var s=r.PSD;r.PSD=e._PSD,u=i(e._value),e._state||u&&"function"==typeof u.then&&u._state===!1||c(e),o.resolve(u)}catch(f){var h=o.reject(f);if(!h&&e.onuncatched)try{e.onuncatched(f)}catch(f){}}finally{if(r.PSD=s,a){do{for(;m.length>0;)t();var l=g.pop();if(l)try{l()}catch(f){}}while(g.length>0||m.length>0);p=d,y=!0}}}function u(e){var r=y;y=!1,p=n;try{e()}finally{if(r){do{for(;m.length>0;)t();var o=g.pop();if(o)try{o()}catch(i){}}while(g.length>0||m.length>0);p=d,y=!0}}}function c(n){n._catched=!0,n._parent&&c(n._parent)}function a(n,t){var e=r.PSD;r.PSD=n._PSD;try{if(t===n)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)return void l(n,function(n,e){t.then(n,e)},function(t){a(n,t)},function(t){s(n,t)});n._state=!0,n._value=t,f.call(n)}catch(o){s(o)}finally{r.PSD=e}}function s(n,t){var e=r.PSD;if(r.PSD=n._PSD,n._state=!1,n._value=t,f.call(n),!n._catched)try{n.onuncatched&&n.onuncatched(n._value),r.on.error.fire(n._value)}catch(o){}return r.PSD=e,n._catched}function f(){for(var n=0,t=this._deferreds.length;t>n;n++)o(this,this._deferreds[n]);this._deferreds=[]}function h(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r}function l(n,t,e,r){var o=!1;try{t(function(n){o||(o=!0,e(n))},function(t){return o?n._catched:(o=!0,r(t))})}catch(i){if(o)return;return r(i)}}var d=W.setImmediate||function(n){var t=e(arguments,1);setTimeout(function(){n.apply(W,t)},0)};b(function(){d=p=n=function(n){var t=arguments;setTimeout(function(){n.apply(W,e(t,1))},0)}});var p=d,y=!0,m=[],g=[];return r.on=v(null,"error"),r.all=function(){var n=e(1===arguments.length&&M(arguments[0])?arguments[0]:arguments);return new r(function(t,e){function r(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var c=u.then;if("function"==typeof c)return void c.call(u,function(n){r(i,n)},e)}n[i]=u,0===--o&&t(n)}catch(a){e(a)}}if(0===n.length)return t([]);for(var o=n.length,i=0;i<n.length;i++)r(i,n[i])})},r.prototype.then=function(n,t){var e=this,i=new r(function(r,i){null===e._state?o(e,new h(n,t,r,i)):p(o,e,new h(n,t,r,i))});return i._PSD=this._PSD,i.onuncatched=this.onuncatched,i._parent=this,i},r.prototype._then=function(n,t){o(this,new h(n,t,i,i))},r.prototype["catch"]=function(n){if(1===arguments.length)return this.then(null,n);var t=arguments[0],e=arguments[1];return"function"==typeof t?this.then(null,function(n){return n instanceof t?e(n):r.reject(n)}):this.then(null,function(n){return n&&n.name===t?e(n):r.reject(n)})},r.prototype["finally"]=function(n){return this.then(function(t){return n(),t},function(t){return n(),r.reject(t)})},r.prototype.onuncatched=null,r.resolve=function(n){if(n&&"function"==typeof n.then)return n;var t=new r(function(){});return t._state=!0,t._value=n,t},r.reject=function(n){var t=new r(function(){});return t._state=!1,t._value=n,t},r.race=function(n){return new r(function(t,e){n.map(function(n){n.then(t,e)})})},r.PSD=null,r.newPSD=function(n){var t=r.PSD;r.PSD=t?Object.create(t):{};try{return n()}finally{r.PSD=t}},r._rootExec=u,r._tickFinalize=function(n){if(y)throw new Error("Not in a virtual tick");g.push(n)},r}(),H=function(){},Y=!1;t(N).from(Error),o["delete"]=function(n){var t=new o(n),e=t["delete"]();return e.onblocked=function(n){return t.on("blocked",n),this},e},o.exists=function(n){return new o(n).open().then(function(n){return n.close(),!0},function(){return!1})},o.getDatabaseNames=function(n){return new J(function(n,t){var r=q();if(r){var o=r();o.onsuccess=function(t){n(e(t.target.result,0))},o.onerror=j(t)}else K(function(t){return n(t),!1})}).then(n)},o.defineClass=function(t){function e(e){e?n(this,e):Y&&E(this,t)}return e},o.applyStructure=E,o.ignoreTransaction=function(n){return J.newPSD(function(){return J.PSD.trans=null,n()})},o.vip=function(n){return J.newPSD(function(){return J.PSD.letThrough=!0,n()})},o.async=function(n){return function(){try{var t=I(n.apply(this,arguments));return t&&"function"==typeof t.then?t:o.Promise.resolve(t)}catch(e){return o.Promise.reject(e)}}},o.spawn=function(n,t,e){try{var r=I(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:o.Promise.resolve(r)}catch(i){return o.Promise.reject(i)}},Object.defineProperty(o,"currentTransaction",{get:function(){return J.PSD&&J.PSD.trans||null}}),o.Promise=J,o.derive=t,o.extend=n,o.override=r,o.events=v,o.getByKeyPath=_,o.setByKeyPath=x,o.delByKeyPath=P,o.shallowClone=S,o.deepClone=D,o.addons=[],o.fakeAutoComplete=H,o.asap=m,o.ModifyError=N,o.MultiModifyError=N,o.IndexSpec=A,o.TableSchema=B,o.MaxKey=V;var G=W.idbModules&&W.idbModules.shimIndexedDB?W.idbModules:{};return o.dependencies={indexedDB:G.shimIndexedDB||W.indexedDB||W.mozIndexedDB||W.webkitIndexedDB||W.msIndexedDB,IDBKeyRange:G.IDBKeyRange||W.IDBKeyRange||W.webkitIDBKeyRange,Error:W.Error||String,SyntaxError:W.SyntaxError||String,TypeError:W.TypeError||String,localStorage:null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:W.localStorage},o.semVer="1.3.0",o.version=o.semVer.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),b(function(){o.fakeAutoComplete=H=b,o.fake=Y=!0}),o}); | ||
if(this.hasOwnProperty("value")){var r=k(e,this.value),o=u.call(this,r,this.primKey,e,f);o&&(n=this.value,R(o).forEach(function(t){x(n,t,o[t])}))}else c.call(this,this.primKey,n,f)};else if(u===i){var v=R(t),y=v.length;p=function(n){for(var e=!1,r=0;y>r;++r){var o=v[r],i=t[o];_(n,o)!==i&&(x(n,o,i),e=!0)}return e}}else{var m=t;t=S(m),p=function(e){var r=!1,o=u.call(this,t,this.primKey,D(e),f);return o&&n(t,o),R(t).forEach(function(n){var o=t[n];_(e,n)!==o&&(x(e,n,o),r=!0)}),o&&(t=S(m)),r}}var b=0,g=0,P=!1,O=[],E=[],C=null;e._iterate(h,function(){P=!0,d()},l,s)})},"delete":function(){return this.modify(function(){delete this.value})}}),n(this,{Collection:en,Table:Z,Transaction:nn,Version:b,WhereClause:tn,WriteableCollection:rn,WriteableTable:$}),y(),_n.forEach(function(n){n(qn)})}function i(){}function u(n){return n}function c(n,t){return n===u?t:function(e){return t(n(e))}}function a(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function s(n,t){return n===i?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?a(r,this.onsuccess):r),o&&(this.onerror=this.onerror?a(o,this.onerror):o),void 0!==i?i:e}}function f(t,e){return t===i?e:function(){var r=t.apply(this,arguments);void 0!==r&&n(arguments[0],r);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var u=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?a(o,this.onsuccess):o),i&&(this.onerror=this.onerror?a(i,this.onerror):i),void 0===r?void 0===u?void 0:u:void 0===u?r:n(r,u)}}function h(n,t){return n===i?t:function(){return n.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function l(n,t){return n===i?t:function(){return t.apply(this,arguments)===!1?!1:n.apply(this,arguments)}}function d(n,t){return n===i?t:function(){n.apply(this,arguments),t.apply(this,arguments)}}function p(n,t){return n===i?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){var r=this,o=arguments;return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function v(n,t){function r(n,t,e){if(M(n))return u(n);if("object"==typeof n)return o(n);t||(t=h),e||(e=i);var r={subscribers:[],fire:e,subscribe:function(n){r.subscribers.push(n),r.fire=t(r.fire,n)},unsubscribe:function(n){r.subscribers=r.subscribers.filter(function(t){return t!==n}),r.fire=r.subscribers.reduce(t,e)}};return a[n]=s[n]=r,r}function o(n){R(n).forEach(function(t){var e=n[t];if(M(e))r(t,n[t][0],n[t][1]);else{if("asap"!==e)throw new Error("Invalid event config");var o=r(t,null,function(){var n=arguments;o.subscribers.forEach(function(t){m(function(){t.apply(W,n)})})});o.subscribe=function(n){-1===o.subscribers.indexOf(n)&&o.subscribers.push(n)},o.unsubscribe=function(n){var t=o.subscribers.indexOf(n);-1!==t&&o.subscribers.splice(t,1)}}})}function u(n){function t(){return e?!1:void(e=!0)}var e=!1;n.forEach(function(n){r(n).subscribe(t)})}var c=arguments,a={},s=function(t,r){if(r){var o=e(arguments,1),i=a[t];return i.subscribe.apply(i,o),n}return"string"==typeof t?a[t]:void 0};s.addEventType=r;for(var f=1,l=c.length;l>f;++f)r(c[f]);return s}function y(n){if(!n)throw new Error("Assertion failed")}function m(n){W.setImmediate?setImmediate(n):setTimeout(n,0)}function b(n){var t=setTimeout(n,1e3);clearTimeout(t)}function g(n,t,e){return function(){var r=J.PSD;J.PSD=e;try{n.apply(this,arguments)}catch(o){t(o)}finally{J.PSD=r}}}function w(n,t){try{n()}catch(e){t(e)}}function _(n,t){if(n.hasOwnProperty(t))return n[t];if(!t)return n;if("string"!=typeof t){for(var e=[],r=0,o=t.length;o>r;++r){var i=_(n,t[r]);e.push(i)}return e}var u=t.indexOf(".");if(-1!==u){var c=n[t.substr(0,u)];return void 0===c?void 0:_(c,t.substr(u+1))}}function x(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){y("string"!=typeof e&&"length"in e);for(var r=0,o=t.length;o>r;++r)x(n,t[r],e[r])}else{var i=t.indexOf(".");if(-1!==i){var u=t.substr(0,i),c=t.substr(i+1);if(""===c)void 0===e?delete n[u]:n[u]=e;else{var a=n[u];a||(a=n[u]={}),x(a,c,e)}}else void 0===e?delete n[t]:n[t]=e}}function P(n,t){"string"==typeof t?x(n,t,void 0):"length"in t&&[].map.call(t,function(t){x(n,t,void 0)})}function S(n){var t={};for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t}function D(n){if(!n||"object"!=typeof n)return n;var t;if(M(n)){t=[];for(var e=0,r=n.length;r>e;++e)t.push(D(n[e]))}else if(n instanceof Date)t=new Date,t.setTime(n.getTime());else{t=n.constructor?Object.create(n.constructor.prototype):{};for(var o in n)n.hasOwnProperty(o)&&(t[o]=D(n[o]))}return t}function k(n,t){var e={};for(var r in n)n.hasOwnProperty(r)&&(t.hasOwnProperty(r)?n[r]!==t[r]&&JSON.stringify(n[r])!=JSON.stringify(t[r])&&(e[r]=t[r]):e[r]=void 0);for(var r in t)t.hasOwnProperty(r)&&!n.hasOwnProperty(r)&&(e[r]=t[r]);return e}function O(n){if("function"==typeof n)return new n;if(M(n))return[O(n[0])];if(n&&"object"==typeof n){var t={};return E(t,n),t}return n}function E(n,t){return R(t).forEach(function(e){var r=O(t[e]);n[e]=r}),n}function j(n,t){return function(e){var r=e&&e.target.error||new Error;if(t){var o=" occurred when "+t.map(function(n){switch(typeof n){case"function":return n();case"string":return n;default:return JSON.stringify(n)}}).join(" ");r.name?r.toString=function(){return r.name+o+(r.message?". "+r.message:"")}:r+=o}return n(r),e&&(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()),!1}}function C(n){try{throw n}catch(t){return t}}function T(n){n.preventDefault()}function K(n){var t,e=o.dependencies.localStorage;if(!e)return n([]);try{t=JSON.parse(e.getItem("Dexie.DatabaseNames")||"[]")}catch(r){t=[]}n(t)&&e.setItem("Dexie.DatabaseNames",JSON.stringify(t))}function I(n){function t(n){return function(t){var r=n(t),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(i,u):Array.isArray(o)?e(o,0):i(o)}}function e(n,t){if(t===n.length)return i(n);var r=n[t];return r.constructor&&"function"==typeof r.constructor.all?r.constructor.all(n).then(i,u):e(n,t+1)}var r=function(t){return n.next(t)},o=function(t){return n["throw"](t)},i=t(r),u=t(o);return t(r)()}function A(n,t,e,r,o,i,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=o,this.compound=i,this.dotted=u;var c="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(o?"++":"")+c}function B(n,t,e,r){this.name=n,this.primKey=t||new A,this.indexes=e||[new A],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=e.reduce(function(n,t){return n[t.name]=t,n},{})}function N(n,t,e,r){this.name="ModifyError",this.failures=t,this.failedKeys=r,this.successCount=e,this.message=t.join("\n")}function F(n){return 1===n.length?n[0]:n}function q(){var n=o.dependencies.indexedDB,t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var R=Object.keys,M=Array.isArray,U=[].slice;if("undefined"==typeof W)var W=self||window;var L=String.fromCharCode(65535),V=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return L}}(),z="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",J=function(){function n(n,t){m.push([n,e(arguments,1)])}function t(){var n=m;m=[];for(var t=0,e=n.length;e>t;++t){var r=n[t];r[0].apply(W,r[1])}}function r(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],this._catched=!1;var t=this,e=!0;this._PSD=r.PSD;try{l(this,n,function(n){e?p(a,t,n):a(t,n)},function(n){return e?(p(s,t,n),!1):s(t,n)})}finally{e=!1}}function o(e,o){if(null===e._state)return void e._deferreds.push(o);var i=e._state?o.onFulfilled:o.onRejected;if(null===i)return(e._state?o.resolve:o.reject)(e._value);var u,a=y;y=!1,p=n;try{var s=r.PSD;r.PSD=e._PSD,u=i(e._value),e._state||u&&"function"==typeof u.then&&u._state===!1||c(e),o.resolve(u)}catch(f){var h=o.reject(f);if(!h&&e.onuncatched)try{e.onuncatched(f)}catch(f){}}finally{if(r.PSD=s,a){do{for(;m.length>0;)t();var l=g.pop();if(l)try{l()}catch(f){}}while(g.length>0||m.length>0);p=d,y=!0}}}function u(e){var r=y;y=!1,p=n;try{e()}finally{if(r){do{for(;m.length>0;)t();var o=g.pop();if(o)try{o()}catch(i){}}while(g.length>0||m.length>0);p=d,y=!0}}}function c(n){n._catched=!0,n._parent&&c(n._parent)}function a(n,t){var e=r.PSD;r.PSD=n._PSD;try{if(t===n)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)return void l(n,function(n,e){t.then(n,e)},function(t){a(n,t)},function(t){s(n,t)});n._state=!0,n._value=t,f.call(n)}catch(o){s(o)}finally{r.PSD=e}}function s(n,t){var e=r.PSD;if(r.PSD=n._PSD,n._state=!1,n._value=t,f.call(n),!n._catched)try{n.onuncatched&&n.onuncatched(n._value),r.on.error.fire(n._value)}catch(o){}return r.PSD=e,n._catched}function f(){for(var n=0,t=this._deferreds.length;t>n;n++)o(this,this._deferreds[n]);this._deferreds=[]}function h(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r}function l(n,t,e,r){var o=!1;try{t(function(n){o||(o=!0,e(n))},function(t){return o?n._catched:(o=!0,r(t))})}catch(i){if(o)return;return r(i)}}var d=W.setImmediate||function(n){var t=e(arguments,1);setTimeout(function(){n.apply(W,t)},0)};b(function(){d=p=n=function(n){var t=arguments;setTimeout(function(){n.apply(W,e(t,1))},0)}});var p=d,y=!0,m=[],g=[];return r.on=v(null,"error"),r.all=function(){var n=e(1===arguments.length&&M(arguments[0])?arguments[0]:arguments);return new r(function(t,e){function r(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var c=u.then;if("function"==typeof c)return void c.call(u,function(n){r(i,n)},e)}n[i]=u,0===--o&&t(n)}catch(a){e(a)}}if(0===n.length)return t([]);for(var o=n.length,i=0;i<n.length;i++)r(i,n[i])})},r.prototype.then=function(n,t){var e=this,i=new r(function(r,i){null===e._state?o(e,new h(n,t,r,i)):p(o,e,new h(n,t,r,i))});return i._PSD=this._PSD,i.onuncatched=this.onuncatched,i._parent=this,i},r.prototype._then=function(n,t){o(this,new h(n,t,i,i))},r.prototype["catch"]=function(n){if(1===arguments.length)return this.then(null,n);var t=arguments[0],e=arguments[1];return"function"==typeof t?this.then(null,function(n){return n instanceof t?e(n):r.reject(n)}):this.then(null,function(n){return n&&n.name===t?e(n):r.reject(n)})},r.prototype["finally"]=function(n){return this.then(function(t){return n(),t},function(t){return n(),r.reject(t)})},r.prototype.onuncatched=null,r.resolve=function(n){if(n&&"function"==typeof n.then)return n;var t=new r(function(){});return t._state=!0,t._value=n,t},r.reject=function(n){var t=new r(function(){});return t._state=!1,t._value=n,t},r.race=function(n){return new r(function(t,e){n.map(function(n){n.then(t,e)})})},r.PSD=null,r.newPSD=function(n){var t=r.PSD;r.PSD=t?Object.create(t):{};try{return n()}finally{r.PSD=t}},r._rootExec=u,r._tickFinalize=function(n){if(y)throw new Error("Not in a virtual tick");g.push(n)},r}(),H=function(){},Y=!1;t(N).from(Error),o["delete"]=function(n){var t=new o(n),e=t["delete"]();return e.onblocked=function(n){return t.on("blocked",n),this},e},o.exists=function(n){return new o(n).open().then(function(n){return n.close(),!0},function(){return!1})},o.getDatabaseNames=function(n){return new J(function(n,t){var r=q();if(r){var o=r();o.onsuccess=function(t){n(e(t.target.result,0))},o.onerror=j(t)}else K(function(t){return n(t),!1})}).then(n)},o.defineClass=function(t){function e(e){e?n(this,e):Y&&E(this,t)}return e},o.applyStructure=E,o.ignoreTransaction=function(n){return J.newPSD(function(){return J.PSD.trans=null,n()})},o.vip=function(n){return J.newPSD(function(){return J.PSD.letThrough=!0,n()})},o.async=function(n){return function(){try{var t=I(n.apply(this,arguments));return t&&"function"==typeof t.then?t:o.Promise.resolve(t)}catch(e){return o.Promise.reject(e)}}},o.spawn=function(n,t,e){try{var r=I(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:o.Promise.resolve(r)}catch(i){return o.Promise.reject(i)}},Object.defineProperty(o,"currentTransaction",{get:function(){return J.PSD&&J.PSD.trans||null}}),o.Promise=J,o.derive=t,o.extend=n,o.override=r,o.events=v,o.getByKeyPath=_,o.setByKeyPath=x,o.delByKeyPath=P,o.shallowClone=S,o.deepClone=D,o.addons=[],o.fakeAutoComplete=H,o.asap=m,o.ModifyError=N,o.MultiModifyError=N,o.IndexSpec=A,o.TableSchema=B,o.MaxKey=V;var G=W.idbModules&&W.idbModules.shimIndexedDB?W.idbModules:{};return o.dependencies={indexedDB:G.shimIndexedDB||W.indexedDB||W.mozIndexedDB||W.webkitIndexedDB||W.msIndexedDB,IDBKeyRange:G.IDBKeyRange||W.IDBKeyRange||W.webkitIDBKeyRange,Error:W.Error||String,SyntaxError:W.SyntaxError||String,TypeError:W.TypeError||String,localStorage:null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:W.localStorage},o.semVer="1.3.2",o.version=o.semVer.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),b(function(){o.fakeAutoComplete=H=b,o.fake=Y=!0}),o["default"]=o,o}); | ||
//# sourceMappingURL=dist/dexie.min.js.map |
{ | ||
"name": "dexie", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "A Minimalistic Wrapper for IndexedDB", | ||
@@ -8,2 +8,13 @@ "main": "dist/dexie.js", | ||
"typings": "dist/dexie.d.ts", | ||
"typescript": { | ||
"definitions": [ | ||
"dist/dexie.d.ts" | ||
] | ||
}, | ||
"jspm": { | ||
"main": "dist/dexie.es6.js", | ||
"files": [ | ||
"dist/dexie.es6.js" | ||
] | ||
}, | ||
"repository": { | ||
@@ -10,0 +21,0 @@ "type": "git", |
160
README.md
@@ -7,3 +7,3 @@ Dexie.js | ||
#### What is Dexie.js? | ||
Dexie.js is a wrapper library for indexedDB. | ||
Dexie.js is a wrapper library for indexedDB - the standard database in the browser. | ||
@@ -19,5 +19,34 @@ #### Why is Dexie.js needed? | ||
#### Please Show me a Hello World Example | ||
#### Hello World | ||
```html | ||
<html> | ||
<head> | ||
<script src="https://npmcdn.com/dexie/dist/dexie.min.js"></script> | ||
<script> | ||
// | ||
// Declare Database | ||
// | ||
var db = new Dexie("FriendDatabase"); | ||
db.version(1).stores({ friends: "++id,name,age" }); | ||
// | ||
// Manipulate and Query Database | ||
// | ||
db.friends.add({name: "Josephine", age: 21}).then(function() { | ||
return db.friends.where("age").below(25).toArray(); | ||
}).then(function (youngFriends) { | ||
alert ("My young friends: " + JSON.stringify(youngFriends)); | ||
}).catch(function (e) { | ||
alert ("Error: " + e.stack || e); | ||
}); | ||
</script> | ||
</head> | ||
</html> | ||
``` | ||
#### Hello World (ES6) | ||
```js | ||
import Dexie from 'dexie'; | ||
// | ||
@@ -28,3 +57,2 @@ // Declare Database | ||
db.version(1).stores({ friends: "++id,name,age" }); | ||
db.open(); | ||
@@ -34,10 +62,71 @@ // | ||
// | ||
db.friends.add({name: "Josephine", age: 21}).then(function() { | ||
Dexie.spawn(function*(){ | ||
// Dexie.spawn gives you the possibility to use yield. | ||
// Use yield like async works in Typescript / ES7 | ||
// Add to database | ||
yield db.friends.add({name: "Josephine", age: 21}); | ||
// Query database | ||
let youngFriends = yield db.friends.where("age").below(25).toArray(); | ||
alert ("My young friends: " + JSON.stringify(youngFriends)); | ||
}).catch(e => { | ||
alert("error: " + e.stack || e); | ||
}); | ||
``` | ||
#### Hello World (Typescript) | ||
Here's the simples typescript sample from Dexie.js/samples/typescript-simple: | ||
```ts | ||
import Dexie from 'dexie'; | ||
interface IFriend { | ||
id?: number; | ||
name?: string; | ||
age?: number; | ||
} | ||
// | ||
// Declare Database | ||
// | ||
class FriendDatabase extends Dexie { | ||
friends: Dexie.Table<IFriend,number>; | ||
constructor() { | ||
super("FriendsDatabase"); | ||
this.version(1).stores({ | ||
friends: "++id,name,age" | ||
}); | ||
} | ||
} | ||
var db = new FriendDatabase(); | ||
// | ||
// Manipulate and Query Database | ||
// | ||
db.friends.add({name: "Josephine", age: 21}).then(()=>{ | ||
return db.friends.where("age").below(25).toArray(); | ||
}).then(function (youngFriends) { | ||
console.log("My young friends: " + JSON.stringify(youngFriends)); | ||
}).then(youngFriends => { | ||
alert ("My young friends: " + JSON.stringify(youngFriends)); | ||
}).catch(e => { | ||
alert("error: " + e.stack || e); | ||
}); | ||
``` | ||
To see this in action, clone Dexie and cd to samples/typescript-simple. Then type: | ||
``` | ||
npm install | ||
npm run build | ||
num run start | ||
``` | ||
... and launch web browser to http://localhost:8081 | ||
Documentation | ||
@@ -61,10 +150,67 @@ ------------- | ||
Install over npm | ||
---------------- | ||
``` | ||
npm install dexie | ||
``` | ||
Download | ||
-------- | ||
For those who don't like package managers, here's the download links: | ||
https://npmcdn.com/dexie/dist/dexie.min.js | ||
https://npmcdn.com/dexie/dist/dexie.min.js.map | ||
https://npmcdn.com/dexie/dist/dexie.d.ts | ||
Contributing | ||
============ | ||
Here is a little cheat-sheet for how to symlink your app's `node_modules/dexie` to a place where you can edit the source, version control your changes and create pull requests back to Dexie. Assuming you've already ran `npm install dexie --save` for the app your are developing. | ||
1. Fork Dexie.js from the web gui on github | ||
2. Clone your fork locally by launching a shell/command window and cd to a neutral place (like `~repos/`, `c:\repos` or whatever) and type: | ||
``` | ||
git clone https://github.com/YOUR-USERNAME/Dexie.js.git | ||
cd Dexie.js | ||
npm install | ||
npm run build | ||
npm link | ||
``` | ||
3. cd to your app directory and write: | ||
``` | ||
npm link dexie | ||
``` | ||
Your app's `node_modules/dexie/` is now sym-linked to the Dexie.js clone on your hard drive so any change you do there will propagate to your app. Build dexie.js using `npm run build` or `npm run watch`. The latter will react on any source file change and rebuild the dist files. | ||
That's it. Now you're up and running to test and commit changes to Dexie.js that will instantly affect the app you are developing. | ||
Pull requests are more than welcome. Some advices are: | ||
* Run npm test before making a pull request. | ||
* If you find an issue, a unit test that reproduces it is lovely ;). If you don't know where to put it, put it in `test/tests-misc.js`. We use qunit. Just look at existing tests in `tests-misc.js` to see how they should be written. Tests are transpiled in the build script so you can use ES6 if you like. | ||
Build | ||
----- | ||
``` | ||
npm run build | ||
``` | ||
Test | ||
---- | ||
``` | ||
npm test | ||
``` | ||
Watch | ||
----- | ||
``` | ||
npm run watch | ||
``` | ||
[npm-image]: https://img.shields.io/npm/v/dexie.svg?style=flat | ||
[npm-url]: https://npmjs.org/package/dexie | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1057929
7295
212
1