mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 14:03:42 +00:00
fix phoenix WINSZ handling
This commit is contained in:
parent
7139d29749
commit
a33d721e21
@ -91,7 +91,10 @@ export class ANSIShell extends EventTarget {
|
||||
})
|
||||
Object.defineProperty(this.env, 'COLS', {
|
||||
enumerable: true,
|
||||
get: () => this.variables.size?.cols ?? 0
|
||||
get: () => {
|
||||
const v = this.variables.size?.cols ?? 0
|
||||
return v;
|
||||
}
|
||||
})
|
||||
|
||||
this.export_('LANG', 'en_US.UTF-8');
|
||||
|
@ -30,10 +30,11 @@ window.main_shell = async () => {
|
||||
.entries()
|
||||
);
|
||||
|
||||
let resolveConfigured = null;
|
||||
const configured_ = new Promise(rslv => {
|
||||
resolveConfigured = rslv;
|
||||
});
|
||||
// let resolveConfigured = null;
|
||||
// const configured_ = new Promise(rslv => {
|
||||
// resolveConfigured = rslv;
|
||||
// });
|
||||
const puterSDK = globalThis.puter;
|
||||
|
||||
const terminal = puter.ui.parentApp();
|
||||
if (!terminal) {
|
||||
@ -45,9 +46,10 @@ window.main_shell = async () => {
|
||||
if (message.$ === 'config') {
|
||||
const configValues = { ...message };
|
||||
// Only copy the config that we actually need
|
||||
config['puter.auth.username'] = configValues['puter.auth.username'];
|
||||
// config['puter.auth.username'] = configValues['puter.auth.username'];
|
||||
config['puter.auth.token'] = configValues['puter.auth.token'];
|
||||
resolveConfigured();
|
||||
// console.log('set!');
|
||||
// resolveConfigured();
|
||||
}
|
||||
});
|
||||
terminal.on('close', () => {
|
||||
@ -59,14 +61,17 @@ window.main_shell = async () => {
|
||||
|
||||
terminal.postMessage({ $: 'ready' });
|
||||
|
||||
await configured_;
|
||||
|
||||
const puterSDK = globalThis.puter;
|
||||
if ( config['puter.auth.token'] ) {
|
||||
await puterSDK.setAuthToken(config['puter.auth.token']);
|
||||
}
|
||||
|
||||
const ptt = new XDocumentPTT(terminal);
|
||||
|
||||
// await configured_;
|
||||
const user = await puterSDK.auth.getUser();
|
||||
config['puter.auth.username'] = user.username;
|
||||
// await new Promise(rslv => setTimeout(rslv, 0));
|
||||
|
||||
// if ( config['puter.auth.token'] ) {
|
||||
// await puterSDK.setAuthToken(config['puter.auth.token']);
|
||||
// }
|
||||
|
||||
await launchPuterShell(new Context({
|
||||
ptt,
|
||||
config, puterSDK,
|
||||
|
@ -21,7 +21,26 @@ import { BetterReader } from "dev-pty";
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
export class XDocumentPTT {
|
||||
static IOCTL = {
|
||||
TIOCGWINSZ: {
|
||||
id: 104,
|
||||
},
|
||||
}
|
||||
constructor(terminalConnection) {
|
||||
for ( const k in XDocumentPTT.IOCTL ) {
|
||||
this[k] = async () => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
terminalConnection.postMessage({
|
||||
$: 'ioctl.request',
|
||||
requestCode: XDocumentPTT.IOCTL[k].id,
|
||||
});
|
||||
this.once('ioctl.set', evt => {
|
||||
resolve(evt);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.ioctl_listeners = {};
|
||||
|
||||
this.readableStream = new ReadableStream({
|
||||
|
@ -136,6 +136,9 @@ export const launchPuterShell = async (ctx) => {
|
||||
}));
|
||||
});
|
||||
|
||||
// NEXT
|
||||
ptt.TIOCGWINSZ();
|
||||
|
||||
const fire = (text) => {
|
||||
// Define fire-like colors (ANSI 256-color codes)
|
||||
const fireColors = [202, 208, 166];
|
||||
|
@ -29,6 +29,14 @@ export class XDocumentANSIShell {
|
||||
|
||||
shell.on('message', message => {
|
||||
// When the shell reports it's ready, send configuration
|
||||
if (message.$ === 'ioctl.request') {
|
||||
if (message.requestCode === 104) {
|
||||
shell.postMessage({
|
||||
$: 'ioctl.set',
|
||||
windowSize: this.internal_.windowSize,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (message.$ === 'ready') {
|
||||
const params = Object.fromEntries(
|
||||
new URLSearchParams(window.location.search)
|
||||
|
Loading…
Reference in New Issue
Block a user