import type { ConnectionNode } from "./connections"; export function tvstarShotComposition(goal: string) { const positive = goal.replace(/(?:不要|禁止|不允许|无需|不能|避免|不)[^,。;\n]{0,6}(?:分屏|拼贴|宫格|画中画|split.?screen|collage)/gi, ""); return /分屏|拼贴|宫格|画中画|split.?screen|collage/i.test(positive) ? "只呈现当前镜头指定的布局,不能把其他分镜混入当前镜头。" : "只生成当前镜头的单一完整画面,禁止上下或左右分屏、拼贴、宫格、画中画和分镜板;不要把其他镜头放进同一画幅。"; } /** A film script is a graph dependency; a single frame must consume only its own shot. */ export function scopeTVstarShotInputs(target: ConnectionNode, kind: string, inputs: ConnectionNode[]) { const shotId = target.draftValues?.tvstarShot; if (kind !== "image" || target.draftValues?.source !== "tvstar" || shotId == null) return inputs; return inputs.map(node => { if (!Array.isArray(node.draftValues?.tvstarShots)) return node; const matches = node.draftValues.tvstarShots.filter((shot: any) => String(shot.shot) === String(shotId)); if (matches.length !== 1) throw Error(`镜头 ${shotId} 无法在上游脚本中唯一定位,未生成关键帧`); const shot = matches[0]; const content = [`当前镜头 ${shotId} 的关键帧`, shot.scene, shot.sceneDescription, shot.imagePrompt, shot.shotSize, shot.lighting] .filter(Boolean).join("。 "); return { ...node, draftValues: { ...node.draftValues, content, rows: undefined } }; }); }