@ninkch/dsh-infinite-canvas 0.20.2 → 0.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -456,6 +456,8 @@ function revealCanvasInRight() {
456
456
  'segPlanHint': '按真实镜头边界把分镜切成若干次生成:切点只在换场/特写插入/新角色入场处;同一段连续动作不拆开。',
457
457
  'segMaxLabel': '单段上限',
458
458
  'segMaxHint': '单次生成的最大秒数(按厂商上限填,MiniMax 这类弱衔接模型建议 6–10 秒)',
459
+ 'targetDurationLabel': '分镜总时长',
460
+ 'targetDurationAuto': '按镜头节奏自动',
459
461
  'customValuePh': '自定义后回车',
460
462
  'customCountPh': '自定义 1–100 镜',
461
463
  'customSegMaxPh': '自定义 1–300 秒',
@@ -893,7 +895,6 @@ function revealCanvasInRight() {
893
895
  'videoApi': '视频 API(提交 + 轮询)',
894
896
  'baseUrl': '接口地址',
895
897
  'apiKey': 'API Key',
896
- 'model': '模型',
897
898
  'size': '尺寸',
898
899
  'apiHintImage': '留空则使用内置演示模式(本地合成占位图)。配置后请求 POST {baseUrl}/images/generations。',
899
900
  'apiHintVideo': 'POST 接口地址提交任务,轮询 GET {url}/{taskId} 直到返回视频地址;留空则使用演示模式(本地合成动画视频)。',
@@ -1060,11 +1061,7 @@ function revealCanvasInRight() {
1060
1061
  'defaultVideoCfg': '默认视频模型',
1061
1062
  'imageApisLabel': '图片模型(可配多个)',
1062
1063
  'videoApisLabel': '视频模型(可配多个)',
1063
- 'addConfig': '新增配置',
1064
- 'setDefault': '设为默认',
1065
- 'isDefault': '默认',
1066
1064
  'cfgName': '名称',
1067
- 'delConfig': '删除此配置',
1068
1065
  'noCfgHint': '尚未配置;生成节点将使用演示模式',
1069
1066
  'bibleTab': '设定集',
1070
1067
  'bibleStyle': '风格基调(画风、年代、色调…跨集保持一致)',
@@ -1280,7 +1277,6 @@ function revealCanvasInRight() {
1280
1277
  'renamed': '已重命名',
1281
1278
  'llmMaxTokens': '输出上限 maxTokens',
1282
1279
  'llmTemperature': '温度 temperature',
1283
- 'llmParamAuto': '留空 = 用 Harness/模型默认',
1284
1280
  'llmParamHint': '留空则不下发该参数,直接使用你在 Harness 里为该模型配置的默认值(插件不会写死任何生成参数)',
1285
1281
  'imgSizeOverride': '尺寸覆盖 size',
1286
1282
  'imgSizePlaceholder': '如 1024x1024(留空=按清晰度×比例)',
@@ -1467,6 +1463,8 @@ function revealCanvasInRight() {
1467
1463
  'segPlanHint': 'Split the storyboard into several generations at real shot boundaries: cuts only land on scene change / insert / new character; one continuous action is never split.',
1468
1464
  'segMaxLabel': 'Per-segment max',
1469
1465
  'segMaxHint': 'Max seconds per generation (match the vendor limit; for weak-continuity models like MiniMax use 6-10s)',
1466
+ 'targetDurationLabel': 'Storyboard total duration',
1467
+ 'targetDurationAuto': 'Auto by shot pacing',
1470
1468
  'customValuePh': 'Custom, press Enter',
1471
1469
  'customCountPh': 'Custom 1-100 shots',
1472
1470
  'customSegMaxPh': 'Custom 1-300 seconds',
@@ -1904,7 +1902,6 @@ function revealCanvasInRight() {
1904
1902
  'videoApi': 'Video API (submit + poll)',
1905
1903
  'baseUrl': 'Base URL',
1906
1904
  'apiKey': 'API Key',
1907
- 'model': 'Model',
1908
1905
  'size': 'Size',
1909
1906
  'apiHintImage': 'Leave empty to use the built-in demo mode (local placeholder images). When set, requests go to POST {baseUrl}/images/generations.',
1910
1907
  'apiHintVideo': 'POSTs the task to the URL and polls GET {url}/{taskId} until a video URL appears; leave empty for demo mode.',
@@ -2071,11 +2068,7 @@ function revealCanvasInRight() {
2071
2068
  'defaultVideoCfg': 'Default video model',
2072
2069
  'imageApisLabel': 'Image models (multiple)',
2073
2070
  'videoApisLabel': 'Video models (multiple)',
2074
- 'addConfig': 'Add config',
2075
- 'setDefault': 'Make default',
2076
- 'isDefault': 'default',
2077
2071
  'cfgName': 'Name',
2078
- 'delConfig': 'Delete this config',
2079
2072
  'noCfgHint': 'Nothing configured yet; generation nodes will use demo mode',
2080
2073
  'bibleTab': 'Bible',
2081
2074
  'bibleStyle': 'Style baseline (art, era, palette… kept across episodes)',
@@ -2292,7 +2285,6 @@ function revealCanvasInRight() {
2292
2285
  'renamed': 'Renamed',
2293
2286
  'llmMaxTokens': 'Output cap (maxTokens)',
2294
2287
  'llmTemperature': 'Temperature',
2295
- 'llmParamAuto': 'empty = Harness/model default',
2296
2288
  'llmParamHint': 'Left empty, the parameter is not sent at all — the model uses the default you configured in Harness. The plugin never hardcodes generation parameters.',
2297
2289
  'imgSizeOverride': 'Size override',
2298
2290
  'imgSizePlaceholder': 'e.g. 1024x1024 (empty = clarity × ratio)',
@@ -3597,6 +3589,7 @@ body[data-ds-dark-theme] .dshic-storage-details{border-color:var(--dsw-alias-bor
3597
3589
  .dshic-pick-menu{position:fixed;z-index:240;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dshic-line2);border-radius:14px;box-shadow:var(--dshic-shadow-lg);display:flex;flex-direction:column;max-height:280px;overflow:hidden;box-sizing:border-box;}
3598
3590
  body[data-ds-dark-theme] .dshic-pick-menu{border-color:var(--dsw-alias-border-l2);}
3599
3591
  .dshic-pick-search{padding:7px;border-bottom:1px solid var(--dshic-line);flex:none;}
3592
+ .dshic-pick-search.is-flipped{border-bottom:none;border-top:1px solid var(--dshic-line);}
3600
3593
  .dshic-pick-search .dshic-input{height:26px;font-size:12px;}
3601
3594
  .dshic-pick-list{overflow-y:auto;padding:5px;flex:1;}
3602
3595
  /* 下拉 / 文本正文 / 分镜清单:滚动条必须可见且可命中;不能用系统默认的淡细条。
@@ -3645,8 +3638,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3645
3638
  videoProviders: [], // [{id, name, url, apiKey, extra, outputFormat?, generateAudio?, protocol?, watermark?, models: [{id, model}]}]
3646
3639
  imageStar: '', // 'providerId|modelId'
3647
3640
  videoStar: '',
3648
- ttsApis: [], // [{id, name, baseUrl, apiKey, model, voice}]
3649
- ttsApiId: '',
3641
+ ttsProviders: [], // [{id, name, baseUrl, apiKey, timeoutMs?, models: [{id, model, voice}]}] —— voice 每模型一个,timeoutMs 供应商级
3642
+ ttsStar: '', // 'providerId|modelId'
3650
3643
  lang: '', // '' = 跟随 Harness
3651
3644
  };
3652
3645
  function loadSettings() {
@@ -3659,8 +3652,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3659
3652
  videoStar: s.videoStar || '',
3660
3653
  // dsh-image-gen 桥接:启用后画布不自配图片 API,直接走它的 /studio(密钥留在它宿主侧)
3661
3654
  imageGen: { enabled: !!(s.imageGen && s.imageGen.enabled), provider: (s.imageGen && s.imageGen.provider) || '', model: (s.imageGen && s.imageGen.model) || '' },
3662
- ttsApis: Array.isArray(s.ttsApis) ? s.ttsApis : [],
3663
- ttsApiId: s.ttsApiId || '',
3655
+ ttsProviders: Array.isArray(s.ttsProviders) ? s.ttsProviders : [],
3656
+ ttsStar: s.ttsStar || '',
3664
3657
  lang: s.lang || '',
3665
3658
  // 专家:缺字段/非法值/旧字段(skillScript/skillStoryboard)→ 一律回退 general,不报错
3666
3659
  };
@@ -3707,12 +3700,34 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3707
3700
  legacyVideoApiRefMap = {};
3708
3701
  for (const cfg of s.videoApis) legacyVideoApiRefMap[cfg.id] = 'p_' + cfg.id + '|m_' + cfg.id;
3709
3702
  }
3703
+ // v0.20.2 及以前 TTS 扁平 API(一配置一模型一 voice)→ 供应商 + 模型列表(issue #6 第二阶段):
3704
+ // 与 image/video 同规:派生 id 确定性沿用旧 cfg id(loadSettings 高频调用,绝不用 uid());
3705
+ // 节点数据只存 data.tts[edgeId] = {status, assetId}(无 ttsApiId),零节点迁移负担
3706
+ if (!out.ttsProviders.length && Array.isArray(s.ttsApis) && s.ttsApis.length) {
3707
+ out.ttsProviders = s.ttsApis.map((cfg) => ({
3708
+ id: 'p_' + cfg.id, name: cfg.name || T('defaultTtsCfg'),
3709
+ baseUrl: cfg.baseUrl || '', apiKey: cfg.apiKey || '',
3710
+ timeoutMs: cfg.timeoutMs || '',
3711
+ models: [{ id: 'm_' + cfg.id, model: cfg.model || '', voice: cfg.voice || 'alloy' }],
3712
+ }));
3713
+ out.ttsStar = (s.ttsApiId && 'p_' + s.ttsApiId + '|m_' + s.ttsApiId) || (out.ttsProviders[0] ? out.ttsProviders[0].id + '|' + out.ttsProviders[0].models[0].id : '');
3714
+ }
3710
3715
  return out;
3711
3716
  }
3712
3717
  function saveSettings(s) {
3713
3718
  lsSet(LS_SETTINGS, s);
3714
3719
  notify(); // 设置即改即存(无保存按钮),但必须通知画布重渲染——否则节点上的模型下拉/星标一直是旧快照
3715
3720
  }
3721
+ /** 设置卡写回:以磁盘最新值为基底叠加本卡变更,杜绝跨卡丢失更新(issue #6)。
3722
+ * 旧模式(每张卡持有挂载时快照、把整对象写回)会让卡 B 的任何保存把卡 A 刚写的字段静默回滚。
3723
+ * base = loadSettings() 现取;apply(base) 返回改了本卡字段的副本;写回 + notify。
3724
+ * 返回写回后的新设置——调用方必须 setS(返回值) 同步本地快照,否则同卡二次编辑的渲染基底仍陈旧。 */
3725
+ function updateSettings(apply) {
3726
+ const base = loadSettings();
3727
+ const next = apply(base);
3728
+ saveSettings(next);
3729
+ return next;
3730
+ }
3716
3731
 
3717
3732
  // ---------- 供应商 + 模型(图片/视频):扁平视图与解析 ----------
3718
3733
  let legacyImageApiRefMap = {}; // 旧扁平配置 id → 'providerId|modelId'(节点字段懒迁移用)
@@ -3742,6 +3757,17 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3742
3757
  }
3743
3758
  return out;
3744
3759
  }
3760
+ /** 供应商列表 → 扁平 TTS 模型视图(ref = 'providerId|modelId');未填模型名的条目不进下拉(与 image/video 同规)。 */
3761
+ function flattenTtsModels(settings) {
3762
+ const out = [];
3763
+ for (const p of settings.ttsProviders || []) {
3764
+ for (const m of (p.models || [])) {
3765
+ if (!m || !m.id || !String(m.model || '').trim()) continue;
3766
+ out.push({ ref: p.id + '|' + m.id, providerId: p.id, providerName: p.name || p.id, modelId: m.id, model: String(m.model).trim(), voice: m.voice || 'alloy', baseUrl: p.baseUrl || '', apiKey: p.apiKey || '', timeoutMs: p.timeoutMs || '' });
3767
+ }
3768
+ }
3769
+ return out;
3770
+ }
3745
3771
  /** 解析节点上的模型引用:空 = 星标默认模型;都没有 = null(运行时报错)。 */
3746
3772
  function resolveImageModelCfg(settings, ref) {
3747
3773
  const list = flattenImageModels(settings);
@@ -6612,6 +6638,7 @@ function queueThumb(assetId) {
6612
6638
  kling: { label: '快手可灵 Kling', base: 'https://api.klingai.com', keyPh: 'AK:SK(冒号分隔)', note: 'Key 填 AK:SK,代码自动签 JWT;国际站把 Base URL 改为 api-singapore.klingai.com;时长按官方 5/10s 取整' },
6613
6639
  wan: { label: '阿里通义万相 Wan(DashScope)', base: 'https://dashscope.aliyuncs.com', note: '异步任务制;国际站把 Base URL 改为 dashscope-intl.aliyuncs.com;图生视频走 img_url' },
6614
6640
  sanbao: { label: '三宝影像工坊(Sanbao 多参考)', base: 'https://sanbaobeauty.com', keyPh: 'sk-sanbao-…', note: '任务制 /openapi/v1/videos;本地素材 dataURL 直传(全模型 media_inputs 含 data_url,已实测);报图片格式错误自动用扩展参数 {"uploadKey":"sk-sanbao-…"} 指定的专用 key 上传 /openapi/v1/uploads/raw 转公网 URL 后重试一次;resolution 小写(480p/720p/1080p/2k);reference 固定 all(可扩展参数覆盖);参考图上限按模型:wan/kling 系 10、hailuo/SD2.0 系 9、SD2.5 系 30,音频 3–10' },
6641
+ api6789: { label: '6789API(任务制 /v1/videos)', base: '', keyPh: 'sk-…', note: '任务制三段式:POST /v1/videos(Idempotency-Key 幂等)→ GET /v1/videos/{id} 每 5s 轮询 → file/download_url 或 /content 下载(任务成功后 CDN 就绪需等待:10 分钟重试窗口每 30s 一次)。请求体按模型分两族:seedance* 用 duration/ratio/resolution/image_urls(resolution 小写;seedance2.5 参考图 30 张、其余 9 张);minimax* 用 seconds/size/workflow_id/images(比例×清晰度映射精确像素尺寸,2K/4K 大写且必须至少 1 张参考图,seconds 5–15)。Base URL 填站点根(…/v1、…/v1/videos 自动归一);任何同格式站点都能用。本地参考图 dataURL 直发,站方要求公网直链时用扩展参数 {"image_urls":["https://…"]}(minimax 系字段名 images)直给' },
6615
6642
  minimax: { label: 'MiniMax 海螺视频(V1 协议)', base: 'https://api.minimaxi.com', note: '异步任务制;时长按官方 6/10s 取整;首帧图支持 base64' },
6616
6643
  minimaxv2: { label: 'MiniMax H3 · V2 协议(优云智算 / 官方)', base: 'https://cp.compshare.cn', keyPh: 'sk-ml-…', note: 'V2 协议自动适配:优云智算走 /minimax/v2,官方(api.minimax.io/.cn)走 /v2;content[] 多模态(首帧/尾帧/参考图≤9/视频≤3/音频≤3),原生音频,分辨率 480P/768P/1080P/2K/4K(大小写敏感),时长 4-30s;use_context_ir / mute_audio 等走扩展参数' },
6617
6644
  vidu: { label: '生数科技 Vidu', base: 'https://api.vidu.com', note: '图片支持 base64;时长按官方 4/8s 取整' },
@@ -6861,6 +6888,120 @@ function queueThumb(assetId) {
6861
6888
  if (!/^https?:/.test(String(url || ''))) throw new Error('Sanbao 素材上传未返回 file.url');
6862
6889
  return url;
6863
6890
  }
6891
+ // —— 6789API:任务制 /v1/videos(同一路径按模型分两族请求体:seedance* / minimax*)——
6892
+ /** 6789 图片数组上限(纯函数供回归断言):seedance2.5 系 30 张、其余 9 张。 */
6893
+ function api6789ImageCap(model) {
6894
+ return /2\.5/.test(String(model || '')) ? 30 : 9;
6895
+ }
6896
+ /** 6789 请求体(纯函数供回归断言):按模型名分两族——
6897
+ * · seedance*:{model, prompt, duration, ratio, resolution(小写), image_urls?}
6898
+ * 时长/比例/分辨率一律透传(站方校验、报错可见,绝不静默裁剪);
6899
+ * · minimax*:{model, prompt, seconds, size, workflow_id, images?}
6900
+ * 比例×清晰度必须映射为精确像素 size(2K/4K 大写);workflow_id 自动选:
6901
+ * 无图 text-to-video / 有图普通 multi-reference / 有图 2K/4K cf-multi-reference。
6902
+ * images:首帧在前、参考图在后(dataURL 直发;站方要公网直链时扩展参数覆盖)。 */
6903
+ function build6789VideoBody(spec, media) {
6904
+ const sp = spec || {};
6905
+ const m = media || {};
6906
+ const model = String(sp.model || '').toLowerCase();
6907
+ const frame = String(m.frameDataUrl || '');
6908
+ const refs = (Array.isArray(m.refDataUrls) ? m.refDataUrls : []).map(String).filter(Boolean);
6909
+ const isMini = model.includes('minimax');
6910
+ if (isMini) {
6911
+ const out = {
6912
+ model,
6913
+ prompt: String(sp.prompt || ''),
6914
+ seconds: Math.round(Number(sp.duration)) || 5,
6915
+ size: api6789SizeOf(sp.ratio, sp.resolution),
6916
+ workflow_id: 'text-to-video',
6917
+ };
6918
+ const images = (frame ? [frame] : []).concat(refs);
6919
+ if (images.length) {
6920
+ out.images = images;
6921
+ out.workflow_id = /^2K$|^4K$/i.test(String(out.size)) ? 'cf-multi-reference' : 'multi-reference';
6922
+ }
6923
+ return out;
6924
+ }
6925
+ const out = {
6926
+ model,
6927
+ prompt: String(sp.prompt || ''),
6928
+ duration: Math.round(Number(sp.duration)) || 5,
6929
+ ratio: String(sp.ratio || '16:9'),
6930
+ resolution: String(sp.resolution || '720p').toLowerCase(),
6931
+ };
6932
+ const images = (frame ? [frame] : []).concat(refs);
6933
+ if (images.length) out.image_urls = images;
6934
+ return out;
6935
+ }
6936
+ /** 6789 minimax 系尺寸映射(纯函数供回归断言):普通清晰度 = 比例×清晰度档的精确像素;
6937
+ * 2K/4K 直接大写(站方要求)。480p 不在枚举 → 按最接近的 768P 档处理并告警可见。 */
6938
+ function api6789SizeOf(ratio, resolution) {
6939
+ const res = String(resolution || '720p').toLowerCase();
6940
+ if (res.includes('2k')) return '2K';
6941
+ if (res.includes('4k')) return '4K';
6942
+ const hd = res.includes('1080');
6943
+ const r = String(ratio || '16:9');
6944
+ const MAP = {
6945
+ // 720P 档 1080P 档
6946
+ '16:9': ['1376x768', '1920x1088'],
6947
+ '9:16': ['768x1376', '1088x1920'],
6948
+ '1:1': ['1024x1024', '1440x1440'],
6949
+ '4:3': ['1184x896', '1664x1248'],
6950
+ '3:4': ['896x1184', '1248x1664'],
6951
+ '21:9': ['1568x672', '2208x960'],
6952
+ };
6953
+ const pair = MAP[r] || MAP['16:9'];
6954
+ return hd ? pair[1] : pair[0];
6955
+ }
6956
+ /** 6789 任务 id(纯函数):顶层 id / task_id,兼容 data 包装(data.task_id / data.id)。 */
6957
+ function api6789TaskIdOf(j) {
6958
+ if (!j || typeof j !== 'object') return null;
6959
+ return j.id ?? j.task_id ?? (j.data && (j.data.task_id ?? j.data.id)) ?? null;
6960
+ }
6961
+ /** 6789 状态(纯函数):顶层 status,兼容 data 包装(data.status)。 */
6962
+ function api6789StatusOf(j) {
6963
+ if (!j || typeof j !== 'object') return '';
6964
+ return String(j.status ?? (j.data && j.data.status) ?? '').trim().toLowerCase();
6965
+ }
6966
+ /** 6789 结果地址(纯函数):优先绝对地址(download_url → video_url → content/output.video_url →
6967
+ * data.video_url),file 为相对路径(/v1/videos/{id}/content)时原样返回(调用方拼 origin)。
6968
+ * 空串视为「未提供」(站方成功响应里 file/download_url 可为 '')。 */
6969
+ function api6789VideoUrlOf(j) {
6970
+ if (!j || typeof j !== 'object') return '';
6971
+ const d = (j.data && typeof j.data === 'object') ? j.data : {};
6972
+ const cands = [j.download_url, j.video_url, d.download_url, d.video_url,
6973
+ j.content && j.content.video_url, j.output && j.output.video_url];
6974
+ const abs = cands.find((u) => typeof u === 'string' && /^https?:/i.test(u));
6975
+ if (abs) return abs;
6976
+ const file = [j.file, d.file].find((u) => typeof u === 'string' && u.startsWith('/'));
6977
+ return file || '';
6978
+ }
6979
+ /** 6789 失败原因(纯函数):error → fail_reason → message → data.error。 */
6980
+ function api6789ErrorOf(j) {
6981
+ if (!j || typeof j !== 'object') return '';
6982
+ const d = (j.data && typeof j.data === 'object') ? j.data : {};
6983
+ const v = j.error || j.fail_reason || j.message || d.error || '';
6984
+ if (!v) return '';
6985
+ return (typeof v === 'string' ? v : JSON.stringify(v)).slice(0, 300);
6986
+ }
6987
+ /** 6789 轮询判定(纯函数):queued/running 及未知状态 = 继续;成功集合取地址;
6988
+ * 失败集合报错。与站方文档枚举一致(含 cancelled/canceled/expired)。 */
6989
+ function api6789PollState(j) {
6990
+ const st = api6789StatusOf(j);
6991
+ if (['succeeded', 'completed', 'success'].includes(st)) {
6992
+ const url = api6789VideoUrlOf(j);
6993
+ return url ? { state: 'done', url } : { state: 'fail', error: '任务成功但响应中没有视频地址' };
6994
+ }
6995
+ if (['failed', 'error', 'cancelled', 'canceled', 'expired'].includes(st)) {
6996
+ return { state: 'fail', error: api6789ErrorOf(j) || st };
6997
+ }
6998
+ return { state: 'wait' };
6999
+ }
7000
+ /** 6789 本地素材是否需要「公网直链」类重试提示(纯函数):只认图片/URL/格式类错误。 */
7001
+ function needs6789MediaHint(errText) {
7002
+ const t = String(errText || '');
7003
+ return /https?:|url|图片|image|格式|format/i.test(t);
7004
+ }
6864
7005
  /** 读取生成视频的真实尺寸与时长(用于「厂商是否忽略了参数」的可见校验)。 */
6865
7006
  function probeVideoMeta(blob) {
6866
7007
  return new Promise((resolve) => {
@@ -7117,6 +7258,91 @@ function queueThumb(assetId) {
7117
7258
  throw err;
7118
7259
  }
7119
7260
  },
7261
+ // —— 6789API:任务制 /v1/videos,同一路径按模型分两族请求体(seedance* / minimax*)——
7262
+ async api6789(prompt, frameBlob, s, o) {
7263
+ if (!s.url) throw new Error('未配置视频 API(6789API 格式:Base URL 填站点根,…/v1 自动归一)');
7264
+ if (!s.model) throw new Error('请在设置里为该视频 API 填写模型名(如 seedance2.0fast / minimax-h3)');
7265
+ const base = vendorBase(s.url, '');
7266
+ if (!base) throw new Error('6789API 需要填写 Base URL');
7267
+ const headers = { 'Content-Type': 'application/json', Authorization: 'Bearer ' + (s.apiKey || '') };
7268
+ const model = String(s.model || '').toLowerCase();
7269
+ const isMini = model.includes('minimax');
7270
+ // 参考图装填:首帧在前、参考图在后;上限按模型(2.5 系 30、其余 9)——超限告警可见
7271
+ const cap = api6789ImageCap(model);
7272
+ const rawRefs = o.hardFrame ? [] : (o.refs || []).slice(0, cap);
7273
+ if (o.warn && (o.refs || []).length > rawRefs.length) {
7274
+ o.warn('参考图 ' + (o.refs || []).length + ' 张超过「' + model + '」上限 ' + cap + ' 张,本次只使用前 ' + cap + ' 张');
7275
+ }
7276
+ let text = prompt;
7277
+ if (frameBlob && rawRefs.length) text = videoRefNote(o.refNames) + '\n' + prompt;
7278
+ // 本地素材 dataURL 直发(宽松尝试,与通用链同口径);站方要求公网直链时报错原文透传
7279
+ const media = {
7280
+ frameDataUrl: frameBlob ? await blobToDataUrlScaled(frameBlob) : '',
7281
+ refDataUrls: await Promise.all(rawRefs.map((b) => blobToDataUrlScaled(b))),
7282
+ };
7283
+ const spec = { model, prompt: text, duration: o.duration, ratio: o.ratio, resolution: o.resolution || '720p' };
7284
+ const body = build6789VideoBody(spec, media);
7285
+ // minimax 系 2K/4K 必须至少 1 张参考图(站方文档硬约束)——提交前明确报错
7286
+ if (isMini && /^2K$|^4K$/i.test(String(body.size)) && !(body.images || []).length) {
7287
+ throw new Error('「' + model + '」的 ' + body.size + ' 清晰度必须至少提供 1 张参考图(站方硬约束):请连线参考图,或把清晰度改成 720P/1080P');
7288
+ }
7289
+ // 480p 不在 minimax 尺寸枚举 → 降档可见告警(build 内已按 768P 档映射)
7290
+ if (isMini && o.warn && String(o.resolution || '').toLowerCase().includes('480')) {
7291
+ o.warn('「' + model + '」没有 480p 尺寸档,本次按 768P 档发送(可选 720P/1080P/2K/4K)');
7292
+ }
7293
+ // 扩展参数:逃生舱(可覆盖任意字段,如 {"image_urls":["https://…"]} 公网直链直给)
7294
+ mergeExtra(body, s);
7295
+ // 幂等键:本次生成固定一个 UUID,网络重试复用(站方文档要求)
7296
+ const idem = (globalThis.crypto && crypto.randomUUID) ? crypto.randomUUID() : ('idem-' + Date.now().toString(36) + Math.random().toString(36).slice(2));
7297
+ const submitUrl = base + '/v1/videos';
7298
+ const r1 = await fetchViaProxy(submitUrl, { headers: { ...headers, 'Idempotency-Key': idem }, body, timeoutMs: Number(s.timeoutMs) > 0 ? Number(s.timeoutMs) : 120000, label: '6789 提交' });
7299
+ if (!r1.ok) {
7300
+ const hint = needs6789MediaHint(r1.text) && (frameBlob || rawRefs.length)
7301
+ ? '——该站参考图要求公网 https 直链:可在扩展参数填 {"image_urls":["https://…"]}(minimax 系字段名 images)直给,或改用文生视频'
7302
+ : '';
7303
+ throw new Error('6789 提交 HTTP ' + r1.status + ' @ ' + submitUrl + ':' + r1.text.slice(0, 300) + hint);
7304
+ }
7305
+ let j1 = null; try { j1 = JSON.parse(r1.text); } catch { throw new Error('6789 响应非 JSON:' + r1.text.slice(0, 200)); }
7306
+ const tid = api6789TaskIdOf(j1);
7307
+ if (!tid) throw new Error('6789 响应中没有任务 id:' + r1.text.slice(0, 200));
7308
+ const taskUrl = base + '/v1/videos/' + encodeURIComponent(tid);
7309
+ if (o.onTask) { try { o.onTask(tid, taskUrl); } catch { /* 持久化失败不影响生成 */ } }
7310
+ const queryTask = async (label) => {
7311
+ const r = await fetchViaProxy(taskUrl, { method: 'GET', headers, timeoutMs: 60000, label });
7312
+ if (!r || !r.ok) return null;
7313
+ try { return JSON.parse(r.text); } catch { return null; }
7314
+ };
7315
+ // 站方建议每 5s 查询一次;画布最长轮询 30 分钟(任务 id 已挂节点,超时可凭 id 回查)
7316
+ const url = await vendorPoll('6789', 5000, async () => {
7317
+ const j = await queryTask('6789 查询');
7318
+ return j ? api6789PollState(j) : { state: 'wait' };
7319
+ });
7320
+ // 任务成功 ≠ 文件可下载:CDN 就绪窗口内重试(10 分钟、每 30s 一次,与三宝同款口径)。
7321
+ // file 相对路径 → 拼 origin 且带 Bearer 下载;绝对地址裸 GET、401/403 自动带鉴权重试;
7322
+ // 每次重试前重查任务刷新地址(download_url 可能是带 exp 的签名地址,会过期)。
7323
+ const origin = (() => { try { return new URL(base).origin; } catch { return ''; } })();
7324
+ const dlHeaders = (u) => String(u || '').startsWith('/') ? headers
7325
+ : (() => { try { return new URL(u).origin === origin ? headers : {}; } catch { return {}; } })();
7326
+ try {
7327
+ return await downloadVideoWithRetry(url, dlHeaders(url), {
7328
+ windowMs: SANBAO_DOWNLOAD_RETRY_MS,
7329
+ stepMs: SANBAO_DOWNLOAD_RETRY_STEP_MS,
7330
+ refreshUrl: async () => {
7331
+ const j = await queryTask('6789 缓存查询');
7332
+ if (!j) return '';
7333
+ const st = api6789PollState(j);
7334
+ return st.state === 'done' ? st.url : '';
7335
+ },
7336
+ onRetry: (e, n) => {
7337
+ try { console.info('[IC] 6789 download not ready (' + ((e && e.message) || e) + ') — retry ' + n); } catch { /* 忽略 */ }
7338
+ },
7339
+ });
7340
+ } catch (e) {
7341
+ const err = new Error('6789 视频下载失败(任务 ' + tid + '):' + ((e && e.message) || e));
7342
+ err.status = e && e.status;
7343
+ throw err;
7344
+ }
7345
+ },
7120
7346
  // —— MiniMax 海螺:异步 task_id + query 接口 ——
7121
7347
  async minimax(prompt, frameBlob, s, o) {
7122
7348
  const base = vendorBase(s.url, VIDEO_VENDORS.minimax.base);
@@ -7410,6 +7636,8 @@ function queueThumb(assetId) {
7410
7636
  // 三宝:按最保守通用模型(hailuo/SD2.0 系 9 图 3 音频;wan/kling 系 10 图、SD2.5 系 30 图,见厂商 note)
7411
7637
  sanbao: { img: 9, audio: 3 },
7412
7638
  minimaxv2: { img: 9, audio: 3 },
7639
+ // 6789:seedance2.5 系 30 图、其余 9 图(api6789ImageCap 按模型取精确值,此处按保守 9 告警)
7640
+ api6789: { img: 9 },
7413
7641
  openai: { img: 8 },
7414
7642
  seedance: { img: 8 },
7415
7643
  // img:0 = 该厂商的协议**没有任何实体参考图入口**(已核对各自 runner:只收首帧/提示词)——
@@ -7618,11 +7846,6 @@ function queueThumb(assetId) {
7618
7846
  return ['succeeded', 'success', 'completed', 'complete', 'done', 'finished'].includes(taskStatusOf(st));
7619
7847
  }
7620
7848
 
7621
- function resolveApiCfg(list, defId, wantId) {
7622
- if (!Array.isArray(list) || !list.length) return null;
7623
- return list.find((x) => x.id === wantId) || list.find((x) => x.id === defId) || list[0];
7624
- }
7625
-
7626
7849
  /** PCM 采样数组 → WAV Blob(单声道 16-bit,声音参考不需要立体声)。 */
7627
7850
  function pcmToWavBlob(samples, sampleRate) {
7628
7851
  const n = samples.length;
@@ -9303,6 +9526,11 @@ function queueThumb(assetId) {
9303
9526
  const bible = bibleBlock(loadBible(S.activeId));
9304
9527
  const zh = effLang() !== 'en';
9305
9528
  const contOn = !(opts && opts.cont === false); // 分镜衔接开关(默认开)
9529
+ // 分镜总时长(issue:下拉硬约束):targetDuration > 0 = 用户手动设定的**本分镜节点总时长**,
9530
+ // 严格 =X 秒——不论切 5 镜还是 50 镜,所有镜头 duration 之和必须等于 X;技能只管按节奏谱系
9531
+ // 把 X 分配到各镜(快冲突 0.3-0.8s / 对白 2-4s / 情绪长镜 ≥5s),装不下压每镜时长而非删戏。
9532
+ // 0/缺省 = 自动档:与旧版逐字一致(节奏自然决定,无硬上限)。
9533
+ const targetDuration = Math.max(0, Math.round(Number(opts && opts.targetDuration) * 10) / 10) || 0;
9306
9534
  // 特效演绎开关:任一所选题材/影调卡 fx_motion:true → 追加特效演绎扩展块(见 FX_RULES)
9307
9535
  const fxOn = await fxMotionEnabledFor(S.activeId);
9308
9536
  const contFields = (() => {
@@ -9391,7 +9619,11 @@ function queueThumb(assetId) {
9391
9619
  '- **Never use straight double quotes " inside JSON string values** — quoted text (signs/subtitles/lines) uses 「」 instead;',
9392
9620
  '- **Split shots by actual content**: one continuous action beat = one shot; the count is decided by the content (3-10 shots are all normal) — never pad, never use a fixed number;',
9393
9621
  '- **[SEGMENTATION-FRIENDLY - HARD] shot boundaries must land where a cut can actually happen**: the system splits this storyboard into several generations, and a split is only allowed on a "cut" boundary - scene change / insert close-up / new character enters. Therefore: never break ONE character\'s ONE continuous action into several `continuation` shots (give that single shot a longer duration instead) - if it gets split across two generations, the two clips cannot be matched. When you genuinely change the camera, make the next shot one of scene change / insert close-up / new character (even a single insert close-up is enough) so the boundary is a clean cut rather than a forced match. **Do not fake it**: never label shots `scene_change` just to create cut points inside the same space - that reads as a jump;',
9394
- '- duration is the shot length in seconds, **one decimal allowed**; **assign by pacing spectrum, never uniform**: normal narrative/dialogue 2-4s, fast conflict/fight/chase 0.3-0.8s (rapid cuts), key reversal/impact 1-2s, long emotional take >=5s — every scene must contain at least one obvious rhythm change (e.g. 3s narrative -> 0.6s cuts x2 -> 1.5s reversal -> 5s emotional take); identical durations kill the rhythm; total duration follows what the scene needs - no hard cap (vendor limits differ and change; if exceeded the video call reports it explicitly, then you split or adjust); shot order = narrative order; last shot lands the emotion; **if a CONTINUITY CONSTRAINT is given below, shot 1 must continue the previous scene\'s last frame and character state (no re-establishing, no wide reset); only without a constraint does shot 1 establish the scene**;',
9622
+ '- duration is the shot length in seconds, **one decimal allowed**; **assign by pacing spectrum, never uniform**: normal narrative/dialogue 2-4s, fast conflict/fight/chase 0.3-0.8s (rapid cuts), key reversal/impact 1-2s, long emotional take >=5s — every scene must contain at least one obvious rhythm change (e.g. 3s narrative -> 0.6s cuts x2 -> 1.5s reversal -> 5s emotional take); identical durations kill the rhythm; '
9623
+ + (targetDuration
9624
+ ? '**[TOTAL DURATION - HARD USER OVERRIDE] the user has fixed this storyboard\'s TOTAL duration at exactly ' + targetDuration + 's**: the sum of ALL shot durations must equal ' + targetDuration + 's (±0.3s rounding tolerance on the last shot, then settle). Distribute ' + targetDuration + 's across shots by the pacing spectrum above; more shots = each shot gets proportionally less, fewer shots = more each; when content cannot fit, compress per-shot durations — never drop dialogue or key actions; a shot may go below its usual spectrum floor if needed (a 0.5s beat is legal), but the TOTAL is inviolable'
9625
+ : 'total duration follows what the scene needs - no hard cap (vendor limits differ and change; if exceeded the video call reports it explicitly, then you split or adjust)')
9626
+ + '; shot order = narrative order; last shot lands the emotion; **if a CONTINUITY CONSTRAINT is given below, shot 1 must continue the previous scene\'s last frame and character state (no re-establishing, no wide reset); only without a constraint does shot 1 establish the scene**;',
9395
9627
  '- **Pick the shot size by emotion**: loneliness/despair/grand crisis = wide; confrontation/action/relationship = full; dialogue/probing/info exchange = medium; shock/suspicion/inner shake = close-up; breakdown/screaming/emotional burst = extreme close-up; key detail/prop reveal = big close-up — conflicts play wide, reveals move close, bursts go extreme, reversals can pull wide; the changing distance itself tells the emotion;',
9396
9628
  '- **Rapid cuts (<1.5s) get minimal visual/motion** (one action, one piece of in-frame information); long durations are earned by information density — duration must match content;',
9397
9629
  '- Output JSON only.',
@@ -9432,6 +9664,14 @@ function queueThumb(assetId) {
9432
9664
  ? `镜头数量:必须输出恰好 ${countNum} 镜(用户手动设置;硬性参数,不是参考值)。`
9433
9665
  : `Shot count: output EXACTLY ${countNum} shots (set by the user; hard parameter, not a reference).`)
9434
9666
  : `${zh ? '镜头数量' : 'Shot count'}:**不固定**——按实际动作节拍切分,由内容自然决定`;
9667
+ // 分镜总时长行:手动档 = 硬性参数(与 countLine 同款口径);自动档 = 如实说「不固定」。
9668
+ const durationLine = targetDuration
9669
+ ? (zh
9670
+ ? `分镜总时长:所有镜头时长之和必须**恰好等于 ${targetDuration} 秒**(用户手动设定;硬性参数,不是参考值)。切 5 镜还是 50 镜都可以,镜头数由内容按节奏决定,但每个镜头 duration 相加必须等于 ${targetDuration} 秒。`
9671
+ : `Storyboard total duration: the sum of ALL shot durations must be EXACTLY ${targetDuration} seconds (set by the user; hard parameter, not a reference). 5 shots or 50 are both fine — shot count follows the content's pacing, but the durations must add up to ${targetDuration}s.`)
9672
+ : (zh
9673
+ ? `分镜总时长:**不固定**——由技能按节奏自然分配`
9674
+ : `Storyboard total duration: **not fixed** — distributed by pacing naturally`);
9435
9675
  // 承接约束:由连线指定(分镜表「衔接上一镜」输入口 ← 上游分镜表「尾镜」输出口)。
9436
9676
  // 只承接尾镜的**结尾瞬间**(≤0.2s 重叠),不重演上一镜——视频模型按秒计费,重演等于白花钱。
9437
9677
  const cont = (() => {
@@ -9482,6 +9722,7 @@ function queueThumb(assetId) {
9482
9722
  `${zh ? '剧本' : 'Script'}:\n${String(scriptText ?? '').trim()}`,
9483
9723
  `${zh ? '额外要求' : 'Extra requirements'}:${String(requirement ?? '').trim() || (zh ? '无' : 'none')}`,
9484
9724
  countLine,
9725
+ durationLine,
9485
9726
  prevLine,
9486
9727
  ].filter(Boolean).join('\n\n');
9487
9728
  const text = await aiCompleteStream({
@@ -10685,7 +10926,24 @@ function queueThumb(assetId) {
10685
10926
  flushSave();
10686
10927
  try {
10687
10928
  const prev = prevSceneTail(n); // 场 N-1 的尾镜 → 作为本场第 1 镜的硬性承接约束
10688
- const shots = await aiStoryboardShots(st, n.data.requirement, Number(n.data.count) || 0, n.data.model, (kind, d) => aiStreamAppend(n.id, kind, d), prev, { cont: n.data.cont !== false });
10929
+ const targetDur = Math.max(0, Math.round(Number(n.data.targetDuration) * 10) / 10) || 0;
10930
+ const shots = await aiStoryboardShots(st, n.data.requirement, Number(n.data.count) || 0, n.data.model, (kind, d) => aiStreamAppend(n.id, kind, d), prev, { cont: n.data.cont !== false, targetDuration: targetDur });
10931
+ // 总时长机械归位(issue:下拉硬约束的执行侧保底):模型 Σ≠X 时按比例缩放各镜 duration,
10932
+ // 末镜吸收舍入残差 → Σ 恰等于 X。只缩放时长,绝不动内容字段;自动档(targetDur=0)零操作。
10933
+ if (targetDur && shots.length) {
10934
+ const sum = shots.reduce((a, s) => a + (Number(s.duration) || 0), 0);
10935
+ if (sum > 0 && Math.abs(sum - targetDur) > 0.05) {
10936
+ const k = targetDur / sum;
10937
+ let acc = 0;
10938
+ for (let i = 0; i < shots.length; i++) {
10939
+ const scaled = i === shots.length - 1
10940
+ ? Math.round((targetDur - acc) * 10) / 10 // 末镜吸收残差
10941
+ : Math.max(0.3, Math.round(Number(shots[i].duration) * k * 10) / 10);
10942
+ shots[i].duration = scaled;
10943
+ acc += scaled;
10944
+ }
10945
+ }
10946
+ }
10689
10947
  // 未闭合引用自愈:句尾丢闭合 @ 的引用按设定集名补全(否则参考图静默丢失)
10690
10948
  const _known = bibleNames(loadBible(S.activeId));
10691
10949
  for (const sh of shots) {
@@ -12556,22 +12814,41 @@ function queueThumb(assetId) {
12556
12814
  const [open, setOpen] = useState(false);
12557
12815
  const [q, setQ] = useState('');
12558
12816
  const [custom, setCustom] = useState('');
12559
- const [pos, setPos] = useState({ left: 0, top: 0, width: width || 160 });
12817
+ const [pos, setPos] = useState({ left: 0, top: 0, width: width || 160, flipped: false });
12560
12818
  const btnRef = useRef(null);
12561
12819
  const menuRef = useRef(null);
12562
- const openMenu = () => {
12563
- if (disabled) return;
12820
+ /** 统一定位器(三处同源:openMenu 初定位 / composerReposition 跟随 / layout effect 实高校正)。
12821
+ * 镜像贴附语义:下翻菜单顶=按钮底+6(搜索框贴按钮);上翻菜单底=按钮顶-6(搜索框在菜单
12822
+ * 最下仍贴按钮)。menuH 传实际高度(layout effect 量得);初定位/跟随阶段传 0 用估算 280。 */
12823
+ const placeMenu = (menuH) => {
12564
12824
  const btn = btnRef.current;
12565
- if (btn && btn.getBoundingClientRect) {
12566
- const r = btn.getBoundingClientRect();
12567
- const mw = Math.max(Number(width) || 160, 200);
12568
- const vw = window.innerWidth || 1200;
12569
- const vh = window.innerHeight || 800;
12570
- const left = Math.max(8, Math.min(r.left, vw - mw - 8));
12571
- const below = r.bottom + 6;
12572
- const top = (below + 280 > vh - 8) ? Math.max(8, r.top - 286) : below;
12573
- setPos({ left, top, width: mw });
12825
+ if (!btn || !btn.getBoundingClientRect) return null;
12826
+ const r = btn.getBoundingClientRect();
12827
+ const mw = Math.max(Number(width) || 160, 200);
12828
+ const vw = window.innerWidth || 1200;
12829
+ const vh = window.innerHeight || 800;
12830
+ const pad = 8;
12831
+ const gap = 6;
12832
+ const left = Math.max(8, Math.min(r.left, vw - mw - 8));
12833
+ const h = Math.max(60, Number(menuH) || 280);
12834
+ // 空间裁决:向下放不下且上方更宽裕 → 上翻;否则下翻(下翻越界时夹视口底)。
12835
+ const downOver = r.bottom + gap + h - (vh - pad); // 下翻超出视口底的量
12836
+ const upSpace = r.top - gap - h - pad; // 上翻后距视口顶的余量
12837
+ const flipped = downOver > 0 && upSpace > -downOver; // 哪边溢出少选哪边
12838
+ let top;
12839
+ if (flipped) {
12840
+ top = r.top - gap - h; // 上翻:菜单底贴按钮顶
12841
+ if (top < pad) { top = Math.max(pad, Math.min(r.bottom + gap, vh - h - pad)); flipped = false; }
12842
+ } else {
12843
+ top = r.bottom + gap; // 下翻:菜单顶贴按钮底
12844
+ if (top + h > vh - pad) top = Math.max(pad, vh - h - pad);
12574
12845
  }
12846
+ return { left, top, width: mw, flipped };
12847
+ };
12848
+ const openMenu = () => {
12849
+ if (disabled) return;
12850
+ const p = placeMenu(0); // 初定位用估算高度(菜单未渲染);layout effect 随后按实际高度校正
12851
+ if (p) setPos(p);
12575
12852
  setQ('');
12576
12853
  setCustom('');
12577
12854
  setOpen(true);
@@ -12598,7 +12875,24 @@ function queueThumb(assetId) {
12598
12875
  setOpen(false);
12599
12876
  };
12600
12877
  document.addEventListener('pointerdown', onDown, true);
12878
+ // 菜单跟随:composer 是活的(跟随节点拖动/画布缩放重定位),菜单坐标若只是打开瞬间的
12879
+ // 快照就会「飞离选择位置」。把自己挂进 composerReposition 链——composer 每次重定位时
12880
+ // 菜单同步重算(与 layout effect 同一 placeMenu:镜像方向 + flipped 一并保持)。
12881
+ const reposition = () => {
12882
+ const menu = menuRef.current;
12883
+ const p = placeMenu(menu && menu.getBoundingClientRect ? menu.getBoundingClientRect().height : 0);
12884
+ if (p) setPos(p);
12885
+ };
12886
+ const prevReposition = composerReposition;
12887
+ composerReposition = () => { try { reposition(); } catch { /* 定位失败不影响画布 */ } if (prevReposition) prevReposition(); };
12888
+ window.addEventListener('resize', reposition);
12889
+ // 打开瞬间校正一次:composer 自身刚完成定位(点击内容区 → composer 挂载 → 立刻点下拉),
12890
+ // openMenu 算到的 btn rect 可能来自 composer 定位前的那一帧——下一帧按已就位的 rect 校正。
12891
+ const raf = requestAnimationFrame(reposition);
12601
12892
  return () => {
12893
+ cancelAnimationFrame(raf);
12894
+ composerReposition = prevReposition;
12895
+ window.removeEventListener('resize', reposition);
12602
12896
  delete document.body.dataset.dshicPickOpen;
12603
12897
  document.removeEventListener('pointerdown', onDown, true);
12604
12898
  };
@@ -12612,6 +12906,19 @@ function queueThumb(assetId) {
12612
12906
  const shown = (searchable && query)
12613
12907
  ? options.filter((o) => (String(o.label) + ' ' + String(o.sub || '') + ' ' + String(o.value)).toLowerCase().includes(query))
12614
12908
  : options;
12909
+ // 菜单实际高度就位后的精确定位(useLayoutEffect 绘制前,无闪烁):与 placeMenu 同源——
12910
+ // 量真实高度重算镜像方向与贴附(初定位用估算 280,渲染后按实际高度修正)。
12911
+ useLayoutEffect(() => {
12912
+ if (!open) return;
12913
+ const menu = menuRef.current;
12914
+ if (!menu || !menu.getBoundingClientRect) return;
12915
+ const mr = menu.getBoundingClientRect();
12916
+ if (!mr.height) return;
12917
+ const p = placeMenu(mr.height);
12918
+ if (!p) return;
12919
+ const changed = Math.abs(p.top - pos.top) > 0.5 || Math.abs((p.left ?? 0) - (pos.left ?? 0)) > 0.5 || !!p.flipped !== !!pos.flipped;
12920
+ if (changed) setPos(p);
12921
+ }, [open, shown.length, editable]);
12615
12922
  return h('span', {
12616
12923
  className: cls('dshic-pick-wrap', className),
12617
12924
  // 可收缩的下拉(模型):flex-basis = 期望宽度,min-width:0 允许被压到省略号
@@ -12631,11 +12938,11 @@ function queueThumb(assetId) {
12631
12938
  h('span', { className: 'dshic-pick-car' }, '▾')),
12632
12939
  open
12633
12940
  ? h('div', {
12634
- ref: menuRef, className: 'dshic-pick-menu',
12941
+ ref: menuRef, className: cls('dshic-pick-menu', pos.flipped && 'is-flipped'),
12635
12942
  style: { left: pos.left, top: pos.top, width: pos.width },
12636
12943
  onPointerDown: (e) => e.stopPropagation(),
12637
12944
  },
12638
- searchable
12945
+ searchable && !pos.flipped
12639
12946
  ? h('div', { className: 'dshic-pick-search' },
12640
12947
  h('input', {
12641
12948
  className: 'dshic-input', autoFocus: true, placeholder: T('searchModelPh'), value: q,
@@ -12655,7 +12962,29 @@ function queueThumb(assetId) {
12655
12962
  h('span', { className: 'dshic-pick-name' }, o.label),
12656
12963
  o.sub ? h('span', { className: 'dshic-pick-sub' }, o.sub) : null))
12657
12964
  : h('div', { className: 'dshic-pick-empty' }, T('noModelMatch'))),
12658
- editable
12965
+ // 上翻(镜像):搜索框/自定义输入框贴按钮的一侧(菜单最下)→ 渲染顺序整体倒置
12966
+ searchable && pos.flipped
12967
+ ? h('div', { className: 'dshic-pick-search is-flipped' },
12968
+ h('input', {
12969
+ className: 'dshic-input', autoFocus: true, placeholder: T('searchModelPh'), value: q,
12970
+ onChange: (e) => setQ(e.target.value), onPointerDown: (e) => e.stopPropagation(),
12971
+ }))
12972
+ : null,
12973
+ editable && pos.flipped
12974
+ ? h('div', { className: 'dshic-pick-custom is-flipped' },
12975
+ h('input', {
12976
+ className: 'dshic-input', type: 'text',
12977
+ inputMode: integer ? 'numeric' : 'decimal',
12978
+ placeholder: customPlaceholder || T('customValuePh'),
12979
+ title: customPlaceholder || T('customValuePh'),
12980
+ value: custom,
12981
+ onChange: (e) => setCustom(e.target.value),
12982
+ onKeyDown: (e) => { if (e && e.key === 'Enter') { e.preventDefault(); submitCustom(); } },
12983
+ onBlur: submitCustom,
12984
+ onPointerDown: (e) => e.stopPropagation(),
12985
+ }))
12986
+ : null,
12987
+ editable && !pos.flipped
12659
12988
  ? h('div', { className: 'dshic-pick-custom' },
12660
12989
  h('input', {
12661
12990
  className: 'dshic-input', type: 'text',
@@ -12757,12 +13086,15 @@ function queueThumb(assetId) {
12757
13086
 
12758
13087
  // —— 模型选项:只列已配置的模型(文本取 Harness 会话可用模型;图片/视频取插件设置里的供应商+模型)——
12759
13088
  const modelOptions = (() => {
12760
- const opts = [{ value: '', label: T('followSettings'), sub: '' }];
13089
+ const opts = [];
12761
13090
  if (isTextLike) {
13091
+ // 文本模型才有「跟随设置」:语言模型由 Harness 会话提供,节点不选 = 用当前会话模型。
13092
+ opts.push({ value: '', label: T('followSettings'), sub: '' });
12762
13093
  for (const p of ((llm && llm.providers) || [])) {
12763
13094
  for (const m of (p.models || [])) opts.push({ value: p.id + '|' + m.id, label: m.name, sub: p.name, title: p.name + ' · ' + m.name });
12764
13095
  }
12765
13096
  } else if (isImage) {
13097
+ // 图片/视频无「跟随设置」:设置页有真实默认(★ 星标),节点不选 = 直接用 ★(resolveImageModelCfg 同语义)。
12766
13098
  for (const m of flattenImageModels(settings)) opts.push({ value: m.ref, label: m.model, sub: m.providerName, title: m.providerName + ' · ' + m.model + (m.ref === settings.imageStar ? ' ★' : '') });
12767
13099
  } else if (isVideo) {
12768
13100
  for (const m of flattenVideoModels(settings)) opts.push({ value: m.ref, label: m.model, sub: m.providerName, title: m.providerName + ' · ' + m.model + (m.ref === settings.videoStar ? ' ★' : '') });
@@ -12770,6 +13102,11 @@ function queueThumb(assetId) {
12770
13102
  return opts;
12771
13103
  })();
12772
13104
  const modelRef = isImage ? nodeImageModelRef(n) : isVideo ? nodeVideoModelRef(n) : (n.data.model || '');
13105
+ // 图片/视频:节点未选模型时显示 ★ 默认模型(而非「跟随设置」)——下拉里它就是普通一项,
13106
+ // 点它 = 显式把节点钉到该模型(写 ref),与「未选时请求侧走 ★」同一结论。
13107
+ const modelValue = modelRef || (!isTextLike
13108
+ ? (isImage ? settings.imageStar : settings.videoStar) || ''
13109
+ : '');
12773
13110
  const setModel = (v) => update((s) => {
12774
13111
  const nd = s.graph.nodes[n.id];
12775
13112
  if (!nd) return;
@@ -13025,7 +13362,7 @@ function queueThumb(assetId) {
13025
13362
  // finalcut 无模型(只有比例/分辨率);其余类型模型永远排在最前
13026
13363
  !isFinalCut
13027
13364
  ? h(PopupSelect, {
13028
- value: modelRef, options: modelOptions, onChange: setModel, width: 172,
13365
+ value: modelValue, options: modelOptions, onChange: setModel, width: 172,
13029
13366
  title: T('modelLabel'), searchable: true, className: 'is-model', shrink: true,
13030
13367
  })
13031
13368
  : null,
@@ -13045,13 +13382,16 @@ function queueThumb(assetId) {
13045
13382
  onChange: (v) => setStoryboardPrev(n.id, v || null),
13046
13383
  })
13047
13384
  : null,
13048
- // 单段生成上限:切段规划器按它决定"一张分镜表切成几次生成"。
13049
- // MiniMax 这类弱衔接模型建议填 6–10;Seedance 2.5 可以填到 15。
13385
+ // 分镜总时长(issue:下拉硬约束):首选项「按镜头节奏自动」(默认,data.targetDuration 缺省)
13386
+ // = 技能按节奏谱系自然分配各镜时长;选任何秒数(预设或自定义 1–300)= 本分镜节点总时长
13387
+ // 硬约束——不论切几镜,所有镜头 duration 之和严格等于该值(生成侧提示词注入 + 机械归位)。
13388
+ // 与切段规划器(planShotSegments 的 maxSeconds,恒用默认 15)解耦:本下拉只管总时长。
13050
13389
  isStoryboard
13051
13390
  ? h(PopupSelect, {
13052
- value: String(Number(n.data.segMaxSeconds) || 15), width: 84, title: T('segMaxLabel'), className: 'is-segmax',
13053
- options: [6, 8, 10, 12, 15, 20, 30].map((x) => ({ value: String(x), label: x + 's' })),
13054
- onChange: (v) => setData('segMaxSeconds', Number(v)),
13391
+ value: n.data.targetDuration != null && Number(n.data.targetDuration) > 0 ? String(Number(n.data.targetDuration)) : '',
13392
+ width: 84, title: T('targetDurationLabel'), className: 'is-segmax',
13393
+ options: [{ value: '', label: T('targetDurationAuto') }].concat([6, 8, 10, 12, 15, 20, 30].map((x) => ({ value: String(x), label: x + 's' }))),
13394
+ onChange: (v) => setData('targetDuration', v === '' ? null : Number(v)),
13055
13395
  editable: true, min: 1, max: 300, integer: false, decimals: 1,
13056
13396
  customLabel: (v) => String(v) + 's', customPlaceholder: T('customSegMaxPh'),
13057
13397
  })
@@ -14073,7 +14413,7 @@ function queueThumb(assetId) {
14073
14413
  const totalDur = shots.reduce((a, sh) => a + Math.max(0, Number(sh.duration) || 0), 0);
14074
14414
  // 切段预览:把"这张分镜表会被切成几次生成、每次几镜几秒、哪些段要接尾帧"直接显示在节点上,
14075
14415
  // 用户铺开前就知道会切成什么样——不用等到生成完才发现接不上。
14076
- const segPlan = shots.length ? planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 }) : null;
14416
+ const segPlan = shots.length ? planShotSegments(shots, { maxSeconds: Number(n.data.targetDuration) || 15 }) : null;
14077
14417
  // 一致性告警的重校验:告警是**生成时刻**算的;设定集更新后有 bibleTick 自动重算(见下),
14078
14418
  // 这里保留手动入口兜底——点刷新按当前设定集重算(checkShotConsistency 读的是实时 bible/资产名索引)
14079
14419
  const [wvChecking, setWvChecking] = useState(false);
@@ -14212,7 +14552,7 @@ function queueThumb(assetId) {
14212
14552
  if (!shots.length) { toast(T('expandNoShots')); return; }
14213
14553
  const zh = effLang() !== 'en';
14214
14554
  // 切段规划:纯函数,可在面板上预览,也由 scripts/test-segment-plan.mjs 直接断言
14215
- const plan = planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 });
14555
+ const plan = planShotSegments(shots, { maxSeconds: Number(n.data.targetDuration) || 15 });
14216
14556
  const segs = plan.segments.length ? plan.segments : [{ index: 0, shots, startIndex: 0, endIndex: shots.length - 1, duration: plan.total, firstSeg: 'opening', lastSeg: 'continuation', opensOnCut: true, closesOnCut: true, seamRisk: 'none', needsTailChain: false, reason: '' }];
14217
14557
  // 项目资产名称索引(用于把角色/场景/道具连接到已有资产节点)
14218
14558
  const recs = await idbByProject(S.activeId).catch(() => []);
@@ -14393,7 +14733,8 @@ function queueThumb(assetId) {
14393
14733
  };
14394
14734
  const genTts = async (x) => {
14395
14735
  const settings = loadSettings();
14396
- const cfg = resolveApiCfg(settings.ttsApis, settings.ttsApiId, null);
14736
+ const list = flattenTtsModels(settings);
14737
+ const cfg = list.find((y) => y.ref === settings.ttsStar) || list[0];
14397
14738
  if (!cfg) { toast(T('errNoTts')); return; }
14398
14739
  const text = String(getSub(x) || '').trim();
14399
14740
  if (!text) { toast(T('subPlaceholder')); return; }
@@ -19426,12 +19767,9 @@ const DIRECTOR_KEY_HELP = [
19426
19767
  for (const m of (p.models || [])) options.push({ value: p.id + '|' + m.id, label: `${p.name} · ${m.name}` });
19427
19768
  }
19428
19769
  const applyTextLlm = (provider, model) => {
19429
- setS((prev) => {
19430
- const next = JSON.parse(JSON.stringify(prev));
19431
- next.textLlm = { provider: provider || '', model: model || '' };
19432
- saveSettings(next);
19433
- return next;
19434
- });
19770
+ // issue #6:基底现取磁盘最新(不再用挂载时快照整对象写回),写回后 setS 同步刷新本地快照
19771
+ const next = updateSettings((b) => ({ ...b, textLlm: { provider: provider || '', model: model || '' } }));
19772
+ setS(next);
19435
19773
  };
19436
19774
  return h('div', { className: 'dshic-field' },
19437
19775
  h('span', { className: 'dshic-field-label' }, T('llmLabel')),
@@ -19500,25 +19838,29 @@ const DIRECTOR_KEY_HELP = [
19500
19838
  style: { flex: 'none', width: 14, height: 14, lineHeight: '13px', textAlign: 'center', fontSize: 10, borderRadius: '50%', border: '1px solid var(--dsw-alias-border-secondary, #777)', color: 'var(--dsw-alias-label-secondary, #999)', cursor: 'help', userSelect: 'none', opacity: 0.85 },
19501
19839
  }, 'i');
19502
19840
  }
19503
- /** 图片/视频模型配置(供应商 + 模型两级):一个供应商配一次 URL/Key,下面挂多个模型;
19504
- * ★星标模型 = 节点未指定时的默认路由。 */
19841
+ /** 图片/视频/TTS 模型配置(供应商 + 模型两级):一个供应商配一次 URL/Key,下面挂多个模型;
19842
+ * ★星标模型 = 节点未指定时的默认路由。TTS(issue #6 第二阶段):
19843
+ * voice 是每模型字段(不同模型支持的音色清单不同),timeoutMs 是供应商级(一供应商=一连接)。 */
19505
19844
  function ModelProviderEditor({ kind }) {
19506
19845
  const [s, setS] = useState(loadSettings);
19507
19846
  const [openId, setOpenId] = useState(null);
19508
- const listKey = kind === 'image' ? 'imageProviders' : 'videoProviders';
19509
- const starKey = kind === 'image' ? 'imageStar' : 'videoStar';
19510
- const icon = kind === 'image' ? 'image' : 'video';
19511
- const labelKey = kind === 'image' ? 'imageApisLabel' : 'videoApisLabel';
19512
- const nameKey = kind === 'image' ? 'defaultImageCfg' : 'defaultVideoCfg';
19513
- const urlKey = kind === 'image' ? 'baseUrl' : 'url';
19847
+ const listKey = kind === 'image' ? 'imageProviders' : kind === 'video' ? 'videoProviders' : 'ttsProviders';
19848
+ const starKey = kind === 'image' ? 'imageStar' : kind === 'video' ? 'videoStar' : 'ttsStar';
19849
+ const icon = kind === 'image' ? 'image' : kind === 'video' ? 'video' : 'audio';
19850
+ const labelKey = kind === 'image' ? 'imageApisLabel' : kind === 'video' ? 'videoApisLabel' : 'ttsApisLabel';
19851
+ const nameKey = kind === 'image' ? 'defaultImageCfg' : kind === 'video' ? 'defaultVideoCfg' : 'defaultTtsCfg';
19852
+ const urlKey = kind === 'video' ? 'url' : 'baseUrl';
19514
19853
  const urlPh = kind === 'image'
19515
19854
  ? 'https://api.example.com/v1(或完整 /images/generations 端点)'
19516
- : 'https://api.example.com/v1/video/generations(或裸域 / /v1)';
19517
- const persist = (next) => { setS(next); saveSettings(next); };
19518
- const mutate = (fn) => { const next = JSON.parse(JSON.stringify(s)); fn(next); persist(next); };
19855
+ : kind === 'video'
19856
+ ? 'https://api.example.com/v1/video/generations(或裸域 / /v1)'
19857
+ : 'https://api.example.com/v1';
19858
+ // issue #6:写回基底 = updateSettings 现取磁盘最新(不再是挂载时快照);persist 只负责把返回的新值同步进本地快照
19859
+ const persist = (next) => setS(next);
19860
+ const mutate = (fn) => { persist(updateSettings((b) => { const d = JSON.parse(JSON.stringify(b)); fn(d); return d; })); };
19519
19861
  const addProvider = () => {
19520
19862
  const id = uid('prov');
19521
- mutate((d) => { d[listKey] = (d[listKey] || []).concat([{ id, name: T(nameKey) + ' ' + ((d[listKey] || []).length + 1), [urlKey]: '', apiKey: '', extra: '', models: [], ...(kind === 'image' ? { mode: 'generations' } : {}) }]); });
19863
+ mutate((d) => { d[listKey] = (d[listKey] || []).concat([{ id, name: T(nameKey) + ' ' + ((d[listKey] || []).length + 1), [urlKey]: '', apiKey: '', ...(kind === 'tts' ? { timeoutMs: '' } : { extra: '' }), models: [], ...(kind === 'image' ? { mode: 'generations' } : {}) }]); });
19522
19864
  setOpenId(id);
19523
19865
  };
19524
19866
  const removeProvider = (id) => {
@@ -19526,7 +19868,7 @@ const DIRECTOR_KEY_HELP = [
19526
19868
  if (openId === id) setOpenId(null);
19527
19869
  };
19528
19870
  const patchProvider = (id, k, v) => mutate((d) => { d[listKey] = (d[listKey] || []).map((x) => (x.id === id ? { ...x, [k]: v } : x)); });
19529
- const addModel = (pid) => mutate((d) => { const p = (d[listKey] || []).find((x) => x.id === pid); if (p) p.models = (p.models || []).concat([{ id: uid('m'), model: '' }]); });
19871
+ const addModel = (pid) => mutate((d) => { const p = (d[listKey] || []).find((x) => x.id === pid); if (p) p.models = (p.models || []).concat([Object.assign({ id: uid('m'), model: '' }, kind === 'tts' ? { voice: 'alloy' } : {})]); });
19530
19872
  const patchModel = (pid, mid, k, v) => mutate((d) => { const p = (d[listKey] || []).find((x) => x.id === pid); if (!p) return; p.models = (p.models || []).map((x) => (x.id === mid ? { ...x, [k]: v } : x)); });
19531
19873
  const removeModel = (pid, mid) => mutate((d) => {
19532
19874
  const p = (d[listKey] || []).find((x) => x.id === pid); if (!p) return;
@@ -19571,6 +19913,11 @@ const DIRECTOR_KEY_HELP = [
19571
19913
  ) : null,
19572
19914
  h(Field, { key: 'u', label: T('baseUrl'), value: p[urlKey] || '', onChange: (v) => patchProvider(p.id, urlKey, v), placeholder: kind === 'video' ? ((VIDEO_VENDORS[detectVideoVendor(p)] || {}).base || urlPh) : urlPh }),
19573
19915
  h(Field, { key: 'k', label: T('apiKey'), value: p.apiKey || '', onChange: (v) => patchProvider(p.id, 'apiKey', v), placeholder: kind === 'video' ? ((VIDEO_VENDORS[detectVideoVendor(p)] || {}).keyPh || 'sk-…') : 'sk-…', password: true }),
19916
+ kind === 'tts' ? h(Field, {
19917
+ key: 'to', label: T('apiTimeout'), value: p.timeoutMs || '',
19918
+ placeholder: '留空 = 120000',
19919
+ onChange: (v) => patchProvider(p.id, 'timeoutMs', v),
19920
+ }) : null,
19574
19921
  kind === 'image' ? [
19575
19922
  h(Field, { key: 'size', label: T('imgSizeOverride'), value: p.size || '', onChange: (v) => patchProvider(p.id, 'size', v), placeholder: T('imgSizePlaceholder') }),
19576
19923
  h(Field, { key: 'rf', label: T('imgResponseFormat'), value: p.responseFormat || '', onChange: (v) => patchProvider(p.id, 'responseFormat', v), placeholder: 'b64_json / url(留空=API 默认)' }),
@@ -19581,12 +19928,12 @@ const DIRECTOR_KEY_HELP = [
19581
19928
  h('option', { value: 'edits' }, T('modeEdits')),
19582
19929
  h('option', { value: 'compshare' }, T('modeCompshare')),
19583
19930
  h('option', { value: 'sanbao' }, T('modeSanbao')))),
19584
- ] : [
19931
+ ] : kind === 'video' ? [
19585
19932
  (detectVideoVendor(p) === 'openai' || detectVideoVendor(p) === 'seedance') ? h(Field, { key: 'of', label: T('vidOutFormat'), value: p.outputFormat || '', onChange: (v) => patchProvider(p.id, 'outputFormat', v), placeholder: 'mp4(留空不发送)' }) : null,
19586
19933
  (detectVideoVendor(p) === 'openai' || detectVideoVendor(p) === 'seedance') ? h('label', { key: 'ga', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
19587
19934
  h('input', { type: 'checkbox', checked: p.generateAudio === true, onChange: (e) => patchProvider(p.id, 'generateAudio', e.target.checked), onPointerDown: (e) => e.stopPropagation() }),
19588
19935
  h('span', {}, T('vidAudioOpt'))) : null,
19589
- ],
19936
+ ] : null,
19590
19937
  (kind === 'image' || kind === 'video') ? [
19591
19938
  h(Field, { key: 'extra', label: T('cfgExtra'), value: p.extra || '', onChange: (v) => patchProvider(p.id, 'extra', v), placeholder: '{"watermark":false,"prompt_extend":false}', tip: T('cfgExtraHint') }),
19592
19939
  ] : null,
@@ -19601,6 +19948,8 @@ const DIRECTOR_KEY_HELP = [
19601
19948
  onPointerDown: (e) => e.stopPropagation(), onClick: () => toggleStar(p.id, m.id),
19602
19949
  }, s[starKey] === p.id + '|' + m.id ? '★' : '☆'),
19603
19950
  h('input', { className: 'dshic-input', style: { flex: 1, minWidth: 0 }, value: m.model || '', placeholder: T('modelNamePh'), onChange: (e) => patchModel(p.id, m.id, 'model', e.target.value), onPointerDown: (e) => e.stopPropagation() }),
19951
+ // TTS:voice 每模型一个(修复旧 ApiListEditor「voice 无编辑入口」的原始缺口)
19952
+ kind === 'tts' ? h('input', { className: 'dshic-input', style: { flex: 1, minWidth: 0 }, value: m.voice || '', placeholder: 'alloy', 'aria-label': T('voice'), onChange: (e) => patchModel(p.id, m.id, 'voice', e.target.value), onPointerDown: (e) => e.stopPropagation() }) : null,
19604
19953
  h('button', { type: 'button', className: 'dshic-iconbtn', title: T('doDelete'), onPointerDown: (e) => e.stopPropagation(), onClick: () => removeModel(p.id, m.id) }, '×'),
19605
19954
  )),
19606
19955
  !(p.models || []).length ? h('div', { className: 'dshic-hint' }, T('noModelsCfg')) : null,
@@ -19609,158 +19958,6 @@ const DIRECTOR_KEY_HELP = [
19609
19958
  }),
19610
19959
  );
19611
19960
  }
19612
- function ApiListEditor({ kind }) {
19613
- const [s, setS] = useState(loadSettings);
19614
- const [openId, setOpenId] = useState(null);
19615
- const listKey = kind === 'image' ? 'imageApis' : kind === 'video' ? 'videoApis' : 'ttsApis';
19616
- const defKey = kind === 'image' ? 'imageApiId' : kind === 'video' ? 'videoApiId' : 'ttsApiId';
19617
- const labelKey = kind === 'image' ? 'imageApisLabel' : kind === 'video' ? 'videoApisLabel' : 'ttsApisLabel';
19618
- const icon = kind === 'image' ? 'image' : kind === 'video' ? 'video' : 'audio';
19619
- const nameKey = kind === 'image' ? 'defaultImageCfg' : kind === 'video' ? 'defaultVideoCfg' : 'defaultTtsCfg';
19620
- const persist = (next) => { setS(next); saveSettings(next); };
19621
- const mutate = (fn) => {
19622
- const next = JSON.parse(JSON.stringify(s));
19623
- next[listKey] = fn(next[listKey] || []);
19624
- persist(next);
19625
- };
19626
- const add = () => {
19627
- const id = uid('cfg');
19628
- mutate((list) => list.concat([{
19629
- id,
19630
- name: T(nameKey) + ' ' + ((s[listKey] || []).length + 1),
19631
- [kcUrlKey(kind)]: '',
19632
- apiKey: '',
19633
- model: '',
19634
- ...(kind === 'image' ? { mode: 'generations' } : {}),
19635
- ...(kind === 'tts' ? { voice: 'alloy' } : {}),
19636
- }]));
19637
- setOpenId(id);
19638
- };
19639
- const patch = (id, k, v) => mutate((list) => list.map((x) => (x.id === id ? { ...x, [k]: v } : x)));
19640
- const remove = (id) => {
19641
- mutate((list) => list.filter((x) => x.id !== id));
19642
- if (openId === id) setOpenId(null);
19643
- };
19644
- const list = s[listKey] || [];
19645
- const urlPh = kind === 'image' ? 'https://api.example.com/v1' : kind === 'video' ? 'https://api.example.com/v1/video/generations' : 'https://api.example.com/v1';
19646
- const urlKey = kind === 'image' ? 'baseUrl' : 'url';
19647
- return h('div', { className: 'dshic-card' },
19648
- h('div', { className: 'dshic-row' },
19649
- Ic(icon, 12),
19650
- h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, T(labelKey)),
19651
- h('span', { className: 'dshic-tag st' }, String(list.length)),
19652
- h('button', { type: 'button', className: 'dshic-mini', onClick: add, onPointerDown: (e) => e.stopPropagation() }, Ic('plus', 11), T('addConfig')),
19653
- ),
19654
- list.length === 0 ? h('div', { className: 'dshic-hint' }, T('noCfgHint')) : null,
19655
- list.map((cfg) => {
19656
- const open = openId === cfg.id;
19657
- const isDef = s[defKey] === cfg.id;
19658
- return h('div', { key: cfg.id, className: 'dshic-card', style: { padding: open ? 8 : 5, gap: 6, background: 'var(--dsw-alias-bg-layer-1)' } },
19659
- // 折叠头:箭头 + 名称 + 默认标记 + 删除
19660
- h('div', { className: 'dshic-row' },
19661
- h('button', {
19662
- type: 'button', className: 'dshic-iconbtn', title: open ? T('collapse') : T('unfold'),
19663
- onPointerDown: (e) => e.stopPropagation(),
19664
- onClick: () => setOpenId(open ? null : cfg.id),
19665
- }, open ? '▾' : '▸'),
19666
- open
19667
- ? h('input', {
19668
- className: 'dshic-input', style: { flex: 1, minWidth: 0, fontWeight: 600 }, value: cfg.name || '',
19669
- placeholder: T('cfgName'), autoFocus: true,
19670
- onChange: (e) => patch(cfg.id, 'name', e.target.value),
19671
- onPointerDown: (e) => e.stopPropagation(),
19672
- })
19673
- : h('span', {
19674
- style: { flex: 1, minWidth: 0, fontSize: 12, fontWeight: 600, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', cursor: 'pointer', color: 'var(--dsw-alias-label-primary)' },
19675
- onClick: () => setOpenId(cfg.id),
19676
- onPointerDown: (e) => e.stopPropagation(),
19677
- title: T('baseUrl') + ': ' + (cfg[kcUrlKey(kind)] || '—'),
19678
- }, cfg.name || T('cfgName')),
19679
- isDef
19680
- ? h('span', { className: 'dshic-tag api' }, T('isDefault'))
19681
- : h('button', {
19682
- type: 'button', className: 'dshic-mini is-ghost', title: T('setDefault'),
19683
- onPointerDown: (e) => e.stopPropagation(),
19684
- onClick: () => { const next = { ...s, [defKey]: cfg.id }; persist(next); },
19685
- }, '★'),
19686
- cfg.model ? h('span', { className: 'dshic-tag st' }, String(cfg.model).slice(0, 18)) : null,
19687
- h('button', {
19688
- type: 'button', className: 'dshic-iconbtn is-danger', title: T('delConfig'),
19689
- onPointerDown: (e) => e.stopPropagation(),
19690
- onClick: () => remove(cfg.id),
19691
- }, Ic('trash', 11)),
19692
- ),
19693
- open ? [
19694
- h(Field, { key: 'u', label: T('baseUrl'), value: cfg[kcUrlKey(kind)] || '', onChange: (v) => patch(cfg.id, urlKey, v), placeholder: urlPh }),
19695
- h(Field, { key: 'k', label: T('apiKey'), value: cfg.apiKey || '', onChange: (v) => patch(cfg.id, 'apiKey', v), placeholder: 'sk-…', password: true }),
19696
- h(Field, { key: 'm', label: T('model'), value: cfg.model || '', onChange: (v) => patch(cfg.id, 'model', v) }),
19697
- h(Field, {
19698
- key: 'to', label: T('apiTimeout'), value: cfg.timeoutMs || '',
19699
- placeholder: T('llmParamAuto'),
19700
- onChange: (v) => patch(cfg.id, 'timeoutMs', v),
19701
- }),
19702
- kind === 'image'
19703
- ? h(Field, { key: 'size', label: T('imgSizeOverride'), value: cfg.size || '', onChange: (v) => patch(cfg.id, 'size', v), placeholder: T('imgSizePlaceholder') })
19704
- : null,
19705
- kind === 'image'
19706
- ? h(Field, { key: 'rf', label: T('imgResponseFormat'), value: cfg.responseFormat || '', onChange: (v) => patch(cfg.id, 'responseFormat', v), placeholder: 'b64_json / url(留空=API 默认)' })
19707
- : null,
19708
- kind === 'image'
19709
- ? h('div', { key: 'mode', className: 'dshic-field' },
19710
- h('span', { className: 'dshic-field-label' }, T('imgMode')),
19711
- h('select', {
19712
- className: 'dshic-select', value: cfg.mode || 'generations',
19713
- onChange: (e) => patch(cfg.id, 'mode', e.target.value),
19714
- onPointerDown: (e) => e.stopPropagation(),
19715
- },
19716
- h('option', { value: 'generations' }, T('modeGenerations')),
19717
- h('option', { value: 'edits' }, T('modeEdits')),
19718
- h('option', { value: 'sanbao' }, T('modeSanbao'))))
19719
- : null,
19720
- kind === 'video'
19721
- ? h('div', { key: 'proto', className: 'dshic-field' },
19722
- h('span', { className: 'dshic-field-label' }, T('vidProtocol'), InfoTip(T('vidProtocolHint'))),
19723
- h('select', {
19724
- className: 'dshic-select', value: cfg.protocol || 'generic',
19725
- onChange: (e) => patch(cfg.id, 'protocol', e.target.value),
19726
- onPointerDown: (e) => e.stopPropagation(),
19727
- },
19728
- h('option', { value: 'generic' }, T('protoGeneric')),
19729
- h('option', { value: 'seedance' }, T('protoSeedance'))))
19730
- : null,
19731
- kind === 'video'
19732
- ? h('label', { key: 'ga', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
19733
- h('input', {
19734
- type: 'checkbox', checked: cfg.generateAudio === true,
19735
- onChange: (e) => patch(cfg.id, 'generateAudio', e.target.checked),
19736
- onPointerDown: (e) => e.stopPropagation(),
19737
- }),
19738
- h('span', {}, T('vidAudioOpt')))
19739
- : null,
19740
- kind === 'video'
19741
- ? h(Field, { key: 'of', label: T('vidOutFormat'), value: cfg.outputFormat || '', onChange: (v) => patch(cfg.id, 'outputFormat', v), placeholder: 'mp4(留空不发送)' })
19742
- : null,
19743
- kind === 'video' && cfg.protocol === 'seedance'
19744
- ? h('label', { key: 'wm', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
19745
- h('input', {
19746
- type: 'checkbox', checked: cfg.watermark === true,
19747
- onChange: (e) => patch(cfg.id, 'watermark', e.target.checked),
19748
- onPointerDown: (e) => e.stopPropagation(),
19749
- }),
19750
- h('span', {}, T('seedanceWatermark')))
19751
- : null,
19752
- (kind === 'image' || kind === 'video')
19753
- ? h(Field, { key: 'extra', label: T('cfgExtra'), value: cfg.extra || '', onChange: (v) => patch(cfg.id, 'extra', v), placeholder: '{"watermark":false,"prompt_extend":false}', tip: T('cfgExtraHint') })
19754
- : null,
19755
- kind === 'tts'
19756
- ? h(Field, { key: 'voice', label: T('voice'), value: cfg.voice || '', onChange: (v) => patch(cfg.id, 'voice', v), placeholder: 'alloy' })
19757
- : null,
19758
- ] : null,
19759
- );
19760
- }),
19761
- );
19762
- }
19763
- function kcUrlKey(kind) { return kind === 'image' ? 'baseUrl' : 'url'; }
19764
19961
 
19765
19962
  /** T2:设置面板 Craft 后期卡片(连接状态 / 工具灯 / 数据目录)。 */
19766
19963
  function CraftCard() {
@@ -20316,7 +20513,8 @@ const DIRECTOR_KEY_HELP = [
20316
20513
  list.unshift({ id: 'image-gen-bridge', name: '桥接dsh-image-gen', baseUrl: '', apiKey: '', viaImageGen: true, models });
20317
20514
  }
20318
20515
  const noChange = JSON.stringify(s0.imageProviders || []) === JSON.stringify(list);
20319
- if (!noChange) { s0.imageProviders = list; saveSettings(s0); }
20516
+ // issue #6:写回统一走 updateSettings(现取磁盘最新做基底,杜绝把别的卡刚写的字段回滚)
20517
+ if (!noChange) updateSettings((b) => ({ ...b, imageProviders: list }));
20320
20518
  return { models: models.length, changed: !noChange };
20321
20519
  };
20322
20520
  useEffect(() => {
@@ -20341,9 +20539,8 @@ const DIRECTOR_KEY_HELP = [
20341
20539
  const toggle = () => {
20342
20540
  const v = !enabled;
20343
20541
  setEnabled(v);
20344
- const s0 = loadSettings();
20345
- s0.imageGen = { ...(s0.imageGen || {}), enabled: v };
20346
- saveSettings(s0);
20542
+ // issue #6:写回统一走 updateSettings(现取磁盘最新做基底)
20543
+ updateSettings((b) => ({ ...b, imageGen: { ...(b.imageGen || {}), enabled: v } }));
20347
20544
  // 开/关即时生效:重跑一次探测同步(加回或移除桥接模型条目)
20348
20545
  (async () => {
20349
20546
  try {
@@ -20374,12 +20571,8 @@ const DIRECTOR_KEY_HELP = [
20374
20571
  function SettingsTab() {
20375
20572
  const [s, setS] = useState(loadSettings);
20376
20573
  const apply = (fn) => {
20377
- setS((prev) => {
20378
- const next = JSON.parse(JSON.stringify(prev));
20379
- fn(next);
20380
- saveSettings(next);
20381
- return next;
20382
- });
20574
+ // issue #6:与四张卡同根——基底现取磁盘最新,不再用挂载快照整对象写回
20575
+ setS(updateSettings((b) => { const d = JSON.parse(JSON.stringify(b)); fn(d); return d; }));
20383
20576
  };
20384
20577
  const field = (label, value, onChange, placeholder, password) => h(Field, { label, value, onChange, placeholder, password });
20385
20578
  return [
@@ -20414,7 +20607,7 @@ const DIRECTOR_KEY_HELP = [
20414
20607
  ),
20415
20608
  h(ModelProviderEditor, { key: 'imglist', kind: 'image' }),
20416
20609
  h(ModelProviderEditor, { key: 'vidlist', kind: 'video' }),
20417
- h(ApiListEditor, { key: 'ttslist', kind: 'tts' }),
20610
+ h(ModelProviderEditor, { key: 'ttslist', kind: 'tts' }),
20418
20611
  // 帮助与反馈:一行入口(点开弹窗看二维码与提 Issue)
20419
20612
  h('div', {
20420
20613
  key: 'support', className: 'dshic-card', style: { cursor: 'pointer' },
@@ -22295,7 +22488,7 @@ const DIRECTOR_KEY_HELP = [
22295
22488
  // IC-04:参考图上传三件套的纯函数出口(供 scripts/test-image-upload.mjs 直接断言)
22296
22489
  window.__DSH_IC_IMGREF__ = { rawImageDims, sniffImageEncoding, registerReferenceAsset };
22297
22490
  // IC-03:视频厂商识别/前缀归一化的纯函数出口(供 scripts/test-vendor-detect.mjs 直接断言)
22298
- window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState, buildSanbaoVideoBody, sanbaoTaskIdOf, sanbaoPollState, needsSanbaoMediaRetry, retryableDownloadError, downloadVideoWithRetry, SANBAO_DOWNLOAD_RETRY_MS, SANBAO_DOWNLOAD_RETRY_STEP_MS, buildSanbaoImageBody, sanbaoImageResultOf, sanbaoImagePollState, bibleStyleAnchor };
22491
+ window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState, buildSanbaoVideoBody, sanbaoTaskIdOf, sanbaoPollState, needsSanbaoMediaRetry, retryableDownloadError, downloadVideoWithRetry, SANBAO_DOWNLOAD_RETRY_MS, SANBAO_DOWNLOAD_RETRY_STEP_MS, buildSanbaoImageBody, sanbaoImageResultOf, sanbaoImagePollState, bibleStyleAnchor, build6789VideoBody, api6789SizeOf, api6789ImageCap, api6789TaskIdOf, api6789StatusOf, api6789VideoUrlOf, api6789ErrorOf, api6789PollState, needs6789MediaHint };
22299
22492
  // 按镜头切段(分段生成本身就是最容易出错的地方):规划器 + 强弱模型分流 + 节点段区间解析
22300
22493
  // 供 scripts/test-segment-plan.mjs 直接断言
22301
22494
  window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };
@@ -22372,9 +22565,11 @@ const DIRECTOR_KEY_HELP = [
22372
22565
  window.__DSH_IC_CRAFT__ = { craftBaseDir, craftBaseDirRequired, joinLocal, craftFolderOf, craft };
22373
22566
  // 设置迁移的测试缝隙
22374
22567
  window.__DSH_IC_SETTINGS__ = {
22375
- DEFAULT_SETTINGS, loadSettings, saveSettings,
22376
- flattenImageModels, resolveImageModelCfg,
22568
+ DEFAULT_SETTINGS, loadSettings, saveSettings, updateSettings,
22569
+ flattenImageModels, flattenTtsModels, resolveImageModelCfg,
22377
22570
  buildExpertContext,
22571
+ // 设置卡组件缝合口(跨卡丢失更新回归用,scripts/test-panel-layout.mjs;不进 __DSH_IC_TABS__,smoke 会遍历渲染)
22572
+ LlmModelSelect, ModelProviderEditor,
22378
22573
  };
22379
22574
  // 创作上下文注入的测试缝隙(供 scripts/test-skill-inject.mjs 断言)
22380
22575
  window.__DSH_IC_SKILL__ = {