1 |
- {"ast":null,"code":"import { Tools } from \"../Misc/tools.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { GetTGAHeader } from \"../Misc/tga.js\";\nimport { WebRequest } from \"../Misc/webRequest.js\";\nimport { AbstractEngine } from \"../Engines/abstractEngine.js\";\n// Sets the default offline provider to Babylon.js\nAbstractEngine.OfflineProviderFactory = (urlToScene, callbackManifestChecked, disableManifestCheck = false) => {\n return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);\n};\n/**\n * Class used to enable access to IndexedDB\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeCached\n */\nexport class Database {\n /**\n * Gets a boolean indicating if scene must be saved in the database\n */\n get enableSceneOffline() {\n return this._enableSceneOffline;\n }\n /**\n * Gets a boolean indicating if textures must be saved in the database\n */\n get enableTexturesOffline() {\n return this._enableTexturesOffline;\n }\n /**\n * Creates a new Database\n * @param urlToScene defines the url to load the scene\n * @param callbackManifestChecked defines the callback to use when manifest is checked\n * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)\n */\n constructor(urlToScene, callbackManifestChecked, disableManifestCheck = false) {\n // Handling various flavors of prefixed version of IndexedDB\n this._idbFactory = typeof indexedDB !== \"undefined\" ? indexedDB : undefined;\n this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);\n this._db = null;\n this._enableSceneOffline = false;\n this._enableTexturesOffline = false;\n this._manifestVersionFound = 0;\n this._mustUpdateRessources = false;\n this._hasReachedQuota = false;\n if (!Database.IDBStorageEnabled) {\n callbackManifestChecked(true);\n } else {\n if (disableManifestCheck) {\n this._enableSceneOffline = true;\n this._enableTexturesOffline = true;\n this._manifestVersionFound = 1;\n Tools.SetImmediate(() => {\n callbackManifestChecked(true);\n });\n } else {\n this._checkManifestFile(callbackManifestChecked);\n }\n }\n }\n _checkManifestFile(callbackManifestChecked) {\n const noManifestFile = () => {\n this._enableSceneOffline = false;\n this._enableTexturesOffline = false;\n callbackManifestChecked(false);\n };\n const createManifestURL = () => {\n try {\n // make sure we have a valid URL.\n if (typeof URL === \"function\" && this._currentSceneUrl.indexOf(\"http\") === 0) {\n // we don't have the base url, so the URL string must have a protocol\n const url = new URL(this._currentSceneUrl);\n url.pathname += \".manifest\";\n return url.toString();\n }\n } catch (e) {\n // defensive - if this fails for any reason, fall back to the older method\n }\n return `${this._currentSceneUrl}.manifest`;\n };\n let timeStampUsed = false;\n let manifestURL = createManifestURL();\n const xhr = new WebRequest();\n if (navigator.onLine) {\n // Adding a timestamp to by-pass browsers' cache\n timeStampUsed = true;\n manifestURL = manifestURL + (manifestURL.match(/\\?/) == null ? \"?\" : \"&\") + Date.now();\n }\n xhr.open(\"GET\", manifestURL);\n xhr.addEventListener(\"load\", () => {\n if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {\n try {\n const manifestFile = JSON.parse(xhr.response);\n this._enableSceneOffline = manifestFile.enableSceneOffline;\n this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database._IsUASupportingBlobStorage;\n if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {\n this._manifestVersionFound = manifestFile.version;\n }\n callbackManifestChecked(true);\n } catch (ex) {\n noManifestFile();\n }\n } else {\n noManifestFile();\n }\n }, false);\n xhr.addEventListener(\"error\", () => {\n if (timeStampUsed) {\n timeStampUsed = false;\n // Let's retry without the timeStamp\n // It could fail when coupled with HTML5 Offline API\n const retryManifestURL = createManifestURL();\n xhr.open(\"GET\", retryManifestURL);\n xhr.send();\n } else {\n noManifestFile();\n }\n }, false);\n try {\n xhr.send();\n } catch (ex) {\n Logger.Error(\"Error on XHR send request.\");\n callbackManifestChecked(false);\n }\n }\n /**\n * Open the database and make it available\n * @param successCallback defines the callback to call on success\n * @param errorCallback defines the callback to call on error\n */\n open(successCallback, errorCallback) {\n const handleError = () => {\n this._isSupported = false;\n if (errorCallback) {\n errorCallback();\n }\n };\n if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {\n // Your browser doesn't support IndexedDB\n this._isSupported = false;\n if (errorCallback) {\n errorCallback();\n }\n } else {\n // If the DB hasn't been opened or created yet\n if (!this._db) {\n this._hasReachedQuota = false;\n this._isSupported = true;\n const request = this._idbFactory.open(\"babylonjs\", 1);\n // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB\n request.onerror = () => {\n handleError();\n };\n // executes when a version change transaction cannot complete due to other active transactions\n request.onblocked = () => {\n Logger.Error(\"IDB request blocked. Please reload the page.\");\n handleError();\n };\n // DB has been opened successfully\n request.onsuccess = () => {\n this._db = request.result;\n successCallback();\n };\n // Initialization of the DB. Creating Scenes & Textures stores\n request.onupgradeneeded = event => {\n this._db = event.target.result;\n if (this._db) {\n try {\n this._db.createObjectStore(\"scenes\", {\n keyPath: \"sceneUrl\"\n });\n this._db.createObjectStore(\"versions\", {\n keyPath: \"sceneUrl\"\n });\n this._db.createObjectStore(\"textures\", {\n keyPath: \"textureUrl\"\n });\n } catch (ex) {\n Logger.Error(\"Error while creating object stores. Exception: \" + ex.message);\n handleError();\n }\n }\n };\n }\n // DB has already been created and opened\n else {\n if (successCallback) {\n successCallback();\n }\n }\n }\n }\n /**\n * Loads an image from the database\n * @param url defines the url to load from\n * @param image defines the target DOM image\n */\n loadImage(url, image) {\n const completeURL = Database._ReturnFullUrlLocation(url);\n const saveAndLoadImage = () => {\n if (!this._hasReachedQuota && this._db !== null) {\n // the texture is not yet in the DB, let's try to save it\n this._saveImageIntoDBAsync(completeURL, image);\n }\n // If the texture is not in the DB and we've reached the DB quota limit\n // let's load it directly from the web\n else {\n image.src = url;\n }\n };\n if (!this._mustUpdateRessources) {\n this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);\n }\n // First time we're download the images or update requested in the manifest file by a version change\n else {\n saveAndLoadImage();\n }\n }\n _loadImageFromDBAsync(url, image, notInDBCallback) {\n if (this._isSupported && this._db !== null) {\n let texture;\n const transaction = this._db.transaction([\"textures\"]);\n transaction.onabort = () => {\n image.src = url;\n };\n transaction.oncomplete = () => {\n let blobTextureURL;\n if (texture && typeof URL === \"function\") {\n blobTextureURL = URL.createObjectURL(texture.data);\n image.onerror = () => {\n Logger.Error(\"Error loading image from blob URL: \" + blobTextureURL + \" switching back to web url: \" + url);\n image.src = url;\n };\n image.src = blobTextureURL;\n } else {\n notInDBCallback();\n }\n };\n const getRequest = transaction.objectStore(\"textures\").get(url);\n getRequest.onsuccess = event => {\n texture = event.target.result;\n };\n getRequest.onerror = () => {\n Logger.Error(\"Error loading texture \" + url + \" from DB.\");\n image.src = url;\n };\n } else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or BabylonJS Database is not open.\");\n image.src = url;\n }\n }\n _saveImageIntoDBAsync(url, image) {\n let blob;\n if (this._isSupported) {\n // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on\n const generateBlobUrl = () => {\n let blobTextureURL;\n if (blob && typeof URL === \"function\") {\n try {\n blobTextureURL = URL.createObjectURL(blob);\n } catch (ex) {\n // Chrome is raising a type error if we're setting the oneTimeOnly parameter\n blobTextureURL = URL.createObjectURL(blob);\n }\n }\n if (blobTextureURL) {\n image.src = blobTextureURL;\n }\n };\n if (Database._IsUASupportingBlobStorage) {\n // Create XHR\n const xhr = new WebRequest();\n xhr.open(\"GET\", url);\n xhr.responseType = \"blob\";\n xhr.addEventListener(\"load\", () => {\n if (xhr.status === 200 && this._db) {\n // Blob as response\n blob = xhr.response;\n const transaction = this._db.transaction([\"textures\"], \"readwrite\");\n // the transaction could abort because of a QuotaExceededError error\n transaction.onabort = event => {\n try {\n //backwards compatibility with ts 1.0, srcElement doesn't have an \"error\" according to ts 1.3\n const srcElement = event.target;\n const error = srcElement.error;\n if (error && error.name === \"QuotaExceededError\") {\n this._hasReachedQuota = true;\n }\n } catch (ex) {}\n generateBlobUrl();\n };\n transaction.oncomplete = () => {\n generateBlobUrl();\n };\n const newTexture = {\n textureUrl: url,\n data: blob\n };\n try {\n // Put the blob into the dabase\n const addRequest = transaction.objectStore(\"textures\").put(newTexture);\n addRequest.onsuccess = () => {};\n addRequest.onerror = () => {\n generateBlobUrl();\n };\n } catch (ex) {\n // \"DataCloneError\" generated by Chrome when you try to inject blob into IndexedDB\n if (ex.code === 25) {\n Database._IsUASupportingBlobStorage = false;\n this._enableTexturesOffline = false;\n }\n image.src = url;\n }\n } else {\n image.src = url;\n }\n }, false);\n xhr.addEventListener(\"error\", () => {\n Logger.Error(\"Error in XHR request in BABYLON.Database.\");\n image.src = url;\n }, false);\n xhr.send();\n } else {\n image.src = url;\n }\n } else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\");\n image.src = url;\n }\n }\n _checkVersionFromDB(url, versionLoaded) {\n const updateVersion = () => {\n // the version is not yet in the DB or we need to update it\n this._saveVersionIntoDBAsync(url, versionLoaded);\n };\n this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);\n }\n _loadVersionFromDBAsync(url, callback, updateInDBCallback) {\n if (this._isSupported && this._db) {\n let version;\n try {\n const transaction = this._db.transaction([\"versions\"]);\n transaction.oncomplete = () => {\n if (version) {\n // If the version in the JSON file is different from the version in DB\n if (this._manifestVersionFound !== version.data) {\n this._mustUpdateRessources = true;\n updateInDBCallback();\n } else {\n callback(version.data);\n }\n }\n // version was not found in DB\n else {\n this._mustUpdateRessources = true;\n updateInDBCallback();\n }\n };\n transaction.onabort = () => {\n callback(-1);\n };\n const getRequest = transaction.objectStore(\"versions\").get(url);\n getRequest.onsuccess = event => {\n version = event.target.result;\n };\n getRequest.onerror = () => {\n Logger.Error(\"Error loading version for scene \" + url + \" from DB.\");\n callback(-1);\n };\n } catch (ex) {\n Logger.Error(\"Error while accessing 'versions' object store (READ OP). Exception: \" + ex.message);\n callback(-1);\n }\n } else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\");\n callback(-1);\n }\n }\n _saveVersionIntoDBAsync(url, callback) {\n if (this._isSupported && !this._hasReachedQuota && this._db) {\n try {\n // Open a transaction to the database\n const transaction = this._db.transaction([\"versions\"], \"readwrite\");\n // the transaction could abort because of a QuotaExceededError error\n transaction.onabort = event => {\n try {\n //backwards compatibility with ts 1.0, srcElement doesn't have an \"error\" according to ts 1.3\n const error = event.target[\"error\"];\n if (error && error.name === \"QuotaExceededError\") {\n this._hasReachedQuota = true;\n }\n } catch (ex) {}\n callback(-1);\n };\n transaction.oncomplete = () => {\n callback(this._manifestVersionFound);\n };\n const newVersion = {\n sceneUrl: url,\n data: this._manifestVersionFound\n };\n // Put the scene into the database\n const addRequest = transaction.objectStore(\"versions\").put(newVersion);\n addRequest.onsuccess = () => {};\n addRequest.onerror = () => {\n Logger.Error(\"Error in DB add version request in BABYLON.Database.\");\n };\n } catch (ex) {\n Logger.Error(\"Error while accessing 'versions' object store (WRITE OP). Exception: \" + ex.message);\n callback(-1);\n }\n } else {\n callback(-1);\n }\n }\n /**\n * Loads a file from database\n * @param url defines the URL to load from\n * @param sceneLoaded defines a callback to call on success\n * @param progressCallBack defines a callback to call when progress changed\n * @param errorCallback defines a callback to call on error\n * @param useArrayBuffer defines a boolean to use array buffer instead of text string\n */\n loadFile(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {\n const completeUrl = Database._ReturnFullUrlLocation(url);\n const saveAndLoadFile = () => {\n // the scene is not yet in the DB, let's try to save it\n this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);\n };\n this._checkVersionFromDB(completeUrl, version => {\n if (version !== -1) {\n if (!this._mustUpdateRessources) {\n this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile, progressCallBack);\n } else {\n this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);\n }\n } else {\n if (errorCallback) {\n errorCallback();\n }\n }\n });\n }\n _loadFileAsync(url, callback, notInDBCallback, progressCallBack) {\n if (this._isSupported && this._db) {\n let targetStore;\n if (url.indexOf(\".babylon\") !== -1) {\n targetStore = \"scenes\";\n } else {\n targetStore = \"textures\";\n }\n let file;\n const transaction = this._db.transaction([targetStore]);\n transaction.oncomplete = () => {\n if (file) {\n if (progressCallBack) {\n var _file$data;\n const numberToLoad = ((_file$data = file.data) === null || _file$data === void 0 ? void 0 : _file$data.byteLength) || 0;\n progressCallBack({\n total: numberToLoad,\n loaded: numberToLoad,\n lengthComputable: true\n });\n }\n callback(file.data);\n }\n // file was not found in DB\n else {\n notInDBCallback();\n }\n };\n transaction.onabort = () => {\n notInDBCallback();\n };\n const getRequest = transaction.objectStore(targetStore).get(url);\n getRequest.onsuccess = event => {\n file = event.target.result;\n };\n getRequest.onerror = () => {\n Logger.Error(\"Error loading file \" + url + \" from DB.\");\n notInDBCallback();\n };\n } else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or BabylonJS Database is not open.\");\n callback();\n }\n }\n _saveFileAsync(url, callback, progressCallback, useArrayBuffer, errorCallback) {\n if (this._isSupported) {\n let targetStore;\n if (url.indexOf(\".babylon\") !== -1) {\n targetStore = \"scenes\";\n } else {\n targetStore = \"textures\";\n }\n // Create XHR\n const xhr = new WebRequest();\n let fileData;\n xhr.open(\"GET\", url + (url.match(/\\?/) == null ? \"?\" : \"&\") + Date.now());\n if (useArrayBuffer) {\n xhr.responseType = \"arraybuffer\";\n }\n if (progressCallback) {\n xhr.onprogress = progressCallback;\n }\n xhr.addEventListener(\"load\", () => {\n if (xhr.status === 200 || xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6)) {\n // Blob as response\n fileData = !useArrayBuffer ? xhr.responseText : xhr.response;\n if (!this._hasReachedQuota && this._db) {\n // Open a transaction to the database\n const transaction = this._db.transaction([targetStore], \"readwrite\");\n // the transaction could abort because of a QuotaExceededError error\n transaction.onabort = event => {\n try {\n //backwards compatibility with ts 1.0, srcElement doesn't have an \"error\" according to ts 1.3\n const error = event.target[\"error\"];\n if (error && error.name === \"QuotaExceededError\") {\n this._hasReachedQuota = true;\n }\n } catch (ex) {}\n callback(fileData);\n };\n transaction.oncomplete = () => {\n callback(fileData);\n };\n let newFile;\n if (targetStore === \"scenes\") {\n newFile = {\n sceneUrl: url,\n data: fileData,\n version: this._manifestVersionFound\n };\n } else {\n newFile = {\n textureUrl: url,\n data: fileData\n };\n }\n try {\n // Put the scene into the database\n const addRequest = transaction.objectStore(targetStore).put(newFile);\n addRequest.onsuccess = () => {};\n addRequest.onerror = () => {\n Logger.Error(\"Error in DB add file request in BABYLON.Database.\");\n };\n } catch (ex) {\n callback(fileData);\n }\n } else {\n callback(fileData);\n }\n } else {\n if (xhr.status >= 400 && errorCallback) {\n errorCallback(xhr);\n } else {\n callback();\n }\n }\n }, false);\n xhr.addEventListener(\"error\", () => {\n Logger.Error(\"error on XHR request.\");\n errorCallback && errorCallback();\n }, false);\n xhr.send();\n } else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\");\n errorCallback && errorCallback();\n }\n }\n /**\n * Validates if xhr data is correct\n * @param xhr defines the request to validate\n * @param dataType defines the expected data type\n * @returns true if data is correct\n */\n static _ValidateXHRData(xhr, dataType = 7) {\n // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all\n try {\n if (dataType & 1) {\n if (xhr.responseText && xhr.responseText.length > 0) {\n return true;\n } else if (dataType === 1) {\n return false;\n }\n }\n if (dataType & 2) {\n // Check header width and height since there is no \"TGA\" magic number\n const tgaHeader = GetTGAHeader(xhr.response);\n if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {\n return true;\n } else if (dataType === 2) {\n return false;\n }\n }\n if (dataType & 4) {\n // Check for the \"DDS\" magic number\n const ddsHeader = new Uint8Array(xhr.response, 0, 3);\n if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {\n return true;\n } else {\n return false;\n }\n }\n } catch (e) {\n // Global protection\n }\n return false;\n }\n}\n/** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */\nDatabase._IsUASupportingBlobStorage = true;\n/**\n * Gets a boolean indicating if Database storage is enabled (off by default)\n */\nDatabase.IDBStorageEnabled = false;\nDatabase._ParseURL = url => {\n const a = document.createElement(\"a\");\n a.href = url;\n const urlWithoutHash = url.substring(0, url.lastIndexOf(\"#\"));\n const fileName = url.substring(urlWithoutHash.lastIndexOf(\"/\") + 1, url.length);\n const absLocation = url.substring(0, url.indexOf(fileName, 0));\n return absLocation;\n};\nDatabase._ReturnFullUrlLocation = url => {\n if (url.indexOf(\"http:/\") === -1 && url.indexOf(\"https:/\") === -1 && typeof window !== \"undefined\") {\n return Database._ParseURL(window.location.href) + url;\n } else {\n return url;\n }\n};","map":{"version":3,"names":["Tools","Logger","GetTGAHeader","WebRequest","AbstractEngine","OfflineProviderFactory","urlToScene","callbackManifestChecked","disableManifestCheck","Database","enableSceneOffline","_enableSceneOffline","enableTexturesOffline","_enableTexturesOffline","constructor","_idbFactory","indexedDB","undefined","_currentSceneUrl","_ReturnFullUrlLocation","_db","_manifestVersionFound","_mustUpdateRessources","_hasReachedQuota","IDBStorageEnabled","SetImmediate","_checkManifestFile","noManifestFile","createManifestURL","URL","indexOf","url","pathname","toString","e","timeStampUsed","manifestURL","xhr","navigator","onLine","match","Date","now","open","addEventListener","status","_ValidateXHRData","manifestFile","JSON","parse","response","_IsUASupportingBlobStorage","version","isNaN","parseInt","ex","retryManifestURL","send","Error","successCallback","errorCallback","handleError","_isSupported","request","onerror","onblocked","onsuccess","result","onupgradeneeded","event","target","createObjectStore","keyPath","message","loadImage","image","completeURL","saveAndLoadImage","_saveImageIntoDBAsync","src","_loadImageFromDBAsync","notInDBCallback","texture","transaction","onabort","oncomplete","blobTextureURL","createObjectURL","data","getRequest","objectStore","get","blob","generateBlobUrl","responseType","srcElement","error","name","newTexture","textureUrl","addRequest","put","code","_checkVersionFromDB","versionLoaded","updateVersion","_saveVersionIntoDBAsync","_loadVersionFromDBAsync","callback","updateInDBCallback","newVersion","sceneUrl","loadFile","sceneLoaded","progressCallBack","useArrayBuffer","completeUrl","saveAndLoadFile","_saveFileAsync","_loadFileAsync","targetStore","file","_file$data","numberToLoad","byteLength","total","loaded","lengthComputable","progressCallback","fileData","onprogress","responseText","newFile","dataType","length","tgaHeader","width","height","ddsHeader","Uint8Array","_ParseURL","a","document","createElement","href","urlWithoutHash","substring","lastIndexOf","fileName","absLocation","window","location"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Offline/database.js"],"sourcesContent":["import { Tools } from \"../Misc/tools.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { GetTGAHeader } from \"../Misc/tga.js\";\nimport { WebRequest } from \"../Misc/webRequest.js\";\nimport { AbstractEngine } from \"../Engines/abstractEngine.js\";\n// Sets the default offline provider to Babylon.js\nAbstractEngine.OfflineProviderFactory = (urlToScene, callbackManifestChecked, disableManifestCheck = false) => {\n return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);\n};\n/**\n * Class used to enable access to IndexedDB\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeCached\n */\nexport class Database {\n /**\n * Gets a boolean indicating if scene must be saved in the database\n */\n get enableSceneOffline() {\n return this._enableSceneOffline;\n }\n /**\n * Gets a boolean indicating if textures must be saved in the database\n */\n get enableTexturesOffline() {\n return this._enableTexturesOffline;\n }\n /**\n * Creates a new Database\n * @param urlToScene defines the url to load the scene\n * @param callbackManifestChecked defines the callback to use when manifest is checked\n * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)\n */\n constructor(urlToScene, callbackManifestChecked, disableManifestCheck = false) {\n // Handling various flavors of prefixed version of IndexedDB\n this._idbFactory = (typeof indexedDB !== \"undefined\" ? indexedDB : undefined);\n this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);\n this._db = null;\n this._enableSceneOffline = false;\n this._enableTexturesOffline = false;\n this._manifestVersionFound = 0;\n this._mustUpdateRessources = false;\n this._hasReachedQuota = false;\n if (!Database.IDBStorageEnabled) {\n callbackManifestChecked(true);\n }\n else {\n if (disableManifestCheck) {\n this._enableSceneOffline = true;\n this._enableTexturesOffline = true;\n this._manifestVersionFound = 1;\n Tools.SetImmediate(() => {\n callbackManifestChecked(true);\n });\n }\n else {\n this._checkManifestFile(callbackManifestChecked);\n }\n }\n }\n _checkManifestFile(callbackManifestChecked) {\n const noManifestFile = () => {\n this._enableSceneOffline = false;\n this._enableTexturesOffline = false;\n callbackManifestChecked(false);\n };\n const createManifestURL = () => {\n try {\n // make sure we have a valid URL.\n if (typeof URL === \"function\" && this._currentSceneUrl.indexOf(\"http\") === 0) {\n // we don't have the base url, so the URL string must have a protocol\n const url = new URL(this._currentSceneUrl);\n url.pathname += \".manifest\";\n return url.toString();\n }\n }\n catch (e) {\n // defensive - if this fails for any reason, fall back to the older method\n }\n return `${this._currentSceneUrl}.manifest`;\n };\n let timeStampUsed = false;\n let manifestURL = createManifestURL();\n const xhr = new WebRequest();\n if (navigator.onLine) {\n // Adding a timestamp to by-pass browsers' cache\n timeStampUsed = true;\n manifestURL = manifestURL + (manifestURL.match(/\\?/) == null ? \"?\" : \"&\") + Date.now();\n }\n xhr.open(\"GET\", manifestURL);\n xhr.addEventListener(\"load\", () => {\n if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {\n try {\n const manifestFile = JSON.parse(xhr.response);\n this._enableSceneOffline = manifestFile.enableSceneOffline;\n this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database._IsUASupportingBlobStorage;\n if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {\n this._manifestVersionFound = manifestFile.version;\n }\n callbackManifestChecked(true);\n }\n catch (ex) {\n noManifestFile();\n }\n }\n else {\n noManifestFile();\n }\n }, false);\n xhr.addEventListener(\"error\", () => {\n if (timeStampUsed) {\n timeStampUsed = false;\n // Let's retry without the timeStamp\n // It could fail when coupled with HTML5 Offline API\n const retryManifestURL = createManifestURL();\n xhr.open(\"GET\", retryManifestURL);\n xhr.send();\n }\n else {\n noManifestFile();\n }\n }, false);\n try {\n xhr.send();\n }\n catch (ex) {\n Logger.Error(\"Error on XHR send request.\");\n callbackManifestChecked(false);\n }\n }\n /**\n * Open the database and make it available\n * @param successCallback defines the callback to call on success\n * @param errorCallback defines the callback to call on error\n */\n open(successCallback, errorCallback) {\n const handleError = () => {\n this._isSupported = false;\n if (errorCallback) {\n errorCallback();\n }\n };\n if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {\n // Your browser doesn't support IndexedDB\n this._isSupported = false;\n if (errorCallback) {\n errorCallback();\n }\n }\n else {\n // If the DB hasn't been opened or created yet\n if (!this._db) {\n this._hasReachedQuota = false;\n this._isSupported = true;\n const request = this._idbFactory.open(\"babylonjs\", 1);\n // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB\n request.onerror = () => {\n handleError();\n };\n // executes when a version change transaction cannot complete due to other active transactions\n request.onblocked = () => {\n Logger.Error(\"IDB request blocked. Please reload the page.\");\n handleError();\n };\n // DB has been opened successfully\n request.onsuccess = () => {\n this._db = request.result;\n successCallback();\n };\n // Initialization of the DB. Creating Scenes & Textures stores\n request.onupgradeneeded = (event) => {\n this._db = event.target.result;\n if (this._db) {\n try {\n this._db.createObjectStore(\"scenes\", { keyPath: \"sceneUrl\" });\n this._db.createObjectStore(\"versions\", { keyPath: \"sceneUrl\" });\n this._db.createObjectStore(\"textures\", { keyPath: \"textureUrl\" });\n }\n catch (ex) {\n Logger.Error(\"Error while creating object stores. Exception: \" + ex.message);\n handleError();\n }\n }\n };\n }\n // DB has already been created and opened\n else {\n if (successCallback) {\n successCallback();\n }\n }\n }\n }\n /**\n * Loads an image from the database\n * @param url defines the url to load from\n * @param image defines the target DOM image\n */\n loadImage(url, image) {\n const completeURL = Database._ReturnFullUrlLocation(url);\n const saveAndLoadImage = () => {\n if (!this._hasReachedQuota && this._db !== null) {\n // the texture is not yet in the DB, let's try to save it\n this._saveImageIntoDBAsync(completeURL, image);\n }\n // If the texture is not in the DB and we've reached the DB quota limit\n // let's load it directly from the web\n else {\n image.src = url;\n }\n };\n if (!this._mustUpdateRessources) {\n this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);\n }\n // First time we're download the images or update requested in the manifest file by a version change\n else {\n saveAndLoadImage();\n }\n }\n _loadImageFromDBAsync(url, image, notInDBCallback) {\n if (this._isSupported && this._db !== null) {\n let texture;\n const transaction = this._db.transaction([\"textures\"]);\n transaction.onabort = () => {\n image.src = url;\n };\n transaction.oncomplete = () => {\n let blobTextureURL;\n if (texture && typeof URL === \"function\") {\n blobTextureURL = URL.createObjectURL(texture.data);\n image.onerror = () => {\n Logger.Error(\"Error loading image from blob URL: \" + blobTextureURL + \" switching back to web url: \" + url);\n image.src = url;\n };\n image.src = blobTextureURL;\n }\n else {\n notInDBCallback();\n }\n };\n const getRequest = transaction.objectStore(\"textures\").get(url);\n getRequest.onsuccess = (event) => {\n texture = event.target.result;\n };\n getRequest.onerror = () => {\n Logger.Error(\"Error loading texture \" + url + \" from DB.\");\n image.src = url;\n };\n }\n else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or BabylonJS Database is not open.\");\n image.src = url;\n }\n }\n _saveImageIntoDBAsync(url, image) {\n let blob;\n if (this._isSupported) {\n // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on\n const generateBlobUrl = () => {\n let blobTextureURL;\n if (blob && typeof URL === \"function\") {\n try {\n blobTextureURL = URL.createObjectURL(blob);\n }\n catch (ex) {\n // Chrome is raising a type error if we're setting the oneTimeOnly parameter\n blobTextureURL = URL.createObjectURL(blob);\n }\n }\n if (blobTextureURL) {\n image.src = blobTextureURL;\n }\n };\n if (Database._IsUASupportingBlobStorage) {\n // Create XHR\n const xhr = new WebRequest();\n xhr.open(\"GET\", url);\n xhr.responseType = \"blob\";\n xhr.addEventListener(\"load\", () => {\n if (xhr.status === 200 && this._db) {\n // Blob as response\n blob = xhr.response;\n const transaction = this._db.transaction([\"textures\"], \"readwrite\");\n // the transaction could abort because of a QuotaExceededError error\n transaction.onabort = (event) => {\n try {\n //backwards compatibility with ts 1.0, srcElement doesn't have an \"error\" according to ts 1.3\n const srcElement = event.target;\n const error = srcElement.error;\n if (error && error.name === \"QuotaExceededError\") {\n this._hasReachedQuota = true;\n }\n }\n catch (ex) { }\n generateBlobUrl();\n };\n transaction.oncomplete = () => {\n generateBlobUrl();\n };\n const newTexture = { textureUrl: url, data: blob };\n try {\n // Put the blob into the dabase\n const addRequest = transaction.objectStore(\"textures\").put(newTexture);\n addRequest.onsuccess = () => { };\n addRequest.onerror = () => {\n generateBlobUrl();\n };\n }\n catch (ex) {\n // \"DataCloneError\" generated by Chrome when you try to inject blob into IndexedDB\n if (ex.code === 25) {\n Database._IsUASupportingBlobStorage = false;\n this._enableTexturesOffline = false;\n }\n image.src = url;\n }\n }\n else {\n image.src = url;\n }\n }, false);\n xhr.addEventListener(\"error\", () => {\n Logger.Error(\"Error in XHR request in BABYLON.Database.\");\n image.src = url;\n }, false);\n xhr.send();\n }\n else {\n image.src = url;\n }\n }\n else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\");\n image.src = url;\n }\n }\n _checkVersionFromDB(url, versionLoaded) {\n const updateVersion = () => {\n // the version is not yet in the DB or we need to update it\n this._saveVersionIntoDBAsync(url, versionLoaded);\n };\n this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);\n }\n _loadVersionFromDBAsync(url, callback, updateInDBCallback) {\n if (this._isSupported && this._db) {\n let version;\n try {\n const transaction = this._db.transaction([\"versions\"]);\n transaction.oncomplete = () => {\n if (version) {\n // If the version in the JSON file is different from the version in DB\n if (this._manifestVersionFound !== version.data) {\n this._mustUpdateRessources = true;\n updateInDBCallback();\n }\n else {\n callback(version.data);\n }\n }\n // version was not found in DB\n else {\n this._mustUpdateRessources = true;\n updateInDBCallback();\n }\n };\n transaction.onabort = () => {\n callback(-1);\n };\n const getRequest = transaction.objectStore(\"versions\").get(url);\n getRequest.onsuccess = (event) => {\n version = event.target.result;\n };\n getRequest.onerror = () => {\n Logger.Error(\"Error loading version for scene \" + url + \" from DB.\");\n callback(-1);\n };\n }\n catch (ex) {\n Logger.Error(\"Error while accessing 'versions' object store (READ OP). Exception: \" + ex.message);\n callback(-1);\n }\n }\n else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\");\n callback(-1);\n }\n }\n _saveVersionIntoDBAsync(url, callback) {\n if (this._isSupported && !this._hasReachedQuota && this._db) {\n try {\n // Open a transaction to the database\n const transaction = this._db.transaction([\"versions\"], \"readwrite\");\n // the transaction could abort because of a QuotaExceededError error\n transaction.onabort = (event) => {\n try {\n //backwards compatibility with ts 1.0, srcElement doesn't have an \"error\" according to ts 1.3\n const error = event.target[\"error\"];\n if (error && error.name === \"QuotaExceededError\") {\n this._hasReachedQuota = true;\n }\n }\n catch (ex) { }\n callback(-1);\n };\n transaction.oncomplete = () => {\n callback(this._manifestVersionFound);\n };\n const newVersion = { sceneUrl: url, data: this._manifestVersionFound };\n // Put the scene into the database\n const addRequest = transaction.objectStore(\"versions\").put(newVersion);\n addRequest.onsuccess = () => { };\n addRequest.onerror = () => {\n Logger.Error(\"Error in DB add version request in BABYLON.Database.\");\n };\n }\n catch (ex) {\n Logger.Error(\"Error while accessing 'versions' object store (WRITE OP). Exception: \" + ex.message);\n callback(-1);\n }\n }\n else {\n callback(-1);\n }\n }\n /**\n * Loads a file from database\n * @param url defines the URL to load from\n * @param sceneLoaded defines a callback to call on success\n * @param progressCallBack defines a callback to call when progress changed\n * @param errorCallback defines a callback to call on error\n * @param useArrayBuffer defines a boolean to use array buffer instead of text string\n */\n loadFile(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {\n const completeUrl = Database._ReturnFullUrlLocation(url);\n const saveAndLoadFile = () => {\n // the scene is not yet in the DB, let's try to save it\n this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);\n };\n this._checkVersionFromDB(completeUrl, (version) => {\n if (version !== -1) {\n if (!this._mustUpdateRessources) {\n this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile, progressCallBack);\n }\n else {\n this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);\n }\n }\n else {\n if (errorCallback) {\n errorCallback();\n }\n }\n });\n }\n _loadFileAsync(url, callback, notInDBCallback, progressCallBack) {\n if (this._isSupported && this._db) {\n let targetStore;\n if (url.indexOf(\".babylon\") !== -1) {\n targetStore = \"scenes\";\n }\n else {\n targetStore = \"textures\";\n }\n let file;\n const transaction = this._db.transaction([targetStore]);\n transaction.oncomplete = () => {\n if (file) {\n if (progressCallBack) {\n const numberToLoad = file.data?.byteLength || 0;\n progressCallBack({\n total: numberToLoad,\n loaded: numberToLoad,\n lengthComputable: true,\n });\n }\n callback(file.data);\n }\n // file was not found in DB\n else {\n notInDBCallback();\n }\n };\n transaction.onabort = () => {\n notInDBCallback();\n };\n const getRequest = transaction.objectStore(targetStore).get(url);\n getRequest.onsuccess = (event) => {\n file = event.target.result;\n };\n getRequest.onerror = () => {\n Logger.Error(\"Error loading file \" + url + \" from DB.\");\n notInDBCallback();\n };\n }\n else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or BabylonJS Database is not open.\");\n callback();\n }\n }\n _saveFileAsync(url, callback, progressCallback, useArrayBuffer, errorCallback) {\n if (this._isSupported) {\n let targetStore;\n if (url.indexOf(\".babylon\") !== -1) {\n targetStore = \"scenes\";\n }\n else {\n targetStore = \"textures\";\n }\n // Create XHR\n const xhr = new WebRequest();\n let fileData;\n xhr.open(\"GET\", url + (url.match(/\\?/) == null ? \"?\" : \"&\") + Date.now());\n if (useArrayBuffer) {\n xhr.responseType = \"arraybuffer\";\n }\n if (progressCallback) {\n xhr.onprogress = progressCallback;\n }\n xhr.addEventListener(\"load\", () => {\n if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {\n // Blob as response\n fileData = !useArrayBuffer ? xhr.responseText : xhr.response;\n if (!this._hasReachedQuota && this._db) {\n // Open a transaction to the database\n const transaction = this._db.transaction([targetStore], \"readwrite\");\n // the transaction could abort because of a QuotaExceededError error\n transaction.onabort = (event) => {\n try {\n //backwards compatibility with ts 1.0, srcElement doesn't have an \"error\" according to ts 1.3\n const error = event.target[\"error\"];\n if (error && error.name === \"QuotaExceededError\") {\n this._hasReachedQuota = true;\n }\n }\n catch (ex) { }\n callback(fileData);\n };\n transaction.oncomplete = () => {\n callback(fileData);\n };\n let newFile;\n if (targetStore === \"scenes\") {\n newFile = { sceneUrl: url, data: fileData, version: this._manifestVersionFound };\n }\n else {\n newFile = { textureUrl: url, data: fileData };\n }\n try {\n // Put the scene into the database\n const addRequest = transaction.objectStore(targetStore).put(newFile);\n addRequest.onsuccess = () => { };\n addRequest.onerror = () => {\n Logger.Error(\"Error in DB add file request in BABYLON.Database.\");\n };\n }\n catch (ex) {\n callback(fileData);\n }\n }\n else {\n callback(fileData);\n }\n }\n else {\n if (xhr.status >= 400 && errorCallback) {\n errorCallback(xhr);\n }\n else {\n callback();\n }\n }\n }, false);\n xhr.addEventListener(\"error\", () => {\n Logger.Error(\"error on XHR request.\");\n errorCallback && errorCallback();\n }, false);\n xhr.send();\n }\n else {\n Logger.Error(\"Error: IndexedDB not supported by your browser or Babylon.js database is not open.\");\n errorCallback && errorCallback();\n }\n }\n /**\n * Validates if xhr data is correct\n * @param xhr defines the request to validate\n * @param dataType defines the expected data type\n * @returns true if data is correct\n */\n static _ValidateXHRData(xhr, dataType = 7) {\n // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all\n try {\n if (dataType & 1) {\n if (xhr.responseText && xhr.responseText.length > 0) {\n return true;\n }\n else if (dataType === 1) {\n return false;\n }\n }\n if (dataType & 2) {\n // Check header width and height since there is no \"TGA\" magic number\n const tgaHeader = GetTGAHeader(xhr.response);\n if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {\n return true;\n }\n else if (dataType === 2) {\n return false;\n }\n }\n if (dataType & 4) {\n // Check for the \"DDS\" magic number\n const ddsHeader = new Uint8Array(xhr.response, 0, 3);\n if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {\n return true;\n }\n else {\n return false;\n }\n }\n }\n catch (e) {\n // Global protection\n }\n return false;\n }\n}\n/** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */\nDatabase._IsUASupportingBlobStorage = true;\n/**\n * Gets a boolean indicating if Database storage is enabled (off by default)\n */\nDatabase.IDBStorageEnabled = false;\nDatabase._ParseURL = (url) => {\n const a = document.createElement(\"a\");\n a.href = url;\n const urlWithoutHash = url.substring(0, url.lastIndexOf(\"#\"));\n const fileName = url.substring(urlWithoutHash.lastIndexOf(\"/\") + 1, url.length);\n const absLocation = url.substring(0, url.indexOf(fileName, 0));\n return absLocation;\n};\nDatabase._ReturnFullUrlLocation = (url) => {\n if (url.indexOf(\"http:/\") === -1 && url.indexOf(\"https:/\") === -1 && typeof window !== \"undefined\") {\n return Database._ParseURL(window.location.href) + url;\n }\n else {\n return url;\n }\n};\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,kBAAkB;AACxC,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,cAAc,QAAQ,8BAA8B;AAC7D;AACAA,cAAc,CAACC,sBAAsB,GAAG,CAACC,UAAU,EAAEC,uBAAuB,EAAEC,oBAAoB,GAAG,KAAK,KAAK;EAC3G,OAAO,IAAIC,QAAQ,CAACH,UAAU,EAAEC,uBAAuB,EAAEC,oBAAoB,CAAC;AAClF,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,CAAC;EAClB;AACJ;AACA;EACI,IAAIC,kBAAkBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACC,mBAAmB;EACnC;EACA;AACJ;AACA;EACI,IAAIC,qBAAqBA,CAAA,EAAG;IACxB,OAAO,IAAI,CAACC,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