66 body
77 {margin : 20px ;display : flex;flex-direction : column;gap : 10px ;font-family : arial}
88
9- iframe
10- {width : 100% ;height : 300px }
9+
10+ # hdr
11+ {display : flex;gap : 10px }
1112
1213 # terminal
1314 {height : 500px }
1415
16+ input
17+ {font-size : 16px ;padding : 5px 10px ;box-sizing : border-box}
18+ input [type= button}
19+ {cursor : pointer}
20+
21+
1522 </ style >
1623
1724 < h3 > esrecurse-browser</ h3 >
1825
26+ < div id =hdr >
27+ < div >
28+ auth
29+ </ div >
30+ < input id =auth >
31+ < input value =ready type =button onclick ='start() '>
32+ </ div >
33+
1934 < div id =terminal > </ div >
2035
2136
@@ -117,8 +132,6 @@ <h3>esrecurse-browser</h3>
117132
118133
119134
120- setTimeout ( start , 50 ) ;
121-
122135
123136 async function start ( ) {
124137
@@ -131,6 +144,9 @@ <h3>esrecurse-browser</h3>
131144 term . open ( terminal ) ;
132145 fitAddon . fit ( ) ;
133146
147+ var { 'file-server' :fs } = await import ( 'https://libs.ext-code.com/js/io/file-server/file-serer.m.js' ) ;
148+ fs . url = 'https://localhost:3000' ;
149+ fs . auth = auth . value ;
134150
135151 for ( var key in files ) {
136152
@@ -153,32 +169,23 @@ <h3>esrecurse-browser</h3>
153169 await package_json ( ) ;
154170 await install_rollup ( ) ;
155171
172+ await Promise . all ( [ 'esm' , 'cjs' ] . map ( async type => {
156173
157- await rollup ( ) ;
158-
159- var uint8 = await webcontainer . fs . readFile ( filename ) ;
160- var blob = new Blob ( [ uint8 ] , { type :'text/javascript' } ) ;
161- var url = window . URL . createObjectURL ( blob ) ;
162-
163-
164- var { 'file-server' : fs } = await import ( 'https://libs.ext-code.com/js/io/file-server/file-serer.m.js' ) ;
165- fs . url = 'https://localhost:3000' ;
166- fs . auth = auth . value ;
167-
168- fs . mkdir ( '/npm/esrecurse-browser' ) ;
169-
174+ await rollup [ type ] ( ) ;
175+
176+ var uint8 = await webcontainer . fs . readFile ( filename [ type ] ) ;
177+ var blob = new Blob ( [ uint8 ] , { type :'text/javascript' } ) ;
178+ var url = window . URL . createObjectURL ( blob ) ;
179+
180+
181+ var path = '/npm/esrecurse-browser/' ;
182+ fs . mkdir ( path ) ;
183+
184+ await fs . writefile ( path + filename [ type ] , blob ) ;
185+
186+ } ) ;
170187
171188
172- if ( 1 ) {
173- console . log ( 'download...' ) ;
174- var a = document . createElement ( 'a' ) ;
175- a . href = url ;
176- a . download = filename ;
177- document . body . append ( a ) ;
178- a . click ( ) ;
179- console . log ( 'done' ) ;
180- return ;
181- }
182189
183190
184191
0 commit comments