@@ -1244,10 +1244,8 @@ async function diffUpdater() {
1244
1244
ubolog ( 'Diff updater: cycle start' ) ;
1245
1245
return new Promise ( resolve => {
1246
1246
let pendingOps = 0 ;
1247
- const bc = new globalThis . BroadcastChannel ( 'diffUpdater' ) ;
1248
1247
const terminate = error => {
1249
1248
worker . terminate ( ) ;
1250
- bc . close ( ) ;
1251
1249
resolve ( ) ;
1252
1250
if ( typeof error !== 'string' ) { return ; }
1253
1251
ubolog ( `Diff updater: terminate because ${ error } ` ) ;
@@ -1260,14 +1258,15 @@ async function diffUpdater() {
1260
1258
if ( metadata . diffPath === data . patchPath ) { return ; }
1261
1259
assetCacheSetDetails ( data . assetKey , metadata ) ;
1262
1260
} ;
1263
- bc . onmessage = ev => {
1261
+ const worker = new Worker ( 'js/diff-updater.js' ) ;
1262
+ worker . onmessage = ev => {
1264
1263
const data = ev . data || { } ;
1265
1264
if ( data . what === 'ready' ) {
1266
1265
ubolog ( 'Diff updater: hard updating' , toHardUpdate . map ( v => v . assetKey ) . join ( ) ) ;
1267
1266
while ( toHardUpdate . length !== 0 ) {
1268
1267
const assetDetails = toHardUpdate . shift ( ) ;
1269
1268
assetDetails . fetch = true ;
1270
- bc . postMessage ( assetDetails ) ;
1269
+ worker . postMessage ( assetDetails ) ;
1271
1270
pendingOps += 1 ;
1272
1271
}
1273
1272
return ;
@@ -1284,7 +1283,7 @@ async function diffUpdater() {
1284
1283
data . text = result . content || '' ;
1285
1284
data . status = undefined ;
1286
1285
checkAndCorrectDiffPath ( data ) ;
1287
- bc . postMessage ( data ) ;
1286
+ worker . postMessage ( data ) ;
1288
1287
} ) ;
1289
1288
return ;
1290
1289
}
@@ -1320,15 +1319,14 @@ async function diffUpdater() {
1320
1319
if ( pendingOps === 0 && toSoftUpdate . length !== 0 ) {
1321
1320
ubolog ( 'Diff updater: soft updating' , toSoftUpdate . map ( v => v . assetKey ) . join ( ) ) ;
1322
1321
while ( toSoftUpdate . length !== 0 ) {
1323
- bc . postMessage ( toSoftUpdate . shift ( ) ) ;
1322
+ worker . postMessage ( toSoftUpdate . shift ( ) ) ;
1324
1323
pendingOps += 1 ;
1325
1324
}
1326
1325
}
1327
1326
if ( pendingOps !== 0 ) { return ; }
1328
1327
ubolog ( 'Diff updater: cycle complete' ) ;
1329
1328
terminate ( ) ;
1330
1329
} ;
1331
- const worker = new Worker ( 'js/diff-updater.js' ) ;
1332
1330
} ) . catch ( reason => {
1333
1331
ubolog ( `Diff updater: ${ reason } ` ) ;
1334
1332
} ) ;
0 commit comments