@twick/video-editor 0.15.29 → 0.15.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/media-manager/browser-media-manager.d.ts +23 -0
- package/dist/index.js +36 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -21816,11 +21816,13 @@ const useEditorManager = () => {
|
|
|
21816
21816
|
class BaseMediaManager {
|
|
21817
21817
|
}
|
|
21818
21818
|
class BrowserMediaManager extends BaseMediaManager {
|
|
21819
|
-
constructor() {
|
|
21820
|
-
super(
|
|
21821
|
-
__publicField(this, "dbName"
|
|
21822
|
-
__publicField(this, "storeName"
|
|
21819
|
+
constructor(options) {
|
|
21820
|
+
super();
|
|
21821
|
+
__publicField(this, "dbName");
|
|
21822
|
+
__publicField(this, "storeName");
|
|
21823
21823
|
__publicField(this, "db", null);
|
|
21824
|
+
this.dbName = (options == null ? void 0 : options.dbName) ?? "mediaStore";
|
|
21825
|
+
this.storeName = (options == null ? void 0 : options.storeName) ?? "mediaItems";
|
|
21824
21826
|
}
|
|
21825
21827
|
async initDB() {
|
|
21826
21828
|
if (this.db) return this.db;
|
|
@@ -21845,6 +21847,36 @@ class BrowserMediaManager extends BaseMediaManager {
|
|
|
21845
21847
|
const transaction = db.transaction(this.storeName, mode);
|
|
21846
21848
|
return transaction.objectStore(this.storeName);
|
|
21847
21849
|
}
|
|
21850
|
+
/**
|
|
21851
|
+
* Clears all items from the object store within this manager's database.
|
|
21852
|
+
* This is scoped to the manager's dbName/storeName (safe for multi-tenant namespaces).
|
|
21853
|
+
*/
|
|
21854
|
+
async clearStore() {
|
|
21855
|
+
const store = await this.getStore("readwrite");
|
|
21856
|
+
await new Promise((resolve, reject) => {
|
|
21857
|
+
const request = store.clear();
|
|
21858
|
+
request.onsuccess = () => resolve();
|
|
21859
|
+
request.onerror = () => reject(request.error);
|
|
21860
|
+
});
|
|
21861
|
+
}
|
|
21862
|
+
/**
|
|
21863
|
+
* Deletes the entire IndexedDB database used by this manager.
|
|
21864
|
+
* Note: Any other tabs/instances using the same dbName may be affected.
|
|
21865
|
+
*/
|
|
21866
|
+
async dropDatabase() {
|
|
21867
|
+
if (this.db) {
|
|
21868
|
+
this.db.close();
|
|
21869
|
+
this.db = null;
|
|
21870
|
+
}
|
|
21871
|
+
await new Promise((resolve, reject) => {
|
|
21872
|
+
const request = indexedDB.deleteDatabase(this.dbName);
|
|
21873
|
+
request.onsuccess = () => resolve();
|
|
21874
|
+
request.onerror = () => reject(request.error);
|
|
21875
|
+
request.onblocked = () => {
|
|
21876
|
+
reject(new Error(`Failed to delete IndexedDB database "${this.dbName}" (blocked)`));
|
|
21877
|
+
};
|
|
21878
|
+
});
|
|
21879
|
+
}
|
|
21848
21880
|
async convertArrayBufferToBlob(arrayBuffer, type) {
|
|
21849
21881
|
return new Blob([arrayBuffer], { type });
|
|
21850
21882
|
}
|