File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ See docs/process.md for more on how version tagging works.
3838 binaryen for wasm). (#26677 )
3939- The ` -m64 ` compiler flag is now honored, and works as an alias for
4040 ` -sMEMORY64 ` and/or ` --target=wasm64 ` . (#26765 )
41+ - The autopersistence feature in IDBFS mount now supports registering a global
42+ callback ` IDBFS.onAutoPersistStateChanged = active => {} ` , which will be
43+ notified of all IDBFS sync start and end events. (#26895 )
4144
42455.0.7 - 04/30/26
4346----------------
Original file line number Diff line number Diff line change @@ -18,14 +18,31 @@ addToLibrary({
1818 DB_VERSION : 21 ,
1919 DB_STORE_NAME : 'FILE_DATA' ,
2020
21+ // When using the autopersistence mechanism, users can set
22+ // IDBFS.onAutoPersistStateChanged callback to receive notification events
23+ // for when persistence operations are in-flight. Use the following syntax:
24+ /*
25+ IDBFS.onAutoPersistStateChanged = autoPersistActive => {
26+ if (autoPersistActive) {
27+ console.log('IDBFS persistence operation has started.');
28+ } else {
29+ console.log('IDBFS persistence operation has finished.');
30+ }
31+ };
32+ */
33+
2134 // Queues a new VFS -> IDBFS synchronization operation
2235 queuePersist : ( mount ) => {
2336 function onPersistComplete ( ) {
2437 if ( mount . idbPersistState === 'again' ) startPersist ( ) ; // If a new sync request has appeared in between, kick off a new sync
25- else mount . idbPersistState = 0 ; // Otherwise reset sync state back to idle to wait for a new sync later
38+ else {
39+ mount . idbPersistState = 0 ; // Otherwise reset sync state back to idle to wait for a new sync later
40+ IDBFS . onAutoPersistStateChanged ?. ( false ) ;
41+ }
2642 }
2743 function startPersist ( ) {
2844 mount . idbPersistState = 'idb' ; // Mark that we are currently running a sync operation
45+ IDBFS . onAutoPersistStateChanged ?. ( true ) ;
2946 IDBFS . syncfs ( mount , /*populate:*/ false , onPersistComplete ) ;
3047 }
3148
Original file line number Diff line number Diff line change @@ -152,7 +152,24 @@ void test() {
152152#endif
153153
154154#ifdef IDBFS_AUTO_PERSIST
155+
156+ #if FIRST
157+ // Register an IDBFS autopersist completion callback to detect when the
158+ // filesystem sync operation has finished.
159+ EM_ASM ({
160+ IDBFS .onAutoPersistStateChanged = (autoPersistActive ) = > {
161+ if (autoPersistActive ) {
162+ console .log ('IDBFS persistence operation has started.' );
163+ } else {
164+ console .log ('IDBFS persistence operation has finished.' );
165+ callUserCallback (_finish );
166+ }
167+ }
168+ });
169+ #else
155170 finish ();
171+ #endif
172+
156173#else
157174 // sync from memory state to persisted and then
158175 // run 'finish'
You can’t perform that action at this time.
0 commit comments