M0: WIT package, MoonBit components, JS host, docs, CI (#1)
CI / test (push) Successful in 19s

This commit was merged in pull request #1.
This commit is contained in:
nandi committed 2026-11-24 23:51:26 +00:00
1 parent e5548fc067
commit 880ecd4102
141 files changed
+9681 -1

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env node
// Headless desktop: boots all components under the Node host and prints the
// composed desktop as text, optionally after a scripted interaction.
// node host/src/cli.mjs [--config file] [--time ISO] [--click-launcher] [--scene out.json]
import { writeFile } from 'node:fs/promises';
import { bootDesktop } from './headless.mjs';
import { renderAscii } from './ascii.mjs';
const args = process.argv.slice(2);
const opt = (n) => { const i = args.indexOf(`--${n}`); return i < 0 ? undefined : args[i + 1]; };
const flag = (n) => args.includes(`--${n}`);
const fixed = opt('time') ? new Date(opt('time')) : undefined;
const { desktop, platform } = await bootDesktop({ configPath: opt('config'), now: fixed ? () => fixed : undefined });
let f = desktop.frame();
if (flag('click-launcher')) {
const e = desktop.hit.widgets.find((w) => w.widget.id === 'launcher');
desktop.pointer('down', e.rect.x + 10, e.rect.y + 10);
f = desktop.frame();
if (flag('type')) { for (const ch of opt('type')) desktop.key(ch); f = desktop.frame(); }
}
console.log(renderAscii(f.ops, f.screen));
console.log(`\n-- ${f.ops.length} draw-ops; widgets: ${desktop.widgets.map((w) => `${w.id}=${w.componentName}`).join(', ')}; theme=${platform.tokens.name}`);
if (opt('scene')) await writeFile(opt('scene'), JSON.stringify(f, null, 1));
if (desktop.faults.length) { console.error(`${desktop.faults.length} component fault(s)`); process.exit(1); }