Compile image style chips and restore complete input metadata

This commit is contained in:
Towsty
2026-09-11 19:04:03 -05:00
parent b5a4882a9c
commit 86ffa9ba04
5 changed files with 20 additions and 4 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
import {stylePrompt} from '../shared/studio2/styles.mjs'
import test from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs'
@@ -12,7 +13,7 @@ const fn=tree.statements.find(n=>ts.isFunctionDeclaration(n)&&n.name.text==='pre
const js=ts.transpileModule(fn.getText(tree),{compilerOptions:{target:ts.ScriptTarget.ES2022}}).outputText
async function prepare(request){
const uploads=[]
const scope={useRuntimeConfig:()=>({comfyFilenamePrefix:'preview'}),upload:async(r,label)=>{uploads.push(label);return label+'.png'},readFileSync:()=>Buffer.from('fixture'),stillPath:()=>'',getStill:(_,id)=>({id}),resolveRequestSize:async()=>{},saveRecord(){},
const scope={stylePrompt,useRuntimeConfig:()=>({comfyFilenamePrefix:'preview'}),upload:async(r,label)=>{uploads.push(label);return label+'.png'},readFileSync:()=>Buffer.from('fixture'),stillPath:()=>'',getStill:(_,id)=>({id}),resolveRequestSize:async()=>{},saveRecord(){},
buildImageV2Workflow:params=>{const graph=structuredClone(template);graph['1'].inputs.image=params.imageAName;return {graph}},sampleKleinSource,attachHeroReference,applyResolvedImageSize,ensureComfyLoraNames:async()=>{},resolveGraphLoraNames(){}}
const run=new Function(...Object.keys(scope),`${js};return prepareGraph`)(...Object.values(scope))
const record={request,owner:'o',id:'job',index:0};return {graph:await run(record),record,uploads}