File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 font-family : sans-serif;
1919 font-weight : bold;
2020 }
21+ # progress {
22+ margin-top : 20px ;
23+ width : 300px ;
24+ height : 20px ;
25+ border : 1px solid black;
26+ border-radius : 10px ;
27+ background-color : white;
28+ overflow : hidden;
29+ }
30+ # bar {
31+ background-color : # 555 ;
32+ height : 20px ;
33+ width : 0% ;
34+ }
2135 </ style >
2236 < script type ="module ">
2337 import { version } from '/lib/moto/license.js' ;
4963 version : map . version || version
5064 } ) ;
5165
66+ const bar = document . getElementById ( 'bar' ) ;
67+
5268 navigator . serviceWorker . addEventListener ( 'message' , e => {
53- console . log ( '[SM]' , e . data ) ;
54- setTimeout ( ( ) => {
55- if ( map . mesh ) {
69+ let { data } = e ;
70+ if ( data . progress ) {
71+ bar . style . width = `${ ( data . progress * 100 ) | 0 } %` ;
72+ return ;
73+ } else {
74+ console . log ( '[SM]' , data ) ;
75+ }
76+ setTimeout ( ( ) => {
77+ bar . style . width = `100%` ;
78+ if ( map . mesh ) {
5679 location . replace ( '/mesh/index.html' ) ;
5780 } else {
5881 location . replace ( '/kiri/index.html' ) ;
6386 </ script >
6487</ head >
6588
66- < body > Booting Grid.Space</ body >
89+ < body >
90+ < div > Installing Grid.Space</ div >
91+ < div id ="progress ">
92+ < div id ="bar "> </ div >
93+ </ div >
94+ </ body >
6795
6896</ html >
Original file line number Diff line number Diff line change @@ -193,8 +193,10 @@ async function preloadBundle() {
193193 const res = await fetch ( BUNDLE_URL , { cache : 'no-store' } ) ;
194194 const buf = await res . arrayBuffer ( ) ;
195195 const files = await unpackBundle ( buf ) ;
196+ const total = Object . keys ( files ) . length ;
196197 await Promise . all (
197198 Object . entries ( files ) . map ( ( [ path , blob ] ) => {
199+ broadcast ( { progress : loaded / total } ) ;
198200 const ext = path . split ( '.' ) . pop ( ) ;
199201 const type =
200202 ext === 'html' ? 'text/html' :
You can’t perform that action at this time.
0 commit comments