11"use strict" ;
2- { { = < % % >= } } { { flutter_js } } < %= { { } } = % >
3- { { = < % % >= } } { { flutter_build_config } } < %= { { } } = % >
2+ { { = < % % >= } } { { flutter_js } } < %= { { } } = % >
3+ { { = < % % >= } } { { flutter_build_config } } < %= { { } } = % >
44
55const progressText = document . querySelector ( '#progress-text' ) ;
66const progressIndicator = document . querySelector ( '#progress-indicator' ) ;
@@ -59,15 +59,16 @@ async function beginPreloading() {
5959 return ;
6060 }
6161
62- const batchSize = { { batch_size} } ;
62+ const batchSize = { { batch_size }
63+ } ;
6364
64- progressIndicator . style . width = '0%' ;
65- progressText . textContent = `Loaded ${ loadedAssets } of ${ totalAssets } assets` ;
65+ progressIndicator . style . width = '0%' ;
66+ progressText . textContent = `Loaded ${ loadedAssets } of ${ totalAssets } assets` ;
6667
67- for ( let i = 0 ; i < assets . length ; i += batchSize ) {
68- const batch = assets . slice ( i , i + batchSize ) ;
69- await loadBatch ( batch ) ;
70- }
68+ for ( let i = 0 ; i < assets . length ; i += batchSize ) {
69+ const batch = assets . slice ( i , i + batchSize ) ;
70+ await loadBatch ( batch ) ;
71+ }
7172}
7273
7374function reportProgress ( ) {
@@ -94,18 +95,19 @@ async function load(url) {
9495}
9596
9697async function loadBatch ( urls ) {
98+ const loadPromises = urls . map ( async ( url ) => {
99+ await load ( url ) ;
100+ reportProgress ( ) ;
101+ } ) ;
97102 try {
98- await Promise . all ( urls . map ( async ( url ) => {
99- await load ( url ) ;
100- reportProgress ( ) ;
101- } ) ) ;
103+ return await Promise . all ( loadPromises ) ;
102104 } catch ( error ) {
103- console . error ( 'Error loading asset:' , error ) ;
105+ console . error ( 'Error loading one or more asset:' , error ) ;
104106 }
105107}
106108
107109_flutter . loader . load ( {
108- onEntrypointLoaded : async function ( engineInitializer ) {
110+ onEntrypointLoaded : async function ( engineInitializer ) {
109111 await Promise . all ( [
110112 beginPreloading ( ) ,
111113 engineInitializer . initializeEngine ( ) ,
0 commit comments