database.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import type { IOfflineProvider } from "./IOfflineProvider";
  2. /**
  3. * Class used to enable access to IndexedDB
  4. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeCached
  5. */
  6. export declare class Database implements IOfflineProvider {
  7. private _currentSceneUrl;
  8. private _db;
  9. private _enableSceneOffline;
  10. private _enableTexturesOffline;
  11. private _manifestVersionFound;
  12. private _mustUpdateRessources;
  13. private _hasReachedQuota;
  14. private _isSupported;
  15. private _idbFactory;
  16. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  17. private static _IsUASupportingBlobStorage;
  18. /**
  19. * Gets a boolean indicating if Database storage is enabled (off by default)
  20. */
  21. static IDBStorageEnabled: boolean;
  22. /**
  23. * Gets a boolean indicating if scene must be saved in the database
  24. */
  25. get enableSceneOffline(): boolean;
  26. /**
  27. * Gets a boolean indicating if textures must be saved in the database
  28. */
  29. get enableTexturesOffline(): boolean;
  30. /**
  31. * Creates a new Database
  32. * @param urlToScene defines the url to load the scene
  33. * @param callbackManifestChecked defines the callback to use when manifest is checked
  34. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  35. */
  36. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  37. private static _ParseURL;
  38. private static _ReturnFullUrlLocation;
  39. private _checkManifestFile;
  40. /**
  41. * Open the database and make it available
  42. * @param successCallback defines the callback to call on success
  43. * @param errorCallback defines the callback to call on error
  44. */
  45. open(successCallback: () => void, errorCallback: () => void): void;
  46. /**
  47. * Loads an image from the database
  48. * @param url defines the url to load from
  49. * @param image defines the target DOM image
  50. */
  51. loadImage(url: string, image: HTMLImageElement): void;
  52. private _loadImageFromDBAsync;
  53. private _saveImageIntoDBAsync;
  54. private _checkVersionFromDB;
  55. private _loadVersionFromDBAsync;
  56. private _saveVersionIntoDBAsync;
  57. /**
  58. * Loads a file from database
  59. * @param url defines the URL to load from
  60. * @param sceneLoaded defines a callback to call on success
  61. * @param progressCallBack defines a callback to call when progress changed
  62. * @param errorCallback defines a callback to call on error
  63. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64. */
  65. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66. private _loadFileAsync;
  67. private _saveFileAsync;
  68. /**
  69. * Validates if xhr data is correct
  70. * @param xhr defines the request to validate
  71. * @param dataType defines the expected data type
  72. * @returns true if data is correct
  73. */
  74. private static _ValidateXHRData;
  75. }