@ninkch/dsh-infinite-canvas 0.19.17 → 0.19.19

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
@@ -942,6 +942,7 @@ function revealCanvasInRight() {
942
942
  'modeGenerations': '生图 /images/generations(支持多参考图)',
943
943
  'modeEdits': '参考图编辑 /images/edits(多参考图上传)',
944
944
  'modeCompshare': '优云智算任务式 /image/v1/tasks(Qwen-Image,参考图登记 + 提示词优化)',
945
+ 'modeSanbao': '三宝图片任务 /openapi/v1/images(异步任务,任务 id 可回查;baseUrl 命中 sanbaobeauty.com 自动生效)',
945
946
  'catMismatch': '提示:资产分类为「{a}」,端口期望「{b}」,已保留连接',
946
947
  'nStoryboard': '分镜表',
947
948
  'nScript': '剧本',
@@ -1071,7 +1072,7 @@ function revealCanvasInRight() {
1071
1072
  'shotsUnit': '镜',
1072
1073
  'savedOk': '已存为资产',
1073
1074
  'warnUnregistered': '未在设定集/资产中登记',
1074
- 'warnScriptTooLong': '剧本较长({n} 字)≈ 超过单个分镜的镜头容量(100 镜):请按场景拆分为多个场景剧本节点(每个分镜只连一个场景剧本)',
1075
+ 'warnShotsOverCapacity': '本分镜已生成 {n} 镜,超过单个分镜的镜头容量(100 镜):请按场景拆分为多个场景剧本节点(每个分镜只连一个场景剧本)',
1075
1076
  'warnEmptyDesc': '已登记但描述为空(待补全)',
1076
1077
  'catMention': '提及',
1077
1078
  'assetCategoriesFixed': '已按命名规范纠正 {n} 个资产的分类',
@@ -1163,6 +1164,17 @@ function revealCanvasInRight() {
1163
1164
  'updateSrcChina': '中国大陆镜像源',
1164
1165
  'updateSrcNow': '当前源',
1165
1166
  'updateSrcSet': '更新源已切换',
1167
+ 'assetsSelAllPage': '全选本页',
1168
+ 'assetsAddToCanvas': '添加到画布',
1169
+ 'assetsClearSel': '清除选择',
1170
+ 'assetsOnlyAudio': '所选均为音频资产,无法生成画布节点',
1171
+ 'assetsAudioSkip': '{n} 个音频资产已跳过',
1172
+ 'assetsAdded': '已添加 {n} 个资产节点',
1173
+ 'assetsBatchDelWarn': '将从资产库删除所选资产;画布上引用它们的节点会解绑:',
1174
+ 'assetsDeletedN': '已删除 {n} 个资产',
1175
+ 'assetsTotalCount': '共 {n} 项',
1176
+ 'assetClickHint': '单击选择 / 双击直接添加到画布',
1177
+ 'assetsRelinked': '已自动回链 {n} 个节点的资产引用',
1166
1178
  'dataRootLabel': '数据根目录',
1167
1179
  'dataRootPlaceholder': '如 D:\\canvas-data',
1168
1180
  'dataRootHint': '资产与视频按项目落盘到该目录(不再占用 C 盘 IndexedDB)。留空 = 浏览器 IndexedDB。',
@@ -1877,6 +1889,7 @@ function revealCanvasInRight() {
1877
1889
  'modeGenerations': 'image /images/generations (with references)',
1878
1890
  'modeEdits': 'image edit /images/edits (multi-reference upload)',
1879
1891
  'modeCompshare': 'Compshare task /image/v1/tasks (Qwen-Image, reference upload)',
1892
+ 'modeSanbao': 'Sanbao image task /openapi/v1/images (async task with queryable task id; auto-enabled when baseUrl hits sanbaobeauty.com)',
1880
1893
  'catMismatch': 'Note: asset category is "{a}", port expects "{b}". Connected anyway.',
1881
1894
  'nStoryboard': 'Storyboard',
1882
1895
  'nScript': 'Script',
@@ -2007,7 +2020,7 @@ function revealCanvasInRight() {
2007
2020
  'shotsUnit': 'shots',
2008
2021
  'savedOk': 'Saved as asset',
2009
2022
  'warnUnregistered': 'not in bible/assets',
2010
- 'warnScriptTooLong': 'Script is long ({n} chars) ≈ beyond one storyboard\'s shot capacity (100 shots): split the script into multiple scene script nodes (each storyboard takes ONE scene)',
2023
+ 'warnShotsOverCapacity': "This storyboard generated {n} shots - beyond one storyboard's shot capacity (100 shots): split the script into multiple scene script nodes (each storyboard takes ONE scene)",
2011
2024
  'warnEmptyDesc': 'registered but description is empty (fill it in)',
2012
2025
  'catMention': 'Mention',
2013
2026
  'assetCategoriesFixed': 'Re-categorized {n} assets by naming convention',
@@ -2099,6 +2112,17 @@ function revealCanvasInRight() {
2099
2112
  'updateSrcChina': 'China mainland mirror',
2100
2113
  'updateSrcNow': 'Active source',
2101
2114
  'updateSrcSet': 'Update source changed',
2115
+ 'assetsSelAllPage': 'Select page',
2116
+ 'assetsAddToCanvas': 'Add to canvas',
2117
+ 'assetsClearSel': 'Clear selection',
2118
+ 'assetsOnlyAudio': 'Only audio assets selected — nothing to place on canvas',
2119
+ 'assetsAudioSkip': '{n} audio assets skipped',
2120
+ 'assetsAdded': '{n} asset nodes added',
2121
+ 'assetsBatchDelWarn': 'Selected assets will be deleted from the library; canvas nodes referencing them will be unbound:',
2122
+ 'assetsDeletedN': '{n} assets deleted',
2123
+ 'assetsTotalCount': '{n} items',
2124
+ 'assetClickHint': 'Click to select / double-click to add to canvas',
2125
+ 'assetsRelinked': 'Relinked {n} nodes to their assets',
2102
2126
  'dataRootLabel': 'Data root',
2103
2127
  'dataRootPlaceholder': 'e.g. D:\\canvas-data',
2104
2128
  'dataRootHint': 'Assets and videos are stored per project under this folder (no more C: IndexedDB). Empty = browser IndexedDB.',
@@ -2710,7 +2734,31 @@ body[data-ds-dark-theme] .dshic-studio-modal{border-color:var(--dsw-alias-border
2710
2734
  .dshic-modal-assets{display:flex;flex-direction:column;gap:10px;}
2711
2735
  .dshic-modal-assets .dshic-asset-grid{grid-template-columns:repeat(auto-fill,minmax(158px,1fr));gap:10px;}
2712
2736
  .dshic-modal-assets .dshic-asset-thumb{height:112px;}
2713
- .dshic-asset-pager{display:flex;align-items:center;gap:8px;font-size:11.5px;color:var(--dsw-alias-label-secondary);}
2737
+ /* ── 资产页工具栏(项目下拉下一行):同步/导入/全选/批量操作 + 分页同排 ──
2738
+ 按钮统一「透明底 + 1px 线框 + 文字」(UI-RULES:禁止灰底色块);hover 只加深边框不加底色。
2739
+ 窄窗口 flex-wrap 换行,分页 margin-left:auto 始终靠右。 */
2740
+ .dshic-asset-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;row-gap:6px;}
2741
+ .dshic-asset-toolbar-main{display:flex;align-items:center;gap:8px;flex-wrap:wrap;row-gap:6px;min-width:0;}
2742
+ .dshic-asset-batch{display:flex;align-items:center;gap:8px;flex-wrap:wrap;row-gap:6px;}
2743
+ .dshic-toolbtn{display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 10px;border-radius:7px;
2744
+ border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);
2745
+ font:inherit;font-size:12px;line-height:1;white-space:nowrap;flex:none;cursor:pointer;}
2746
+ .dshic-toolbtn:hover:not(:disabled){border-color:var(--dsw-alias-label-secondary);}
2747
+ .dshic-toolbtn:disabled{opacity:.45;cursor:default;}
2748
+ .dshic-toolbtn.is-danger{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);}
2749
+ .dshic-toolbtn.is-icon{width:26px;padding:0;justify-content:center;font-size:14px;}
2750
+ .dshic-asset-selall{display:inline-flex;align-items:center;gap:4px;font-size:12px;
2751
+ color:var(--dsw-alias-label-secondary);cursor:pointer;flex:none;}
2752
+ .dshic-asset-audiohint{font-size:11px;color:var(--dsw-alias-label-secondary);opacity:.75;}
2753
+ .dshic-asset-pager{display:flex;align-items:center;gap:6px;margin-left:auto;flex:none;
2754
+ font-size:11.5px;color:var(--dsw-alias-label-secondary);}
2755
+ .dshic-asset-pagebox{display:inline-flex;align-items:center;gap:4px;}
2756
+ .dshic-asset-pageinput{width:44px;height:26px;text-align:center;font:inherit;font-size:12px;padding:0 4px;
2757
+ border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;
2758
+ color:var(--dsw-alias-label-primary);box-sizing:border-box;}
2759
+ .dshic-asset-pageinput:focus{outline:none;border-color:var(--dsw-alias-brand-primary);box-shadow:var(--dshic-shadow-sel);}
2760
+ .dshic-asset-pagetotal,.dshic-asset-pagecount{font-variant-numeric:tabular-nums;white-space:nowrap;}
2761
+ .dshic-asset-pagecount{opacity:.75;}
2714
2762
  /* 设定集条目:行 + 已绑定资产缩略图 */
2715
2763
  .dshic-bible-item{display:flex;flex-direction:column;gap:4px;padding:5px 0;border-bottom:1px dashed var(--dsw-alias-border-l1);}
2716
2764
  .dshic-bible-thumbs{display:flex;gap:5px;flex-wrap:wrap;padding-left:4px;}
@@ -2913,6 +2961,9 @@ body[data-ds-dark-theme] .dshic-inline-input{border-color:var(--dsw-alias-border
2913
2961
  .dshic-asset{position:relative;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;overflow:hidden;cursor:pointer;
2914
2962
  background:var(--dsw-alias-bg-layer-2);}
2915
2963
  .dshic-asset:hover{border-color:var(--dsw-alias-brand-primary);}
2964
+ /* 批量选择:复选框常驻左上角;选中卡片描边 */
2965
+ .dshic-asset-check{position:absolute;left:6px;top:6px;z-index:2;width:15px;height:15px;cursor:pointer;accent-color:var(--dsw-alias-brand-primary);}
2966
+ .dshic-asset.is-checked{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px;}
2916
2967
  .dshic-asset-thumb{width:100%;height:86px;object-fit:cover;display:block;background:var(--dsw-alias-bg-layer-2);}
2917
2968
  .dshic-asset-meta{display:flex;align-items:center;gap:4px;padding:3px 6px;font-size:10px;color:var(--dsw-alias-label-secondary);flex-wrap:wrap;}
2918
2969
  .dshic-asset-actions{position:absolute;top:4px;right:4px;display:flex;gap:3px;opacity:0;transition:opacity .12s;}
@@ -3641,6 +3692,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3641
3692
  V.x = s.graph.view.x; V.y = s.graph.view.y; V.scale = s.graph.view.scale;
3642
3693
  applyViewToDom();
3643
3694
  });
3695
+ scheduleRepair(); // 载入/切画布后自愈被误置空的资产引用(幂等,每画布一次)
3644
3696
  history.stack = [];
3645
3697
  history.idx = -1;
3646
3698
  pushHistory();
@@ -4038,6 +4090,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4038
4090
  new_character: 'new_character', newchar: 'new_character', '新角色': 'new_character', '入场': 'new_character',
4039
4091
  scene_change: 'scene_change', scene: 'scene_change', '换场': 'scene_change', '转场': 'scene_change',
4040
4092
  closeup: 'closeup', insert: 'closeup', '特写': 'closeup', '插入': 'closeup',
4093
+ // 同机位状态跳变:切前不在/切后在(灯闪现身、影子凭空在场、影化实)——奇幻特效叙事的合法段落
4094
+ state_jump: 'state_jump', jump: 'state_jump', '跳变': 'state_jump', '状态跳变': 'state_jump',
4041
4095
  };
4042
4096
  let seg = SEG_ALIAS[segRaw] || '';
4043
4097
  const boxed = (k) => String(s[k] || '').trim();
@@ -4049,8 +4103,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4049
4103
  else seg = 'continuation';
4050
4104
  }
4051
4105
  if (seg === 'opening' && prevShot) seg = 'continuation'; // 首段只能在第 1 镜;后面标"开场"视为续帧
4052
- // 接缝档位:换场/新角色入场都放宽(新角色段本就不承接上段画面),特写插入允许跳切
4053
- const join = (seg === 'scene_change' || seg === 'new_character') ? 'loose' : seg === 'closeup' ? 'cut' : 'strict';
4106
+ // 接缝档位:换场/新角色入场都放宽(新角色段本就不承接上段画面),特写插入与状态跳变允许跳切
4107
+ const join = (seg === 'scene_change' || seg === 'new_character') ? 'loose' : (seg === 'closeup' || seg === 'state_jump') ? 'cut' : 'strict';
4054
4108
  // 只有真正需要画面承接的段落才接力尾帧;新角色入场首帧若来自上一段,新角色反而无从进入
4055
4109
  const chain = seg === 'continuation' && !!prevShot;
4056
4110
  // ownTail = 本镜的接点尾态(留给**下一镜**);cam = 本镜运镜(同样留给下一镜延续)
@@ -4109,7 +4163,16 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4109
4163
  let kindLine = '';
4110
4164
  if (p.seg === 'scene_change') kindLine = zh ? '段落类型:换场(不承接上一镜画面,直接建立新空间;环境声可延续)' : 'Segment type: scene change (do not continue the previous frame; establish the new space; ambience may carry over)';
4111
4165
  else if (p.seg === 'closeup') kindLine = zh ? '段落类型:特写/细节插入(可与上一镜跳切,不要求画面连续)' : 'Segment type: insert close-up (jump cut allowed, no frame continuity required)';
4112
- else if (p.seg === 'new_character') kindLine = zh ? '段落类型:新角色入场(新角色须在画面中自然进入,不得凭空出现)' : 'Segment type: new character enters (must enter naturally, never pop in)';
4166
+ else if (p.seg === 'state_jump') kindLine = zh
4167
+ ? '段落类型:同机位状态跳变(机位/构图与上一镜完全一致,不推不摇;区别只是**状态**——主体/特效在第 1 帧已完整在场且静止;绝不允许演出进入/飞入/移动/变形过程,也不得回退到上一镜状态)'
4168
+ : 'Segment type: same-framing state jump (framing identical to the previous shot, camera locked; the ONLY difference is state - the subject/effect is already fully present and STATIC in frame 1; never animate an entrance/fly-in/move/morph, never fall back to the previous state)';
4169
+ else if (p.seg === 'new_character') kindLine = zh
4170
+ ? ((p.fxEntry || /凝聚|凭空|灯闪|黑场|影子|化实|现身|浮现/.test(String(p.start || '') + String(p.note || '')))
4171
+ ? '段落类型:新角色入场(以特效方式进入:灯闪/黑场后已在场、从影子凝聚立起、浮现成形——不得缓慢走入)'
4172
+ : '段落类型:新角色入场(新角色须在画面中自然进入,不得凭空出现)')
4173
+ : ((p.fxEntry || /凝聚|凭空|灯闪|黑场|影子|化实|现身|浮现/.test(String(p.start || '') + String(p.note || '')))
4174
+ ? 'Segment type: new character enters via an effect (appears after a flash/black frame, rises from a shadow, condenses into form - never walks in slowly)'
4175
+ : 'Segment type: new character enters (must enter naturally, never pop in)');
4113
4176
  else if (p.seg === 'continuation') kindLine = zh
4114
4177
  ? (isFirst ? '段落类型:承接上一个分镜表(本分镜第 1 镜从上一镜结尾继续,不重演、不重新建立场景)' : '段落类型:续帧(从上一镜结尾继续,不重演)')
4115
4178
  : (isFirst ? 'Segment type: continues the previous storyboard (no re-establishing, no replay)' : 'Segment type: continuation (continue from the previous shot, no replay)');
@@ -4124,8 +4187,9 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4124
4187
  } else if (p.start && p.seg === 'continuation') {
4125
4188
  parts.push((zh ? '本镜起始态:' : 'Start state: ') + p.start);
4126
4189
  }
4127
- // 运镜延续:优先用上一镜的运镜(本镜要接着走);没有则用本镜自己写的 cam
4128
- if (p.cam) parts.push((zh ? '运镜延续:' : 'Camera continues: ') + p.cam + (zh ? '(方向与速度保持,不反向、不突变)' : ' (same direction and speed; no reversal, no sudden change)'));
4190
+ // 运镜延续:优先用上一镜的运镜(本镜要接着走);没有则用本镜自己写的 cam。
4191
+ // state_jump 同机位跳变除外:机位必须锁死,不承接上一镜的运动。
4192
+ if (p.cam && p.seg !== 'state_jump') parts.push((zh ? '运镜延续:' : 'Camera continues: ') + p.cam + (zh ? '(方向与速度保持,不反向、不突变)' : ' (same direction and speed; no reversal, no sudden change)'));
4129
4193
  // 本镜的接点尾态单独提示,明确它是留给下一段的(同时提醒不要在片尾收成定格)
4130
4194
  if (p.tail && p.seg === 'continuation') {
4131
4195
  parts.push((zh ? '本镜接点(片尾停在此状态,保持动作进行中,不要演完站定)' : 'End this shot on this hand-off state, still mid-motion; do not settle to a static pose') + ':' + p.tail);
@@ -4133,9 +4197,13 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4133
4197
  if (p.note) parts.push((zh ? '接戏要求:' : 'Continuity requirement: ') + p.note);
4134
4198
  if (!kindLine && !parts.length) return '';
4135
4199
  const head = zh ? '【衔接】' : '[Continuity] ';
4136
- const end = zh
4137
- ? '禁止重启姿态、禁止重新建立场景、禁止改变人物朝向与站位(除非剧情明确要求)'
4138
- : 'Never reset posture, never re-establish the scene, never change facing or blocking unless the story demands it';
4200
+ const end = p.seg === 'state_jump'
4201
+ ? (zh
4202
+ ? '除状态差外,机位、构图、光线基调与上一镜保持一致;本镜只呈现这一次状态跳变'
4203
+ : 'Except for the state change, keep framing/composition/light identical to the previous shot; this cut renders exactly one state jump')
4204
+ : (zh
4205
+ ? '禁止重启姿态、禁止重新建立场景、禁止改变人物朝向与站位(除非剧情明确要求)'
4206
+ : 'Never reset posture, never re-establish the scene, never change facing or blocking unless the story demands it');
4139
4207
  const body = [kindLine].concat(parts, [end]).filter(Boolean);
4140
4208
  // 统一标点:拼接前去掉各自尾部标点,避免出现「。;」这种叠标点
4141
4209
  const clean = body.map((x) => String(x).replace(/[。;;.、\s]+$/, '')).filter(Boolean);
@@ -4176,9 +4244,10 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4176
4244
  // 同时给这段打 seamRisk:'forced'(UI 要如实显示"这段是硬切的",不静默);
4177
4245
  // ⑤ 只有 ① 之外的情况(上一段末镜与本段首镜同为 continuation)才需要尾帧接力。
4178
4246
  // ============================================================
4179
- /** 该 seg 是否构成一个"可以安全开始新生成段"的切点。opening 只在全表第 1 镜成立。 */
4247
+ /** 该 seg 是否构成一个"可以安全开始新生成段"的切点。opening 只在全表第 1 镜成立。
4248
+ * state_jump(同机位状态跳变)也是合法切点:跳变本身就是"切"——前后镜只差状态、不接动作。 */
4180
4249
  function isCutPoint(seg) {
4181
- return seg === 'scene_change' || seg === 'closeup' || seg === 'new_character' || seg === 'opening';
4250
+ return seg === 'scene_change' || seg === 'closeup' || seg === 'new_character' || seg === 'opening' || seg === 'state_jump';
4182
4251
  }
4183
4252
  /**
4184
4253
  * 把一张分镜表的镜头按「真实镜头边界」切成若干生成段。
@@ -5711,6 +5780,12 @@ function queueThumb(assetId) {
5711
5780
  // 协议自动路由:优云智算的图片 API 只有任务式(/image/v1/tasks)——误配成通用模式
5712
5781
  // 会在 /v1/images/generations 上拿到 401 "invalid api key"(该面不存在),按域名自动切任务式
5713
5782
  try { if (/compshare\.cn$/i.test(new URL(base).hostname)) return await compshareImageTask(prompt, refs, { ...s, extra: extraSrc }, opts); } catch { /* URL 异常由后续流程报错 */ }
5783
+ // 三宝影像工坊:图片走**异步任务协议**(POST /openapi/v1/images 拿任务 id → 轮询 → 下载)。
5784
+ // 通用同步格式在该厂商出图 >120s 会吃代理 504,且手里没有任务 id、已扣费也无法回查;
5785
+ // 域名命中自动切任务式(与优云同款),也可在图片 API 模式下拉显式选「三宝图片任务」。
5786
+ let sanbaoRoute = s.mode === 'sanbao';
5787
+ if (!sanbaoRoute) { try { sanbaoRoute = /(^|\.)sanbaobeauty\.com$/i.test(new URL(base).hostname); } catch { /* URL 异常由后续流程报错 */ } }
5788
+ if (sanbaoRoute) return await sanbaoImageTask(prompt, refs, s, opts);
5714
5789
  const upstreamTimeout = Number(s.timeoutMs) > 0 ? Number(s.timeoutMs) : 120000; // 商汤等同步接口 20s+,默认 120s
5715
5790
  // 参考图编辑模式:multipart 上传到 /images/edits(OpenAI gpt-image-1 兼容)
5716
5791
  if (refs.length && s.mode === 'edits') {
@@ -5767,6 +5842,14 @@ function queueThumb(assetId) {
5767
5842
  body: b, timeoutMs: upstreamTimeout, label,
5768
5843
  });
5769
5844
  let res = await send(body, '图片 API');
5845
+ // 瞬态兜底(通用格式):上游慢/冷启动导致 502/503/504/429/408 时补一次尝试;
5846
+ // 401/400/405 是配置错误绝不重试(retryableDownloadError 与视频/下载同一判定口径)
5847
+ if (!res.ok && retryableDownloadError({ status: res.status })) {
5848
+ if (genAborted()) throw new Error(T('stoppedNote'));
5849
+ try { console.info('[IC] image api not ready (HTTP ' + res.status + ') — retry 1/1'); } catch { /* 忽略 */ }
5850
+ await sleep(20000);
5851
+ res = await send(body, '图片 API(瞬态重试)');
5852
+ }
5770
5853
  if (!res.ok && res.status === 400) {
5771
5854
  const bad = unsupportedFieldName(res.text);
5772
5855
  if (bad && Object.prototype.hasOwnProperty.call(body, bad)) {
@@ -6059,9 +6142,63 @@ function queueThumb(assetId) {
6059
6142
  if (!r.ok && (r.status === 401 || r.status === 403) && authFallback && Object.keys(authFallback).length) {
6060
6143
  r = await fetchViaProxy(url, { method: 'GET', headers: authFallback, timeoutMs: 300000, label: '下载视频' });
6061
6144
  }
6062
- if (!r.ok) throw new Error('下载视频失败 HTTP ' + r.status);
6145
+ if (!r.ok) {
6146
+ const e = new Error('下载视频失败 HTTP ' + r.status);
6147
+ e.status = r.status; // 供下载重试判定区分「缓存未就绪(502/404…)」与「鉴权/请求错误(401/400)」
6148
+ throw e;
6149
+ }
6063
6150
  return r.blob;
6064
6151
  }
6152
+ /** 下载重试判定(纯函数):厂商任务成功后 CDN 缓存尚未铺开时,首次 GET 常见
6153
+ * 502/503/504/404/403/429/408;这些都可重试。401(鉴权)与 400/405(请求格式)
6154
+ * 是配置错误,绝不重试——否则会把真实错误拖满整个重试窗口。 */
6155
+ function retryableDownloadError(err) {
6156
+ const st = Number(err && err.status) || 0;
6157
+ if (!st) return true; // 无 HTTP 状态 = 网络抖动/代理超时(fetchViaProxy 直接抛错)
6158
+ return st === 403 || st === 404 || st === 408 || st === 409 || st === 425 || st === 429 || st >= 500;
6159
+ }
6160
+ /** 三宝:succeeded 后等 CDN 缓存铺开的下载重试窗口(实测 2–3 分钟,最迟 5 分钟;留 10 分钟余量)。
6161
+ * 生成成功只有一次下载机会 → 单次 502 不能让整次生成作废。 */
6162
+ const SANBAO_DOWNLOAD_RETRY_MS = 10 * 60 * 1000;
6163
+ const SANBAO_DOWNLOAD_RETRY_STEP_MS = 10 * 1000;
6164
+ /** 带窗口的下载重试(三宝等「任务成功 ≠ 文件可下载」的厂商):
6165
+ * · 仅在可重试错误上循环(见 retryableDownloadError),鉴权/请求错误立即抛;
6166
+ * · 每次重试前可用 refreshUrl 拿最新签名地址(旧地址可能已过期);
6167
+ * · 到达窗口上限后抛明确错误(带最后 HTTP 状态),绝不再无限等;
6168
+ * · 中断(用户停止)优先于重试;download/sleep/now 可注入供回归(不真等 10 分钟)。 */
6169
+ async function downloadVideoWithRetry(url, headers, opts) {
6170
+ const o = opts || {};
6171
+ const windowMs = o.windowMs == null ? SANBAO_DOWNLOAD_RETRY_MS : Math.max(0, Number(o.windowMs) || 0);
6172
+ const stepMs = o.stepMs == null ? SANBAO_DOWNLOAD_RETRY_STEP_MS : Math.max(0, Number(o.stepMs) || 0);
6173
+ const dl = typeof o.download === 'function' ? o.download : downloadVideo;
6174
+ const wait = typeof o.sleep === 'function' ? o.sleep : sleep;
6175
+ const now = typeof o.now === 'function' ? o.now : Date.now;
6176
+ const isAborted = typeof o.isAborted === 'function' ? o.isAborted : genAborted;
6177
+ const deadline = now() + windowMs;
6178
+ for (let attempt = 1; ; attempt++) {
6179
+ if (isAborted && isAborted()) throw new Error(T('stoppedNote'));
6180
+ try {
6181
+ return await dl(url, headers || {}, o.authFallback);
6182
+ } catch (e) {
6183
+ if (!retryableDownloadError(e)) throw e;
6184
+ if (now() >= deadline) {
6185
+ const err = new Error((o.label ? o.label + ' ' : '') + '视频已生成,但 '
6186
+ + Math.round(windowMs / 60000) + ' 分钟内仍无法下载(最后错误:' + ((e && e.message) || e) + ')');
6187
+ err.status = e && e.status;
6188
+ err.downloadTimeout = true;
6189
+ throw err;
6190
+ }
6191
+ if (typeof o.onRetry === 'function') { try { o.onRetry(e, attempt); } catch { /* 诊断失败不影响重试 */ } }
6192
+ if (typeof o.refreshUrl === 'function') {
6193
+ try {
6194
+ const fresh = await o.refreshUrl();
6195
+ if (fresh) url = fresh;
6196
+ } catch { /* 刷新地址失败:沿用旧地址继续重试 */ }
6197
+ }
6198
+ await wait(stepMs);
6199
+ }
6200
+ }
6201
+ }
6065
6202
  /** 跨镜衔接标注(短剧分镜链式生成的行业标准做法):图1=上一镜尾帧(仅用于衔接),
6066
6203
  * 图2..N=实体参考图(名称与 o.refNames 对齐)。Seedance 的 first_frame 与 reference_image 互斥,
6067
6204
  * 尾帧+参考图同连时尾帧降级为第一张衔接参考图,靠顺序+标注控制用途。 */
@@ -6386,6 +6523,93 @@ function queueThumb(assetId) {
6386
6523
  if (st === 'failed') return { state: 'fail', error: sanbaoErrorOf(j) || st };
6387
6524
  return { state: 'wait' };
6388
6525
  }
6526
+ // —— 三宝图片任务协议(/openapi/v1/images,异步):通用同步格式在该厂商会 504
6527
+ // (出图 >120s 时代理 abort,且手里没有任务 id,远程已扣费也无法回查)。
6528
+ // 任务式与视频同构:提交拿 id → 轮询 → 下载,钱花了必须能凭 id 找回。——
6529
+ /** 三宝图片请求体(纯函数供回归断言):model/prompt/aspect_ratio/images/quality;
6530
+ * images 为公网 URL 数组(本地参考图先经 uploads/raw 转公网);uploadKey 绝不进请求体。 */
6531
+ function buildSanbaoImageBody(base, media) {
6532
+ const b = base || {};
6533
+ const m = media || {};
6534
+ const out = {
6535
+ model: String(b.model || ''),
6536
+ prompt: String(b.prompt || ''),
6537
+ aspect_ratio: String(b.aspect_ratio || 'auto'),
6538
+ quality: String(b.quality || 'high'),
6539
+ };
6540
+ const images = (Array.isArray(m.refUrls) ? m.refUrls : []).map(String).filter(Boolean);
6541
+ if (images.length) out.images = images;
6542
+ return out;
6543
+ }
6544
+ /** 三宝图片结果地址(纯函数):succeeded 后从 data.image_url / data.images[0](字符串或 {url})/
6545
+ * data.download_url 逐级取第一个 http(s) 地址;顶层兜底兼容。 */
6546
+ function sanbaoImageResultOf(j) {
6547
+ if (!j || typeof j !== 'object') return '';
6548
+ const d = (j.data && typeof j.data === 'object') ? j.data : null;
6549
+ const imgs = ((d && Array.isArray(d.images) ? d.images : (Array.isArray(j.images) ? j.images : []))
6550
+ .map((x) => (typeof x === 'string' ? x : (x && x.url)))
6551
+ .find((u) => typeof u === 'string' && /^https?:/.test(u))) || '';
6552
+ return [d && (d.image_url || d.download_url || d.url), imgs, j.image_url, j.download_url]
6553
+ .find((u) => typeof u === 'string' && /^https?:/.test(u)) || '';
6554
+ }
6555
+ /** 三宝图片轮询判定:queued/processing 及未知状态 = 继续;succeeded → 图片地址;failed → error。 */
6556
+ function sanbaoImagePollState(j) {
6557
+ const st = sanbaoStatusOf(j);
6558
+ if (st === 'succeeded') {
6559
+ const url = sanbaoImageResultOf(j);
6560
+ return url ? { state: 'done', url } : { state: 'fail', error: '成功但无图片地址' };
6561
+ }
6562
+ if (st === 'failed') return { state: 'fail', error: sanbaoErrorOf(j) || st };
6563
+ return { state: 'wait' };
6564
+ }
6565
+ /** 三宝图片任务运行器:提交(本地参考图先经 uploads/raw 转公网)→ 轮询 → 带重试下载。
6566
+ * aspect_ratio:供应商设置填了 size(具体尺寸值)则原样传,否则节点比例(16:9 等),缺省 auto。
6567
+ * quality 默认 high,扩展参数可覆盖;uploadKey 只用于上传,绝不进任务请求体。 */
6568
+ async function sanbaoImageTask(prompt, refBlobs, s, opts) {
6569
+ const base = vendorBase(s.baseUrl, VIDEO_VENDORS.sanbao.base);
6570
+ const headers = { 'Content-Type': 'application/json', Authorization: 'Bearer ' + (s.apiKey || '') };
6571
+ const o = opts || {};
6572
+ const rawRefs = refBlobs || [];
6573
+ // 扩展参数:逃生舱;uploadKey 专用上传 key 只用于 /uploads/raw,绝不进任务请求体
6574
+ let uploadKey = s.apiKey || '';
6575
+ let extra = null;
6576
+ try {
6577
+ const ex = parseExtraParams(s.extra || '');
6578
+ if (ex) { uploadKey = String(ex.uploadKey || uploadKey); extra = { ...ex }; delete extra.uploadKey; }
6579
+ } catch (e) { throw new Error('三宝扩展参数配置有误:' + ((e && e.message) || e)); }
6580
+ // 参考图:本地 blob → uploads/raw 公网 URL;已是 http(s) 的引用原样透传
6581
+ const refUrls = [];
6582
+ for (const b of rawRefs) {
6583
+ const raw = (b && b.blob) ? b.blob : b;
6584
+ if (typeof raw === 'string' && /^https?:/i.test(raw)) { refUrls.push(raw); continue; }
6585
+ if (!raw) continue;
6586
+ refUrls.push(await sanbaoUploadRaw(base, uploadKey, raw, 'image'));
6587
+ }
6588
+ const aspect = String(s.size || '').trim() || String(o.ratio || '').trim() || 'auto';
6589
+ const body = buildSanbaoImageBody({ model: s.model || '', prompt, aspect_ratio: aspect, quality: 'high' }, { refUrls });
6590
+ if (extra) Object.assign(body, extra);
6591
+ const r1 = await fetchViaProxy(base + '/openapi/v1/images', { headers, body, timeoutMs: 120000, label: 'Sanbao 图片提交' });
6592
+ if (!r1.ok) throw new Error('Sanbao 图片提交 HTTP ' + r1.status + ' @ ' + base + ':' + r1.text.slice(0, 300));
6593
+ let j1 = null; try { j1 = JSON.parse(r1.text); } catch { throw new Error('Sanbao 图片响应非 JSON:' + r1.text.slice(0, 200)); }
6594
+ const tid = sanbaoTaskIdOf(j1);
6595
+ if (!tid) throw new Error('Sanbao 图片响应中没有任务 id:' + r1.text.slice(0, 200));
6596
+ const taskUrl = base + '/openapi/v1/images/' + encodeURIComponent(tid);
6597
+ if (o.onTask) { try { o.onTask(tid, taskUrl); } catch { /* 持久化失败不影响生成 */ } }
6598
+ const url = await vendorPoll('Sanbao', 5000, async () => {
6599
+ const r = await fetchViaProxy(taskUrl, { method: 'GET', headers: { Authorization: 'Bearer ' + (s.apiKey || '') }, timeoutMs: 60000, label: 'Sanbao 图片查询' });
6600
+ if (!r || !r.ok) return { state: 'wait' };
6601
+ let j = null; try { j = JSON.parse(r.text); } catch { return { state: 'wait' }; }
6602
+ return sanbaoImagePollState(j);
6603
+ });
6604
+ // 链接是签名直链(约 24h 有效),拿到就立即下载;下载带瞬态重试(缓存未就绪 502 同视频口径)
6605
+ return await downloadVideoWithRetry(url, {}, {
6606
+ windowMs: SANBAO_DOWNLOAD_RETRY_MS,
6607
+ stepMs: SANBAO_DOWNLOAD_RETRY_STEP_MS,
6608
+ onRetry: (e, n) => {
6609
+ try { console.info('[IC] sanbao image download not ready (' + ((e && e.message) || e) + ') — retry ' + n); } catch { /* 忽略 */ }
6610
+ },
6611
+ });
6612
+ }
6389
6613
  /** 三宝图片字段兜底触发:只认「图片/素材/格式/URL」类错误。
6390
6614
  * 余额(402/余额不足/credits)、鉴权(401/api key)、限流(429/频繁)、账号限制(403)绝不重试。 */
6391
6615
  function needsSanbaoMediaRetry(errText) {
@@ -6629,14 +6853,41 @@ function queueThumb(assetId) {
6629
6853
  let j1 = null; try { j1 = JSON.parse(r1.text); } catch { throw new Error('Sanbao 响应非 JSON:' + r1.text.slice(0, 200)); }
6630
6854
  const tid = sanbaoTaskIdOf(j1);
6631
6855
  if (!tid) throw new Error('Sanbao 响应中没有任务 id:' + r1.text.slice(0, 200));
6632
- if (o.onTask) { try { o.onTask(tid, base + '/openapi/v1/videos/' + encodeURIComponent(tid)); } catch { /* 持久化失败不影响生成 */ } }
6856
+ const taskUrl = base + '/openapi/v1/videos/' + encodeURIComponent(tid);
6857
+ if (o.onTask) { try { o.onTask(tid, taskUrl); } catch { /* 持久化失败不影响生成 */ } }
6858
+ const queryTask = async (label) => {
6859
+ const r = await fetchViaProxy(taskUrl, { method: 'GET', headers: { Authorization: 'Bearer ' + (s.apiKey || '') }, timeoutMs: 60000, label });
6860
+ if (!r || !r.ok) return null;
6861
+ try { return JSON.parse(r.text); } catch { return null; }
6862
+ };
6633
6863
  const url = await vendorPoll('Sanbao', 8000, async () => {
6634
- const r = await fetchViaProxy(base + '/openapi/v1/videos/' + encodeURIComponent(tid), { method: 'GET', headers: { Authorization: 'Bearer ' + (s.apiKey || '') }, timeoutMs: 60000, label: 'Sanbao 查询' });
6635
- if (!r || !r.ok) return { state: 'wait' };
6636
- let j = null; try { j = JSON.parse(r.text); } catch { return { state: 'wait' }; }
6637
- return sanbaoPollState(j);
6864
+ const j = await queryTask('Sanbao 查询');
6865
+ return j ? sanbaoPollState(j) : { state: 'wait' };
6638
6866
  });
6639
- return await downloadVideo(url, {});
6867
+ // 三宝 succeeded 只代表转码完成:CDN 缓存尚未铺开时首次 GET 会 502(实测 2–3 分钟,最迟 5 分钟)。
6868
+ // 任务已成功、钱已花 → 给 10 分钟重试窗口,每次重试前刷新签名地址;鉴权/请求错误仍立即失败。
6869
+ try {
6870
+ return await downloadVideoWithRetry(url, {}, {
6871
+ windowMs: SANBAO_DOWNLOAD_RETRY_MS,
6872
+ stepMs: SANBAO_DOWNLOAD_RETRY_STEP_MS,
6873
+ refreshUrl: async () => {
6874
+ const j = await queryTask('Sanbao 缓存查询');
6875
+ if (!j) return '';
6876
+ const st = sanbaoPollState(j);
6877
+ return st.state === 'done' ? st.url : '';
6878
+ },
6879
+ onRetry: (e, n) => {
6880
+ try {
6881
+ console.info('[IC] sanbao download not ready (' + ((e && e.message) || e) + ') — retry '
6882
+ + n + '/' + Math.ceil(SANBAO_DOWNLOAD_RETRY_MS / SANBAO_DOWNLOAD_RETRY_STEP_MS));
6883
+ } catch { /* 诊断失败不影响重试 */ }
6884
+ },
6885
+ });
6886
+ } catch (e) {
6887
+ const err = new Error('三宝视频下载失败(任务 ' + tid + '):' + ((e && e.message) || e));
6888
+ err.status = e && e.status;
6889
+ throw err;
6890
+ }
6640
6891
  },
6641
6892
  // —— MiniMax 海螺:异步 task_id + query 接口 ——
6642
6893
  async minimax(prompt, frameBlob, s, o) {
@@ -7373,6 +7624,23 @@ function queueThumb(assetId) {
7373
7624
  URL.revokeObjectURL(url);
7374
7625
  }
7375
7626
  }
7627
+ /** 尾帧入库决策(纯函数):一次生成只入一张尾帧。
7628
+ * 优先"最佳选帧"(续帧接力用的是它);best 缺失或与 last 同一张 → 用 last(命名"尾帧");
7629
+ * best 与 last 是两张不同画面 → 只存 best(命名"尾帧选帧"),真·最后一帧不再单独入库。
7630
+ * 历史事故:生成路径与媒体节点体兜底两条管线各存一张,一次生成冒出三张尾帧资产。 */
7631
+ function tailFrameDecision(tail) {
7632
+ const t = tail || {};
7633
+ const last = t.last || null;
7634
+ const best = t.best || null;
7635
+ if (!last && !best) return null;
7636
+ const same = !best || best === last;
7637
+ return {
7638
+ blob: same ? last : best,
7639
+ isPick: !same,
7640
+ t: Number(t.bestT) || 0,
7641
+ score: Number(t.bestScore) || 0,
7642
+ };
7643
+ }
7376
7644
  /** 缩略灰度(接缝校验用):任意图 Blob → 32×32 RGBA。 */
7377
7645
  async function grayThumb(blob, size) {
7378
7646
  const n = Math.max(8, Math.min(128, Number(size) || 32));
@@ -8188,8 +8456,22 @@ function queueThumb(assetId) {
8188
8456
  const LS_DOCSYNC = 'dsh-ic:docsync:';
8189
8457
  /** Host 侧改动了项目文档(Agent 建节点/连线/写内容/补设定集)→ 拉回并合并到本地画布。
8190
8458
  * canvasId 非空 = 该画布文档(多画布);缺省 = 项目默认画布。 */
8191
- function mergeHostDoc(pid, full, canvasId) {
8192
- if (!full) return;
8459
+ /** 媒体节点指针空值保护(纯函数供回归):Host 副本把 assetId/lastAssetId 清成 null 时,
8460
+ * 本地有值则保留——null 不是有效写入(没人会"有意"清空指针),而这类 null 恰是
8461
+ * 「历史清理误判 / 跨机空库」污染后的形态;真删资产时展示层有缺失态兜底,保留指针永远可恢复。
8462
+ * Host 的非空值仍以 Host 为准(Agent 写入是有意的)。 */
8463
+ function protectMediaPointer(hostNode, localNode) {
8464
+ if (!hostNode || !hostNode.data || !localNode || !localNode.data) return hostNode;
8465
+ const t = normalizeNodeType(hostNode.type);
8466
+ if (t !== 'image' && t !== 'video') return hostNode;
8467
+ const local = localNode.data;
8468
+ const data = { ...hostNode.data };
8469
+ let changed = false;
8470
+ if (!data.assetId && local.assetId) { data.assetId = local.assetId; changed = true; }
8471
+ if (!data.lastAssetId && local.lastAssetId) { data.lastAssetId = local.lastAssetId; changed = true; }
8472
+ return changed ? { ...hostNode, data } : hostNode;
8473
+ }
8474
+ function mergeHostDoc(pid, full, canvasId) { if (!full) return;
8193
8475
  const cid = full.canvasId || canvasId || DEFAULT_CANVAS_ID;
8194
8476
  // Host 侧(对话 Agent)可能写入了旧类型节点:先把整份文档归一,再做合并(类型迁移与旧项目兼容)
8195
8477
  normalizeGraphDoc(full);
@@ -8213,7 +8495,7 @@ function queueThumb(assetId) {
8213
8495
  // (否则刚生成完的分镜会被一次过期合并清空,客户端再推回去就永久丢失)
8214
8496
  if (cur && cur.type === 'storyboard' && Array.isArray(cur.data && cur.data.shots) && cur.data.shots.length
8215
8497
  && !(n && n.data && Array.isArray(n.data.shots) && n.data.shots.length)) continue;
8216
- nodes[nid] = n; // Host 为准(Agent 写入是有意的)
8498
+ nodes[nid] = protectMediaPointer(n, cur); // Host 为准,但媒体指针不允许被 Host 的 null 清空(回链被覆盖事故)
8217
8499
  }
8218
8500
  const deadEdges = new Set([...(local.edgeTombstones || []), ...(full.edgeTombstones || []), ...((live && live.edgeTombstones) || [])]);
8219
8501
  const edges = (live && live.edges) ? [...live.edges] : [...(local.edges || [])];
@@ -8243,6 +8525,7 @@ function queueThumb(assetId) {
8243
8525
  }
8244
8526
  }
8245
8527
  if (isActiveCanvas) update((s) => { s.graph = { nodes, edges: keep, view: s.graph.view, tombstones: tombOut, edgeTombstones: local.edgeTombstones || [] }; s.assetsTick++; });
8528
+ if (isActiveCanvas) scheduleRepair(); // 启动同步落图后自愈被误置空的资产引用
8246
8529
  }
8247
8530
  async function hostSyncTick() {
8248
8531
  if (hostSyncStopped) return;
@@ -8792,6 +9075,8 @@ function queueThumb(assetId) {
8792
9075
  const bible = bibleBlock(loadBible(S.activeId));
8793
9076
  const zh = effLang() !== 'en';
8794
9077
  const contOn = !(opts && opts.cont === false); // 分镜衔接开关(默认开)
9078
+ // 特效演绎开关:任一所选题材/影调卡 fx_motion:true → 追加特效演绎扩展块(见 FX_RULES)
9079
+ const fxOn = await fxMotionEnabledFor(S.activeId);
8795
9080
  const contFields = (() => {
8796
9081
  if (zh) {
8797
9082
  return contOn
@@ -8802,6 +9087,25 @@ function queueThumb(assetId) {
8802
9087
  ? '{"title":"…","visual":"…","motion":"…","timeBeats":["0s …","mid …","end …"],"camera":"…","vfx":"…","negative":"…","tail":"…","cam":"…","start":"…","seg":"continuation","characters":["…"],"scene":"…","props":["…"],"duration":3,"dialogue":[{"role":"Chen","line":"…"}],"sfx":"zipper snap, paper tear"}'
8803
9088
  : '{"title":"…","visual":"…","motion":"…","timeBeats":["0s …","mid …","end …"],"camera":"…","vfx":"…","negative":"…","characters":["…"],"scene":"…","props":["…"],"duration":3,"dialogue":[{"role":"Chen","line":"…"}],"sfx":"zipper snap, paper tear"}';
8804
9089
  })();
9090
+ /** 特效演绎扩展块(fx_motion 卡开启时注入):动作承担者中立 / 画面状态节拍 / 奇幻特效词表 /
9091
+ * 角色特效签名 / 速度铁律 / state_jump / 关键帧建议。写实项目(无 fx 卡)完全不受影响。 */
9092
+ const FX_RULES = !fxOn ? [] : (zh ? [
9093
+ '- **【特效演绎·动作承担者】动作的承担者由画面内容决定:角色身体、特效、光影、环境物皆可。特效主导镜的标准写法 = 本体静止 + 一道特效运动(例:人物立于桥头不动,一道兽形暗影贴地掠过画面;真气自掌心汇聚击出)。visual 写明本体状态(静止/仅衣袂微动),motion 写特效的运动轨迹与速度——"人物本体没动,一道特效动了"是完全合法的镜头;',
9094
+ '- **【特效镜节拍·覆盖】vfx/motion 写明"本体静止、特效运动"的镜头,timeBeats 改为**画面状态节拍**:按时间写可见的画面状态推进(例:["0s 桥面空景,第九灯稳定","1s 灯闪过曝一帧","1.5s 兽形暗影已横在桥面,静止"]),拍数 1–3 由内容定,**不受"必须三拍"限制**;身体动作镜仍按"起势→发力→落点"三拍执行;',
9095
+ '- **【vfx 必填·奇幻词表】每镜 vfx 至少 1 项,按需取用——氛围/环境:光尘浮游、雾气漫卷、热浪扭曲、落叶逆卷;发光体:器物幽光、符文亮起、眼瞳竖光;能量:真气/灵气光晕环绕、流光尾迹、粒子凝聚成形、光束击发、冲击波荡开、地面龟裂尘浪、草木伏倒;变化:灯闪过曝一帧、黑场跳变、影化实(影子立起成实体)、实化影(实体缩回影子)、凭空在场(切前不在切后在)、瞬移残影;异兽:剪影飞掠、局部呈现(角/爪/眼/尾)、尺度参照物(桶/门框/马对照);',
9096
+ '- **【角色特效签名·硬性】每个动用特效的角色/异兽,设定集 desc 必须带「特效签名:颜色 + 形态母题 + 粒子质地」(例:特效签名:青色流云纹真气,龙形招式,细雾粒子);缺失时先用 canvas_update_bible 补设定集再写分镜;本镜 vfx 涉及该角色时**必须逐字带出签名**——不同角色的光效颜色/形态必须可区分,跨镜头绝不漂色;',
9097
+ '- **【速度铁律·硬性】模型演不出"快":瞬时事件(一闪而过/瞬移/现身/消失)绝不在本镜内演出过程,一律写成切点两侧的状态差;速度感只允许三种来源:①硬切跳变 ②静止主体+光效突变 ③甩镜+运动模糊。禁止写"高速掠过/瞬间冲过去"让主体在镜内位移——改成三镜:空景 → 灯闪 → 已在场;',
9098
+ '- **【state_jump·同机位状态跳变】seg 可用 `state_jump`:切前不在/切后在(灯闪现身、影子凭空在场、影化实)。机位与上一镜完全一致且静止,不写 tail(尾态就是"静止完整在场")。「假换场」禁令不适用于 state_jump——假换场指既无状态变化又无叙事目的的乱跳;',
9099
+ '- **【关键帧建议】具象化招式/变身镜(龙形光效、法相、影化实)的 vfx 要写成**可直接出设定图的画面**(构图+形态+颜色+粒子);这类镜铺开生成时优先"先出关键帧设定图 → 图生视频(hard 首帧)";',
9100
+ ] : [
9101
+ '- **[FX-DRIVEN - ACTION BEARER] what carries the motion is decided by the picture: the character body, an effect, light or the environment are all valid. The standard FX-led shot = still body + one moving effect (e.g. the character stands still on the bridge while a beast-shaped shadow skims past; qi condenses from a palm and strikes). visual states the body state (still / only clothes stirring), motion describes the effect trajectory and speed - "body unmoved, an effect moves" is a fully legal shot;',
9102
+ '- **[FX BEATS - OVERRIDE] for shots whose vfx/motion say "body still, effect moves", timeBeats become PICTURE-STATE beats: visible state progression over time (e.g. ["0s empty bridge, ninth lantern steady","1s lantern flash overexposes one frame","1.5s the beast shadow is already lying across the deck, static"]), 1-3 beats as content dictates, exempt from the mandatory three-beat rule; body-action shots still use wind-up -> drive -> settle;',
9103
+ '- **[VFX REQUIRED - FANTASY LEXICON] at least 1 vfx per shot: ambience - drifting light dust, rolling mist, heat-haze shimmer, leaves sucked upward; glow - faint object luminescence, runes igniting, vertical slit pupils; energy - qi halo orbiting the body, light-trail, particles condensing into form, beam strike, shockwave ripple, cracked ground and dust wave, flattened grass; transformations - one-frame lantern flash, black-frame jump, shadow-to-solid (a shadow rises into a body), solid-to-shadow, already-present (absent before the cut, present after), teleport afterimage; beasts - silhouette streak, partial reveal (horn/claw/eye/tail), scale reference (bucket/door frame/horse);',
9104
+ '- **[CHARACTER FX SIGNATURE - HARD] every character/beast that uses effects must carry in its bible desc "特效签名:colour + motif + particle texture" (e.g. 特效签名:青色流云纹真气,龙形招式,细雾粒子); if missing, update the bible first; whenever a shot involves that character, its vfx must quote the signature VERBATIM - colours/motifs must stay distinguishable between characters and never drift across shots;',
9105
+ '- **[SPEED IRON LAW - HARD] video models cannot act "fast": instantaneous events (a flash-past / teleport / appearance / vanishing) must NEVER be performed inside a shot; write them as state differences across a cut. Speed may come only from: (1) a hard-cut jump, (2) a still subject plus a sudden light change, (3) a whip pan with motion blur. Never write "streaks past at high speed" expecting the subject to move within the shot - use three shots: empty frame -> flash -> already there;',
9106
+ '- **[STATE_JUMP] `state_jump` segment type: absent before the cut / present after (lantern-flash reveal, a shadow already there, shadow-to-solid). Framing identical to the previous shot and locked; no tail (the tail state IS "fully present, static"). The fake-scene-change ban does not apply to state_jump - a fake scene change is a jump with no state change and no narrative purpose;',
9107
+ '- **[KEYFRAME TIP] for materialized-technique / transformation shots (dragon-shaped light, dharma form, shadow-to-solid) write vfx as a picture that could be generated directly as a keyframe still (composition + form + colour + particles); when expanding, prefer keyframe-then-video (hard first frame) for these shots;',
9108
+ ]);
8805
9109
  const jsonContract = zh
8806
9110
  ? [
8807
9111
  '把剧本拆解为「按镜头切段生成」的分镜脚本:铺开时系统会按真实镜头边界把分镜切成若干次生成,每次只把本段的镜头写进同一条提示词,由视频模型生成那一段(镜头间由模型直接硬切,不是一镜一视频再拼接)。',
@@ -8809,10 +9113,10 @@ function queueThumb(assetId) {
8809
9113
  '规则:',
8810
9114
  '- visual 是本镜画面描述(景别、人物外观与站位、场景、光线、构图,60 字内);',
8811
9115
  '- **visual 与 motion 里的角色/场景/道具必须写成 @资产名@ 引用形式**(前后各一个 @ 精确包裹,如「@陈拾@ 在 @城市街头@ 的围挡旁拿起 @奇怪快递件@」);名称必须与设定集/资产**逐字一致**;剧本原文里已出现的 @资产名@ 锚点要在镜头中原样保留(名称逐字一致);名称内不得含 @、空格或标点;@ 后绝不允许直接跟其他文字(必须以 @ 闭合)——系统会隐藏两个 @ 并把名称显示为蓝色加粗,未登记的 @名称@ 会被一致性检查提示补充;',
8812
- '- motion 是本镜动作与运镜(主体动作节拍、机位运动方向与速度、情绪节奏,50 字内);与 visual 不重复;',
9116
+ '- motion 是本镜动作与运镜(主体动作节拍、机位运动方向与速度、情绪节奏,50 字内);与 visual 不重复;动作的承担者由画面内容决定——角色身体、特效、光影、环境物皆可(特效演绎项目见下方扩展条款);',
8813
9117
  '- **【动作层次·硬性】timeBeats 是本镜的三个时间节拍(数组,按时间顺序)**:把"一个动作"拆成 **起势 → 发力 → 落点** 三拍,每拍写**可见的**身体/道具状态,如 ["0s 右手抬到一半、指节收紧","1.2s 手继续抬到胸口、肩线前压","3s 停在信封贴住心口、雨珠从指缝滑落"]。**只写一个节拍 = 模型只会演一个姿势(用户实测:动作极简、只会平移)**;凡 ≥2s 的镜头必须写满 3 拍,≤1s 的快切镜可以只写 1 拍。**每一拍都必须能拍出来,不写"他感到/他意识到"**;',
8814
9118
  '- **camera 是本镜的机位/焦段/运镜三件套**(不是只写"推近/平移"):写成「景别 + 焦段光圈 + 运镜起点→终点」,如「中近景 50mm f/2.0,从腰高缓推至面部,匀速、到面部前 0.2 秒减速停住」。**禁止只写"推近/拉远/平移"这类空模板**(那是用户看到的"只会平移"的直接来源);**一镜只能有一个主运镜**,要两个就拆镜;',
8815
- '- **vfx 是本镜必须可见的物理特效/细节**(不写就没有,模型不会自己加):按题材点名 1–3 项——雨丝斜打 / 尘粒在光柱中浮动 / 雪片近大远小 / 逆光镜头光斑 / 路灯钠黄溢光 / 闪电瞬时照亮 / 衣角被风掀起 / 水面涟漪扩散 / 纸张翻飞 / 轻微手持晃动 / 运动模糊拖影 / 烟雾弥漫 / 蒸汽升腾。写**可拍摄的物理现象**,不写"画面很唯美"这类空话;**每场至少 3 镜要有 vfx**;',
9119
+ '- **vfx 是本镜必须可见的特效/细节**(不写就没有,模型不会自己加):按题材点名 1–3 项——雨丝斜打 / 尘粒在光柱中浮动 / 雪片近大远小 / 逆光镜头光斑 / 路灯钠黄溢光 / 闪电瞬时照亮 / 衣角被风掀起 / 水面涟漪扩散 / 纸张翻飞 / 轻微手持晃动 / 运动模糊拖影 / 烟雾弥漫 / 蒸汽升腾。写**可呈现的画面现象**,不写"画面很唯美"这类空话;**每场至少 3 镜要有 vfx**;',
8816
9120
  '- **【色调·逐镜显式】把本镜色调写进 visual(主色/色温/明暗对比,按影调色彩命题取值,如「钠黄主光、青绿补色、高对比」)——色调是逐镜的画面事实,不得只写"电影感/有质感"这类空话**;',
8817
9121
  '- characters/scene/props 使用剧本与设定集中的名称(不带 @),便于匹配资产;无道具给空数组;',
8818
9122
  '- **dialogue 是本镜的角色台词**:把剧本中落在这一镜的对白逐行搬进来({"role":"角色名","line":"台词原文"}),台词必须**逐字来自剧本**、不新写不改写;本镜无台词给空数组;一镜尽量只放一个角色的台词(单说话人镜头利于声音参考提取);',
@@ -8827,13 +9131,13 @@ function queueThumb(assetId) {
8827
9131
  '- **按情绪选景别**:孤独/绝望/宏大危机=远景;对峙/动作/关系建立=全景;对话/试探/信息交换=中景;震惊/怀疑/内心动摇=近景;崩溃/嘶吼/情绪爆发=特写;关键细节/道具揭示=大特写——冲突用全景、揭秘转近景、爆发给特写、反转可拉远,景别变化本身在讲情绪;',
8828
9132
  '- **快切镜头(<1.5s)的 visual/motion 要极短**(一个动作、一句画内信息),信息量大的镜头才配长时长——时长与内容量必须匹配;',
8829
9133
  '- 只输出 JSON,不要输出任何其他内容。',
8830
- ].concat(contOn ? [
9134
+ ].concat(FX_RULES, contOn ? [
8831
9135
  '',
8832
9136
  '**【分镜衔接·硬性】成片是分段生成的,每段模型看不到上一段画面——衔接只能靠写在分镜里的"接点"。除末镜外,每镜都必须写 tail 与 cam:**',
8833
9137
  '- **tail(接点尾态)**:本镜**最后一刻**的状态,一行写清——人物姿势停在哪个动作的中途、朝向、视线落点、手持物位置、位置关系(如「右手抬到胸口一半,视线仍锁在 @陈拾@ 脸上,@糯糯@ 停在他左后方半步」「已侧身转到 3/4 面,还没完全转身面对对方」)。**必须是"动作进行中"的状态,不能写成"已经完成/站定/看向"**——切点停在静止定格,下一镜就没有动作可接,接缝必然暴露;',
8834
9138
  '- **cam(运镜延续)**:本镜运镜的方向与速度,写成下一镜可以直接"接着走"的形式(如「右移横移,匀速,未停」「缓推向面部,接近停住」);末镜写「收束静止」;**全片避免相邻镜反向运镜**(上一镜右移、下一镜突然左移 = 观众立刻感觉跳),需要反向时把切点设计成遮挡/过肩/特写插入;',
8835
9139
  '- **start(仅第 1 镜或 seg 非续帧的镜头需要)**:本镜起始状态;续帧镜头不写 start(它会自动承接上一镜 tail);',
8836
- '- **seg(段落类型)**:`continuation` 续帧(默认,绝大多数镜头)、`scene_change` 换场/切换地点时间、`new_character` 新角色首次出场、`closeup` 特写/细节插入(允许跳切)、`opening` 仅第 1 镜且无上游承接时;',
9140
+ '- **seg(段落类型)**:`continuation` 续帧(默认,绝大多数镜头)、`scene_change` 换场/切换地点时间、`new_character` 新角色首次出场、`closeup` 特写/细节插入(允许跳切)、`opening` 仅第 1 镜且无上游承接时、`state_jump` 同机位状态跳变(切前不在/切后在,如灯闪现身;仅特效演绎时使用);',
8837
9141
  '- **一镜只做一个主动作**:转身、走路、推镜、换表情不要塞进同一镜——模型只会执行前半段,下一镜就对不上;',
8838
9142
  '- **一段一运镜**:不要又推又横移又摇;',
8839
9143
  '- **大位移拆镜**:人物横移超过画面 1/4、或场景大换位,就再拆一镜(用不同景别接,而不是一镜硬走);',
@@ -8845,10 +9149,10 @@ function queueThumb(assetId) {
8845
9149
  'Rules:',
8846
9150
  '- visual = the shot\'s frame description (shot size, wardrobe, staging, light, framing, <=60 words);',
8847
9151
  '- **characters/scenes/props inside visual and motion must be written as @Name@ references** (an @ on each side, e.g. "@Chen@ picks up @Parcel@ by @Street@"); names must match the bible/assets VERBATIM, with no @, space or punctuation inside; an @ must never be followed directly by other text (always close with @) - the UI hides the @s and shows the name in blue bold; unregistered @Name@ is flagged by the consistency check;',
8848
- '- motion = action & camera for the shot (action beats, camera move, emotional rhythm, <=50 words); do not repeat visual;',
9152
+ '- motion = action & camera for the shot (action beats, camera move, emotional rhythm, <=50 words); do not repeat visual; what carries the motion is decided by the picture - the body, an effect, light or the environment are all valid (FX projects: see the extension clauses below);',
8849
9153
  '- **[ACTION LAYERING - HARD] timeBeats is this shot\'s three time beats (array, in order)**: split "one action" into **wind-up -> drive -> settle**, each beat describing a VISIBLE body/prop state, e.g. ["0s right hand half-way up, knuckles tightening","1.2s hand reaches the chest, shoulder line pressing forward","3s it settles over the envelope, a raindrop sliding off the fingers"]. **A single beat means the model performs a single pose (measured user feedback: minimal motion, pan-only)**; any shot >=2s must carry 3 beats, rapid cuts <=1s may carry 1. **Every beat must be filmable - never "he feels / he realizes"**;',
8850
9154
  '- **camera = body/lens/move for this shot** (not just "push in / pan"): write "shot size + focal length & aperture + move start->end", e.g. "medium close-up 50mm f/2.0, slow push from waist height to the face, constant speed, decelerating to a stop 0.2s before the face". **Never use empty template verbs like push in / pull out / pan alone** (that is exactly what produces the "pan-only" result); **one primary camera move per shot** - if you need two, split the shot;',
8851
- '- **vfx = physical effects/details that must be visible in this shot** (if unwritten they simply do not exist; the model will not add them): name 1-3 per shot by genre - slanted rain / dust motes floating in a light shaft / snowflakes near-to-far / backlit lens flare / sodium-vapour streetlamp spill / lightning flash lighting the set / coat hem lifted by wind / ripples spreading on water / paper sheets tumbling / subtle handheld shake / motion-blur trails / drifting smoke / rising steam. Write **filmable physical phenomena**, never "a beautiful frame"; **at least 3 shots per scene must carry vfx**;',
9155
+ '- **vfx = physical effects/details that must be visible in this shot** (if unwritten they simply do not exist; the model will not add them): name 1-3 per shot by genre - slanted rain / dust motes floating in a light shaft / snowflakes near-to-far / backlit lens flare / sodium-vapour streetlamp spill / lightning flash lighting the set / coat hem lifted by wind / ripples spreading on water / paper sheets tumbling / subtle handheld shake / motion-blur trails / drifting smoke / rising steam. Write **renderable picture phenomena**, never "a beautiful frame"; **at least 3 shots per scene must carry vfx**;',
8852
9156
  '- **[TONE - PER SHOT] write this shot\'s dominant colour / colour temperature / contrast into visual per the look\'s colour thesis (e.g. "sodium-amber key, teal fill, high contrast") - tone is a per-shot fact, never just "cinematic"**;',
8853
9157
  '- characters/scene/props arrays must use plain names from the script and series bible (no @) so assets match; empty props array if none;',
8854
9158
  '- **dialogue = the character lines that fall in this shot**, moved verbatim from the script ({"role":"Name","line":"exact line"}); never rewrite lines; empty array if none; keep one speaker per shot when possible (helps voice-reference extraction);',
@@ -8863,13 +9167,13 @@ function queueThumb(assetId) {
8863
9167
  '- **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;',
8864
9168
  '- **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;',
8865
9169
  '- Output JSON only.',
8866
- ].concat(contOn ? [
9170
+ ].concat(FX_RULES, contOn ? [
8867
9171
  '',
8868
9172
  '**[CONTINUITY - HARD] the film is generated in segments and each segment cannot see the previous one, so the "hand-off point" must be written into the storyboard. Every shot except the last MUST carry tail and cam:**',
8869
9173
  '- **tail (hand-off tail state)**: the state at the LAST instant of this shot, in one line - where the posture stops mid-motion, facing, gaze target, hand/prop position, blocking (e.g. "right hand half-way up to the chest, eyes still locked on @Chen@, @Nuonuo@ half a step behind his left shoulder"). It MUST be a mid-motion state, never a settled/completed pose: a cut on a static freeze leaves nothing for the next shot to continue, which is exactly what makes the seam visible;',
8870
9174
  '- **cam (camera carry-over)**: the move direction and speed of this shot, written so the next shot can continue it (e.g. "lateral right, constant speed, never stops"; "slow push-in, almost settled"). Last shot: "settle to static". Avoid reversing direction on adjacent shots (right pan then sudden left pan reads as a jump); if you need a reversal, make the cut a wipe/over-shoulder/insert close-up;',
8871
9175
  '- **start**: the start state, needed only for shot 1 or shots whose seg is not a continuation; continuation shots omit it (they inherit the previous tail);',
8872
- '- **seg (segment type)**: `continuation` (default, most shots), `scene_change` (new place/time), `new_character` (a character appears for the first time), `closeup` (insert/detail, jump cut allowed), `opening` (only shot 1 with no upstream continuation);',
9176
+ '- **seg (segment type)**: `continuation` (default, most shots), `scene_change` (new place/time), `new_character` (a character appears for the first time), `closeup` (insert/detail, jump cut allowed), `opening` (only shot 1 with no upstream continuation), `state_jump` (same-framing state jump: absent before the cut / present after, e.g. a lantern-flash reveal; FX projects only);',
8873
9177
  '- **one primary action per shot**: never pack a turn + walk + push-in + expression change into one shot - the model only executes the first half and the next shot cannot match it;',
8874
9178
  '- **one camera move per shot**;',
8875
9179
  '- **split big displacements**: if a character crosses more than 1/4 of the frame, or the staging changes a lot, break it into another shot (different shot size) instead of one long move;',
@@ -9471,6 +9775,46 @@ function queueThumb(assetId) {
9471
9775
  return { x, y };
9472
9776
  }
9473
9777
 
9778
+ /** 资产批量导入落点(纯函数供回归):在现有节点最右侧之外按列铺开,一列 ≤5 个。
9779
+ * existingRects:现有节点矩形 [{x,y,w,h}];items:[{w,h}](按导入顺序,仅计可成节点的资产)。
9780
+ * 返回 [{x,y,w,h}]:列内自上而下堆叠、放不下碰撞则顺延,列间 GAP_COL,彼此与现有节点零重叠。 */
9781
+ function layoutBatchColumns(existingRects, items, opts) {
9782
+ const o = opts || {};
9783
+ const GAP_X = Number(o.gapX) || 80; // 与现有节点最右界的水平间距
9784
+ const GAP_COL = Number(o.gapCol) || 60; // 列间距
9785
+ const GAP_Y = Number(o.gapY) || 40; // 行间距
9786
+ const PER_COL = Number(o.perCol) || 5; // 一列上限
9787
+ const rects = (existingRects || []).filter((r) => r && Number.isFinite(Number(r.x)));
9788
+ const baseX = rects.length
9789
+ ? Math.round(Math.max(...rects.map((r) => (Number(r.x) || 0) + (Number(r.w) || 0))) + GAP_X)
9790
+ : 80;
9791
+ const baseY = Math.round(Number(o.y0) || 40);
9792
+ const placed = [];
9793
+ const hit = (x, y, w, h) => rects.find((r) => (Number(r.x) || 0) < x + w + 28 && (Number(r.x) || 0) + (Number(r.w) || 0) + 28 > x
9794
+ && (Number(r.y) || 0) < y + h + 28 && (Number(r.y) || 0) + (Number(r.h) || 0) + 28 > y)
9795
+ || placed.find((p) => p.x < x + w + 28 && p.x + p.w + 28 > x && p.y < y + h + 28 && p.y + p.h + 28 > y);
9796
+ const out = [];
9797
+ let colX = baseX;
9798
+ let colY = baseY;
9799
+ let colW = 0;
9800
+ let inCol = 0;
9801
+ for (const it of items || []) {
9802
+ const w = Math.max(1, Number(it && it.w) || 360);
9803
+ const h = Math.max(1, Number(it && it.h) || 220);
9804
+ if (inCol >= PER_COL) { colX = colX + colW + GAP_COL; colY = baseY; colW = 0; inCol = 0; }
9805
+ let y = colY;
9806
+ let blocker = hit(colX, y, w, h);
9807
+ let guard = 0;
9808
+ while (blocker && guard++ < 80) { y = (Number(blocker.y) || 0) + (Number(blocker.h) || 0) + 28; blocker = hit(colX, y, w, h); }
9809
+ out.push({ x: Math.round(colX), y: Math.round(y), w, h });
9810
+ placed.push({ x: colX, y, w, h });
9811
+ colW = Math.max(colW, w);
9812
+ colY = y + h + GAP_Y;
9813
+ inCol++;
9814
+ }
9815
+ return out;
9816
+ }
9817
+
9474
9818
  function addNodeAt(type, pos) {
9475
9819
  // 代码级强控制:建点坐标由布局引擎决定(一类型一列 + 碰撞下移),不信任调用者的自由坐标。
9476
9820
  // 媒体节点外框按比例(与 Host nextNodePos 同口径),其余 360×360。
@@ -9507,6 +9851,84 @@ function queueThumb(assetId) {
9507
9851
  pushHistory();
9508
9852
  flushSave(); // 删除立即推送(不等 450ms 防抖):同步把 Host 上的节点删掉,压缩"拉回复活"的时间窗
9509
9853
  }
9854
+ /** 历史条死条目裁剪(纯函数供回归):返回去死后的新数组,无死时原样返回(调用方按引用判变化)。
9855
+ * 【契约】只裁 history——绝不产生「清空当前 assetId」的语义(旧版清理曾把 assetId 置空落盘,
9856
+ * 刷新/跨机误判时造成生成节点预览全部丢失)。 */
9857
+ function pruneDeadHistory(history, aliveIds) {
9858
+ const hasDead = (history || []).some((x) => !aliveIds.has(x.assetId));
9859
+ if (!hasDead) return history;
9860
+ return (history || []).filter((x) => aliveIds.has(x.assetId));
9861
+ }
9862
+ /** 资产回链候选挑选(纯函数供回归):跳过已被其他节点引用的资产,取 createdAt 最新的一条;
9863
+ * 无可用候选返回 null(宁缺勿错)。 */
9864
+ function repairPickAsset(candidates, usedIds) {
9865
+ const pool = (candidates || []).filter((c) => c && c.id && !(usedIds && usedIds.has(c.id)));
9866
+ if (!pool.length) return null;
9867
+ let best = null;
9868
+ for (const c of pool) {
9869
+ if (!best || (Number(c.createdAt) || 0) >= (Number(best.createdAt) || 0)) best = c;
9870
+ }
9871
+ return best;
9872
+ }
9873
+ /** 资产回链计划(纯函数供回归):孤儿节点(done 无 assetId)按 nodeLabel 逐字匹配资产,
9874
+ * 跳过已被其他节点引用的候选,每节点取 createdAt 最新的一条;无可用候选 → 不产生修复项。 */
9875
+ function repairPlan(orphanNodes, recs, usedIdsIn) {
9876
+ const usedIds = new Set(usedIdsIn || []);
9877
+ const byLabel = new Map();
9878
+ for (const rec of recs || []) {
9879
+ if (rec.kind !== 'image' && rec.kind !== 'video') continue;
9880
+ const lb = String(rec.nodeLabel || '').trim();
9881
+ if (!lb) continue;
9882
+ if (!byLabel.has(lb)) byLabel.set(lb, []);
9883
+ byLabel.get(lb).push(rec);
9884
+ }
9885
+ const fixes = [];
9886
+ for (const nd of orphanNodes || []) {
9887
+ const pick = repairPickAsset(byLabel.get(String(nd.data.label || '').trim()), usedIds);
9888
+ if (!pick) continue;
9889
+ fixes.push({ id: nd.id, assetId: pick.id });
9890
+ usedIds.add(pick.id);
9891
+ }
9892
+ return fixes;
9893
+ }
9894
+ // 修复:旧版清理在 store 未就绪(刷新竞态)/跨机打开(本地库无资产行)时会误把 assetId
9895
+ // 置空并落盘 → 生成节点预览全部丢失(资产文件与资产库都还在,只有指针没了)。
9896
+ // 每次载入项目/切画布后跑一次:按 nodeLabel 与节点 label 逐字唯一匹配回链最新资产(幂等)。
9897
+ let repairDoneFor = '';
9898
+ let repairTimer = null;
9899
+ function scheduleRepair() {
9900
+ if (repairTimer) clearTimeout(repairTimer);
9901
+ repairTimer = setTimeout(() => { repairTimer = null; repairMissingAssetLinks().catch(() => { /* 静默 */ }); }, 1500);
9902
+ }
9903
+ async function repairMissingAssetLinks() {
9904
+ if (!S.store || !S.activeId) return;
9905
+ const nodes = Object.values(S.graph.nodes).filter((nd) => (nd.type === 'image' || nd.type === 'video')
9906
+ && nd.data && nd.data.status === 'done' && !nd.data.assetId && String(nd.data.label || '').trim());
9907
+ // 图未加载 / 服务端暂时拉不到清单 → 不记账直接返回(下次调度重试);
9908
+ // 记账必须在"真正完成一次有效检查"之后,否则启动竞态会把每画布一次的额度烧掉
9909
+ if (!nodes.length) return;
9910
+ const recs = await idbByProject(S.activeId).catch(() => []);
9911
+ if (!recs.length) {
9912
+ try { console.info('[IC] asset-relink: orphans=' + nodes.length + ' recs=0(assetsList 未返回)'); } catch { /* 忽略 */ }
9913
+ return;
9914
+ }
9915
+ const key = S.activeId + '/' + activeCanvasId();
9916
+ if (repairDoneFor === key) return;
9917
+ repairDoneFor = key;
9918
+ const usedIds = new Set(Object.values(S.graph.nodes).map((nd) => nd.data && nd.data.assetId).filter(Boolean));
9919
+ const fixes = repairPlan(nodes, recs, usedIds);
9920
+ try { console.info('[IC] asset-relink: orphans=' + nodes.length + ' recs=' + recs.length + ' fixes=' + fixes.length); } catch { /* 忽略 */ }
9921
+ if (!fixes.length) return;
9922
+ update((s) => {
9923
+ for (const f of fixes) {
9924
+ const nd = s.graph.nodes[f.id];
9925
+ if (nd && nd.data && !nd.data.assetId) nd.data.assetId = f.assetId;
9926
+ }
9927
+ s.assetsTick++;
9928
+ });
9929
+ flushSave();
9930
+ toast(T('assetsRelinked').replace('{n}', String(fixes.length)));
9931
+ }
9510
9932
  function duplicateSelection() {
9511
9933
  const clones = [];
9512
9934
  update((s) => {
@@ -9769,6 +10191,14 @@ function queueThumb(assetId) {
9769
10191
  ? '标注「台词」的对白必须由**画面内可见的角色当场开口说出**(口型与台词同步、语气贴合情绪、面部朝镜头可见);严禁处理成画外音/旁白;同步音频开启时按台词生成人声。'
9770
10192
  : 'Dialogue must be SPOKEN ON SCREEN by the visible character (lip-synced to the line, matching emotion, face toward camera); never render it as voice-over/narration; generate speech when synced audio is on.');
9771
10193
  }
10194
+ // 状态跳变段(奇幻特效叙事):镜头之间是"状态硬切"——后一镜的主体/特效在第 1 帧已完整在场。
10195
+ // 负向词里的"凭空出现"对这类段不适用,替换为更精确的禁令(见下方 negation 组装)。
10196
+ const hasStateJump = shots.some((s) => String(s.seg || '').trim().toLowerCase() === 'state_jump');
10197
+ if (hasStateJump) {
10198
+ lines.push(zh
10199
+ ? '本段含同机位状态跳变镜:跳变靠**硬切**呈现——跳变镜的主体/特效在第 1 帧就已完整在场(静止),前后镜之间不演出任何进入/飞入/移动/凝聚的中间过程;运动可以由特效承担,人物/生物本体允许全程静止。'
10200
+ : 'This segment contains same-framing state-jump shots: the jump is a HARD CUT - in a jump shot the subject/effect is already fully present and STATIC in frame 1; no entrance/fly-in/movement/condensation is ever animated in between; motion may be carried by the effect while the character/creature body stays still.');
10201
+ }
9772
10202
  shots.forEach((s, i) => {
9773
10203
  const dur = durOf(s);
9774
10204
  const parts = [];
@@ -9782,7 +10212,7 @@ function queueThumb(assetId) {
9782
10212
  const cam = String(s.camera || '').trim();
9783
10213
  if (cam) parts.push((zh ? '机位/焦段/运镜' : 'Camera/lens/move') + ':' + cam);
9784
10214
  const vfx = String(s.vfx || '').trim();
9785
- if (vfx) parts.push((zh ? '物理特效(必须可见)' : 'Physical VFX (must be visible)') + ':' + vfx);
10215
+ if (vfx) parts.push((zh ? '特效(必须可见)' : 'VFX (must be visible)') + ':' + vfx);
9786
10216
  const dls = (s.dialogue || []).map((d) => String(d && d.role || '').trim() + ':' + String(d && d.line || '').trim()).filter((x) => x.replace(':', '').trim());
9787
10217
  if (dls.length) {
9788
10218
  parts.push(zh
@@ -9792,14 +10222,21 @@ function queueThumb(assetId) {
9792
10222
  if (String(s.sfx || '').trim()) parts.push((zh ? '音效:' : 'SFX: ') + String(s.sfx).trim());
9793
10223
  lines.push((zh ? `镜头${i + 1}(${dur}s):` : `Shot ${i + 1} (${dur}s): `) + parts.join(zh ? ';' : '; '));
9794
10224
  });
9795
- // 段级负向要求:模型默认会漂移、穿模、闪烁,不点名就一定会出现
10225
+ // 段级负向要求:模型默认会漂移、穿模、闪烁,不点名就一定会出现。
10226
+ // 含状态跳变镜的段:「凭空出现」恰好是这类段要的效果,替换为更精确的禁令。
9796
10227
  const negAll = shots.map((s) => String(s.negative || '').trim()).filter(Boolean);
9797
10228
  const negLine = negAll.length
9798
10229
  ? [...new Set(negAll.join('、').split(/[、,,;;]/).map((x) => x.trim()).filter(Boolean))].join('、')
9799
10230
  : '';
9800
- lines.push(zh
9801
- ? '禁止:换脸、五官漂移、服装变化、手部畸形、多指、穿模、画面闪烁、风格突变、动作僵硬、人物凭空出现或消失、口型与台词不同步' + (negLine ? '、' + negLine : '') + '。'
9802
- : 'Never: face swap, facial drift, wardrobe change, deformed hands, extra fingers, clipping, flicker, style jump, stiff motion, characters popping in or out, lip-sync mismatch' + (negLine ? ', ' + negLine : '') + '.');
10231
+ if (hasStateJump) {
10232
+ lines.push(zh
10233
+ ? '禁止:换脸、五官漂移、服装变化、手部畸形、多指、穿模、画面闪烁、风格突变、动作僵硬、口型与台词不同步、主体未在首帧完整在场、主体缓慢走入或移入画面、跳变过程被演成动画' + (negLine ? '、' + negLine : '') + '。'
10234
+ : 'Never: face swap, facial drift, wardrobe change, deformed hands, extra fingers, clipping, flicker, style jump, stiff motion, lip-sync mismatch, subject not fully present in frame 1, subject walking or drifting slowly into frame, the jump animated as a morph' + (negLine ? ', ' + negLine : '') + '.');
10235
+ } else {
10236
+ lines.push(zh
10237
+ ? '禁止:换脸、五官漂移、服装变化、手部畸形、多指、穿模、画面闪烁、风格突变、动作僵硬、人物凭空出现或消失、口型与台词不同步' + (negLine ? '、' + negLine : '') + '。'
10238
+ : 'Never: face swap, facial drift, wardrobe change, deformed hands, extra fingers, clipping, flicker, style jump, stiff motion, characters popping in or out, lip-sync mismatch' + (negLine ? ', ' + negLine : '') + '.');
10239
+ }
9803
10240
  return lines.join('\n');
9804
10241
  }
9805
10242
  function resolvePrompt(n) {
@@ -10000,11 +10437,11 @@ function queueThumb(assetId) {
10000
10437
  // 先自动补录缺失条目(空描述),再算一致性告警:否则告警标志的条目其实马上就被自动补录了,"未登记"语义会误导用户与对话侧
10001
10438
  try { await autoRegisterBibleEntries(shots); } catch { /* 补录失败不影响分镜 */ }
10002
10439
  const warnings = await checkShotConsistency(shots);
10003
- // 容量告警:镜头数硬上限 100(与生成端解析/UI 自定义输入一致)。剧本过长说明应该按场景
10004
- // 拆分成多个场景剧本节点,而不是让一个分镜表硬吃全集。时长本身不设上限,不做压缩。
10005
- const stLen = st.length;
10006
- if (stLen > 600) {
10007
- warnings.push(T('warnScriptTooLong').replace('{n}', String(stLen)));
10440
+ // 容量告警:按**实际生成的镜头数**判断(MAX_STORYBOARD_SHOTS,与生成端解析/UI 自定义输入一致)。
10441
+ // 字数与镜头数没有换算关系——914 字的单场剧本正常产出 9~15 镜;旧口径按剧本字数(>600 字)
10442
+ // 判容量,特效分镜镜头写得更详细后每场都超,是纯误报,已废弃。时长本身不设上限,不做压缩。
10443
+ if (shots.length > MAX_STORYBOARD_SHOTS) {
10444
+ warnings.push(T('warnShotsOverCapacity').replace('{n}', String(shots.length)));
10008
10445
  }
10009
10446
  update((s) => {
10010
10447
  const nd = s.graph.nodes[n.id];
@@ -10159,7 +10596,14 @@ function queueThumb(assetId) {
10159
10596
  const cases = [];
10160
10597
  for (let i = 0; i < want; i++) {
10161
10598
  if (want > 1) update((s) => { const nd = s.graph.nodes[n.id]; if (nd) nd.data.progress = (i + 1) + '/' + want; });
10162
- const blob = await apiImage(p, metas, mcfg, { size: n.data.size, ratio: n.data.ratio, nodeExtra: n.data.imgExtra, warn: addWarn });
10599
+ const blob = await apiImage(p, metas, mcfg, {
10600
+ size: n.data.size, ratio: n.data.ratio, nodeExtra: n.data.imgExtra, warn: addWarn,
10601
+ // 任务式厂商(三宝图片):任务 id 就是凭证——代理超时/页面关闭后仍可凭 id 回查(与视频同口径)
10602
+ onTask: (tid, qurl) => {
10603
+ update((s) => { const nd = s.graph.nodes[n.id]; if (nd) { nd.data.taskId = String(tid || ''); nd.data.taskQueryUrl = String(qurl || ''); } });
10604
+ flushSave();
10605
+ },
10606
+ });
10163
10607
  const rec = await saveAssetRecord(S.activeId, 'image', blob, {
10164
10608
  name: assetNameFor(n, entities, 'image'),
10165
10609
  prompt: stripMentionMarks(prompt), effectivePrompt: p,
@@ -10267,7 +10711,16 @@ function queueThumb(assetId) {
10267
10711
  } else if (plan.seg === 'scene_change') {
10268
10712
  bits.push(zh ? '本段换场:不承接上一段画面,但环境声/情绪可延续' : 'Scene change: do not continue the previous frame; ambience and mood may carry over');
10269
10713
  } else if (plan.seg === 'new_character') {
10270
- bits.push(zh ? '本段有新角色入场:新角色必须从画面内自然进入(走入/被带入),不得凭空出现' : 'A new character enters: they must enter naturally from within the frame, never pop in');
10714
+ // 特效入场(灯闪现身/影子凝聚/影化实)合法:首镜 vfx/start 写明特效进入时不逼"走入"
10715
+ const fxEntry = /凝聚|凭空|灯闪|黑场|影子|化实|现身|浮现/.test(
10716
+ String(st.vfx || '') + String(st.start || '') + String(st.visual || '') + String(st.motion || ''));
10717
+ bits.push(zh
10718
+ ? (fxEntry
10719
+ ? '本段有新角色入场(特效进入):灯闪/黑场后已在场、从影子凝聚立起、浮现成形——不得缓慢走入'
10720
+ : '本段有新角色入场:新角色必须从画面内自然进入(走入/被带入),不得凭空出现')
10721
+ : (fxEntry
10722
+ ? 'A new character enters via an effect: already there after a flash/black frame, rises from a shadow, condenses into form - never walks in slowly'
10723
+ : 'A new character enters: they must enter naturally from within the frame, never pop in'));
10271
10724
  }
10272
10725
  return bits.join(zh ? ';' : '; ');
10273
10726
  })();
@@ -10354,33 +10807,38 @@ function queueThumb(assetId) {
10354
10807
  } catch { /* 探测失败不影响生成 */ }
10355
10808
  // 尾帧抽取(续帧接力的关键):末段多帧候选里选「动作进行中/清晰/不抖」的一帧,
10356
10809
  // 而不是机械取最后一帧(最后一帧常在动作顶点/模糊/抖动上)。
10810
+ // 【单一所有者】入库前先写 tailPending 占位(封锁媒体节点体的兜底提取 effect):
10811
+ // 两条管线曾各自入库,一次生成冒出两张相同尾帧 + 一张最佳帧 = 三张尾帧资产。
10357
10812
  try {
10813
+ update((s) => { const nd = s.graph.nodes[n.id]; if (nd) nd.data.tailPending = rec.id; });
10358
10814
  const tail = await extractTailFrames(blob, { count: 9, span: 0.8 });
10359
- if (tail && tail.last) {
10360
- const fRec = await saveAssetRecord(S.activeId, 'image', tail.last, {
10361
- name: T('lastFrame') + '-' + (n.data.label || n.id.slice(-4)),
10362
- prompt: 'last frame of ' + prompt.slice(0, 60), source: 'api', category: 'image',
10815
+ const dec = tailFrameDecision(tail);
10816
+ if (dec && dec.blob) {
10817
+ const recT = await saveAssetRecord(S.activeId, 'image', dec.blob, {
10818
+ name: (dec.isPick ? T('tailPick') : T('lastFrame')) + '-' + (n.data.label || n.id.slice(-4)),
10819
+ prompt: (dec.isPick ? 'continuity tail pick t=' + Number(dec.t).toFixed(2) + 's; ' : 'last frame of ') + prompt.slice(0, 60),
10820
+ source: 'api', category: 'image',
10363
10821
  });
10364
- // 最佳选帧单独存一份(last 口保持"真·最后一帧"语义,接力用"最佳帧")
10365
- let pickRec = null;
10366
- if (tail.best && tail.best !== tail.last) {
10367
- pickRec = await saveAssetRecord(S.activeId, 'image', tail.best, {
10368
- name: T('tailPick') + '-' + (n.data.label || n.id.slice(-4)),
10369
- prompt: 'continuity tail pick t=' + Number(tail.bestT || 0).toFixed(2) + 's; ' + prompt.slice(0, 40),
10370
- source: 'api', category: 'image',
10371
- });
10372
- }
10373
10822
  update((s) => {
10374
10823
  const nd = s.graph.nodes[n.id];
10375
10824
  if (nd) {
10376
- nd.data.lastAssetId = fRec.id; nd.data.lastAssetVideo = rec.id;
10377
- nd.data.lastPickAssetId = pickRec ? pickRec.id : fRec.id;
10378
- nd.data.tailPickMeta = { t: Number(tail.bestT || 0), score: Math.round((tail.bestScore || 0) * 100) / 100 };
10825
+ // 一张尾帧服务两个口:last / tailpick 指向同一资产(自动续帧与手动连线都优先 tailpick)
10826
+ nd.data.lastAssetId = recT.id;
10827
+ nd.data.lastPickAssetId = recT.id;
10828
+ nd.data.lastAssetVideo = rec.id;
10829
+ nd.data.tailPickMeta = { t: Number(dec.t) || 0, score: Math.round((Number(dec.score) || 0) * 100) / 100 };
10830
+ nd.data.tailPending = null;
10379
10831
  }
10380
10832
  s.assetsTick++;
10381
10833
  });
10382
10834
  }
10383
- } catch { /* 尾帧提取失败不影响主流程 */ }
10835
+ } catch {
10836
+ // 抽帧/入库失败:解锁占位,让媒体节点体的兜底提取可以重试(外部导入视频仍走兜底)
10837
+ update((s) => {
10838
+ const nd = s.graph.nodes[n.id];
10839
+ if (nd && nd.data.tailPending === rec.id && nd.data.lastAssetVideo !== rec.id) nd.data.tailPending = null;
10840
+ });
10841
+ }
10384
10842
  // 接缝校验:本段首帧 vs 上一段尾帧(续帧段才有意义)。不达标 → 节点上可见告警(不静默)
10385
10843
  if (useFrame && plan.chain) {
10386
10844
  try {
@@ -12423,10 +12881,13 @@ function queueThumb(assetId) {
12423
12881
  * 空节点不放任何生成按钮(生成动作在 GenComposer 的发送按钮)。点击节点任意位置打开面板。 */
12424
12882
  function MediaNodeBodyInner({ n, kind, refSig }) {
12425
12883
  void refSig;
12426
- // 视频产物自动提取尾帧(含外部注入/导入的视频):last 口与跨镜衔接不依赖"必须由本节点生成"
12884
+ // 视频产物自动提取尾帧(含外部注入/导入的视频):last 口与跨镜衔接不依赖"必须由本节点生成"。
12885
+ // 【守卫】lastAssetVideo 匹配 = 本节点已登记这条视频(生成管线独占负责,见 tailPending 占位);
12886
+ // tailPending 匹配 = 生成管线正在抽帧入库——两者都跳过,绝不与生成路径重复入库。
12427
12887
  useEffect(() => {
12428
12888
  if (kind !== 'video' || !n.data.assetId) return;
12429
- if (n.data.lastAssetId && n.data.lastAssetVideo === n.data.assetId) return;
12889
+ if (n.data.lastAssetVideo === n.data.assetId) return;
12890
+ if (n.data.tailPending === n.data.assetId) return;
12430
12891
  let cancelled = false;
12431
12892
  (async () => {
12432
12893
  try {
@@ -12448,14 +12909,18 @@ function queueThumb(assetId) {
12448
12909
  return () => { cancelled = true; };
12449
12910
  }, [kind, n.data.assetId, n.data.label, S.assetsTick]);
12450
12911
  // 历史条自愈:已被删除的资产(渲染成 … 的幽灵格)自动从节点 history 剔除;
12451
- // 服务端不可达时跳过本轮(宁可不修剪,绝不误删有效历史)
12912
+ // 【卫语句】store 未就绪绝不清理——sqlite 资产不在 IDB,误走 IDB 分支会把活资产
12913
+ // 全部判死并置空 assetId(刷新竞态曾造成生成节点预览全部丢失,见 0.19.18 修复记录)。
12914
+ // 【契约】清理只裁 history,绝不回写 data.assetId——当前资产指针是用户数据,
12915
+ // 资产真被删时展示层已有缺失态兜底,节点仍可重生成/重连。
12452
12916
  useEffect(() => {
12453
12917
  const histList = n.data.history || [];
12454
12918
  if (!histList.length) return;
12919
+ if (!S.store) return;
12455
12920
  let ok = true;
12456
12921
  (async () => {
12457
12922
  let alive = null;
12458
- if (S.store) {
12923
+ if (S.store === 'sqlite') {
12459
12924
  const r = await hostRpc('assetsGet', { ids: histList.map((x) => x.assetId) }).catch(() => null);
12460
12925
  if (!r) return;
12461
12926
  alive = new Set((r.items || []).map((x) => x.id));
@@ -12464,15 +12929,12 @@ function queueThumb(assetId) {
12464
12929
  alive = new Set(histList.filter((_, i) => recs[i]).map((x) => x.assetId));
12465
12930
  }
12466
12931
  if (!ok) return;
12467
- const dead = histList.filter((x) => !alive.has(x.assetId)).map((x) => x.assetId);
12468
- if (!dead.length) return;
12932
+ const next = pruneDeadHistory(n.data.history, alive);
12933
+ if (next === n.data.history) return;
12469
12934
  update((s) => {
12470
12935
  const nd = s.graph.nodes[n.id];
12471
12936
  if (!nd || !Array.isArray(nd.data.history)) return;
12472
- const next = nd.data.history.filter((x) => !dead.includes(x.assetId));
12473
- if (next.length === nd.data.history.length) return;
12474
12937
  nd.data.history = next;
12475
- if (nd.data.assetId && dead.includes(nd.data.assetId)) nd.data.assetId = next.length ? next[next.length - 1].assetId : null;
12476
12938
  });
12477
12939
  })();
12478
12940
  return () => { ok = false; };
@@ -14201,6 +14663,29 @@ function queueThumb(assetId) {
14201
14663
  return PACK_MANIFEST;
14202
14664
  }
14203
14665
 
14666
+ /** 项目是否开启「特效演绎」(fx_motion):任一所选题材/影调卡的 frontmatter 带 fx_motion: true。
14667
+ * 开启后分镜契约追加特效演绎扩展块(动作承担者中立 / 画面状态节拍 / 奇幻特效词表 / state_jump /
14668
+ * 速度铁律 / 关键帧建议)。未配置技能包或卡未标记 → false(写实项目行为完全不变)。 */
14669
+ async function fxMotionEnabledFor(pid) {
14670
+ const id = pid || S.activeId;
14671
+ if (!id) return false;
14672
+ const manifest = await loadPackManifest();
14673
+ if (!manifest) return false;
14674
+ const profile = loadSkillProfile(id);
14675
+ const picks = [];
14676
+ if (profile.lens) picks.push(['lens', profile.lens, 'lenses']);
14677
+ for (const g of (profile.genres || [])) picks.push(['genre', g, 'genres']);
14678
+ if (profile.form) picks.push(['form', profile.form, 'forms']);
14679
+ if (profile.look) picks.push(['look', profile.look, 'looks']);
14680
+ for (const [layer, cardId, listKey] of picks) {
14681
+ const entry = (manifest[listKey] || []).find((x) => x.id === cardId);
14682
+ if (!entry) continue;
14683
+ const md = await readPackCard(layer, entry.file);
14684
+ if (md && /(^|\n)\s*fx_motion:\s*true\s*(\n|$)/.test(md)) return true;
14685
+ }
14686
+ return false;
14687
+ }
14688
+
14204
14689
  /** 按层+id 读一张卡的 markdown(缓存)。 */
14205
14690
  async function readPackCard(layer, file) {
14206
14691
  const key = layer + '/' + file;
@@ -14555,6 +15040,10 @@ function queueThumb(assetId) {
14555
15040
  if (md) addNegs(P.negativePhrases(md));
14556
15041
  }
14557
15042
  if (negs.length) push('必须排除:', negs.slice(0, 6).join(', '));
15043
+ // 特效演绎项目(fx_motion 卡):注入速度铁律——与分镜契约同口径,锁住"模型演快必变慢走"的失败形态
15044
+ if (await fxMotionEnabledFor(pid)) {
15045
+ push('速度与特效:', '瞬时事件(一闪/瞬移/现身)=切点两侧的状态差;速度感只来自硬切、静止主体+光效突变、甩镜;禁止镜内高速位移。');
15046
+ }
14558
15047
 
14559
15048
  if (!parts.length) return '';
14560
15049
  const head = '[全片风格锚] 以下为全片级总控;逐镜画面与动作以正文为准:';
@@ -17760,6 +18249,16 @@ const DIRECTOR_KEY_HELP = [
17760
18249
  * 搜索/分类/项目筛选与分页都在客户端做;卡片 = AssetCard(缩略图或视频首帧 + 名称 + 分类 + 时间,
17761
18250
  * 预览/下载/添加到画布 全部保留)。右侧面板不再有资产页签。 */
17762
18251
  const ASSET_PAGE_SIZE = 24;
18252
+ /** 资产分页跳转(纯函数):页码输入 → 0-based 页。
18253
+ * 非数字/空/小数 → null(保持当前页);越界夹取到 1..pageCount。 */
18254
+ function assetsPageIndex(raw, pageCount) {
18255
+ const t = String(raw == null ? '' : raw).trim();
18256
+ if (!/^\d+$/.test(t)) return null;
18257
+ const n = parseInt(t, 10);
18258
+ if (!Number.isFinite(n)) return null;
18259
+ const pc = Math.max(1, Number(pageCount) || 1);
18260
+ return Math.min(Math.max(1, n), pc) - 1;
18261
+ }
17763
18262
  function AssetsTab({ variant } = {}) {
17764
18263
  void variant;
17765
18264
  const [assets, setAssets] = useState([]);
@@ -17778,13 +18277,16 @@ const DIRECTOR_KEY_HELP = [
17778
18277
  const [craftFor, setCraftFor] = useState(null);
17779
18278
  const [delTarget, setDelTarget] = useState(null); // 待确认删除的资产(确认框见 DeleteAssetModal)
17780
18279
  const [assetName, setAssetName] = useState(''); // 删除确认框的输入内容
18280
+ const [selIds, setSelIds] = useState(() => new Set()); // 批量选择(资产 id):选中后一键按列导入画布 / 批量删除
18281
+ const [batchDel, setBatchDel] = useState(false); // 批量删除确认框
18282
+ const [pageDraft, setPageDraft] = useState(null); // 页码输入草稿(null = 显示当前页)
17781
18283
  const fileRef = useRef(null);
17782
18284
  // 搜索防抖:资产多时避免每个按键都过一遍全量过滤
17783
18285
  useEffect(() => {
17784
18286
  const t = setTimeout(() => setQDeb(search), 300);
17785
18287
  return () => clearTimeout(t);
17786
18288
  }, [search]);
17787
- useEffect(() => { setPage(0); }, [filter, qDeb, scope]);
18289
+ useEffect(() => { setPage(0); setPageDraft(null); }, [filter, qDeb, scope]);
17788
18290
  useEffect(() => {
17789
18291
  probeCraft();
17790
18292
  let ok = true;
@@ -17880,6 +18382,52 @@ const DIRECTOR_KEY_HELP = [
17880
18382
  });
17881
18383
  bumpView();
17882
18384
  };
18385
+ // ---------- 批量选择:一键按列导入画布 / 批量删除 ----------
18386
+ // 落点由 layoutBatchColumns 决定(现有节点最右侧之外按列铺开,一列 ≤5,零重叠),
18387
+ // 音频资产不成节点(与单个添加同一口径),导入时跳过并提示数量。
18388
+ const selList = assets.filter((a) => selIds.has(a.id));
18389
+ const addableList = selList.filter((a) => a.kind !== 'audio');
18390
+ const audioN = selList.length - addableList.length;
18391
+ const allPageSel = () => shown.length > 0 && shown.every((a) => selIds.has(a.id));
18392
+ const toggleSel = (a) => setSelIds((prev) => { const n = new Set(prev); if (n.has(a.id)) n.delete(a.id); else n.add(a.id); return n; });
18393
+ const selectAllPage = () => setSelIds((prev) => {
18394
+ const n = new Set(prev);
18395
+ if (allPageSel()) shown.forEach((a) => n.delete(a.id));
18396
+ else shown.forEach((a) => n.add(a.id));
18397
+ return n;
18398
+ });
18399
+ const clearSel = () => setSelIds(new Set());
18400
+ const addSelectedToCanvas = () => {
18401
+ if (!addableList.length) { toast(T('assetsOnlyAudio')); return; }
18402
+ // 检测画布现有节点位置:批量落点在其最右侧之外按列铺开,绝不与现有节点重叠
18403
+ const rects = Object.values(S.graph.nodes)
18404
+ .filter((nd) => nd.type !== 'group' && !(nd.data && nd.data.hidden))
18405
+ .map((nd) => ({ x: Number(nd.x) || 0, y: Number(nd.y) || 0, w: Number(nd.w) || 280, h: Number(nd.h) || 160 }));
18406
+ const items = addableList.map((a) => (a.kind === 'text' ? { w: 360, h: 220 } : nodeSizeForRatio('16:9', { hasFooter: false })));
18407
+ const pts = layoutBatchColumns(rects, items);
18408
+ const newIds = [];
18409
+ update((s) => {
18410
+ addableList.forEach((a, k) => {
18411
+ const nd = newNode(a.kind === 'text' ? 'text' : a.kind, pts[k]);
18412
+ if (a.kind === 'text') nd.data.text = a.text || '';
18413
+ else { nd.data.assetId = a.id; nd.data.status = 'done'; }
18414
+ s.graph.nodes[nd.id] = nd;
18415
+ newIds.push(nd.id);
18416
+ });
18417
+ s.sel = new Set(newIds); s.selEdge = null;
18418
+ });
18419
+ pushHistory();
18420
+ flushSave();
18421
+ setSelIds(new Set());
18422
+ toast(T('assetsAdded').replace('{n}', String(addable.length)) + (audioN ? ',' + T('assetsAudioSkip').replace('{n}', String(audioN)) : ''));
18423
+ };
18424
+ const delSelected = async () => {
18425
+ const list = selList.slice();
18426
+ setBatchDel(false);
18427
+ for (const a of list) { try { await del(a); } catch { /* 单个失败继续其余 */ } }
18428
+ setSelIds(new Set());
18429
+ toast(T('assetsDeletedN').replace('{n}', String(list.length)));
18430
+ };
17883
18431
  // 资产重命名:服务端写回(SQL/JSON 各自落库)+ 刷新名称缓存(@引用与连线名称都吃这份缓存)
17884
18432
  const rename = async (a, name) => {
17885
18433
  if (S.store) {
@@ -17922,6 +18470,19 @@ const DIRECTOR_KEY_HELP = [
17922
18470
  const pageCount = Math.max(1, Math.ceil(filtered.length / ASSET_PAGE_SIZE));
17923
18471
  const pageSafe = Math.min(Math.max(0, page), pageCount - 1);
17924
18472
  const shown = filtered.slice(pageSafe * ASSET_PAGE_SIZE, pageSafe * ASSET_PAGE_SIZE + ASSET_PAGE_SIZE);
18473
+ /** 提交页码输入:回车/失焦;非法文本保持当前页,越界夹取(UI-RULES 第 15 条口径)。 */
18474
+ const commitPageJump = () => {
18475
+ const idx = assetsPageIndex(pageDraft, pageCount);
18476
+ if (idx != null) setPage(idx);
18477
+ setPageDraft(null);
18478
+ };
18479
+ /** 翻页:输入框有草稿时先以草稿为基准(避免 blur 提交与按钮翻页互相覆盖)。 */
18480
+ const goPage = (delta) => {
18481
+ const idx = pageDraft != null ? assetsPageIndex(pageDraft, pageCount) : null;
18482
+ const base = idx != null ? idx : pageSafe;
18483
+ setPage(Math.min(Math.max(0, base + delta), pageCount - 1));
18484
+ setPageDraft(null);
18485
+ };
17925
18486
  return [
17926
18487
  h('div', { key: 'chips', className: 'dshic-chips' },
17927
18488
  [{ id: 'all', label: T('catAll') }].concat(CATEGORIES.map((c) => ({ id: c, label: catLabel(c) }))).map((c) =>
@@ -17943,8 +18504,61 @@ const DIRECTOR_KEY_HELP = [
17943
18504
  .concat(S.projects.map((p) => ({ value: p.id, label: p.name }))),
17944
18505
  onChange: (v) => setScope(v),
17945
18506
  }),
17946
- h('button', { key: 'craftsync', type: 'button', className: 'dshic-mini', style: { alignSelf: 'flex-start' }, disabled: !craftOkCached(), title: craftOkCached() ? T('craftSyncAll') : T('craftUnreachable'), onClick: syncAll, onPointerDown: (e) => e.stopPropagation() }, Ic('upload', 11), T('craftSyncAll')),
17947
- h('button', { key: 'imp', type: 'button', className: 'dshic-mini', style: { alignSelf: 'flex-start' }, onClick: () => { if (fileRef.current) fileRef.current.click(); } }, Ic('upload', 11), T('import')),
18507
+ // 工具栏(项目下一行):所有操作按钮 + 分页集中在一行,窄窗口自动换行、分页始终靠右。
18508
+ // 按钮统一「透明底 + 1px 线框 + 文字」(UI-RULES:禁止灰底色块)。
18509
+ h('div', { key: 'toolbar', className: 'dshic-asset-toolbar', 'data-role': 'assets-toolbar' },
18510
+ h('div', { className: 'dshic-asset-toolbar-main' },
18511
+ h('button', {
18512
+ type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-sync-all',
18513
+ disabled: !craftOkCached(), title: craftOkCached() ? T('craftSyncAll') : T('craftUnreachable'),
18514
+ onClick: syncAll, onPointerDown: (e) => e.stopPropagation(),
18515
+ }, Ic('upload', 11), T('craftSyncAll')),
18516
+ h('button', {
18517
+ type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-import',
18518
+ onClick: () => { if (fileRef.current) fileRef.current.click(); },
18519
+ }, Ic('upload', 11), T('import')),
18520
+ h('label', { className: 'dshic-asset-selall', onPointerDown: (e) => e.stopPropagation() },
18521
+ h('input', { type: 'checkbox', checked: allPageSel(), disabled: !shown.length, onChange: selectAllPage }),
18522
+ T('assetsSelAllPage')),
18523
+ // 批量操作:选中 >0 时出现,与导入同一行(不另占一行)
18524
+ selIds.size
18525
+ ? h('div', { key: 'batchbar', className: 'dshic-asset-batch', 'data-role': 'assets-batch-bar' },
18526
+ h('button', { type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-add-selected', disabled: !addableList.length, onClick: addSelectedToCanvas, onPointerDown: (e) => e.stopPropagation() }, Ic('expandAll', 11), T('assetsAddToCanvas') + '(' + addableList.length + ')'),
18527
+ h('button', { type: 'button', className: 'dshic-toolbtn is-danger', 'data-action': 'assets-batch-delete', onClick: () => setBatchDel(true), onPointerDown: (e) => e.stopPropagation() }, T('doDelete') + '(' + selIds.size + ')'),
18528
+ h('button', { type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-clear-sel', onClick: clearSel, onPointerDown: (e) => e.stopPropagation() }, T('assetsClearSel')),
18529
+ audioN ? h('span', { className: 'dshic-asset-audiohint' }, T('assetsAudioSkip').replace('{n}', String(audioN))) : null,
18530
+ )
18531
+ : null,
18532
+ ),
18533
+ // 分页(客户端分页):‹ [页码输入] / N › + 总数;Enter/失焦跳转,Esc 取消,越界夹取
18534
+ h('div', { key: 'pager', className: 'dshic-asset-pager', 'data-role': 'assets-pager' },
18535
+ h('button', {
18536
+ type: 'button', className: 'dshic-toolbtn is-icon', 'data-action': 'assets-page-prev', title: T('pagePrev'),
18537
+ disabled: pageSafe <= 0, onClick: () => goPage(-1), onPointerDown: (e) => e.stopPropagation(),
18538
+ }, '‹'),
18539
+ h('div', { className: 'dshic-asset-pagebox' },
18540
+ h('input', {
18541
+ className: 'dshic-asset-pageinput', type: 'text', inputMode: 'numeric',
18542
+ 'data-role': 'assets-page-input', 'aria-label': T('pageNumber'),
18543
+ value: pageDraft != null ? pageDraft : String(pageSafe + 1),
18544
+ onPointerDown: (e) => e.stopPropagation(),
18545
+ onClick: (e) => e.stopPropagation(),
18546
+ onChange: (e) => setPageDraft(e.target.value),
18547
+ onBlur: commitPageJump,
18548
+ onKeyDown: (e) => {
18549
+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); commitPageJump(); }
18550
+ else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setPageDraft(null); }
18551
+ },
18552
+ }),
18553
+ h('span', { className: 'dshic-asset-pagetotal', 'data-role': 'assets-page-total' }, '/ ' + pageCount),
18554
+ ),
18555
+ h('button', {
18556
+ type: 'button', className: 'dshic-toolbtn is-icon', 'data-action': 'assets-page-next', title: T('pageNext'),
18557
+ disabled: pageSafe >= pageCount - 1, onClick: () => goPage(1), onPointerDown: (e) => e.stopPropagation(),
18558
+ }, '›'),
18559
+ h('span', { className: 'dshic-asset-pagecount', 'data-role': 'assets-page-info' }, T('assetsTotalCount').replace('{n}', String(filtered.length))),
18560
+ ),
18561
+ ),
17948
18562
  h('input', { key: 'file', ref: fileRef, type: 'file', accept: 'image/*,video/*', multiple: true, style: { display: 'none' }, onChange: onImport }),
17949
18563
  loading && !assets.length
17950
18564
  ? h('div', { key: 'loading', className: 'dshic-hint' }, T('aiRunning'))
@@ -17955,25 +18569,25 @@ const DIRECTOR_KEY_HELP = [
17955
18569
  key: a.id, a, onAdd: addNodeFor, onDel: (x) => setDelTarget(x), onCat: changeCategory,
17956
18570
  onRename: rename, onMove: moveAsset,
17957
18571
  projectName: projectName(a.projectId),
18572
+ checked: selIds.has(a.id), onToggleSel: toggleSel,
17958
18573
  })),
17959
18574
  ),
17960
- // 分页(客户端分页:资产数据源已是全量 assetsForPicker)
17961
- h('div', { key: 'pager', className: 'dshic-asset-pager' },
17962
- h('button', {
17963
- type: 'button', className: 'dshic-mini is-ghost', 'data-action': 'assets-page-prev',
17964
- disabled: pageSafe <= 0, onClick: () => setPage(pageSafe - 1), onPointerDown: (e) => e.stopPropagation(),
17965
- }, '‹ ' + T('pagePrev')),
17966
- h('span', { 'data-role': 'assets-page-info' }, (pageSafe + 1) + ' / ' + pageCount + ' · ' + filtered.length + ' / ' + assets.length),
17967
- h('button', {
17968
- type: 'button', className: 'dshic-mini is-ghost', 'data-action': 'assets-page-next',
17969
- disabled: pageSafe >= pageCount - 1, onClick: () => setPage(pageSafe + 1), onPointerDown: (e) => e.stopPropagation(),
17970
- }, T('pageNext') + ' ›'),
17971
- ),
17972
18575
  delTarget ? h(DeleteAssetModal, {
17973
18576
  key: 'delasset', target: delTarget, name: assetName, setName: setAssetName,
17974
18577
  onCancel: () => { setDelTarget(null); setAssetName(''); },
17975
18578
  onConfirm: async () => { const t = delTarget; setDelTarget(null); setAssetName(''); await del(t); },
17976
18579
  }) : null,
18580
+ batchDel ? h('div', { className: 'dshic-modal-overlay', onPointerDown: (e) => { if (e.target === e.currentTarget) setBatchDel(false); } },
18581
+ h('div', { className: 'dshic-modal' },
18582
+ h('div', { className: 'dshic-modal-title' }, T('delAssetTitle') + ' × ' + selIds.size),
18583
+ h('div', { className: 'dshic-modal-warn' },
18584
+ T('assetsBatchDelWarn'),
18585
+ h('div', { className: 'dshic-modal-name', style: { marginTop: 4 } },
18586
+ selList.slice(0, 3).map((a) => a.name || '—').join('、') + (selList.length > 3 ? ' …' : ''))),
18587
+ h('div', { className: 'dshic-modal-actions' },
18588
+ h('button', { type: 'button', className: 'dshic-btn dshic-btn-outline', onClick: () => setBatchDel(false) }, T('cancel')),
18589
+ h('button', { type: 'button', className: 'dshic-btn is-danger', onClick: delSelected }, T('doDelete'))),
18590
+ )) : null,
17977
18591
  ];
17978
18592
  }
17979
18593
  /** 删除资产确认框:与项目删除同一套交互 —— 名字可选中,手打确认,不做一键填入。 */
@@ -18009,7 +18623,7 @@ const DIRECTOR_KEY_HELP = [
18009
18623
  ));
18010
18624
  }
18011
18625
 
18012
- function AssetCard({ a, onAdd, onDel, onCat, onRename, onMove, projectName }) {
18626
+ function AssetCard({ a, checked = false, onToggleSel = () => {}, onAdd, onDel, onCat, onRename, onMove, projectName }) {
18013
18627
  const url = useAssetUrl(a.kind === 'text' ? null : a.id);
18014
18628
  const [craftFor, setCraftFor] = useState(false);
18015
18629
  const [renaming, setRenaming] = useState(false);
@@ -18034,7 +18648,17 @@ const DIRECTOR_KEY_HELP = [
18034
18648
  onClick: startRename,
18035
18649
  }, Ic('pencil', 11));
18036
18650
  const downloadName = (a.name || 'asset') + extForDownload(a.mime, a.name, a.kind);
18037
- return h('div', { className: 'dshic-asset', onClick: a.kind === 'audio' ? undefined : () => onAdd(a), title: a.kind === 'text' ? T('textAssetHint') : a.kind === 'audio' ? '' : T('addAssetNode') },
18651
+ return h('div', {
18652
+ className: cls('dshic-asset', checked && 'is-checked'),
18653
+ onClick: () => onToggleSel(a),
18654
+ onDoubleClick: a.kind === 'audio' ? undefined : () => onAdd(a), // 双击 = 单个直接添加(熟练用户捷径)
18655
+ title: T('assetClickHint'),
18656
+ },
18657
+ // 复选框:批量选择入口(单击卡片也切换选中;图标按钮仍 stopPropagation 不受影响)
18658
+ h('input', { type: 'checkbox', className: 'dshic-asset-check', checked: !!checked,
18659
+ onPointerDown: (e) => e.stopPropagation(),
18660
+ onClick: (e) => { e.stopPropagation(); onToggleSel(a); },
18661
+ onChange: () => {} }),
18038
18662
  a.kind === 'text'
18039
18663
  ? h('div', { className: 'dshic-textcard is-title' },
18040
18664
  renaming ? nameInput : h('div', { className: 'dshic-textcard-title', title: a.name || '' }, a.name || T('scriptAssetPrefix')),
@@ -18304,7 +18928,8 @@ const DIRECTOR_KEY_HELP = [
18304
18928
  h('select', { className: 'dshic-select', value: p.mode || 'generations', onChange: (e) => patchProvider(p.id, 'mode', e.target.value), onPointerDown: (e) => e.stopPropagation() },
18305
18929
  h('option', { value: 'generations' }, T('modeGenerations')),
18306
18930
  h('option', { value: 'edits' }, T('modeEdits')),
18307
- h('option', { value: 'compshare' }, T('modeCompshare')))),
18931
+ h('option', { value: 'compshare' }, T('modeCompshare')),
18932
+ h('option', { value: 'sanbao' }, T('modeSanbao')))),
18308
18933
  ] : [
18309
18934
  (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,
18310
18935
  (detectVideoVendor(p) === 'openai' || detectVideoVendor(p) === 'seedance') ? h('label', { key: 'ga', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
@@ -18438,7 +19063,8 @@ const DIRECTOR_KEY_HELP = [
18438
19063
  onPointerDown: (e) => e.stopPropagation(),
18439
19064
  },
18440
19065
  h('option', { value: 'generations' }, T('modeGenerations')),
18441
- h('option', { value: 'edits' }, T('modeEdits'))))
19066
+ h('option', { value: 'edits' }, T('modeEdits')),
19067
+ h('option', { value: 'sanbao' }, T('modeSanbao'))))
18442
19068
  : null,
18443
19069
  kind === 'video'
18444
19070
  ? h('div', { key: 'proto', className: 'dshic-field' },
@@ -19231,6 +19857,7 @@ const DIRECTOR_KEY_HELP = [
19231
19857
  'crime-police': ['M4 9l3-4h10l3 4v6l-3 4H7l-3-4z', 'M12 7l1.8 4.2L18 13l-4.2 1.8L12 19l-1.8-4.2L6 13l4.2-1.8z'],
19232
19858
  wuxia: ['M4 9l3-4h10l3 4v6l-3 4H7l-3-4z', 'M6 18L18 6M14 6h4v4'],
19233
19859
  fantasy: ['M4 9l3-4h10l3 4v6l-3 4H7l-3-4z', 'M12 7l2 4 4 1-3 3 1 4-4-2-4 2 1-4-3-3 4-1z'],
19860
+ 'shanhaijing-myth': ['M4 9l3-4h10l3 4v6l-3 4H7l-3-4z', 'M6 16c2-6 4-2 6-6s4 0 6-4M9 17h6'],
19234
19861
  adventure: ['M4 9l3-4h10l3 4v6l-3 4H7l-3-4z', 'M6 17l6-9 6 9M9 17h6'],
19235
19862
  'hk-retro': ['M4 9l3-4h10l3 4v6l-3 4H7l-3-4z', 'M8 8v8M16 8v8M8 12h8'],
19236
19863
  // ── L2 行业题材:六边形 + 标记 ──
@@ -20181,6 +20808,10 @@ const DIRECTOR_KEY_HELP = [
20181
20808
  fetchUpdateRegistry();
20182
20809
  // 数据根目录(Host 旧版静默降级为 IndexedDB 模式);就绪后把本地遗留 blob 搬进服务端(v1 旧布局由 Host 侧自动迁移)
20183
20810
  refreshDataRoot().then(() => migrateLegacyAssets('boot')).catch(() => { /* 静默 */ });
20811
+ // 资产指针自愈:显式调度,不依赖同步回调(普通启动没有文档变更信号,mergeHostDoc 不会触发)。
20812
+ // 2s 主跑 + 10s 兜底重试(图/资产清单加载慢时第二轮补上);scheduleRepair 自带 1.5s 防抖。
20813
+ setTimeout(() => scheduleRepair(), 2000);
20814
+ setTimeout(() => scheduleRepair(), 10000);
20184
20815
  // 对话 ↔ 画布同步(启动一次 + 3s 轮询;旧 Host 自动停轮询)
20185
20816
  hostSyncTick().then(() => pushAllProjectsToHost());
20186
20817
  const hostSyncTimer = setInterval(() => hostSyncTick(), 3000);
@@ -20337,6 +20968,16 @@ const DIRECTOR_KEY_HELP = [
20337
20968
  wheelScrollTarget,
20338
20969
  // 建点布局强控制(一类型一列 + 碰撞下移):addNodeAt 收口 + 纯函数,供回归测试直接驱动
20339
20970
  nextNodePosClient, addNodeAt,
20971
+ // 资产批量导入落点:现有节点最右侧之外按列铺开(一列 ≤5,零重叠),供回归测试直接断言
20972
+ layoutBatchColumns,
20973
+ // 资产页分页跳转(页码输入 → 0-based 页;非法文本 null、越界夹取)
20974
+ assetsPageIndex,
20975
+ // 尾帧入库决策(一次生成只入一张:best 优先,best=last 才用 last)
20976
+ tailFrameDecision,
20977
+ // 历史条死条目裁剪 / 资产回链候选挑选与回链计划(纯函数,供回归测试直接断言)
20978
+ pruneDeadHistory, repairPickAsset, repairPlan,
20979
+ // 媒体节点指针空值保护(Host 合并不得用 null 覆盖本地有效 assetId/lastAssetId)
20980
+ protectMediaPointer,
20340
20981
  graph: () => JSON.parse(JSON.stringify(S.graph)), // 建点结果断言用(与 SYNC.graph 同口径)
20341
20982
  addGraphNodes: (list) => { for (const n of (list || [])) S.graph.nodes[n.id] = n; }, // 测试播种(写入活状态)
20342
20983
  // 下拉自定义数值的纯函数:范围夹取 / 整数与小数口径(分镜数、单段上限共用)
@@ -20384,7 +21025,7 @@ const DIRECTOR_KEY_HELP = [
20384
21025
  // IC-04:参考图上传三件套的纯函数出口(供 scripts/test-image-upload.mjs 直接断言)
20385
21026
  window.__DSH_IC_IMGREF__ = { rawImageDims, sniffImageEncoding, registerReferenceAsset };
20386
21027
  // IC-03:视频厂商识别/前缀归一化的纯函数出口(供 scripts/test-vendor-detect.mjs 直接断言)
20387
- window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState, buildSanbaoVideoBody, sanbaoTaskIdOf, sanbaoPollState, needsSanbaoMediaRetry, bibleStyleAnchor };
21028
+ 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 };
20388
21029
  // 按镜头切段(分段生成本身就是最容易出错的地方):规划器 + 强弱模型分流 + 节点段区间解析
20389
21030
  // 供 scripts/test-segment-plan.mjs 直接断言
20390
21031
  window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };