Files
LTX-DeskWEB/scripts/ui-fixture.mjs
T

31 lines
2.2 KiB
JavaScript

// Explicit synthetic UI fixture. Never contacts Athena or loads a model.
import http from 'node:http'
import { mkdtemp, mkdir } from 'node:fs/promises'
import os from 'node:os'
import path from 'node:path'
import { createApp } from '../server/app.mjs'
const dir=await mkdtemp(path.join(os.tmpdir(),'deskweb-ui-'))
await mkdir(path.join(dir,'output'))
const spec={display_name:'LTX Test Backend (synthetic)',supported_resolutions_durations:{'540p':{fps_to_durations:{'24':[2,4,6]}}},capabilities:{t2v:true,i2v:true,a2v:true,retake:false,extend:false,user_loras:false,ic_lora:false,multi_keyframe:false,multi_keyframe_max_count:0,auto_duration:false}}
const native=http.createServer(async(req,res)=>{
res.setHeader('Content-Type','application/json')
if(req.method!=='GET'){res.writeHead(503);res.end(JSON.stringify({detail:'Synthetic UI fixture: generation disabled'}));return}
const data={
'/health':{status:'ok'},
'/api/runtime-policy':{force_api_generations:false},
'/api/gpu-info':{cuda_available:true,gpu_name:'Synthetic test device'},
'/api/settings':{useLocalTextEncoder:true,modelsDir:'/synthetic/models'},
'/api/generate/models-specs':{local_models:[{pipeline:'fast',spec}],api_models:[]},
'/api/generation/progress':{status:'idle',progress:0,phase:null,currentStep:0,totalSteps:0,result:null,cancellable:false},
'/api/loras':{loras:[],local_loras:[]},
'/api/ic-loras':{ic_loras:[]},
'/api/models/ltx-ic-lora-recommendation':{status:'ready'},
'/api/models/ltx-recommendation':{status:'ready'},
}[req.url]
if(!data){res.writeHead(404);res.end(JSON.stringify({detail:'Not provided by synthetic UI fixture'}));return}
res.end(JSON.stringify(data))
})
await new Promise(resolve=>native.listen(0,'127.0.0.1',resolve))
const server=await createApp({password:'synthetic-browser-test-only',backendToken:'',backendUrl:`http://127.0.0.1:${native.address().port}`,dist:new URL('../dist',import.meta.url).pathname,roots:[{local:path.join(dir,'input'),backend:'/synthetic/inputs',writable:true},{local:path.join(dir,'output'),backend:'/synthetic/outputs'}]})
server.listen(18118,'127.0.0.1',()=>console.log('Synthetic UI fixture on http://127.0.0.1:18118 — no Athena connection'))