1 |
- (window.webpackJsonp=window.webpackJsonp||[]).push([[0],[,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(19),o=n(2),a=n(0),i=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},u=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},c="logDay",s=7*o.a,l=1*o.a,f=function(){function e(e){var t;this.DB=new r.CustomDB({dbName:e||"logan_web_db",dbVersion:1,tables:(t={},t.logan_detail_table={indexList:[{indexName:"logReportName",unique:!1},{indexName:"logCreateTime",unique:!1}]},t.log_day_table={primaryKey:c},t)})}return e.prototype.logReportNameFormatter=function(e,t){return e+"_"+t},e.prototype.logReportNameParser=function(e){var t=e.split("_");return{logDay:t[0],pageIndex:+t[1]}},e.prototype.getLogDayInfo=function(e){return i(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.DB.getItem("log_day_table",e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getLogDaysInfo=function(e,t){return i(this,void 0,void 0,(function(){var n;return u(this,(function(r){switch(r.label){case 0:return e!==t?[3,2]:[4,this.DB.getItem("log_day_table",e)];case 1:return[2,(n=r.sent())?[n]:[]];case 2:return[4,this.DB.getItemsInRange({tableName:"log_day_table",indexRange:{indexName:c,lowerIndex:e,upperIndex:t,lowerExclusive:!1,upperExclusive:!1}})];case 3:return[2,r.sent()]}}))}))},e.prototype.getLogsByReportName=function(e){return i(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.DB.getItemsInRange({tableName:"logan_detail_table",indexRange:{indexName:"logReportName",onlyIndex:e}})];case 1:return[2,t.sent()]}}))}))},e.prototype.addLog=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,f,d,h,p,m,b,v,y,g,w,x;return u(this,(function(u){switch(u.label){case 0:return t=Object(o.g)(e),n=new Date,r=Object(o.c)(n),[4,this.getLogDayInfo(r)];case 1:if((i=u.sent()||((g={})[c]=r,g.totalSize=0,g.reportPagesInfo={pageSizes:[0]},g)).totalSize+t>s)throw new Error(a.b.EXCEED_LOG_SIZE_LIMIT);return f=i.reportPagesInfo.pageSizes,d=f.length-1,h=f[d],p=h>0&&h+t>l,I=f.slice(),p?I.push(t):I[d]+=t,m=I,(w={}).logReportName=this.logReportNameFormatter(r,p?d+1:d),w.logCreateTime=+n,w.logSize=t,w.logString=e,b=w,(x={})[c]=r,x.totalSize=i.totalSize+t,x.reportPagesInfo={pageSizes:m},v=x,y=6048e5-(+new Date-Object(o.e)(new Date)),[4,this.DB.addItems([{tableName:"logan_detail_table",item:b,itemDuration:y},{tableName:"log_day_table",item:v,itemDuration:y}])];case 2:return u.sent(),[2]}var I}))}))},e.idbIsSupported=r.idbIsSupported,e.deleteDB=r.deleteDB,e}();t.b=f},,,function(e,t,n){"use strict";function r(e){return!isNaN(e)&&e>=0}Object.defineProperty(t,"__esModule",{value:!0}),t.ParamCheckerEnum={NonNegativeInteger:{rule:r,desc:"needs to be a non-negative integer"},NotNullObject:{rule:function(e){return e&&"object"==typeof e},desc:"needs to be a not-null object"},String:{rule:function(e){return"string"==typeof e},desc:"needs to be a string"},Array:{rule:function(e){return e instanceof Array},desc:"needs to be an Array"},Boolean:{rule:function(e){return"boolean"==typeof e},desc:"needs to be a boolean"}},t.isNonNegativeInteger=r,t.optionWithBackup=function(e,t){return void 0!==e?e:t},t.paramChecker=function(e,t,n,r){var o=n+" "+t.desc;if(r){if(void 0!==e&&!t.rule(e))throw new Error(o+" if defined")}else if(!t.rule(e))throw new Error(o)},t.deduplicateList=function(e){return e.reduce((function(e,t){return e.indexOf(t)<0?e.concat(t):e}),[])}},,,function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(20),u=n(21),c=n(16);function s(e){if(c.paramChecker(e,c.ParamCheckerEnum.NotNullObject,"tableIndexRange",!1),c.paramChecker(e.tableName,c.ParamCheckerEnum.String,"tableIndexRange's",!1),c.paramChecker(e.indexRange,c.ParamCheckerEnum.NotNullObject,"tableIndexRange's indexRange",!0),e.indexRange){var t=e.indexRange,n=t.indexName,r=t.onlyIndex,o=t.lowerIndex,a=t.upperIndex,i=t.lowerExclusive,u=t.upperExclusive;if(c.paramChecker(n,c.ParamCheckerEnum.String,"indexRange's indexName",!1),void 0===r&&void 0===o&&void 0===a)throw new Error("indexRange should have bounds or value for the index");if(void 0!==o&&void 0!==a&&o>=a)throw new Error("lowerIndex should be less than upperIndex");o&&a&&c.paramChecker(i,c.ParamCheckerEnum.Boolean,"indexRange's lowerExclusive",!0),c.paramChecker(u,c.ParamCheckerEnum.Boolean,"indexRange's upperExclusive",!0)}}function l(){try{return i.default(),!0}catch(e){return!1}}t.idbIsSupported=l;var f=function(){function e(e){i.default(),function(e){c.paramChecker(e,c.ParamCheckerEnum.NotNullObject,"dbConfig",!1),c.paramChecker(e.dbName,c.ParamCheckerEnum.String,"dbName",!1),c.paramChecker(e.dbVersion,c.ParamCheckerEnum.NonNegativeInteger,"dbVersion",!0),c.paramChecker(e.itemDuration,c.ParamCheckerEnum.NonNegativeInteger,"itemDuration of dbConfig",!0),c.paramChecker(e.tables,c.ParamCheckerEnum.NotNullObject,"tables",!0),Object.keys(e.tables||{}).forEach((function(t){var n=e.tables[t];c.paramChecker(n.primaryKey,c.ParamCheckerEnum.String,"primaryKey",!0),c.paramChecker(n.itemDuration,c.ParamCheckerEnum.NonNegativeInteger,"itemDuration of table",!0),c.paramChecker(n.indexList,c.ParamCheckerEnum.Array,"indexList",!0),(n.indexList||[]).forEach((function(e){c.paramChecker(e.indexName,c.ParamCheckerEnum.String,"indexName",!1),c.paramChecker(e.unique,c.ParamCheckerEnum.Boolean,"unique",!0)}))}))}(e),this.name=e.dbName,this.version=c.optionWithBackup(e.dbVersion,1),this.tableList=Object.keys(e.tables||{}).map((function(t){return r({tableName:t},e.tables[t])})),this.itemDuration=e.itemDuration}return e.prototype.addItems=function(e){return o(this,void 0,void 0,(function(){var t,n,o=this;return a(this,(function(a){switch(a.label){case 0:return t=function(e,t,n){return void 0!==n?n:void 0!==t?t:e},i=e,s=this.tableList,c.paramChecker(i,c.ParamCheckerEnum.Array,"items",!1),i.forEach((function(e){c.paramChecker(e.tableName,c.ParamCheckerEnum.String,"item's tableName",!1),c.paramChecker(e.itemDuration,c.ParamCheckerEnum.NonNegativeInteger,"item's itemDuration",!0);var t=s.filter((function(t){return t.tableName===e.tableName}))[0];if(!t)throw new Error("Table "+e.tableName+" does not exist");if(void 0!==t.primaryKey&&Object.getOwnPropertyNames(e.item).indexOf(t.primaryKey)<0)throw new Error("primaryKey is needed for item in table "+e.tableName)})),n=e.map((function(e){var n=o.tableList.filter((function(t){return t.tableName===e.tableName}))[0];return r({itemDuration:t(o.itemDuration,n.itemDuration,e.itemDuration)},e)})),[4,u.default.addItems({name:this.name,tableList:this.tableList,version:this.version},n)];case 1:return a.sent(),[2]}var i,s}))}))},e.prototype.getItem=function(e,t){return o(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,h(this.name,e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.getItemsInRange=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,p(this.name,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.deleteItemsInRange=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.paramChecker(e,c.ParamCheckerEnum.Array,"tableIndexRanges",!1),e.forEach((function(e){s(e)})),[4,u.default.deleteItems(this.name,e)];case 1:return t.sent(),[2]}}))}))},e}();function d(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return i.default(),c.paramChecker(e,c.ParamCheckerEnum.String,"dbName",!1),[4,u.default.deleteDB(e)];case 1:return t.sent(),[2]}}))}))}function h(e,t,n){return o(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return c.paramChecker(e,c.ParamCheckerEnum.String,"dbName",!1),c.paramChecker(t,c.ParamCheckerEnum.String,"tableName",!1),[4,u.default.getItem(e,t,n)];case 1:return[2,r.sent()]}}))}))}function p(e,t){return o(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return c.paramChecker(e,c.ParamCheckerEnum.String,"dbName",!1),s(t),[4,u.default.getItemsInRange(e,t)];case 1:return[2,n.sent()]}}))}))}t.CustomDB=f,t.deleteDB=d,t.getItemFromDB=h,t.getItemsInRangeFromDB=p,t.default={idbIsSupported:l,CustomDB:f,deleteDB:d,getItemFromDB:h,getItemsInRangeFromDB:p}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(!window)throw new Error("idb-managed can not run in non-browser environment");for(var e=0,t=["indexedDB","IDBDatabase","IDBObjectStore","IDBTransaction","IDBIndex","IDBCursor","IDBKeyRange","IDBRequest"];e<t.length;e++){var n=t[e];if(!window.hasOwnProperty(n)||!window[n])throw new Error(n+" is not supported in window")}}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(16),u=n(22);function c(e){var t=e.onlyIndex,n=e.lowerIndex,r=e.upperIndex,o=e.lowerExclusive,a=void 0!==o&&o,i=e.upperExclusive,u=void 0!==i&&i;return void 0!==t?IDBKeyRange.only(t):void 0!==n&&void 0!==r?IDBKeyRange.bound(n,r,a,u):void 0!==n?IDBKeyRange.lowerBound(n,a):IDBKeyRange.upperBound(r,u)}function s(e){var t,n=Date.now();return r(r({},e.item),((t={}).updateTime=n,t.expireTime=void 0!==e.itemDuration?e.itemDuration+n:-1,t))}function l(e){return e?e.expireTime>0&&e.expireTime<Date.now()?null:(delete e.updateTime,delete e.expireTime,e):null}function f(e){return o(this,void 0,void 0,(function(){var t,n,r,o,i;return a(this,(function(a){switch(a.label){case 0:return[4,p()];case 1:return[4,b(t=a.sent(),"IDB_MANAGER_STORE",e.name)];case 2:return!(n=a.sent())||e.version>n.version?(r=t.transaction("IDB_MANAGER_STORE","readwrite"),o=r.objectStore("IDB_MANAGER_STORE"),i={dbName:e.name,tableList:e.tableList,version:e.version},o.put(s({item:i,tableName:"IDB_MANAGER_STORE"})),[4,r.complete]):[3,4];case 3:a.sent(),t.close(),a.label=4;case 4:return[2]}}))}))}function d(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return[4,p()];case 1:return t=r.sent(),n=t.transaction("IDB_MANAGER_STORE","readwrite"),n.objectStore("IDB_MANAGER_STORE").delete(e),[4,n.complete];case 2:return r.sent(),t.close(),[2]}}))}))}function h(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,f(e)];case 1:return t.sent(),[4,u.open(e.name,e.version,(function(t){v(t,e.tableList)}))];case 2:return[2,t.sent()]}}))}))}function p(){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,u.open("IDB_MANAGER_DB",1,(function(e){!function(e){e.createObjectStore("IDB_MANAGER_STORE",{keyPath:"dbName"})}(e)}))];case 1:return[2,e.sent()]}}))}))}function m(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return[4,p()];case 1:return[4,b(t=r.sent(),"IDB_MANAGER_STORE",e)];case 2:return n=r.sent(),t.close(),n?[4,u.open(n.dbName,n.version,(function(e){v(e,n.tableList||[])}))]:[3,4];case 3:return[2,r.sent()];case 4:return[2,null]}}))}))}function b(e,t,n){return o(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return e.objectStoreNames.contains(t)?(r=e.transaction(t,"readonly"),[4,r.objectStore(t).get(n)]):[3,2];case 1:return[2,l(o.sent())];case 2:return[2,null]}}))}))}function v(e,t){try{t.forEach((function(t){if(e.objectStoreNames.contains(t.tableName)){var n=e.transaction(t.tableName).objectStore(t.tableName);(t.indexList||[]).forEach((function(e){n.indexNames.contains(e.indexName)||n.createIndex(e.indexName,e.indexName,{unique:e.unique})}))}else{var o=t.primaryKey||"id",a=e.createObjectStore(t.tableName,r({keyPath:o},"id"===o?{autoIncrement:!0}:{}));a.createIndex(o,o,{unique:!0}),(t.indexList||[]).forEach((function(e){a.createIndex(e.indexName,e.indexName,{unique:e.unique})})),a.createIndex("updateTime","updateTime",{unique:!1}),a.createIndex("expireTime","expireTime",{unique:!1})}}))}catch(t){e.close()}}function y(e,t,n){return o(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,7,8]),[4,n()];case 1:return o.sent(),[3,8];case 2:r=o.sent();try{e.abort()}catch(e){}o.label=3;case 3:return o.trys.push([3,5,,6]),[4,e.complete];case 4:return o.sent(),[3,6];case 5:throw o.sent(),r;case 6:return[3,8];case 7:return t.close(),[7];case 8:return[2]}}))}))}function g(e,t){return o(this,void 0,void 0,(function(){var n,r,u,s=this;return a(this,(function(l){switch(l.label){case 0:return n=t.filter((function(t){return e.objectStoreNames.contains(t.tableName)})),r=i.deduplicateList(n.map((function(e){return e.tableName}))),[4,y(u=e.transaction(r,"readwrite"),e,(function(){return o(s,void 0,void 0,(function(){var e,t,r,o,i,s,l;return a(this,(function(a){switch(a.label){case 0:e=0,t=n,a.label=1;case 1:return e<t.length?(r=t[e],o=r.tableName,i=r.indexRange,s=u.objectStore(o),i?[3,3]:[4,s.clear()]):[3,8];case 2:return a.sent(),[3,7];case 3:return[4,s.index(i.indexName).openCursor(c(i))];case 4:l=a.sent(),a.label=5;case 5:return l?(s.delete(l.primaryKey),[4,l.continue()]):[3,7];case 6:return l=a.sent(),[3,5];case 7:return e++,[3,1];case 8:return[2]}}))}))}))];case 1:return l.sent(),[2]}}))}))}function w(e,t){return o(this,void 0,void 0,(function(){var n,r,u,c=this;return a(this,(function(l){switch(l.label){case 0:return n=i.deduplicateList(t.map((function(e){return e.tableName}))),[4,_(e.name,n.map((function(e){return{tableName:e,indexRange:{indexName:"expireTime",upperIndex:+new Date,upperExclusive:!1}}})))];case 1:return l.sent(),[4,h(e)];case 2:return r=l.sent(),[4,y(u=r.transaction(n,"readwrite"),r,(function(){return o(c,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){switch(o.label){case 0:e=0,n=t,o.label=1;case 1:return e<n.length?(r=n[e],[4,u.objectStore(r.tableName).put(s(r))]):[3,4];case 2:o.sent(),o.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}))];case 3:return l.sent(),[2]}}))}))}function x(e,t,n){return o(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return[4,m(e)];case 1:if(!(r=o.sent()))return[3,7];o.label=2;case 2:return o.trys.push([2,4,5,6]),[4,b(r,t,n)];case 3:return[2,o.sent()];case 4:throw o.sent();case 5:return r.close(),[7];case 6:return[3,8];case 7:return[2,null];case 8:return[2]}}))}))}function I(e,t){return o(this,void 0,void 0,(function(){var n,r,o,i,u,s,f,d,h;return a(this,(function(a){switch(a.label){case 0:return n=t.tableName,r=t.indexRange,[4,m(e)];case 1:if(!(o=a.sent()))return[3,13];a.label=2;case 2:return a.trys.push([2,10,11,12]),i=[],o.objectStoreNames.contains(n)?[3,3]:[3,9];case 3:return u=o.transaction(n,"readonly"),s=u.objectStore(n),r?[3,5]:[4,s.getAll()];case 4:return f=a.sent(),i=(f||[]).map(l).filter((function(e){return null!==e})),[3,9];case 5:return[4,s.index(r.indexName).openCursor(c(r))];case 6:d=a.sent(),a.label=7;case 7:return d?((h=l(d.value))&&i.push(h),[4,d.continue()]):[3,9];case 8:return d=a.sent(),[3,7];case 9:return[2,i];case 10:throw a.sent();case 11:return o.close(),[7];case 12:return[3,14];case 13:return[2,[]];case 14:return[2]}}))}))}function N(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,d(e)];case 1:return t.sent(),[4,u.delete(e)];case 2:return t.sent(),[2]}}))}))}function _(e,t){return o(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return[4,m(e)];case 1:return(n=r.sent())?[4,g(n,t)]:[3,3];case 2:return r.sent(),[3,4];case 3:case 4:return[2]}}))}))}t.addItems=w,t.getItem=x,t.getItemsInRange=I,t.deleteDB=N,t.deleteItems=_,t.default={addItems:w,getItem:x,getItemsInRange:I,deleteDB:N,deleteItems:_}},function(e,t){function n(e){return Array.prototype.slice.call(e)}function r(e){return new Promise((function(t,n){e.onsuccess=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function o(e,t,n){var o,a=new Promise((function(a,i){r(o=e[t].apply(e,n)).then(a,i)}));return a.request=o,a}function a(e,t,n){var r=o(e,t,n);return r.then((function(e){if(e)return new f(e,r.request)}))}function i(e,t,n){n.forEach((function(n){Object.defineProperty(e.prototype,n,{get:function(){return this[t][n]},set:function(e){this[t][n]=e}})}))}function u(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return o(this[t],r,arguments)})}))}function c(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return this[t][r].apply(this[t],arguments)})}))}function s(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return a(this[t],r,arguments)})}))}function l(e){this._index=e}function f(e,t){this._cursor=e,this._request=t}function d(e){this._store=e}function h(e){this._tx=e,this.complete=new Promise((function(t,n){e.oncomplete=function(){t()},e.onerror=function(){n(e.error)},e.onabort=function(){n(e.error)}}))}function p(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new h(n)}function m(e){this._db=e}var b;if(d.prototype.createIndex=function(){return new l(this._store.createIndex.apply(this._store,arguments))},d.prototype.index=function(){return new l(this._store.index.apply(this._store,arguments))},h.prototype.objectStore=function(){return new d(this._tx.objectStore.apply(this._tx,arguments))},p.prototype.createObjectStore=function(){return new d(this._db.createObjectStore.apply(this._db,arguments))},m.prototype.transaction=function(){return new h(this._db.transaction.apply(this._db,arguments))},function(){try{return["IDBIndex","IDBCursor","IDBObjectStore","IDBTransaction","IDBDatabase"].forEach((function(e){if(window&&(!window[e]||!window.hasOwnProperty(e)))throw new Error(e)})),!0}catch(e){return!1}}())i(l,"_index",["name","keyPath","multiEntry","unique"]),u(l,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),s(l,"_index",IDBIndex,["openCursor","openKeyCursor"]),i(f,"_cursor",["direction","key","primaryKey","value"]),u(f,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach((function(e){e in IDBCursor.prototype&&(f.prototype[e]=function(){var t=this,n=arguments;return Promise.resolve().then((function(){return t._cursor[e].apply(t._cursor,n),r(t._request).then((function(e){if(e)return new f(e,t._request)}))}))})})),i(d,"_store",["name","keyPath","indexNames","autoIncrement"]),u(d,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),s(d,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),c(d,"_store",IDBObjectStore,["deleteIndex"]),i(h,"_tx",["objectStoreNames","mode"]),c(h,"_tx",IDBTransaction,["abort"]),i(p,"_db",["name","version","objectStoreNames"]),c(p,"_db",IDBDatabase,["deleteObjectStore","close"]),i(m,"_db",["name","version","objectStoreNames"]),c(m,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach((function(e){[d,l].forEach((function(t){e in t.prototype&&(t.prototype[e.replace("open","iterate")]=function(){var t=n(arguments),r=t[t.length-1],o=this._store||this._index,a=o[e].apply(o,t.slice(0,-1));a.onsuccess=function(){r(a.result)}})}))})),[l,d].forEach((function(e){e.prototype.getAll||(e.prototype.getAll=function(e,t){var n=this,r=[];return new Promise((function(o){n.iterateCursor(e,(function(e){e?(r.push(e.value),void 0===t||r.length!=t?e.continue():o(r)):o(r)}))}))})})),b={open:function(e,t,n){var r=o(indexedDB,"open",[e,t]),a=r.request;return a&&(a.onupgradeneeded=function(e){n&&n(new p(a.result,e.oldVersion,a.transaction))}),r.then((function(e){return new m(e)}))},delete:function(e){return o(indexedDB,"deleteDatabase",[e])}};else{var v="indexedDB is not supported";b={open:function(){return Promise.reject(new Error(v))},delete:function(){return Promise.reject(new Error(v))}}}e.exports=b}]]);
|