|
388 | 388 | snippet.css.insert_rule([':host {height:100%;}','#root {height:100%}']); |
389 | 389 | snippet.editor.css.insert_rule([':host {flex:1}','#root {height:100%}']); |
390 | 390 |
|
391 | | - snippet.ctx = {snippet,webcontainer,viewport,vm}; |
| 391 | + snippet.ctx = {snippet,webcontainer,viewport,vm,shell,term}; |
392 | 392 |
|
393 | 393 |
|
394 | 394 | var attrs = {component:'page'}; |
|
464 | 464 |
|
465 | 465 | log.green('installing https-server'); |
466 | 466 |
|
467 | | - var cwd = await shell._process.cwd(); |
| 467 | + debugger; |
| 468 | + var process = await shell._process.bind(shell._process); |
| 469 | + |
| 470 | + var cwd = await process.cwd(); |
468 | 471 | console.log(cwd); |
469 | 472 |
|
470 | 473 | var mod = await import('https://code.ext-code.com/nodejs/servers/https-server/create-archive.m.js'); |
|
712 | 715 | await webcontainer.mount(files); |
713 | 716 | term.write('spawn jsh ...\r\n') |
714 | 717 | shell = await webcontainer.spawn('jsh'); |
| 718 | + console.dir(shell._process, { depth: 10 }); |
| 719 | + |
715 | 720 | var output = new WritableStream({write(data){term.write(data)}}); |
716 | 721 | shell.output.pipeTo(output); |
717 | 722 |
|
|
726 | 731 | })(); |
727 | 732 |
|
728 | 733 |
|
| 734 | + async function getShellCwd(shell){ |
| 735 | + |
| 736 | + return new Promise(resolve=>{ |
| 737 | + |
| 738 | + var decoder = new TextDecoder(); |
| 739 | + var onData = data=>{ |
| 740 | + |
| 741 | + var text = decoder.decode(data); |
| 742 | + var line = text.trim(); |
| 743 | + if(line.startsWith('/')){ |
| 744 | + shell.output.off('data',onData); |
| 745 | + resolve(line); |
| 746 | + } |
| 747 | + |
| 748 | + }; |
| 749 | + |
| 750 | + shell.output.on('data',onData); |
| 751 | + shell.input.write('pwd\n'); |
| 752 | + |
| 753 | + }); |
| 754 | + |
| 755 | + }//getShellCwd |
| 756 | + |
| 757 | + |
| 758 | + |
729 | 759 | </script> |
730 | 760 |
|
731 | 761 | </html> |
|
0 commit comments