@ninkch/dsh-infinite-canvas 0.19.19 → 0.19.21
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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/assets/canvas-director/genres/absurd-parable.md +33 -35
- package/assets/canvas-director/genres/action-mission.md +36 -24
- package/assets/canvas-director/genres/adventure.md +34 -35
- package/assets/canvas-director/genres/broken-mirror-reunion.md +35 -77
- package/assets/canvas-director/genres/class-vertical.md +36 -36
- package/assets/canvas-director/genres/counterattack.md +35 -24
- package/assets/canvas-director/genres/county-drift.md +35 -35
- package/assets/canvas-director/genres/crime-police.md +36 -35
- package/assets/canvas-director/genres/family-melodrama.md +35 -35
- package/assets/canvas-director/genres/family-relation.md +38 -24
- package/assets/canvas-director/genres/fantasy.md +36 -38
- package/assets/canvas-director/genres/gambling-den.md +35 -35
- package/assets/canvas-director/genres/gunstandoff.md +35 -35
- package/assets/canvas-director/genres/hk-retro.md +35 -35
- package/assets/canvas-director/genres/identity-swap.md +37 -24
- package/assets/canvas-director/genres/institutional-eccentric.md +35 -35
- package/assets/canvas-director/genres/mo-lei-tau.md +36 -37
- package/assets/canvas-director/genres/modern-urban.md +34 -35
- package/assets/canvas-director/genres/multi-thread-caper.md +35 -35
- package/assets/canvas-director/genres/neon-dystopia.md +36 -35
- package/assets/canvas-director/genres/parent-child-secret.md +40 -75
- package/assets/canvas-director/genres/period-power-struggle.md +38 -24
- package/assets/canvas-director/genres/rebirth-transmigration.md +37 -24
- package/assets/canvas-director/genres/revenge-face-slap.md +38 -24
- package/assets/canvas-director/genres/shanhaijing-myth.md +85 -40
- package/assets/canvas-director/genres/slice-of-life.md +36 -24
- package/assets/canvas-director/genres/smalltown-uncanny.md +34 -35
- package/assets/canvas-director/genres/social-traverse.md +34 -35
- package/assets/canvas-director/genres/survival-fate.md +35 -35
- package/assets/canvas-director/genres/suspense-rule.md +38 -24
- package/assets/canvas-director/genres/system-flow.md +38 -24
- package/assets/canvas-director/genres/wasteland-chase.md +35 -35
- package/assets/canvas-director/genres/wealthy-romance.md +38 -24
- package/assets/canvas-director/genres/workplace-comedy.md +37 -24
- package/assets/canvas-director/genres/wuxia.md +35 -35
- package/assets/canvas-director/genres/xianxia-cultivation.md +38 -24
- package/assets/canvas-director/genres/youth-distance.md +35 -35
- package/assets/canvas-director/pack.js +3 -2
- package/assets/canvas-studio/SKILL.md +14 -0
- package/client.js +648 -41
- package/docs/UI-RULES.md +4 -0
- package/index.js +692 -18
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -297,7 +297,7 @@ function revealCanvasInRight() {
|
|
|
297
297
|
const MULTI_INPUT_PORTS = new Set(['ref', 'char', 'scene', 'prop']);
|
|
298
298
|
// 分镜端口期望的资产分类(仅用于连接时的非阻断提示)
|
|
299
299
|
const PORT_CATEGORY = { char: 'character', scene: 'scene', prop: 'prop' };
|
|
300
|
-
const CATEGORIES = ['character', 'scene', 'prop', 'script', 'storyboard', 'audio', 'finalcut', '
|
|
300
|
+
const CATEGORIES = ['character', 'scene', 'prop', 'script', 'storyboard', 'audio', 'finalcut', 'general'];
|
|
301
301
|
const RATIOS = ['16:9', '9:16', '1:1', '4:3', '3:4', '21:9'];
|
|
302
302
|
const IMAGE_SIZES = ['1K', '2K', '4K'];
|
|
303
303
|
// 时长选项放宽到 30s(万相 3.0 等支持长视频);各厂商上限不同——超限由接口报错,系统不做静默截断
|
|
@@ -882,7 +882,7 @@ function revealCanvasInRight() {
|
|
|
882
882
|
'projectName': '项目名称',
|
|
883
883
|
'renameHint': '双击名称重命名',
|
|
884
884
|
'delProjectHint': '删除项目及其资产',
|
|
885
|
-
'import': '
|
|
885
|
+
'import': '导入',
|
|
886
886
|
'addAssetNode': '添加到画布',
|
|
887
887
|
'download': '下载',
|
|
888
888
|
'viewOriginal': '查看原图',
|
|
@@ -956,6 +956,22 @@ function revealCanvasInRight() {
|
|
|
956
956
|
'keysTitle': '快捷键与操作',
|
|
957
957
|
'guideDesc': '在对话旁直接分镜、生成视频与成片',
|
|
958
958
|
'hostTakenTitle': '画布已在另一侧打开',
|
|
959
|
+
// —— 会话↔画布绑定(composer 画布选择器)——
|
|
960
|
+
'bindSessionOnly': '仅会话',
|
|
961
|
+
'bindCreateProjectAction': '创建项目',
|
|
962
|
+
'bindNewCanvas': '新建子画布',
|
|
963
|
+
'bindNewCanvasPlaceholder': '',
|
|
964
|
+
'bindOpenCanvas': '打开画布',
|
|
965
|
+
'bindOccupied': '占用中',
|
|
966
|
+
'bindFail': '绑定失败',
|
|
967
|
+
'bindCreating': '创建中…',
|
|
968
|
+
'bindHostStale': '宿主插件是旧版本:请完全退出并重启 DeepSeek Harness 后再试',
|
|
969
|
+
'bindChipBound': '{project}·{name}',
|
|
970
|
+
// —— 记忆查看器(统一弹窗「记忆」页签)——
|
|
971
|
+
'memViewerTab': '记忆',
|
|
972
|
+
'memViewerEmpty': '项目还没有记忆。各集会话在创作中用 canvas_write_memory 回写后,这里能看到每一集的记忆索引与全文。',
|
|
973
|
+
'memRefresh': '刷新',
|
|
974
|
+
'memViewerHint': '点任一集查看完整记忆(只读)',
|
|
959
975
|
'hostTakenHint': '同一时刻画布只能在一处运行(共享同一份节点与生成状态),点击下方按钮把画布切换到这里。',
|
|
960
976
|
'hostTakeOver': '把画布切换到这里',
|
|
961
977
|
'keysHint': '点击按钮收起;Esc 也可关闭',
|
|
@@ -1829,7 +1845,7 @@ function revealCanvasInRight() {
|
|
|
1829
1845
|
'projectName': 'Project name',
|
|
1830
1846
|
'renameHint': 'Double-click to rename',
|
|
1831
1847
|
'delProjectHint': 'Delete project and its assets',
|
|
1832
|
-
'import': 'Import
|
|
1848
|
+
'import': 'Import',
|
|
1833
1849
|
'addAssetNode': 'Add to canvas',
|
|
1834
1850
|
'download': 'Download',
|
|
1835
1851
|
'viewOriginal': 'View original',
|
|
@@ -1904,6 +1920,22 @@ function revealCanvasInRight() {
|
|
|
1904
1920
|
'keysTitle': 'Shortcuts & gestures',
|
|
1905
1921
|
'guideDesc': 'Storyboard, generate and cut right beside the chat',
|
|
1906
1922
|
'hostTakenTitle': 'The canvas is open elsewhere',
|
|
1923
|
+
// —— Session↔canvas binding (composer canvas selector) ——
|
|
1924
|
+
'bindSessionOnly': 'Session only',
|
|
1925
|
+
'bindCreateProjectAction': 'Create project',
|
|
1926
|
+
'bindNewCanvas': 'New sub-canvas',
|
|
1927
|
+
'bindNewCanvasPlaceholder': '',
|
|
1928
|
+
'bindOpenCanvas': 'Open canvas',
|
|
1929
|
+
'bindOccupied': 'Occupied',
|
|
1930
|
+
'bindFail': 'Binding failed',
|
|
1931
|
+
'bindCreating': 'Creating…',
|
|
1932
|
+
'bindHostStale': 'The host plugin is outdated: fully quit and restart DeepSeek Harness, then retry.',
|
|
1933
|
+
'bindChipBound': '{project} · {name}',
|
|
1934
|
+
// —— Memory viewer (studio modal "memory" tab) ——
|
|
1935
|
+
'memViewerTab': 'Memory',
|
|
1936
|
+
'memViewerEmpty': 'No memories yet. As episode sessions write back via canvas_write_memory, the per-episode index and full memory appear here.',
|
|
1937
|
+
'memRefresh': 'Refresh',
|
|
1938
|
+
'memViewerHint': 'Click an episode to read its full memory (read-only)',
|
|
1907
1939
|
'hostTakenHint': 'The canvas runs in one place at a time (one shared node graph and generation state). Move it here with the button below.',
|
|
1908
1940
|
'hostTakeOver': 'Move the canvas here',
|
|
1909
1941
|
'keysHint': 'Click the button again to collapse; Esc also closes',
|
|
@@ -2499,6 +2531,7 @@ body[data-ds-dark-theme] .dshic-studio-modal{border-color:var(--dsw-alias-border
|
|
|
2499
2531
|
/* 弹窗内部再开确认框/PhotoCraft:层级必须高于统一弹窗(否则被遮罩盖住点不到) */
|
|
2500
2532
|
.dshic-studio-overlay .dshic-modal-overlay{z-index:340;}
|
|
2501
2533
|
.dshic-studio-bible{display:flex;flex-direction:column;gap:8px;width:100%;max-width:820px;margin:0 auto;}
|
|
2534
|
+
.dshic-studio-memory{display:flex;flex-direction:column;min-height:0;width:100%;max-width:820px;margin:0 auto;}
|
|
2502
2535
|
/* ── 3D 导演台:三栏(对象 / 视口 / 属性);视口是纯 Canvas2D 软件渲染(见 directorRenderScene) ── */
|
|
2503
2536
|
.dshic-dir-modal{width:min(1220px,calc(100vw - 40px));height:min(820px,calc(100vh - 40px));}
|
|
2504
2537
|
.dshic-dir-body{flex:1;min-height:0;display:flex;gap:0;overflow:hidden;}
|
|
@@ -2759,6 +2792,12 @@ body[data-ds-dark-theme] .dshic-studio-modal{border-color:var(--dsw-alias-border
|
|
|
2759
2792
|
.dshic-asset-pageinput:focus{outline:none;border-color:var(--dsw-alias-brand-primary);box-shadow:var(--dshic-shadow-sel);}
|
|
2760
2793
|
.dshic-asset-pagetotal,.dshic-asset-pagecount{font-variant-numeric:tabular-nums;white-space:nowrap;}
|
|
2761
2794
|
.dshic-asset-pagecount{opacity:.75;}
|
|
2795
|
+
/* 搜索行:搜索框(≈2/3,右侧内嵌放大镜)+ 项目选择(≈1/3)同行;窄窗口自动换行 */
|
|
2796
|
+
.dshic-asset-searchrow{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
|
|
2797
|
+
.dshic-asset-search{position:relative;flex:2 1 320px;min-width:220px;}
|
|
2798
|
+
.dshic-asset-search .dshic-input{width:100%;padding-right:26px;box-sizing:border-box;}
|
|
2799
|
+
.dshic-asset-scope{flex:1.1 1 200px;min-width:180px;display:flex;}
|
|
2800
|
+
.dshic-asset-scope .dshic-msel{width:100%;}
|
|
2762
2801
|
/* 设定集条目:行 + 已绑定资产缩略图 */
|
|
2763
2802
|
.dshic-bible-item{display:flex;flex-direction:column;gap:4px;padding:5px 0;border-bottom:1px dashed var(--dsw-alias-border-l1);}
|
|
2764
2803
|
.dshic-bible-thumbs{display:flex;gap:5px;flex-wrap:wrap;padding-left:4px;}
|
|
@@ -2988,6 +3027,47 @@ body[data-ds-dark-theme] .dshic-inline-input{border-color:var(--dsw-alias-border
|
|
|
2988
3027
|
color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;cursor:pointer;text-align:left;white-space:nowrap;}
|
|
2989
3028
|
.dshic-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover,color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent));}
|
|
2990
3029
|
body[data-ds-dark-theme] .dshic-menu{border-color:var(--dsw-alias-border-l2);}
|
|
3030
|
+
/* —— 会话↔画布绑定(composer 画布选择 chip):与宿主会话输入行 chip 同一视觉语言 —— */
|
|
3031
|
+
.dshic-bind{position:relative;display:inline-flex;align-items:center;gap:2px;}
|
|
3032
|
+
.dshic-bind-chip{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 10px;border-radius:10px;border:1px solid transparent;
|
|
3033
|
+
background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap;max-width:220px;overflow:hidden;text-overflow:ellipsis;}
|
|
3034
|
+
.dshic-bind-chip:hover{background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-3));color:var(--dsw-alias-label-primary);}
|
|
3035
|
+
.dshic-bind-chip.is-bound{color:var(--dsw-alias-label-primary);}
|
|
3036
|
+
.dshic-bind-ico{display:inline-flex;align-items:center;flex:none;opacity:.85;}
|
|
3037
|
+
.dshic-bind-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
3038
|
+
.dshic-bind-caret{font-size:10px;opacity:.75;flex:none;margin-left:2px;}
|
|
3039
|
+
.dshic-bind-menu{position:absolute;top:calc(100% + 6px);left:0;z-index:70;max-height:340px;overflow:auto;min-width:240px;border-radius:12px;padding:4px;}
|
|
3040
|
+
.dshic-bind-sep{height:1px;background:var(--dsw-alias-border-l1);margin:4px 6px;}
|
|
3041
|
+
.dshic-bind-rowico{display:inline-flex;align-items:center;flex:none;opacity:.8;}
|
|
3042
|
+
.dshic-bind-rowlabel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
3043
|
+
.dshic-bind-exp{margin-left:auto;padding-left:12px;font-size:10px;opacity:.65;flex:none;}
|
|
3044
|
+
.dshic-bind-indent{padding-left:26px;}
|
|
3045
|
+
.dshic-menu-item.is-selected{background:var(--dsw-alias-interactive-bg-hover,color-mix(in srgb,var(--dsw-alias-label-primary) 8%,transparent));}
|
|
3046
|
+
.dshic-bind-occ{color:var(--dsw-alias-label-secondary);font-size:11px;margin-left:auto;padding-left:12px;}
|
|
3047
|
+
.dshic-menu-item.is-dim{opacity:.55;cursor:not-allowed;}
|
|
3048
|
+
.dshic-menu-item.is-dim:hover{background:transparent;}
|
|
3049
|
+
.dshic-bind-newrow{display:flex;gap:6px;padding:4px 8px 6px;}
|
|
3050
|
+
.dshic-bind-newrow input{flex:1;min-width:0;height:28px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:0 8px;box-sizing:border-box;}
|
|
3051
|
+
.dshic-bind-newrow button{height:28px;padding:0 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap;}
|
|
3052
|
+
.dshic-bind-newrow button:hover{border-color:var(--dsw-alias-brand-primary);}
|
|
3053
|
+
.dshic-bind-err{position:absolute;top:calc(100% + 4px);left:0;font-size:11px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:2px 8px;z-index:70;max-width:260px;}
|
|
3054
|
+
.dshic-bind-err-inmenu{font-size:11px;color:var(--dsw-alias-label-primary);padding:6px 10px;margin-top:4px;border-top:1px solid var(--dsw-alias-border-l1);white-space:pre-wrap;word-break:break-word;}
|
|
3055
|
+
.dshic-bind-warn{font-size:11px;color:var(--dsw-alias-label-primary);padding:6px 10px;margin-bottom:4px;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:pre-wrap;word-break:break-word;}
|
|
3056
|
+
/* —— 记忆查看器(统一弹窗「记忆」页签)—— */
|
|
3057
|
+
.dshic-memtab{display:flex;flex-direction:column;gap:8px;height:100%;min-height:0;}
|
|
3058
|
+
.dshic-memtab-bar{display:flex;align-items:center;gap:10px;flex:none;}
|
|
3059
|
+
.dshic-memtab-hint{font-size:11px;color:var(--dsw-alias-label-secondary);}
|
|
3060
|
+
.dshic-memtab-empty{padding:26px 10px;text-align:center;font-size:12px;color:var(--dsw-alias-label-secondary);}
|
|
3061
|
+
.dshic-memtab-list{display:flex;flex-direction:column;gap:4px;overflow:auto;flex:1;min-height:0;}
|
|
3062
|
+
.dshic-memtab-row{display:flex;align-items:baseline;gap:8px;padding:7px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;
|
|
3063
|
+
background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;cursor:pointer;text-align:left;flex-wrap:wrap;}
|
|
3064
|
+
.dshic-memtab-row:hover{border-color:var(--dsw-alias-brand-primary);}
|
|
3065
|
+
.dshic-memtab-row.is-open{border-color:var(--dsw-alias-brand-primary);}
|
|
3066
|
+
.dshic-memtab-row-title{font-weight:600;flex:none;}
|
|
3067
|
+
.dshic-memtab-row-status{flex:none;color:var(--dsw-alias-label-secondary);font-size:11px;}
|
|
3068
|
+
.dshic-memtab-row-sum{color:var(--dsw-alias-label-secondary);font-size:11px;}
|
|
3069
|
+
.dshic-memtab-body{flex:none;max-height:45%;overflow:auto;margin:0;padding:10px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;
|
|
3070
|
+
background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:1.6;white-space:pre-wrap;word-break:break-word;}
|
|
2991
3071
|
.dshic-overlay{position:fixed;inset:0;z-index:50;background:transparent;}
|
|
2992
3072
|
.dshic-empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;pointer-events:none;}
|
|
2993
3073
|
.dshic-empty-card{pointer-events:auto;text-align:center;display:flex;flex-direction:column;gap:10px;align-items:center;
|
|
@@ -9423,8 +9503,9 @@ function queueThumb(assetId) {
|
|
|
9423
9503
|
rightTab: 'projects',
|
|
9424
9504
|
// 多画布预留:当前项目下只有默认画布(null);将来 = 子目录/子画布 id
|
|
9425
9505
|
activeCanvasId: null,
|
|
9426
|
-
// 统一弹窗(资产 +
|
|
9506
|
+
// 统一弹窗(资产 + 设定集 + 记忆):'bible' | 'assets' | 'memory' | null;纯 UI 状态
|
|
9427
9507
|
panelModal: null,
|
|
9508
|
+
memoryViewer: null, // 记忆查看器状态:{ loaded, index, open, body }(随项目切换重拉)
|
|
9428
9509
|
// 工具栏项目下拉(位置由按钮真实矩形计算):{left, top} | null;纯 UI 状态
|
|
9429
9510
|
projectMenu: null,
|
|
9430
9511
|
// 项目下拉的搜索与分页(最多 5 行/页,分页在列表底部、带页码输入框);打开下拉时重置
|
|
@@ -9458,6 +9539,16 @@ function queueThumb(assetId) {
|
|
|
9458
9539
|
keysOpen: false, // 左上角快捷键面板是否展开(纯 UI 状态,不持久化)
|
|
9459
9540
|
skillPalette: false, // 创作技能浮层(Ctrl/⌘+Shift+K 打开;纯 UI 状态,不持久化)
|
|
9460
9541
|
canvasHost: null, // 画布当前宿主:'main'(全屏面板)| 'pane'(会话右栏页签)| null——同一时刻只允许一处实例
|
|
9542
|
+
activeSessionId: null, // 当前活动会话(composer 画布 chip 上报):会话↔画布绑定与面板跟随的锚点
|
|
9543
|
+
sessionBinding: null, // sessionBindingGet 结果缓存(活动会话的绑定态:workspace/project/binding/canvases/occupied)
|
|
9544
|
+
bindingRev: 0, // 绑定刷新信号:驱动画布面板跟随 effect
|
|
9545
|
+
bindingMenuOpen: false,// chip 下拉开关
|
|
9546
|
+
bindingMenuProject: null, // 未绑定态展开的项目 id(两级菜单)
|
|
9547
|
+
bindableProjects: null,// 可绑定项目清单(菜单打开时懒加载;null=加载中)
|
|
9548
|
+
bindingNewFor: null, // 正在内联「新建子画布」的项目 id
|
|
9549
|
+
bindingError: null, // 绑定动作失败提示
|
|
9550
|
+
bindingCreating: false,// 「创建项目」进行中
|
|
9551
|
+
hostBindingStale: false, // 宿主进程为旧版(缺 bindingCapabilities rev>=2)→ 菜单提示重启并拦截动作
|
|
9461
9552
|
// 3D 导演台(纯 UI 状态;场景数据存在节点/项目的 director 文档里,见 directorDoc)
|
|
9462
9553
|
directorOpen: false,
|
|
9463
9554
|
directorFull: false, // 导演台是否全屏
|
|
@@ -10085,6 +10176,12 @@ function queueThumb(assetId) {
|
|
|
10085
10176
|
};
|
|
10086
10177
|
return map[c] || c;
|
|
10087
10178
|
}
|
|
10179
|
+
/** 资产分类归一(纯函数供回归):「图片」分类已移除——角色/道具/场景本来就是图片,
|
|
10180
|
+
* 其余一律归「通用」。历史已标 image 的资产在展示/过滤/搜索层归一,不迁移数据库。 */
|
|
10181
|
+
function normCat(c) {
|
|
10182
|
+
const v = String(c || '').trim();
|
|
10183
|
+
return !v || v === 'image' ? 'general' : v;
|
|
10184
|
+
}
|
|
10088
10185
|
function portWorldPos(nodeId, portId, dir) {
|
|
10089
10186
|
const n = S.graph.nodes[nodeId];
|
|
10090
10187
|
if (!n) return { x: 0, y: 0 };
|
|
@@ -11455,6 +11552,8 @@ function queueThumb(assetId) {
|
|
|
11455
11552
|
keyboard: 'M3 6h18v12H3zM7 10h.01M10 10h.01M13 10h.01M16 10h.01M7 13h.01M10 13h.01M13 13h.01M16 13h.01M8 16h8',
|
|
11456
11553
|
link: 'M10 13a5 5 0 007.1 0l2.4-2.4a5 5 0 00-7.1-7.1L11 4.9M14 11a5 5 0 00-7.1 0L4.5 13.4a5 5 0 007.1 7.1L13 19.1',
|
|
11457
11554
|
camera: 'M4 8h3l1.5-2h7L17 8h3v11H4zM12 16a3 3 0 100-6 3 3 0 000 6z',
|
|
11555
|
+
memory: 'M5 5h14M5 10h14M5 15h9M5 20h6M18 15v5M15.5 17.5h5',
|
|
11556
|
+
chat: 'M4 5h16v11H9l-5 4V5z',
|
|
11458
11557
|
};
|
|
11459
11558
|
function Ic(name, size) { return h(Icon, { d: ICONS[name], size: size || 14 }); }
|
|
11460
11559
|
|
|
@@ -14192,10 +14291,10 @@ function queueThumb(assetId) {
|
|
|
14192
14291
|
// 统一弹窗 / 项目命名弹窗的状态与动作(供图标列、工具栏、测试缝共用)
|
|
14193
14292
|
// ============================================================
|
|
14194
14293
|
function openStudioModal(tab) {
|
|
14195
|
-
update((s) => { s.panelModal = tab === 'assets' ? 'assets' : 'bible'; });
|
|
14294
|
+
update((s) => { s.panelModal = tab === 'assets' ? 'assets' : (tab === 'memory' ? 'memory' : 'bible'); });
|
|
14196
14295
|
}
|
|
14197
14296
|
function setStudioModalTab(tab) {
|
|
14198
|
-
update((s) => { if (s.panelModal) s.panelModal = tab === 'assets' ? 'assets' : 'bible'; });
|
|
14297
|
+
update((s) => { if (s.panelModal) s.panelModal = tab === 'assets' ? 'assets' : (tab === 'memory' ? 'memory' : 'bible'); });
|
|
14199
14298
|
}
|
|
14200
14299
|
function closeStudioModal() {
|
|
14201
14300
|
update((s) => { s.panelModal = null; });
|
|
@@ -14813,6 +14912,11 @@ function queueThumb(assetId) {
|
|
|
14813
14912
|
});
|
|
14814
14913
|
const KIND = { script: ['剧本', 'script'], storyboard: ['分镜', 'storyboard'], prompt: ['提示词', 'prompt'], assets: ['资产设定图', 'asset sheet'] };
|
|
14815
14914
|
const kl = (KIND[kind] || [kind])[zh ? 0 : 1];
|
|
14915
|
+
// 剧本能力切片的总纲:机制库条目 = 可自由组合的零件,绝不规定唯一走向;
|
|
14916
|
+
// 素材优先级:已有小说/剧本原文与设定集 > 题材素材库(库条目供二次创作借形)。
|
|
14917
|
+
const scriptDoctrine = zh
|
|
14918
|
+
? '【机制与素材】题材卡的机制库条目是可自由组合的零件:按当下故事的需要选择、改造、混搭或不用,事件与走向由剧本决定,条目绝不规定唯一走向,也绝不要求"用某设定就必须叠加某机制"。【素材优先级】已有小说/剧本原文与设定集设定 > 题材素材库:库条目仅供二次创作借形,绝不替代或改写既有设定。风格基调与导演运镜始终有效。'
|
|
14919
|
+
: '[Mechanics & material] Genre mechanism entries are freely combinable parts: pick, adapt, mix or skip per the story at hand - events and direction belong to the script, entries never mandate a single direction, and no entry implies "use X therefore Y". [Material precedence] Existing novel/script text and the series bible outrank the genre library: library entries are optional shapes for adaptation, never replacements for established settings. Style and camera direction always apply.';
|
|
14816
14920
|
if (zh) {
|
|
14817
14921
|
return [
|
|
14818
14922
|
'【画布技能包 · ' + kl + '】',
|
|
@@ -14821,6 +14925,7 @@ function queueThumb(assetId) {
|
|
|
14821
14925
|
+ ' 规格:' + (nameOf('forms', profile.form) || '未选')
|
|
14822
14926
|
+ ' 影调:' + (profile.look ? nameOf('looks', profile.look) : '跟随导演'),
|
|
14823
14927
|
'优先级:用户显式指令 > 导演透镜 > 规格(仅单镜时长与结构上压过透镜;画幅由视频节点生成时决定,不在此列)> 题材 > 影调。以下为对应切片,写提示词时按它执行;与本块冲突的通用规则让位于本块。',
|
|
14928
|
+
...(kind === 'script' ? [scriptDoctrine] : []),
|
|
14824
14929
|
].join('\n');
|
|
14825
14930
|
}
|
|
14826
14931
|
return [
|
|
@@ -14830,6 +14935,7 @@ function queueThumb(assetId) {
|
|
|
14830
14935
|
+ ' Spec: ' + (nameOf('forms', profile.form) || 'none')
|
|
14831
14936
|
+ ' Look: ' + (profile.look ? nameOf('looks', profile.look) : 'follow the lens'),
|
|
14832
14937
|
'Precedence: explicit user instruction > director lens > spec (clip length and structure only; aspect is set on the video node) > genre > look. The slices below are binding; generic rules that disagree give way.',
|
|
14938
|
+
...(kind === 'script' ? [scriptDoctrine] : []),
|
|
14833
14939
|
].join('\n');
|
|
14834
14940
|
}
|
|
14835
14941
|
|
|
@@ -17637,6 +17743,13 @@ const DIRECTOR_KEY_HELP = [
|
|
|
17637
17743
|
'data-action': 'open-bible', title: T('bibleTab'),
|
|
17638
17744
|
onClick: () => openStudioModal('bible'),
|
|
17639
17745
|
}, Ic('script', 16)),
|
|
17746
|
+
// 记忆查看器:项目级每集记忆索引 + 全文(只读;agent 经 canvas_write_memory 维护)
|
|
17747
|
+
h('button', {
|
|
17748
|
+
key: 'memory', type: 'button',
|
|
17749
|
+
className: cls('dshic-rail-btn', S.panelModal === 'memory' && 'is-active'),
|
|
17750
|
+
'data-action': 'open-memory', title: T('memViewerTab'),
|
|
17751
|
+
onClick: () => openStudioModal('memory'),
|
|
17752
|
+
}, Ic('memory', 16)),
|
|
17640
17753
|
h('div', { key: 'sep-actions', className: 'dshic-rail-sep' }),
|
|
17641
17754
|
// 3D 导演台:摆位 + 取景 + 导出镜头首帧(参考项目 BeefTV 的导演台能力,只借鉴设计、独立实现)
|
|
17642
17755
|
h('button', {
|
|
@@ -17684,7 +17797,8 @@ const DIRECTOR_KEY_HELP = [
|
|
|
17684
17797
|
h('div', { className: 'dshic-studio-head' },
|
|
17685
17798
|
h('div', { className: 'dshic-studio-tabs' },
|
|
17686
17799
|
tabBtn('bible', T('bibleTab')),
|
|
17687
|
-
tabBtn('assets', T('assets'))
|
|
17800
|
+
tabBtn('assets', T('assets')),
|
|
17801
|
+
tabBtn('memory', T('memViewerTab'))),
|
|
17688
17802
|
h('span', { className: 'dshic-studio-title' }, proj ? proj.name : ''),
|
|
17689
17803
|
h('button', {
|
|
17690
17804
|
type: 'button', className: 'dshic-iconbtn', title: T('cancel'),
|
|
@@ -17693,10 +17807,73 @@ const DIRECTOR_KEY_HELP = [
|
|
|
17693
17807
|
h('div', { className: 'dshic-studio-body' },
|
|
17694
17808
|
tab === 'bible'
|
|
17695
17809
|
? h('div', { className: 'dshic-studio-bible' }, h(BibleTab))
|
|
17696
|
-
:
|
|
17810
|
+
: (tab === 'memory'
|
|
17811
|
+
? h('div', { className: 'dshic-studio-memory' }, h(MemoryTab))
|
|
17812
|
+
: h('div', { className: 'dshic-modal-assets' }, h(AssetsTab, { variant: 'modal' })))),
|
|
17697
17813
|
));
|
|
17698
17814
|
}
|
|
17699
17815
|
|
|
17816
|
+
// ============================================================
|
|
17817
|
+
// 记忆查看器(统一弹窗「记忆」页签):项目级每集记忆索引 + 全文(只读;
|
|
17818
|
+
// 写入由 agent 经 canvas_write_memory 维护,人只看不改,避免与 agent 打架)
|
|
17819
|
+
// ============================================================
|
|
17820
|
+
async function loadMemoryIndex(pid) {
|
|
17821
|
+
if (!pid) return;
|
|
17822
|
+
try {
|
|
17823
|
+
const r = await hostRpc('memoryGet', { projectId: pid });
|
|
17824
|
+
update((s) => {
|
|
17825
|
+
s.memoryViewer = { loaded: true, index: (r && r.index) || { episodes: [] }, open: null, body: null };
|
|
17826
|
+
});
|
|
17827
|
+
} catch {
|
|
17828
|
+
update((s) => { s.memoryViewer = { loaded: true, index: { episodes: [] }, open: null, body: null }; });
|
|
17829
|
+
}
|
|
17830
|
+
}
|
|
17831
|
+
async function loadMemoryBody(pid, canvasId) {
|
|
17832
|
+
try {
|
|
17833
|
+
const r = await hostRpc('memoryGet', { projectId: pid, canvasId });
|
|
17834
|
+
update((s) => {
|
|
17835
|
+
const prev = s.memoryViewer || { index: { episodes: [] } };
|
|
17836
|
+
s.memoryViewer = {
|
|
17837
|
+
loaded: true,
|
|
17838
|
+
index: (r && r.index) || prev.index,
|
|
17839
|
+
open: canvasId,
|
|
17840
|
+
body: (r && r.episode && r.episode.body) || '',
|
|
17841
|
+
};
|
|
17842
|
+
});
|
|
17843
|
+
} catch { /* 静默:正文拉取失败保持原状 */ }
|
|
17844
|
+
}
|
|
17845
|
+
function MemoryTab() {
|
|
17846
|
+
useApp();
|
|
17847
|
+
const pid = S.activeId;
|
|
17848
|
+
useEffect(() => {
|
|
17849
|
+
loadMemoryIndex(pid);
|
|
17850
|
+
return undefined;
|
|
17851
|
+
}, [pid]);
|
|
17852
|
+
const st = S.memoryViewer || { loaded: false, index: { episodes: [] }, open: null, body: null };
|
|
17853
|
+
const eps = (st.index && Array.isArray(st.index.episodes)) ? st.index.episodes : [];
|
|
17854
|
+
return h('div', { className: 'dshic-memtab' },
|
|
17855
|
+
h('div', { className: 'dshic-memtab-bar' },
|
|
17856
|
+
h('button', { type: 'button', className: 'dshic-mini', onClick: () => loadMemoryIndex(pid) }, T('memRefresh')),
|
|
17857
|
+
h('span', { className: 'dshic-memtab-hint' }, T('memViewerHint'))),
|
|
17858
|
+
!st.loaded
|
|
17859
|
+
? h('div', { className: 'dshic-memtab-empty' }, '…')
|
|
17860
|
+
: (!eps.length
|
|
17861
|
+
? h('div', { className: 'dshic-memtab-empty' }, T('memViewerEmpty'))
|
|
17862
|
+
: h('div', { className: 'dshic-memtab-list' }, eps.map((e, i) => h('button', {
|
|
17863
|
+
key: String(e.canvasId) + ':' + i,
|
|
17864
|
+
type: 'button',
|
|
17865
|
+
className: 'dshic-memtab-row' + (st.open === e.canvasId ? ' is-open' : ''),
|
|
17866
|
+
onClick: () => loadMemoryBody(pid, e.canvasId),
|
|
17867
|
+
},
|
|
17868
|
+
h('span', { className: 'dshic-memtab-row-title' }, (i + 1) + '. ' + (e.title || e.canvasId || '')),
|
|
17869
|
+
h('span', { className: 'dshic-memtab-row-status' }, e.status === 'done' ? '✓' : '…'),
|
|
17870
|
+
h('span', { className: 'dshic-memtab-row-sum' }, e.summary || ''))))),
|
|
17871
|
+
st.open != null && st.body != null
|
|
17872
|
+
? h('pre', { className: 'dshic-memtab-body' }, st.body)
|
|
17873
|
+
: null,
|
|
17874
|
+
);
|
|
17875
|
+
}
|
|
17876
|
+
|
|
17700
17877
|
// ============================================================
|
|
17701
17878
|
// 顶部工具栏:最左「返回」图标 → 项目名(下拉切换 / 双击或铅笔重命名 / 新建)
|
|
17702
17879
|
// 说明:添节点在左侧图标列,运行工作流也在图标列;快捷键/帮助/检查更新是右上角纯图标按钮。
|
|
@@ -18144,7 +18321,8 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18144
18321
|
T('emptyProjectHint'))
|
|
18145
18322
|
: null,
|
|
18146
18323
|
// 项目区域顶部:一行「+ 新建画布(纯图标)」+ 搜索框(放大镜内嵌在输入框右侧)
|
|
18147
|
-
|
|
18324
|
+
// 折叠只折叠**下方画布列表**:搜索行始终可见(折叠不能把上方工具行一起吞掉)
|
|
18325
|
+
proj
|
|
18148
18326
|
? h('div', { key: 'searchbar', className: 'dshic-canvas-searchbar', 'data-role': 'canvas-searchbar' },
|
|
18149
18327
|
h('button', {
|
|
18150
18328
|
key: 'add', type: 'button', className: 'dshic-canvas-add',
|
|
@@ -18331,7 +18509,10 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18331
18509
|
if (a.kind === 'text') {
|
|
18332
18510
|
const c = worldCenter();
|
|
18333
18511
|
const nd = addNodeAt('text', { x: c.x - 120, y: c.y - 60 });
|
|
18334
|
-
update((s) => {
|
|
18512
|
+
update((s) => {
|
|
18513
|
+
const n2 = s.graph.nodes[nd.id];
|
|
18514
|
+
if (n2) { n2.data.text = a.text || ''; n2.data.label = a.name || n2.data.label; } // 节点名 = 资产名
|
|
18515
|
+
});
|
|
18335
18516
|
return;
|
|
18336
18517
|
}
|
|
18337
18518
|
const c = worldCenter();
|
|
@@ -18339,7 +18520,7 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18339
18520
|
const n = addNodeAt(type, { x: c.x + (Math.random() * 60 - 30), y: c.y + (Math.random() * 60 - 30) });
|
|
18340
18521
|
update((s) => {
|
|
18341
18522
|
const nd = s.graph.nodes[n.id];
|
|
18342
|
-
if (nd) { nd.data.assetId = a.id; nd.data.status = 'done'; }
|
|
18523
|
+
if (nd) { nd.data.assetId = a.id; nd.data.status = 'done'; nd.data.label = a.name || nd.data.label; } // 节点名 = 资产名
|
|
18343
18524
|
});
|
|
18344
18525
|
};
|
|
18345
18526
|
const changeCategory = (a, category) => {
|
|
@@ -18354,13 +18535,22 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18354
18535
|
let failed = 0;
|
|
18355
18536
|
for (const f of files) {
|
|
18356
18537
|
const kind = f.type.startsWith('video/') ? 'video' : f.type.startsWith('image/') ? 'image' : null;
|
|
18357
|
-
if (!kind) continue;
|
|
18358
18538
|
try {
|
|
18359
|
-
|
|
18539
|
+
// 文本(.txt/.md):入库为文本资产(名称=文件名去扩展名,分类=剧本,归属=当前项目)——
|
|
18540
|
+
// 多集小说/剧本一键导入,入库后在资产面板多选批量铺画布(text 节点可直接连分镜表当剧本源)
|
|
18541
|
+
if (!kind && /\.(txt|md|markdown)$/i.test(f.name)) {
|
|
18542
|
+
const text = await f.text();
|
|
18543
|
+
await saveTextAssetRecord(S.activeId, {
|
|
18544
|
+
name: f.name.replace(/\.(txt|md|markdown)$/i, ''),
|
|
18545
|
+
text, category: 'script', source: 'upload',
|
|
18546
|
+
});
|
|
18547
|
+
} else if (kind) {
|
|
18548
|
+
await saveAssetRecord(S.activeId, kind, f, { name: f.name, source: 'upload', category: 'general' });
|
|
18549
|
+
} else { continue; }
|
|
18360
18550
|
} catch { failed++; } // 单个失败不影响其余文件
|
|
18361
18551
|
}
|
|
18362
18552
|
if (failed) toast(T('uploadFailed') + '(' + failed + '/' + files.length + ')');
|
|
18363
|
-
if (files.length) bumpView();
|
|
18553
|
+
if (files.length) { bumpView(); update((s) => { s.assetsTick++; }); }
|
|
18364
18554
|
};
|
|
18365
18555
|
const del = async (a) => {
|
|
18366
18556
|
// 服务端删除(SQL:行 + FTS + CAS 引用计数;JSON:文件 + assets.json),随后清本地缓存
|
|
@@ -18411,6 +18601,7 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18411
18601
|
const nd = newNode(a.kind === 'text' ? 'text' : a.kind, pts[k]);
|
|
18412
18602
|
if (a.kind === 'text') nd.data.text = a.text || '';
|
|
18413
18603
|
else { nd.data.assetId = a.id; nd.data.status = 'done'; }
|
|
18604
|
+
nd.data.label = a.name || nd.data.label; // 节点名 = 资产名(不再叫 图片1/视频2/文本1)
|
|
18414
18605
|
s.graph.nodes[nd.id] = nd;
|
|
18415
18606
|
newIds.push(nd.id);
|
|
18416
18607
|
});
|
|
@@ -18458,11 +18649,14 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18458
18649
|
toast(T('craftSyncDone').replace('{ok}', String(okN)).replace('{fail}', String(failN)));
|
|
18459
18650
|
};
|
|
18460
18651
|
const filtered = assets.filter((a) => {
|
|
18461
|
-
|
|
18462
|
-
|
|
18652
|
+
// 严格项目隔离:scope=具体项目 → 只见该项目资产;通用项目(GENERAL_PID)资产不再
|
|
18653
|
+
// 混入其他项目(旧口径"通用资产多项目共享"改为显式——要看通用资产请把 scope 切到
|
|
18654
|
+
// 「通用项目」或「全部」;跨项目取素材的功能面(@引用/设定集绑定)不受影响)。
|
|
18655
|
+
if (scope !== 'all' && a.projectId !== scope) return false;
|
|
18656
|
+
if (filter !== 'all' && normCat(a.category) !== filter) return false;
|
|
18463
18657
|
if (!q) return true;
|
|
18464
18658
|
const hay = [
|
|
18465
|
-
a.name, a.prompt || '', a.text || '', catLabel(a.category
|
|
18659
|
+
a.name, a.prompt || '', a.text || '', catLabel(normCat(a.category)),
|
|
18466
18660
|
projectName(a.projectId), a.kind === 'image' ? T('kindImage') : a.kind === 'video' ? T('kindVideo') : 'text',
|
|
18467
18661
|
].join(' ').toLowerCase();
|
|
18468
18662
|
return hay.includes(q);
|
|
@@ -18492,18 +18686,24 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18492
18686
|
onClick: () => setFilter(c.id),
|
|
18493
18687
|
}, c.label)),
|
|
18494
18688
|
),
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18501
|
-
|
|
18502
|
-
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18689
|
+
// 搜索行:搜索框(≈2/3,右侧内嵌放大镜)+ 项目选择(≈1/3)同行;窄窗口自动换行
|
|
18690
|
+
h('div', { key: 'searchrow', className: 'dshic-asset-searchrow', 'data-role': 'assets-searchrow' },
|
|
18691
|
+
h('div', { className: 'dshic-asset-search' },
|
|
18692
|
+
h('input', {
|
|
18693
|
+
className: 'dshic-input', value: search,
|
|
18694
|
+
placeholder: T('searchLabel'),
|
|
18695
|
+
onChange: (e) => setSearch(e.target.value),
|
|
18696
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
18697
|
+
}),
|
|
18698
|
+
h('span', { className: 'dshic-search-ic', 'aria-hidden': 'true' }, Ic('search', 12))),
|
|
18699
|
+
h('div', { className: 'dshic-asset-scope' },
|
|
18700
|
+
h(MiniSelect, {
|
|
18701
|
+
value: scope, title: T('projectFilter'),
|
|
18702
|
+
options: [{ value: 'all', label: T('allProjects') }, { value: GENERAL_PID, label: T('generalProject') }]
|
|
18703
|
+
.concat(S.projects.map((p) => ({ value: p.id, label: p.name }))),
|
|
18704
|
+
onChange: (v) => setScope(v),
|
|
18705
|
+
})),
|
|
18706
|
+
),
|
|
18507
18707
|
// 工具栏(项目下一行):所有操作按钮 + 分页集中在一行,窄窗口自动换行、分页始终靠右。
|
|
18508
18708
|
// 按钮统一「透明底 + 1px 线框 + 文字」(UI-RULES:禁止灰底色块)。
|
|
18509
18709
|
h('div', { key: 'toolbar', className: 'dshic-asset-toolbar', 'data-role': 'assets-toolbar' },
|
|
@@ -18559,7 +18759,7 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18559
18759
|
h('span', { className: 'dshic-asset-pagecount', 'data-role': 'assets-page-info' }, T('assetsTotalCount').replace('{n}', String(filtered.length))),
|
|
18560
18760
|
),
|
|
18561
18761
|
),
|
|
18562
|
-
h('input', { key: 'file', ref: fileRef, type: 'file', accept: 'image/*,video
|
|
18762
|
+
h('input', { key: 'file', ref: fileRef, type: 'file', accept: 'image/*,video/*,.txt,.md,text/plain,text/markdown', multiple: true, style: { display: 'none' }, onChange: onImport }),
|
|
18563
18763
|
loading && !assets.length
|
|
18564
18764
|
? h('div', { key: 'loading', className: 'dshic-hint' }, T('aiRunning'))
|
|
18565
18765
|
: shown.length === 0
|
|
@@ -18648,6 +18848,17 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18648
18848
|
onClick: startRename,
|
|
18649
18849
|
}, Ic('pencil', 11));
|
|
18650
18850
|
const downloadName = (a.name || 'asset') + extForDownload(a.mime, a.name, a.kind);
|
|
18851
|
+
// 项目归属下拉(全部资产同款,含文本资产):看归属 + 就地改归属(onMove 服务端写回)
|
|
18852
|
+
const projSel = h('select', {
|
|
18853
|
+
className: 'dshic-asset-project', title: T('projectFilter'),
|
|
18854
|
+
value: a.projectId || GENERAL_PID,
|
|
18855
|
+
onClick: (e) => e.stopPropagation(),
|
|
18856
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
18857
|
+
onChange: (e) => { e.stopPropagation(); onMove(a, e.target.value); },
|
|
18858
|
+
},
|
|
18859
|
+
h('option', { value: GENERAL_PID }, T('generalProject')),
|
|
18860
|
+
S.projects.map((pp) => h('option', { key: pp.id, value: pp.id }, pp.name)),
|
|
18861
|
+
);
|
|
18651
18862
|
return h('div', {
|
|
18652
18863
|
className: cls('dshic-asset', checked && 'is-checked'),
|
|
18653
18864
|
onClick: () => onToggleSel(a),
|
|
@@ -18681,16 +18892,7 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18681
18892
|
renameBtn)
|
|
18682
18893
|
: null,
|
|
18683
18894
|
a.kind !== 'text'
|
|
18684
|
-
?
|
|
18685
|
-
className: 'dshic-asset-project', title: T('projectFilter'),
|
|
18686
|
-
value: a.projectId || GENERAL_PID,
|
|
18687
|
-
onClick: (e) => e.stopPropagation(),
|
|
18688
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
18689
|
-
onChange: (e) => { e.stopPropagation(); onMove(a, e.target.value); },
|
|
18690
|
-
},
|
|
18691
|
-
h('option', { value: GENERAL_PID }, T('generalProject')),
|
|
18692
|
-
S.projects.map((pp) => h('option', { key: pp.id, value: pp.id }, pp.name)),
|
|
18693
|
-
)
|
|
18895
|
+
? projSel
|
|
18694
18896
|
: null,
|
|
18695
18897
|
h('div', { className: 'dshic-asset-actions' },
|
|
18696
18898
|
(a.kind === 'image' || a.kind === 'video')
|
|
@@ -18730,8 +18932,10 @@ const DIRECTOR_KEY_HELP = [
|
|
|
18730
18932
|
? h('audio', { src: url, controls: true, style: { width: '100%', height: 30 }, onPointerDown: (e) => e.stopPropagation(), onClick: (e) => e.stopPropagation(), preload: 'metadata' })
|
|
18731
18933
|
: null,
|
|
18732
18934
|
h('div', { className: 'dshic-asset-meta' },
|
|
18935
|
+
// 文本资产:meta 行补项目下拉(媒体资产的下拉在名称行下,文本卡片放这里——位置不同、控件同款)
|
|
18936
|
+
a.kind === 'text' ? projSel : null,
|
|
18733
18937
|
h('select', {
|
|
18734
|
-
className: 'dshic-cat', title: T('catLabel'), value: a.category
|
|
18938
|
+
className: 'dshic-cat', title: T('catLabel'), value: normCat(a.category),
|
|
18735
18939
|
onClick: (e) => e.stopPropagation(),
|
|
18736
18940
|
onPointerDown: (e) => e.stopPropagation(),
|
|
18737
18941
|
onChange: (e) => { e.stopPropagation(); onCat(a, e.target.value); },
|
|
@@ -20778,6 +20982,391 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20778
20982
|
);
|
|
20779
20983
|
}
|
|
20780
20984
|
|
|
20985
|
+
// ============================================================
|
|
20986
|
+
// 会话↔画布绑定(0.20.x):composer 画布选择 chip + 画布面板跟随
|
|
20987
|
+
// ============================================================
|
|
20988
|
+
const TPL = (tpl, vars) => String(tpl || '').replace(/\{(\w+)\}/g, (m, k) => (vars && vars[k] != null ? String(vars[k]) : m));
|
|
20989
|
+
/** 拉取活动会话的绑定态(sessionBindingGet)。旧宿主 supported:false → chip 整体隐藏。 */
|
|
20990
|
+
async function refreshSessionBinding(sessionId) {
|
|
20991
|
+
if (!sessionId) return;
|
|
20992
|
+
try {
|
|
20993
|
+
const r = await hostRpc('sessionBindingGet', { sessionId });
|
|
20994
|
+
update((s) => {
|
|
20995
|
+
if (s.activeSessionId !== sessionId) return; // 会话已切走:丢弃过期回包
|
|
20996
|
+
s.sessionBinding = Object.assign({ loaded: true }, r);
|
|
20997
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
20998
|
+
});
|
|
20999
|
+
} catch (e) {
|
|
21000
|
+
update((s) => {
|
|
21001
|
+
if (s.activeSessionId !== sessionId) return;
|
|
21002
|
+
s.sessionBinding = { loaded: true, supported: false, error: String((e && e.message) || e) };
|
|
21003
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21004
|
+
});
|
|
21005
|
+
}
|
|
21006
|
+
}
|
|
21007
|
+
/** 画布在绑定清单里的序位(默认画布算第 1 集)。 */
|
|
21008
|
+
function canvasEpisodeOf(binding, canvasId) {
|
|
21009
|
+
if (!binding) return null;
|
|
21010
|
+
const cid = canvasId == null ? null : canvasId;
|
|
21011
|
+
const list = Array.isArray(binding.canvases) ? binding.canvases : [];
|
|
21012
|
+
const i = list.findIndex((c) => (c.id || null) === cid);
|
|
21013
|
+
return i >= 0 ? { n: i + 1, total: list.length, name: list[i].name || '' } : null;
|
|
21014
|
+
}
|
|
21015
|
+
/** 绑定打开/跟随:切项目 → 切画布 → 拉远端文档。
|
|
21016
|
+
* opts.force=true(chip 显式动作)无视宿主守卫;否则仅 pane(会话旁画布)自动跟随。 */
|
|
21017
|
+
function followBoundCanvas(opts) {
|
|
21018
|
+
const b = S.sessionBinding;
|
|
21019
|
+
if (!b || !b.loaded || !b.binding || !b.project) return false;
|
|
21020
|
+
if (!(opts && opts.force === true) && S.canvasHost !== 'pane') return false;
|
|
21021
|
+
const pid = b.project.id;
|
|
21022
|
+
const cid = b.binding.canvasId == null ? null : b.binding.canvasId;
|
|
21023
|
+
if (S.activeId !== pid) switchProject(pid);
|
|
21024
|
+
if (activeCanvasId() !== cid) switchCanvas(cid, { skipFlush: true });
|
|
21025
|
+
hydrateCanvasFromHost(pid, cid); // 远端兜底(本地缓存可能为空/过期;对默认画布 switchCanvas 不触发 hydrate)
|
|
21026
|
+
return true;
|
|
21027
|
+
}
|
|
21028
|
+
/** chip 点击(已绑定态):打开右栏画布并落到绑定画布。 */
|
|
21029
|
+
function openBoundCanvasFromChip() {
|
|
21030
|
+
try { revealCanvasInRight(); } catch { /* 布局服务缺失 → 仅切换不展开 */ }
|
|
21031
|
+
followBoundCanvas({ force: true });
|
|
21032
|
+
}
|
|
21033
|
+
/** 客户端项目条目 → 画布清单(默认画布 id=null 在前;与画布管理器同源)。 */
|
|
21034
|
+
function canvasesFromProject(proj) {
|
|
21035
|
+
if (!proj) return [];
|
|
21036
|
+
const list = proj.defaultCanvasDeleted ? [] : [{ id: null, name: proj.defaultCanvasName || '默认画布' }];
|
|
21037
|
+
return list.concat((proj.canvases || []).map((c) => ({ id: c.id, name: c.name })));
|
|
21038
|
+
}
|
|
21039
|
+
/** 确保项目在客户端项目表里(绑定到尚未同步的项目时本地先可见)。 */
|
|
21040
|
+
function ensureLocalProject(id, name) {
|
|
21041
|
+
const pid = String(id || '');
|
|
21042
|
+
if (!pid) return;
|
|
21043
|
+
if ((S.projects || []).some((p) => p.id === pid)) return;
|
|
21044
|
+
update((s) => {
|
|
21045
|
+
s.projects = [{
|
|
21046
|
+
id: pid, name: name || pid, canvases: [], defaultCanvasName: '默认画布',
|
|
21047
|
+
createdAt: Date.now(), updatedAt: Date.now(),
|
|
21048
|
+
}].concat(s.projects || []);
|
|
21049
|
+
});
|
|
21050
|
+
}
|
|
21051
|
+
/** 绑定能力探针:识别宿主进程是否仍是旧版(旧宿主无此 RPC → 抛错 → stale=true)。 */
|
|
21052
|
+
async function refreshBindingCapabilities() {
|
|
21053
|
+
try {
|
|
21054
|
+
const r = await hostRpc('bindingCapabilities');
|
|
21055
|
+
update((s) => { s.hostBindingStale = !(r && r.ok && Number(r.rev) >= 2); });
|
|
21056
|
+
} catch {
|
|
21057
|
+
update((s) => { s.hostBindingStale = true; });
|
|
21058
|
+
}
|
|
21059
|
+
}
|
|
21060
|
+
/** 旧宿主守卫:所有绑定动作统一拦截并给出重启提示(不再静默失败)。 */
|
|
21061
|
+
function bindingStaleGuard() {
|
|
21062
|
+
if (!S.hostBindingStale) return false;
|
|
21063
|
+
update((s) => { s.bindingError = T('bindHostStale'); });
|
|
21064
|
+
return true;
|
|
21065
|
+
}
|
|
21066
|
+
async function bindSessionToCanvas(sessionId, projectId, canvasId) {
|
|
21067
|
+
if (!sessionId || !projectId) return;
|
|
21068
|
+
if (bindingStaleGuard()) return;
|
|
21069
|
+
try {
|
|
21070
|
+
const r = await hostRpc('sessionBindingSet', { sessionId, projectId, canvasId: canvasId == null ? null : canvasId });
|
|
21071
|
+
if (!r || r.ok === false) {
|
|
21072
|
+
update((s) => { s.bindingError = (r && (r.error || (r.occupied && T('bindOccupied')))) || T('bindFail'); });
|
|
21073
|
+
return;
|
|
21074
|
+
}
|
|
21075
|
+
// 乐观更新:绑定成功立即用本地项目表显示「项目·画布」,不等宿主回读
|
|
21076
|
+
const local = (Array.isArray(S.projects) ? S.projects : []).find((p) => p.id === projectId);
|
|
21077
|
+
ensureLocalProject(projectId, (local && local.name) || projectId);
|
|
21078
|
+
update((s) => {
|
|
21079
|
+
const prev = s.sessionBinding || {};
|
|
21080
|
+
s.sessionBinding = {
|
|
21081
|
+
loaded: true, supported: true,
|
|
21082
|
+
workspace: prev.workspace || null,
|
|
21083
|
+
project: { id: projectId, name: (local && local.name) || projectId },
|
|
21084
|
+
binding: { canvasId: canvasId == null ? null : canvasId, boundAt: Date.now() },
|
|
21085
|
+
canvasId: canvasId == null ? null : canvasId,
|
|
21086
|
+
canvases: canvasesFromProject(local),
|
|
21087
|
+
occupied: prev.occupied || {},
|
|
21088
|
+
defaultCanvasName: (local && local.defaultCanvasName) || '默认画布',
|
|
21089
|
+
};
|
|
21090
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21091
|
+
s.bindingError = null;
|
|
21092
|
+
s.bindingMenuOpen = false; s.bindingMenuProject = null; s.bindingNewFor = null;
|
|
21093
|
+
});
|
|
21094
|
+
await refreshSessionBinding(sessionId);
|
|
21095
|
+
followBoundCanvas({ force: true });
|
|
21096
|
+
} catch (e) {
|
|
21097
|
+
update((s) => { s.bindingError = String((e && e.message) || e) || T('bindFail'); });
|
|
21098
|
+
}
|
|
21099
|
+
}
|
|
21100
|
+
async function unbindSession(sessionId) {
|
|
21101
|
+
if (bindingStaleGuard()) return;
|
|
21102
|
+
// 乐观清态:chip 立即回「仅会话」(回到可重新选项目的状态),宿主清除随后回读校正
|
|
21103
|
+
update((s) => {
|
|
21104
|
+
const prev = s.sessionBinding || {};
|
|
21105
|
+
s.sessionBinding = {
|
|
21106
|
+
loaded: true, supported: true,
|
|
21107
|
+
workspace: prev.workspace || null,
|
|
21108
|
+
project: null, binding: null, canvasId: null,
|
|
21109
|
+
canvases: [], occupied: {},
|
|
21110
|
+
};
|
|
21111
|
+
s.bindingRev = (s.bindingRev || 0) + 1;
|
|
21112
|
+
s.bindingError = null;
|
|
21113
|
+
s.bindingMenuOpen = false; s.bindingMenuProject = null; s.bindingNewFor = null;
|
|
21114
|
+
});
|
|
21115
|
+
try {
|
|
21116
|
+
const r = await hostRpc('sessionBindingClear', { sessionId });
|
|
21117
|
+
if (r && r.ok === false) update((s) => { s.bindingError = r.error || T('bindFail'); });
|
|
21118
|
+
} catch (e) {
|
|
21119
|
+
update((s) => { s.bindingError = String((e && e.message) || e) || T('bindFail'); });
|
|
21120
|
+
}
|
|
21121
|
+
await refreshSessionBinding(sessionId);
|
|
21122
|
+
}
|
|
21123
|
+
/** 「创建项目」:优先工作区内嵌项目;会话未挂工作区等失败场景退回普通建项目通道,然后绑定。 */
|
|
21124
|
+
async function createWorkspaceProject(sessionId) {
|
|
21125
|
+
if (bindingStaleGuard()) return;
|
|
21126
|
+
update((s) => { s.bindingCreating = true; s.bindingError = null; });
|
|
21127
|
+
const formerName = () => {
|
|
21128
|
+
const ws = S.sessionBinding && S.sessionBinding.workspace;
|
|
21129
|
+
const seg = ws && ws.path ? String(ws.path).split(/[\\/]/).filter(Boolean).pop() : '';
|
|
21130
|
+
return (seg || '画布项目') + ' ' + new Date().toISOString().slice(0, 16).replace('T', ' ');
|
|
21131
|
+
};
|
|
21132
|
+
const fallbackCreate = async () => {
|
|
21133
|
+
const name = formerName();
|
|
21134
|
+
const cp = await hostRpc('canvasCreateProject', { name });
|
|
21135
|
+
if (!cp || !cp.ok || !cp.projectId) throw new Error((cp && cp.error) || T('bindFail'));
|
|
21136
|
+
ensureLocalProject(cp.projectId, cp.name || name);
|
|
21137
|
+
update((s) => { s.bindingCreating = false; });
|
|
21138
|
+
refreshDataRoot().catch(() => { /* 下一轮 3s 同步也会带 */ });
|
|
21139
|
+
await bindSessionToCanvas(sessionId, cp.projectId, null);
|
|
21140
|
+
};
|
|
21141
|
+
try {
|
|
21142
|
+
const r = await hostRpc('workspaceProjectCreate', { sessionId });
|
|
21143
|
+
if (r && r.ok) {
|
|
21144
|
+
update((s) => { s.bindingCreating = false; s.bindingMenuOpen = false; });
|
|
21145
|
+
ensureLocalProject(r.projectId, (S.sessionBinding && S.sessionBinding.project && S.sessionBinding.project.name) || '');
|
|
21146
|
+
refreshDataRoot().catch(() => { /* 项目清单下一轮 3s 同步也会带 */ });
|
|
21147
|
+
await refreshSessionBinding(sessionId);
|
|
21148
|
+
const sb = S.sessionBinding;
|
|
21149
|
+
if (!(sb && sb.binding && sb.project && sb.project.id === r.projectId)) {
|
|
21150
|
+
await bindSessionToCanvas(sessionId, r.projectId, null); // 宿主未自动绑定时本地补绑
|
|
21151
|
+
}
|
|
21152
|
+
followBoundCanvas({ force: true });
|
|
21153
|
+
return;
|
|
21154
|
+
}
|
|
21155
|
+
// 工作区通道失败(如会话未挂工作区):退回普通建项目通道
|
|
21156
|
+
await fallbackCreate();
|
|
21157
|
+
} catch (e) {
|
|
21158
|
+
try {
|
|
21159
|
+
await fallbackCreate();
|
|
21160
|
+
} catch {
|
|
21161
|
+
update((s) => { s.bindingCreating = false; s.bindingError = String((e && e.message) || e) || T('bindFail'); });
|
|
21162
|
+
}
|
|
21163
|
+
}
|
|
21164
|
+
}
|
|
21165
|
+
/** 会话侧新建子画布后的本地登记:项目树/画布列表立即出现(与画布管理器同一数据源)。 */
|
|
21166
|
+
function registerLocalCanvas(projectId, canvasId, name) {
|
|
21167
|
+
const pid = String(projectId || '');
|
|
21168
|
+
const cid = String(canvasId || '');
|
|
21169
|
+
const cname = String(name || '').slice(0, 80);
|
|
21170
|
+
if (!pid || !cid) return;
|
|
21171
|
+
update((s) => {
|
|
21172
|
+
const pp = s.projects.find((x) => x.id === pid);
|
|
21173
|
+
if (!pp) return;
|
|
21174
|
+
const list = Array.isArray(pp.canvases) ? pp.canvases : [];
|
|
21175
|
+
if (!list.some((c) => c.id === cid)) {
|
|
21176
|
+
pp.canvases = [...list, { id: cid, name: cname, createdAt: Date.now() }];
|
|
21177
|
+
}
|
|
21178
|
+
});
|
|
21179
|
+
lsSet(LS_PROJECTS, S.projects);
|
|
21180
|
+
if (!loadGraphDoc(pid, cid)) saveGraphDoc(pid, emptyGraph(), cid); // 新画布首入空白
|
|
21181
|
+
scheduleSave();
|
|
21182
|
+
}
|
|
21183
|
+
/** 新建子画布并绑定(Host 先落登记;projectId 显式传入——未绑定态的项目二级菜单也能用)。 */
|
|
21184
|
+
async function createCanvasAndBind(sessionId, projectId, rawName) {
|
|
21185
|
+
if (bindingStaleGuard()) return;
|
|
21186
|
+
const name = String(rawName == null ? '' : rawName).trim();
|
|
21187
|
+
if (!sessionId || !projectId) return;
|
|
21188
|
+
if (!name) { update((s) => { s.bindingError = T('canvasNameRequired'); }); return; }
|
|
21189
|
+
try {
|
|
21190
|
+
const made = await hostRpc('canvasCreate', { projectId, name });
|
|
21191
|
+
update((s) => { s.bindingError = null; });
|
|
21192
|
+
if (made && made.ok && made.canvasId) {
|
|
21193
|
+
registerLocalCanvas(projectId, made.canvasId, made.name || name); // 本地先登记:项目树立即可见
|
|
21194
|
+
await bindSessionToCanvas(sessionId, projectId, made.canvasId);
|
|
21195
|
+
} else {
|
|
21196
|
+
update((s) => { s.bindingError = (made && made.error) || T('bindFail'); });
|
|
21197
|
+
}
|
|
21198
|
+
} catch (e) {
|
|
21199
|
+
update((s) => { s.bindingError = String((e && e.message) || e); });
|
|
21200
|
+
}
|
|
21201
|
+
}
|
|
21202
|
+
let bindingNewCanvasName = ''; // 内联新建输入(非受控:回车/按钮提交后弃用)
|
|
21203
|
+
/** 下拉菜单(宿主选择器格式:图标行 + 选中高亮 + 分隔线)。
|
|
21204
|
+
* 未绑定 = 仅会话 / 创建项目 / 已有项目列表(项目展开二级子画布 + 新建子画布);
|
|
21205
|
+
* 已绑定 = 项目锁定,只列本项目子画布。 */
|
|
21206
|
+
function BindingMenu() {
|
|
21207
|
+
const sessionId = S.activeSessionId;
|
|
21208
|
+
const b = S.sessionBinding || {};
|
|
21209
|
+
useEffect(() => {
|
|
21210
|
+
const onDown = (e) => {
|
|
21211
|
+
const t = e && e.target;
|
|
21212
|
+
if (t && t.closest && t.closest('.dshic-bind-menu, .dshic-bind-chip')) return;
|
|
21213
|
+
update((s) => { s.bindingMenuOpen = false; });
|
|
21214
|
+
};
|
|
21215
|
+
const esc = (e) => { if (e && e.key === 'Escape') update((s) => { s.bindingMenuOpen = false; }); };
|
|
21216
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
21217
|
+
document.addEventListener('keydown', esc, true);
|
|
21218
|
+
return () => {
|
|
21219
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
21220
|
+
document.removeEventListener('keydown', esc, true);
|
|
21221
|
+
};
|
|
21222
|
+
}, []);
|
|
21223
|
+
// 未绑定态懒加载可绑定项目(已绑定不需要项目列表——项目锁定)
|
|
21224
|
+
useEffect(() => {
|
|
21225
|
+
if (b.binding) return undefined;
|
|
21226
|
+
let alive = true;
|
|
21227
|
+
hostRpc('bindableProjects').then((r) => {
|
|
21228
|
+
if (alive) update((s) => { s.bindableProjects = (r && r.projects) || []; });
|
|
21229
|
+
}).catch(() => { if (alive) update((s) => { s.bindableProjects = []; }); });
|
|
21230
|
+
return () => { alive = false; };
|
|
21231
|
+
}, []);
|
|
21232
|
+
const close = () => update((s) => { s.bindingMenuOpen = false; s.bindingMenuProject = null; s.bindingNewFor = null; });
|
|
21233
|
+
const row = (key, icon, label, onClick, o) => h('button', {
|
|
21234
|
+
key, type: 'button',
|
|
21235
|
+
className: 'dshic-menu-item'
|
|
21236
|
+
+ (o && o.selected ? ' is-selected' : '')
|
|
21237
|
+
+ (o && o.dim ? ' is-dim' : '')
|
|
21238
|
+
+ (o && o.indent ? ' dshic-bind-indent' : ''),
|
|
21239
|
+
onClick,
|
|
21240
|
+
},
|
|
21241
|
+
icon ? h('span', { key: 'i', className: 'dshic-bind-rowico' }, icon) : null,
|
|
21242
|
+
h('span', { key: 'l', className: 'dshic-bind-rowlabel' }, label),
|
|
21243
|
+
o && o.suffix ? h('span', { key: 's', className: 'dshic-bind-exp' }, o.suffix) : null,
|
|
21244
|
+
o && o.tail ? o.tail : null);
|
|
21245
|
+
const sep = (key) => h('div', { key, className: 'dshic-bind-sep' });
|
|
21246
|
+
const newRow = (pid, indent) => (S.bindingNewFor === pid
|
|
21247
|
+
? h('div', { key: 'newrow:' + pid, className: 'dshic-bind-newrow' + (indent ? ' dshic-bind-indent' : '') },
|
|
21248
|
+
h('input', {
|
|
21249
|
+
type: 'text', autoFocus: true,
|
|
21250
|
+
onInput: (e) => { bindingNewCanvasName = (e && e.target && e.target.value) || ''; },
|
|
21251
|
+
onKeyDown: (e) => { if (e && e.key === 'Enter' && bindingNewCanvasName.trim()) createCanvasAndBind(sessionId, pid, bindingNewCanvasName); },
|
|
21252
|
+
}),
|
|
21253
|
+
h('button', { type: 'button', onClick: () => createCanvasAndBind(sessionId, pid, bindingNewCanvasName) }, T('bindNewCanvas')))
|
|
21254
|
+
: row('newbtn:' + pid, Ic('plus', 14), T('bindNewCanvas'),
|
|
21255
|
+
() => update((s) => { s.bindingNewFor = pid; s.bindingMenuProject = pid; }), { indent }));
|
|
21256
|
+
const rows = [];
|
|
21257
|
+
// 旧宿主警告:绑定能力探针失败时置顶提示,所有绑定动作已被拦截
|
|
21258
|
+
if (S.hostBindingStale) rows.push(h('div', { key: '__stale__', className: 'dshic-bind-warn' }, T('bindHostStale')));
|
|
21259
|
+
// 项目列表数据源 = 客户端项目表(与画布管理器同源,老项目必现);宿主 bindableProjects 仅补充合并
|
|
21260
|
+
const localProjects = Array.isArray(S.projects) ? S.projects : [];
|
|
21261
|
+
const seenPids = new Set();
|
|
21262
|
+
const menuProjects = [];
|
|
21263
|
+
for (const p of localProjects) {
|
|
21264
|
+
if (!p || !p.id || seenPids.has(p.id)) continue;
|
|
21265
|
+
seenPids.add(p.id);
|
|
21266
|
+
menuProjects.push({ id: p.id, name: p.name || p.id, canvases: canvasesFromProject(p), updatedAt: p.updatedAt || 0 });
|
|
21267
|
+
}
|
|
21268
|
+
for (const p of (Array.isArray(S.bindableProjects) ? S.bindableProjects : [])) {
|
|
21269
|
+
if (!p || !p.id || seenPids.has(p.id)) continue;
|
|
21270
|
+
seenPids.add(p.id);
|
|
21271
|
+
menuProjects.push({ id: p.id, name: p.name || p.id, canvases: p.canvases || [], updatedAt: p.updatedAt || 0 });
|
|
21272
|
+
}
|
|
21273
|
+
menuProjects.sort((a, z) => (z.updatedAt || 0) - (a.updatedAt || 0));
|
|
21274
|
+
if (b.binding && b.project) {
|
|
21275
|
+
// —— 已绑定:项目锁定,只列本项目的子画布(宿主回读缺失时用本地项目表兜底)——
|
|
21276
|
+
rows.push(row('__open__', Ic('image', 14), T('bindOpenCanvas'), () => { close(); openBoundCanvasFromChip(); }));
|
|
21277
|
+
rows.push(sep('s1'));
|
|
21278
|
+
const boundLocal = localProjects.find((p) => p && p.id === b.project.id);
|
|
21279
|
+
const boundCanvases = (Array.isArray(b.canvases) && b.canvases.length) ? b.canvases : canvasesFromProject(boundLocal);
|
|
21280
|
+
for (const c of boundCanvases) {
|
|
21281
|
+
const cid = c.id == null ? null : c.id;
|
|
21282
|
+
const isCurrent = (b.binding.canvasId == null ? null : b.binding.canvasId) === cid;
|
|
21283
|
+
const occupiedBy = (b.occupied || {})[cid == null ? 'null' : cid] || null;
|
|
21284
|
+
rows.push(row('cv:' + String(cid) + ':' + c.name, Ic('image', 14), c.name || T('panel'),
|
|
21285
|
+
occupiedBy ? undefined : () => bindSessionToCanvas(sessionId, b.project.id, cid),
|
|
21286
|
+
{
|
|
21287
|
+
selected: isCurrent, dim: !!occupiedBy,
|
|
21288
|
+
tail: occupiedBy ? h('span', { key: 'occ', className: 'dshic-bind-occ' }, T('bindOccupied')) : null,
|
|
21289
|
+
}));
|
|
21290
|
+
}
|
|
21291
|
+
rows.push(newRow(b.project.id, false));
|
|
21292
|
+
rows.push(sep('s2'));
|
|
21293
|
+
rows.push(row('__only__', Ic('chat', 14), T('bindSessionOnly'), () => unbindSession(sessionId)));
|
|
21294
|
+
} else {
|
|
21295
|
+
// —— 未绑定:仅会话 / 创建项目 / 已有项目(项目展开二级子画布 + 新建子画布)——
|
|
21296
|
+
rows.push(row('__only__', Ic('chat', 14), T('bindSessionOnly'), close, { selected: true }));
|
|
21297
|
+
rows.push(row('__create__', Ic('plus', 14), T('bindCreateProjectAction'), () => createWorkspaceProject(sessionId)));
|
|
21298
|
+
rows.push(sep('s1'));
|
|
21299
|
+
if (!menuProjects.length && S.bindableProjects === null) {
|
|
21300
|
+
rows.push(row('__loading__', null, '…', null, { dim: true }));
|
|
21301
|
+
} else {
|
|
21302
|
+
for (const p of menuProjects) {
|
|
21303
|
+
const expanded = S.bindingMenuProject === p.id;
|
|
21304
|
+
rows.push(row('p:' + p.id, Ic('folder', 14), p.name || p.id,
|
|
21305
|
+
() => update((s) => { s.bindingMenuProject = expanded ? null : p.id; s.bindingNewFor = null; }),
|
|
21306
|
+
{ suffix: expanded ? '▾' : '▸' }));
|
|
21307
|
+
if (expanded) {
|
|
21308
|
+
for (const c of (p.canvases || [])) {
|
|
21309
|
+
const cid = c.id == null ? null : c.id;
|
|
21310
|
+
rows.push(row('pc:' + p.id + ':' + String(cid), Ic('image', 14), c.name || T('panel'),
|
|
21311
|
+
() => bindSessionToCanvas(sessionId, p.id, cid), { indent: true }));
|
|
21312
|
+
}
|
|
21313
|
+
rows.push(newRow(p.id, true));
|
|
21314
|
+
}
|
|
21315
|
+
}
|
|
21316
|
+
}
|
|
21317
|
+
}
|
|
21318
|
+
// 失败原因显示在菜单内(保持菜单打开,用户能看到为什么没生效)
|
|
21319
|
+
if (S.bindingError) rows.push(h('div', { key: '__err__', className: 'dshic-bind-err-inmenu' }, S.bindingError));
|
|
21320
|
+
return h('div', { className: 'dshic-menu dshic-bind-menu' }, rows);
|
|
21321
|
+
}
|
|
21322
|
+
/** composer 画布选择 chip。session 作用域槽位的组件:props.sessionId 由 Runner 标准属性提供。 */
|
|
21323
|
+
function SessionBindingChip(props) {
|
|
21324
|
+
useApp();
|
|
21325
|
+
const sessionId = props && props.sessionId;
|
|
21326
|
+
useEffect(() => {
|
|
21327
|
+
if (!sessionId) return undefined;
|
|
21328
|
+
update((s) => {
|
|
21329
|
+
const same = s.activeSessionId === sessionId;
|
|
21330
|
+
s.activeSessionId = sessionId;
|
|
21331
|
+
if (!same) s.sessionBinding = null; // 换会话:清旧绑定态(立即重拉)
|
|
21332
|
+
});
|
|
21333
|
+
refreshSessionBinding(sessionId);
|
|
21334
|
+
refreshBindingCapabilities();
|
|
21335
|
+
return () => { /* 保留 binding 缓存:切回会话时秒显,refresh 会覆盖 */ };
|
|
21336
|
+
}, [sessionId]);
|
|
21337
|
+
if (!sessionId) return null; // 老 Runner 不给会话身份 → chip 缺席(绑定不可用,画布走全局行为)
|
|
21338
|
+
const b = S.sessionBinding;
|
|
21339
|
+
if (!b || !b.loaded) return null; // 加载中不渲染(避免闪「建画布项目」)
|
|
21340
|
+
if (b.supported === false) return null; // 旧宿主:无工作区能力
|
|
21341
|
+
const bound = !!(b.binding && b.project);
|
|
21342
|
+
const ep = bound ? canvasEpisodeOf(b, b.binding.canvasId) : null;
|
|
21343
|
+
const openMenu = () => update((s) => { s.bindingMenuOpen = !s.bindingMenuOpen; });
|
|
21344
|
+
const chipLabel = bound
|
|
21345
|
+
? TPL(T('bindChipBound'), {
|
|
21346
|
+
project: (b.project && b.project.name) || b.project.id || '',
|
|
21347
|
+
name: ep ? ep.name : String(b.binding.canvasId || ''),
|
|
21348
|
+
})
|
|
21349
|
+
: (S.bindingCreating ? T('bindCreating') : T('bindSessionOnly'));
|
|
21350
|
+
const chip = h('button', {
|
|
21351
|
+
key: 'chip',
|
|
21352
|
+
type: 'button',
|
|
21353
|
+
className: 'dshic-bind-chip' + (bound ? ' is-bound' : ''),
|
|
21354
|
+
title: chipLabel,
|
|
21355
|
+
// 一体式下拉(与「选择工作区」选择器同构):整颗胶囊点击 = 开下拉,
|
|
21356
|
+
// 未绑定态先给「仅会话 / 创建项目 / 已有项目」选择,绝不点一下替用户决定
|
|
21357
|
+
onClick: openMenu,
|
|
21358
|
+
}, [
|
|
21359
|
+
h('span', { key: 'ico', className: 'dshic-bind-ico' }, Ic('folder', 14)),
|
|
21360
|
+
h('span', { key: 'label', className: 'dshic-bind-label' }, chipLabel),
|
|
21361
|
+
h('span', { key: 'caret', className: 'dshic-bind-caret' }, '▾'),
|
|
21362
|
+
]);
|
|
21363
|
+
return h('div', { className: 'dshic-bind' },
|
|
21364
|
+
chip,
|
|
21365
|
+
S.bindingMenuOpen ? h(BindingMenu, { key: 'menu' }) : null,
|
|
21366
|
+
S.bindingError && !S.bindingMenuOpen ? h('div', { key: 'err', className: 'dshic-bind-err' }, S.bindingError) : null,
|
|
21367
|
+
);
|
|
21368
|
+
}
|
|
21369
|
+
|
|
20781
21370
|
// ============================================================
|
|
20782
21371
|
// 插件入口
|
|
20783
21372
|
// ============================================================
|
|
@@ -20830,6 +21419,16 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20830
21419
|
label: () => T('panel'),
|
|
20831
21420
|
locale: NS,
|
|
20832
21421
|
}, PanelIcon));
|
|
21422
|
+
// —— 会话↔画布绑定:composer 画布选择 chip(session 作用域槽位,Runner 标准属性免费给 sessionId)——
|
|
21423
|
+
// 旧 runner 没有 conversation.input.left 槽位:try/catch 静默降级(无 chip,画布面板走全局行为,功能缺席不炸插件)
|
|
21424
|
+
try {
|
|
21425
|
+
ctx.slots.inject('conversation.input.left', () => ctx.slots.register({
|
|
21426
|
+
name: 'conversation.input.left',
|
|
21427
|
+
id: 'infinite-canvas-binding',
|
|
21428
|
+
order: 40,
|
|
21429
|
+
locale: NS,
|
|
21430
|
+
}, SessionBindingChip));
|
|
21431
|
+
} catch { /* 旧 runner:绑定 chip 不可用(降级) */ }
|
|
20833
21432
|
// 面板根:包一层错误边界——任何渲染期崩溃都不再白屏,而是显示可复制的错误卡片
|
|
20834
21433
|
PanelErrorBoundary.__dshicClass = true; // 冒烟 walker 标记
|
|
20835
21434
|
function PanelRoot() {
|
|
@@ -20850,6 +21449,12 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20850
21449
|
const CANVAS_TAB_ID = '@ninkch/dsh-infinite-canvas'; // = 注册 id = 槽位 key
|
|
20851
21450
|
function CanvasHostedApp({ host }) {
|
|
20852
21451
|
useApp();
|
|
21452
|
+
const bindingRev = S.bindingRev; // 绑定刷新 → 跟随 effect 重跑(跟随守卫在 followBoundCanvas:仅 pane 自动)
|
|
21453
|
+
useEffect(() => {
|
|
21454
|
+
if (host !== 'pane') return; // 全屏面板不自动跟随(chip 显式动作走 force)
|
|
21455
|
+
followBoundCanvas();
|
|
21456
|
+
return undefined;
|
|
21457
|
+
}, [host, bindingRev]);
|
|
20853
21458
|
useEffect(() => {
|
|
20854
21459
|
// 挂载即声明宿主(后开者接管):在窄栏宿主里顺手收起画布自带的右侧栏(宽度不够)
|
|
20855
21460
|
const takeover = S.canvasHost !== host;
|
|
@@ -20974,6 +21579,8 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20974
21579
|
assetsPageIndex,
|
|
20975
21580
|
// 尾帧入库决策(一次生成只入一张:best 优先,best=last 才用 last)
|
|
20976
21581
|
tailFrameDecision,
|
|
21582
|
+
// 资产分类归一(image→general,空→general):「图片」分类已移除,展示/过滤/搜索层归一
|
|
21583
|
+
normCat,
|
|
20977
21584
|
// 历史条死条目裁剪 / 资产回链候选挑选与回链计划(纯函数,供回归测试直接断言)
|
|
20978
21585
|
pruneDeadHistory, repairPickAsset, repairPlan,
|
|
20979
21586
|
// 媒体节点指针空值保护(Host 合并不得用 null 覆盖本地有效 assetId/lastAssetId)
|