|
69 | 69 | var misc; |
70 | 70 | var filemod; |
71 | 71 | var wcfs; |
| 72 | + var ports; |
72 | 73 | var log; |
73 | 74 |
|
74 | 75 |
|
|
89 | 90 | misc = mod['misc-hdr']; |
90 | 91 | filemod = mod['file-mod']; |
91 | 92 | wcfs = mod['webcontainer-fs']; |
| 93 | + ports = mod['webcontainer-ports']; |
92 | 94 | log = mod['log-mod']; |
93 | 95 |
|
94 | 96 | misc.initmod({ext,$}); |
95 | 97 | filemod.initmod({ext,$,menumod,menu,complete,source,log}); |
96 | 98 | wcfs.initmod({ext,$,filemod,menumod,menu,complete,source,log,debug,webcontainer}); |
| 99 | + ports.initmod({$,vm}); |
97 | 100 | log.initmod({ext,$}); |
98 | 101 |
|
99 | 102 |
|
|
102 | 105 | misc.init(), |
103 | 106 | filemod.init(), |
104 | 107 | wcfs.init(), |
| 108 | + ports.init(), |
105 | 109 | log.init(), |
106 | 110 | ]); |
107 | 111 |
|
|
186 | 190 | .icon |
187 | 191 | {width:32px;height:32px;border:1px solid gray;border-radius:3px;box-sizing:border-box;cursor:pointer} |
188 | 192 |
|
| 193 | + #ports |
| 194 | + {content:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABDUlEQVR4AeyU6xEBQRCEtySCSBAJIkEkiASRkAn9FVdlbnf2UXXKn1Mz+5jpnt7XmYTy7ynIXt43YuT6cTOvETCE1skoUDwx74hmYnKBuIZhp4bxtxNTOBC7awBHnTVPAMJV0EOlP4S7yCPzBADe1PAUaxxs0w5UexjL7WAQhb8JcGnTxi3AiSjeDgAnLy2q8A4s1MFRZ80T4FUsBa0RAQMWjijWPAGeJivibVPAsuwMDFg4NqOZJ6BUONPIj/KUCKumOLmtMEnLCbAiiBTgy6YYMQS7ObmVKvPVq4stJwAaIgX4y2C+VrORE0d8/hmrS1tJAFZ3vggx7oqfSJa8RqBUI5sfBbLHQ/LnR/QCAAD//7FNDYAAAAAGSURBVAMASAU3rzhnxxoAAAAASUVORK5CYII=); |
| 195 | + } |
189 | 196 |
|
190 | 197 |
|
191 | 198 | #more-menu-click |
|
236 | 243 | </div> |
237 | 244 |
|
238 | 245 | <div id=icons> |
| 246 | + <img id=ports title=ports class=icon> |
239 | 247 | <img id=niframe title=iframe class=icon> |
240 | 248 | <img id=snippet-editor title=editor class=icon> |
241 | 249 | <img id=snippet-console title=snippet-console class=icon> |
|
265 | 273 | <input value=test type=button> |
266 | 274 | </div> |
267 | 275 |
|
| 276 | + |
| 277 | + |
| 278 | + <webcontainer-ports component=page></webcontainer-ports> |
| 279 | + |
268 | 280 | <log-mod component></log-mod> |
269 | 281 |
|
270 | 282 | </body> |
|
300 | 312 |
|
301 | 313 | //: |
302 | 314 |
|
303 | | - function initdom(){ |
| 315 | + async function initdom(){ |
304 | 316 |
|
305 | | - vm.initdom(); |
| 317 | + await vm.initdom(); |
306 | 318 |
|
307 | | - misc.initdom(); |
| 319 | + await misc.initdom(); |
308 | 320 | misc.set.version(version); |
309 | 321 |
|
310 | | - filemod.initdom(); |
311 | | - wcfs.initdom(); |
| 322 | + await filemod.initdom(); |
| 323 | + await wcfs.initdom(); |
| 324 | + await ports.initdom(); |
| 325 | + |
312 | 326 |
|
313 | 327 | //menu.add.style(); |
314 | 328 | var card = $('#more-menu'); |
315 | 329 | $('#more-menu-click').onclick = menu.click(card,'both',false,menu_callback.more); |
316 | 330 |
|
317 | 331 |
|
| 332 | + $('#ports').onclick = btn.ports; |
318 | 333 | $('#niframe').onclick = btn.niframe; |
319 | 334 | $('#snippet-editor').onclick = btn['snippet-editor']; |
320 | 335 | $('#snippet-console').onclick = btn['snippet-console']; |
|
324 | 339 |
|
325 | 340 | $('[value=test]').onclick = btn.test; |
326 | 341 |
|
327 | | - log.initdom(); |
| 342 | + await log.initdom(); |
328 | 343 |
|
329 | 344 | blank = $('#file-info img').src; |
330 | 345 |
|
|
338 | 353 | //: |
339 | 354 |
|
340 | 355 |
|
| 356 | + btn.ports = async function(){ |
| 357 | + |
| 358 | + console.log(ports.viewport.status); |
| 359 | + |
| 360 | + if(ports.viewport.status==='hidden'){ |
| 361 | + ports.show(); |
| 362 | + }else{ |
| 363 | + ports.hide(); |
| 364 | + } |
| 365 | + |
| 366 | + }//ports |
| 367 | + |
| 368 | + |
341 | 369 | btn.niframe = async function(){ |
342 | 370 |
|
343 | 371 | var node = document.createElement('webcontainer-iframe'); |
|
389 | 417 | var viewport = await vm.new(); |
390 | 418 | viewport.pos({x:250,y:200,w:850,h:1100}); |
391 | 419 |
|
392 | | - var attrs = {component:true,'v2.0':true,'web-editor':'fullsize=false',exportparts:"root: inner-label"}; |
| 420 | + var attrs = {component:true,'v2.0':true,'web-editor':'fullsize=false',exportparts:'root:inner-label'}; |
393 | 421 | var opts = {par:viewport.body}; |
394 | 422 | var snippet = await mod.component('snippet-console',attrs,opts); |
395 | 423 |
|
|
943 | 971 |
|
944 | 972 | }); |
945 | 973 |
|
946 | | -/* |
947 | | -[J~/rt4gcbtwdausp1nng6uyw4vpasf83c-wlvi |
948 | | -[1G[0J❯ [3G |
949 | | -[?2004h |
950 | | -*/ |
951 | | - |
| 974 | + |
952 | 975 | var fitAddon = new FitAddon(); |
953 | 976 | term.loadAddon(fitAddon); |
954 | 977 | term.open(terminal); |
|
1108 | 1131 |
|
1109 | 1132 | webcontainer.on('server-ready',(port,url)=>{ |
1110 | 1133 | console.log('server-ready',url,port); |
1111 | | - term.writeln('server-ready :'+url+' --- '+port); |
| 1134 | + //term.writeln('server-ready :'+url+' --- '+port); |
1112 | 1135 |
|
1113 | 1136 | }); |
1114 | 1137 | webcontainer.on('port',(port,type,url)=>{ |
1115 | 1138 | console.log(port,type,url) |
1116 | | - term.writeln('port :'+type+' --- '+url+' --- '+port); |
| 1139 | + //term.writeln('port :'+type+' --- '+url+' --- '+port); |
1117 | 1140 |
|
| 1141 | + switch(type){ |
| 1142 | + |
| 1143 | + case '' : ports.add(port,url); break; |
| 1144 | + case '' : port.remove(port); break; |
| 1145 | + |
| 1146 | + }//switch |
1118 | 1147 | }); |
1119 | 1148 |
|
1120 | 1149 |
|
|
0 commit comments