|
13 | 13 |
|
14 | 14 | <head> |
15 | 15 | <meta charset=utf-8> |
16 | | - |
| 16 | + |
17 | 17 | <title> |
18 | 18 | Node.js Terminal |
19 | 19 | </title> |
|
25 | 25 |
|
26 | 26 | <link rel='shortcut icon' type='image/x-icon' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAMAAABBJv+bAAAAQlBMVEVHcEwyODg0ODkzNzgxNzc0ODk0ODkzODgzODgzNzgyNzgzODg0ODkzODgyNzgzODgzODgzODk0ODk0ODkyNzg0ODmObyvDAAAAFXRSTlMABvaSDbPHe15GL5u9hRxvO6rn2VJXM6DpAAAAxElEQVQoz71TyRbDIAh0Ie6J2fz/Xy3Y2pDktZ5aTiODCAMK0QxAPoFsgNk0JrMEQmEwyU5ndt4K2khQEzLhdNeQTznCWREegNEOOe18fRO8i6ooz+gRw1k9gMkyo/E9zY5yKMX+ihbLq8mjFB5N4UepYLGRmdM7OnLlpYtJXWQQkFCIpHcpfBVpCxeRV/KuodHzmfaNxuTmlpxmoEzc5bs0rnGdQQZeybWxRX6Vxf5rJJ116CxTZxX5Isf7Ive+wadP9AAuFg97y3bd7gAAAABJRU5ErkJggg=='> |
27 | 27 | <meta name=viewport content='width=device-width, initial-scale=1'> |
28 | | - |
| 28 | + |
29 | 29 | <script type='application/ld+json'> |
30 | 30 | { |
31 | 31 | "@context" : "https://schema.org", |
|
40 | 40 | "softwareVersion" : "1.0.0", |
41 | 41 | "offers" : {"@type":"Offer","price":"0","priceCurrency":"GBP"} |
42 | 42 | } |
43 | | - </script> |
44 | | - |
45 | | - |
46 | | - <script src='https://libs.ext-code.com/js/dom/component/component.js'></script> |
47 | | - |
| 43 | + </script> |
| 44 | + |
| 45 | + |
| 46 | + <script src='https://libs.ext-code.com/js/dom/component/v3.0/component.js'></script> |
| 47 | + |
48 | 48 | <script init> |
49 | 49 | console.clear(); |
50 | 50 | console.log('terminal-v2.0.html'); |
|
63 | 63 | var menu; |
64 | 64 |
|
65 | 65 | var hdr; |
66 | | - |
67 | | - |
| 66 | + |
| 67 | + |
68 | 68 | async function init(){ |
69 | | - |
70 | | - |
| 69 | + |
| 70 | + |
71 | 71 | menu = menumod(); |
72 | | - |
| 72 | + |
73 | 73 | mod.base.add({ext,$,datatype,keydown,menu,menumod}); |
74 | 74 |
|
75 | 75 |
|
76 | 76 | hdr = mod['misc-hdr']; |
77 | 77 |
|
78 | 78 | hdr.initmod({ext,$}); |
79 | | - |
| 79 | + |
80 | 80 |
|
81 | 81 | await Promise.all([ |
82 | 82 | hdr.init(), |
83 | 83 | ]); |
84 | 84 |
|
85 | 85 |
|
86 | 86 | initdom(); |
87 | | - |
| 87 | + |
88 | 88 |
|
89 | 89 | }//init |
90 | 90 |
|
|
94 | 94 | mod.stack.add; |
95 | 95 |
|
96 | 96 | ({ext} = await import('https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js')); |
97 | | - |
| 97 | + |
98 | 98 | var promise = ext.load.libs( |
99 | 99 | 'js/dom/$.js', |
100 | 100 | 'js/core/datatype.js', |
|
103 | 103 | 'js/debug/debug.js', |
104 | 104 | ); |
105 | 105 | [$,datatype,menumod,keydown,debug] = await promise; |
106 | | - |
| 106 | + |
107 | 107 | mod.stack.complete; |
108 | | - |
| 108 | + |
109 | 109 | })(); |
110 | 110 |
|
111 | 111 |
|
112 | 112 | </script> |
113 | | - |
114 | | - |
| 113 | + |
| 114 | + |
115 | 115 |
|
116 | 116 |
|
117 | 117 | <link rel=stylesheet href='https://cdn.jsdelivr.net/npm/@xterm/xterm@5.5.0/css/xterm.css'> |
118 | 118 |
|
119 | 119 | <style> |
120 | | - |
| 120 | + |
121 | 121 | html |
122 | 122 | {height:100%;font-family:arial} |
123 | 123 | body |
|
129 | 129 | {padding:10px;border:2px solid lightgray;box-sizing:border-box} |
130 | 130 |
|
131 | 131 | </style> |
132 | | - |
| 132 | + |
133 | 133 | </head> |
134 | 134 |
|
135 | 135 |
|
136 | 136 | <body> |
137 | | - |
138 | | - |
| 137 | + |
| 138 | + |
139 | 139 | <misc-hdr component=grp> |
140 | 140 | <img class=title src='images/terminal.png' style='top:-15px;height:50px' alt='Node.js Terminal'> |
141 | 141 | <time slot=date datetime=2025-10-31>31 Oct 2025</time> |
142 | 142 | </misc-hdr> |
143 | | - |
144 | | - |
| 143 | + |
| 144 | + |
145 | 145 | <div id=terminal></div> |
146 | | - |
147 | | - |
| 146 | + |
| 147 | + |
148 | 148 | </body> |
149 | | - |
150 | | - |
| 149 | + |
| 150 | + |
151 | 151 | <script> |
152 | | - |
| 152 | + |
153 | 153 |
|
154 | 154 | function initdom(){ |
155 | | - |
| 155 | + |
156 | 156 | }//initdom |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
161 | 161 | var theme = {}; |
162 | 162 |
|
163 | 163 | theme.light = { |
|
182 | 182 | brightCyan : '#00938d', |
183 | 183 | brightWhite : '#ffffff' |
184 | 184 | }; |
185 | | - |
186 | | - |
| 185 | + |
| 186 | + |
187 | 187 | var x = { |
188 | | - |
| 188 | + |
189 | 189 | reset : '\x1b[0m', |
190 | | - |
| 190 | + |
191 | 191 | black : '\x1b[30m', |
192 | 192 | red : '\x1b[31m', |
193 | 193 | green : '\x1b[32m', |
|
196 | 196 | magenta : '\x1b[35m', |
197 | 197 | cyan : '\x1b[36m', |
198 | 198 | white : '\x1b[37m', |
199 | | - |
| 199 | + |
200 | 200 | brightBlack : '\x1b[90m', |
201 | 201 | brightRed: '\x1b[91m', |
202 | 202 | brightGreen: '\x1b[92m', |
|
205 | 205 | brightMagenta: '\x1b[95m', |
206 | 206 | brightCyan: '\x1b[96m', |
207 | 207 | brightWhite: '\x1b[97m', |
208 | | - |
| 208 | + |
209 | 209 | bgRed: '\x1b[41m', |
210 | 210 | bgGreen: '\x1b[42m', |
211 | 211 | bgYellow: '\x1b[43m', |
212 | 212 | bgBlue: '\x1b[44m', |
213 | 213 | bgMagenta: '\x1b[45m', |
214 | 214 | bgCyan: '\x1b[46m', |
215 | 215 | bgWhite: '\x1b[47m', |
216 | | - |
| 216 | + |
217 | 217 | bgBrightRed : '\x1b[101m', |
218 | 218 | bgBrightGreen : '\x1b[102m', |
219 | 219 | bgBrightYellow : '\x1b[103m', |
220 | 220 | bgBrightBlue : '\x1b[104m', |
221 | 221 | bgBrightMagenta : '\x1b[105m', |
222 | 222 | bgBrightCyan : '\x1b[106m', |
223 | 223 | bgBrightWhite : '\x1b[107m', |
224 | | - |
| 224 | + |
225 | 225 | bold : '\x1b[1m', |
226 | 226 | dim : '\x1b[2m', |
227 | 227 | italic : '\x1b[3m', |
228 | 228 | underline : '\x1b[4m', |
229 | 229 | inverse : '\x1b[7m', |
230 | 230 | hidden : '\x1b[8m', |
231 | 231 | strikethrough : '\x1b[9m', |
232 | | - |
| 232 | + |
233 | 233 | gray : '\x1b[38;5;245m', |
234 | 234 |
|
235 | 235 | }; |
236 | | - |
| 236 | + |
237 | 237 | var chr = { |
238 | 238 | warn : '\u26A0', |
239 | 239 | cross : '\u274C', |
|
245 | 245 | ok : '\u1F197', |
246 | 246 | }; |
247 | 247 |
|
248 | | - |
| 248 | + |
249 | 249 | </script> |
250 | 250 |
|
251 | 251 |
|
252 | 252 | <script type=module> |
253 | 253 | console.clear(); |
254 | 254 | import {Terminal} from 'https://cdn.jsdelivr.net/npm/@xterm/xterm/+esm'; |
255 | | - import {FitAddon} from 'https://cdn.jsdelivr.net/npm/@xterm/addon-fit/+esm' |
| 255 | + import {FitAddon} from 'https://cdn.jsdelivr.net/npm/@xterm/addon-fit/+esm' |
256 | 256 | import {WebContainer} from 'https://cdn.jsdelivr.net/npm/@webcontainer/api/+esm' |
257 | 257 |
|
258 | 258 | var term = new Terminal({ |
259 | | - |
| 259 | + |
260 | 260 | fontFamily : 'monospace', |
261 | 261 | fontSize : 16, |
262 | 262 | lineHeight : 1.0, |
263 | | - |
264 | | - |
| 263 | + |
| 264 | + |
265 | 265 | theme : theme.light, |
266 | 266 | rendererType : 'dom', |
267 | | - |
| 267 | + |
268 | 268 | }); |
269 | 269 | var fitAddon = new FitAddon(); |
270 | 270 | term.loadAddon(fitAddon); |
|
276 | 276 | var shell = await webcontainer.spawn('jsh'); |
277 | 277 | var output = new WritableStream({write(data){term.write(data)}}); |
278 | 278 | shell.output.pipeTo(output); |
279 | | - |
| 279 | + |
280 | 280 | var input = shell.input.getWriter(); |
281 | 281 | term.onData(data=>input.write(data)); |
282 | 282 |
|
283 | 283 | term.focus(); |
284 | | - |
| 284 | + |
285 | 285 | </script> |
286 | | - |
287 | | -</html> |
288 | 286 |
|
| 287 | +</html> |
| 288 | + |
0 commit comments