@@ -52,20 +52,25 @@ class PersistentFile {
5252 }
5353}
5454
55+ interface WithModule {
56+ _module : { retryOps : Promise < void > [ ] } ;
57+ }
58+
5559export class OPFSCoopSyncVFS2 extends FacadeVFS {
5660 mapIdToFile = new Map < number , File > ( ) ;
5761
5862 lastError = null ;
59- log = null ; //function(...args) { console.log(`[${contextName}]`, ...args) };
63+ // log = null; //function(...args) { console.log(`[${contextName}]`, ...args) };
64+ log = function ( ...args ) {
65+ console . log ( `[OPFSCoopSyncVFS2]` , ...args ) ;
66+ } ;
6067
6168 persistentFiles = new Map < string , PersistentFile > ( ) ;
6269 boundAccessHandles = new Map < string , FileSystemSyncAccessHandle > ( ) ;
6370 unboundAccessHandles = new Set < FileSystemSyncAccessHandle > ( ) ;
6471 accessiblePaths = new Set < string > ( ) ;
6572 releaser : null | ( ( ) => void ) = null ;
6673
67- _module : { retryOps : Promise < void > [ ] } ;
68-
6974 static async create ( name , module ) {
7075 const vfs = new OPFSCoopSyncVFS2 ( name , module ) ;
7176 await Promise . all ( [
@@ -79,6 +84,10 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
7984 super ( name , module ) ;
8085 }
8186
87+ get #module( ) {
88+ return ( this as unknown as WithModule ) . _module ;
89+ }
90+
8291 async #initialize( nTemporaryFiles ) {
8392 // Delete temporary directories no longer in use.
8493 const root = await navigator . storage . getDirectory ( ) ;
@@ -148,7 +157,7 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
148157 // files are ready to be used.
149158 this . log ?.( `creating persistent file for ${ path } ` ) ;
150159 const create = ! ! ( flags & VFS . SQLITE_OPEN_CREATE ) ;
151- this . _module . retryOps . push (
160+ this . #module . retryOps . push (
152161 ( async ( ) => {
153162 try {
154163 // Get the path directory handle.
@@ -192,7 +201,7 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
192201 } else if ( ! persistentFile . accessHandle ) {
193202 // This branch is reached if the database was previously opened
194203 // and closed.
195- this . _module . retryOps . push (
204+ this . #module . retryOps . push (
196205 ( async ( ) => {
197206 const file = new File ( path , flags ) ;
198207 file . persistentFile = this . persistentFiles . get ( path ) ;
@@ -499,7 +508,7 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
499508 console . assert ( ! file . persistentFile . handleLockReleaser ) ;
500509 if ( ! file . persistentFile . isRequestInProgress ) {
501510 file . persistentFile . isRequestInProgress = true ;
502- this . _module . retryOps . push (
511+ this . #module . retryOps . push (
503512 ( async ( ) => {
504513 // Acquire the Web Lock.
505514 file . persistentFile . handleLockReleaser = await this . #acquireLock(
@@ -523,7 +532,7 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
523532 file . persistentFile . isRequestInProgress = false ;
524533 } ) ( )
525534 ) ;
526- return this . _module . retryOps . at ( - 1 ) ;
535+ return this . #module . retryOps . at ( - 1 ) ;
527536 }
528537 return Promise . resolve ( ) ;
529538 }
0 commit comments