Socket
Socket
Sign inDemoInstall

dexie

Package Overview
Dependencies
Maintainers
2
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dexie - npm Package Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-beta.2

test/tests-asyncawait.js

2

bower.json

@@ -34,3 +34,3 @@ {

],
"version": "2.0.0-beta.1"
"version": "2.0.0-beta.2"
}

@@ -1,2 +0,2 @@

// Type definitions for Dexie v2.0.0-beta.1
// Type definitions for Dexie v2.0.0-beta.2
// Project: https://github.com/dfahlander/Dexie.js

@@ -121,6 +121,4 @@ // Definitions by: David Fahlander <http://github.com/dfahlander>

Version: new()=>Dexie.Version;
WriteableTable: new()=>Dexie.Table<any,any>;
Transaction: new()=>Dexie.Transaction;
Collection: new()=>Dexie.Collection<any,any>;
WriteableCollection: new()=>Dexie.Collection<any,any>;
}

@@ -438,3 +436,2 @@

class DatabaseClosedError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}
class IncompatiblePromiseError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}
class UnknownError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}

@@ -441,0 +438,0 @@ class ConstraintError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}

@@ -1,3 +0,3 @@

!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?n:(An(t).forEach(function(e){n[e]=t[e]}),n)}function t(n,t){return Cn.call(n,t)}function e(n,t){"function"==typeof t&&(t=t(jn(n))),An(t).forEach(function(e){r(n,e,t[e])})}function r(e,r,i,o){Object.defineProperty(e,r,n(i&&t(i,"get")&&"function"==typeof i.get?{get:i.get,set:i.set,configurable:!0}:{value:i,configurable:!0,writable:!0},o))}function i(n){return{from:function(t){return n.prototype=Object.create(t.prototype),r(n.prototype,"constructor",n),{extend:e.bind(null,n.prototype)}}}}function o(n,t){var e,r=Dn(n,t);return r||(e=jn(n))&&o(e,t)}function u(n,t,e){return Pn.call(n,t,e)}function a(n,t){return t(n)}function c(n){var t=setTimeout(n,1e3);clearTimeout(t)}function s(n){if(!n)throw new Error("Assertion Failed")}function f(n){In.setImmediate?setImmediate(n):setTimeout(n,0)}function l(n,t){return n.reduce(function(n,e,r){var i=t(e,r);return i&&(n[i[0]]=i[1]),n},{})}function h(n,t){return function(){try{n.apply(this,arguments)}catch(n){t(n)}}}function d(n,t,e){try{n.apply(null,e)}catch(n){t&&t(n)}}function p(n,e){if(t(n,e))return n[e];if(!e)return n;if("string"!=typeof e){for(var r=[],i=0,o=e.length;i<o;++i){var u=p(n,e[i]);r.push(u)}return r}var a=e.indexOf(".");if(a!==-1){var c=n[e.substr(0,a)];return void 0===c?void 0:p(c,e.substr(a+1))}}function v(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){s("string"!=typeof e&&"length"in e);for(var r=0,i=t.length;r<i;++r)v(n,t[r],e[r])}else{var o=t.indexOf(".");if(o!==-1){var u=t.substr(0,o),a=t.substr(o+1);if(""===a)void 0===e?delete n[u]:n[u]=e;else{var c=n[u];c||(c=n[u]={}),v(c,a,e)}}else void 0===e?delete n[t]:n[t]=e}}function y(n,t){"string"==typeof t?v(n,t,void 0):"length"in t&&[].map.call(t,function(t){v(n,t,void 0)})}function m(n){var e={};for(var r in n)t(n,r)&&(e[r]=n[r]);return e}function g(n){if(!n||"object"!=typeof n)return n;var e;if(On(n)){e=[];for(var r=0,i=n.length;r<i;++r)e.push(g(n[r]))}else if(n instanceof Date)e=new Date,e.setTime(n.getTime());else{e=n.constructor?Object.create(n.constructor.prototype):{};for(var o in n)t(n,o)&&(e[o]=g(n[o]))}return e}function b(n,e,r,i){return r=r||{},i=i||"",An(n).forEach(function(o){if(t(e,o)){var u=n[o],a=e[o];"object"==typeof u&&"object"==typeof a&&u&&a&&u.constructor===a.constructor?b(u,a,r,i+o+"."):u!==a&&(r[i+o]=e[o])}else r[i+o]=void 0}),An(e).forEach(function(o){t(n,o)||(r[i+o]=e[o])}),r}function _(n){var t,e,r,i;if(1===arguments.length){if(On(n))return n.slice();if(this===Kn&&"string"==typeof n)return[n];if(i=Tn(n)){for(e=[];r=i.next(),!r.done;)e.push(r.value);return e}if(null==n)return[n];if(t=n.length,"number"==typeof t){for(e=new Array(t);t--;)e[t]=n[t];return e}return[n]}for(t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return e}function w(n){return Bn.apply([],n)}function k(){}function x(n){return n}function E(n,t){return null==n||n===x?t:function(e){return t(n(e))}}function A(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function O(n,t){return n===k?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?A(r,this.onsuccess):r),i&&(this.onerror=this.onerror?A(i,this.onerror):i),void 0!==o?o:e}}function I(n,t){return n===k?t:function(){n.apply(this,arguments);var e=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?A(e,this.onsuccess):e),r&&(this.onerror=this.onerror?A(r,this.onerror):r)}}function j(t,e){return t===k?e:function(r){var i=t.apply(this,arguments);n(r,i);var o=this.onsuccess,u=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?A(o,this.onsuccess):o),u&&(this.onerror=this.onerror?A(u,this.onerror):u),void 0===i?void 0===a?void 0:a:n(i,a)}}function C(n,t){return n===k?t:function(){return t.apply(this,arguments)!==!1&&n.apply(this,arguments)}}function D(n,t){return n===k?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function P(n,t){Mn=n,Nn=t}function S(){if(Fn)try{throw S.arguments,new Error}catch(n){return n}return new Error}function T(n,t){var e=n.stack;return e?(t=t||0,0===e.indexOf(n.name)&&(t+=(n.name+n.message).split("\n").length),e.split("\n").slice(t).filter(Nn).map(function(n){return"\n"+n}).join("")):""}function K(n,t){return function(){return console.warn(n+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+T(S(),1)),t.apply(this,arguments)}}function B(n,t){this._e=S(),this.name=n,this.message=t}function M(n,t){return n+". Errors: "+t.map(function(n){return n.toString()}).filter(function(n,t,e){return e.indexOf(n)===t}).join("\n")}function N(n,t,e,r){this._e=S(),this.failures=t,this.failedKeys=r,this.successCount=e}function F(n,t){this._e=S(),this.name="BulkError",this.failures=t,this.message=M(n,t)}function q(n,t){if(!n||n instanceof B||n instanceof TypeError||n instanceof SyntaxError||!n.name||!Hn[n.name])return n;var e=new Hn[n.name](t||n.message,n);return"stack"in n&&r(e,"stack",{get:function(){return this.inner.stack}}),e}function R(n){function t(n,t,o){if("object"==typeof n)return e(n);t||(t=C),o||(o=k);var u={subscribers:[],fire:o,subscribe:function(n){u.subscribers.indexOf(n)===-1&&(u.subscribers.push(n),u.fire=t(u.fire,n))},unsubscribe:function(n){u.subscribers=u.subscribers.filter(function(t){return t!==n}),u.fire=u.subscribers.reduce(t,o)}};return r[n]=i[n]=u,u}function e(n){An(n).forEach(function(e){var r=n[e];if(On(r))t(e,n[e][0],n[e][1]);else{if("asap"!==r)throw new Wn.InvalidArgument("Invalid event config");var i=t(e,x,function(){for(var n=arguments.length,t=new Array(n);n--;)t[n]=arguments[n];i.subscribers.forEach(function(n){f(function(){n.apply(null,t)})})})}})}var r={},i=function(t,e){if(e){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return r[t].subscribe.apply(null,o),n}if("string"==typeof t)return r[t]};i.addEventType=t;for(var o=1,u=arguments.length;o<u;++o)t(arguments[o]);return i}function U(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=k,this._lib=!1;var t=this._PSD=at;if(Mn&&(this._stackHolder=S(),this._prev=null,this._numPrev=0,Q(this,it)),"function"!=typeof n){if(n!==Jn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&L(this,this._value))}this._state=null,this._value=null,++t.ref,V(this,n)}function z(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r,this.psd=at}function V(n,t){try{t(function(t){if(null===n._state){if(t===n)throw new TypeError("A promise cannot be resolved with itself.");var e=n._lib&&$();t&&"function"==typeof t.then?V(n,function(n,e){t instanceof U?t._then(n,e):t.then(n,e)}):(n._state=!0,n._value=t,W(n)),e&&X()}},L.bind(null,n))}catch(t){L(n,t)}}function L(n,t){if(rt.push(t),null===n._state){var e=n._lib&&$();t=ot(t),n._state=!1,n._value=t,Mn&&null!==t&&"object"==typeof t&&!t._promise&&d(function(){var e=o(t,"stack");t._promise=n,r(t,"stack",{get:function(){return $n?e&&(e.get?e.get.apply(t):e.value):n.stack}})}),tn(n),W(n),e&&X()}}function W(n){var t=n._listeners;n._listeners=[];for(var e=0,r=t.length;e<r;++e)H(n,t[e]);var i=n._PSD;--i.ref||i.finalize(),0===st&&(++st,Zn(function(){0===--st&&Z()},[]))}function H(n,t){if(null===n._state)return void n._listeners.push(t);var e=n._state?t.onFulfilled:t.onRejected;if(null===e)return(n._state?t.resolve:t.reject)(n._value);var r=t.psd;++r.ref,++st,Zn(G,[e,n,t])}function G(n,t,e){var r=at,i=e.psd;try{i!==r&&(at=i),it=t;var o,u=t._value;t._state?o=n(u):(rt.length&&(rt=[]),o=n(u),rt.indexOf(u)===-1&&en(t)),e.resolve(o)}catch(n){e.reject(n)}finally{i!==r&&(at=r),it=null,0===--st&&Z(),--i.ref||i.finalize()}}function J(n,t,e){if(t.length===e)return t;var r="";if(n._state===!1){var i,o,u=n._value;null!=u?(i=u.name||"Error",o=u.message||u,r=T(u,0)):(i=u,o=""),t.push(i+(o?": "+o:"")+r)}return Mn&&(r=T(n._stackHolder,2),r&&t.indexOf(r)===-1&&t.push(r),n._prev&&J(n._prev,t,e)),t}function Q(n,t){var e=t?t._numPrev+1:0;e<Qn&&(n._prev=t,n._numPrev=e)}function Y(){$()&&X()}function $(){var n=nt;return nt=!1,tt=!1,n}function X(){var n,t,e;do for(;ct.length>0;)for(n=ct,ct=[],e=n.length,t=0;t<e;++t){var r=n[t];r[0].apply(null,r[1])}while(ct.length>0);nt=!0,tt=!0}function Z(){var n=et;et=[],n.forEach(function(n){n._PSD.onunhandled.call(null,n._value,n)});for(var t=ft.slice(0),e=t.length;e;)t[--e]()}function nn(n){function t(){n(),ft.splice(ft.indexOf(t),1)}ft.push(t),++st,Zn(function(){0===--st&&Z()},[])}function tn(n){et.some(function(t){return t._value===n._value})||et.push(n)}function en(n){for(var t=et.length;t;)if(et[--t]._value===n._value)return void et.splice(t,1)}function rn(n){console.warn("Unhandled rejection: "+(n.stack||n))}function on(n){return new U(Jn,!1,n)}function un(n,t){var e=at;return function(){var r=$(),i=at;try{return i!==e&&(at=e),n.apply(this,arguments)}catch(n){t&&t(n)}finally{i!==e&&(at=i),r&&X()}}}function an(n,t,e,r){var i=at,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=cn(o,n,t,e,r);return 0===o.ref&&o.finalize(),u}function cn(n,t,e,r,i){var o=at;try{return n!==o&&(at=n),t(e,r,i)}finally{n!==o&&(at=o)}}function sn(n,t){var e;try{e=t.onuncatched(n)}catch(n){}if(e!==!1)try{U.on.error.fire(n,t)}catch(n){}}function fn(n,t){var e=U.reject(n);return t?e.uncaught(t):e}function ln(o,f){function y(){rt.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+rt.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+rt.name+"'. Closing db now to resume the delete request."),rt.close()}),rt.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+rt.name+"') was blocked"):console.warn("Upgrade '"+rt.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function A(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function C(n,t,e){var r=rt._createTransaction(et,Qn,Gn);r.create(t),r._completion.catch(e);var i=r._reject.bind(r);an(function(){at.trans=r,0===n?(An(Gn).forEach(function(n){B(t,n,Gn[n].primKey,Gn[n].indexes)}),U.follow(function(){return rt.on.populate.fire(r)}).catch(i)):P(n,r,t).catch(i)})}function P(n,t,e){function r(){return i.length?U.resolve(i.shift()(t.idbtrans)).then(r):U.resolve()}var i=[],o=Jn.filter(function(t){return t._cfg.version===n})[0];if(!o)throw new Wn.Upgrade("Dexie specification of currently installed DB version is missing");Gn=rt._dbSchema=o._cfg.dbschema;var u=!1,a=Jn.filter(function(t){return t._cfg.version>n});return a.forEach(function(n){i.push(function(){var r=Gn,i=n._cfg.dbschema;Tn(r,e),Tn(i,e),Gn=rt._dbSchema=i;var o=T(r,i);if(o.add.forEach(function(n){B(e,n[0],n[1].primKey,n[1].indexes)}),o.change.forEach(function(n){if(n.recreate)throw new Wn.Upgrade("Not yet support for changing primary key");var t=e.objectStore(n.name);n.add.forEach(function(n){z(t,n)}),n.change.forEach(function(n){t.deleteIndex(n.name),z(t,n)}),n.del.forEach(function(n){t.deleteIndex(n)})}),n._cfg.contentUpgrade)return u=!0,U.follow(function(){n._cfg.contentUpgrade(t)})}),i.push(function(t){if(!u||!gt){var e=n._cfg.dbschema;q(e,t)}})}),r().then(function(){M(Gn,e)})}function T(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var i=n[r],o=t[r];if(i){var u={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)u.recreate=!0,e.change.push(u);else{var a=i.idxByName,c=o.idxByName;for(var s in a)c[s]||u.del.push(s);for(s in c){var f=a[s],l=c[s];f?f.src!==l.src&&u.change.push(l):u.add.push(l)}(u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,o])}return e}function B(n,t,e,r){var i=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){z(i,n)}),i}function M(n,t){An(n).forEach(function(e){t.db.objectStoreNames.contains(e)||B(t,e,n[e].primKey,n[e].indexes)})}function q(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null==n[r]&&t.db.deleteObjectStore(r)}}function z(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function V(n){return rt.on.error.fire(n)}function L(n,t,e){if(nt||at.letThrough){var r=rt._createTransaction(n,t,Gn);return r._promise(n,function(n,t){an(function(){at.trans=r,e(n,t,r)})}).then(function(n){return r._completion.then(function(){return n})})}if(!Zn){if(!Vn)return fn(new Wn.DatabaseClosed,V);rt.open().catch(k)}return it.then(function(){return L(n,t,e)})}function W(n,t,e){this.name=n,this.schema=t,this.hook=Yn[n]?Yn[n].hook:R(null,{creating:[O,k],reading:[E,x],updating:[j,k],deleting:[I,k]}),this._collClass=e||$}function H(n,t,e){W.call(this,n,t,e||Z)}function G(n,t,e){return(e?mn:yn)(function(e){n.push(e),t&&t()})}function J(n,t,e,r,i){return new U(function(o,u){var a=e.length,c=a-1;if(0===a)return o();if(r){var s,f=mn(u),l=vn(null);d(function(){for(var r=0;r<a;++r){s={onsuccess:null,onerror:null};var u=e[r];i.call(s,u[0],u[1],t);var h=n.delete(u[0]);h._hookCtx=s,h.onerror=f,r===c?h.onsuccess=vn(o):h.onsuccess=l}},function(n){throw s.onerror&&s.onerror(n),n})}else for(var h=0;h<a;++h){var p=n.delete(e[h]);p.onerror=un(yn(u)),h===c&&(p.onsuccess=un(function(){return o()}))}}).uncaught(V)}function Q(n,t,e,r){var i=this;this.db=rt,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=R(this,"complete","error","abort"),this.parent=r||null,this.active=!0,this._tables=null,this._reculock=0,this._blockedFuncs=[],this._psd=null,this._dbschema=e,this._resolve=null,this._reject=null,this._completion=new U(function(n,t){i._resolve=n,i._reject=t}).uncaught(V),this._completion.then(function(){i.on.complete.fire()},function(n){return i.on.error.fire(n),i.parent?i.parent._reject(n):i.active&&i.idbtrans&&i.idbtrans.abort(),i.active=!1,fn(n)})}function Y(n,t,e){this._ctx={table:n,index:":id"===t?null:t,collClass:n._collClass,or:e}}function $(n,t){var e=null,r=null;if(t)try{e=t()}catch(n){r=n}var i=n._ctx,o=i.table;this._ctx={table:o,index:i.index,isPrimKey:!i.index||o.schema.primKey.keyPath&&i.index===o.schema.primKey.name,range:e,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:o.hook.reading.fire}}function X(n,t){return!(n.filter||n.algorithm||n.or)&&(t?n.justLimit:!n.replayFilter)}function Z(){$.apply(this,arguments)}function nn(n,t){return n._cfg.version-t._cfg.version}function tn(n,t,e,r){t.forEach(function(t){var i=rt._tableFactory(e,r[t]);n.forEach(function(n){t in n||(n[t]=i)})})}function en(n){n.forEach(function(n){for(var t in n)n[t]instanceof W&&delete n[t]})}function rn(n,t,e,r,i,o){var u=o?function(n,t,r){return e(o(n),t,r)}:e,a=un(u,i);n.onerror||(n.onerror=yn(i)),t?n.onsuccess=h(function(){var e=n.result;if(e){var o=function(){e.continue()};t(e,function(n){o=n},r,i)&&a(e.value,e,function(n){o=n}),o()}else r()},i):n.onsuccess=h(function(){var t=n.result;if(t){var e=function(){t.continue()};a(t.value,t,function(n){e=n}),e()}else r()},i)}function on(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace(/([&*]|\+\+)/g,""),r=/^\[/.test(e)?e.match(/^\[(.*)\]$/)[1].split("+"):e;t.push(new wn(e,r||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),On(r),/\./.test(n)))}),t}function cn(n,t){return Ln.cmp(n,t)}function sn(n,t){return cn(n,t)<0?n:t}function hn(n,t){return cn(n,t)>0?n:t}function In(n,t){return Ln.cmp(n,t)}function jn(n,t){return Ln.cmp(t,n)}function Cn(n,t){return n<t?-1:n===t?0:1}function Dn(n,t){return n>t?-1:n===t?0:1}function Pn(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function Sn(){if(rt.verno=$n.version/10,rt._dbSchema=Gn={},Qn=u($n.objectStoreNames,0),0!==Qn.length){var n=$n.transaction(xn(Qn),"readonly");Qn.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1,o=new wn(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),u=[],a=0;a<e.indexNames.length;++a){var c=e.index(e.indexNames[a]);r=c.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1;var s=new wn(c.name,r,!!c.unique,!!c.multiEntry,!1,r&&"string"!=typeof r,i);u.push(s)}Gn[t]=new kn(t,o,u,{})}),tn([Yn,Q.prototype],An(Gn),et,Gn)}}function Tn(n,t){for(var e=t.db.objectStoreNames,r=0;r<e.length;++r){var i=e[r],o=t.objectStore(i);qn="getAll"in o;for(var a=0;a<o.indexNames.length;++a){var c=o.indexNames[a],s=o.index(c).keyPath,f="string"==typeof s?s:"["+u(s).join("+")+"]";if(n[i]){var l=n[i].idxByName[f];l&&(l.name=c)}}}}function Bn(n){rt.on("blocked").fire(n),yt.filter(function(n){return n.name===rt.name&&n!==rt&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var Nn,Fn,qn,Rn=ln.dependencies,Un=n({addons:ln.addons,autoOpen:!0,indexedDB:Rn.indexedDB,IDBKeyRange:Rn.IDBKeyRange},f),zn=Un.addons,Vn=Un.autoOpen,Ln=Un.indexedDB,Hn=Un.IDBKeyRange,Gn=this._dbSchema={},Jn=[],Qn=[],Yn={},$n=null,Xn=null,Zn=!1,nt=!1,tt="readonly",et="readwrite",rt=this,it=new U(function(n){Nn=n}),ot=new U(function(n,t){Fn=t}),ut=!0,ct=!!En(Ln);this.version=function(n){if($n||Zn)throw new Wn.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=Jn.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new A(n),Jn.push(t),Jn.sort(nn),t)},n(A.prototype,{stores:function(t){this._cfg.storesSource=this._cfg.storesSource?n(this._cfg.storesSource,t):t;var e={};Jn.forEach(function(t){n(e,t._cfg.storesSource)});var r=this._cfg.dbschema={};return this._parseStoresSpec(e,r),Gn=rt._dbSchema=r,en([Yn,rt,Q.prototype]),tn([Yn,rt,Q.prototype,this._cfg.tables],An(r),et,r),Qn=An(r),this},upgrade:function(n){var t=this;return wt(function(){n(rt._createTransaction(et,An(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){An(n).forEach(function(e){if(null!==n[e]){var r={},i=on(n[e]),o=i.shift();if(o.multi)throw new Wn.Schema("Primary key cannot be multi-valued");o.keyPath&&v(r,o.keyPath,o.auto?0:o.keyPath),i.forEach(function(n){if(n.auto)throw new Wn.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new Wn.Schema("Index must have a name and cannot be an empty string");v(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new kn(e,o,i,r)}})}}),this._allTables=Yn,this._tableFactory=function(n,t){return n===tt?new W(t.name,t,$):new H(t.name,t)},this._createTransaction=function(n,t,e,r){return new Q(n,t,e,r)},this._whenReady=function(n){return new U(kt||nt||at.letThrough?n:function(t,e){if(!Zn){if(!Vn)return void e(new Wn.DatabaseClosed);rt.open().catch(k)}it.then(function(){n(t,e)})}).uncaught(V)},this.verno=0,this.open=function(){if(Zn||$n)return it.then(function(){return Xn?fn(Xn,V):rt});Mn&&(ot._stackHolder=S()),Zn=!0,Xn=null,nt=!1;var n=Nn,t=null;return U.race([ot,new U(function(n,e){if(c(function(){return n()}),Jn.length>0&&(ut=!1),!Ln)throw new Wn.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var r=ut?Ln.open(o):Ln.open(o,Math.round(10*rt.verno));if(!r)throw new Wn.MissingAPI("IndexedDB API not available");r.onerror=un(yn(e)),r.onblocked=un(Bn),r.onupgradeneeded=un(function(n){if(t=r.transaction,ut&&!rt._allowEmptyDB){r.onerror=gn,t.abort(),r.result.close();var i=Ln.deleteDatabase(o);i.onsuccess=i.onerror=un(function(){e(new Wn.NoSuchDatabase("Database "+o+" doesnt exist"))})}else{t.onerror=un(yn(e));var u=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;C(u/10,t,e,r)}},e),r.onsuccess=un(function(){if(t=null,$n=r.result,yt.push(rt),ut)Sn();else if($n.objectStoreNames.length>0)try{Tn(Gn,$n.transaction(xn($n.objectStoreNames),tt))}catch(n){}$n.onversionchange=un(function(n){rt._vcFired=!0,rt.on("versionchange").fire(n)}),ct||bn(function(n){if(n.indexOf(o)===-1)return n.push(o)}),n()},e)})]).then(function(){return ln.vip(rt.on.ready.fire)}).then(function(){return Zn=!1,rt}).catch(function(n){try{t&&t.abort()}catch(n){}return Zn=!1,rt.close(),Xn=n,fn(Xn,V)}).finally(function(){nt=!0,n()})},this.close=function(){var n=yt.indexOf(rt);if(n>=0&&yt.splice(n,1),$n){try{$n.close()}catch(n){}$n=null}Vn=!1,Xn=new Wn.DatabaseClosed,Zn&&Fn(Xn),it=new U(function(n){Nn=n}),ot=new U(function(n,t){Fn=t})},this.delete=function(){var n=arguments.length>0;return new U(function(t,e){function r(){rt.close();var n=Ln.deleteDatabase(o);n.onsuccess=un(function(){ct||bn(function(n){var t=n.indexOf(o);if(t>=0)return n.splice(t,1)}),t()}),n.onerror=un(yn(e)),n.onblocked=Bn}if(n)throw new Wn.InvalidArgument("Arguments not allowed in db.delete()");Zn?it.then(r):r()}).uncaught(V)},this.backendDB=function(){return $n},this.isOpen=function(){return null!==$n},this.hasFailed=function(){return null!==Xn},this.dynamicallyOpened=function(){return ut},this.name=o,r(this,"tables",{get:function(){return An(Yn).map(function(n){return Yn[n]})}}),this.on=R(this,"error","populate","blocked","versionchange",{ready:[D,k]}),this.on.ready.subscribe=a(this.on.ready.subscribe,function(n){return function(t,e){ln.vip(function(){nt?(U.resolve().then(t),e&&n(t)):(n(t),e||n(function n(){rt.on.ready.unsubscribe(t),rt.on.ready.unsubscribe(n)}))})}}),wt(function(){rt.on("populate").fire(rt._createTransaction(et,Qn,Gn)),rt.on("error").fire(new Error)}),this.transaction=function(n,e,r){function i(e){var i=at;e(U.resolve().then(function(){return an(function(){at.transless=at.transless||i;var e=rt._createTransaction(n,f,Gn,c);at.trans=e,c?e.idbtrans=c.idbtrans:e.create();var o=f.map(function(n){return Yn[n]});o.push(e);var u;return U.follow(function(){if(u=r.apply(e,o))if("function"==typeof u.next&&"function"==typeof u.throw)u=_n(u);else if("function"==typeof u.then&&!t(u,"_PSD"))throw new Wn.IncompatiblePromise("Incompatible Promise returned from transaction scope (read more at http://tinyurl.com/znyqjqc). Transaction scope: "+r.toString())}).uncaught(V).then(function(){return c&&e._resolve(),e._completion}).then(function(){return u}).catch(function(n){return e._reject(n),fn(n)})})}))}var o=arguments.length;if(o<2)throw new Wn.InvalidArgument("Too few arguments");for(var u=new Array(o-1);--o;)u[o-1]=arguments[o];r=u.pop();var a=w(u),c=at.trans;c&&c.db===rt&&n.indexOf("!")===-1||(c=null);var s=n.indexOf("?")!==-1;n=n.replace("!","").replace("?","");try{var f=a.map(function(n){var t=n instanceof W?n.name:n;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t});if("r"==n||n==tt)n=tt;else{if("rw"!=n&&n!=et)throw new Wn.InvalidArgument("Invalid transaction mode: "+n);n=et}if(c){if(c.mode===tt&&n===et){if(!s)throw new Wn.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");c=null}c&&f.forEach(function(n){if(c&&c.storeNames.indexOf(n)===-1){if(!s)throw new Wn.SubTransaction("Table "+n+" not included in parent transaction.");c=null}})}}catch(n){return c?c._promise(null,function(t,e){e(n)}):fn(n,V)}return c?c._promise(n,i,"lock"):rt._whenReady(i)},this.table=function(n){if(kt&&ut)return new H(n);if(!t(Yn,n))throw new Wn.InvalidTable("Table "+n+" does not exist");return Yn[n]},e(W.prototype,{_trans:function(n,t,e){var r=at.trans;return r&&r.db===rt?r._promise(n,t,e):L(n,[this.name],t)},_idbstore:function(n,t,e){function r(n,e,r){t(n,e,r.idbtrans.objectStore(o),r)}if(kt)return new U(t);var i=at.trans,o=this.name;return i&&i.db===rt?i._promise(n,r,e):L(n,[this.name],r)},get:function(n,t){var e=this;return this._idbstore(tt,function(t,r,i){kt&&t(e.schema.instanceTemplate);var o=i.get(n);o.onerror=yn(r),o.onsuccess=function(){t(e.hook.reading.fire(o.result))}}).then(t)},where:function(n){return new Y(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){return this.toCollection().each(n)},toArray:function(n){return this.toCollection().toArray(n)},orderBy:function(n){return new this._collClass(new Y(this,n))},toCollection:function(){return new this._collClass(new Y(this))},mapToClass:function(n,e){this.schema.mappedClass=n;var r=Object.create(n.prototype);e&&dn(r,e),this.schema.instanceTemplate=r;var i=function(e){if(!e)return e;var r=Object.create(n.prototype);for(var i in e)t(e,i)&&(r[i]=e[i]);return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),n},defineClass:function(n){return this.mapToClass(ln.defineClass(n),n)}}),i(H).from(W).extend({bulkDelete:function(n){return this.hook.deleting.fire===k?this._idbstore(et,function(t,e,r,i){t(J(r,i,n,!1,k))}):this.where(":id").anyOf(n).delete().then(function(){})},bulkPut:function(n,t){var e=this;return this._idbstore(et,function(r,i,o){if(!o.keyPath&&!e.schema.primKey.auto&&!t)throw new Wn.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(o.keyPath&&t)throw new Wn.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new Wn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return r();var u,a,c=function(n){0===s.length?r(n):i(new F(e.name+".bulkPut(): "+s.length+" of "+f+" operations failed",s))},s=[],f=n.length,h=e;if(e.hook.creating.fire===k&&e.hook.updating.fire===k){a=G(s);for(var d=0,v=n.length;d<v;++d)u=t?o.put(n[d],t[d]):o.put(n[d]),u.onerror=a;u.onerror=G(s,c),u.onsuccess=pn(c)}else{var y=t||o.keyPath&&n.map(function(n){return p(n,o.keyPath)}),m=y&&l(y,function(t,e){return null!=t&&[t,n[e]]}),g=y?h.where(":id").anyOf(y.filter(function(n){return null!=n})).modify(function(){this.value=m[this.primKey],m[this.primKey]=null}).catch(N,function(n){s=n.failures}).then(function(){for(var e=[],r=t&&[],i=y.length-1;i>=0;--i){var o=y[i];(null==o||m[o])&&(e.push(n[i]),t&&r.push(o),null!=o&&(m[o]=null))}return e.reverse(),t&&r.reverse(),h.bulkAdd(e,r)}).then(function(n){var t=y[y.length-1];return null!=t?t:n}):h.bulkAdd(n);g.then(c).catch(F,function(n){s=s.concat(n.failures),c()}).catch(i)}},"locked")},bulkAdd:function(n,t){var e=this,r=this.hook.creating.fire;return this._idbstore(et,function(i,o,u,a){function c(n){0===h.length?i(n):o(new F(e.name+".bulkAdd(): "+h.length+" of "+y+" operations failed",h))}if(!u.keyPath&&!e.schema.primKey.auto&&!t)throw new Wn.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(u.keyPath&&t)throw new Wn.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new Wn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return i();var s,f,l,h=[],y=n.length;if(r!==k){var m,b=u.keyPath;f=G(h,null,!0),l=vn(null),d(function(){for(var e=0,i=n.length;e<i;++e){m={onerror:null,onsuccess:null};var o=t&&t[e],c=n[e],h=t?o:b?p(c,b):void 0,d=r.call(m,h,c,a);null==h&&null!=d&&(b?(c=g(c),v(c,b,d)):o=d),s=null!=o?u.add(c,o):u.add(c),s._hookCtx=m,e<i-1&&(s.onerror=f,m.onsuccess&&(s.onsuccess=l))}},function(n){throw m.onerror&&m.onerror(n),n}),s.onerror=G(h,c,!0),s.onsuccess=vn(c)}else{f=G(h);for(var _=0,w=n.length;_<w;++_)s=t?u.add(n[_],t[_]):u.add(n[_]),s.onerror=f;s.onerror=G(h,c),s.onsuccess=pn(c)}})},add:function(n,t){var e=this.hook.creating.fire;return this._idbstore(et,function(r,i,o,u){var a={onsuccess:null,onerror:null};if(e!==k){var c=null!=t?t:o.keyPath?p(n,o.keyPath):void 0,s=e.call(a,c,n,u);null==c&&null!=s&&(o.keyPath?v(n,o.keyPath,s):t=s)}try{var f=null!=t?o.add(n,t):o.add(n);f._hookCtx=a,f.onerror=mn(i),f.onsuccess=vn(function(t){var e=o.keyPath;e&&v(n,e,t),r(t)})}catch(n){throw a.onerror&&a.onerror(n),n}})},put:function(n,t){var e=this,r=this.hook.creating.fire,i=this.hook.updating.fire;return r!==k||i!==k?this._trans(et,function(r,i,o){var u=void 0!==t?t:e.schema.primKey.keyPath&&p(n,e.schema.primKey.keyPath);null==u?e.add(n).then(r,i):(o._lock(),n=g(n),e.where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?e.add(n,t):u}).finally(function(){o._unlock()}).then(r,i))}):this._idbstore(et,function(e,r,i){var o=void 0!==t?i.put(n,t):i.put(n);o.onerror=yn(r),o.onsuccess=function(t){var r=i.keyPath;r&&v(n,r,t.target.result),e(o.result)}})},delete:function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n).delete():this._idbstore(et,function(t,e,r){var i=r.delete(n);i.onerror=yn(e),i.onsuccess=function(){t(i.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection().delete():this._idbstore(et,function(n,t,e){var r=e.clear();r.onerror=yn(t),r.onsuccess=function(){n(r.result)}})},update:function(n,t){if("object"!=typeof t||On(t))throw new Wn.InvalidArgument("Modifications must be an object.");if("object"!=typeof n||On(n))return this.where(":id").equals(n).modify(t);An(t).forEach(function(e){v(n,e,t[e])});var e=p(n,this.schema.primKey.keyPath);return void 0===e?fn(new Wn.InvalidArgument("Given object does not contain its primary key"),V):this.where(":id").equals(e).modify(t)}}),e(Q.prototype,{_lock:function(){return s(!at.global),++this._reculock,1!==this._reculock||at.global||(at.lockOwnerFor=this),this},_unlock:function(){if(s(!at.global),0===--this._reculock)for(at.global||(at.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(n){}}return this},_locked:function(){return this._reculock&&at.lockOwnerFor!==this},create:function(n){var t=this;if(s(!this.idbtrans),!n&&!$n)switch(Xn&&Xn.name){case"DatabaseClosedError":throw new Wn.DatabaseClosed(Xn);case"MissingAPIError":throw new Wn.MissingAPI(Xn.message,Xn);default:throw new Wn.OpenFailed(Xn)}if(!this.active)throw new Wn.TransactionInactive;return s(null===this._completion._state),n=this.idbtrans=n||$n.transaction(xn(this.storeNames),this.mode),n.onerror=un(function(e){gn(e),t._reject(n.error)}),n.onabort=un(function(n){gn(n),t.active&&t._reject(new Wn.Abort),t.active=!1,t.on("abort").fire(n)}),n.oncomplete=un(function(){t.active=!1,t._resolve()}),this},_promise:function(n,t,e){var r=this;return an(function(){var i;return r._locked()?i=new U(function(i,o){r._blockedFuncs.push(function(){r._promise(n,t,e).then(i,o)})}):(i=r.active?new U(function(i,o){if(n===et&&r.mode!==et)throw new Wn.ReadOnly("Transaction is readonly");!r.idbtrans&&n&&r.create(),e&&r._lock(),t(i,o,r)}):fn(new Wn.TransactionInactive),r.active&&e&&i.finally(function(){r._unlock()})),i._lib=!0,i.uncaught(V)})},abort:function(){this.active&&this._reject(new Wn.Abort),this.active=!1},tables:{get:K("Transaction.tables",function(){return l(this.storeNames,function(n){return[n,Yn[n]]})},"Use db.tables()")},complete:K("Transaction.complete()",function(n){return this.on("complete",n)}),error:K("Transaction.error()",function(n){return this.on("error",n)}),table:K("Transaction.table()",function(n){if(this.storeNames.indexOf(n)===-1)throw new Wn.InvalidTable("Table "+n+" not in transaction");
return Yn[n]})}),e(Y.prototype,function(){function n(n,t,e){var r=n instanceof Y?new n._ctx.collClass(n):n;return r._ctx.error=e?new e(t):new TypeError(t),r}function t(n){return new n._ctx.collClass(n,function(){return Hn.only("")}).limit(0)}function e(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function r(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function i(n,t,e,r,i,o){for(var u=Math.min(n.length,r.length),a=-1,c=0;c<u;++c){var s=t[c];if(s!==r[c])return i(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):i(n[c],r[c])<0?n.substr(0,c)+r[c]+e.substr(c+1):a>=0?n.substr(0,a)+t[a]+e.substr(a+1):null;i(n[c],s)<0&&(a=c)}return u<r.length&&"next"===o?n+e.substr(n.length):u<n.length&&"prev"===o?n.substr(0,e.length):a<0?null:n.substr(0,a)+r[a]+e.substr(a+1)}function o(t,o,u,a){function c(n){s=e(n),f=r(n),l="next"===n?Cn:Dn;var t=u.map(function(n){return{lower:f(n),upper:s(n)}}).sort(function(n,t){return l(n.lower,t.lower)});h=t.map(function(n){return n.upper}),d=t.map(function(n){return n.lower}),p=n,v="next"===n?"":a}var s,f,l,h,d,p,v,y=u.length;if(!u.every(function(n){return"string"==typeof n}))return n(t,vt);c("next");var m=new t._ctx.collClass(t,function(){return Hn.bound(h[0],d[y-1]+a)});m._ondirectionchange=function(n){c(n)};var g=0;return m._addAlgorithm(function(n,t,e){var r=n.key;if("string"!=typeof r)return!1;var u=f(r);if(o(u,d,g))return!0;for(var a=null,c=g;c<y;++c){var s=i(r,u,h[c],d[c],l,p);null===s&&null===a?g=c+1:(null===a||l(a,s)>0)&&(a=s)}return t(null!==a?function(){n.continue(a+v)}:e),!1}),m}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return cn(e,r)>0||0===cn(e,r)&&(i||o)&&(!i||!o)?t(this):new this._ctx.collClass(this,function(){return Hn.bound(e,r,!i,!o)})}catch(t){return n(this,pt)}},equals:function(n){return new this._ctx.collClass(this,function(){return Hn.only(n)})},above:function(n){return new this._ctx.collClass(this,function(){return Hn.lowerBound(n,!0)})},aboveOrEqual:function(n){return new this._ctx.collClass(this,function(){return Hn.lowerBound(n)})},below:function(n){return new this._ctx.collClass(this,function(){return Hn.upperBound(n,!0)})},belowOrEqual:function(n){return new this._ctx.collClass(this,function(){return Hn.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,vt):this.between(t,t+ht,!0,!0)},startsWithIgnoreCase:function(n){return""===n?this.startsWith(n):o(this,function(n,t){return 0===n.indexOf(t[0])},[n],ht)},equalsIgnoreCase:function(n){return o(this,function(n,t){return n===t[0]},[n],"")},anyOfIgnoreCase:function(){var n=_.apply(Kn,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.indexOf(n)!==-1},n,"")},startsWithAnyOfIgnoreCase:function(){var n=_.apply(Kn,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},n,ht)},anyOf:function(){var e=_.apply(Kn,arguments),r=In;try{e.sort(r)}catch(t){return n(this,pt)}if(0===e.length)return t(this);var i=new this._ctx.collClass(this,function(){return Hn.bound(e[0],e[e.length-1])});i._ondirectionchange=function(n){r="next"===n?In:jn,e.sort(r)};var o=0;return i._addAlgorithm(function(n,t,i){for(var u=n.key;r(u,e[o])>0;)if(++o,o===e.length)return t(i),!1;return 0===r(u,e[o])||(t(function(){n.continue(e[o])}),!1)}),i},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,dt]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=_.apply(Kn,arguments);if(0===t.length)return new this._ctx.collClass(this);try{t.sort(In)}catch(t){return n(this,pt)}var e=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return e.push([t[t.length-1],dt]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(n,t){for(var e=0,r=n.length;e<r;++e){var i=n[e];if(cn(t[0],i[1])<0&&cn(t[1],i[0])>0){i[0]=sn(i[0],t[0]),i[1]=hn(i[1],t[1]);break}}return e===r&&n.push(t),n}function o(n,t){return l(n[0],t[0])}function u(n){return!d(n)&&!p(n)}var a=this._ctx;if(0===e.length)return t(this);if(!e.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&In(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",Wn.InvalidArgument);var c,s=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,l=In;try{c=e.reduce(i,[]),c.sort(o)}catch(t){return n(this,pt)}var h=0,d=f?function(n){return In(n,c[h][1])>0}:function(n){return In(n,c[h][1])>=0},p=s?function(n){return jn(n,c[h][0])>0}:function(n){return jn(n,c[h][0])>=0},v=d,y=new a.collClass(this,function(){return Hn.bound(c[0][0],c[c.length-1][1],!s,!f)});return y._ondirectionchange=function(n){"next"===n?(v=d,l=In):(v=p,l=jn),c.sort(o)},y._addAlgorithm(function(n,t,e){for(var r=n.key;v(r);)if(++h,h===c.length)return t(e),!1;return!!u(r)||0!==cn(r,c[h][1])&&0!==cn(r,c[h][0])&&(t(function(){l===In?n.continue(c[h][0]):n.continue(c[h][1])}),!1)}),y},startsWithAnyOf:function(){var e=_.apply(Kn,arguments);return e.every(function(n){return"string"==typeof n})?0===e.length?t(this):this.inAnyRange(e.map(function(n){return[n,n+ht]})):n(this,"startsWithAnyOf() only works with strings")}}}),e($.prototype,function(){function e(n,t){n.filter=Pn(n.filter,t)}function r(n,t,e){var r=n.replayFilter;n.replayFilter=r?function(){return Pn(r(),t())}:t,n.justLimit=e&&!r}function i(n,t){n.isMatch=Pn(n.isMatch,t)}function o(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new Wn.Schema("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return t.index(e.name)}function u(n,t){var e=o(n,t);return n.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(n.range||null,n.dir+n.unique):e.openCursor(n.range||null,n.dir+n.unique)}function a(n,e,r,i,o){var a=n.replayFilter?Pn(n.filter,n.replayFilter()):n.filter;n.or?function(){function c(){2===++l&&r()}function s(n,r,o){if(!a||a(r,o,c,i)){var u=r.primaryKey.toString();t(f,u)||(f[u]=!0,e(n,r,o))}}var f={},l=0;n.or._iterate(s,c,i,o),rn(u(n,o),n.algorithm,s,c,i,!n.keysOnly&&n.valueMapper)}():rn(u(n,o),Pn(n.algorithm,a),e,r,i,!n.keysOnly&&n.valueMapper)}function c(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(tt,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(et,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=Pn(t.algorithm,n)},_iterate:function(n,t,e,r){return a(this._ctx,n,t,e,r)},clone:function(t){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&n(r,t),e._ctx=r,e},raw:function(){return this._ctx.valueMapper=null,this},each:function(n){var t=this._ctx;if(kt){var e=c(t),r=t.table.schema.primKey.keyPath,i=p(e,t.index?t.table.schema.idxByName[t.index].keyPath:r),o=p(e,r);n(e,{key:i,primaryKey:o})}return this._read(function(e,r,i){a(t,n,e,r,i)})},count:function(n){if(kt)return U.resolve(0).then(n);var t=this._ctx;if(X(t,!0))return this._read(function(n,e,r){var i=o(t,r),u=t.range?i.count(t.range):i.count();u.onerror=yn(e),u.onsuccess=function(e){n(Math.min(e.target.result,t.limit))}},n);var e=0;return this._read(function(n,r,i){a(t,function(){return++e,!1},function(){n(e)},r,i)},n)},sortBy:function(n,t){function e(n,t){return t?e(n[i[t]],t-1):n[o]}function r(n,t){var r=e(n,u),i=e(t,u);return r<i?-a:r>i?a:0}var i=n.split(".").reverse(),o=i[0],u=i.length-1,a="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){if(kt&&n([c(t)]),qn&&"next"===t.dir&&X(t,!0)&&t.limit>0){var i=t.table.hook.reading.fire,u=o(t,r),s=t.limit<1/0?u.getAll(t.range,t.limit):u.getAll(t.range);s.onerror=yn(e),s.onsuccess=i===x?pn(n):un(pn(function(t){n(t.map(i))}))}else{var f=[];a(t,function(n){f.push(n)},function(){n(f)},e,r)}},n)},offset:function(n){var t=this._ctx;return n<=0?this:(t.offset+=n,X(t)?r(t,function(){var t=n;return function(n,e){return 0===t||(1===t?(--t,!1):(e(function(){n.advance(t),t=0}),!1))}}):r(t,function(){var t=n;return function(){return--t<0}}),this)},limit:function(n){return this._ctx.limit=Math.min(this._ctx.limit,n),r(this._ctx,function(){var t=n;return function(n,e,r){return--t<=0&&e(r),t>=0}},!0),this},until:function(n,t){var r=this._ctx;return kt&&n(c(r)),e(this._ctx,function(e,r,i){return!n(e.value)||(r(i),t)}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},filter:function(n){return kt&&n(c(this._ctx)),e(this._ctx,function(t){return n(t.value)}),i(this._ctx,n),this},and:function(n){return this.filter(n)},or:function(n){return new Y(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 t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.key,e)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},eachPrimaryKey:function(n){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.primaryKey,e)})},keys:function(n){var t=this._ctx;t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.key)}).then(function(){return e}).then(n)},primaryKeys:function(n){var t=this._ctx;if(qn&&"next"===t.dir&&X(t,!0)&&t.limit>0)return this._read(function(n,e,r){var i=o(t,r),u=t.limit<1/0?i.getAllKeys(t.range,t.limit):i.getAllKeys(t.range);u.onerror=yn(e),u.onsuccess=pn(n)}).then(n);t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.primaryKey)}).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 n=this._ctx,r=n.index&&n.table.schema.idxByName[n.index];if(!r||!r.multi)return this;var i={};return e(this._ctx,function(n){var e=n.primaryKey.toString(),r=t(i,e);return i[e]=!0,!r}),this}}}),i(Z).from($).extend({modify:function(e){var r=this,i=this._ctx,o=i.table.hook,u=o.updating.fire,a=o.deleting.fire;return kt&&"function"==typeof e&&e.call({value:i.table.schema.instanceTemplate},i.table.schema.instanceTemplate),this._write(function(i,o,c,s){function f(n,e){function r(n){return I.push(n),j.push(i.primKey),h(),!0}C=e.primaryKey;var i={primKey:e.primaryKey,value:n,onsuccess:null,onerror:null};if(y.call(i,n,i)!==!1){var o=!t(i,"value");++E,d(function(){var n=o?e.delete():e.update(i.value);n._hookCtx=i,n.onerror=mn(r),n.onsuccess=vn(function(){++A,h()})},r)}else i.onsuccess&&i.onsuccess(i.value)}function l(n){return n&&(I.push(n),j.push(C)),o(new N("Error modifying one or more objects",I,A,j))}function h(){O&&A+I.length===E&&(I.length>0?l():i(A))}var y;if("function"==typeof e)y=u===k&&a===k?e:function(n){var r=g(n);if(e.call(this,n,this)===!1)return!1;if(t(this,"value")){var i=b(r,this.value),o=u.call(this,i,this.primKey,r,s);o&&(n=this.value,An(o).forEach(function(t){v(n,t,o[t])}))}else a.call(this,this.primKey,n,s)};else if(u===k){var _=An(e),w=_.length;y=function(n){for(var t=!1,r=0;r<w;++r){var i=_[r],o=e[i];p(n,i)!==o&&(v(n,i,o),t=!0)}return t}}else{var x=e;e=m(x),y=function(t){var r=!1,i=u.call(this,e,this.primKey,g(t),s);return i&&n(e,i),An(e).forEach(function(n){var i=e[n];p(t,n)!==i&&(v(t,n,i),r=!0)}),i&&(e=m(x)),r}}var E=0,A=0,O=!1,I=[],j=[],C=null;r.clone().raw()._iterate(f,function(){O=!0,h()},l,c)})},delete:function(){var n=this,t=this._ctx,e=t.range,r=t.table.hook.deleting.fire,i=r!==k;if(!i&&X(t)&&(t.isPrimKey&&!bt||!e))return this._write(function(n,t,r){var i=yn(t),o=e?r.count(e):r.count();o.onerror=i,o.onsuccess=function(){var u=o.result;d(function(){var t=e?r.delete(e):r.clear();t.onerror=i,t.onsuccess=function(){return n(u)}},function(n){return t(n)})}});var o=i?2e3:1e4;return this._write(function(e,u,a,c){var s=0,f=n.clone({keysOnly:!t.isMatch&&!i}).distinct().limit(o).raw(),l=[],h=function(){return f.each(i?function(n,t){l.push([t.primaryKey,t.value])}:function(n,t){l.push(t.primaryKey)}).then(function(){return i?l.sort(function(n,t){return In(n[0],t[0])}):l.sort(In),J(a,c,l,i,r)}).then(function(){var n=l.length;return s+=n,l=[],n<o?s:h()})};e(h())})}}),n(this,{Collection:$,Table:W,Transaction:Q,Version:A,WhereClause:Y,WriteableCollection:Z,WriteableTable:H}),y(),zn.forEach(function(n){n(rt)})}function hn(n){if("function"==typeof n)return new n;if(On(n))return[hn(n[0])];if(n&&"object"==typeof n){var t={};return dn(t,n),t}return n}function dn(n,t){return An(t).forEach(function(e){var r=hn(t[e]);n[e]=r}),n}function pn(n){return function(t){n(t.target.result)}}function vn(n){return un(function(t){var e=t.target,r=e.result,i=e._hookCtx,o=i&&i.onsuccess;o&&o(r),n&&n(r)},n)}function yn(n){return function(t){return gn(t),n(t.target.error),!1}}function mn(n){return un(function(t){var e=t.target,r=e.error,i=e._hookCtx,o=i&&i.onerror;return o&&o(r),gn(t),n(r),!1})}function gn(n){n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault()}function bn(n){var t,e=ln.dependencies.localStorage;if(!e)return n([]);try{t=JSON.parse(e.getItem("Dexie.DatabaseNames")||"[]")}catch(n){t=[]}n(t)&&e.setItem("Dexie.DatabaseNames",JSON.stringify(t))}function _n(n){function t(n){return function(t){var e=n(t),r=e.value;return e.done?r:r&&"function"==typeof r.then?r.then(i,o):On(r)?U.all(r).then(i,o):i(r)}}var e=function(t){return n.next(t)},r=function(t){return n.throw(t)},i=t(e),o=t(r);return t(e)()}function wn(n,t,e,r,i,o,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=i,this.compound=o,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(i?"++":"")+a}function kn(n,t,e,r){this.name=n,this.primKey=t||new wn,this.indexes=e||[new wn],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=l(e,function(n){return[n.name,n]})}function xn(n){return 1===n.length?n[0]:n}function En(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var An=Object.keys,On=Array.isArray,In="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,jn=Object.getPrototypeOf,Cn={}.hasOwnProperty,Dn=Object.getOwnPropertyDescriptor,Pn=[].slice,Sn="undefined"!=typeof Symbol&&Symbol.iterator,Tn=Sn?function(n){var t;return null!=n&&(t=n[Sn])&&t.apply(n)}:function(){return null},Kn={},Bn=[].concat,Mn="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),Nn=function(){return!0},Fn=!new Error("").stack,qn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","IncompatiblePromise"],Rn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Un=qn.concat(Rn),zn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};i(B).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+T(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i(N).from(B),i(F).from(B);var Vn=Un.reduce(function(n,t){return n[t]=t+"Error",n},{}),Ln=B,Wn=Un.reduce(function(n,t){function e(n,e){this._e=S(),this.name=r,n?"string"==typeof n?(this.message=n,this.inner=e||null):"object"==typeof n&&(this.message=n.name+" "+n.message,this.inner=n):(this.message=zn[t]||r,this.inner=null)}var r=t+"Error";return i(e).from(Ln),n[t]=e,n},{});Wn.Syntax=SyntaxError,Wn.Type=TypeError,Wn.Range=RangeError;var Hn=Rn.reduce(function(n,t){return n[t+"Error"]=Wn[t],n},{}),Gn=Un.reduce(function(n,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(n[t+"Error"]=Wn[t]),n},{});Gn.ModifyError=N,Gn.DexieError=B,Gn.BulkError=F;var Jn={},Qn=100,Yn=20,$n=!1,Xn=In.setImmediate?setImmediate.bind(null,Y):In.MutationObserver?function(){var n=document.createElement("div");new MutationObserver(function(){Y(),n=null}).observe(n,{attributes:!0}),n.setAttribute("i","1")}:function(){setTimeout(Y,0)},Zn=function(n,t){ct.push([n,t]),tt&&(Xn(),tt=!1)},nt=!0,tt=!0,et=[],rt=[],it=null,ot=x,ut={global:!0,ref:0,unhandleds:[],onunhandled:sn,finalize:function(){this.unhandleds.forEach(function(n){try{sn(n[0],n[1])}catch(n){}})}},at=ut,ct=[],st=0,ft=[];e(U.prototype,{then:function(n,t){var e=this,r=new U(function(r,i){H(e,new z(n,t,r,i))});return Mn&&(!this._prev||null===this._state)&&Q(r,this),r},_then:function(n,t){H(this,new z(null,null,n,t))},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):on(n)}):this.then(null,function(n){return n&&n.name===t?e(n):on(n)})},finally:function(n){return this.then(function(t){return n(),t},function(t){return n(),on(t)})},uncaught:function(n){var t=this;return this.onuncatched=C(this.onuncatched,n),this._state===!1&&et.indexOf(this)===-1&&et.some(function(n,e,r){return n._value===t._value&&(r[e]=t)}),this},stack:{get:function(){if(this._stack)return this._stack;try{$n=!0;var n=J(this,[],Yn),t=n.join("\nFrom previous: ");return null!==this._state&&(this._stack=t),t}finally{$n=!1}}}}),e(U,{all:function(){var n=_.apply(null,arguments);return new U(function(t,e){0===n.length&&t([]);var r=n.length;n.forEach(function(i,o){return U.resolve(i).then(function(e){n[o]=e,--r||t(n)},e)})})},resolve:function(n){return n instanceof U?n:n&&"function"==typeof n.then?new U(function(t,e){n.then(t,e)}):new U(Jn,!0,n)},reject:on,race:function(){var n=_.apply(null,arguments);return new U(function(t,e){n.map(function(n){return U.resolve(n).then(t,e)})})},PSD:{get:function(){return at},set:function(n){return at=n}},newPSD:an,usePSD:cn,scheduler:{get:function(){return Zn},set:function(n){Zn=n}},rejectionMapper:{get:function(){return ot},set:function(n){ot=n}},follow:function(n){return new U(function(t,e){return an(function(t,e){var r=at;r.unhandleds=[],r.onunhandled=e,r.finalize=A(function(){var n=this;nn(function(){0===n.unhandleds.length?t():e(n.unhandleds[0])})},r.finalize),n()},t,e)})},on:R(null,{error:[C,rn]})}),c(function(){Zn=function(n,t){setTimeout(function(){n.apply(null,t)},0)}});var lt="2.0.0-beta.1",ht=String.fromCharCode(65535),dt=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return ht}}(),pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",vt="String expected.",yt=[],mt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),gt=mt,bt=mt,_t=function(n){return!/(dexie\.js|dexie\.min\.js)/.test(n)};P(Mn,_t);var wt=function(){},kt=!1,xt=In.idbModules&&In.idbModules.shimIndexedDB?In.idbModules:{};return e(ln,Gn),e(ln,{delete:function(n){var t=new ln(n),e=t.delete();return e.onblocked=function(n){return t.on("blocked",n),this},e},exists:function(n){return new ln(n).open().then(function(n){return n.close(),!0}).catch(ln.NoSuchDatabaseError,function(){return!1})},getDatabaseNames:function(n){return new U(function(n,t){var e=En(indexedDB);if(e){var r=e();r.onsuccess=function(t){n(u(t.target.result,0))},r.onerror=yn(t)}else bn(function(t){return n(t),!1})}).then(n)},defineClass:function(t){function e(e){e?n(this,e):kt&&dn(this,t)}return e},applyStructure:dn,ignoreTransaction:function(n){return at.trans?cn(at.transless,n):n()},vip:function(n){return an(function(){return at.letThrough=!0,n()})},async:function(n){return function(){try{var t=_n(n.apply(this,arguments));return t&&"function"==typeof t.then?t:U.resolve(t)}catch(n){return fn(n)}}},spawn:function(n,t,e){try{var r=_n(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:U.resolve(r)}catch(n){return fn(n)}},currentTransaction:{get:function(){return at.trans||null}},Promise:U,debug:{get:function(){return Mn},set:function(n){P(n,"dexie"===n?function(){return!0}:_t)}},derive:i,extend:n,props:e,override:a,Events:R,events:{get:K(function(){return R})},getByKeyPath:p,setByKeyPath:v,delByKeyPath:y,shallowClone:m,deepClone:g,getObjectDiff:b,asap:f,maxKey:dt,addons:[],connections:yt,MultiModifyError:Wn.Modify,errnames:Vn,IndexSpec:wn,TableSchema:kn,dependencies:{indexedDB:xt.shimIndexedDB||In.indexedDB||In.mozIndexedDB||In.webkitIndexedDB||In.msIndexedDB,IDBKeyRange:xt.IDBKeyRange||In.IDBKeyRange||In.webkitIDBKeyRange},semVer:lt,version:lt.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),fakeAutoComplete:wt,default:ln}),d(function(){ln.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:In.localStorage}),U.rejectionMapper=q,c(function(){ln.fakeAutoComplete=wt=c,ln.fake=kt=!0}),ln});
!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?n:(An(t).forEach(function(e){n[e]=t[e]}),n)}function t(n,t){return Sn.call(n,t)}function e(n,t){"function"==typeof t&&(t=t(In(n))),An(t).forEach(function(e){r(n,e,t[e])})}function r(e,r,i,o){Kn(e,r,n(i&&t(i,"get")&&"function"==typeof i.get?{get:i.get,set:i.set,configurable:!0}:{value:i,configurable:!0,writable:!0},o))}function i(n){return{from:function(t){return n.prototype=Object.create(t.prototype),r(n.prototype,"constructor",n),{extend:e.bind(null,n.prototype)}}}}function o(n,t){var e,r=Tn(n,t);return r||(e=In(n))&&o(e,t)}function u(n,t,e){return Cn.call(n,t,e)}function a(n,t){return t(n)}function c(n){var t=setTimeout(n,1e3);clearTimeout(t)}function s(n){if(!n)throw new Error("Assertion Failed")}function f(n){Dn.setImmediate?setImmediate(n):setTimeout(n,0)}function l(n,t){return n.reduce(function(n,e,r){var i=t(e,r);return i&&(n[i[0]]=i[1]),n},{})}function h(n,t){return function(){try{n.apply(this,arguments)}catch(n){t(n)}}}function d(n,t,e){try{n.apply(null,e)}catch(n){t&&t(n)}}function v(n,e){if(t(n,e))return n[e];if(!e)return n;if("string"!=typeof e){for(var r=[],i=0,o=e.length;i<o;++i){var u=v(n,e[i]);r.push(u)}return r}var a=e.indexOf(".");if(a!==-1){var c=n[e.substr(0,a)];return void 0===c?void 0:v(c,e.substr(a+1))}}function p(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){s("string"!=typeof e&&"length"in e);for(var r=0,i=t.length;r<i;++r)p(n,t[r],e[r])}else{var o=t.indexOf(".");if(o!==-1){var u=t.substr(0,o),a=t.substr(o+1);if(""===a)void 0===e?delete n[u]:n[u]=e;else{var c=n[u];c||(c=n[u]={}),p(c,a,e)}}else void 0===e?delete n[t]:n[t]=e}}function y(n,t){"string"==typeof t?p(n,t,void 0):"length"in t&&[].map.call(t,function(t){p(n,t,void 0)})}function m(n){var e={};for(var r in n)t(n,r)&&(e[r]=n[r]);return e}function g(n){if(!n||"object"!=typeof n)return n;var e;if(On(n)){e=[];for(var r=0,i=n.length;r<i;++r)e.push(g(n[r]))}else if(n instanceof Date)e=new Date,e.setTime(n.getTime());else{e=n.constructor?Object.create(n.constructor.prototype):{};for(var o in n)t(n,o)&&(e[o]=g(n[o]))}return e}function b(n,e,r,i){return r=r||{},i=i||"",An(n).forEach(function(o){if(t(e,o)){var u=n[o],a=e[o];"object"==typeof u&&"object"==typeof a&&u&&a&&u.constructor===a.constructor?b(u,a,r,i+o+"."):u!==a&&(r[i+o]=e[o])}else r[i+o]=void 0}),An(e).forEach(function(o){t(n,o)||(r[i+o]=e[o])}),r}function w(n){var t,e,r,i;if(1===arguments.length){if(On(n))return n.slice();if(this===Nn&&"string"==typeof n)return[n];if(i=Mn(n)){for(e=[];r=i.next(),!r.done;)e.push(r.value);return e}if(null==n)return[n];if(t=n.length,"number"==typeof t){for(e=new Array(t);t--;)e[t]=n[t];return e}return[n]}for(t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return e}function _(n){return Fn.apply([],n)}function k(n,t){Rn=n,qn=t}function x(){if(Un)try{throw x.arguments,new Error}catch(n){return n}return new Error}function P(n,t){var e=n.stack;return e?(t=t||0,0===e.indexOf(n.name)&&(t+=(n.name+n.message).split("\n").length),e.split("\n").slice(t).filter(qn).map(function(n){return"\n"+n}).join("")):""}function E(n,t){return function(){return console.warn(n+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+P(x(),1)),t.apply(this,arguments)}}function j(n,t){this._e=x(),this.name=n,this.message=t}function A(n,t){return n+". Errors: "+t.map(function(n){return n.toString()}).filter(function(n,t,e){return e.indexOf(n)===t}).join("\n")}function O(n,t,e,r){this._e=x(),this.failures=t,this.failedKeys=r,this.successCount=e}function D(n,t){this._e=x(),this.name="BulkError",this.failures=t,this.message=A(n,t)}function I(n,t){if(!n||n instanceof j||n instanceof TypeError||n instanceof SyntaxError||!n.name||!Qn[n.name])return n;var e=new Qn[n.name](t||n.message,n);return"stack"in n&&r(e,"stack",{get:function(){return this.inner.stack}}),e}function S(){}function K(n){return n}function T(n,t){return null==n||n===K?t:function(e){return t(n(e))}}function C(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function B(n,t){return n===S?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?C(r,this.onsuccess):r),i&&(this.onerror=this.onerror?C(i,this.onerror):i),void 0!==o?o:e}}function M(n,t){return n===S?t:function(){n.apply(this,arguments);var e=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?C(e,this.onsuccess):e),r&&(this.onerror=this.onerror?C(r,this.onerror):r)}}function N(t,e){return t===S?e:function(r){var i=t.apply(this,arguments);n(r,i);var o=this.onsuccess,u=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?C(o,this.onsuccess):o),u&&(this.onerror=this.onerror?C(u,this.onerror):u),void 0===i?void 0===a?void 0:a:n(i,a)}}function F(n,t){return n===S?t:function(){return t.apply(this,arguments)!==!1&&n.apply(this,arguments)}}function R(n,t){return n===S?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function q(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=S,this._lib=!1;var t=this._PSD=pt;if(Rn&&(this._stackHolder=x(),this._prev=null,this._numPrev=0,J(this,ht)),"function"!=typeof n){if(n!==$n)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&V(this,this._value))}this._state=null,this._value=null,++t.ref,z(this,n)}function U(n,t,e,r,i){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r,this.psd=i}function z(n,t){try{t(function(t){if(null===n._state){if(t===n)throw new TypeError("A promise cannot be resolved with itself.");var e=n._lib&&Y();t&&"function"==typeof t.then?z(n,function(n,e){t instanceof q?t._then(n,e):t.then(n,e)}):(n._state=!0,n._value=t,L(n)),e&&$()}},V.bind(null,n))}catch(t){V(n,t)}}function V(n,t){if(lt.push(t),null===n._state){var e=n._lib&&Y();t=dt(t),n._state=!1,n._value=t,Rn&&null!==t&&"object"==typeof t&&!t._promise&&d(function(){var e=o(t,"stack");t._promise=n,r(t,"stack",{get:function(){return ot?e&&(e.get?e.get.apply(t):e.value):n.stack}})}),nn(n),L(n),e&&$()}}function L(n){var t=n._listeners;n._listeners=[];for(var e=0,r=t.length;e<r;++e)W(n,t[e]);var i=n._PSD;--i.ref||i.finalize(),0===mt&&(++mt,at(function(){0===--mt&&X()},[]))}function W(n,t){if(null===n._state)return void n._listeners.push(t);var e=n._state?t.onFulfilled:t.onRejected;return null===e?(n._state?t.resolve:t.reject)(n._value):(++t.psd.ref,++mt,void at(H,[e,n,t]))}function H(n,t,e){try{ht=t;var r,i=t._value;t._state?r=n(i):(lt.length&&(lt=[]),r=n(i),lt.indexOf(i)===-1&&tn(t)),e.resolve(r)}catch(n){e.reject(n)}finally{ht=null,0===--mt&&X(),--e.psd.ref||e.psd.finalize()}}function G(n,t,e){if(t.length===e)return t;var r="";if(n._state===!1){var i,o,u=n._value;null!=u?(i=u.name||"Error",o=u.message||u,r=P(u,0)):(i=u,o=""),t.push(i+(o?": "+o:"")+r)}return Rn&&(r=P(n._stackHolder,2),r&&t.indexOf(r)===-1&&t.push(r),n._prev&&G(n._prev,t,e)),t}function J(n,t){var e=t?t._numPrev+1:0;e<Xn&&(n._prev=t,n._numPrev=e)}function Q(){Y()&&$()}function Y(){var n=ct;return ct=!1,st=!1,n}function $(){var n,t,e;do for(;yt.length>0;)for(n=yt,yt=[],e=n.length,t=0;t<e;++t){var r=n[t];r[0].apply(null,r[1])}while(yt.length>0);ct=!0,st=!0}function X(){var n=ft;ft=[],n.forEach(function(n){n._PSD.onunhandled.call(null,n._value,n)});for(var t=gt.slice(0),e=t.length;e;)t[--e]()}function Z(n){function t(){n(),gt.splice(gt.indexOf(t),1)}gt.push(t),++mt,at(function(){0===--mt&&X()},[])}function nn(n){ft.some(function(t){return t._value===n._value})||ft.push(n)}function tn(n){for(var t=ft.length;t;)if(ft[--t]._value===n._value)return void ft.splice(t,1)}function en(n){return new q($n,!1,n)}function rn(n,t){var e=pt;return function(){var r=Y(),i=pt;try{return un(e),n.apply(this,arguments)}catch(n){t&&t(n)}finally{un(i),r&&$()}}}function on(t,e,r,i){var o=pt,u=Object.create(o);u.parent=o,u.ref=0,u.global=!1;var a=vt.env;u.env=it?{Promise:q,nc:q,nthen:fn(a.nthen,u),gthen:fn(a.gthen,u),dthen:fn(a.dthen,u)}:{dthen:fn(a.dthen,u)},e&&n(u,e),++o.ref,u.finalize=function(){--this.parent.ref||this.parent.finalize()};var c=an(u,t,r,i);return 0===u.ref&&u.finalize(),c}function un(n){if(n!==pt){var t=pt;if(pt=n,t===vt&&"Promise"in Dn){var e=vt.env;e.Promise=Dn.Promise,e.nc=et.constructor,e.nthen=et.then,e.gthen=Dn.Promise.prototype.then,e.dthen=q.prototype.then}q.prototype.then=n.env.dthen,"Promise"in Dn&&(Dn.Promise=n.env.Promise,et.then=n.env.nthen,et.constructor=n.env.nc,vt.env.Promise.prototype.then=n.env.gthen)}}function an(n,t,e,r,i){var o=pt;try{return un(n),t(e,r,i)}finally{un(o)}}function cn(n){it.call(tt,n)}function sn(n,t,e){return"function"!=typeof n?n:function(){var r=pt;un(t),e&&(++t.ref,cn(function(){un(t)}));try{return n.apply(this,arguments)}finally{un(r),e&&cn(function(){un(vt),--t.ref||t.finalize()})}}}function fn(n,t){return function(e,r){var i=t!==pt&&!!it;return n.call(this,sn(e,t,i),sn(r,t,i))}}function ln(t,e){var r;try{r=e.onuncatched(t)}catch(n){}if(r!==!1)try{var i,o={promise:e,reason:t};if(Dn.document&&document.createEvent?(i=document.createEvent("Event"),i.initEvent(bt,!0,!0),n(i,o)):Dn.CustomEvent&&(i=new CustomEvent(bt,{detail:o}),n(i,o)),i&&Dn.dispatchEvent&&(dispatchEvent(i),!Dn.PromiseRejectionEvent&&Dn.onunhandledrejection))try{Dn.onunhandledrejection(i)}catch(n){}i.defaultPrevented||console.warn("Unhandled rejection: "+(t.stack||t))}catch(n){}}function hn(n){function t(n,t,o){if("object"==typeof n)return e(n);t||(t=F),o||(o=S);var u={subscribers:[],fire:o,subscribe:function(n){u.subscribers.indexOf(n)===-1&&(u.subscribers.push(n),u.fire=t(u.fire,n))},unsubscribe:function(n){u.subscribers=u.subscribers.filter(function(t){return t!==n}),u.fire=u.subscribers.reduce(t,o)}};return r[n]=i[n]=u,u}function e(n){An(n).forEach(function(e){var r=n[e];if(On(r))t(e,n[e][0],n[e][1]);else{if("asap"!==r)throw new Jn.InvalidArgument("Invalid event config");var i=t(e,K,function(){for(var n=arguments.length,t=new Array(n);n--;)t[n]=arguments[n];i.subscribers.forEach(function(n){f(function(){n.apply(null,t)})})})}})}var r={},i=function(t,e){if(e){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return r[t].subscribe.apply(null,o),n}if("string"==typeof t)return r[t]};i.addEventType=t;for(var o=1,u=arguments.length;o<u;++o)t(arguments[o]);return i}function dn(i,o){function f(){Zn.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+Zn.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+Zn.name+"'. Closing db now to resume the delete request."),Zn.close()}),Zn.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+Zn.name+"') was blocked"):console.warn("Upgrade '"+Zn.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function y(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function k(n,t,e){var r=Zn._createTransaction(Xn,Ln,zn);r.create(t),r._completion.catch(e);var i=r._reject.bind(r);on(function(){pt.trans=r,0===n?(An(zn).forEach(function(n){A(t,n,zn[n].primKey,zn[n].indexes)}),q.follow(function(){return Zn.on.populate.fire(r)}).catch(i)):P(n,r,t).catch(i)})}function P(n,t,e){function r(){return i.length?q.resolve(i.shift()(t.idbtrans)).then(r):q.resolve()}var i=[],o=Vn.filter(function(t){return t._cfg.version===n})[0];if(!o)throw new Jn.Upgrade("Dexie specification of currently installed DB version is missing");zn=Zn._dbSchema=o._cfg.dbschema;var u=!1,a=Vn.filter(function(t){return t._cfg.version>n});return a.forEach(function(n){i.push(function(){var r=zn,i=n._cfg.dbschema;Dn(r,e),Dn(i,e),zn=Zn._dbSchema=i;var o=j(r,i);if(o.add.forEach(function(n){A(e,n[0],n[1].primKey,n[1].indexes)}),o.change.forEach(function(n){if(n.recreate)throw new Jn.Upgrade("Not yet support for changing primary key");var t=e.objectStore(n.name);n.add.forEach(function(n){F(t,n)}),n.change.forEach(function(n){t.deleteIndex(n.name),F(t,n)}),n.del.forEach(function(n){t.deleteIndex(n)})}),n._cfg.contentUpgrade)return u=!0,q.follow(function(){n._cfg.contentUpgrade(t)})}),i.push(function(t){if(!u||!Ot){var e=n._cfg.dbschema;C(e,t)}})}),r().then(function(){I(zn,e)})}function j(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var i=n[r],o=t[r];if(i){var u={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)u.recreate=!0,e.change.push(u);else{var a=i.idxByName,c=o.idxByName;for(var s in a)c[s]||u.del.push(s);for(s in c){var f=a[s],l=c[s];f?f.src!==l.src&&u.change.push(l):u.add.push(l)}(u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,o])}return e}function A(n,t,e,r){var i=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){F(i,n)}),i}function I(n,t){An(n).forEach(function(e){t.db.objectStoreNames.contains(e)||A(t,e,n[e].primKey,n[e].indexes)})}function C(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null==n[r]&&t.db.deleteObjectStore(r)}}function F(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function U(n,t,e){if(Yn||pt.letThrough){var r=Zn._createTransaction(n,t,zn);return r._promise(n,function(n,t){on(function(){pt.trans=r,e(n,t,r)})}).then(function(n){return r._completion.then(function(){return n})})}if(!Qn){if(!Fn)return wt(new Jn.DatabaseClosed);Zn.open().catch(S)}return nt.then(function(){return U(n,t,e)})}function z(n,t,e){var r=arguments.length;if(r<2)throw new Jn.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];e=i.pop();var o=_(i);return[n,o,e]}function V(n,t){this.name=n,this.schema=t,this.hook=Wn[n]?Wn[n].hook:hn(null,{creating:[B,S],reading:[T,K],updating:[N,S],deleting:[M,S]})}function L(n,t,e){return(e?bn:gn)(function(e){n.push(e),t&&t()})}function W(n,t,e,r,i){return new q(function(o,u){var a=e.length,c=a-1;if(0===a)return o();if(r){var s,f=bn(u),l=mn(null);d(function(){for(var r=0;r<a;++r){s={onsuccess:null,onerror:null};var u=e[r];i.call(s,u[0],u[1],t);var h=n.delete(u[0]);h._hookCtx=s,h.onerror=f,r===c?h.onsuccess=mn(o):h.onsuccess=l}},function(n){throw s.onerror&&s.onerror(n),n})}else for(var h=0;h<a;++h){var v=n.delete(e[h]);v.onerror=rn(gn(u)),h===c&&(v.onsuccess=rn(function(){return o()}))}})}function H(n,t,e,r){var i=this;this.db=Zn,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=hn(this,"complete","error","abort"),this.parent=r||null,this.active=!0,this._tables=null,this._reculock=0,this._blockedFuncs=[],this._psd=null,this._dbschema=e,this._resolve=null,this._reject=null,this._completion=new q(function(n,t){i._resolve=n,i._reject=t}),this._completion.then(function(){i.on.complete.fire()},function(n){return i.on.error.fire(n),i.parent?i.parent._reject(n):i.active&&i.idbtrans&&i.idbtrans.abort(),i.active=!1,wt(n)})}function G(n,t,e){this._ctx={table:n,index:":id"===t?null:t,or:e}}function J(n,t){var e=null,r=null;if(t)try{e=t()}catch(n){r=n}var i=n._ctx,o=i.table;this._ctx={table:o,index:i.index,isPrimKey:!i.index||o.schema.primKey.keyPath&&i.index===o.schema.primKey.name,range:e,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:o.hook.reading.fire}}function Q(n,t){return!(n.filter||n.algorithm||n.or)&&(t?n.justLimit:!n.replayFilter)}function Y(n,t){return n._cfg.version-t._cfg.version}function $(n,t,e){t.forEach(function(t){var r=Zn._tableFactory(Xn,e[t]);n.forEach(function(n){t in n||(n[t]=r)})})}function X(n){n.forEach(function(n){for(var t in n)n[t]instanceof V&&delete n[t]})}function Z(n,t,e,r,i,o){var u=o?function(n,t,r){return e(o(n),t,r)}:e,a=rn(u,i);n.onerror||(n.onerror=gn(i)),t?n.onsuccess=h(function(){var e=n.result;if(e){var o=function(){e.continue()};t(e,function(n){o=n},r,i)&&a(e.value,e,function(n){o=n}),o()}else r()},i):n.onsuccess=h(function(){var t=n.result;if(t){var e=function(){t.continue()};a(t.value,t,function(n){e=n}),e()}else r()},i)}function nn(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace(/([&*]|\+\+)/g,""),r=/^\[/.test(e)?e.match(/^\[(.*)\]$/)[1].split("+"):e;t.push(new xn(e,r||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),On(r),/\./.test(n)))}),t}function tn(n,t){return qn.cmp(n,t)}function en(n,t){return tn(n,t)<0?n:t}function un(n,t){return tn(n,t)>0?n:t}function an(n,t){return qn.cmp(n,t)}function cn(n,t){return qn.cmp(t,n)}function sn(n,t){return n<t?-1:n===t?0:1}function fn(n,t){return n>t?-1:n===t?0:1}function ln(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function vn(){if(Zn.verno=Hn.version/10,Zn._dbSchema=zn={},Ln=u(Hn.objectStoreNames,0),0!==Ln.length){var n=Hn.transaction(En(Ln),"readonly");Ln.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1,o=new xn(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),u=[],a=0;a<e.indexNames.length;++a){var c=e.index(e.indexNames[a]);r=c.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1;var s=new xn(c.name,r,!!c.unique,!!c.multiEntry,!1,r&&"string"!=typeof r,i);u.push(s)}zn[t]=new Pn(t,o,u,{})}),$([Wn],An(zn),zn)}}function Dn(n,t){for(var e=t.db.objectStoreNames,r=0;r<e.length;++r){var i=e[r],o=t.objectStore(i);Tn="getAll"in o;for(var a=0;a<o.indexNames.length;++a){var c=o.indexNames[a],s=o.index(c).keyPath,f="string"==typeof s?s:"["+u(s).join("+")+"]";if(n[i]){var l=n[i].idxByName[f];l&&(l.name=c)}}}}function In(n){Zn.on("blocked").fire(n),jt.filter(function(n){return n.name===Zn.name&&n!==Zn&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var Sn,Kn,Tn,Cn=dn.dependencies,Bn=n({addons:dn.addons,autoOpen:!0,indexedDB:Cn.indexedDB,IDBKeyRange:Cn.IDBKeyRange},o),Mn=Bn.addons,Fn=Bn.autoOpen,qn=Bn.indexedDB,Un=Bn.IDBKeyRange,zn=this._dbSchema={},Vn=[],Ln=[],Wn={},Hn=null,Gn=null,Qn=!1,Yn=!1,$n="readonly",Xn="readwrite",Zn=this,nt=new q(function(n){Sn=n}),tt=new q(function(n,t){Kn=t}),et=!0,rt=!!jn(qn);this.version=function(n){if(Hn||Qn)throw new Jn.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=Vn.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new y(n),Vn.push(t),Vn.sort(Y),t)},n(y.prototype,{stores:function(t){this._cfg.storesSource=this._cfg.storesSource?n(this._cfg.storesSource,t):t;var e={};Vn.forEach(function(t){n(e,t._cfg.storesSource)});var r=this._cfg.dbschema={};return this._parseStoresSpec(e,r),zn=Zn._dbSchema=r,X([Wn,Zn,H.prototype]),$([Wn,Zn,H.prototype,this._cfg.tables],An(r),r),Ln=An(r),this},upgrade:function(n){var t=this;return St(function(){n(Zn._createTransaction(Xn,An(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){An(n).forEach(function(e){if(null!==n[e]){var r={},i=nn(n[e]),o=i.shift();if(o.multi)throw new Jn.Schema("Primary key cannot be multi-valued");o.keyPath&&p(r,o.keyPath,o.auto?0:o.keyPath),i.forEach(function(n){if(n.auto)throw new Jn.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new Jn.Schema("Index must have a name and cannot be an empty string");p(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new Pn(e,o,i,r)}})}}),this._allTables=Wn,this._tableFactory=function(n,t){return new V(t.name,t)},this._createTransaction=function(n,t,e,r){return new H(n,t,e,r)},this._whenReady=function(n){return new q(Kt||Yn||pt.letThrough?n:function(t,e){if(!Qn){if(!Fn)return void e(new Jn.DatabaseClosed);Zn.open().catch(S)}nt.then(function(){n(t,e)})})},this.verno=0,this.open=function(){if(Qn||Hn)return nt.then(function(){return Gn?wt(Gn):Zn});Rn&&(tt._stackHolder=x()),Qn=!0,Gn=null,Yn=!1;var n=Sn,t=null;return q.race([tt,new q(function(n,e){if(c(function(){return n()}),Vn.length>0&&(et=!1),!qn)throw new Jn.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var r=et?qn.open(i):qn.open(i,Math.round(10*Zn.verno));if(!r)throw new Jn.MissingAPI("IndexedDB API not available");r.onerror=rn(gn(e)),r.onblocked=rn(In),r.onupgradeneeded=rn(function(n){if(t=r.transaction,et&&!Zn._allowEmptyDB){r.onerror=wn,t.abort(),r.result.close();var o=qn.deleteDatabase(i);o.onsuccess=o.onerror=rn(function(){e(new Jn.NoSuchDatabase("Database "+i+" doesnt exist"))})}else{t.onerror=rn(gn(e));var u=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;k(u/10,t,e,r)}},e),r.onsuccess=rn(function(){if(t=null,Hn=r.result,jt.push(Zn),et)vn();else if(Hn.objectStoreNames.length>0)try{Dn(zn,Hn.transaction(En(Hn.objectStoreNames),$n))}catch(n){}Hn.onversionchange=rn(function(n){Zn._vcFired=!0,Zn.on("versionchange").fire(n)}),rt||_n(function(n){if(n.indexOf(i)===-1)return n.push(i)}),n()},e)})]).then(function(){return dn.vip(Zn.on.ready.fire)}).then(function(){return Qn=!1,Zn}).catch(function(n){try{t&&t.abort()}catch(n){}return Qn=!1,Zn.close(),Gn=n,wt(Gn)}).finally(function(){Yn=!0,n()})},this.close=function(){var n=jt.indexOf(Zn);if(n>=0&&jt.splice(n,1),Hn){try{Hn.close()}catch(n){}Hn=null}Fn=!1,Gn=new Jn.DatabaseClosed,Qn&&Kn(Gn),nt=new q(function(n){Sn=n}),tt=new q(function(n,t){Kn=t})},this.delete=function(){var n=arguments.length>0;return new q(function(t,e){function r(){Zn.close();var n=qn.deleteDatabase(i);n.onsuccess=rn(function(){rt||_n(function(n){var t=n.indexOf(i);if(t>=0)return n.splice(t,1)}),t()}),n.onerror=rn(gn(e)),n.onblocked=In}if(n)throw new Jn.InvalidArgument("Arguments not allowed in db.delete()");Qn?nt.then(r):r()})},this.backendDB=function(){return Hn},this.isOpen=function(){return null!==Hn},this.hasFailed=function(){return null!==Gn},this.dynamicallyOpened=function(){return et},this.name=i,r(this,"tables",{get:function(){return An(Wn).map(function(n){return Wn[n]})}}),this.on=hn(this,"populate","blocked","versionchange",{ready:[R,S]}),this.on.ready.subscribe=a(this.on.ready.subscribe,function(n){return function(t,e){dn.vip(function(){Yn?(Gn||q.resolve().then(t),e&&n(t)):(n(t),e||n(function n(){Zn.on.ready.unsubscribe(t),Zn.on.ready.unsubscribe(n)}))})}}),St(function(){Zn.on("populate").fire(Zn._createTransaction(Xn,Ln,zn))}),this.transaction=function(){var n=z.apply(this,arguments);return this._transaction.apply(this,n)},this._transaction=function(n,t,e){function r(t){var r=pt;t(q.resolve().then(function(){var t=pt.transless||r,o=Zn._createTransaction(n,u,zn,i),a={trans:o,transless:t};i?o.idbtrans=i.idbtrans:o.create();var c;return q.follow(function(){c=e.call(o,o),c&&"function"==typeof c.next&&"function"==typeof c.throw&&(c=kn(c))},a).then(function(){return i&&o._resolve(),o._completion}).then(function(){return c}).catch(function(n){return o._reject(n),wt(n)})}))}var i=pt.trans;i&&i.db===Zn&&n.indexOf("!")===-1||(i=null);var o=n.indexOf("?")!==-1;n=n.replace("!","").replace("?","");try{var u=t.map(function(n){var t=n instanceof V?n.name:n;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t});if("r"==n||n==$n)n=$n;else{if("rw"!=n&&n!=Xn)throw new Jn.InvalidArgument("Invalid transaction mode: "+n);n=Xn}if(i){if(i.mode===$n&&n===Xn){if(!o)throw new Jn.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&u.forEach(function(n){if(i&&i.storeNames.indexOf(n)===-1){if(!o)throw new Jn.SubTransaction("Table "+n+" not included in parent transaction.");i=null}})}}catch(n){return i?i._promise(null,function(t,e){e(n)}):wt(n)}return i?i._promise(n,r,"lock"):Zn._whenReady(r)},this.table=function(n){if(Kt&&et)return new V(n);if(!t(Wn,n))throw new Jn.InvalidTable("Table "+n+" does not exist");return Wn[n]},e(V.prototype,{_trans:function(n,t,e){var r=pt.trans;return r&&r.db===Zn?r._promise(n,t,e):U(n,[this.name],t)},_idbstore:function(n,t,e){function r(n,e,r){t(n,e,r.idbtrans.objectStore(o),r)}if(Kt)return new q(t);var i=pt.trans,o=this.name;return i&&i.db===Zn?i._promise(n,r,e):U(n,[this.name],r)},get:function(n,t){var e=this;return this._idbstore($n,function(t,r,i){Kt&&t(e.schema.instanceTemplate);var o=i.get(n);o.onerror=gn(r),o.onsuccess=function(){t(e.hook.reading.fire(o.result))}}).then(t)},where:function(n){return new G(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){return this.toCollection().each(n)},toArray:function(n){return this.toCollection().toArray(n)},orderBy:function(n){return new J(new G(this,n))},toCollection:function(){return new J(new G(this))},mapToClass:function(n,e){this.schema.mappedClass=n;var r=Object.create(n.prototype);e&&pn(r,e),this.schema.instanceTemplate=r;var i=function(e){if(!e)return e;var r=Object.create(n.prototype);for(var i in e)t(e,i)&&(r[i]=e[i]);return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),n},defineClass:function(n){return this.mapToClass(dn.defineClass(n),n)},bulkDelete:function(n){return this.hook.deleting.fire===S?this._idbstore(Xn,function(t,e,r,i){t(W(r,i,n,!1,S))}):this.where(":id").anyOf(n).delete().then(function(){})},bulkPut:function(n,t){var e=this;return this._idbstore(Xn,function(r,i,o){if(!o.keyPath&&!e.schema.primKey.auto&&!t)throw new Jn.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(o.keyPath&&t)throw new Jn.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new Jn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return r();var u,a,c=function(n){0===s.length?r(n):i(new D(e.name+".bulkPut(): "+s.length+" of "+f+" operations failed",s))},s=[],f=n.length,h=e;if(e.hook.creating.fire===S&&e.hook.updating.fire===S){a=L(s);for(var d=0,p=n.length;d<p;++d)u=t?o.put(n[d],t[d]):o.put(n[d]),u.onerror=a;u.onerror=L(s,c),u.onsuccess=yn(c)}else{var y=t||o.keyPath&&n.map(function(n){return v(n,o.keyPath)}),m=y&&l(y,function(t,e){return null!=t&&[t,n[e]]}),g=y?h.where(":id").anyOf(y.filter(function(n){return null!=n})).modify(function(){this.value=m[this.primKey],m[this.primKey]=null}).catch(O,function(n){s=n.failures}).then(function(){for(var e=[],r=t&&[],i=y.length-1;i>=0;--i){var o=y[i];(null==o||m[o])&&(e.push(n[i]),t&&r.push(o),null!=o&&(m[o]=null))}return e.reverse(),t&&r.reverse(),h.bulkAdd(e,r)}).then(function(n){var t=y[y.length-1];return null!=t?t:n}):h.bulkAdd(n);g.then(c).catch(D,function(n){s=s.concat(n.failures),c()}).catch(i)}},"locked")},bulkAdd:function(n,t){var e=this,r=this.hook.creating.fire;return this._idbstore(Xn,function(i,o,u,a){function c(n){0===h.length?i(n):o(new D(e.name+".bulkAdd(): "+h.length+" of "+y+" operations failed",h))}if(!u.keyPath&&!e.schema.primKey.auto&&!t)throw new Jn.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(u.keyPath&&t)throw new Jn.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new Jn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return i();var s,f,l,h=[],y=n.length;if(r!==S){var m,b=u.keyPath;f=L(h,null,!0),l=mn(null),d(function(){for(var e=0,i=n.length;e<i;++e){m={onerror:null,onsuccess:null};var o=t&&t[e],c=n[e],h=t?o:b?v(c,b):void 0,d=r.call(m,h,c,a);null==h&&null!=d&&(b?(c=g(c),p(c,b,d)):o=d),s=null!=o?u.add(c,o):u.add(c),s._hookCtx=m,e<i-1&&(s.onerror=f,m.onsuccess&&(s.onsuccess=l))}},function(n){throw m.onerror&&m.onerror(n),n}),s.onerror=L(h,c,!0),s.onsuccess=mn(c)}else{f=L(h);for(var w=0,_=n.length;w<_;++w)s=t?u.add(n[w],t[w]):u.add(n[w]),s.onerror=f;s.onerror=L(h,c),s.onsuccess=yn(c)}})},add:function(n,t){var e=this.hook.creating.fire;return this._idbstore(Xn,function(r,i,o,u){var a={onsuccess:null,onerror:null};if(e!==S){var c=null!=t?t:o.keyPath?v(n,o.keyPath):void 0,s=e.call(a,c,n,u);null==c&&null!=s&&(o.keyPath?p(n,o.keyPath,s):t=s)}try{var f=null!=t?o.add(n,t):o.add(n);f._hookCtx=a,f.onerror=bn(i),f.onsuccess=mn(function(t){var e=o.keyPath;e&&p(n,e,t),r(t)})}catch(n){throw a.onerror&&a.onerror(n),n}})},put:function(n,t){var e=this,r=this.hook.creating.fire,i=this.hook.updating.fire;return r!==S||i!==S?this._trans(Xn,function(r,i,o){var u=void 0!==t?t:e.schema.primKey.keyPath&&v(n,e.schema.primKey.keyPath);null==u?e.add(n).then(r,i):(o._lock(),n=g(n),e.where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?e.add(n,t):u}).finally(function(){o._unlock()}).then(r,i))}):this._idbstore(Xn,function(e,r,i){var o=void 0!==t?i.put(n,t):i.put(n);o.onerror=gn(r),o.onsuccess=function(t){var r=i.keyPath;r&&p(n,r,t.target.result),e(o.result)}})},delete:function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n).delete():this._idbstore(Xn,function(t,e,r){var i=r.delete(n);i.onerror=gn(e),i.onsuccess=function(){t(i.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection().delete():this._idbstore(Xn,function(n,t,e){var r=e.clear();r.onerror=gn(t),r.onsuccess=function(){n(r.result)}})},update:function(n,t){if("object"!=typeof t||On(t))throw new Jn.InvalidArgument("Modifications must be an object.");if("object"!=typeof n||On(n))return this.where(":id").equals(n).modify(t);An(t).forEach(function(e){p(n,e,t[e])});var e=v(n,this.schema.primKey.keyPath);return void 0===e?wt(new Jn.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)}}),e(H.prototype,{_lock:function(){return s(!pt.global),++this._reculock,1!==this._reculock||pt.global||(pt.lockOwnerFor=this),this},_unlock:function(){if(s(!pt.global),0===--this._reculock)for(pt.global||(pt.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(n){}}return this},_locked:function(){return this._reculock&&pt.lockOwnerFor!==this},create:function(n){var t=this;if(s(!this.idbtrans),!n&&!Hn)switch(Gn&&Gn.name){case"DatabaseClosedError":throw new Jn.DatabaseClosed(Gn);case"MissingAPIError":throw new Jn.MissingAPI(Gn.message,Gn);default:throw new Jn.OpenFailed(Gn)}if(!this.active)throw new Jn.TransactionInactive;return s(null===this._completion._state),n=this.idbtrans=n||Hn.transaction(En(this.storeNames),this.mode),n.onerror=rn(function(e){wn(e),t._reject(n.error)}),n.onabort=rn(function(n){wn(n),t.active&&t._reject(new Jn.Abort),t.active=!1,t.on("abort").fire(n)}),n.oncomplete=rn(function(){t.active=!1,t._resolve()}),this},_promise:function(n,t,e){var r=this;return on(function(){var i;return r._locked()?i=new q(function(i,o){r._blockedFuncs.push(function(){r._promise(n,t,e).then(i,o)})}):(i=r.active?new q(function(i,o){if(n===Xn&&r.mode!==Xn)throw new Jn.ReadOnly("Transaction is readonly");!r.idbtrans&&n&&r.create(),e&&r._lock(),t(i,o,r)}):wt(new Jn.TransactionInactive),r.active&&e&&i.finally(function(){r._unlock()})),i._lib=!0,i})},abort:function(){
this.active&&this._reject(new Jn.Abort),this.active=!1},tables:{get:E("Transaction.tables",function(){return Wn})},table:E("Transaction.table()",function(n){return Wn[n]})}),e(G.prototype,function(){function n(n,t,e){var r=n instanceof G?new J(n):n;return r._ctx.error=e?new e(t):new TypeError(t),r}function t(n){return new J(n,function(){return Un.only("")}).limit(0)}function e(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function r(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function i(n,t,e,r,i,o){for(var u=Math.min(n.length,r.length),a=-1,c=0;c<u;++c){var s=t[c];if(s!==r[c])return i(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):i(n[c],r[c])<0?n.substr(0,c)+r[c]+e.substr(c+1):a>=0?n.substr(0,a)+t[a]+e.substr(a+1):null;i(n[c],s)<0&&(a=c)}return u<r.length&&"next"===o?n+e.substr(n.length):u<n.length&&"prev"===o?n.substr(0,e.length):a<0?null:n.substr(0,a)+r[a]+e.substr(a+1)}function o(t,o,u,a){function c(n){s=e(n),f=r(n),l="next"===n?sn:fn;var t=u.map(function(n){return{lower:f(n),upper:s(n)}}).sort(function(n,t){return l(n.lower,t.lower)});h=t.map(function(n){return n.upper}),d=t.map(function(n){return n.lower}),v=n,p="next"===n?"":a}var s,f,l,h,d,v,p,y=u.length;if(!u.every(function(n){return"string"==typeof n}))return n(t,Et);c("next");var m=new J(t,function(){return Un.bound(h[0],d[y-1]+a)});m._ondirectionchange=function(n){c(n)};var g=0;return m._addAlgorithm(function(n,t,e){var r=n.key;if("string"!=typeof r)return!1;var u=f(r);if(o(u,d,g))return!0;for(var a=null,c=g;c<y;++c){var s=i(r,u,h[c],d[c],l,v);null===s&&null===a?g=c+1:(null===a||l(a,s)>0)&&(a=s)}return t(null!==a?function(){n.continue(a+p)}:e),!1}),m}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return tn(e,r)>0||0===tn(e,r)&&(i||o)&&(!i||!o)?t(this):new J(this,function(){return Un.bound(e,r,!i,!o)})}catch(t){return n(this,Pt)}},equals:function(n){return new J(this,function(){return Un.only(n)})},above:function(n){return new J(this,function(){return Un.lowerBound(n,!0)})},aboveOrEqual:function(n){return new J(this,function(){return Un.lowerBound(n)})},below:function(n){return new J(this,function(){return Un.upperBound(n,!0)})},belowOrEqual:function(n){return new J(this,function(){return Un.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,Et):this.between(t,t+kt,!0,!0)},startsWithIgnoreCase:function(n){return""===n?this.startsWith(n):o(this,function(n,t){return 0===n.indexOf(t[0])},[n],kt)},equalsIgnoreCase:function(n){return o(this,function(n,t){return n===t[0]},[n],"")},anyOfIgnoreCase:function(){var n=w.apply(Nn,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.indexOf(n)!==-1},n,"")},startsWithAnyOfIgnoreCase:function(){var n=w.apply(Nn,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},n,kt)},anyOf:function(){var e=w.apply(Nn,arguments),r=an;try{e.sort(r)}catch(t){return n(this,Pt)}if(0===e.length)return t(this);var i=new J(this,function(){return Un.bound(e[0],e[e.length-1])});i._ondirectionchange=function(n){r="next"===n?an:cn,e.sort(r)};var o=0;return i._addAlgorithm(function(n,t,i){for(var u=n.key;r(u,e[o])>0;)if(++o,o===e.length)return t(i),!1;return 0===r(u,e[o])||(t(function(){n.continue(e[o])}),!1)}),i},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,xt]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=w.apply(Nn,arguments);if(0===t.length)return new J(this);try{t.sort(an)}catch(t){return n(this,Pt)}var e=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return e.push([t[t.length-1],xt]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(n,t){for(var e=0,r=n.length;e<r;++e){var i=n[e];if(tn(t[0],i[1])<0&&tn(t[1],i[0])>0){i[0]=en(i[0],t[0]),i[1]=un(i[1],t[1]);break}}return e===r&&n.push(t),n}function o(n,t){return f(n[0],t[0])}function u(n){return!h(n)&&!d(n)}if(0===e.length)return t(this);if(!e.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&an(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",Jn.InvalidArgument);var a,c=!r||r.includeLowers!==!1,s=r&&r.includeUppers===!0,f=an;try{a=e.reduce(i,[]),a.sort(o)}catch(t){return n(this,Pt)}var l=0,h=s?function(n){return an(n,a[l][1])>0}:function(n){return an(n,a[l][1])>=0},d=c?function(n){return cn(n,a[l][0])>0}:function(n){return cn(n,a[l][0])>=0},v=h,p=new J(this,function(){return Un.bound(a[0][0],a[a.length-1][1],!c,!s)});return p._ondirectionchange=function(n){"next"===n?(v=h,f=an):(v=d,f=cn),a.sort(o)},p._addAlgorithm(function(n,t,e){for(var r=n.key;v(r);)if(++l,l===a.length)return t(e),!1;return!!u(r)||0!==tn(r,a[l][1])&&0!==tn(r,a[l][0])&&(t(function(){f===an?n.continue(a[l][0]):n.continue(a[l][1])}),!1)}),p},startsWithAnyOf:function(){var e=w.apply(Nn,arguments);return e.every(function(n){return"string"==typeof n})?0===e.length?t(this):this.inAnyRange(e.map(function(n){return[n,n+kt]})):n(this,"startsWithAnyOf() only works with strings")}}}),e(J.prototype,function(){function e(n,t){n.filter=ln(n.filter,t)}function r(n,t,e){var r=n.replayFilter;n.replayFilter=r?function(){return ln(r(),t())}:t,n.justLimit=e&&!r}function i(n,t){n.isMatch=ln(n.isMatch,t)}function o(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new Jn.Schema("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return t.index(e.name)}function u(n,t){var e=o(n,t);return n.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(n.range||null,n.dir+n.unique):e.openCursor(n.range||null,n.dir+n.unique)}function a(n,e,r,i,o){var a=n.replayFilter?ln(n.filter,n.replayFilter()):n.filter;n.or?function(){function c(){2===++l&&r()}function s(n,r,o){if(!a||a(r,o,c,i)){var u=r.primaryKey.toString();t(f,u)||(f[u]=!0,e(n,r,o))}}var f={},l=0;n.or._iterate(s,c,i,o),Z(u(n,o),n.algorithm,s,c,i,!n.keysOnly&&n.valueMapper)}():Z(u(n,o),ln(n.algorithm,a),e,r,i,!n.keysOnly&&n.valueMapper)}function c(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($n,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(Xn,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=ln(t.algorithm,n)},_iterate:function(n,t,e,r){return a(this._ctx,n,t,e,r)},clone:function(t){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&n(r,t),e._ctx=r,e},raw:function(){return this._ctx.valueMapper=null,this},each:function(n){var t=this._ctx;if(Kt){var e=c(t),r=t.table.schema.primKey.keyPath,i=v(e,t.index?t.table.schema.idxByName[t.index].keyPath:r),o=v(e,r);n(e,{key:i,primaryKey:o})}return this._read(function(e,r,i){a(t,n,e,r,i)})},count:function(n){if(Kt)return q.resolve(0).then(n);var t=this._ctx;if(Q(t,!0))return this._read(function(n,e,r){var i=o(t,r),u=t.range?i.count(t.range):i.count();u.onerror=gn(e),u.onsuccess=function(e){n(Math.min(e.target.result,t.limit))}},n);var e=0;return this._read(function(n,r,i){a(t,function(){return++e,!1},function(){n(e)},r,i)},n)},sortBy:function(n,t){function e(n,t){return t?e(n[i[t]],t-1):n[o]}function r(n,t){var r=e(n,u),i=e(t,u);return r<i?-a:r>i?a:0}var i=n.split(".").reverse(),o=i[0],u=i.length-1,a="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){if(Kt&&n([c(t)]),Tn&&"next"===t.dir&&Q(t,!0)&&t.limit>0){var i=t.table.hook.reading.fire,u=o(t,r),s=t.limit<1/0?u.getAll(t.range,t.limit):u.getAll(t.range);s.onerror=gn(e),s.onsuccess=i===K?yn(n):rn(yn(function(t){n(t.map(i))}))}else{var f=[];a(t,function(n){f.push(n)},function(){n(f)},e,r)}},n)},offset:function(n){var t=this._ctx;return n<=0?this:(t.offset+=n,Q(t)?r(t,function(){var t=n;return function(n,e){return 0===t||(1===t?(--t,!1):(e(function(){n.advance(t),t=0}),!1))}}):r(t,function(){var t=n;return function(){return--t<0}}),this)},limit:function(n){return this._ctx.limit=Math.min(this._ctx.limit,n),r(this._ctx,function(){var t=n;return function(n,e,r){return--t<=0&&e(r),t>=0}},!0),this},until:function(n,t){var r=this._ctx;return Kt&&n(c(r)),e(this._ctx,function(e,r,i){return!n(e.value)||(r(i),t)}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},filter:function(n){return Kt&&n(c(this._ctx)),e(this._ctx,function(t){return n(t.value)}),i(this._ctx,n),this},and:function(n){return this.filter(n)},or:function(n){return new G(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 t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.key,e)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},eachPrimaryKey:function(n){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.primaryKey,e)})},keys:function(n){var t=this._ctx;t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.key)}).then(function(){return e}).then(n)},primaryKeys:function(n){var t=this._ctx;if(Tn&&"next"===t.dir&&Q(t,!0)&&t.limit>0)return this._read(function(n,e,r){var i=o(t,r),u=t.limit<1/0?i.getAllKeys(t.range,t.limit):i.getAllKeys(t.range);u.onerror=gn(e),u.onsuccess=yn(n)}).then(n);t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.primaryKey)}).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 n=this._ctx,r=n.index&&n.table.schema.idxByName[n.index];if(!r||!r.multi)return this;var i={};return e(this._ctx,function(n){var e=n.primaryKey.toString(),r=t(i,e);return i[e]=!0,!r}),this},modify:function(e){var r=this,i=this._ctx,o=i.table.hook,u=o.updating.fire,a=o.deleting.fire;return Kt&&"function"==typeof e&&e.call({value:i.table.schema.instanceTemplate},i.table.schema.instanceTemplate),this._write(function(i,o,c,s){function f(n,e){function r(n){return j.push(n),A.push(i.primKey),h(),!0}D=e.primaryKey;var i={primKey:e.primaryKey,value:n,onsuccess:null,onerror:null};if(y.call(i,n,i)!==!1){var o=!t(i,"value");++x,d(function(){var n=o?e.delete():e.update(i.value);n._hookCtx=i,n.onerror=bn(r),n.onsuccess=mn(function(){++P,h()})},r)}else i.onsuccess&&i.onsuccess(i.value)}function l(n){return n&&(j.push(n),A.push(D)),o(new O("Error modifying one or more objects",j,P,A))}function h(){E&&P+j.length===x&&(j.length>0?l():i(P))}var y;if("function"==typeof e)y=u===S&&a===S?e:function(n){var r=g(n);if(e.call(this,n,this)===!1)return!1;if(t(this,"value")){var i=b(r,this.value),o=u.call(this,i,this.primKey,r,s);o&&(n=this.value,An(o).forEach(function(t){p(n,t,o[t])}))}else a.call(this,this.primKey,n,s)};else if(u===S){var w=An(e),_=w.length;y=function(n){for(var t=!1,r=0;r<_;++r){var i=w[r],o=e[i];v(n,i)!==o&&(p(n,i,o),t=!0)}return t}}else{var k=e;e=m(k),y=function(t){var r=!1,i=u.call(this,e,this.primKey,g(t),s);return i&&n(e,i),An(e).forEach(function(n){var i=e[n];v(t,n)!==i&&(p(t,n,i),r=!0)}),i&&(e=m(k)),r}}var x=0,P=0,E=!1,j=[],A=[],D=null;r.clone().raw()._iterate(f,function(){E=!0,h()},l,c)})},delete:function(){var n=this,t=this._ctx,e=t.range,r=t.table.hook.deleting.fire,i=r!==S;if(!i&&Q(t)&&(t.isPrimKey&&!Dt||!e))return this._write(function(n,t,r){var i=gn(t),o=e?r.count(e):r.count();o.onerror=i,o.onsuccess=function(){var u=o.result;d(function(){var t=e?r.delete(e):r.clear();t.onerror=i,t.onsuccess=function(){return n(u)}},function(n){return t(n)})}});var o=i?2e3:1e4;return this._write(function(e,u,a,c){var s=0,f=n.clone({keysOnly:!t.isMatch&&!i}).distinct().limit(o).raw(),l=[],h=function(){return f.each(i?function(n,t){l.push([t.primaryKey,t.value])}:function(n,t){l.push(t.primaryKey)}).then(function(){return i?l.sort(function(n,t){return an(n[0],t[0])}):l.sort(an),W(a,c,l,i,r)}).then(function(){var n=l.length;return s+=n,l=[],n<o?s:h()})};e(h())})}}}),n(this,{Collection:J,Table:V,Transaction:H,Version:y,WhereClause:G}),f(),Mn.forEach(function(n){n(Zn)})}function vn(n){if("function"==typeof n)return new n;if(On(n))return[vn(n[0])];if(n&&"object"==typeof n){var t={};return pn(t,n),t}return n}function pn(n,t){return An(t).forEach(function(e){var r=vn(t[e]);n[e]=r}),n}function yn(n){return function(t){n(t.target.result)}}function mn(n){return rn(function(t){var e=t.target,r=e.result,i=e._hookCtx,o=i&&i.onsuccess;o&&o(r),n&&n(r)},n)}function gn(n){return function(t){return wn(t),n(t.target.error),!1}}function bn(n){return rn(function(t){var e=t.target,r=e.error,i=e._hookCtx,o=i&&i.onerror;return o&&o(r),wn(t),n(r),!1})}function wn(n){n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault()}function _n(n){var t,e=dn.dependencies.localStorage;if(!e)return n([]);try{t=JSON.parse(e.getItem("Dexie.DatabaseNames")||"[]")}catch(n){t=[]}n(t)&&e.setItem("Dexie.DatabaseNames",JSON.stringify(t))}function kn(n){function t(n){return function(t){var e=n(t),r=e.value;return e.done?r:r&&"function"==typeof r.then?r.then(i,o):On(r)?q.all(r).then(i,o):i(r)}}var e=function(t){return n.next(t)},r=function(t){return n.throw(t)},i=t(e),o=t(r);return t(e)()}function xn(n,t,e,r,i,o,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=i,this.compound=o,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(i?"++":"")+a}function Pn(n,t,e,r){this.name=n,this.primKey=t||new xn,this.indexes=e||[new xn],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=l(e,function(n){return[n.name,n]})}function En(n){return 1===n.length?n[0]:n}function jn(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var An=Object.keys,On=Array.isArray,Dn="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,In=Object.getPrototypeOf,Sn={}.hasOwnProperty,Kn=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Cn=[].slice,Bn="undefined"!=typeof Symbol&&Symbol.iterator,Mn=Bn?function(n){var t;return null!=n&&(t=n[Bn])&&t.apply(n)}:function(){return null},Nn={},Fn=[].concat,Rn="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),qn=function(){return!0},Un=!new Error("").stack,zn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed"],Vn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Ln=zn.concat(Vn),Wn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};i(j).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+P(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i(O).from(j),i(D).from(j);var Hn=Ln.reduce(function(n,t){return n[t]=t+"Error",n},{}),Gn=j,Jn=Ln.reduce(function(n,t){function e(n,e){this._e=x(),this.name=r,n?"string"==typeof n?(this.message=n,this.inner=e||null):"object"==typeof n&&(this.message=n.name+" "+n.message,this.inner=n):(this.message=Wn[t]||r,this.inner=null)}var r=t+"Error";return i(e).from(Gn),n[t]=e,n},{});Jn.Syntax=SyntaxError,Jn.Type=TypeError,Jn.Range=RangeError;var Qn=Vn.reduce(function(n,t){return n[t+"Error"]=Jn[t],n},{}),Yn=Ln.reduce(function(n,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(n[t+"Error"]=Jn[t]),n},{});Yn.ModifyError=O,Yn.DexieError=j,Yn.BulkError=D;var $n={},Xn=100,Zn=20,nt=function(){try{return new Function("let p=(async ()=>{})(); return [p, Object.getPrototypeOf(p)];")()}catch(t){var n=Dn.Promise;return[n&&n.resolve(),n&&n.prototype]}}(),tt=nt[0],et=nt[1],rt=Dn.Promise&&Dn.Promise.resolve(),it=et&&et.then,ot=!1,ut=rt?function(){an(vt,function(){rt.then(Q)})}:Dn.setImmediate?setImmediate.bind(null,Q):Dn.MutationObserver?function(){var n=document.createElement("div");new MutationObserver(function(){Q(),n=null}).observe(n,{attributes:!0}),n.setAttribute("i","1")}:function(){setTimeout(Q,0)},at=function(n,t){yt.push([n,t]),st&&(ut(),st=!1)},ct=!0,st=!0,ft=[],lt=[],ht=null,dt=K,vt={global:!0,ref:0,unhandleds:[],onunhandled:ln,pgp:!1,env:{Promise:Dn.Promise,nc:et&&et.constructor,nthen:et&&et.then,gthen:Dn.Promise&&Dn.Promise.prototype.then,dthen:null},finalize:function(){this.unhandleds.forEach(function(n){try{ln(n[0],n[1])}catch(n){}})}},pt=vt,yt=[],mt=0,gt=[];e(q.prototype,{then:function(n,t){var e=this,r=new q(function(r,i){W(e,new U(n,t,r,i,pt))});return Rn&&(!this._prev||null===this._state)&&J(r,this),r},_then:function(n,t){W(this,new U(null,null,n,t,pt))},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):en(n)}):this.then(null,function(n){return n&&n.name===t?e(n):en(n)})},finally:function(n){return this.then(function(t){return n(),t},function(t){return n(),en(t)})},stack:{get:function(){if(this._stack)return this._stack;try{ot=!0;var n=G(this,[],Zn),t=n.join("\nFrom previous: ");return null!==this._state&&(this._stack=t),t}finally{ot=!1}}}}),e(q,{all:function(){var n=w.apply(null,arguments);return new q(function(t,e){0===n.length&&t([]);var r=n.length;n.forEach(function(i,o){return q.resolve(i).then(function(e){n[o]=e,--r||t(n)},e)})})},resolve:function(n){return n instanceof q?n:n&&"function"==typeof n.then?new q(function(t,e){n.then(t,e)}):new q($n,!0,n)},reject:en,race:function(){var n=w.apply(null,arguments);return new q(function(t,e){n.map(function(n){return q.resolve(n).then(t,e)})})},PSD:{get:function(){return pt},set:function(n){return pt=n}},newPSD:on,usePSD:an,scheduler:{get:function(){return at},set:function(n){at=n}},rejectionMapper:{get:function(){return dt},set:function(n){dt=n}},follow:function(n,t){return new q(function(e,r){return on(function(t,e){var r=pt;r.unhandleds=[],r.onunhandled=e,r.finalize=C(function(){var n=this;Z(function(){0===n.unhandleds.length?t():e(n.unhandleds[0])})},r.finalize),n()},t,e,r)})}}),vt.env.dthen=q.prototype.then;var bt="unhandledrejection";c(function(){at=function(n,t){setTimeout(function(){n.apply(null,t)},0)}});var wt=q.reject,_t="2.0.0-beta.2",kt=String.fromCharCode(65535),xt=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return kt}}(),Pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Et="String expected.",jt=[],At="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Ot=At,Dt=At,It=function(n){return!/(dexie\.js|dexie\.min\.js)/.test(n)};k(Rn,It);var St=function(){},Kt=!1,Tt=Dn.idbModules&&Dn.idbModules.shimIndexedDB?Dn.idbModules:{};return e(dn,Yn),e(dn,{delete:function(n){var t=new dn(n),e=t.delete();return e.onblocked=function(n){return t.on("blocked",n),this},e},exists:function(n){return new dn(n).open().then(function(n){return n.close(),!0}).catch(dn.NoSuchDatabaseError,function(){return!1})},getDatabaseNames:function(n){return new q(function(n,t){var e=jn(indexedDB);if(e){var r=e();r.onsuccess=function(t){n(u(t.target.result,0))},r.onerror=gn(t)}else _n(function(t){return n(t),!1})}).then(n)},defineClass:function(t){function e(e){e?n(this,e):Kt&&pn(this,t)}return e},applyStructure:pn,ignoreTransaction:function(n){return pt.trans?an(pt.transless,n):n()},vip:function(n){return on(function(){return pt.letThrough=!0,n()})},async:function(n){return function(){try{var t=kn(n.apply(this,arguments));return t&&"function"==typeof t.then?t:q.resolve(t)}catch(n){return wt(n)}}},spawn:function(n,t,e){try{var r=kn(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:q.resolve(r)}catch(n){return wt(n)}},currentTransaction:{get:function(){return pt.trans||null}},Promise:q,debug:{get:function(){return Rn},set:function(n){k(n,"dexie"===n?function(){return!0}:It)}},derive:i,extend:n,props:e,override:a,Events:hn,getByKeyPath:v,setByKeyPath:p,delByKeyPath:y,shallowClone:m,deepClone:g,getObjectDiff:b,asap:f,maxKey:xt,addons:[],connections:jt,MultiModifyError:Jn.Modify,errnames:Hn,IndexSpec:xn,TableSchema:Pn,dependencies:{indexedDB:Tt.shimIndexedDB||Dn.indexedDB||Dn.mozIndexedDB||Dn.webkitIndexedDB||Dn.msIndexedDB,IDBKeyRange:Tt.IDBKeyRange||Dn.IDBKeyRange||Dn.webkitIDBKeyRange},semVer:_t,version:_t.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),fakeAutoComplete:St,default:dn}),d(function(){dn.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:Dn.localStorage}),q.rejectionMapper=I,c(function(){dn.fakeAutoComplete=St=c,dn.fake=Kt=!0}),dn});
//# sourceMappingURL=dexie.min.js.map
{
"name": "dexie",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "A Minimalistic Wrapper for IndexedDB",

@@ -50,2 +50,4 @@ "main": "dist/dexie.js",

"babel-plugin-transform-es2015-computed-properties": "^6.6.5",
"babel-plugin-transform-es2015-constants": "^6.1.4",
"babel-plugin-transform-es2015-destructuring": "^6.16.0",
"babel-plugin-transform-es2015-literals": "^6.5.0",

@@ -52,0 +54,0 @@ "babel-plugin-transform-es2015-object-super": "^6.6.5",

@@ -121,6 +121,4 @@ // Type definitions for Dexie v{version}

Version: new()=>Dexie.Version;
WriteableTable: new()=>Dexie.Table<any,any>;
Transaction: new()=>Dexie.Transaction;
Collection: new()=>Dexie.Collection<any,any>;
WriteableCollection: new()=>Dexie.Collection<any,any>;
}

@@ -438,3 +436,2 @@

class DatabaseClosedError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}
class IncompatiblePromiseError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}
class UnknownError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}

@@ -441,0 +438,0 @@ class ConstraintError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);}

@@ -18,4 +18,3 @@ import { derive, setProp } from './utils';

'Internal',
'DatabaseClosed',
'IncompatiblePromise'
'DatabaseClosed'
];

@@ -81,3 +80,3 @@

//
// ModifyError - thrown in WriteableCollection.modify()
// ModifyError - thrown in Collection.modify()
// Specific constructor because it contains members failures and failedKeys.

@@ -84,0 +83,0 @@ //

import {doFakeAutoComplete, tryCatch, props,
setProp, _global, getPropertyDescriptor, getArrayOf} from './utils';
import {reverseStoppableEventChain, nop, callBoth, mirror} from './chaining-functions';
import Events from './Events';
setProp, _global, getPropertyDescriptor, getArrayOf, extend} from './utils';
import {nop, callBoth, mirror} from './chaining-functions';
import {debug, prettyStack, getErrorWithStack} from './debug';

@@ -41,8 +40,23 @@

// Async stacks (long stacks) must not grow infinitely.
var LONG_STACKS_CLIP_LIMIT = 100,
const
LONG_STACKS_CLIP_LIMIT = 100,
// When calling error.stack or promise.stack, limit the number of asyncronic stacks to print out.
MAX_LONG_STACKS = 20,
stack_being_generated = false;
nativePromiseInstanceAndProto = (()=>{
try {
// Be able to patch native async functions
return new Function("let p=(async ()=>{})(); return [p, Object.getPrototypeOf(p)];")();
} catch(e) {
var P = _global.Promise;
return [P && P.resolve(), P && P.prototype]; // Support transpiled async functions
}
})(),
resolvedNativePromise = nativePromiseInstanceAndProto[0],
nativePromiseProto = nativePromiseInstanceAndProto[1],
resolvedGlobalPromise = _global.Promise && _global.Promise.resolve(),
nativePromiseThen = nativePromiseProto && nativePromiseProto.then;
var stack_being_generated = false;
/* The default "nextTick" function used only for the very first promise in a promise chain.
/* The default function used only for the very first promise in a promise chain.
As soon as then promise is resolved or rejected, all next tasks will be executed in micro ticks

@@ -52,28 +66,31 @@ emulated in this module. For indexedDB compatibility, this means that every method needs to

db.ready().then() for every operation to make sure the indexedDB event is started in an
emulated micro tick.
indexedDB-compatible emulated micro task loop.
*/
var schedulePhysicalTick = (_global.setImmediate ?
// setImmediate supported. Those modern platforms also supports Function.bind().
setImmediate.bind(null, physicalTick) :
_global.MutationObserver ?
// MutationObserver supported
() => {
var hiddenDiv = document.createElement("div");
(new MutationObserver(() => {
physicalTick();
hiddenDiv = null;
})).observe(hiddenDiv, { attributes: true });
hiddenDiv.setAttribute('i', '1');
} :
// No support for setImmediate or MutationObserver. No worry, setTimeout is only called
// once time. Every tick that follows will be our emulated micro tick.
// Could have uses setTimeout.bind(null, 0, physicalTick) if it wasnt for that FF13 and below has a bug
()=>{setTimeout(physicalTick,0);}
);
var schedulePhysicalTick = resolvedGlobalPromise ?
() => {
usePSD(globalPSD, () => {
resolvedGlobalPromise.then(physicalTick);} ) }:
_global.setImmediate ?
// setImmediate supported. Those modern platforms also supports Function.bind().
setImmediate.bind(null, physicalTick) :
_global.MutationObserver ?
// MutationObserver supported
() => {
var hiddenDiv = document.createElement("div");
(new MutationObserver(() => {
physicalTick();
hiddenDiv = null;
})).observe(hiddenDiv, { attributes: true });
hiddenDiv.setAttribute('i', '1');
} :
// No support for setImmediate or MutationObserver. No worry, setTimeout is only called
// once time. Every tick that follows will be our emulated micro tick.
// Could have uses setTimeout.bind(null, 0, physicalTick) if it wasnt for that FF13 and below has a bug
()=>{setTimeout(physicalTick,0);};
// Confifurable through Promise.scheduler.
// Configurable through Promise.scheduler.
// Don't export because it would be unsafe to let unknown
// code call it unless they do try..catch within their callback.
// This function can be retrieved through getter of Promise.scheduler though,
// but users must not do Promise.scheduler (myFuncThatThrows exception)!
// but users must not do Promise.scheduler = myFuncThatThrowsException
var asap = function (callback, args) {

@@ -85,7 +102,7 @@ microtickQueue.push([callback, args]);

}
}
};
var isOutsideMicroTick = true, // True when NOT in a virtual microTick.
needsNewPhysicalTick = true, // True when a push to microtickQueue must also schedulePhysicalTick()
unhandledErrors = [], // Rejected promises that has occured. Used for firing Promise.on.error and promise.onuncatched.
unhandledErrors = [], // Rejected promises that has occured. Used for triggering 'unhandledrejection'.
rejectingErrors = [], // Tracks if errors are being re-rejected during onRejected callback.

@@ -100,3 +117,10 @@ currentFulfiller = null,

onunhandled: globalError,
//env: null, // Will be set whenever leaving a scope using wrappers.snapshot()
pgp: false,
env: { // Environment globals snapshotted on leaving global zone
Promise: _global.Promise,
nc: nativePromiseProto && nativePromiseProto.constructor,
nthen: nativePromiseProto && nativePromiseProto.then,
gthen: _global.Promise && _global.Promise.prototype.then,
dthen: null // Will be set later on.
},
finalize: function () {

@@ -117,26 +141,2 @@ this.unhandleds.forEach(uh => {

// Wrappers are not being used yet. Their framework is functioning and can be used
// to replace environment during a PSD scope (a.k.a. 'zone').
/* **KEEP** export var wrappers = (() => {
var wrappers = [];
return {
snapshot: () => {
var i = wrappers.length,
result = new Array(i);
while (i--) result[i] = wrappers[i].snapshot();
return result;
},
restore: values => {
var i = wrappers.length;
while (i--) wrappers[i].restore(values[i]);
},
wrap: () => wrappers.map(w => w.wrap()),
add: wrapper => {
wrappers.push(wrapper);
}
};
})();
*/
export default function Promise(fn) {

@@ -185,3 +185,3 @@ if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new');

var rv = new Promise((resolve, reject) => {
propagateToListener(this, new Listener(onFulfilled, onRejected, resolve, reject));
propagateToListener(this, new Listener(onFulfilled, onRejected, resolve, reject, PSD));
});

@@ -191,6 +191,6 @@ debug && (!this._prev || this._state === null) && linkToPreviousPromise(rv, this);

},
_then: function (onFulfilled, onRejected) {
// A little tinier version of then() that don't have to create a resulting promise.
propagateToListener(this, new Listener(null, null, onFulfilled, onRejected));
propagateToListener(this, new Listener(null, null, onFulfilled, onRejected, PSD));
},

@@ -224,18 +224,2 @@

// Deprecate in next major. Needed only for db.on.error.
uncaught: function (uncaughtHandler) {
// Be backward compatible and use "onuncatched" as the event name on this.
// Handle multiple subscribers through reverseStoppableEventChain(). If a handler returns `false`, bubbling stops.
this.onuncatched = reverseStoppableEventChain(this.onuncatched, uncaughtHandler);
// In case caller does this on an already rejected promise, assume caller wants to point out the error to this promise and not
// a previous promise. Reason: the prevous promise may lack onuncatched handler.
if (this._state === false && unhandledErrors.indexOf(this) === -1) {
// Replace unhandled error's destinaion promise with this one!
unhandledErrors.some((p,i,l) => p._value === this._value && (l[i] = this));
// Actually we do this shit because we need to support db.on.error() correctly during db.open(). If we deprecate db.on.error, we could
// take away this piece of code as well as the onuncatched and uncaught() method.
}
return this;
},
stack: {

@@ -257,3 +241,3 @@ get: function() {

function Listener(onFulfilled, onRejected, resolve, reject) {
function Listener(onFulfilled, onRejected, resolve, reject, zone) {
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;

@@ -263,3 +247,3 @@ this.onRejected = typeof onRejected === 'function' ? onRejected : null;

this.reject = reject;
this.psd = PSD;
this.psd = zone;
}

@@ -317,3 +301,3 @@

follow: fn => {
follow: (fn, zoneProps) => {
return new Promise((resolve, reject) => {

@@ -333,11 +317,5 @@ return newScope((resolve, reject) => {

fn();
}, resolve, reject);
}, zoneProps, resolve, reject);
});
},
on: Events(null, {"error": [
reverseStoppableEventChain,
defaultErrorHandler] // Default to defaultErrorHandler
})
}
});

@@ -356,3 +334,3 @@

fn(value => {
if (promise._state !== null) return;
if (promise._state !== null) return; // Already settled
if (value === promise) throw new TypeError('A promise cannot be resolved with itself.');

@@ -436,4 +414,3 @@ var shouldExecuteTick = promise._lib && beginMicroTickScope();

}
var psd = listener.psd;
++psd.ref;
++listener.psd.ref;
++numScheduledCalls;

@@ -444,11 +421,3 @@ asap (callListener, [cb, promise, listener]);

function callListener (cb, promise, listener) {
var outerScope = PSD;
var psd = listener.psd;
try {
if (psd !== outerScope) {
// **KEEP** outerScope.env = wrappers.snapshot(); // Snapshot outerScope's environment.
PSD = psd;
// **KEEP** wrappers.restore(psd.env); // Restore PSD's environment.
}
// Set static variable currentFulfiller to the promise that is being fullfilled,

@@ -459,7 +428,9 @@ // so that we connect the chain of promises (for long stacks support)

// Call callback and resolve our listener with it's return value.
var value = promise._value,
ret;
var ret, value = promise._value;
if (promise._state) {
// cb is onResolved
ret = cb (value);
} else {
// cb is onRejected
if (rejectingErrors.length) rejectingErrors = [];

@@ -475,10 +446,6 @@ ret = cb(value);

} finally {
// Restore PSD, env and currentFulfiller.
if (psd !== outerScope) {
PSD = outerScope;
// **KEEP** wrappers.restore(outerScope.env); // Restore outerScope's environment
}
// Restore env and currentFulfiller.
currentFulfiller = null;
if (--numScheduledCalls === 0) finalizePhysicalTick();
--psd.ref || psd.finalize();
--listener.psd.ref || listener.psd.finalize();
}

@@ -501,3 +468,3 @@ }

errorName = failure; // If error is undefined or null, show that.
message = ""
message = "";
}

@@ -606,7 +573,2 @@ stacks.push(errorName + (message ? ": " + message : "") + stack);

// By default, log uncaught errors to the console
function defaultErrorHandler(e) {
console.warn(`Unhandled rejection: ${e.stack || e}`);
}
function PromiseReject (reason) {

@@ -616,2 +578,3 @@ return new Promise(INTERNAL, false, reason);

export function wrap (fn, errorCatcher) {

@@ -624,7 +587,3 @@ var psd = PSD;

try {
if (outerScope !== psd) {
// **KEEP** outerScope.env = wrappers.snapshot(); // Snapshot outerScope's environment
PSD = psd;
// **KEEP** wrappers.restore(psd.env); // Restore PSD's environment.
}
switchToZone(psd);
return fn.apply(this, arguments);

@@ -634,6 +593,3 @@ } catch (e) {

} finally {
if (outerScope !== psd) {
PSD = outerScope;
// **KEEP** wrappers.restore(outerScope.env); // Restore outerScope's environment
}
switchToZone(outerScope);
if (wasRootExec) endMicroTickScope();

@@ -643,4 +599,7 @@ }

}
globalPSD.env.dthen = Promise.prototype.then;
export function newScope (fn, a1, a2, a3) {
export function newScope (fn, props, a1, a2) {
var parent = PSD,

@@ -651,3 +610,14 @@ psd = Object.create(parent);

psd.global = false;
// **KEEP** psd.env = wrappers.wrap(psd);
// Prepare for promise patching (done in usePSD):
var globalEnv = globalPSD.env;
psd.env = nativePromiseThen ? {
Promise: Promise, // Changing window.Promise could be omitted for Chrome and Edge, where IDB+Promise plays well!
nc: Promise,
nthen: getPatchedPromiseThen (globalEnv.nthen, psd), // native then
gthen: getPatchedPromiseThen (globalEnv.gthen, psd), // global then
dthen: getPatchedPromiseThen (globalEnv.dthen, psd) // dexie then
} : {
dthen: getPatchedPromiseThen (globalEnv.dthen, psd)
};
if (props) extend(psd, props);

@@ -662,3 +632,3 @@ // unhandleds and onunhandled should not be specifically set here.

}
var rv = usePSD (psd, fn, a1, a2, a3);
var rv = usePSD (psd, fn, a1, a2);
if (psd.ref === 0) psd.finalize();

@@ -668,19 +638,97 @@ return rv;

function switchToZone (targetZone) {
if (targetZone === PSD) return;
var currentZone = PSD;
PSD = targetZone;
// Snapshot on every leave from global zone.
if (currentZone === globalPSD && ('Promise' in _global)) {
var globalEnv = globalPSD.env;
globalEnv.Promise = _global.Promise; // Changing window.Promise could be omitted for Chrome and Edge, where IDB+Promise plays well!
globalEnv.nc = nativePromiseProto.constructor;
globalEnv.nthen = nativePromiseProto.then;
globalEnv.gthen = _global.Promise.prototype.then;
globalEnv.dthen = Promise.prototype.then;
}
// Patch our own Promise to keep zones in it:
Promise.prototype.then = targetZone.env.dthen;
if (('Promise' in _global)) {
// Swich environments
// Set this Promise to window.Promise so that Typescript 2.0's async functions will work on Firefox, Safari and IE, as well as with Zonejs and angular.
_global.Promise = targetZone.env.Promise;
// Make native async functions work according to their standard specification but invoke our zones
// (https://github.com/tc39/ecmascript-asyncawait/issues/65)
nativePromiseProto.then = targetZone.env.nthen;
// Also override constructor (https://github.com/tc39/ecmascript-asyncawait/issues/65#issuecomment-145250337)
nativePromiseProto.constructor = targetZone.env.nc;
// Also patch the global Promise in case it differs from native Promise (must work with transpilers and polyfills)
globalPSD.env.Promise.prototype.then = targetZone.env.gthen;
}
}
export function usePSD (psd, fn, a1, a2, a3) {
var outerScope = PSD;
try {
if (psd !== outerScope) {
// **KEEP** outerScope.env = wrappers.snapshot(); // snapshot outerScope's environment.
PSD = psd;
// **KEEP** wrappers.restore(psd.env); // Restore PSD's environment.
}
switchToZone(psd);
return fn(a1, a2, a3);
} finally {
if (psd !== outerScope) {
PSD = outerScope;
// **KEEP** wrappers.restore(outerScope.env); // Restore outerScope's environment.
}
switchToZone(outerScope);
}
}
function enqueueNativeMicroTask (job) {
//
// Precondition: nativePromiseThen !== undefined
//
nativePromiseThen.call(resolvedNativePromise, job);
}
function nativeAwaitCompatibleWrap(fn, zone, possibleAwait) {
return typeof fn !== 'function' ? fn : function () {
var outerZone = PSD;
switchToZone(zone);
if (possibleAwait) {
// Before calling fn (which is onResolved or onRejected),
// enque a zone injector onto the Micro Task queue, because when fn() is executed,
// it will call resolvingFunctions.[[Resolve]] or resolvingFunctions.[[Reject]] as
// specified in ES2015, PromiseResolveThenableJob http://www.ecma-international.org/ecma-262/6.0/#sec-promiseresolvethenablejob
// Thos [[Resolve]] and [[Reject]] internal slots will in its turn enqueue its internal
// onResolved or onRejected callbacks on the "PromiseJobs" queue. We must enque a zone-
// invoker and zone-resetter before and after the native queue record.
++zone.ref;
enqueueNativeMicroTask(()=>{
switchToZone(zone);
});
}
try {
return fn.apply(this, arguments);
} finally {
switchToZone(outerZone);
if (possibleAwait) {
enqueueNativeMicroTask(()=>{
switchToZone(globalPSD);
--zone.ref || zone.finalize(); // if ref reaches zero, call finalize();
});
}
}
};
}
function getPatchedPromiseThen (origThen, zone) {
return function (onResolved, onRejected) {
var possibleAwait = (zone !== PSD) && !!nativePromiseThen;
return origThen.call(this,
nativeAwaitCompatibleWrap(onResolved, zone, possibleAwait),
nativeAwaitCompatibleWrap(onRejected, zone, possibleAwait));
};
}
const UNHANDLEDREJECTION = "unhandledrejection";
function globalError(err, promise) {

@@ -692,59 +740,23 @@ var rv;

if (rv !== false) try {
Promise.on.error.fire(err, promise); // TODO: Deprecated and use same global handler as bluebird.
var event, eventData = {promise: promise, reason: err};
if (_global.document && document.createEvent) {
event = document.createEvent('Event');
event.initEvent(UNHANDLEDREJECTION, true, true);
extend(event, eventData);
} else if (_global.CustomEvent) {
event = new CustomEvent(UNHANDLEDREJECTION, {detail: eventData});
extend(event, eventData);
}
if (event && _global.dispatchEvent) {
dispatchEvent(event);
if (!_global.PromiseRejectionEvent && _global.onunhandledrejection)
// No native support for PromiseRejectionEvent but user has set window.onunhandledrejection. Manually call it.
try {_global.onunhandledrejection(event);} catch (_) {}
}
if (!event.defaultPrevented) {
console.warn(`Unhandled rejection: ${err.stack || err}`);
}
} catch (e) {}
}
/* **KEEP**
export function wrapPromise(PromiseClass) {
var proto = PromiseClass.prototype;
var origThen = proto.then;
wrappers.add({
snapshot: () => proto.then,
restore: value => {proto.then = value;},
wrap: () => patchedThen
});
function patchedThen (onFulfilled, onRejected) {
var promise = this;
var onFulfilledProxy = wrap(function(value){
var rv = value;
if (onFulfilled) {
rv = onFulfilled(rv);
if (rv && typeof rv.then === 'function') rv.then(); // Intercept that promise as well.
}
--PSD.ref || PSD.finalize();
return rv;
});
var onRejectedProxy = wrap(function(err){
promise._$err = err;
var unhandleds = PSD.unhandleds;
var idx = unhandleds.length,
rv;
while (idx--) if (unhandleds[idx]._$err === err) break;
if (onRejected) {
if (idx !== -1) unhandleds.splice(idx, 1); // Mark as handled.
rv = onRejected(err);
if (rv && typeof rv.then === 'function') rv.then(); // Intercept that promise as well.
} else {
if (idx === -1) unhandleds.push(promise);
rv = PromiseClass.reject(err);
rv._$nointercept = true; // Prohibit eternal loop.
}
--PSD.ref || PSD.finalize();
return rv;
});
if (this._$nointercept) return origThen.apply(this, arguments);
++PSD.ref;
return origThen.call(this, onFulfilledProxy, onRejectedProxy);
}
}
// Global Promise wrapper
if (_global.Promise) wrapPromise(_global.Promise);
*/
doFakeAutoComplete(() => {

@@ -756,1 +768,3 @@ // Simplify the job for VS Intellisense. This piece of code is one of the keys to the new marvellous intellisense support in Dexie.

});
export var rejection = Promise.reject;

@@ -39,4 +39,6 @@ /*

export const defineProperty = Object.defineProperty;
export function setProp(obj, prop, functionOrGetSet, options) {
Object.defineProperty(obj, prop, extend(functionOrGetSet && hasOwn(functionOrGetSet, "get") && typeof functionOrGetSet.get === 'function' ?
defineProperty(obj, prop, extend(functionOrGetSet && hasOwn(functionOrGetSet, "get") && typeof functionOrGetSet.get === 'function' ?
{get: functionOrGetSet.get, set: functionOrGetSet.set, configurable: true} :

@@ -43,0 +45,0 @@ {value: functionOrGetSet, configurable: true, writable: true}, options));

@@ -121,3 +121,3 @@ import Dexie from 'dexie';

.catch(e => ok(false, e.stack || e))
.finally(start);
.then(start);
});

@@ -128,5 +128,5 @@ } else {

.catch(e => ok(false, e.stack || e))
.finally(start);
.then(start);
});
}
}

@@ -16,2 +16,9 @@ module.exports = function(config) {

cfg.customLaunchers = {
bs_firefox_latest: {
base: 'BrowserStack',
browser: 'firefox',
browser_version: 'latest',
os: 'Windows',
os_version: 7
},
bs_firefox: {

@@ -31,2 +38,9 @@ base: 'BrowserStack',

},
bs_ie11: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '11',
os: 'Windows',
os_version: 7
},
bs_chrome: {

@@ -38,2 +52,9 @@ base: 'BrowserStack',

os_version: 'Mountain Lion'
},
bs_chrome_latest: {
base: 'BrowserStack',
browser: "Chrome",
browser_version: "latest",
os: 'Windows',
os_version: 10
}

@@ -44,4 +65,7 @@ };

'bs_chrome',
'bs_chrome_latest',
'bs_firefox',
'bs_edge'
'bs_firefox_latest',
'bs_edge',
'bs_ie11'
];

@@ -48,0 +72,0 @@

@@ -26,6 +26,14 @@ module.exports = function(config) {

},
bs_ie11: {
base: 'BrowserStack',
browser: 'ie',
browser_version: '11',
os: 'Windows',
os_version: 7
}
};
cfg.browsers = !useBrowserStack ? ['Firefox'] : [
'bs_firefox'
'bs_firefox',
'bs_ie11'
];

@@ -32,0 +40,0 @@

@@ -10,2 +10,3 @@ import "./tests-crud-hooks";

import "./tests-transaction.js";
import "./tests-asyncawait.js";
import "./tests-open.js";

@@ -12,0 +13,0 @@ import "./tests-exception-handling.js";

@@ -11,6 +11,2 @@ import Dexie from 'dexie';

});
function dbOnErrorHandler (e) {
ok(false, "An error bubbled out to the db.on('error'). Should not happen because all tests should catch their errors themselves. " + e);
}
db.on("error", dbOnErrorHandler);

@@ -28,15 +24,15 @@ module("exception-handling", {

asyncTest("Uncaught promise should signal to Promise.on('error')", function(){
asyncTest("Uncaught promise should signal 'unhandledrejection'", function(){
// We must not use finally or catch here because then we don't test what we should.
var onErrorSignals = 0;
function onerror(e) {
function onerror(ev) {
++onErrorSignals;
ev.preventDefault();
}
Dexie.Promise.on('error', onerror);
db.on('error').unsubscribe(dbOnErrorHandler);
var prevUnhandledRejection = window.onunhandledrejection;
window.onunhandledrejection = onerror;
db.users.add({ id: 1 });
setTimeout(()=> {
equal(onErrorSignals, 1, "Promise.on('error') should have been signaled");
db.on("error", dbOnErrorHandler);
Dexie.Promise.on('error').unsubscribe(onerror);
equal(onErrorSignals, 1, "unhandledrejection should have been signaled");
window.onunhandledrejection = prevUnhandledRejection;
start();

@@ -255,101 +251,2 @@ }, 100);

asyncTest("catch-all with db.on('error')", 6, function () {
if (typeof idbModules !== 'undefined' && Dexie.dependencies.indexedDB === idbModules.shimIndexedDB) {
// Using indexedDBShim.
ok(false, "This test would hang with IndexedDBShim as of 2015-05-07");
start();
return;
}
var ourDB = new Dexie("TestDB2");
ourDB.version(1).stores({ users: "++id,first,last,&username,&*email,*pets" });
ourDB.on("populate", function () {
ourDB.users.add({ first: "Daniel", last: "Fahlenius", username: "dfahlenius", email: ["david@awarica.com", "daw@thridi.com"], pets: ["dog"] });
ourDB.users.add({ first: "Carl", last: "Cedersköld", username: "cceder", email: ["karl@ceder.what"], pets: [] });
});
var errorCount = 0;
ourDB.on("error", function (e) {
ok(errorCount < 5, "Uncatched error successfully bubbled to ourDB.on('error'): " + e.stack);
if (++errorCount == 5) {
ourDB.delete().then(()=>{
Dexie.Promise.on('error').unsubscribe(swallowPromiseOnError);
start();
});
}
});
function swallowPromiseOnError(e){
return false;
}
Dexie.Promise.on('error', swallowPromiseOnError); // Just to get rid of default error logs for not catching.
ourDB.delete()
.then(()=>ourDB.open())
.then(()=>{
ourDB.transaction("rw", ourDB.users, function () {
ourDB.users.add({ username: "dfahlenius" }).then(function () {
ok(false, "Should not be able to add two users with same username");
});
}).then(function () {
ok(false, "Transaction should not complete since errors wasnt catched");
});
ourDB.transaction("rw", ourDB.users, function () {
ourDB.users.add({ username: "dfahlenius" }).then(function () {
ok(false, "Should not be able to add two users with same username");
});
}).then(function () {
ok(false, "Transaction should not complete since errors wasnt catched");
});
ourDB.transaction("rw", ourDB.users, function () {
ourDB.users.add({ id: {} }).then(function () {
ok(false, "Should not be able to add user with faulty key");
});
}).then(function () {
ok(false, "Transaction should not complete since errors wasnt catched");
}).catch(err => {
ok(true, "Got error: " + err.stack);
return Dexie.Promise.reject(err); // Returning failed promise to bubble to db.on.error.
})
// And outside transactions:
ourDB.users.add({ username: "dfahlenius" }).then(function () {
ok(false, "Should not be able to add two users with same username");
});
ourDB.users.add({ id: {} }).then(function () {
ok(false, "Should not be able to add user with faulty key");
});
});
});
asyncTest("Issue #32: db.on('error') doesnt catch 'not found index' DOMExceptions", function () {
var ourDB = new Dexie("TestDB2");
new Dexie.Promise(function (finalResolve) {
ourDB.version(1).stores({ users: "++id" });
ourDB.on("populate", function() {
db.users.add({ id: 100, first: "David", last: "Fahlander" });
});
var errorHasBubbled = false;
ourDB.on("error", function(e) {
errorHasBubbled = true;
ok(true, "Uncatched error successfully bubbled to db.on('error'): " + e);
finalResolve();
});
ourDB.open().then(function () {
// Make the db fail by not finding a correct index:
ourDB.users.where("I am a little frog!").equals(18).toArray();
setTimeout(function() {
if (!errorHasBubbled) {
ok(false, "Timeout! Error never bubbled to db.on('error')");
}
finalResolve();
}, 300);
});
}).then(function() {
ourDB.delete().then(start);
});
});
asyncTest("Error in on('populate') should abort database creation", function () {

@@ -502,9 +399,10 @@ var popufail = new Dexie("PopufailDB");

var errorList = [];
function globalRejectionHandler(e) {
console.log("Got error: " + e);
if (errorList.indexOf(e) === -1) // Current implementation: accept multiple redundant triggers
errorList.push(e);
function globalRejectionHandler(ev) {
console.log("Got error: " + ev.reason);
if (errorList.indexOf(ev.reason) === -1) // Current implementation: accept multiple redundant triggers
errorList.push(ev.reason);
ev.preventDefault();
}
Dexie.Promise.on("error", globalRejectionHandler);
window.addEventListener('unhandledrejection', globalRejectionHandler);

@@ -543,5 +441,8 @@ // The most simple case: Any Promise reject that is not catched should

// With finally, it should yet trigger the global event:
new Dexie.Promise(function(resolve, reject) {
reject("forth error (uncatched but with finally)");
Dexie.Promise.resolve(Promise.reject(new Error("Converting a rejected standard promise to Dexie.Promise but don't catch it")))
.finally(()=>{
// With finally, it should yet trigger the global event:
return new Dexie.Promise(function(resolve, reject) {
reject("forth error (uncatched but with finally)");
});
}).finally(function() {

@@ -554,7 +455,2 @@ // From issue #43:

db.version(1).stores({ table1: "id" });
db.on('error', function(err) {
// Global 'db' error handler (will never be called 'cause the error is not in a transaction)
console.log("db.on.error: " + err);
errorList.push("Got db.on.error: " + err);
});
db.open().then(function() {

@@ -566,10 +462,11 @@ console.log("before");

db.delete().finally(function() {
equal(errorList.length, 5, "THere should be 4 global errors triggered");
equal(errorList.length, 6, "THere should be 6 global errors triggered");
equal(errorList[0], "first error (by reject)", "first error (by reject)");
equal(errorList[1], "second error (throw)", "second error (throw)");
equal(errorList[2], "Simple error 1", "Simple error 1");
equal(errorList[3], "forth error (uncatched but with finally)", "forth error (uncatched but with finally)");
equal(errorList[4], "FOO", "FOO");
equal(errorList[3].message, "Converting a rejected standard promise to Dexie.Promise but don't catch it", "Converting a rejected standard promise to Dexie.Promise but don't catch it");
equal(errorList[4], "forth error (uncatched but with finally)", "forth error (uncatched but with finally)");
equal(errorList[5], "FOO", "FOO");
// cleanup:
Dexie.Promise.on("error").unsubscribe(globalRejectionHandler);
window.removeEventListener('unhandledrejection', globalRejectionHandler);
start();

@@ -576,0 +473,0 @@ });

@@ -259,3 +259,3 @@ import Dexie from 'dexie';

ok(true, "Could open the database");
return db.transaction('rw', db.table1, function() {

@@ -262,0 +262,0 @@ ok(true, "Could create a transaction");

import Dexie from 'dexie';
import {module, stop, start, asyncTest, equal, ok} from 'QUnit';
import {spawnedTest} from './dexie-unittest-utils';

@@ -132,9 +133,10 @@ module("promise");

asyncTest("Promise.on.error should propagate once", 1, function(){
asyncTest("onunhandledrejection should propagate once", 1, function(){
var Promise = Dexie.Promise;
function logErr (e) {
ok(true, e);
function logErr (ev) {
ok(true, ev.reason);
return false;
}
Promise.on('error', logErr);
window.addEventListener('unhandledrejection', logErr);
var p = new Promise((resolve, reject)=>{

@@ -156,3 +158,3 @@ reject("apa");

setTimeout(()=>{
Promise.on('error').unsubscribe(logErr);
window.removeEventListener('unhandledrejection', logErr);
start();

@@ -163,8 +165,8 @@ }, 1);

asyncTest("Promise.on.error should not propagate if catched after finally", 1, function(){
asyncTest("onunhandledrejection should not propagate if catched after finally", 1, function(){
var Promise = Dexie.Promise;
function logErr (e) {
ok(false, "Should already be catched:" + e);
function logErr (ev) {
ok(false, "Should already be catched:" + ev.reason);
}
Promise.on('error', logErr);
window.addEventListener('unhandledrejection', logErr);
var p = new Promise((resolve, reject)=>{

@@ -190,3 +192,3 @@ reject("apa");

setTimeout(()=>{
Promise.on('error').unsubscribe(logErr);
window.removeEventListener('unhandledrejection', logErr);
start();

@@ -307,9 +309,9 @@ }, 1);

asyncTest("Promise.on.error", ()=> {
asyncTest("unhandledrejection", ()=> {
var errors = [];
function onError(e, p) {
errors.push(e);
return false;
function onError(ev) {
errors.push(ev.reason);
ev.preventDefault();
}
Dexie.Promise.on('error', onError);
window.addEventListener('unhandledrejection', onError);

@@ -322,3 +324,4 @@ new Dexie.Promise((resolve, reject) => {

equal(errors[0], "error", "Should be our error there");
Dexie.Promise.on.error.unsubscribe(onError);
window.removeEventListener('unhandledrejection', onError);
start();

@@ -328,9 +331,9 @@ }, 40);

asyncTest("Promise.on.error2", ()=> {
asyncTest("unhandledrejection2", ()=> {
var errors = [];
function onError(e, p) {
errors.push(e);
return false;
function onError(ev) {
errors.push(ev.reason);
ev.preventDefault();
}
Dexie.Promise.on('error', onError);
window.addEventListener('unhandledrejection', onError);

@@ -349,3 +352,3 @@ new Dexie.Promise((resolve, reject) => {

equal(errors[0], "error", "Should be our error there");
Dexie.Promise.on.error.unsubscribe(onError);
window.removeEventListener('unhandledrejection', onError);
start();

@@ -355,9 +358,9 @@ }, 40);

asyncTest("Promise.on.error3", ()=> {
asyncTest("unhandledrejection3", ()=> {
var errors = [];
function onError(e, p) {
errors.push(e);
return false;
function onError(ev) {
errors.push(ev.reason);
ev.preventDefault();
}
Dexie.Promise.on('error', onError);
window.addEventListener('unhandledrejection', onError);

@@ -375,5 +378,5 @@ new Dexie.Promise((resolve, reject) => {

equal(errors.length, 0, "Should be zarro errors there");
Dexie.Promise.on.error.unsubscribe(onError);
window.removeEventListener('unhandledrejection', onError);
start();
}, 40);
});
import Dexie from 'dexie';
import {module, stop, start, asyncTest, equal, ok} from 'QUnit';
import {resetDatabase} from './dexie-unittest-utils';
import {resetDatabase, spawnedTest} from './dexie-unittest-utils';

@@ -25,14 +25,21 @@ "use strict";

asyncTest("Transaction should fail if returning non-Dexie Promise in transaction scope", function(){
db.transaction('rw', db.users, function() {
return window.Promise.resolve().then(()=> {
ok(Dexie.currentTransaction == null, "Dexie.currentTransaction == null. If this assertion fails, don't weap. Rejoice and try to understand how the hell this could be possible.");
//return db.users.add({ username: "foobar" });
var NativePromise = window.Promise;
asyncTest("Transaction should work when returning native Promise in transaction scope", function() {
db.transaction('rw', db.users, trans => {
ok(Dexie.currentTransaction === trans, "First argument to transaction callback should be the transaction instance itself");
return NativePromise.resolve().then(()=> {
ok(Dexie.currentTransaction === trans, "Dexie.currentTransaction should persted through the native promise!");
}).then(()=>{
//return db.users.add({ username: "barfoo" });
});
}).then (function(){
ok(false, "Transaction should not commit because we were using a non-Dexie promise");
}).catch ('IncompatiblePromiseError', function(e){
ok(true, "Good. Should fail with 'IncompatiblePromiseError': " + e);
return db.users.add({ username: "barfoo" }); // Will only work on Chrome, Opera and Edge as of Oktober 6, 2016.
}).then(()=>{
ok(Dexie.currentTransaction === trans, "Dexie.currentTransaction should persted through the native promise!");
return db.users.count();
})
}).then (count => {
ok(true, `User count: ${count}. REJOICE! YOUR BROWSER'S INDEXEDDB PLAYS BALL WITH PROMISES!`);
}).catch ('TransactionInactiveError', e => {
ok(true, "Your browser has native incompatibility between native Promise and IndexedDB. This is why we still avoid returning native promises.");
}).catch (e => {
ok(false, `Failed: ${e.stack || e}`);
}).finally(start);

@@ -39,0 +46,0 @@ });

@@ -210,4 +210,4 @@ const promisifyAll = require('es6-promisify-all');

"transform-es2015-computed-properties",
//"transform-es2015-constants",
//"transform-es2015-destructuring",
"transform-es2015-constants",
//"transform-es2015-destructuring", // Requires big __restructurer function to occupy space onto the result.
//"transform-es2015-for-of",

@@ -214,0 +214,0 @@ //"transform-es2015-function-name", // Slightly increases the code size, but could improve debugging experience a bit.

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 too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc