bizydraft 0.2.31__py3-none-any.whl → 0.2.78.dev20251117024007__py3-none-any.whl

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.
@@ -1,217 +1,132 @@
1
1
  import { app } from "../../scripts/app.js";
2
2
  import '../BizyAir/bizyair_frontend.js'
3
- import { hideWidget } from './tool.js'
4
-
5
- // 白名单配置 - 不符合正则表达式的节点名称和对应的模型类型
6
- const WHITELIST_NODES = {
7
- "LayerMask: YoloV8Detect": "Detection",
8
- "Lora Loader Stack (rgthree)": "LoRa",
9
- "easy loraNames": "LoRa",
10
- "easy loraStack": "LoRa",
11
- "Load Lora": "LoRa",
12
- "Intrinsic_lora_sampling": "LoRa",
13
- "ADE_LoadAnimateDiffModel": "Checkpoint",
14
- "ADE_AnimateDiffLoRALoader": "LoRa",
15
- "easy ultralyticsDetectorPipe": "Detection",
16
- "UltralyticsDetectorProvider": "Detection",
17
- "SAMLoader": "Detection",
18
- "easy samLoaderPipe": "Detection",
19
- };
20
- const HAZY_WHITELIST_NODES = {
21
-
22
- }
23
-
24
- const possibleWidgetNames=[
25
- "clip_name",
26
- "clip_name1",
27
- "clip_name2",
28
- "clip_name3",
29
- "ckpt_name",
30
- "lora_name",
31
- "name",
32
- "lora_01",
33
- "lora_02",
34
- "lora_03",
35
- "lora_04",
36
- "lora_1_name",
37
- "lora_2_name",
38
- "lora_3_name",
39
- "lora_4_name",
40
- "lora_5_name",
41
- "lora_6_name",
42
- "lora_7_name",
43
- "lora_8_name",
44
- "lora_9_name",
45
- "lora_10_name",
46
- "lora_11_name",
47
- "lora_12_name",
48
- "model_name",
49
- "control_net_name",
50
- "ipadapter_file",
51
- "unet_name",
52
- "vae_name",
53
- "model_name",
54
- "instantid_file",
55
- "pulid_file",
56
- "style_model_name",
57
- "yolo_model"
58
- ]
59
-
60
- // 根据节点名称匹配模型类型
61
- function getModelTypeFromNodeName(nodeName) {
62
- if (/bizyair/i.test(nodeName)) {
63
- return null;
64
- }
65
- // 首先检查白名单
66
- if (WHITELIST_NODES.hasOwnProperty(nodeName)) {
67
- console.log(`白名单匹配: ${nodeName} -> ${WHITELIST_NODES[nodeName]}`);
68
- return WHITELIST_NODES[nodeName];
69
- }
70
- const HAZY_WHITELIST_NODES_KEYS = Object.keys(HAZY_WHITELIST_NODES);
71
- const thisKey = HAZY_WHITELIST_NODES_KEYS.find(key => nodeName.toLowerCase().includes(key.toLowerCase()));
72
- if (thisKey) {
73
- console.log(`模糊白名单匹配: ${nodeName} -> ${HAZY_WHITELIST_NODES[thisKey]}`);
74
- return HAZY_WHITELIST_NODES[thisKey];
75
- }
76
-
77
-
78
- // 然后使用正则表达式匹配
79
- const regex = /^(\w+).*Loader.*/i;
80
- const match = nodeName.match(regex);
81
- if (match) {
82
- return match[1];
83
- }
84
- return null;
85
- }
86
-
87
- function createSetWidgetCallback(modelType, selectedBaseModels = []) {
88
- return function setWidgetCallback() {
89
- const targetWidget = this.widgets.filter(widget => possibleWidgetNames.includes(widget.name));
90
- targetWidget.forEach((wdt, index) => {
91
- wdt.value = wdt.value || "to choose"
92
- wdt.mouse = function(e, pos, canvas) {
93
- try {
94
- if (e.type === "pointerdown" || e.type === "mousedown" || e.type === "click" || e.type === "pointerup") {
95
- e.preventDefault();
96
- e.stopPropagation();
97
- e.widgetClick = true;
98
-
99
- const currentNode = this.node;
100
-
101
- if (!currentNode || !currentNode.widgets) {
102
- console.warn("Node or widgets not available");
103
- return false;
104
- }
105
-
106
- if (typeof bizyAirLib !== 'undefined' && typeof bizyAirLib.showModelSelect === 'function') {
107
- bizyAirLib.showModelSelect({
108
- modelType: [modelType],
109
- selectedBaseModels,
110
- onApply: (version, model) => {
111
- if (!currentNode || !currentNode.widgets) return;
112
-
113
- const currentLora = currentNode.widgets.filter(widget => possibleWidgetNames.includes(widget.name));
114
- let currentModel;
115
-
116
- if (index === 0) {
117
- currentModel = currentNode.widgets.find(w => w.name === "model_version_id");
118
- } else {
119
- const fieldName = `model_version_id${index + 1}`;
120
- currentModel = currentNode.widgets.find(w => w.name === fieldName);
121
- }
122
-
123
- if (model && currentModel && version) {
124
- currentLora[index].value = model;
125
-
126
- currentModel.value = version.id;
127
- currentNode.setDirtyCanvas(true);
128
- }
129
- }
130
- });
131
- } else {
132
- console.error("bizyAirLib not available");
133
- }
134
- return false;
135
- }
136
- } catch (error) {
137
- console.error("Error handling mouse event:", error);
138
- }
139
- };
140
-
141
- // wdt.node = this;
142
- wdt.options = wdt.options || {};
143
- wdt.options.values = () => [];
144
- wdt.options.editable = false;
145
- wdt.clickable = true;
146
- wdt.processMouse = true;
147
- });
148
- }
149
- }
150
-
151
- function setupNodeMouseBehavior(node, modelType) {
152
- hideWidget(node, "model_version_id");
153
-
154
- // 只设置必要的状态信息,不修改onMouseDown(已在上面的扩展中处理)
155
- if (!node._bizyairState) {
156
- node._bizyairState = {
157
- lastClickTime: 0,
158
- DEBOUNCE_DELAY: 300,
159
- modelType: modelType
160
- };
161
- }
162
- }
163
-
3
+ import {
4
+ getNodeConfig,
5
+ createSetWidgetCallback,
6
+ setupNodeMouseBehavior,
7
+ addBadge,
8
+ possibleWidgetNames
9
+ } from './hookLoad/model.js'
10
+
11
+ // 存储清理标志
12
+ let storageClearedOnce = false;
164
13
  app.registerExtension({
165
14
  name: "bizyair.hook.load.model",
166
15
  async beforeRegisterNodeDef(nodeType, nodeData, app) {
167
16
 
168
- localStorage.removeItem('workflow')
169
- sessionStorage.clear()
17
+ if (!storageClearedOnce) {
18
+ // localStorage.removeItem('workflow')
19
+ localStorage.clear()
20
+ sessionStorage.clear()
21
+ storageClearedOnce = true;
22
+ }
170
23
  const interval = setInterval(() => {
171
24
  if (window.switchLanguage) {
172
25
  window.switchLanguage('zh')
173
26
  clearInterval(interval)
174
27
  }
175
28
  }, 100)
176
- const modelType = getModelTypeFromNodeName(nodeData.name);
177
- if (modelType) {
178
- const onNodeCreated = nodeType.prototype.onNodeCreated;
29
+
30
+ // 异步获取节点配置
31
+ const onNodeCreated = nodeType.prototype.onNodeCreated;
32
+ const nodeConfig = await getNodeConfig(nodeData.name);
33
+ if (nodeConfig) {
179
34
  nodeType.prototype.onNodeCreated = function() {
180
35
  try {
181
- const targetWidget = this.widgets.filter(widget => possibleWidgetNames.includes(widget.name));
182
- // 为每个targetWidget添加对应的model_version_id字段
183
- targetWidget.forEach((widget, index) => {
184
- let model_version_id;
185
- if (index === 0) {
186
- // 第一个保持原名
187
- model_version_id = this.widgets.find(w => w.name === "model_version_id");
188
- if (!model_version_id) {
189
- model_version_id = this.addWidget("hidden", "model_version_id", "", function(){
190
- }, {
191
- serialize: true,
192
- values: []
193
- });
194
- }
195
- } else {
196
- // 从第二个开始使用新名称
197
- const fieldName = `model_version_id${index + 1}`;
198
- model_version_id = this.widgets.find(w => w.name === fieldName);
199
- if (!model_version_id) {
200
- model_version_id = this.addWidget("hidden", fieldName, "", function(){
201
- }, {
202
- serialize: true,
203
- values: []
204
- });
205
- }
36
+ const inputs = nodeConfig.config.inputs;
37
+ const inputKeys = Object.keys(inputs);
38
+
39
+ // 计算需处理的目标widgets(按禁用过滤后再确定数量和索引)
40
+ let targetWidgets = [];
41
+ // 优先按API字段名匹配
42
+ inputKeys.forEach((key) => {
43
+ const cfg = inputs[key];
44
+ if (cfg && !cfg.disable_comfyagent) {
45
+ const w = this.widgets.find(x => x.name === key);
46
+ if (w) targetWidgets.push(w);
206
47
  }
207
48
  });
49
+ // 如果一个都没匹配到,使用fallback列表
50
+ if (targetWidgets.length === 0) {
51
+ const fallback = this.widgets.filter(w => possibleWidgetNames.includes(w.name));
52
+ // fallback 不再过滤 disable 标记,因为此路径说明API key未命中
53
+ targetWidgets = fallback;
54
+ }
55
+
56
+ // 按目标widgets数量创建隐藏字段(model_version_id, model_version_id2...)
57
+ targetWidgets.forEach((_, idx) => {
58
+ const fieldName = idx === 0 ? "model_version_id" : `model_version_id${idx + 1}`;
59
+ let mv = this.widgets.find(w => w.name === fieldName);
60
+ if (!mv) {
61
+ mv = this.addWidget("hidden", fieldName, "", function(){}, { serialize: true, values: [] });
62
+ }
63
+ });
64
+
65
+ // 如果没有找到匹配的输入字段,使用兼容性逻辑
66
+ if (inputKeys.length === 0) {
67
+ const targetWidget = this.widgets.filter(widget => possibleWidgetNames.includes(widget.name));
68
+ targetWidget.forEach((widget, index) => {
69
+ let model_version_id;
70
+ if (index === 0) {
71
+ model_version_id = this.widgets.find(w => w.name === "model_version_id");
72
+ if (!model_version_id) {
73
+ model_version_id = this.addWidget("hidden", "model_version_id", "", function(){
74
+ }, {
75
+ serialize: true,
76
+ values: []
77
+ });
78
+ }
79
+ } else {
80
+ const fieldName = `model_version_id${index + 1}`;
81
+ model_version_id = this.widgets.find(w => w.name === fieldName);
82
+ if (!model_version_id) {
83
+ model_version_id = this.addWidget("hidden", fieldName, "", function(){
84
+ }, {
85
+ serialize: true,
86
+ values: []
87
+ });
88
+ }
89
+ }
90
+ });
91
+ }
208
92
 
209
93
  const result = onNodeCreated?.apply(this, arguments);
210
94
  let selectedBaseModels = [];
211
- // if (modelType === 'Checkpoint') {
212
- // selectedBaseModels = ['SDXL', 'Pony', 'SD 3.5', 'Illustrious']
213
- // }
214
- createSetWidgetCallback(modelType, selectedBaseModels).call(this);
95
+
96
+ // 检查是否需要添加徽章(与targetWidgets一致的索引规则)
97
+ targetWidgets.forEach((widget, idx) => {
98
+ const fieldName = idx === 0 ? "model_version_id" : `model_version_id${idx + 1}`;
99
+ const mv = this.widgets.find(w => w.name === fieldName);
100
+ if (mv) {
101
+ setTimeout(() => {
102
+ if (widget.value != 'NONE' && !mv.value) addBadge(this);
103
+ }, 200);
104
+ }
105
+ });
106
+
107
+ // 如果没有找到匹配的输入字段,使用兼容性逻辑检查徽章
108
+ if (inputKeys.length === 0) {
109
+ const targetWidget = this.widgets.filter(widget => possibleWidgetNames.includes(widget.name));
110
+ targetWidget.forEach((widget, index) => {
111
+ let model_version_id;
112
+ if (index === 0) {
113
+ model_version_id = this.widgets.find(w => w.name === "model_version_id");
114
+ } else {
115
+ const fieldName = `model_version_id${index + 1}`;
116
+ model_version_id = this.widgets.find(w => w.name === fieldName);
117
+ }
118
+
119
+ if (model_version_id) {
120
+ setTimeout(() => {
121
+ if (widget.value != 'NONE' && !model_version_id.value) {
122
+ addBadge(this);
123
+ }
124
+ }, 200);
125
+ }
126
+ });
127
+ }
128
+
129
+ createSetWidgetCallback(nodeConfig, selectedBaseModels).call(this);
215
130
  return result;
216
131
  } catch (error) {
217
132
  console.error("Error in node creation:", error);
@@ -220,10 +135,56 @@ app.registerExtension({
220
135
  }
221
136
  },
222
137
  async nodeCreated(node) {
223
- const modelType = getModelTypeFromNodeName(node?.comfyClass);
138
+ const nodeConfig = await getNodeConfig(node?.comfyClass);
139
+
140
+ if (nodeConfig) {
141
+ setupNodeMouseBehavior(node, nodeConfig);
142
+ }
143
+ },
144
+ async setup() {
145
+ const app = document.querySelector('#vue-app').__vue_app__
146
+ const pinia = app.config.globalProperties.$pinia
147
+ const settingStore = pinia._s.get('setting')
148
+ await settingStore.set('Comfy.Workflow.ShowMissingModelsWarning', false)
149
+
150
+
151
+
224
152
 
225
- if (modelType) {
226
- setupNodeMouseBehavior(node, modelType);
153
+ // 获取 toastStore
154
+ const toastStore = pinia._s.get('toast');
155
+
156
+ // 保存原始的 add 方法
157
+ const originalAdd = toastStore.add;
158
+
159
+ // 重写 add 方法,添加过滤逻辑
160
+ toastStore.add = function(message) {
161
+ const detail = (message.detail || '').toLowerCase();
162
+ const summary = (message.summary || '').toLowerCase();
163
+ const text = `${summary} ${detail}`;
164
+
165
+ // 检查是否包含阻止的关键词
166
+ const blockedKeywords = [
167
+ 'missing dependencies',
168
+ 'comfyui logs',
169
+ 'comfyullogs',
170
+ 'refer to the comfyui',
171
+ 'you may be missing'
172
+ ];
173
+
174
+ const shouldBlock = blockedKeywords.some(keyword =>
175
+ text.includes(keyword.toLowerCase())
176
+ );
177
+
178
+ // 如果包含阻止的关键词,则不添加 toast
179
+ if (shouldBlock) {
180
+ console.log('Blocked toast:', message);
181
+ return;
227
182
  }
183
+
184
+ // 否则正常添加
185
+ return originalAdd.call(this, message);
186
+ };
187
+
188
+ console.log('Toast blocker activated!');
228
189
  }
229
190
  })
@@ -1,4 +1,6 @@
1
1
  // 主入口文件,导入所有模块
2
- import "./hookLoadImage.js";
2
+ import "./disableComfyWebSocket.js";
3
+ import "./hookLoadMedia.js";
3
4
  import "./postEvent.js";
4
5
  import "./handleStyle.js";
6
+ import "./clipspaceToOss.js";