dev: update emu load indicator

This commit is contained in:
KernelDeimos 2024-09-30 16:50:03 -04:00
parent 04c05a5bb8
commit 6e1ed7ab04
7 changed files with 35 additions and 9 deletions

9
package-lock.json generated
View File

@ -7296,6 +7296,14 @@
"@xterm/xterm": "^5.0.0"
}
},
"node_modules/@xterm/addon-image": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/@xterm/addon-image/-/addon-image-0.8.0.tgz",
"integrity": "sha512-b/dqpFn3jUad2pUP5UpF4scPIh0WdxRQL/1qyiahGfUI85XZTCXo0py9G6AcOR2QYUw8eJ8EowGspT7BQcgw6A==",
"peerDependencies": {
"@xterm/xterm": "^5.2.0"
}
},
"node_modules/@xterm/xterm": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-5.5.0.tgz",
@ -17436,6 +17444,7 @@
"license": "AGPL-3.0-only",
"dependencies": {
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-image": "^0.8.0",
"@xterm/xterm": "^5.5.0"
},
"devDependencies": {

View File

@ -115,6 +115,11 @@ const setup_pty = (ptt, pty) => {
})()
}
let TUX_SIXEL; (async () => {
const resp = await fetch('./static/tux.sixel');
const text = await resp.text();
TUX_SIXEL = text;
})();
puter.ui.on('connection', event => {
const { conn, accept, reject } = event;
@ -131,6 +136,7 @@ puter.ui.on('connection', event => {
accept({
version: '1.0.0',
status,
logo: TUX_SIXEL,
});
console.log('emulator got connection event', event);

1
src/emulator/tux.sixel Normal file

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,8 @@ module.exports = {
}),
new CopyPlugin({
patterns: [
{ from: 'benchmark', to: 'static' }
{ from: 'benchmark', to: 'static' },
{ from: 'tux.sixel', to: 'static' },
]
})
]

View File

@ -40,6 +40,7 @@ export class EmuCommandProvider {
let prev_phase = 'init';
let progress_shown = false;
let tux_enabled = false;
const leftpadd = 10;
const on_message = message => {
if ( message.$ !== 'status' ) {
console.log('[!!] message from the emulator', message);
@ -53,21 +54,22 @@ export class EmuCommandProvider {
if ( message.phase === 'ready' ) {
if ( progress_shown ) {
// show complete progress so it doesn't look weird
ctx.externs.out.write('\r[' + '='.repeat(ctx.env.COLS-2) + ']\n');
ctx.externs.out.write(`\r\x1B[${leftpadd}C[` +
'='.repeat(ctx.env.COLS-2-leftpadd) + ']\n');
}
p_ready.resolve();
return;
}
if ( message.phase !== prev_phase ) {
progress_shown = false;
ctx.externs.out.write(`phase: ${message.phase}\n`);
ctx.externs.out.write(`\r\x1B[${leftpadd}Cphase: ${message.phase}\n`);
prev_phase = message.phase;
}
if ( message.phase_progress ) {
progress_shown = true;
let w = ctx.env.COLS;
w -= 2;
ctx.externs.out.write('\r[');
w -= 2 + leftpadd;
ctx.externs.out.write(`\r\x1B[${leftpadd}C[`);
const done = Math.floor(message.phase_progress * w);
for ( let i=0 ; i < done ; i++ ) {
ctx.externs.out.write('=');
@ -83,9 +85,12 @@ export class EmuCommandProvider {
if ( conn.response.status.ready ) {
p_ready.resolve();
} else {
tux_enabled = true;
conn.response.status.$ = 'status';
ctx.externs.out.write('\x1B[36;1mWaiting for emulator to be ready...\x1B[0m\n');
ctx.externs.out.write(' Puter Linux is starting...\n');
ctx.externs.out.write(' (Alpine Linux edge i686)\n');
ctx.externs.out.write('\x1B[2A');
ctx.externs.out.write(conn.response.logo + '\n');
ctx.externs.out.write('\x1B[2A');
on_message(conn.response.status);
}
console.log('status from emu', conn.response);

View File

@ -19,7 +19,8 @@
"rollup-plugin-copy": "^3.4.0"
},
"dependencies": {
"@xterm/xterm": "^5.5.0",
"@xterm/addon-fit": "^0.10.0"
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-image": "^0.8.0",
"@xterm/xterm": "^5.5.0"
}
}

View File

@ -18,6 +18,7 @@
*/
import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import { ImageAddon } from '@xterm/addon-image';
import { PTY } from './pty/PTY';
import { XDocumentANSIShell } from './pty/XDocumentANSIShell';
@ -98,6 +99,8 @@ window.main_term = async () => {
const term = new Terminal({
linkHandler,
});
const imageAddon = new ImageAddon();
term.loadAddon(imageAddon);
term.open(document.getElementById('terminal'));
const fitAddon = new FitAddon();