Files
strata/apps/host/server/fonts.mjs
T
Niko1221 0b3299a019 apps/host: the owner's UI and the Node App Host
The UI source from the 14 October handoff (src/, public/, index.html, vite and
tsconfig, tests, audit-fixes, design docs) and the App Host (server/*.mjs): model
import and monitor routes, API-provider catalog and streaming (OpenAI chat, OpenAI Responses,
the Messages API), serving, tunnel, tasks, plus the host routes for Time-skip
(server/timeskip.mjs) and the tuning plan/reports. src/lib/time-skip.ts renders a real
job's own record.

The UI design is unchanged. The rebuild routed #/tuning to a new TunePanel; that is
reverted: src/screens/ModelRun.tsx and src/main.tsx are the handoff's again (#/tuning
goes where the handoff sends it), and src/components/TunePanel.tsx and
src/styles/tuning.css, which only that route used, are not carried over. Left out of
git on purpose: dist/ (build output), node_modules, and docs/evidence + docs/checkpoints
(170 MB of screenshots, kept in StrataSplit\evidence-archive).

From the owner's rebuild branch strata/rebuild-2026-10.
2026-10-15 10:24:09 +02:00

23 lines
1.5 KiB
JavaScript

import {execFile} from 'node:child_process';
import {promisify} from 'node:util';
const execute=promisify(execFile);
let cached=null;
export async function systemFonts({platform=process.platform,run=execute}={}){
if(cached&&platform===process.platform&&run===execute)return cached;
const read=(cmd,args)=>run(cmd,args,{timeout:20000,maxBuffer:16*1024*1024,windowsHide:true});
try{
let names=[];
if(platform==='darwin'){
const {stdout}=await read('/usr/sbin/system_profiler',['SPFontsDataType','-json','-detailLevel','mini']);
const collect=value=>{if(!value||typeof value!=='object')return;if(typeof value.family==='string')names.push(value.family);for(const nested of Object.values(value))if(typeof nested==='object')collect(nested);};collect(JSON.parse(stdout));
}else if(platform==='win32'){
const {stdout}=await read('powershell.exe',['-NoProfile','-NonInteractive','-Command','Add-Type -AssemblyName System.Drawing; (New-Object System.Drawing.Text.InstalledFontCollection).Families.Name | ConvertTo-Json -Compress']);
const result=JSON.parse(stdout.replace(/^\uFEFF/,''));names=Array.isArray(result)?result:[result];
}else{
const {stdout}=await read('fc-list',['-f','%{family}\n']);names=stdout.split(/[\n,]/);
}
const fonts=[...new Set(names.filter(name=>typeof name==='string').map(name=>name.trim()).filter(Boolean))].sort((a,b)=>a.localeCompare(b));
const result={fonts,available:fonts.length>0};if(platform===process.platform&&run===execute)cached=result;return result;
}catch{return{fonts:[],available:false};}
}