1- import { Emulators , CommandInterface } from "emulators" ;
1+ import { Emulators , CommandInterface , BackendOptions } from "emulators" ;
22import { TransportLayer } from "emulators/dist/types/protocol/protocol" ;
33import { EmulatorsUi } from "./emulators-ui" ;
44import { Layers , LayersOptions } from "./dom/layers" ;
@@ -254,6 +254,19 @@ export class DosInstance {
254254 const bundlePromise = emulatorsUi . network . resolveBundle ( bundleUrl , {
255255 onprogress : ( percent ) => this . layers . setLoadingMessage ( "Downloading bundle " + percent + "%" ) ,
256256 } ) ;
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+ } ;
257270 try {
258271 let changesBundle : Uint8Array | undefined ;
259272 if ( optionalChangesUrl !== undefined && optionalChangesUrl !== null && optionalChangesUrl . length > 0 ) {
@@ -264,17 +277,17 @@ export class DosInstance {
264277 const bundle = await bundlePromise ;
265278 if ( this . emulatorFunction === "backend" ) {
266279 this . ciPromise = emulators . backend ( [ bundle , changesBundle ] ,
267- ( this as any ) . createTransportLayer ( ) as TransportLayer ) ;
280+ ( this as any ) . createTransportLayer ( ) as TransportLayer , options ) ;
268281 } else {
269- this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle , changesBundle ] ) ;
282+ this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle , changesBundle ] , options ) ;
270283 }
271284 } catch {
272285 const bundle = await bundlePromise ;
273286 if ( this . emulatorFunction === "backend" ) {
274287 this . ciPromise = emulators . backend ( [ bundle ] ,
275- ( this as any ) . createTransportLayer ( ) as TransportLayer ) ;
288+ ( this as any ) . createTransportLayer ( ) as TransportLayer , options ) ;
276289 } else {
277- this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle ] ) ;
290+ this . ciPromise = emulators [ this . emulatorFunction ] ( [ bundle ] , options ) ;
278291 }
279292 }
280293 }
0 commit comments