PowerOfIndexedDB/jscompiled/IndexedDB.js.map

1 line
32 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"mappings":"A,C,KCaA,MAAM,EAWK,GAAG,CAAY,CAAE,CAAiB,CACzC,CACO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAEhB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAO,IAAI,CAAC,GAE7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAM,CAAC,EAAS,CAEzC,CAIO,iBAAiB,CAAY,CAAE,CAAiB,CACvD,CACI,IAAI,CAAC,EAAE,CAAC,EAAO,EACnB,CAIA,cAAqB,CAAW,CAChC,CACI,IAAI,CAAC,SAAS,CAAC,EAAM,IAAI,CAAE,EAC/B,CAMO,UAAU,CAAW,CAAE,GAAG,CAAI,CACrC,CACI,IAAI,EAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAC9B,GAAG,EAAQ,IAAK,IAAM,KAAa,EAC/B,KAAa,EAErB,C,a,CAzCC,IAAA,CACM,OAAA,CAAmC,IAAI,G,CAyClD,CACO,MAAM,UAAkB,EAqB3B,aACA,CACI,KAAK,GAnBR,IAAA,CACM,OAAA,CAAoB,CAAA,EAmBnB,EAAU,MAAM,EAEhB,EAAU,mBAAmB,EAErC,CAIA,MAAa,CAAc,CAC3B,CACI,GAAG,IAAI,CAAC,OAAO,CAEX,OAAO,IAEX,IAAI,CAAC,gBAAgB,CAAC,OAAO,IAAM,IACvC,CAIA,MAAa,SACb,CACI,IAAI,CAAC,OAAO,CAAG,CAAA,EACf,IAAI,CAAC,SAAS,CAAG,EAAU,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAI,GAC9E,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,gBAAiB,IAA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,MAAM,CAAC,KAAK,CAAC,EAAE,EAEhD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAE/B,CACO,QAAQ,CAAK,CACpB,CACO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAEzB,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAEpD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAEjC,CACJ,CACA,OAAO,SAAS,CAAG,C,C","sources":["<anon>","src/Services/IndexedDB.ts"],"sourcesContent":["(() => {\n/**\n * Browser ve nodejs uyumluluğu için yerel eventleri kullanmak yerine manual event sistemi yazılmıştır\n */ class $cc6210a985e36f00$var$EventTarget {\n /**\n * Olay gerçekleştiğinde gerçekleşmesi için yeni işlev kaydı açar\n * @param {string} event olayın türü\n * @param {Function} callback olay gerçekleştiğinde çağrılacak fonksiyon\n */ on(event, callback) {\n if (this._events.has(event)) this._events.get(event).push(callback);\n else this._events.set(event, [\n callback\n ]);\n }\n /**\n * on ile aynı, eski tarayıcılar hala addEventListener kullanıyor\n */ addEventListener(event, callback) {\n this.on(event, callback);\n }\n /**\n * Browserlar için olay tetikleyicisi\n */ dispatchEvent(event) {\n this.emitEvent(event.type, event);\n }\n /**\n * \n * @param {string} type gerçekleşen olay türü\n * @param {...any[]} args olay gerçekleştiğinde çalışacak işlevler gönderilecek argümanlar\n */ emitEvent(type, ...args) {\n let events = this._events.get(type);\n if (events) for (const callbacks of events)callbacks(...args);\n }\n constructor(){\n /**\n * Olayları tutan nesne\n */ this._events = new Map();\n }\n}\nclass $cc6210a985e36f00$export$c4e63223f1bd3b44 extends $cc6210a985e36f00$var$EventTarget {\n /**\n * IndexedDB yeni örneğinde sistemin desteklediği API'yi yapılandırıyoruz\n */ constructor(){\n super();\n /**\n * Veritabanının hazır olup olmadığını tutar\n */ this.IsReady = false;\n if (!$cc6210a985e36f00$export$c4e63223f1bd3b44.Engine) $cc6210a985e36f00$export$c4e63223f1bd3b44.PolyfillCompalibity();\n }\n /**\n * Veritabanıık ve işlemlere hazır olduğu anda çalıştırılır\n */ scope(func) {\n if (this.IsReady) return func();\n this.addEventListener(\"load\", ()=>func());\n }\n /**\n * Modeller hazır olduğunda bağlanmak için kullanılır\n */ async connect() {\n this.IsReady = false;\n this.DBRequest = $cc6210a985e36f00$export$c4e63223f1bd3b44.Engine.open(this.Model.name, this.Model.version || 0);\n this.DBRequest.addEventListener(\"upgradeneeded\", this.executeMigrate.bind(this));\n new $cc6210a985e36f00$var$IEventLocate(this.DBRequest).sync().then(async (db)=>{\n this.DB = db;\n this.IsReady = true;\n this.dispatchEvent(new Event(\"load\"));\n });\n }\n /**\n * IndexedDB'de yeni tablolar ve kolonlarını açmak için çalıştırılır\n */ executeMigrate() {\n let db = this.DBRequest.result;\n for (let e of this.Model.tables){\n let objectStore;\n if (!db.objectStoreNames.contains(e.name)) objectStore = db.createObjectStore(e.name, {\n keyPath: e.key\n });\n else objectStore = this.DBRequest.transaction.objectStore(e.name);\n e.columns.forEach((name)=>{\n if (!objectStore.indexNames.contains(name)) objectStore.createIndex(name, name);\n });\n let indexes = Array.from(objectStore.indexNames);\n for (let indexName of indexes)if (!e.columns.includes(indexName)) objectStore.deleteIndex(indexName);\n }\n // \n for (const objectStoreName of Array.from(db.objectStoreNames)){\n let isExists = this.Model.tables.filter((e)=>e.name == objectStoreName).length != 0;\n if (!isExists) db.deleteObjectStore(objectStoreName);\n }\n this.dispatchEvent(new Event(\"migrate\"));\n }\n /**\n * IndexedDB'de belirli bir yapıda tablo yapısı oluşturur ve değiştirir\n */ migrate(mi) {\n this.Model = mi;\n }\n /**\n * Tabloya veri ekler\n */ async add(tablename, data) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).add(data);\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablodaki tüm verileri temizler\n */ async clear(tablename) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).clear();\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablodaki verilerin sayısını döner\n */ async count(tablename) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).count();\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablo bir kayıt siler\n */ async delete(tablename, name) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).delete(name);\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablodaki bir kaydı okur\n */ async get(tablename, index) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).get(index);\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablodaki bir kaydı okur\n */ async getFrom(tablename, column, index) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).index(column).get(index);\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablodaki tüm kayıtları alır\n */ async getAll(tablename) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).getAll();\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tabloda veri yoksa oluşturur varsa günceller\n */ async save(tablename, key, data) {\n if (!this.IsReady) return;\n let record = await this.get(tablename, key);\n if (record) await this.put(tablename, data);\n else await this.add(tablename, data);\n }\n /**\n * Tabloda bir veriyi günceller\n */ async put(tablename, data) {\n if (!this.IsReady) return;\n let store = this.DB.transaction([\n tablename\n ], \"readwrite\").objectStore(tablename).put(data);\n return await new $cc6210a985e36f00$var$IEventLocate(store).sync();\n }\n /**\n * Tablodaki tüm verileri tek tek verir\n */ async each(tablename, callback) {\n let store = this.DB.transaction([\n tablename\n ], \"readonly\").objectStore(tablename);\n let cursor = store.openCursor();\n await new Promise((ok)=>{\n cursor.onsuccess = function() {\n if (cursor.result !== null) {\n let data = cursor.result.value;\n try {\n callback(data, ()=>cursor.result.continue(), ()=>ok(void 0), cursor.result.primaryKey);\n } catch {\n ok(void 0);\n }\n } else ok(void 0);\n };\n });\n }\n /**\n * Tablodaki tüm verileri tek tek gezer ve aktif menipülasyon sağlar\n */ async subfilter(tablename, filterCallback, mapCallback, resultCallback) {\n let pool = [];\n let mappedObj = [];\n await this.each(tablename, async (value, next, stop, id)=>{\n if (await filterCallback(value, stop)) pool.push(id);\n next();\n });\n for (const item of pool){\n let value = this.get(tablename, item);\n mappedObj.push(await mapCallback(value));\n }\n if (typeof resultCallback == \"function\") resultCallback(mappedObj);\n return mappedObj;\n }\n /**\n * Tablodaki tüm verileri tek tek verir\n */ async countFilter(tablename, filterCallback, stopFindedOne = false) {\n let pool = 0;\n await this.each(tablename, async (value, next, stop)=>{\n if (await filterCallback(value, stop)) {\n pool++;\n if (stopFindedOne) stop();\n }\n next();\n });\n return pool;\n }\n /**\n * IndexedDB bağlantısını sonlandırır\n */ close() {\n if (!this.IsReady) return;\n this.dispatchEvent(new Event(\"close\"));\n this.DB.close();\n this.IsReady = false;\n }\n /**\n * Farklı browserlarda uyumluluk için IndexedDB farklı isimlerde çağrılabilir\n */ static PolyfillCompalibity() {\n if (\"indexedDB\" in window) $cc6210a985e36f00$export$c4e63223f1bd3b44.Engine = window[\"indexedDB\"];\n if (\"mozIndexedDB\" in window) $cc6210a985e36f00$export$c4e63223f1bd3b44.Engine = window[\"mozIndexedDB\"];\n if (\"webkitIndexedDB\" in window) $cc6210a985e36f00$export$c4e63223f1bd3b44.Engine = window[\"webkitIndexedDB\"];\n if (\"msIndexedDB\" in window) $cc6210a985e36f00$export$c4e63223f1bd3b44.Engine = window[\"msIndexedDB\"];\n }\n}\n/**\n * Başarılı olduğunda onsuccess başarısız olduğunda onerror döndüren yapıları\n * javascript ES6 tarafında async/await yapısına dönüştürür böylece try-catch kullanılarak yakalanabilir\n */ class $cc6210a985e36f00$var$IEventLocate {\n constructor(sheel){\n this.result = {\n then: [],\n catch: [],\n finally: []\n };\n this.events = {\n then: [],\n catch: [],\n finally: []\n };\n sheel.onerror = (event)=>{\n this.result.catch = [\n event.target,\n event\n ];\n this.events.catch.forEach((e)=>{\n e.call(event.target, event.target?.result);\n });\n this.events.finally.forEach((e)=>{\n e.call(event.target, event.target?.result);\n });\n };\n sheel.onsuccess = (event)=>{\n this.result.then = [\n event.target,\n event\n ];\n this.events.then.forEach((e)=>{\n e.call(event.target, event.target?.result);\n });\n };\n }\n sync() {\n return new Promise((resolve, reject)=>{\n this.then(resolve);\n this.catch(reject);\n });\n }\n then(e) {\n if (this.result.then.length) e.call(this.result.then[0], this.result.then[1]);\n else this.events.then.push(e);\n }\n catch(e) {\n if (this.result.catch.length) e.call(this.result.catch[0], this.result.catch[1]);\n else this.events.catch.push(e);\n }\n finally(e) {\n if (this.result.finally.length) e.call(this.result.finally[0], this.result.finally[1]);\n else this.events.finally.push(e);\n }\n}\nwindow.IndexedDB = $cc6210a985e36f00$export$c4e63223f1bd3b44;\n\n})();\n//# sourceMappingURL=IndexedDB.js.map\n","interface ModelIterface {\n name:string;\n version:number;\n tables : TableInterface[]\n}\ninterface TableInterface {\n name:string;\n key:string,\n columns:string[]\n}\n/**\n * Browser ve nodejs uyumluluğu için yerel eventleri kullanmak yerine manual event sistemi yazılmıştır\n */\nclass EventTarget\n{\n /**\n * Olayları tutan nesne\n */\n public _events : Map<string,Function[]> = new Map();\n /**\n * Olay gerçekleştiğinde gerçekleşmesi için yeni işlev kaydı açar\n * @param {string} event olayın türü\n * @param {Function} callback olay gerçekleştiğinde çağrılacak fonksiyon\n */\n public on(event:string, callback:Function)\n {\n if(this._events.has(event))\n {\n this._events.get(event).push(callback)\n }else{\n this._events.set(event,[callback])\n }\n }\n /**\n * on ile aynı, eski tarayıcılar hala addEventListener kullanıyor\n */\n public addEventListener(event:string, callback:Function)\n {\n this.on(event, callback)\n }\n /**\n * Browserlar için olay tetikleyicisi\n */\n public dispatchEvent(event:Event)\n {\n this.emitEvent(event.type, event)\n }\n /**\n * \n * @param {string} type gerçekleşen olay türü\n * @param {...any[]} args olay gerçekleştiğinde çalışacak işlevler gönderilecek argümanlar\n */\n public emitEvent(type:string, ...args)\n {\n let events = this._events.get(type);\n if(events) for (const callbacks of events) {\n callbacks(...args)\n }\n }\n}\nexport class IndexedDB extends EventTarget\n{\n /**\n * Veritabanının hazır olup olmadığını tutar\n */\n public IsReady : Boolean = false;\n /**\n * Migration için tabloların yapısı tutulan veri\n */\n public Model : ModelIterface;\n /**\n * IndexedDB verisi\n */\n private DBRequest : IDBOpenDBRequest;\n /**\n * IndexedDB veritabanı işleci\n */\n private DB : IDBDatabase;\n /**\n * IndexedDB yeni örneğinde sistemin desteklediği API'yi yapılandırıyoruz\n */\n public constructor()\n {\n super()\n if(!IndexedDB.Engine)\n {\n IndexedDB.PolyfillCompalibity()\n }\n }\n /**\n * Veritabanıık ve işlemlere hazır olduğu anda çalıştırılır\n */\n public scope(func: Function)\n {\n if(this.IsReady)\n {\n return func()\n }\n this.addEventListener(\"load\",() => func())\n }\n /**\n * Modeller hazır olduğunda bağlanmak için kullanılır\n */\n public async connect()\n {\n this.IsReady = false;\n this.DBRequest = IndexedDB.Engine.open(this.Model.name, this.Model.version || 0);\n this.DBRequest.addEventListener(\"upgradeneeded\", this.executeMigrate.bind(this));\n new IEventLocate<IDBDatabase>(this.DBRequest).sync().then(async db => {\n this.DB = db;\n this.IsReady = true;\n this.dispatchEvent(new Event(\"load\"));\n })\n }\n /**\n * IndexedDB'de yeni tablolar ve kolonlarını açmak için çalıştırılır\n */\n public executeMigrate()\n {\n let db : IDBDatabase = this.DBRequest.result;\n for(let e of this.Model.tables)\n {\n let objectStore : IDBObjectStore;\n if(!db.objectStoreNames.contains(e.name))\n {\n objectStore = db.createObjectStore(e.name, {keyPath:e.key});\n }else{\n objectStore = this.DBRequest.transaction.objectStore(e.name);\n }\n \n e.columns.forEach(name => {\n if(!objectStore.indexNames.contains(name))\n {\n objectStore.createIndex(name, name)\n }\n })\n\n let indexes = Array.from(objectStore.indexNames);\n\n for(let indexName of indexes)\n {\n if(!e.columns.includes(indexName))\n {\n objectStore.deleteIndex(indexName)\n }\n }\n }\n\n // \n\n for (const objectStoreName of Array.from(db.objectStoreNames)) {\n let isExists = this.Model.tables.filter(e => e.name == objectStoreName).length != 0;\n if(!isExists)\n {\n db.deleteObjectStore(objectStoreName);\n }\n }\n\n this.dispatchEvent(new Event(\"migrate\"));\n }\n /**\n * IndexedDB'de belirli bir yapıda tablo yapısı oluşturur ve değiştirir\n */\n public migrate(mi:ModelIterface)\n {\n this.Model = mi;\n }\n /**\n * Tabloya veri ekler\n */\n public async add(tablename:string, data:{[key:string]:any})\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).add(data);\n return await (new IEventLocate<IDBValidKey>(store)).sync();\n }\n /**\n * Tablodaki tüm verileri temizler\n */\n public async clear(tablename:string)\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).clear();\n return await (new IEventLocate<undefined>(store)).sync();\n }\n /**\n * Tablodaki verilerin sayısını döner\n */\n public async count(tablename:string)\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).count();\n return await (new IEventLocate<number>(store)).sync();\n }\n /**\n * Tablo bir kayıt siler\n */\n public async delete(tablename:string, name:string)\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).delete(name);\n return await (new IEventLocate <undefined> (store)).sync();\n }\n /**\n * Tablodaki bir kaydı okur\n */\n public async get(tablename:string, index:string)\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).get(index);\n return await (new IEventLocate <{[key:string]:any}> (store)).sync();\n }\n /**\n * Tablodaki bir kaydı okur\n */\n public async getFrom(tablename:string, column:string, index:string)\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).index(column).get(index);\n return await (new IEventLocate <{[key:string]:any}> (store)).sync();\n }\n /**\n * Tablodaki tüm kayıtları alır\n */\n public async getAll(tablename:string)\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).getAll();\n return await (new IEventLocate <{[key:string]:any}[]> (store)).sync();\n }\n /**\n * Tabloda veri yoksa oluşturur varsa günceller\n */\n public async save(tablename:string, key:string, data:{[key:string]:any})\n {\n if(!this.IsReady) return;\n let record = await this.get(tablename, key);\n if(record)\n {\n await this.put(tablename, data);\n }else{\n await this.add(tablename, data);\n }\n }\n /**\n * Tabloda bir veriyi günceller\n */\n public async put(tablename:string,data:{[key:string]:any})\n {\n if(!this.IsReady) return;\n let store = this.DB.transaction([tablename], \"readwrite\").objectStore(tablename).put(data);\n return await (new IEventLocate <IDBValidKey> (store)).sync();\n }\n /**\n * Tablodaki tüm verileri tek tek verir\n */\n public async each(tablename:string, callback:(value:Object,next:Function, stop:Function, primaryKey:any) => Promise<any>)\n {\n let store = this.DB.transaction([tablename],\"readonly\").objectStore(tablename);\n\n let cursor = store.openCursor();\n\n await new Promise(ok => {\n cursor.onsuccess = function(){\n if(cursor.result !== null)\n {\n let data = cursor.result.value;\n try{\n callback(\n data,\n () => cursor.result.continue(),\n () => ok(void 0),\n cursor.result.primaryKey\n )\n }catch{\n ok(void 0)\n }\n }\n else\n {\n ok(void 0)\n }\n };\n })\n }\n /**\n * Tablodaki tüm verileri tek tek gezer ve aktif menipülasyon sağlar\n */\n public async subfilter(\n tablename:string,\n filterCallback: (value:Object, stop:Function) => Promise<Boolean>,\n mapCallback: (value:Object) => Promise<any>,\n resultCallback?: (value:any[]) => any,\n ) : Promise<any[]>\n {\n let pool : string[] = [];\n let mappedObj : any[] = [];\n\n await this.each(tablename, async (value, next, stop, id: string) => {\n if(await filterCallback(\n value,\n stop\n )){\n pool.push(id);\n }\n next();\n });\n for (const item of pool)\n {\n let value = this.get(tablename, item);\n mappedObj.push(\n await mapCallback(value)\n )\n }\n\n if(typeof resultCallback == \"function\")\n {\n resultCallback(mappedObj)\n }\n\n return mappedObj\n }\n /**\n * Tablodaki tüm verileri tek tek verir\n */\n public async countFilter(\n tablename:string,\n filterCallback: (value:Object, stop:Function) => Promise<Boolean>,\n stopFindedOne : boolean = false\n ) : Promise<number>\n {\n let pool : number = 0;\n\n await this.each(tablename, async (value, next, stop) => {\n if(await filterCallback(\n value,\n stop\n )){\n pool++;\n if(stopFindedOne)\n {\n stop()\n }\n }\n next();\n });\n\n return pool\n }\n /**\n * IndexedDB bağlantısını sonlandırır\n */\n public close()\n {\n if(!this.IsReady) return;\n this.dispatchEvent(new Event(\"close\"));\n this.DB.close();\n this.IsReady = false;\n }\n /**\n * IndexedDB okuma yazma için kullanılan api\n */\n public static Engine : IDBFactory;\n /**\n * Farklı browserlarda uyumluluk için IndexedDB farklı isimlerde çağrılabilir\n */\n public static PolyfillCompalibity()\n {\n if('indexedDB' in window)\n {\n IndexedDB.Engine = window['indexedDB'] as IDBFactory\n }\n if('mozIndexedDB' in window)\n {\n IndexedDB.Engine = window['mozIndexedDB'] as IDBFactory\n }\n if('webkitIndexedDB' in window)\n {\n IndexedDB.Engine = window['webkitIndexedDB'] as IDBFactory\n }\n if('msIndexedDB' in window)\n {\n IndexedDB.Engine = window['msIndexedDB'] as IDBFactory\n }\n }\n}\ninterface ISheel{\n onsuccess : (e:any) => any;\n onerror : (e:any) => any;\n}\n/**\n * Başarılı olduğunda onsuccess başarısız olduğunda onerror döndüren yapıları\n * javascript ES6 tarafında async/await yapısına dönüştürür böylece try-catch kullanılarak yakalanabilir\n */\nclass IEventLocate<Type>\n{\n private result : {\n then:any[],\n catch:any[],\n finally:any[]\n } = {\n then:[],\n catch:[],\n finally:[]\n };\n public events : {[key:string]:Function[]}= {\n then: [],\n catch: [],\n finally: []\n };\n public constructor(sheel:ISheel)\n {\n sheel.onerror = (event) => {\n this.result.catch = [event.target, event];\n this.events.catch.forEach(e => {\n e.call(event.target, event.target?.result);\n })\n this.events.finally.forEach(e => {\n e.call(event.target, event.target?.result);\n })\n }\n sheel.onsuccess = (event) => {\n this.result.then = [event.target, event];\n this.events.then.forEach(e => {\n e.call(event.target, event.target?.result);\n })\n }\n }\n public sync() : Promise<Type>\n {\n return new Promise((resolve, reject) => {\n this.then(resolve);\n this.catch(reject);\n })\n }\n public then(e:any)\n {\n if(this.result.then.length)\n {\n e.call(this.result.then[0],this.result.then[1])\n }else{\n this.events.then.push(e);\n }\n }\n public catch(e:any)\n {\n if(this.result.catch.length)\n {\n e.call(this.result.catch[0],this.result.catch[1])\n }else{\n this.events.catch.push(e); \n }\n }\n public finally(e:any)\n {\n if(this.result.finally.length)\n {\n e.call(this.result.finally[0],this.result.finally[1])\n }else{\n this.events.finally.push(e);\n }\n }\n}\nwindow.IndexedDB = IndexedDB"],"names":["$cc6210a985e36f00$var$EventTarget","on","event","callback","_events","has","get","push","set","addEventListener","dispatchEvent","emitEvent","type","args","events","callbacks","constructor","Map","$cc6210a985e36f00$export$c4e63223f1bd3b44","IsReady","Engine","PolyfillCompalibity","scope","func","connect","DBRequest","open","Model","name","version","executeMigrate","bind","$cc6210a985e36f00$var$IEventLocate","sync","then","db","DB","Event","result","e","tables","objectStore","indexName","objectStoreNames","contains","transaction","createObjectStore","keyPath","key","columns","forEach","indexNames","createIndex","Array","from","includes","deleteIndex","objectStoreName","filter","length","deleteObjectStore","migrate","mi","add","tablename","data","store","clear","count","delete","index","getFrom","column","getAll","save","put","each","cursor","openCursor","Promise","ok","onsuccess","value","continue","primaryKey","subfilter","filterCallback","mapCallback","resultCallback","pool","mappedObj","item","next","stop","id","countFilter","stopFindedOne","close","window","sheel","catch","finally","onerror","target","call","resolve","reject","IndexedDB"],"version":3,"file":"IndexedDB.js.map"}