bizydraft 0.2.49__py3-none-any.whl → 0.2.87__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.

Potentially problematic release.


This version of bizydraft might be problematic. Click here for more details.

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