@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
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { default as BaseMediaManager } from './base-media-manager';
|
|
2
2
|
import { MediaItem, PaginationOptions, SearchOptions } from '../types';
|
|
3
3
|
|
|
4
|
+
export type BrowserMediaManagerOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* IndexedDB database name. Use this to namespace per tenant/user/project.
|
|
7
|
+
* Defaults to "mediaStore" for backwards compatibility.
|
|
8
|
+
*/
|
|
9
|
+
dbName?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Object store name within the database.
|
|
12
|
+
* Defaults to "mediaItems" for backwards compatibility.
|
|
13
|
+
*/
|
|
14
|
+
storeName?: string;
|
|
15
|
+
};
|
|
4
16
|
declare class BrowserMediaManager extends BaseMediaManager {
|
|
5
17
|
private dbName;
|
|
6
18
|
private storeName;
|
|
7
19
|
private db;
|
|
20
|
+
constructor(options?: BrowserMediaManagerOptions);
|
|
8
21
|
private initDB;
|
|
9
22
|
private getStore;
|
|
23
|
+
/**
|
|
24
|
+
* Clears all items from the object store within this manager's database.
|
|
25
|
+
* This is scoped to the manager's dbName/storeName (safe for multi-tenant namespaces).
|
|
26
|
+
*/
|
|
27
|
+
clearStore(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes the entire IndexedDB database used by this manager.
|
|
30
|
+
* Note: Any other tabs/instances using the same dbName may be affected.
|
|
31
|
+
*/
|
|
32
|
+
dropDatabase(): Promise<void>;
|
|
10
33
|
private convertArrayBufferToBlob;
|
|
11
34
|
addItem(item: Omit<MediaItem, 'id'>): Promise<MediaItem>;
|
|
12
35
|
addItems(items: Omit<MediaItem, 'id'>[]): Promise<MediaItem[]>;
|
package/dist/index.js
CHANGED
|
@@ -21818,11 +21818,13 @@ const useEditorManager = () => {
|
|
|
21818
21818
|
class BaseMediaManager {
|
|
21819
21819
|
}
|
|
21820
21820
|
class BrowserMediaManager extends BaseMediaManager {
|
|
21821
|
-
constructor() {
|
|
21822
|
-
super(
|
|
21823
|
-
__publicField(this, "dbName"
|
|
21824
|
-
__publicField(this, "storeName"
|
|
21821
|
+
constructor(options) {
|
|
21822
|
+
super();
|
|
21823
|
+
__publicField(this, "dbName");
|
|
21824
|
+
__publicField(this, "storeName");
|
|
21825
21825
|
__publicField(this, "db", null);
|
|
21826
|
+
this.dbName = (options == null ? void 0 : options.dbName) ?? "mediaStore";
|
|
21827
|
+
this.storeName = (options == null ? void 0 : options.storeName) ?? "mediaItems";
|
|
21826
21828
|
}
|
|
21827
21829
|
async initDB() {
|
|
21828
21830
|
if (this.db) return this.db;
|
|
@@ -21847,6 +21849,36 @@ class BrowserMediaManager extends BaseMediaManager {
|
|
|
21847
21849
|
const transaction = db.transaction(this.storeName, mode);
|
|
21848
21850
|
return transaction.objectStore(this.storeName);
|
|
21849
21851
|
}
|
|
21852
|
+
/**
|
|
21853
|
+
* Clears all items from the object store within this manager's database.
|
|
21854
|
+
* This is scoped to the manager's dbName/storeName (safe for multi-tenant namespaces).
|
|
21855
|
+
*/
|
|
21856
|
+
async clearStore() {
|
|
21857
|
+
const store = await this.getStore("readwrite");
|
|
21858
|
+
await new Promise((resolve, reject) => {
|
|
21859
|
+
const request = store.clear();
|
|
21860
|
+
request.onsuccess = () => resolve();
|
|
21861
|
+
request.onerror = () => reject(request.error);
|
|
21862
|
+
});
|
|
21863
|
+
}
|
|
21864
|
+
/**
|
|
21865
|
+
* Deletes the entire IndexedDB database used by this manager.
|
|
21866
|
+
* Note: Any other tabs/instances using the same dbName may be affected.
|
|
21867
|
+
*/
|
|
21868
|
+
async dropDatabase() {
|
|
21869
|
+
if (this.db) {
|
|
21870
|
+
this.db.close();
|
|
21871
|
+
this.db = null;
|
|
21872
|
+
}
|
|
21873
|
+
await new Promise((resolve, reject) => {
|
|
21874
|
+
const request = indexedDB.deleteDatabase(this.dbName);
|
|
21875
|
+
request.onsuccess = () => resolve();
|
|
21876
|
+
request.onerror = () => reject(request.error);
|
|
21877
|
+
request.onblocked = () => {
|
|
21878
|
+
reject(new Error(`Failed to delete IndexedDB database "${this.dbName}" (blocked)`));
|
|
21879
|
+
};
|
|
21880
|
+
});
|
|
21881
|
+
}
|
|
21850
21882
|
async convertArrayBufferToBlob(arrayBuffer, type) {
|
|
21851
21883
|
return new Blob([arrayBuffer], { type });
|
|
21852
21884
|
}
|