/** * Cesium - https://github.com/CesiumGS/cesium * * Copyright 2011-2020 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details. */ define(["./when-8d13db60","./createTaskProcessorWorker"],function(d,e){function v(e){return null!=e}function c(e){var t;this.name="DeveloperError",this.message=e;try{throw new Error}catch(e){t=e.stack}this.stack=t}v(Object.create)&&((c.prototype=Object.create(Error.prototype)).constructor=c),c.prototype.toString=function(){var e=this.name+": "+this.message;return v(this.stack)&&(e+="\n"+this.stack.toString()),e},c.throwInstantiationError=function(){throw new c("This function defines an interface and should not be called directly.")};var f=1,b=2,p=3;function n(e){if(!v(e.name))throw new c("options.name is required.");var t=d.when.defer();this.dbname=e.name;var r=indexedDB.open(this.dbname),n=this;return r.onsuccess=function(e){n.db=e.target.result,n.version=n.db.version,v(n.cachestatus)||(n.cachestatus={}),t.resolve(n)},r.onupgradeneeded=function(e){n.db=e.target.result,n.version=n.db.version,t.resolve(n)},r.onerror=function(e){n.db=null,t.reject("create database fail, error code : "+e.target.errorcode)},this.layer=e.layer||null,this.storageType=e.storageType||"arrayBuffer",this.creatingTable=!1,this.cachestatus={},t.promise}n.prototype.checkObjectStoreExit=function(e){return!!v(this.db)&&this.db.objectStoreNames.contains(e)},n.prototype.createObjectStore=function(n){var c=d.when.defer();if(this.creatingTable)c.reject(!1);else{if(this.db.objectStoreNames.contains(n))return c.reject(!1),c.promise;this.creatingTable=!0;var o=this,e=parseInt(o.db.version);o.db.close();var t=indexedDB.open(o.dbname,e+1);t.onupgradeneeded=function(e){var t=e.target.result,r=(o.db=t).createObjectStore(n,{keyPath:"id"});v(r)?(r.createIndex("value","value",{unique:!1}),o.creatingTable=!1,v(o.cachestatus)||(o.cachestatus={}),o.cachestatus[n]={},o.db.close(),indexedDB.open(o.dbname).onsuccess=function(e){var t=e.target.result;o.db=t,c.resolve(!0)}):(o.creatingTable=!1,c.reject(!1))},t.onsuccess=function(e){e.target.result.close(),c.resolve(!0)},t.onerror=function(e){o.creatingTable=!1,c.reject(!1)}}return c.promise},n.prototype.putElementInDB=function(o,a,s,i){var u,l=d.when.defer();if(!v(this.db))return l.reject(!1),l.promise;var h=this;if(v(h.cachestatus[o])&&!v(i)&&v(h.cachestatus[o][a])&&(h.cachestatus[o][a]===f||h.cachestatus[o][a]===b))return l.resolve(!1),l.promise;if(this.db.objectStoreNames.contains(o)){var e;v(h.cachestatus[o])||(h.cachestatus[o]={});try{e=this.db.transaction([o],"readwrite")}catch(e){return l.reject(null),l.promise}if(u=e.objectStore(o),v(i))if(i instanceof Array){for(var t=0,r=i.length;t