1
- import { Emulators , CommandInterface } from "emulators" ;
1
+ import { Emulators , CommandInterface , BackendOptions } from "emulators" ;
2
2
import { TransportLayer } from "emulators/dist/types/protocol/protocol" ;
3
3
import { EmulatorsUi } from "./emulators-ui" ;
4
4
import { Layers , LayersOptions } from "./dom/layers" ;
@@ -254,6 +254,19 @@ export class DosInstance {
254
254
const bundlePromise = emulatorsUi . network . resolveBundle ( bundleUrl , {
255
255
onprogress : ( percent ) => this . layers . setLoadingMessage ( "Downloading bundle " + percent + "%" ) ,
256
256
} ) ;
257
+ const options : BackendOptions = {
258
+ onExtractProgress : ( index , file , extracted , total ) => {
259
+ if ( index !== 0 ) {
260
+ return ;
261
+ }
262
+
263
+ const percent = Math . round ( extracted / total * 100 ) ;
264
+ const lastIndex = file . lastIndexOf ( "/" ) ;
265
+
266
+ const name = file . substring ( lastIndex + 1 ) ;
267
+ this . layers . setLoadingMessage ( "Extracting " + percent + "% (" + name + ")" ) ;
268
+ } ,
269
+ } ;
257
270
try {
258
271
let changesBundle : Uint8Array | undefined ;
259
272
if ( optionalChangesUrl !== undefined && optionalChangesUrl !== null && optionalChangesUrl . length > 0 ) {
@@ -264,17 +277,17 @@ export class DosInstance {
264
277
const bundle = await bundlePromise ;
265
278
if ( this . emulatorFunction === "backend" ) {
266
279
this . ciPromise = emulators . backend ( [ bundle , changesBundle ] ,
267
- ( this as any ) . createTransportLayer ( ) as TransportLayer ) ;
280
+ ( this as any ) . createTransportLayer ( ) as TransportLayer , options ) ;
268
281
} else {
269
- this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle , changesBundle ] ) ;
282
+ this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle , changesBundle ] , options ) ;
270
283
}
271
284
} catch {
272
285
const bundle = await bundlePromise ;
273
286
if ( this . emulatorFunction === "backend" ) {
274
287
this . ciPromise = emulators . backend ( [ bundle ] ,
275
- ( this as any ) . createTransportLayer ( ) as TransportLayer ) ;
288
+ ( this as any ) . createTransportLayer ( ) as TransportLayer , options ) ;
276
289
} else {
277
- this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle ] ) ;
290
+ this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle ] , options ) ;
278
291
}
279
292
}
280
293
}
0 commit comments