Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import { IndexedDbModelStore } from "./IndexedDbModelStore";
/**
* Recommended {@link PersistenceInterface} for browsers and MV3 service workers.
*
* Wires {@link IndexedDbModelStore} as the primary model store. IndexedDB is available in MV3
* service workers, so this is the stock persistence for extension backgrounds. Pass an instance
* to {@link PassmanClient.createInstance}:
*
* ```ts
* const persistence = new IndexedDbPersistenceService({ autoRestoreOnReconstruction: true });
* const client = await PassmanClient.createInstance(serverData, undefined, undefined, persistence);
* ```
*
* Does not configure the legacy request cache or decrypted-data cache; provide those via a custom
* PersistenceInterface if you still need them.
*/
export class IndexedDbPersistenceService {
modelStore;
autoRestore;
constructor(options = {}) {
this.modelStore = new IndexedDbModelStore(options.dbName);
this.autoRestore = options.autoRestoreOnReconstruction ?? false;
}
autoRestoreOnReconstruction() {
return this.autoRestore;
}
getModelStore() {
return this.modelStore;
}
getRequestCacheHandler() {
return undefined;
}
getDecryptedDataCacheHandler() {
return undefined;
}
}
|