dsh-comfyui-canvas 0.1.7 → 0.1.9
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/lib/client.js +31 -15
- package/package.json +2 -3
- package/lib/index.js.bak-20260910000704 +0 -1773
package/lib/client.js
CHANGED
|
@@ -524,8 +524,9 @@ function ComfyUISplitToggle(props) {
|
|
|
524
524
|
var sessionId = String(props.sessionId ?? "root");
|
|
525
525
|
var scope = props.scope;
|
|
526
526
|
var snapshot = React.useSyncExternalStore(
|
|
527
|
-
function (cb) { return scope.subscribe(cb); },
|
|
528
|
-
function () { return scope.getSnapshot(); },
|
|
527
|
+
function (cb) { return scope && typeof scope.subscribe === "function" ? scope.subscribe(cb) : function () {}; },
|
|
528
|
+
function () { return scope && typeof scope.getSnapshot === "function" ? scope.getSnapshot() : null; },
|
|
529
|
+
function () { return scope && typeof scope.getSnapshot === "function" ? scope.getSnapshot() : null; },
|
|
529
530
|
);
|
|
530
531
|
var value = (snapshot && snapshot.value) || {};
|
|
531
532
|
var map = value.splitEnabledBySession || {};
|
|
@@ -590,7 +591,9 @@ function ComfyUISplitToggle(props) {
|
|
|
590
591
|
drag.lastW = w;
|
|
591
592
|
// 即时生效(CSS 变量驱动挤压样式),并持久化 railWidth。
|
|
592
593
|
applyRailWidth(w);
|
|
593
|
-
|
|
594
|
+
if (scope && typeof scope.set === "function") {
|
|
595
|
+
scope.set("railWidth", w).catch(function () { /* recover handled by scope */ });
|
|
596
|
+
}
|
|
594
597
|
// 拖动中实时重算画布覆盖层与把手位置(rail 左缘随宽度变化),
|
|
595
598
|
// 否则把手会停在起点,脱离 rail 边界。
|
|
596
599
|
var st = canvasState();
|
|
@@ -667,14 +670,18 @@ function ComfyUISplitToggle(props) {
|
|
|
667
670
|
var next = {};
|
|
668
671
|
for (var k in map) next[k] = map[k];
|
|
669
672
|
next[sessionId] = !enabled;
|
|
670
|
-
|
|
673
|
+
if (scope && typeof scope.set === "function") {
|
|
674
|
+
scope.set("splitEnabledBySession", next).catch(function () { /* recover handled by scope */ });
|
|
675
|
+
}
|
|
671
676
|
};
|
|
672
677
|
|
|
673
678
|
var toggleRail = function () {
|
|
674
679
|
var next = {};
|
|
675
680
|
for (var k in railClosedMap) next[k] = railClosedMap[k];
|
|
676
681
|
next[sessionId] = !railClosed;
|
|
677
|
-
|
|
682
|
+
if (scope && typeof scope.set === "function") {
|
|
683
|
+
scope.set("railClosedBySession", next).catch(function () { /* recover handled by scope */ });
|
|
684
|
+
}
|
|
678
685
|
};
|
|
679
686
|
|
|
680
687
|
// 顶栏折叠图标(buildCanvas 里 #dsh-comfy-rail-toggle)的点击事件 →
|
|
@@ -774,8 +781,9 @@ function ComfyUISplitToggle(props) {
|
|
|
774
781
|
function ComfyUISettingsRow(props) {
|
|
775
782
|
var scope = props.scope;
|
|
776
783
|
var snapshot = React.useSyncExternalStore(
|
|
777
|
-
function (cb) { return scope.subscribe(cb); },
|
|
778
|
-
function () { return scope.getSnapshot(); },
|
|
784
|
+
function (cb) { return scope && typeof scope.subscribe === "function" ? scope.subscribe(cb) : function () {}; },
|
|
785
|
+
function () { return scope && typeof scope.getSnapshot === "function" ? scope.getSnapshot() : null; },
|
|
786
|
+
function () { return scope && typeof scope.getSnapshot === "function" ? scope.getSnapshot() : null; },
|
|
779
787
|
);
|
|
780
788
|
var value = (snapshot && snapshot.value) || {};
|
|
781
789
|
var baseUrl = typeof value.baseUrl === "string" && value.baseUrl ? value.baseUrl : DEFAULT_BASE;
|
|
@@ -952,10 +960,16 @@ function ComfyUISettingsRow(props) {
|
|
|
952
960
|
);
|
|
953
961
|
}
|
|
954
962
|
|
|
955
|
-
var inject = ["slots"
|
|
963
|
+
var inject = ["slots"];
|
|
956
964
|
|
|
957
965
|
function apply(ctx) {
|
|
958
|
-
|
|
966
|
+
// 2026-09-24: 核心 #4587 移除了客户端 settingsScope 服务,且 cordis ctx 代理对
|
|
967
|
+
// 未注入服务的属性访问(ctx.settingsScope)会直接抛 "cannot get property...
|
|
968
|
+
// without inject",导致客户端 apply 失败。改用 ctx.get()(缺失返回 undefined)。
|
|
969
|
+
var settingsScopeService = typeof ctx.get === "function" ? ctx.get("settingsScope") : undefined;
|
|
970
|
+
var scope = settingsScopeService && typeof settingsScopeService.bind === "function"
|
|
971
|
+
? settingsScopeService.bind({ namespace: NAMESPACE })
|
|
972
|
+
: undefined;
|
|
959
973
|
// 画布顶栏「重启 / 关闭 ComfyUI」按钮 → 写 settings.comfyControl,
|
|
960
974
|
// host watcher 执行 kill / restart(结果由可达性探测反映到状态圆点)。
|
|
961
975
|
document.addEventListener("dsh-comfyui-control", function (e) {
|
|
@@ -966,7 +980,7 @@ function apply(ctx) {
|
|
|
966
980
|
});
|
|
967
981
|
// 让画布 iframe 使用设置里的地址(并跟随变更)。
|
|
968
982
|
var syncConfig = function () {
|
|
969
|
-
var snap = scope.getSnapshot();
|
|
983
|
+
var snap = scope ? scope.getSnapshot() : undefined;
|
|
970
984
|
var v = snap && snap.value;
|
|
971
985
|
var base = v && typeof v.baseUrl === "string" && v.baseUrl
|
|
972
986
|
? v.baseUrl : DEFAULT_BASE;
|
|
@@ -984,7 +998,7 @@ function apply(ctx) {
|
|
|
984
998
|
// 实时应用右侧面板宽度(发布 CSS 变量,分屏挤压样式引用)。
|
|
985
999
|
applyRailWidth(v?.railWidth != null ? v.railWidth : DEFAULT_RAIL);
|
|
986
1000
|
};
|
|
987
|
-
scope.subscribe(syncConfig);
|
|
1001
|
+
if (scope) scope.subscribe(syncConfig);
|
|
988
1002
|
|
|
989
1003
|
// 全局看门狗:保证分屏标记与真实分屏态一致,杜绝 data-dsh-split-on 残留。
|
|
990
1004
|
// 挤压规则只在 html[data-dsh-split-on="1"] 时生效;一旦残留打上该属性,
|
|
@@ -998,7 +1012,7 @@ function apply(ctx) {
|
|
|
998
1012
|
return tab ? (tab.textContent || "").trim() : "";
|
|
999
1013
|
};
|
|
1000
1014
|
var enforceSplitMarker = function () {
|
|
1001
|
-
var snap = scope.getSnapshot();
|
|
1015
|
+
var snap = scope ? scope.getSnapshot() : undefined;
|
|
1002
1016
|
var v = snap && snap.value ? snap.value : {};
|
|
1003
1017
|
var map = v.splitEnabledBySession || {};
|
|
1004
1018
|
var anyEnabled = Object.keys(map).some(function (k) { return map[k] === true; });
|
|
@@ -1026,7 +1040,7 @@ function apply(ctx) {
|
|
|
1026
1040
|
}
|
|
1027
1041
|
};
|
|
1028
1042
|
var splitWatchdog = null;
|
|
1029
|
-
scope.subscribe(enforceSplitMarker);
|
|
1043
|
+
if (scope) scope.subscribe(enforceSplitMarker);
|
|
1030
1044
|
if (typeof MutationObserver === "function") {
|
|
1031
1045
|
splitWatchdog = new MutationObserver(enforceSplitMarker);
|
|
1032
1046
|
splitWatchdog.observe(
|
|
@@ -1051,14 +1065,16 @@ function apply(ctx) {
|
|
|
1051
1065
|
var onNarrow = function () {
|
|
1052
1066
|
var now = narrowQuery ? narrowQuery.matches : (window.innerWidth < 1200);
|
|
1053
1067
|
if (now && !narrowWas) {
|
|
1054
|
-
var snap = scope.getSnapshot();
|
|
1068
|
+
var snap = scope ? scope.getSnapshot() : undefined;
|
|
1055
1069
|
var v = snap && snap.value ? snap.value : {};
|
|
1056
1070
|
var map = v.splitEnabledBySession || {};
|
|
1057
1071
|
var anyEnabled = Object.keys(map).some(function (k) { return map[k] === true; });
|
|
1058
1072
|
if (anyEnabled) {
|
|
1059
1073
|
var cleared = {};
|
|
1060
1074
|
for (var k in map) cleared[k] = false;
|
|
1061
|
-
|
|
1075
|
+
if (scope && typeof scope.set === "function") {
|
|
1076
|
+
scope.set("splitEnabledBySession", cleared).catch(function () { /* recover handled by scope */ });
|
|
1077
|
+
}
|
|
1062
1078
|
// 同步清理 DOM,避免 settings 异步落地前挤压样式/画布残留。
|
|
1063
1079
|
document.documentElement.removeAttribute("data-dsh-split-on");
|
|
1064
1080
|
document.documentElement.removeAttribute("data-dsh-rail-closed");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-comfyui-canvas",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Give DeepSeek Harness agents live control of your ComfyUI canvas (local or cloud): embed it as a split-screen tab, then read/edit/run workflows, debug errors, fetch output images, and batch-sweep parameters straight from the chat. Ships the ComfyUI-side bridge node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -49,8 +49,7 @@
|
|
|
49
49
|
"client": {
|
|
50
50
|
"platform": "web",
|
|
51
51
|
"inject": [
|
|
52
|
-
"@deepseek-ai/dsh-client-ui-settings"
|
|
53
|
-
"@deepseek-ai/dsh-client-runtime"
|
|
52
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
54
53
|
]
|
|
55
54
|
},
|
|
56
55
|
"bundle": { "patch": "./cordis.patch.yml" }
|