Frontend uudelleenrakennettu: Astro-komponentit, Wasm pääsäikeessä, ei Workeria

Vanha frontend siirretty temp/. Uusi rakenne:
- StatusBar.astro, Terminal.astro, Editor.astro, Guide.astro
- global.css erillinen
- Wasm pääsäikeessä (ei Worker — yksinkertainen, debugattava)
- Tab-completion, dropdown, projektikortti, Monaco, GUIDE.md
- Ei tokenisointia eikä koodilaboratoriota

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaakko Vanhala
2026-04-09 20:17:39 +03:00
parent e3fdb91ac5
commit a8c4af0975
9617 changed files with 996171 additions and 5349 deletions

View File

@@ -0,0 +1,100 @@
import { spawn } from 'node:child_process';
const TIMEOUT = 2000;
function checkUnixCommandExists(command) {
return new Promise((resolve) => {
const proc = spawn('which', [command]);
proc.on('error', () => resolve(false));
proc.on('close', (code) => resolve(code === 0));
});
}
async function getReadCommand() {
switch (process.platform) {
case 'darwin':
return ['pbpaste', []];
case 'win32':
return ['powershell', ['Get-Clipboard']];
case 'linux':
case 'freebsd':
case 'openbsd':
if (process.env.WSL_DISTRO_NAME) {
return ['powershell.exe', ['-noprofile', '-command', 'Get-Clipboard']];
}
if (process.env.WAYLAND_DISPLAY) {
return ['wl-paste', []];
}
if (await checkUnixCommandExists('xsel')) {
return ['xsel', ['--clipboard', '--output']];
}
return ['xclip', ['-selection', 'clipboard', '-o']];
case 'android':
return ['termux-clipboard-get', []];
default:
return undefined;
}
}
/**
* Reads text from the clipboard.
*/
export function readText() {
return new Promise(async (resolve, reject) => {
const command = await getReadCommand();
if (!command) {
return reject(new Error('No clipboard tool found'));
}
const proc = spawn(...command, {
signal: AbortSignal.timeout(TIMEOUT)
});
let data = '';
proc.stdout.on('data', (chunk) => (data += chunk));
proc.on('error', (cause) => reject(new Error('An error occurred while reading from clipboard', { cause })));
proc.on('close', (code) => code === 0
? resolve(data.trim())
: reject(new Error('An unknown error occurred while reading from clipboard')));
});
}
async function getWriteCommand() {
switch (process.platform) {
case 'darwin':
return ['pbcopy', []];
case 'win32':
return ['clip', []];
case 'linux':
case 'freebsd':
case 'openbsd':
if (process.env.WSL_DISTRO_NAME) {
return ['clip.exe', []];
}
if (process.env.WAYLAND_DISPLAY) {
return ['wl-copy', []];
}
if (await checkUnixCommandExists('xsel')) {
return ['xsel', ['--clipboard', '--input']];
}
return ['xclip', ['-selection', 'clipboard', '-i']];
case 'android':
return ['termux-clipboard-set', []];
default:
return undefined;
}
}
/**
* Writes text to the clipboard.
*/
export function writeText(text) {
return new Promise(async (resolve, reject) => {
const command = await getWriteCommand();
if (!command) {
return reject(new Error('No clipboard tool found'));
}
const proc = spawn(...command, {
stdio: ['pipe', 'ignore', 'ignore'],
signal: AbortSignal.timeout(TIMEOUT)
});
proc.on('error', (cause) => reject(new Error('An error occurred while copying', { cause })));
proc.on('close', (code) => code === 0
? resolve()
: reject(new Error('An unknown error occurred while copying')));
proc.stdin.write(text);
proc.stdin.end();
});
}