@ninkch/dsh-infinite-canvas 0.19.16 → 0.19.18

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
@@ -1157,6 +1157,23 @@ function revealCanvasInRight() {
1157
1157
  'updateInstalledHint': '重启 Harness 后生效(网页部分刷新页面即可)',
1158
1158
  'updateFailGuide': '自动安装未成功,请在 DSH 插件管理 中升级',
1159
1159
  'updatePolicySkipped': '(已按你的点击跳过 24 小时新版本冷却期)',
1160
+ 'updateSrcTitle': '更新源',
1161
+ 'updateSrcAuto': '自动检测',
1162
+ 'updateSrcOfficial': 'npm 官方源',
1163
+ 'updateSrcChina': '中国大陆镜像源',
1164
+ 'updateSrcNow': '当前源',
1165
+ 'updateSrcSet': '更新源已切换',
1166
+ 'assetsSelAllPage': '全选本页',
1167
+ 'assetsAddToCanvas': '添加到画布',
1168
+ 'assetsClearSel': '清除选择',
1169
+ 'assetsOnlyAudio': '所选均为音频资产,无法生成画布节点',
1170
+ 'assetsAudioSkip': '{n} 个音频资产已跳过',
1171
+ 'assetsAdded': '已添加 {n} 个资产节点',
1172
+ 'assetsBatchDelWarn': '将从资产库删除所选资产;画布上引用它们的节点会解绑:',
1173
+ 'assetsDeletedN': '已删除 {n} 个资产',
1174
+ 'assetsTotalCount': '共 {n} 项',
1175
+ 'assetClickHint': '单击选择 / 双击直接添加到画布',
1176
+ 'assetsRelinked': '已自动回链 {n} 个节点的资产引用',
1160
1177
  'dataRootLabel': '数据根目录',
1161
1178
  'dataRootPlaceholder': '如 D:\\canvas-data',
1162
1179
  'dataRootHint': '资产与视频按项目落盘到该目录(不再占用 C 盘 IndexedDB)。留空 = 浏览器 IndexedDB。',
@@ -2087,6 +2104,23 @@ function revealCanvasInRight() {
2087
2104
  'updateInstalledHint': 'restart Harness to take effect (refresh the page for the web part)',
2088
2105
  'updateFailGuide': 'Auto-install failed — please upgrade via the DSH Plugin Manager',
2089
2106
  'updatePolicySkipped': '(skipped the 24-hour release cool-down at your click)',
2107
+ 'updateSrcTitle': 'Update source',
2108
+ 'updateSrcAuto': 'Auto-detect',
2109
+ 'updateSrcOfficial': 'npm official',
2110
+ 'updateSrcChina': 'China mainland mirror',
2111
+ 'updateSrcNow': 'Active source',
2112
+ 'updateSrcSet': 'Update source changed',
2113
+ 'assetsSelAllPage': 'Select page',
2114
+ 'assetsAddToCanvas': 'Add to canvas',
2115
+ 'assetsClearSel': 'Clear selection',
2116
+ 'assetsOnlyAudio': 'Only audio assets selected — nothing to place on canvas',
2117
+ 'assetsAudioSkip': '{n} audio assets skipped',
2118
+ 'assetsAdded': '{n} asset nodes added',
2119
+ 'assetsBatchDelWarn': 'Selected assets will be deleted from the library; canvas nodes referencing them will be unbound:',
2120
+ 'assetsDeletedN': '{n} assets deleted',
2121
+ 'assetsTotalCount': '{n} items',
2122
+ 'assetClickHint': 'Click to select / double-click to add to canvas',
2123
+ 'assetsRelinked': 'Relinked {n} nodes to their assets',
2090
2124
  'dataRootLabel': 'Data root',
2091
2125
  'dataRootPlaceholder': 'e.g. D:\\canvas-data',
2092
2126
  'dataRootHint': 'Assets and videos are stored per project under this folder (no more C: IndexedDB). Empty = browser IndexedDB.',
@@ -2698,7 +2732,31 @@ body[data-ds-dark-theme] .dshic-studio-modal{border-color:var(--dsw-alias-border
2698
2732
  .dshic-modal-assets{display:flex;flex-direction:column;gap:10px;}
2699
2733
  .dshic-modal-assets .dshic-asset-grid{grid-template-columns:repeat(auto-fill,minmax(158px,1fr));gap:10px;}
2700
2734
  .dshic-modal-assets .dshic-asset-thumb{height:112px;}
2701
- .dshic-asset-pager{display:flex;align-items:center;gap:8px;font-size:11.5px;color:var(--dsw-alias-label-secondary);}
2735
+ /* ── 资产页工具栏(项目下拉下一行):同步/导入/全选/批量操作 + 分页同排 ──
2736
+ 按钮统一「透明底 + 1px 线框 + 文字」(UI-RULES:禁止灰底色块);hover 只加深边框不加底色。
2737
+ 窄窗口 flex-wrap 换行,分页 margin-left:auto 始终靠右。 */
2738
+ .dshic-asset-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;row-gap:6px;}
2739
+ .dshic-asset-toolbar-main{display:flex;align-items:center;gap:8px;flex-wrap:wrap;row-gap:6px;min-width:0;}
2740
+ .dshic-asset-batch{display:flex;align-items:center;gap:8px;flex-wrap:wrap;row-gap:6px;}
2741
+ .dshic-toolbtn{display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 10px;border-radius:7px;
2742
+ border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);
2743
+ font:inherit;font-size:12px;line-height:1;white-space:nowrap;flex:none;cursor:pointer;}
2744
+ .dshic-toolbtn:hover:not(:disabled){border-color:var(--dsw-alias-label-secondary);}
2745
+ .dshic-toolbtn:disabled{opacity:.45;cursor:default;}
2746
+ .dshic-toolbtn.is-danger{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);}
2747
+ .dshic-toolbtn.is-icon{width:26px;padding:0;justify-content:center;font-size:14px;}
2748
+ .dshic-asset-selall{display:inline-flex;align-items:center;gap:4px;font-size:12px;
2749
+ color:var(--dsw-alias-label-secondary);cursor:pointer;flex:none;}
2750
+ .dshic-asset-audiohint{font-size:11px;color:var(--dsw-alias-label-secondary);opacity:.75;}
2751
+ .dshic-asset-pager{display:flex;align-items:center;gap:6px;margin-left:auto;flex:none;
2752
+ font-size:11.5px;color:var(--dsw-alias-label-secondary);}
2753
+ .dshic-asset-pagebox{display:inline-flex;align-items:center;gap:4px;}
2754
+ .dshic-asset-pageinput{width:44px;height:26px;text-align:center;font:inherit;font-size:12px;padding:0 4px;
2755
+ border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;
2756
+ color:var(--dsw-alias-label-primary);box-sizing:border-box;}
2757
+ .dshic-asset-pageinput:focus{outline:none;border-color:var(--dsw-alias-brand-primary);box-shadow:var(--dshic-shadow-sel);}
2758
+ .dshic-asset-pagetotal,.dshic-asset-pagecount{font-variant-numeric:tabular-nums;white-space:nowrap;}
2759
+ .dshic-asset-pagecount{opacity:.75;}
2702
2760
  /* 设定集条目:行 + 已绑定资产缩略图 */
2703
2761
  .dshic-bible-item{display:flex;flex-direction:column;gap:4px;padding:5px 0;border-bottom:1px dashed var(--dsw-alias-border-l1);}
2704
2762
  .dshic-bible-thumbs{display:flex;gap:5px;flex-wrap:wrap;padding-left:4px;}
@@ -2757,6 +2815,8 @@ body[data-ds-dark-theme] .dshic-inline-input{border-color:var(--dsw-alias-border
2757
2815
  .dshic-edge.kind-image{stroke:var(--dsw-alias-brand-primary);}
2758
2816
  .dshic-edge.kind-video{stroke:var(--dsw-alias-state-success-primary);}
2759
2817
  .dshic-edge.is-selected{stroke-width:3.5;filter:drop-shadow(0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 60%,transparent));}
2818
+ /* 选中节点的连线高亮:亮绿 + 双层外发光(固定高对比色,选中态不随主题变化) */
2819
+ .dshic-edge.is-node-linked{stroke:#2fe08a;stroke-width:2.6;filter:drop-shadow(0 0 3px rgba(47,224,138,.95)) drop-shadow(0 0 9px rgba(47,224,138,.5));}
2760
2820
  .dshic-edge-hit{fill:none;stroke:transparent;stroke-width:14;pointer-events:stroke;cursor:pointer;}
2761
2821
  .dshic-edge-temp{fill:none;stroke:var(--dsw-alias-label-secondary);stroke-width:2;stroke-dasharray:6 5;pointer-events:none;}
2762
2822
  /* ── 节点卡片(原型 .node):圆角 14 / 1px --line2 边框 / 柔和投影 ── */
@@ -2899,6 +2959,9 @@ body[data-ds-dark-theme] .dshic-inline-input{border-color:var(--dsw-alias-border
2899
2959
  .dshic-asset{position:relative;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;overflow:hidden;cursor:pointer;
2900
2960
  background:var(--dsw-alias-bg-layer-2);}
2901
2961
  .dshic-asset:hover{border-color:var(--dsw-alias-brand-primary);}
2962
+ /* 批量选择:复选框常驻左上角;选中卡片描边 */
2963
+ .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);}
2964
+ .dshic-asset.is-checked{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px;}
2902
2965
  .dshic-asset-thumb{width:100%;height:86px;object-fit:cover;display:block;background:var(--dsw-alias-bg-layer-2);}
2903
2966
  .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;}
2904
2967
  .dshic-asset-actions{position:absolute;top:4px;right:4px;display:flex;gap:3px;opacity:0;transition:opacity .12s;}
@@ -3627,6 +3690,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3627
3690
  V.x = s.graph.view.x; V.y = s.graph.view.y; V.scale = s.graph.view.scale;
3628
3691
  applyViewToDom();
3629
3692
  });
3693
+ scheduleRepair(); // 载入/切画布后自愈被误置空的资产引用(幂等,每画布一次)
3630
3694
  history.stack = [];
3631
3695
  history.idx = -1;
3632
3696
  pushHistory();
@@ -3725,7 +3789,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3725
3789
  // ============================================================
3726
3790
  const LS_BIBLE = 'dsh-ic:bible:';
3727
3791
  const LS_BIBLE_SYNC = 'dsh-ic:biblesync:';
3728
- function emptyBible() { return { worldview: '', style: '', characters: [], scenes: [], props: [] }; }
3792
+ function emptyBible() { return { worldview: '', style: '', styleAnchor: '', characters: [], scenes: [], props: [] }; }
3729
3793
  function loadBible(pid) {
3730
3794
  if (!pid) return emptyBible();
3731
3795
  const b = lsGet(LS_BIBLE + pid, null);
@@ -3733,6 +3797,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3733
3797
  return {
3734
3798
  worldview: b.worldview || '',
3735
3799
  style: b.style || '',
3800
+ styleAnchor: b.styleAnchor || '',
3736
3801
  characters: Array.isArray(b.characters) ? b.characters : [],
3737
3802
  scenes: Array.isArray(b.scenes) ? b.scenes : [],
3738
3803
  props: Array.isArray(b.props) ? b.props : [],
@@ -3929,7 +3994,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3929
3994
  return `${entityLabelOf(e.kind)} ${e.name}:${desc}${voiceLine}`;
3930
3995
  });
3931
3996
  return [
3932
- (bible.style || '').trim() ? (zh ? '风格:' : 'Style: ') + bible.style.trim() : '',
3997
+ bibleStyleAnchor(bible) ? (zh ? '风格:' : 'Style: ') + bibleStyleAnchor(bible) : '',
3933
3998
  bind ? (zh ? '参考图 → ' : 'Refs -> ') + bind : '',
3934
3999
  stripMentionMarks(prompt),
3935
4000
  entLines.length ? (zh ? '设定集:' : 'Series bible: ') + entLines.join(';') : '',
@@ -3975,6 +4040,17 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3975
4040
  return [].concat(b.characters || [], b.scenes || [], b.props || [])
3976
4041
  .map((x) => (x && x.name ? String(x.name).trim() : '')).filter(Boolean);
3977
4042
  }
4043
+ /** 设定集风格锚(一句话,全片视觉总锚):优先 styleAnchor 字段(AI 更新设定集时同步产出),
4044
+ * 缺省取 style 第一句(按句末标点语义分句,整句保留,绝不字数截断)。
4045
+ * 分工:style 全文进剧本/分镜 LLM 消化成逐镜色调;图片/视频请求只带锚。 */
4046
+ function bibleStyleAnchor(bible) {
4047
+ const raw = String((bible && (bible.styleAnchor || bible.style_anchor)) || '').trim();
4048
+ if (raw) return raw;
4049
+ const style = String((bible && bible.style) || '').trim();
4050
+ if (!style) return '';
4051
+ const m = /^[^。;!?.!?]*[。;!?.!?]?/.exec(style);
4052
+ return (m && m[0].trim()) || style;
4053
+ }
3978
4054
 
3979
4055
  // ---------- 分镜衔接(续帧接力 / 段落调度 / 接缝校验)----------
3980
4056
  // 为什么需要它:每段视频是**独立采样**的,模型不知道上一段最后发生了什么。分镜只写"本镜拍什么"、
@@ -4553,7 +4629,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4553
4629
  });
4554
4630
  // ④ 逐镜描述(画面 + 运镜 + 台词 + 音效)
4555
4631
  outs.push('detailed_description:');
4556
- const style = String((bible && bible.style) || '').trim();
4632
+ const style = bibleStyleAnchor(bible);
4557
4633
  if (style) outs.push((zh ? '风格:' : 'Style: ') + style);
4558
4634
  const hasDialogue = list.some((s) => (s.dialogue || []).some((d) => String((d && d.line) || '').trim()));
4559
4635
  if (hasDialogue) {
@@ -4649,7 +4725,7 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
4649
4725
  const seg = ap ? ap[1] : raw.replace(/声音[::][^。;\n]*/g, '').trim();
4650
4726
  return seg.replace(/\s+/g, ' ').trim();
4651
4727
  })();
4652
- const style = String((bible && bible.style) || '').trim() || (zh ? '写实电影感' : 'realistic cinematic');
4728
+ const style = bibleStyleAnchor(bible) || (zh ? '写实电影感' : 'realistic cinematic');
4653
4729
  const lookLine = look ? look : (zh ? '(设定集未提供外观描述:按名称与常识绘制,保持朴素克制)' : '(no appearance notes in the bible: keep it plain and coherent)');
4654
4730
  if (kind === 'scene') {
4655
4731
  return zh
@@ -6033,9 +6109,63 @@ function queueThumb(assetId) {
6033
6109
  if (!r.ok && (r.status === 401 || r.status === 403) && authFallback && Object.keys(authFallback).length) {
6034
6110
  r = await fetchViaProxy(url, { method: 'GET', headers: authFallback, timeoutMs: 300000, label: '下载视频' });
6035
6111
  }
6036
- if (!r.ok) throw new Error('下载视频失败 HTTP ' + r.status);
6112
+ if (!r.ok) {
6113
+ const e = new Error('下载视频失败 HTTP ' + r.status);
6114
+ e.status = r.status; // 供下载重试判定区分「缓存未就绪(502/404…)」与「鉴权/请求错误(401/400)」
6115
+ throw e;
6116
+ }
6037
6117
  return r.blob;
6038
6118
  }
6119
+ /** 下载重试判定(纯函数):厂商任务成功后 CDN 缓存尚未铺开时,首次 GET 常见
6120
+ * 502/503/504/404/403/429/408;这些都可重试。401(鉴权)与 400/405(请求格式)
6121
+ * 是配置错误,绝不重试——否则会把真实错误拖满整个重试窗口。 */
6122
+ function retryableDownloadError(err) {
6123
+ const st = Number(err && err.status) || 0;
6124
+ if (!st) return true; // 无 HTTP 状态 = 网络抖动/代理超时(fetchViaProxy 直接抛错)
6125
+ return st === 403 || st === 404 || st === 408 || st === 409 || st === 425 || st === 429 || st >= 500;
6126
+ }
6127
+ /** 三宝:succeeded 后等 CDN 缓存铺开的下载重试窗口(实测 2–3 分钟,最迟 5 分钟;留 10 分钟余量)。
6128
+ * 生成成功只有一次下载机会 → 单次 502 不能让整次生成作废。 */
6129
+ const SANBAO_DOWNLOAD_RETRY_MS = 10 * 60 * 1000;
6130
+ const SANBAO_DOWNLOAD_RETRY_STEP_MS = 10 * 1000;
6131
+ /** 带窗口的下载重试(三宝等「任务成功 ≠ 文件可下载」的厂商):
6132
+ * · 仅在可重试错误上循环(见 retryableDownloadError),鉴权/请求错误立即抛;
6133
+ * · 每次重试前可用 refreshUrl 拿最新签名地址(旧地址可能已过期);
6134
+ * · 到达窗口上限后抛明确错误(带最后 HTTP 状态),绝不再无限等;
6135
+ * · 中断(用户停止)优先于重试;download/sleep/now 可注入供回归(不真等 10 分钟)。 */
6136
+ async function downloadVideoWithRetry(url, headers, opts) {
6137
+ const o = opts || {};
6138
+ const windowMs = o.windowMs == null ? SANBAO_DOWNLOAD_RETRY_MS : Math.max(0, Number(o.windowMs) || 0);
6139
+ const stepMs = o.stepMs == null ? SANBAO_DOWNLOAD_RETRY_STEP_MS : Math.max(0, Number(o.stepMs) || 0);
6140
+ const dl = typeof o.download === 'function' ? o.download : downloadVideo;
6141
+ const wait = typeof o.sleep === 'function' ? o.sleep : sleep;
6142
+ const now = typeof o.now === 'function' ? o.now : Date.now;
6143
+ const isAborted = typeof o.isAborted === 'function' ? o.isAborted : genAborted;
6144
+ const deadline = now() + windowMs;
6145
+ for (let attempt = 1; ; attempt++) {
6146
+ if (isAborted && isAborted()) throw new Error(T('stoppedNote'));
6147
+ try {
6148
+ return await dl(url, headers || {}, o.authFallback);
6149
+ } catch (e) {
6150
+ if (!retryableDownloadError(e)) throw e;
6151
+ if (now() >= deadline) {
6152
+ const err = new Error((o.label ? o.label + ' ' : '') + '视频已生成,但 '
6153
+ + Math.round(windowMs / 60000) + ' 分钟内仍无法下载(最后错误:' + ((e && e.message) || e) + ')');
6154
+ err.status = e && e.status;
6155
+ err.downloadTimeout = true;
6156
+ throw err;
6157
+ }
6158
+ if (typeof o.onRetry === 'function') { try { o.onRetry(e, attempt); } catch { /* 诊断失败不影响重试 */ } }
6159
+ if (typeof o.refreshUrl === 'function') {
6160
+ try {
6161
+ const fresh = await o.refreshUrl();
6162
+ if (fresh) url = fresh;
6163
+ } catch { /* 刷新地址失败:沿用旧地址继续重试 */ }
6164
+ }
6165
+ await wait(stepMs);
6166
+ }
6167
+ }
6168
+ }
6039
6169
  /** 跨镜衔接标注(短剧分镜链式生成的行业标准做法):图1=上一镜尾帧(仅用于衔接),
6040
6170
  * 图2..N=实体参考图(名称与 o.refNames 对齐)。Seedance 的 first_frame 与 reference_image 互斥,
6041
6171
  * 尾帧+参考图同连时尾帧降级为第一张衔接参考图,靠顺序+标注控制用途。 */
@@ -6220,6 +6350,7 @@ function queueThumb(assetId) {
6220
6350
  seedance: { label: '火山方舟 · Seedance(豆包视频)', base: 'https://ark.cn-beijing.volces.com/api/v3/contents/generations/tasks', keyPh: 'ARK API Key', note: 'Base URL 填方舟提交端点或 /api/v3 均可;模型 id 如 doubao-seedance-2-0-260128' },
6221
6351
  kling: { label: '快手可灵 Kling', base: 'https://api.klingai.com', keyPh: 'AK:SK(冒号分隔)', note: 'Key 填 AK:SK,代码自动签 JWT;国际站把 Base URL 改为 api-singapore.klingai.com;时长按官方 5/10s 取整' },
6222
6352
  wan: { label: '阿里通义万相 Wan(DashScope)', base: 'https://dashscope.aliyuncs.com', note: '异步任务制;国际站把 Base URL 改为 dashscope-intl.aliyuncs.com;图生视频走 img_url' },
6353
+ 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' },
6223
6354
  minimax: { label: 'MiniMax 海螺视频(V1 协议)', base: 'https://api.minimaxi.com', note: '异步任务制;时长按官方 6/10s 取整;首帧图支持 base64' },
6224
6355
  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 等走扩展参数' },
6225
6356
  vidu: { label: '生数科技 Vidu', base: 'https://api.vidu.com', note: '图片支持 base64;时长按官方 4/8s 取整' },
@@ -6304,6 +6435,84 @@ function queueThumb(assetId) {
6304
6435
  if (WAN_STATUS_FAIL.includes(st)) return { state: 'fail', error: wanErrorOf(j) || st };
6305
6436
  return { state: 'wait' }; // unknown/pending/running 及一切未知状态 = 继续轮询
6306
6437
  }
6438
+ // —— 三宝影像工坊(Sanbao):任务制多参考(/openapi/v1/videos)——
6439
+ /** 三宝视频请求体(纯函数供回归断言):本地素材 dataURL 直传(全模型 media_inputs 含 data_url,
6440
+ * 2026-10-31 实测格式校验通过)。首帧+参考图同传时首帧降级为首张参考图(沿用全站互斥口径);
6441
+ * 参考音频走 audios[{tag,url}];reference 固定 all(多参考全能模式,可扩展参数覆盖)。
6442
+ * frameDataUrl/refDataUrls 取值 dataURL 或公网 URL 皆可——上传兜底重试共用同一构造器。 */
6443
+ function buildSanbaoVideoBody(base, media) {
6444
+ const b = base || {};
6445
+ const m = media || {};
6446
+ const frame = String(m.frameDataUrl || '');
6447
+ const refs = (Array.isArray(m.refDataUrls) ? m.refDataUrls : []).map(String).filter(Boolean);
6448
+ const audios = (Array.isArray(m.audioDataUrls) ? m.audioDataUrls : []).map(String).filter(Boolean);
6449
+ const out = {
6450
+ model: String(b.model || ''),
6451
+ prompt: String(b.prompt || ''),
6452
+ ratio: String(b.ratio || '16:9'),
6453
+ resolution: String(b.resolution || '720p').toLowerCase(), // 模型表枚举是小写:480p/720p/1080p/2k
6454
+ duration: Math.round(Number(b.duration)) || 5,
6455
+ reference: 'all',
6456
+ };
6457
+ const images = (frame ? [frame] : []).concat(refs);
6458
+ if (images.length) out.images = images;
6459
+ if (audios.length) out.audios = audios.map((url, i) => ({ tag: '音频' + (i + 1), url }));
6460
+ return out;
6461
+ }
6462
+ /** 三宝任务 id:查询响应包在 data 里(data.id),创建响应顶层 id 兼容。 */
6463
+ function sanbaoTaskIdOf(j) {
6464
+ if (!j || typeof j !== 'object') return null;
6465
+ const d = (j.data && typeof j.data === 'object') ? j.data : null;
6466
+ return (d && (d.id || d.task_id)) || j.id || j.task_id || null;
6467
+ }
6468
+ function sanbaoStatusOf(j) {
6469
+ if (!j || typeof j !== 'object') return '';
6470
+ const d = (j.data && typeof j.data === 'object') ? j.data : null;
6471
+ return String((d && (d.status ?? d.task_status)) ?? j.status ?? '').trim().toLowerCase();
6472
+ }
6473
+ function sanbaoVideoUrlOf(j) {
6474
+ if (!j || typeof j !== 'object') return '';
6475
+ const d = (j.data && typeof j.data === 'object') ? j.data : null;
6476
+ return [d && (d.video_url || d.download_url || d.url), j.video_url, j.download_url]
6477
+ .find((u) => typeof u === 'string' && /^https?:/.test(u)) || '';
6478
+ }
6479
+ function sanbaoErrorOf(j) {
6480
+ const d = (j && j.data && typeof j.data === 'object') ? j.data : null;
6481
+ return String((d && d.error) || (j && j.error) || '');
6482
+ }
6483
+ /** 三宝轮询判定:queued/processing 及未知状态 = 继续;succeeded → video_url/download_url;failed → error。 */
6484
+ function sanbaoPollState(j) {
6485
+ const st = sanbaoStatusOf(j);
6486
+ if (st === 'succeeded') {
6487
+ const url = sanbaoVideoUrlOf(j);
6488
+ return url ? { state: 'done', url } : { state: 'fail', error: '成功但无视频地址' };
6489
+ }
6490
+ if (st === 'failed') return { state: 'fail', error: sanbaoErrorOf(j) || st };
6491
+ return { state: 'wait' };
6492
+ }
6493
+ /** 三宝图片字段兜底触发:只认「图片/素材/格式/URL」类错误。
6494
+ * 余额(402/余额不足/credits)、鉴权(401/api key)、限流(429/频繁)、账号限制(403)绝不重试。 */
6495
+ function needsSanbaoMediaRetry(errText) {
6496
+ const t = String(errText || '');
6497
+ if (!t) return false;
6498
+ if (/余额不足|积分不足|insufficient_credits|api\s*key|unauthorized|forbidden|请求过于频繁|rate\s*limit|401|402|403|429/i.test(t)) return false;
6499
+ return /图片|图像|image|素材|格式|url|链接/i.test(t);
6500
+ }
6501
+ /** 三宝素材上传(原始二进制体,非 multipart):返回 file.url 公网地址。
6502
+ * 用专用 uploadKey(扩展参数指定,缺省回退主 key);fetchViaProxy 的 bodyRaw 直传 Blob。 */
6503
+ async function sanbaoUploadRaw(base, uploadKey, blob, kind) {
6504
+ const type = (blob && blob.type) || (kind === 'audio' ? 'audio/mpeg' : kind === 'video' ? 'video/mp4' : 'image/jpeg');
6505
+ const ext = String(type.split('/')[1] || 'bin').replace(/[^a-z0-9]/gi, '') || 'bin';
6506
+ const r = await fetchViaProxy(base + '/openapi/v1/uploads/raw?kind=' + kind + '&fileName=ref.' + ext, {
6507
+ headers: { 'Content-Type': type, Authorization: 'Bearer ' + (uploadKey || '') },
6508
+ bodyRaw: blob, bodyContentType: type, timeoutMs: 120000, label: 'Sanbao 素材上传',
6509
+ });
6510
+ if (!r.ok) throw new Error('Sanbao 素材上传 HTTP ' + r.status + ':' + String(r.text || '').slice(0, 200));
6511
+ let j = null; try { j = JSON.parse(r.text); } catch { throw new Error('Sanbao 素材上传响应非 JSON:' + String(r.text || '').slice(0, 200)); }
6512
+ const url = j && j.file && j.file.url;
6513
+ if (!/^https?:/.test(String(url || ''))) throw new Error('Sanbao 素材上传未返回 file.url');
6514
+ return url;
6515
+ }
6307
6516
  /** 读取生成视频的真实尺寸与时长(用于「厂商是否忽略了参数」的可见校验)。 */
6308
6517
  function probeVideoMeta(blob) {
6309
6518
  return new Promise((resolve) => {
@@ -6343,6 +6552,7 @@ function queueThumb(assetId) {
6343
6552
  // URL 特征兜底:URL 也是用户显式配置的一部分(旧配置 vendor 字段为空时走这里,
6344
6553
  // 设置卡片渲染时会按此回填 vendor,之后恒走显式值)。
6345
6554
  if (url.includes('dashscope')) return 'wan';
6555
+ if (url.includes('sanbaobeauty')) return 'sanbao';
6346
6556
  if (url.includes('klingai')) return 'kling';
6347
6557
  if (url.includes('minimax')) return 'minimax';
6348
6558
  if (url.includes('vidu')) return 'vidu';
@@ -6476,6 +6686,89 @@ function queueThumb(assetId) {
6476
6686
  });
6477
6687
  return await downloadVideo(url, {});
6478
6688
  },
6689
+ // —— 三宝影像工坊 Sanbao:任务制多参考(/openapi/v1/videos),本地图 dataURL 直传,格式错误自动上传转 URL 重试 ——
6690
+ async sanbao(prompt, frameBlob, s, o) {
6691
+ const base = vendorBase(s.url, VIDEO_VENDORS.sanbao.base);
6692
+ const headers = { 'Content-Type': 'application/json', Authorization: 'Bearer ' + (s.apiKey || '') };
6693
+ const rawRefs = o.hardFrame ? [] : (o.refs || []).slice(0, 9);
6694
+ let text = prompt;
6695
+ if (frameBlob && rawRefs.length) text = videoRefNote(o.refNames) + '\n' + prompt;
6696
+ const baseSpec = { model: s.model || '', prompt: text, ratio: o.ratio, resolution: o.resolution || '720p', duration: o.duration };
6697
+ // 第一发:本地素材 dataURL 直传(全模型 media_inputs 含 data_url,2026-10-31 实测格式校验通过)
6698
+ const body = buildSanbaoVideoBody(baseSpec, {
6699
+ frameDataUrl: frameBlob ? await blobToDataUrlScaled(frameBlob) : '',
6700
+ refDataUrls: await Promise.all(rawRefs.map((b) => blobToDataUrlScaled(b))),
6701
+ audioDataUrls: await Promise.all((o.audioRefs || []).slice(0, 3).map((b) => blobToDataUrl(b))),
6702
+ });
6703
+ // 扩展参数:逃生舱;uploadKey 专用上传 key 只用于 /uploads/raw,绝不进任务请求体
6704
+ let uploadKey = s.apiKey || '';
6705
+ try {
6706
+ const ex = parseExtraParams(s.extra);
6707
+ if (ex) {
6708
+ if (ex.uploadKey) uploadKey = String(ex.uploadKey);
6709
+ const rest = { ...ex }; delete rest.uploadKey;
6710
+ Object.assign(body, rest);
6711
+ }
6712
+ } catch (e) { throw new Error('三宝扩展参数配置有误:' + ((e && e.message) || e)); }
6713
+ const submit = (b, label) => fetchViaProxy(base + '/openapi/v1/videos', { headers, body: b, timeoutMs: 120000, label });
6714
+ let r1 = await submit(body, 'Sanbao 提交');
6715
+ // 兜底:图片/素材格式或 URL 类错误 → 用专用 uploadKey 把本地素材传 /uploads/raw 转公网 URL 后重试一次
6716
+ // (余额/鉴权/限流/账号限制类错误绝不重试——needsSanbaoMediaRetry 排除)
6717
+ if (!r1.ok && needsSanbaoMediaRetry(r1.text) && (frameBlob || rawRefs.length || (o.audioRefs || []).length)) {
6718
+ try {
6719
+ const frameUrl = frameBlob ? await sanbaoUploadRaw(base, uploadKey, frameBlob, 'image') : '';
6720
+ const refUrls = [];
6721
+ for (const b of rawRefs) refUrls.push(await sanbaoUploadRaw(base, uploadKey, b, 'image'));
6722
+ const audioUrls = [];
6723
+ for (const b of (o.audioRefs || []).slice(0, 3)) audioUrls.push(await sanbaoUploadRaw(base, uploadKey, b, 'audio'));
6724
+ const body2 = buildSanbaoVideoBody(baseSpec, { frameDataUrl: frameUrl, refDataUrls: refUrls, audioDataUrls: audioUrls });
6725
+ const ex2 = parseExtraParams(s.extra);
6726
+ if (ex2) { const rest2 = { ...ex2 }; delete rest2.uploadKey; Object.assign(body2, rest2); }
6727
+ r1 = await submit(body2, 'Sanbao 提交(素材转URL重试)');
6728
+ } catch (e) {
6729
+ throw new Error('Sanbao 提交 HTTP ' + r1.status + ':' + r1.text.slice(0, 200) + ';[素材上传重试] ' + ((e && e.message) || e));
6730
+ }
6731
+ }
6732
+ if (!r1.ok) throw new Error('Sanbao 提交 HTTP ' + r1.status + ' @ ' + base + ':' + r1.text.slice(0, 300));
6733
+ let j1 = null; try { j1 = JSON.parse(r1.text); } catch { throw new Error('Sanbao 响应非 JSON:' + r1.text.slice(0, 200)); }
6734
+ const tid = sanbaoTaskIdOf(j1);
6735
+ if (!tid) throw new Error('Sanbao 响应中没有任务 id:' + r1.text.slice(0, 200));
6736
+ const taskUrl = base + '/openapi/v1/videos/' + encodeURIComponent(tid);
6737
+ if (o.onTask) { try { o.onTask(tid, taskUrl); } catch { /* 持久化失败不影响生成 */ } }
6738
+ const queryTask = async (label) => {
6739
+ const r = await fetchViaProxy(taskUrl, { method: 'GET', headers: { Authorization: 'Bearer ' + (s.apiKey || '') }, timeoutMs: 60000, label });
6740
+ if (!r || !r.ok) return null;
6741
+ try { return JSON.parse(r.text); } catch { return null; }
6742
+ };
6743
+ const url = await vendorPoll('Sanbao', 8000, async () => {
6744
+ const j = await queryTask('Sanbao 查询');
6745
+ return j ? sanbaoPollState(j) : { state: 'wait' };
6746
+ });
6747
+ // 三宝 succeeded 只代表转码完成:CDN 缓存尚未铺开时首次 GET 会 502(实测 2–3 分钟,最迟 5 分钟)。
6748
+ // 任务已成功、钱已花 → 给 10 分钟重试窗口,每次重试前刷新签名地址;鉴权/请求错误仍立即失败。
6749
+ try {
6750
+ return await downloadVideoWithRetry(url, {}, {
6751
+ windowMs: SANBAO_DOWNLOAD_RETRY_MS,
6752
+ stepMs: SANBAO_DOWNLOAD_RETRY_STEP_MS,
6753
+ refreshUrl: async () => {
6754
+ const j = await queryTask('Sanbao 缓存查询');
6755
+ if (!j) return '';
6756
+ const st = sanbaoPollState(j);
6757
+ return st.state === 'done' ? st.url : '';
6758
+ },
6759
+ onRetry: (e, n) => {
6760
+ try {
6761
+ console.info('[IC] sanbao download not ready (' + ((e && e.message) || e) + ') — retry '
6762
+ + n + '/' + Math.ceil(SANBAO_DOWNLOAD_RETRY_MS / SANBAO_DOWNLOAD_RETRY_STEP_MS));
6763
+ } catch { /* 诊断失败不影响重试 */ }
6764
+ },
6765
+ });
6766
+ } catch (e) {
6767
+ const err = new Error('三宝视频下载失败(任务 ' + tid + '):' + ((e && e.message) || e));
6768
+ err.status = e && e.status;
6769
+ throw err;
6770
+ }
6771
+ },
6479
6772
  // —— MiniMax 海螺:异步 task_id + query 接口 ——
6480
6773
  async minimax(prompt, frameBlob, s, o) {
6481
6774
  const base = vendorBase(s.url, VIDEO_VENDORS.minimax.base);
@@ -6766,6 +7059,8 @@ function queueThumb(assetId) {
6766
7059
  * 超出上限会被截断——必须显式告警(o.warn → 节点 genWarn),绝不静默丢素材。 */
6767
7060
  const VIDEO_REF_CAPS = {
6768
7061
  wan: { img: 10 },
7062
+ // 三宝:按最保守通用模型(hailuo/SD2.0 系 9 图 3 音频;wan/kling 系 10 图、SD2.5 系 30 图,见厂商 note)
7063
+ sanbao: { img: 9, audio: 3 },
6769
7064
  minimaxv2: { img: 9, audio: 3 },
6770
7065
  openai: { img: 8 },
6771
7066
  seedance: { img: 8 },
@@ -7918,6 +8213,23 @@ function queueThumb(assetId) {
7918
8213
  // 有新版本 → 横幅 + "去升级";点击后由 Host 在所属 profile 内
7919
8214
  // pnpm add 精确版本(绝不自动重启/刷新);旧 Host / 开发态 / 失败 → 回退为纯引导
7920
8215
  // ============================================================
8216
+ /** 从 Host 读取更新源配置(覆盖值 + 自动探测结果;旧 Host 无此 RPC → 静默隐藏选择器)。 */
8217
+ async function fetchUpdateRegistry() {
8218
+ try {
8219
+ const r = await hostRpc('updateGetRegistry');
8220
+ update((s) => { s.updateRegistry = r.override || 'auto'; s.updateRegistryResolved = r.resolved || null; });
8221
+ } catch { /* 旧 Host:radio 仍显示,仅无当前源展示 */ }
8222
+ }
8223
+ /** 切换更新源(auto=按网络环境自动探测;official/china=手动覆盖)。写 Host config 并回读生效源。 */
8224
+ async function setUpdateSource(val) {
8225
+ update((s) => { s.updateRegistry = val; });
8226
+ try {
8227
+ const r = await hostRpc('updateSetRegistry', { override: val });
8228
+ update((s) => { s.updateRegistry = r.override || val; s.updateRegistryResolved = r.resolved || null; });
8229
+ toast(T('updateSrcSet') + (r.resolved ? ':' + (r.resolved === 'china' ? T('updateSrcChina') : T('updateSrcOfficial')) : ''));
8230
+ } catch { /* 旧 Host 无此 RPC:UI 状态已记录,仅生效源未知 */ }
8231
+ }
8232
+ const srcLabel = (kind) => (kind === 'china' ? T('updateSrcChina') : kind === 'official' ? T('updateSrcOfficial') : T('updateSrcAuto'));
7921
8233
  async function checkUpdate(silent) {
7922
8234
  update((s) => { s.updateInfo = null; s.updateChecking = true; s.updateMsg = null; });
7923
8235
  try {
@@ -7939,7 +8251,8 @@ function queueThumb(assetId) {
7939
8251
  const res = await hostRpc('updateInstall');
7940
8252
  if (res && res.ok && res.changed) {
7941
8253
  const relaxed = res.policyRelaxed ? ' ' + T('updatePolicySkipped') : '';
7942
- update((s) => { s.updateBusy = false; s.updateMsg = T('updateInstalled') + ' v' + res.version + ' — ' + T('updateInstalledHint') + relaxed; });
8254
+ const srcTxt = res.registryKind ? '(' + T('updateSrcNow') + ':' + srcLabel(res.registryKind) + ')' : '';
8255
+ update((s) => { s.updateBusy = false; s.updateMsg = T('updateInstalled') + ' v' + res.version + srcTxt + ' — ' + T('updateInstalledHint') + relaxed; });
7943
8256
  } else if (res && res.ok) {
7944
8257
  update((s) => { s.updateBusy = false; s.updateMsg = T('updateUpToDate') + (res.version ? ' v' + res.version : ''); });
7945
8258
  } else {
@@ -8006,8 +8319,22 @@ function queueThumb(assetId) {
8006
8319
  const LS_DOCSYNC = 'dsh-ic:docsync:';
8007
8320
  /** Host 侧改动了项目文档(Agent 建节点/连线/写内容/补设定集)→ 拉回并合并到本地画布。
8008
8321
  * canvasId 非空 = 该画布文档(多画布);缺省 = 项目默认画布。 */
8009
- function mergeHostDoc(pid, full, canvasId) {
8010
- if (!full) return;
8322
+ /** 媒体节点指针空值保护(纯函数供回归):Host 副本把 assetId/lastAssetId 清成 null 时,
8323
+ * 本地有值则保留——null 不是有效写入(没人会"有意"清空指针),而这类 null 恰是
8324
+ * 「历史清理误判 / 跨机空库」污染后的形态;真删资产时展示层有缺失态兜底,保留指针永远可恢复。
8325
+ * Host 的非空值仍以 Host 为准(Agent 写入是有意的)。 */
8326
+ function protectMediaPointer(hostNode, localNode) {
8327
+ if (!hostNode || !hostNode.data || !localNode || !localNode.data) return hostNode;
8328
+ const t = normalizeNodeType(hostNode.type);
8329
+ if (t !== 'image' && t !== 'video') return hostNode;
8330
+ const local = localNode.data;
8331
+ const data = { ...hostNode.data };
8332
+ let changed = false;
8333
+ if (!data.assetId && local.assetId) { data.assetId = local.assetId; changed = true; }
8334
+ if (!data.lastAssetId && local.lastAssetId) { data.lastAssetId = local.lastAssetId; changed = true; }
8335
+ return changed ? { ...hostNode, data } : hostNode;
8336
+ }
8337
+ function mergeHostDoc(pid, full, canvasId) { if (!full) return;
8011
8338
  const cid = full.canvasId || canvasId || DEFAULT_CANVAS_ID;
8012
8339
  // Host 侧(对话 Agent)可能写入了旧类型节点:先把整份文档归一,再做合并(类型迁移与旧项目兼容)
8013
8340
  normalizeGraphDoc(full);
@@ -8031,7 +8358,7 @@ function queueThumb(assetId) {
8031
8358
  // (否则刚生成完的分镜会被一次过期合并清空,客户端再推回去就永久丢失)
8032
8359
  if (cur && cur.type === 'storyboard' && Array.isArray(cur.data && cur.data.shots) && cur.data.shots.length
8033
8360
  && !(n && n.data && Array.isArray(n.data.shots) && n.data.shots.length)) continue;
8034
- nodes[nid] = n; // Host 为准(Agent 写入是有意的)
8361
+ nodes[nid] = protectMediaPointer(n, cur); // Host 为准,但媒体指针不允许被 Host 的 null 清空(回链被覆盖事故)
8035
8362
  }
8036
8363
  const deadEdges = new Set([...(local.edgeTombstones || []), ...(full.edgeTombstones || []), ...((live && live.edgeTombstones) || [])]);
8037
8364
  const edges = (live && live.edges) ? [...live.edges] : [...(local.edges || [])];
@@ -8061,6 +8388,7 @@ function queueThumb(assetId) {
8061
8388
  }
8062
8389
  }
8063
8390
  if (isActiveCanvas) update((s) => { s.graph = { nodes, edges: keep, view: s.graph.view, tombstones: tombOut, edgeTombstones: local.edgeTombstones || [] }; s.assetsTick++; });
8391
+ if (isActiveCanvas) scheduleRepair(); // 启动同步落图后自愈被误置空的资产引用
8064
8392
  }
8065
8393
  async function hostSyncTick() {
8066
8394
  if (hostSyncStopped) return;
@@ -8631,6 +8959,7 @@ function queueThumb(assetId) {
8631
8959
  '- **【动作层次·硬性】timeBeats 是本镜的三个时间节拍(数组,按时间顺序)**:把"一个动作"拆成 **起势 → 发力 → 落点** 三拍,每拍写**可见的**身体/道具状态,如 ["0s 右手抬到一半、指节收紧","1.2s 手继续抬到胸口、肩线前压","3s 停在信封贴住心口、雨珠从指缝滑落"]。**只写一个节拍 = 模型只会演一个姿势(用户实测:动作极简、只会平移)**;凡 ≥2s 的镜头必须写满 3 拍,≤1s 的快切镜可以只写 1 拍。**每一拍都必须能拍出来,不写"他感到/他意识到"**;',
8632
8960
  '- **camera 是本镜的机位/焦段/运镜三件套**(不是只写"推近/平移"):写成「景别 + 焦段光圈 + 运镜起点→终点」,如「中近景 50mm f/2.0,从腰高缓推至面部,匀速、到面部前 0.2 秒减速停住」。**禁止只写"推近/拉远/平移"这类空模板**(那是用户看到的"只会平移"的直接来源);**一镜只能有一个主运镜**,要两个就拆镜;',
8633
8961
  '- **vfx 是本镜必须可见的物理特效/细节**(不写就没有,模型不会自己加):按题材点名 1–3 项——雨丝斜打 / 尘粒在光柱中浮动 / 雪片近大远小 / 逆光镜头光斑 / 路灯钠黄溢光 / 闪电瞬时照亮 / 衣角被风掀起 / 水面涟漪扩散 / 纸张翻飞 / 轻微手持晃动 / 运动模糊拖影 / 烟雾弥漫 / 蒸汽升腾。写**可拍摄的物理现象**,不写"画面很唯美"这类空话;**每场至少 3 镜要有 vfx**;',
8962
+ '- **【色调·逐镜显式】把本镜色调写进 visual(主色/色温/明暗对比,按影调色彩命题取值,如「钠黄主光、青绿补色、高对比」)——色调是逐镜的画面事实,不得只写"电影感/有质感"这类空话**;',
8634
8963
  '- characters/scene/props 使用剧本与设定集中的名称(不带 @),便于匹配资产;无道具给空数组;',
8635
8964
  '- **dialogue 是本镜的角色台词**:把剧本中落在这一镜的对白逐行搬进来({"role":"角色名","line":"台词原文"}),台词必须**逐字来自剧本**、不新写不改写;本镜无台词给空数组;一镜尽量只放一个角色的台词(单说话人镜头利于声音参考提取);',
8636
8965
  '- **【音话同步·硬性】有台词的镜头必须让说话角色在画面内开口说话**:景别用近景/中近景,脸部朝向可见(正面或 3/4 侧脸),禁止背对镜头、脸部被遮挡、人物出画;visual 或 motion 里必须写明「开口说话、口型清晰可见」;台词**绝不能**处理成画外音/旁白(否则成片里人嘴是闭的、声音飘在背景里);若某句台词在剧本里说话人无法入画,就把这句台词安排到能看见他说话的那一镜;',
@@ -8666,6 +8995,7 @@ function queueThumb(assetId) {
8666
8995
  '- **[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"**;',
8667
8996
  '- **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;',
8668
8997
  '- **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**;',
8998
+ '- **[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"**;',
8669
8999
  '- characters/scene/props arrays must use plain names from the script and series bible (no @) so assets match; empty props array if none;',
8670
9000
  '- **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);',
8671
9001
  '- **[LIP-SYNC - HARD] any shot carrying dialogue must show the speaker TALKING ON SCREEN**: use a close-up / medium close-up with the face visible (frontal or 3/4), never back-to-camera, never obscured, never off-frame; state "speaks on screen, mouth clearly visible" in visual or motion; dialogue must NEVER become voice-over/narration (otherwise the final cut has a closed mouth with the voice floating in the background); if a line cannot be on camera in the script, move that line to the shot where the speaker is visible;',
@@ -9287,6 +9617,46 @@ function queueThumb(assetId) {
9287
9617
  return { x, y };
9288
9618
  }
9289
9619
 
9620
+ /** 资产批量导入落点(纯函数供回归):在现有节点最右侧之外按列铺开,一列 ≤5 个。
9621
+ * existingRects:现有节点矩形 [{x,y,w,h}];items:[{w,h}](按导入顺序,仅计可成节点的资产)。
9622
+ * 返回 [{x,y,w,h}]:列内自上而下堆叠、放不下碰撞则顺延,列间 GAP_COL,彼此与现有节点零重叠。 */
9623
+ function layoutBatchColumns(existingRects, items, opts) {
9624
+ const o = opts || {};
9625
+ const GAP_X = Number(o.gapX) || 80; // 与现有节点最右界的水平间距
9626
+ const GAP_COL = Number(o.gapCol) || 60; // 列间距
9627
+ const GAP_Y = Number(o.gapY) || 40; // 行间距
9628
+ const PER_COL = Number(o.perCol) || 5; // 一列上限
9629
+ const rects = (existingRects || []).filter((r) => r && Number.isFinite(Number(r.x)));
9630
+ const baseX = rects.length
9631
+ ? Math.round(Math.max(...rects.map((r) => (Number(r.x) || 0) + (Number(r.w) || 0))) + GAP_X)
9632
+ : 80;
9633
+ const baseY = Math.round(Number(o.y0) || 40);
9634
+ const placed = [];
9635
+ 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
9636
+ && (Number(r.y) || 0) < y + h + 28 && (Number(r.y) || 0) + (Number(r.h) || 0) + 28 > y)
9637
+ || 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);
9638
+ const out = [];
9639
+ let colX = baseX;
9640
+ let colY = baseY;
9641
+ let colW = 0;
9642
+ let inCol = 0;
9643
+ for (const it of items || []) {
9644
+ const w = Math.max(1, Number(it && it.w) || 360);
9645
+ const h = Math.max(1, Number(it && it.h) || 220);
9646
+ if (inCol >= PER_COL) { colX = colX + colW + GAP_COL; colY = baseY; colW = 0; inCol = 0; }
9647
+ let y = colY;
9648
+ let blocker = hit(colX, y, w, h);
9649
+ let guard = 0;
9650
+ while (blocker && guard++ < 80) { y = (Number(blocker.y) || 0) + (Number(blocker.h) || 0) + 28; blocker = hit(colX, y, w, h); }
9651
+ out.push({ x: Math.round(colX), y: Math.round(y), w, h });
9652
+ placed.push({ x: colX, y, w, h });
9653
+ colW = Math.max(colW, w);
9654
+ colY = y + h + GAP_Y;
9655
+ inCol++;
9656
+ }
9657
+ return out;
9658
+ }
9659
+
9290
9660
  function addNodeAt(type, pos) {
9291
9661
  // 代码级强控制:建点坐标由布局引擎决定(一类型一列 + 碰撞下移),不信任调用者的自由坐标。
9292
9662
  // 媒体节点外框按比例(与 Host nextNodePos 同口径),其余 360×360。
@@ -9323,6 +9693,84 @@ function queueThumb(assetId) {
9323
9693
  pushHistory();
9324
9694
  flushSave(); // 删除立即推送(不等 450ms 防抖):同步把 Host 上的节点删掉,压缩"拉回复活"的时间窗
9325
9695
  }
9696
+ /** 历史条死条目裁剪(纯函数供回归):返回去死后的新数组,无死时原样返回(调用方按引用判变化)。
9697
+ * 【契约】只裁 history——绝不产生「清空当前 assetId」的语义(旧版清理曾把 assetId 置空落盘,
9698
+ * 刷新/跨机误判时造成生成节点预览全部丢失)。 */
9699
+ function pruneDeadHistory(history, aliveIds) {
9700
+ const hasDead = (history || []).some((x) => !aliveIds.has(x.assetId));
9701
+ if (!hasDead) return history;
9702
+ return (history || []).filter((x) => aliveIds.has(x.assetId));
9703
+ }
9704
+ /** 资产回链候选挑选(纯函数供回归):跳过已被其他节点引用的资产,取 createdAt 最新的一条;
9705
+ * 无可用候选返回 null(宁缺勿错)。 */
9706
+ function repairPickAsset(candidates, usedIds) {
9707
+ const pool = (candidates || []).filter((c) => c && c.id && !(usedIds && usedIds.has(c.id)));
9708
+ if (!pool.length) return null;
9709
+ let best = null;
9710
+ for (const c of pool) {
9711
+ if (!best || (Number(c.createdAt) || 0) >= (Number(best.createdAt) || 0)) best = c;
9712
+ }
9713
+ return best;
9714
+ }
9715
+ /** 资产回链计划(纯函数供回归):孤儿节点(done 无 assetId)按 nodeLabel 逐字匹配资产,
9716
+ * 跳过已被其他节点引用的候选,每节点取 createdAt 最新的一条;无可用候选 → 不产生修复项。 */
9717
+ function repairPlan(orphanNodes, recs, usedIdsIn) {
9718
+ const usedIds = new Set(usedIdsIn || []);
9719
+ const byLabel = new Map();
9720
+ for (const rec of recs || []) {
9721
+ if (rec.kind !== 'image' && rec.kind !== 'video') continue;
9722
+ const lb = String(rec.nodeLabel || '').trim();
9723
+ if (!lb) continue;
9724
+ if (!byLabel.has(lb)) byLabel.set(lb, []);
9725
+ byLabel.get(lb).push(rec);
9726
+ }
9727
+ const fixes = [];
9728
+ for (const nd of orphanNodes || []) {
9729
+ const pick = repairPickAsset(byLabel.get(String(nd.data.label || '').trim()), usedIds);
9730
+ if (!pick) continue;
9731
+ fixes.push({ id: nd.id, assetId: pick.id });
9732
+ usedIds.add(pick.id);
9733
+ }
9734
+ return fixes;
9735
+ }
9736
+ // 修复:旧版清理在 store 未就绪(刷新竞态)/跨机打开(本地库无资产行)时会误把 assetId
9737
+ // 置空并落盘 → 生成节点预览全部丢失(资产文件与资产库都还在,只有指针没了)。
9738
+ // 每次载入项目/切画布后跑一次:按 nodeLabel 与节点 label 逐字唯一匹配回链最新资产(幂等)。
9739
+ let repairDoneFor = '';
9740
+ let repairTimer = null;
9741
+ function scheduleRepair() {
9742
+ if (repairTimer) clearTimeout(repairTimer);
9743
+ repairTimer = setTimeout(() => { repairTimer = null; repairMissingAssetLinks().catch(() => { /* 静默 */ }); }, 1500);
9744
+ }
9745
+ async function repairMissingAssetLinks() {
9746
+ if (!S.store || !S.activeId) return;
9747
+ const nodes = Object.values(S.graph.nodes).filter((nd) => (nd.type === 'image' || nd.type === 'video')
9748
+ && nd.data && nd.data.status === 'done' && !nd.data.assetId && String(nd.data.label || '').trim());
9749
+ // 图未加载 / 服务端暂时拉不到清单 → 不记账直接返回(下次调度重试);
9750
+ // 记账必须在"真正完成一次有效检查"之后,否则启动竞态会把每画布一次的额度烧掉
9751
+ if (!nodes.length) return;
9752
+ const recs = await idbByProject(S.activeId).catch(() => []);
9753
+ if (!recs.length) {
9754
+ try { console.info('[IC] asset-relink: orphans=' + nodes.length + ' recs=0(assetsList 未返回)'); } catch { /* 忽略 */ }
9755
+ return;
9756
+ }
9757
+ const key = S.activeId + '/' + activeCanvasId();
9758
+ if (repairDoneFor === key) return;
9759
+ repairDoneFor = key;
9760
+ const usedIds = new Set(Object.values(S.graph.nodes).map((nd) => nd.data && nd.data.assetId).filter(Boolean));
9761
+ const fixes = repairPlan(nodes, recs, usedIds);
9762
+ try { console.info('[IC] asset-relink: orphans=' + nodes.length + ' recs=' + recs.length + ' fixes=' + fixes.length); } catch { /* 忽略 */ }
9763
+ if (!fixes.length) return;
9764
+ update((s) => {
9765
+ for (const f of fixes) {
9766
+ const nd = s.graph.nodes[f.id];
9767
+ if (nd && nd.data && !nd.data.assetId) nd.data.assetId = f.assetId;
9768
+ }
9769
+ s.assetsTick++;
9770
+ });
9771
+ flushSave();
9772
+ toast(T('assetsRelinked').replace('{n}', String(fixes.length)));
9773
+ }
9326
9774
  function duplicateSelection() {
9327
9775
  const clones = [];
9328
9776
  update((s) => {
@@ -12264,14 +12712,18 @@ function queueThumb(assetId) {
12264
12712
  return () => { cancelled = true; };
12265
12713
  }, [kind, n.data.assetId, n.data.label, S.assetsTick]);
12266
12714
  // 历史条自愈:已被删除的资产(渲染成 … 的幽灵格)自动从节点 history 剔除;
12267
- // 服务端不可达时跳过本轮(宁可不修剪,绝不误删有效历史)
12715
+ // 【卫语句】store 未就绪绝不清理——sqlite 资产不在 IDB,误走 IDB 分支会把活资产
12716
+ // 全部判死并置空 assetId(刷新竞态曾造成生成节点预览全部丢失,见 0.19.18 修复记录)。
12717
+ // 【契约】清理只裁 history,绝不回写 data.assetId——当前资产指针是用户数据,
12718
+ // 资产真被删时展示层已有缺失态兜底,节点仍可重生成/重连。
12268
12719
  useEffect(() => {
12269
12720
  const histList = n.data.history || [];
12270
12721
  if (!histList.length) return;
12722
+ if (!S.store) return;
12271
12723
  let ok = true;
12272
12724
  (async () => {
12273
12725
  let alive = null;
12274
- if (S.store) {
12726
+ if (S.store === 'sqlite') {
12275
12727
  const r = await hostRpc('assetsGet', { ids: histList.map((x) => x.assetId) }).catch(() => null);
12276
12728
  if (!r) return;
12277
12729
  alive = new Set((r.items || []).map((x) => x.id));
@@ -12280,15 +12732,12 @@ function queueThumb(assetId) {
12280
12732
  alive = new Set(histList.filter((_, i) => recs[i]).map((x) => x.assetId));
12281
12733
  }
12282
12734
  if (!ok) return;
12283
- const dead = histList.filter((x) => !alive.has(x.assetId)).map((x) => x.assetId);
12284
- if (!dead.length) return;
12735
+ const next = pruneDeadHistory(n.data.history, alive);
12736
+ if (next === n.data.history) return;
12285
12737
  update((s) => {
12286
12738
  const nd = s.graph.nodes[n.id];
12287
12739
  if (!nd || !Array.isArray(nd.data.history)) return;
12288
- const next = nd.data.history.filter((x) => !dead.includes(x.assetId));
12289
- if (next.length === nd.data.history.length) return;
12290
12740
  nd.data.history = next;
12291
- if (nd.data.assetId && dead.includes(nd.data.assetId)) nd.data.assetId = next.length ? next[next.length - 1].assetId : null;
12292
12741
  });
12293
12742
  })();
12294
12743
  return () => { ok = false; };
@@ -12816,7 +13265,7 @@ function queueThumb(assetId) {
12816
13265
  * 尾部的「人物:/场景/道具:」清单从最后一场剥离(资产生产参考,不属于场景正文)。 */
12817
13266
  function parseScriptScenes(output) {
12818
13267
  const text = String(output || '').replace(/\r\n/g, '\n');
12819
- const head = /^\s*(?:【\s*场\s*\d+[^】]*】|【?\s*场\s*\d+\s*】?\s*[::、..]|场\s*\d+\s*[::、..]|#{1,4}\s*场?\s*\d+|SCENE\s*\d+\b)/i;
13268
+ const head = /^\s*(?:【\s*场\s*\d+[^】]*】|【?\s*场\s*\d+\s*】?\s*[::、..]|场\s*\d+\s*[::、..]|#{1,4}\s*场\s*\d+|SCENE\s*\d+\b)/i;
12820
13269
  const scenes = [];
12821
13270
  let cur = null;
12822
13271
  for (const line of text.split('\n')) {
@@ -12828,10 +13277,28 @@ function queueThumb(assetId) {
12828
13277
  }
12829
13278
  }
12830
13279
  if (cur && cur.text.trim()) scenes.push(cur);
13280
+ // 片尾清单剥离:只剥「真正的片尾清单」——最后一场的**末尾**是纯清单行块
13281
+ // (人物/角色/场景/道具/地点 行 + 空行 + (终)/完 终止符)一直延续到文本结尾,
13282
+ // 且块内真的含「人物/角色」清单行,才剥离。场内的「人物:」行(每场格式的常见写法)
13283
+ // 不是片尾清单,绝不剥离(旧正则从场内首个「人物:」一路吞到结尾,曾把最后一场正文全部丢掉)。
12831
13284
  if (scenes.length) {
12832
13285
  const last = scenes[scenes.length - 1];
12833
- const i = last.text.search(/\n(?:人物|角色)\s*[::][\s\S]*$/);
12834
- if (i >= 0) last.text = last.text.slice(0, i) + '\n';
13286
+ const lines = last.text.split('\n');
13287
+ const isList = (l) => /^\s*(?:(?:人物|角色|地点|场景|道具)\s*[::]|场景\s*\/\s*道具\s*[::])/.test(l);
13288
+ const isMeta = (l) => /^\s*$/.test(l) || /^\s*(?:(终)|完|——\s*完\s*——)\s*$/.test(l);
13289
+ let i = lines.length - 1;
13290
+ let sawList = false;
13291
+ for (; i >= 1; i--) {
13292
+ if (isList(lines[i])) { sawList = true; continue; }
13293
+ if (isMeta(lines[i])) continue;
13294
+ break;
13295
+ }
13296
+ if (sawList && i >= 1) {
13297
+ // 剥离从块的第一个清单行开始:块内排在清单行之前的终止符/空行(如「(终)」)保留在正文里
13298
+ let firstList = i + 1;
13299
+ while (firstList < lines.length && !isList(lines[firstList])) firstList++;
13300
+ last.text = lines.slice(0, firstList).join('\n') + '\n';
13301
+ }
12835
13302
  }
12836
13303
  return scenes.filter((s) => s.text.trim());
12837
13304
  }
@@ -13443,6 +13910,8 @@ function queueThumb(assetId) {
13443
13910
  S.graph.edges.map((e) => {
13444
13911
  const kind = edgeKind(e);
13445
13912
  const sel = S.selEdge === e.id;
13913
+ // 选中节点的所有入边/出边 → 亮绿外发光(边自身被选中时已有 is-selected,互斥不叠加)
13914
+ const linked = !sel && (S.sel.has(e.fromNode) || S.sel.has(e.toNode));
13446
13915
  const g = edgeGeom(e);
13447
13916
  return h('g', { key: e.id, className: 'dshic-edge-g' },
13448
13917
  h('path', {
@@ -13451,7 +13920,7 @@ function queueThumb(assetId) {
13451
13920
  }),
13452
13921
  h('path', {
13453
13922
  ref: (el) => { if (el) edgePathEls.set(e.id, el); else edgePathEls.delete(e.id); },
13454
- d: g.d, className: cls('dshic-edge', 'kind-' + kind, sel && 'is-selected'),
13923
+ d: g.d, className: cls('dshic-edge', 'kind-' + kind, sel && 'is-selected', linked && 'is-node-linked'),
13455
13924
  }),
13456
13925
  // 悬停中点显示删除按钮(Toonflow 式)
13457
13926
  h('g', {
@@ -14144,20 +14613,21 @@ function queueThumb(assetId) {
14144
14613
  ].join('\n');
14145
14614
  }
14146
14615
 
14147
- /** 提示词侧的「镜头语言锁」:只带风格参数与负向词,不污染结构化格式。 */
14148
14616
  /**
14149
- * 图片 / 视频提示词的「风格增强块」。
14617
+ * 图片 / 视频提示词的「风格锁」(注入分工契约)。
14150
14618
  *
14151
- * 这是整条链路最容易掉队的一环:剧本与分镜走的是 AI 生成(拿到完整切片),
14152
- * 但图片与视频是「拼装提示词」——如果只带风格参数与负向词,影调的成像/材质/光学、
14153
- * 规格的节奏、题材的场面颗粒就全丢了,于是第一镜对、后面越走越偏。
14619
+ * 分工:导演的运镜手法/镜头语言/细色调在分镜层由 LLM 消化成逐镜 camera/motion/visual
14620
+ * 字段(随结构化正文进请求);技能卡切片只进剧本/分镜的系统提示当教材,绝不原文进
14621
+ * 生成请求——视频编码器有效窗口只有几百 token,教材长文会稀释正文。
14154
14622
  *
14155
14623
  * 按生成能力取切片:
14156
- * kind='prompt' —— 图片与视频。风格参数 + 影调(成像/光比/色彩/介质/光学/材质/特效)
14157
- * + 规格(ASL 与负向词)+ 题材的「常见场面颗粒」+ 三份负向词
14158
- * kind='assets' —— 角色/场景/道具设定图。影调的成像与色彩(不含叙事与剪辑)
14624
+ * 图片(medium='image')—— 紧凑锁:镜头风格 bits + 色彩/影调(截断)+ 场面材料(260B)
14625
+ * + 负向词(700B 总预算);设定图额外带材质响应。
14626
+ * 视频(kind='prompt')—— 总控锁 ≤1.2KB:影调美学短语(成像底层摘要)+ 交付规格
14627
+ * (单镜时长口径)+ 负向词 ≤6 条。全片风格锚(styleAnchor/
14628
+ * style 首句)在正文「风格:」行,逐镜事实以正文为准。
14159
14629
  *
14160
- * 不内联:叙事方法、剪辑节奏、人物表演(这些只对剧本/分镜有意义)。
14630
+ * 不内联(叙事方法、剪辑节奏、运镜词典、题材颗粒长文……):只对剧本/分镜有意义。
14161
14631
  */
14162
14632
  /**
14163
14633
  * 图片生成专用的紧凑风格锁。
@@ -14171,16 +14641,16 @@ function queueThumb(assetId) {
14171
14641
  async function buildImageLockText(P, manifest, profile, k) {
14172
14642
  const parts = [];
14173
14643
  const push = (label, body) => { const b = String(body || '').trim(); if (b) parts.push(label + '\n' + b); };
14174
- /** 按句末标点截断,避免切出半句。 */
14644
+ /** 按句末标点截断,避免切出半句;UTF-8 字节数手算(部分测试沙箱没有 TextEncoder)。 */
14175
14645
  const cap = (text, maxBytes) => {
14176
14646
  const t = String(text || '').replace(/\s+/g, ' ').trim();
14177
14647
  if (!t) return '';
14178
- const enc = new TextEncoder();
14179
- if (enc.encode(t).length <= maxBytes) return t;
14648
+ const bLen = (s) => { let n = 0; for (const ch of String(s)) { const c = ch.codePointAt(0); n += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; } return n; };
14649
+ if (bLen(t) <= maxBytes) return t;
14180
14650
  const heads = t.split(/(?<=[。;;!?])/);
14181
14651
  let out = '';
14182
14652
  for (const h of heads) {
14183
- if (enc.encode(out + h).length > maxBytes) break;
14653
+ if (bLen(out + h) > maxBytes) break;
14184
14654
  out += h;
14185
14655
  }
14186
14656
  return (out || t.slice(0, maxBytes)).trim();
@@ -14265,7 +14735,7 @@ function queueThumb(assetId) {
14265
14735
  }
14266
14736
 
14267
14737
  if (!parts.length) return '';
14268
- return '[画面风格锁] 以下决定画面成色(与正文冲突时以本块为准):' + EOL + parts.join(EOL);
14738
+ return '[画面风格锁] 以下决定画面成色(与正文冲突时以本块为准):\n' + parts.join('\n');
14269
14739
  }
14270
14740
 
14271
14741
  async function buildShotLockText(kind, opts) {
@@ -14287,58 +14757,34 @@ function queueThumb(assetId) {
14287
14757
  const b = String(body || '').trim();
14288
14758
  if (b) parts.push(label + '\n' + b);
14289
14759
  };
14290
- // 负向词跨四层全局收集:单卡内去重不够——导演/题材/规格/影调经常重复同类禁令,
14291
- // 重复注入会稀释权重。统一去重后再给总预算,防止异常卡把视频请求撑成负向词文本墙。
14292
- const negs = [];
14293
- const seenNeg = new Set();
14294
- const addNegs = (phrases) => {
14295
- for (const raw of (phrases || [])) {
14296
- const s = String(raw || '').trim();
14297
- if (s && !seenNeg.has(s.toLowerCase())) { seenNeg.add(s.toLowerCase()); negs.push(s); }
14760
+ // 按句末标点压缩(不切半句):总控锁里唯一允许的压缩方式
14761
+ const capZh = (text, maxBytes) => {
14762
+ const t = String(text || '').replace(/\s+/g, ' ').trim();
14763
+ if (!t) return '';
14764
+ // UTF-8 字节数手算(不依赖 TextEncoder——部分测试沙箱没有该构造器)
14765
+ const bLen = (s) => { let n = 0; for (const ch of String(s)) { const c = ch.codePointAt(0); n += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; } return n; };
14766
+ if (bLen(t) <= maxBytes) return t;
14767
+ const heads = t.split(/(?<=[。;;!?])/);
14768
+ let out = '';
14769
+ for (const h of heads) {
14770
+ if (bLen(out + h) > maxBytes) break;
14771
+ out += h;
14298
14772
  }
14773
+ return (out || t.slice(0, maxBytes)).trim();
14299
14774
  };
14300
-
14301
- // ① 导演透镜:风格参数 YAML(机读、可核对)+ 灯光与色彩(成型规则)
14302
- const lensEntry = profile.lens ? (manifest.lenses || []).find((x) => x.id === profile.lens) : null;
14303
- if (lensEntry) {
14304
- const md = await readPackCard('lens', lensEntry.file);
14305
- if (md) {
14306
- const y = P.yamlBlock(md);
14307
- if (y) push('本片风格参数(逐条执行,不得改动数值):', y);
14308
- const light = P.pickSections(md, k);
14309
- if (light) push('导演的光线与色彩规则:', light);
14310
- }
14311
- }
14312
-
14313
- // ② 影调质感:按能力切片(prompt 取成像/光比/色彩/介质/光学/材质/特效;assets 取成像与色彩)
14775
+ // —— 总控锁 v2(注入分工):导演的运镜手法/镜头语言/细色调已在分镜层被 LLM 消化成
14776
+ // 每镜 camera/motion/visual 字段(随结构化正文进请求),这里不再倒教材——视频编码器
14777
+ // 有效窗口只有几百 token,长锁会稀释正文。锁只保留全片级总控元素,总量 ≤1.2KB。——
14778
+ // ① 影调美学短语:影调卡「成像底层」摘要——全片质感的总控兜底(逐镜色调已写进 visual)
14314
14779
  const lookEntry = profile.look ? (manifest.looks || []).find((x) => x.id === profile.look) : null;
14315
14780
  if (lookEntry) {
14316
14781
  const md = await readPackCard('look', lookEntry.file);
14317
14782
  if (md) {
14318
- const body = P.pickSections(md, k);
14319
- if (body) push('影调与材质(画面必须长成这样):', body);
14783
+ const essence = P.sectionText(md, '成像底层') || P.sectionText(md, '质感基线') || '';
14784
+ if (essence) push('影调质感:', capZh(essence, 200));
14320
14785
  }
14321
14786
  }
14322
-
14323
- // ③ 题材:只取「常见场面颗粒」(可拍摄的物件/动作/空间),这是提示词最需要的具体材料
14324
- for (const gid of (profile.genres || [])) {
14325
- const ge = (manifest.genres || []).find((x) => x.id === gid) || null;
14326
- const ie = ge ? null : (manifest.industries || []).find((x) => x.id === gid);
14327
- const entry = ge || ie;
14328
- if (!entry) continue;
14329
- const md = await readPackCard(ge ? 'genre' : 'industry', entry.file);
14330
- if (!md) continue;
14331
- const granules = P.sectionText(md, '常见场面颗粒') || P.sectionText(md, '参考镜头') || P.sectionText(md, '视觉母题');
14332
- if (granules) push((ge ? '题材的场面颗粒' : '行业视觉母题') + '(' + entry.name + '):', granules);
14333
- // 题材的「禁止漂移」是画面层约束(能出现什么物件、不能出现什么年代错误、不许用什么代替故事),
14334
- // 以前只在 script 切片里出现、进不了 prompt,等于题材对成片没有约束力。这里补上。
14335
- const forbid = P.sectionText(md, '禁止漂移');
14336
- if (forbid) push('本题材的画面禁项(' + entry.name + ',必须排除):', forbid);
14337
- // 题材级负向词与其它层合并,统一去重后在块尾注入
14338
- addNegs(P.negativePhrases(md));
14339
- }
14340
-
14341
- // ④ 规格:节奏与负向词(画幅不在这里定,由视频节点选)
14787
+ // ② 交付规格:单镜时长口径(规格卡)
14342
14788
  const formEntry = profile.form ? (manifest.forms || []).find((x) => x.id === profile.form) : null;
14343
14789
  if (formEntry) {
14344
14790
  const md = await readPackCard('form', formEntry.file);
@@ -14347,38 +14793,37 @@ function queueThumb(assetId) {
14347
14793
  const bits = [];
14348
14794
  if (spec.asl_floor_s) bits.push('单镜不短于 ' + spec.asl_floor_s + 's');
14349
14795
  if (spec.asl_target_s) bits.push('平均镜长 ' + spec.asl_target_s + 's');
14350
- if (bits.length) push('交付规格(' + formEntry.name + '):', bits.join(';'));
14351
- addNegs(P.negativePhrases(md));
14796
+ if (bits.length) push('交付规格:', bits.join(';'));
14352
14797
  }
14353
14798
  }
14354
-
14355
- // ⑤ 透镜与影调负向词:和题材/规格合并,块尾统一注入
14356
- for (const layer of ['lens', 'look']) {
14357
- const id = layer === 'lens' ? profile.lens : profile.look;
14358
- const entry = id ? (manifest[layer === 'lens' ? 'lenses' : 'looks'] || []).find((x) => x.id === id) : null;
14799
+ // ③ 负向词:四层合并去重后只内联前 6 条——内联负向词会与正向争夺注意力(稀释规则),
14800
+ // 只点名最可能出现的风险类;有独立负向词字段的厂商应改走字段(runner 侧,后续接通)
14801
+ const negs = [];
14802
+ const seenNeg = new Set();
14803
+ const addNegs = (phrases) => {
14804
+ for (const raw of (phrases || [])) {
14805
+ const s = String(raw || '').trim();
14806
+ if (s && !seenNeg.has(s.toLowerCase())) { seenNeg.add(s.toLowerCase()); negs.push(s); }
14807
+ }
14808
+ };
14809
+ for (const [layer, id] of [['lens', profile.lens], ['look', profile.look], ['form', profile.form]]) {
14810
+ if (!id) continue;
14811
+ const entry = (manifest[layer === 'lens' ? 'lenses' : layer === 'look' ? 'looks' : 'forms'] || []).find((x) => x.id === id);
14359
14812
  if (!entry) continue;
14360
14813
  const md = await readPackCard(layer, entry.file);
14361
- if (!md) continue;
14362
- addNegs(P.negativePhrases(md));
14814
+ if (md) addNegs(P.negativePhrases(md));
14363
14815
  }
14364
-
14365
- if (negs.length) {
14366
- // 预算按 UTF-8 字节计算(pack.js 的 utf8Bytes 与浏览器/Node 同口径);逗号分隔符也计入。
14367
- // 超过预算的尾部短语直接截掉,不做半句截断——截半条负向词可能反转语义。
14368
- const kept = [];
14369
- let bytes = 0;
14370
- for (const s of negs) {
14371
- const need = P.utf8Bytes(s) + (kept.length ? 2 : 0);
14372
- if (!need || bytes + need > 2400) continue;
14373
- kept.push(s);
14374
- bytes += need;
14375
- }
14376
- if (kept.length) push('全局负向词(必须排除):', kept.join(', '));
14816
+ for (const gid of (profile.genres || [])) {
14817
+ const ge = (manifest.genres || []).find((x) => x.id === gid);
14818
+ if (!ge) continue;
14819
+ const md = await readPackCard('genre', ge.file);
14820
+ if (md) addNegs(P.negativePhrases(md));
14377
14821
  }
14822
+ if (negs.length) push('必须排除:', negs.slice(0, 6).join(', '));
14378
14823
 
14379
14824
  if (!parts.length) return '';
14380
- const head = '[风格增强锁] 以下分块直接决定画面成败,与提示词正文冲突时以本块为准:';
14381
- return head + '\n' + parts.join('\n\n');
14825
+ const head = '[全片风格锚] 以下为全片级总控;逐镜画面与动作以正文为准:';
14826
+ return head + '\n' + parts.join('\n');
14382
14827
  }
14383
14828
 
14384
14829
  async function loadModelIndex() {
@@ -17580,6 +18025,16 @@ const DIRECTOR_KEY_HELP = [
17580
18025
  * 搜索/分类/项目筛选与分页都在客户端做;卡片 = AssetCard(缩略图或视频首帧 + 名称 + 分类 + 时间,
17581
18026
  * 预览/下载/添加到画布 全部保留)。右侧面板不再有资产页签。 */
17582
18027
  const ASSET_PAGE_SIZE = 24;
18028
+ /** 资产分页跳转(纯函数):页码输入 → 0-based 页。
18029
+ * 非数字/空/小数 → null(保持当前页);越界夹取到 1..pageCount。 */
18030
+ function assetsPageIndex(raw, pageCount) {
18031
+ const t = String(raw == null ? '' : raw).trim();
18032
+ if (!/^\d+$/.test(t)) return null;
18033
+ const n = parseInt(t, 10);
18034
+ if (!Number.isFinite(n)) return null;
18035
+ const pc = Math.max(1, Number(pageCount) || 1);
18036
+ return Math.min(Math.max(1, n), pc) - 1;
18037
+ }
17583
18038
  function AssetsTab({ variant } = {}) {
17584
18039
  void variant;
17585
18040
  const [assets, setAssets] = useState([]);
@@ -17598,13 +18053,16 @@ const DIRECTOR_KEY_HELP = [
17598
18053
  const [craftFor, setCraftFor] = useState(null);
17599
18054
  const [delTarget, setDelTarget] = useState(null); // 待确认删除的资产(确认框见 DeleteAssetModal)
17600
18055
  const [assetName, setAssetName] = useState(''); // 删除确认框的输入内容
18056
+ const [selIds, setSelIds] = useState(() => new Set()); // 批量选择(资产 id):选中后一键按列导入画布 / 批量删除
18057
+ const [batchDel, setBatchDel] = useState(false); // 批量删除确认框
18058
+ const [pageDraft, setPageDraft] = useState(null); // 页码输入草稿(null = 显示当前页)
17601
18059
  const fileRef = useRef(null);
17602
18060
  // 搜索防抖:资产多时避免每个按键都过一遍全量过滤
17603
18061
  useEffect(() => {
17604
18062
  const t = setTimeout(() => setQDeb(search), 300);
17605
18063
  return () => clearTimeout(t);
17606
18064
  }, [search]);
17607
- useEffect(() => { setPage(0); }, [filter, qDeb, scope]);
18065
+ useEffect(() => { setPage(0); setPageDraft(null); }, [filter, qDeb, scope]);
17608
18066
  useEffect(() => {
17609
18067
  probeCraft();
17610
18068
  let ok = true;
@@ -17700,6 +18158,52 @@ const DIRECTOR_KEY_HELP = [
17700
18158
  });
17701
18159
  bumpView();
17702
18160
  };
18161
+ // ---------- 批量选择:一键按列导入画布 / 批量删除 ----------
18162
+ // 落点由 layoutBatchColumns 决定(现有节点最右侧之外按列铺开,一列 ≤5,零重叠),
18163
+ // 音频资产不成节点(与单个添加同一口径),导入时跳过并提示数量。
18164
+ const selList = assets.filter((a) => selIds.has(a.id));
18165
+ const addableList = selList.filter((a) => a.kind !== 'audio');
18166
+ const audioN = selList.length - addableList.length;
18167
+ const allPageSel = () => shown.length > 0 && shown.every((a) => selIds.has(a.id));
18168
+ 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; });
18169
+ const selectAllPage = () => setSelIds((prev) => {
18170
+ const n = new Set(prev);
18171
+ if (allPageSel()) shown.forEach((a) => n.delete(a.id));
18172
+ else shown.forEach((a) => n.add(a.id));
18173
+ return n;
18174
+ });
18175
+ const clearSel = () => setSelIds(new Set());
18176
+ const addSelectedToCanvas = () => {
18177
+ if (!addableList.length) { toast(T('assetsOnlyAudio')); return; }
18178
+ // 检测画布现有节点位置:批量落点在其最右侧之外按列铺开,绝不与现有节点重叠
18179
+ const rects = Object.values(S.graph.nodes)
18180
+ .filter((nd) => nd.type !== 'group' && !(nd.data && nd.data.hidden))
18181
+ .map((nd) => ({ x: Number(nd.x) || 0, y: Number(nd.y) || 0, w: Number(nd.w) || 280, h: Number(nd.h) || 160 }));
18182
+ const items = addableList.map((a) => (a.kind === 'text' ? { w: 360, h: 220 } : nodeSizeForRatio('16:9', { hasFooter: false })));
18183
+ const pts = layoutBatchColumns(rects, items);
18184
+ const newIds = [];
18185
+ update((s) => {
18186
+ addableList.forEach((a, k) => {
18187
+ const nd = newNode(a.kind === 'text' ? 'text' : a.kind, pts[k]);
18188
+ if (a.kind === 'text') nd.data.text = a.text || '';
18189
+ else { nd.data.assetId = a.id; nd.data.status = 'done'; }
18190
+ s.graph.nodes[nd.id] = nd;
18191
+ newIds.push(nd.id);
18192
+ });
18193
+ s.sel = new Set(newIds); s.selEdge = null;
18194
+ });
18195
+ pushHistory();
18196
+ flushSave();
18197
+ setSelIds(new Set());
18198
+ toast(T('assetsAdded').replace('{n}', String(addable.length)) + (audioN ? ',' + T('assetsAudioSkip').replace('{n}', String(audioN)) : ''));
18199
+ };
18200
+ const delSelected = async () => {
18201
+ const list = selList.slice();
18202
+ setBatchDel(false);
18203
+ for (const a of list) { try { await del(a); } catch { /* 单个失败继续其余 */ } }
18204
+ setSelIds(new Set());
18205
+ toast(T('assetsDeletedN').replace('{n}', String(list.length)));
18206
+ };
17703
18207
  // 资产重命名:服务端写回(SQL/JSON 各自落库)+ 刷新名称缓存(@引用与连线名称都吃这份缓存)
17704
18208
  const rename = async (a, name) => {
17705
18209
  if (S.store) {
@@ -17742,6 +18246,19 @@ const DIRECTOR_KEY_HELP = [
17742
18246
  const pageCount = Math.max(1, Math.ceil(filtered.length / ASSET_PAGE_SIZE));
17743
18247
  const pageSafe = Math.min(Math.max(0, page), pageCount - 1);
17744
18248
  const shown = filtered.slice(pageSafe * ASSET_PAGE_SIZE, pageSafe * ASSET_PAGE_SIZE + ASSET_PAGE_SIZE);
18249
+ /** 提交页码输入:回车/失焦;非法文本保持当前页,越界夹取(UI-RULES 第 15 条口径)。 */
18250
+ const commitPageJump = () => {
18251
+ const idx = assetsPageIndex(pageDraft, pageCount);
18252
+ if (idx != null) setPage(idx);
18253
+ setPageDraft(null);
18254
+ };
18255
+ /** 翻页:输入框有草稿时先以草稿为基准(避免 blur 提交与按钮翻页互相覆盖)。 */
18256
+ const goPage = (delta) => {
18257
+ const idx = pageDraft != null ? assetsPageIndex(pageDraft, pageCount) : null;
18258
+ const base = idx != null ? idx : pageSafe;
18259
+ setPage(Math.min(Math.max(0, base + delta), pageCount - 1));
18260
+ setPageDraft(null);
18261
+ };
17745
18262
  return [
17746
18263
  h('div', { key: 'chips', className: 'dshic-chips' },
17747
18264
  [{ id: 'all', label: T('catAll') }].concat(CATEGORIES.map((c) => ({ id: c, label: catLabel(c) }))).map((c) =>
@@ -17763,8 +18280,61 @@ const DIRECTOR_KEY_HELP = [
17763
18280
  .concat(S.projects.map((p) => ({ value: p.id, label: p.name }))),
17764
18281
  onChange: (v) => setScope(v),
17765
18282
  }),
17766
- 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')),
17767
- 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')),
18283
+ // 工具栏(项目下一行):所有操作按钮 + 分页集中在一行,窄窗口自动换行、分页始终靠右。
18284
+ // 按钮统一「透明底 + 1px 线框 + 文字」(UI-RULES:禁止灰底色块)。
18285
+ h('div', { key: 'toolbar', className: 'dshic-asset-toolbar', 'data-role': 'assets-toolbar' },
18286
+ h('div', { className: 'dshic-asset-toolbar-main' },
18287
+ h('button', {
18288
+ type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-sync-all',
18289
+ disabled: !craftOkCached(), title: craftOkCached() ? T('craftSyncAll') : T('craftUnreachable'),
18290
+ onClick: syncAll, onPointerDown: (e) => e.stopPropagation(),
18291
+ }, Ic('upload', 11), T('craftSyncAll')),
18292
+ h('button', {
18293
+ type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-import',
18294
+ onClick: () => { if (fileRef.current) fileRef.current.click(); },
18295
+ }, Ic('upload', 11), T('import')),
18296
+ h('label', { className: 'dshic-asset-selall', onPointerDown: (e) => e.stopPropagation() },
18297
+ h('input', { type: 'checkbox', checked: allPageSel(), disabled: !shown.length, onChange: selectAllPage }),
18298
+ T('assetsSelAllPage')),
18299
+ // 批量操作:选中 >0 时出现,与导入同一行(不另占一行)
18300
+ selIds.size
18301
+ ? h('div', { key: 'batchbar', className: 'dshic-asset-batch', 'data-role': 'assets-batch-bar' },
18302
+ 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 + ')'),
18303
+ 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 + ')'),
18304
+ h('button', { type: 'button', className: 'dshic-toolbtn', 'data-action': 'assets-clear-sel', onClick: clearSel, onPointerDown: (e) => e.stopPropagation() }, T('assetsClearSel')),
18305
+ audioN ? h('span', { className: 'dshic-asset-audiohint' }, T('assetsAudioSkip').replace('{n}', String(audioN))) : null,
18306
+ )
18307
+ : null,
18308
+ ),
18309
+ // 分页(客户端分页):‹ [页码输入] / N › + 总数;Enter/失焦跳转,Esc 取消,越界夹取
18310
+ h('div', { key: 'pager', className: 'dshic-asset-pager', 'data-role': 'assets-pager' },
18311
+ h('button', {
18312
+ type: 'button', className: 'dshic-toolbtn is-icon', 'data-action': 'assets-page-prev', title: T('pagePrev'),
18313
+ disabled: pageSafe <= 0, onClick: () => goPage(-1), onPointerDown: (e) => e.stopPropagation(),
18314
+ }, '‹'),
18315
+ h('div', { className: 'dshic-asset-pagebox' },
18316
+ h('input', {
18317
+ className: 'dshic-asset-pageinput', type: 'text', inputMode: 'numeric',
18318
+ 'data-role': 'assets-page-input', 'aria-label': T('pageNumber'),
18319
+ value: pageDraft != null ? pageDraft : String(pageSafe + 1),
18320
+ onPointerDown: (e) => e.stopPropagation(),
18321
+ onClick: (e) => e.stopPropagation(),
18322
+ onChange: (e) => setPageDraft(e.target.value),
18323
+ onBlur: commitPageJump,
18324
+ onKeyDown: (e) => {
18325
+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); commitPageJump(); }
18326
+ else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); setPageDraft(null); }
18327
+ },
18328
+ }),
18329
+ h('span', { className: 'dshic-asset-pagetotal', 'data-role': 'assets-page-total' }, '/ ' + pageCount),
18330
+ ),
18331
+ h('button', {
18332
+ type: 'button', className: 'dshic-toolbtn is-icon', 'data-action': 'assets-page-next', title: T('pageNext'),
18333
+ disabled: pageSafe >= pageCount - 1, onClick: () => goPage(1), onPointerDown: (e) => e.stopPropagation(),
18334
+ }, '›'),
18335
+ h('span', { className: 'dshic-asset-pagecount', 'data-role': 'assets-page-info' }, T('assetsTotalCount').replace('{n}', String(filtered.length))),
18336
+ ),
18337
+ ),
17768
18338
  h('input', { key: 'file', ref: fileRef, type: 'file', accept: 'image/*,video/*', multiple: true, style: { display: 'none' }, onChange: onImport }),
17769
18339
  loading && !assets.length
17770
18340
  ? h('div', { key: 'loading', className: 'dshic-hint' }, T('aiRunning'))
@@ -17775,25 +18345,25 @@ const DIRECTOR_KEY_HELP = [
17775
18345
  key: a.id, a, onAdd: addNodeFor, onDel: (x) => setDelTarget(x), onCat: changeCategory,
17776
18346
  onRename: rename, onMove: moveAsset,
17777
18347
  projectName: projectName(a.projectId),
18348
+ checked: selIds.has(a.id), onToggleSel: toggleSel,
17778
18349
  })),
17779
18350
  ),
17780
- // 分页(客户端分页:资产数据源已是全量 assetsForPicker)
17781
- h('div', { key: 'pager', className: 'dshic-asset-pager' },
17782
- h('button', {
17783
- type: 'button', className: 'dshic-mini is-ghost', 'data-action': 'assets-page-prev',
17784
- disabled: pageSafe <= 0, onClick: () => setPage(pageSafe - 1), onPointerDown: (e) => e.stopPropagation(),
17785
- }, '‹ ' + T('pagePrev')),
17786
- h('span', { 'data-role': 'assets-page-info' }, (pageSafe + 1) + ' / ' + pageCount + ' · ' + filtered.length + ' / ' + assets.length),
17787
- h('button', {
17788
- type: 'button', className: 'dshic-mini is-ghost', 'data-action': 'assets-page-next',
17789
- disabled: pageSafe >= pageCount - 1, onClick: () => setPage(pageSafe + 1), onPointerDown: (e) => e.stopPropagation(),
17790
- }, T('pageNext') + ' ›'),
17791
- ),
17792
18351
  delTarget ? h(DeleteAssetModal, {
17793
18352
  key: 'delasset', target: delTarget, name: assetName, setName: setAssetName,
17794
18353
  onCancel: () => { setDelTarget(null); setAssetName(''); },
17795
18354
  onConfirm: async () => { const t = delTarget; setDelTarget(null); setAssetName(''); await del(t); },
17796
18355
  }) : null,
18356
+ batchDel ? h('div', { className: 'dshic-modal-overlay', onPointerDown: (e) => { if (e.target === e.currentTarget) setBatchDel(false); } },
18357
+ h('div', { className: 'dshic-modal' },
18358
+ h('div', { className: 'dshic-modal-title' }, T('delAssetTitle') + ' × ' + selIds.size),
18359
+ h('div', { className: 'dshic-modal-warn' },
18360
+ T('assetsBatchDelWarn'),
18361
+ h('div', { className: 'dshic-modal-name', style: { marginTop: 4 } },
18362
+ selList.slice(0, 3).map((a) => a.name || '—').join('、') + (selList.length > 3 ? ' …' : ''))),
18363
+ h('div', { className: 'dshic-modal-actions' },
18364
+ h('button', { type: 'button', className: 'dshic-btn dshic-btn-outline', onClick: () => setBatchDel(false) }, T('cancel')),
18365
+ h('button', { type: 'button', className: 'dshic-btn is-danger', onClick: delSelected }, T('doDelete'))),
18366
+ )) : null,
17797
18367
  ];
17798
18368
  }
17799
18369
  /** 删除资产确认框:与项目删除同一套交互 —— 名字可选中,手打确认,不做一键填入。 */
@@ -17829,7 +18399,7 @@ const DIRECTOR_KEY_HELP = [
17829
18399
  ));
17830
18400
  }
17831
18401
 
17832
- function AssetCard({ a, onAdd, onDel, onCat, onRename, onMove, projectName }) {
18402
+ function AssetCard({ a, checked = false, onToggleSel = () => {}, onAdd, onDel, onCat, onRename, onMove, projectName }) {
17833
18403
  const url = useAssetUrl(a.kind === 'text' ? null : a.id);
17834
18404
  const [craftFor, setCraftFor] = useState(false);
17835
18405
  const [renaming, setRenaming] = useState(false);
@@ -17854,7 +18424,17 @@ const DIRECTOR_KEY_HELP = [
17854
18424
  onClick: startRename,
17855
18425
  }, Ic('pencil', 11));
17856
18426
  const downloadName = (a.name || 'asset') + extForDownload(a.mime, a.name, a.kind);
17857
- return h('div', { className: 'dshic-asset', onClick: a.kind === 'audio' ? undefined : () => onAdd(a), title: a.kind === 'text' ? T('textAssetHint') : a.kind === 'audio' ? '' : T('addAssetNode') },
18427
+ return h('div', {
18428
+ className: cls('dshic-asset', checked && 'is-checked'),
18429
+ onClick: () => onToggleSel(a),
18430
+ onDoubleClick: a.kind === 'audio' ? undefined : () => onAdd(a), // 双击 = 单个直接添加(熟练用户捷径)
18431
+ title: T('assetClickHint'),
18432
+ },
18433
+ // 复选框:批量选择入口(单击卡片也切换选中;图标按钮仍 stopPropagation 不受影响)
18434
+ h('input', { type: 'checkbox', className: 'dshic-asset-check', checked: !!checked,
18435
+ onPointerDown: (e) => e.stopPropagation(),
18436
+ onClick: (e) => { e.stopPropagation(); onToggleSel(a); },
18437
+ onChange: () => {} }),
17858
18438
  a.kind === 'text'
17859
18439
  ? h('div', { className: 'dshic-textcard is-title' },
17860
18440
  renaming ? nameInput : h('div', { className: 'dshic-textcard-title', title: a.name || '' }, a.name || T('scriptAssetPrefix')),
@@ -18752,6 +19332,7 @@ const DIRECTOR_KEY_HELP = [
18752
19332
  const next = {
18753
19333
  worldview: String(obj.worldview || cur.worldview || '').trim(),
18754
19334
  style: String(obj.style || cur.style || '').trim(),
19335
+ styleAnchor: String(obj.styleAnchor !== undefined ? obj.styleAnchor : (cur.styleAnchor || '')).trim(),
18755
19336
  characters: merge(cur.characters, list(obj.characters)),
18756
19337
  scenes: merge(cur.scenes, list(obj.scenes)),
18757
19338
  props: merge(cur.props, list(obj.props)),
@@ -19584,6 +20165,17 @@ const DIRECTOR_KEY_HELP = [
19584
20165
  onPointerDown: (e) => e.stopPropagation(),
19585
20166
  onClick: applyUpdate,
19586
20167
  }, Ic('download', 11), T('updateGo')),
20168
+ // 更新源:自动检测(按网络环境)/ 手动覆盖官方源或大陆镜像源(如图选择的 radio 形态)
20169
+ h('span', { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 11, opacity: 0.95 }, onPointerDown: (e) => e.stopPropagation() },
20170
+ T('updateSrcTitle') + ':',
20171
+ ...[['auto', 'updateSrcAuto'], ['official', 'updateSrcOfficial'], ['china', 'updateSrcChina']].map(([val, key]) =>
20172
+ h('label', { key: val, style: { display: 'flex', alignItems: 'center', gap: 3, cursor: 'pointer' } },
20173
+ h('input', { type: 'radio', name: 'dshic-update-src', checked: (S.updateRegistry || 'auto') === val, disabled: !!S.updateBusy, onChange: () => setUpdateSource(val) }),
20174
+ T(key))),
20175
+ S.updateRegistryResolved
20176
+ ? h('span', { style: { opacity: 0.75 } }, '(' + T('updateSrcNow') + ':' + (S.updateRegistryResolved === 'china' ? T('updateSrcChina') : T('updateSrcOfficial')) + ')')
20177
+ : null,
20178
+ ),
19587
20179
  h('a', {
19588
20180
  href: 'https://github.com/NINKCH/dsh-infinite_canvas/releases', target: '_blank', rel: 'noreferrer',
19589
20181
  style: { color: 'inherit', opacity: 0.8, fontSize: 11 },
@@ -19985,8 +20577,14 @@ const DIRECTOR_KEY_HELP = [
19985
20577
  probeCraft();
19986
20578
  // 检查更新(Host RPC;Host 旧版未带此方法时静默)
19987
20579
  checkUpdate(true);
20580
+ // 更新源配置(自动探测/手动覆盖;旧 Host 无此 RPC 时静默降级为仅展示)
20581
+ fetchUpdateRegistry();
19988
20582
  // 数据根目录(Host 旧版静默降级为 IndexedDB 模式);就绪后把本地遗留 blob 搬进服务端(v1 旧布局由 Host 侧自动迁移)
19989
20583
  refreshDataRoot().then(() => migrateLegacyAssets('boot')).catch(() => { /* 静默 */ });
20584
+ // 资产指针自愈:显式调度,不依赖同步回调(普通启动没有文档变更信号,mergeHostDoc 不会触发)。
20585
+ // 2s 主跑 + 10s 兜底重试(图/资产清单加载慢时第二轮补上);scheduleRepair 自带 1.5s 防抖。
20586
+ setTimeout(() => scheduleRepair(), 2000);
20587
+ setTimeout(() => scheduleRepair(), 10000);
19990
20588
  // 对话 ↔ 画布同步(启动一次 + 3s 轮询;旧 Host 自动停轮询)
19991
20589
  hostSyncTick().then(() => pushAllProjectsToHost());
19992
20590
  const hostSyncTimer = setInterval(() => hostSyncTick(), 3000);
@@ -20143,6 +20741,14 @@ const DIRECTOR_KEY_HELP = [
20143
20741
  wheelScrollTarget,
20144
20742
  // 建点布局强控制(一类型一列 + 碰撞下移):addNodeAt 收口 + 纯函数,供回归测试直接驱动
20145
20743
  nextNodePosClient, addNodeAt,
20744
+ // 资产批量导入落点:现有节点最右侧之外按列铺开(一列 ≤5,零重叠),供回归测试直接断言
20745
+ layoutBatchColumns,
20746
+ // 资产页分页跳转(页码输入 → 0-based 页;非法文本 null、越界夹取)
20747
+ assetsPageIndex,
20748
+ // 历史条死条目裁剪 / 资产回链候选挑选与回链计划(纯函数,供回归测试直接断言)
20749
+ pruneDeadHistory, repairPickAsset, repairPlan,
20750
+ // 媒体节点指针空值保护(Host 合并不得用 null 覆盖本地有效 assetId/lastAssetId)
20751
+ protectMediaPointer,
20146
20752
  graph: () => JSON.parse(JSON.stringify(S.graph)), // 建点结果断言用(与 SYNC.graph 同口径)
20147
20753
  addGraphNodes: (list) => { for (const n of (list || [])) S.graph.nodes[n.id] = n; }, // 测试播种(写入活状态)
20148
20754
  // 下拉自定义数值的纯函数:范围夹取 / 整数与小数口径(分镜数、单段上限共用)
@@ -20182,13 +20788,15 @@ const DIRECTOR_KEY_HELP = [
20182
20788
  expandStoryboard,
20183
20789
  // 纯函数出口:资产设定图提示词生成器(不依赖 DOM,可直接断言)
20184
20790
  buildAssetSheetPrompt, assetSheetNodeSpec,
20791
+ // 纯函数出口:剧本 → 场景切分(供 scripts/test-script-scenes.mjs 断言分场与片尾清单剥离)
20792
+ parseScriptScenes,
20185
20793
  };
20186
20794
  // IC-01:下载侧扩展名判定的纯函数出口(供 scripts/test-download-ext.mjs 直接断言)
20187
20795
  window.__DSH_IC_MEDIA__ = { extForDownload };
20188
20796
  // IC-04:参考图上传三件套的纯函数出口(供 scripts/test-image-upload.mjs 直接断言)
20189
20797
  window.__DSH_IC_IMGREF__ = { rawImageDims, sniffImageEncoding, registerReferenceAsset };
20190
20798
  // IC-03:视频厂商识别/前缀归一化的纯函数出口(供 scripts/test-vendor-detect.mjs 直接断言)
20191
- window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState };
20799
+ 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, bibleStyleAnchor };
20192
20800
  // 按镜头切段(分段生成本身就是最容易出错的地方):规划器 + 强弱模型分流 + 节点段区间解析
20193
20801
  // 供 scripts/test-segment-plan.mjs 直接断言
20194
20802
  window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };