@@ -45,11 +45,11 @@ export interface IDBCacheConfig {
4545 /**
4646 * Sensitive identifier used for securely encrypting data.
4747 */
48- cacheKey : string ;
48+ cacheKey ? : string ;
4949 /**
5050 * Unique value (not sensitive) used to invalidate old cache entries.
5151 */
52- cacheBuster : string ;
52+ cacheBuster ? : string ;
5353 /**
5454 * Size of each chunk in bytes. When an item exceeds this size,
5555 * it splits into multiple chunks. Defaults to 25000 bytes.
@@ -114,11 +114,11 @@ export class IDBCache implements IDBCacheInterface {
114114 private gcTime : number ;
115115 private cleanupIntervalId : number | undefined ;
116116
117- private cacheKey : string ;
117+ private cacheKey ?: string ;
118+ private cacheBuster : string ;
118119 private chunkSize : number ;
119120 private cleanupInterval : number ;
120121 private pbkdf2Iterations : number ;
121- private cacheBuster : string ;
122122 private debug : boolean ;
123123 private maxTotalChunks ?: number ;
124124 private priority : "normal" | "low" = "normal" ;
@@ -139,7 +139,7 @@ export class IDBCache implements IDBCacheInterface {
139139
140140 this . storeName = "cache" ;
141141 this . cacheKey = cacheKey ;
142- this . cacheBuster = cacheBuster ;
142+ this . cacheBuster = cacheBuster || "" ;
143143 this . debug = debug ;
144144 this . gcTime = gcTime ;
145145 this . chunkSize = chunkSize ;
@@ -189,8 +189,8 @@ export class IDBCache implements IDBCacheInterface {
189189 * @throws {WorkerInitializationError } If the worker fails to initialize.
190190 */
191191 private async initWorker (
192- cacheKey : string ,
193- cacheBuster : string
192+ cacheKey ? : string ,
193+ cacheBuster ? : string
194194 ) : Promise < void > {
195195 if ( this . workerReadyPromise ) {
196196 return this . workerReadyPromise ;
@@ -612,9 +612,6 @@ export class IDBCache implements IDBCacheInterface {
612612 const isLastChunk = chunkIndex === totalChunks - 1 ;
613613
614614 if ( existingChunkKeysSet . has ( chunkKey ) ) {
615- if ( this . priority === "low" ) {
616- await waitForAnimationFrame ( ) ;
617- }
618615 const existingChunk = await db . get ( this . storeName , chunkKey ) ;
619616 if ( existingChunk ) {
620617 chunksToUpdate . push ( {
@@ -625,6 +622,9 @@ export class IDBCache implements IDBCacheInterface {
625622 } ) ;
626623 }
627624 } else {
625+ if ( this . priority === "low" ) {
626+ await waitForAnimationFrame ( ) ;
627+ }
628628 const encryptedChunk = await encryptChunk (
629629 this . getPort ( ) ,
630630 chunk ,
0 commit comments