bizydraft 0.2.75.dev20251022074525__py3-none-any.whl → 0.2.75.dev20251022081333__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.

@@ -0,0 +1,70 @@
1
+ // 媒体节点配置获取与工具函数(与 hookLoad/model.js 结构一致,面向 media_load_nodes)
2
+
3
+ // 动态配置缓存(仅缓存媒体部分)
4
+ let mediaConfigCache = null;
5
+ let mediaConfigLoadPromise = null;
6
+
7
+ // API配置(与模型相同接口,不同数据块)
8
+ const CONFIG_API_URL = 'https://uat87.bizyair.cn/api/special/comfyagent_node_config?t=' + Math.floor(Date.now() / 60000);
9
+
10
+ // 常见的媒体输入字段名(作为回退匹配)
11
+ export const possibleMediaWidgetNames = [
12
+ "image",
13
+ "file",
14
+ "audio",
15
+ "video",
16
+ "model_file"
17
+ ];
18
+
19
+ // 获取媒体配置的API函数(只解析 media_load_nodes)
20
+ export async function fetchMediaConfig() {
21
+ if (mediaConfigCache) return mediaConfigCache;
22
+ if (mediaConfigLoadPromise) return mediaConfigLoadPromise;
23
+
24
+ mediaConfigLoadPromise = (async () => {
25
+ try {
26
+ const response = await fetch(CONFIG_API_URL, { credentials: 'include' });
27
+ if (!response || !response.ok) {
28
+ throw new Error('HTTP error ' + (response && response.status));
29
+ }
30
+ const result = await response.json();
31
+ if (result && result.code === 20000 && result.data && result.data.media_load_nodes) {
32
+ mediaConfigCache = result.data.media_load_nodes;
33
+ return mediaConfigCache;
34
+ }
35
+ throw new Error('API返回数据不包含 media_load_nodes');
36
+ } catch (err) {
37
+ console.error('获取媒体配置失败:', err);
38
+ mediaConfigCache = null;
39
+ return null;
40
+ }
41
+ })();
42
+
43
+ return mediaConfigLoadPromise;
44
+ }
45
+
46
+ // 根据节点名称获取媒体节点配置(仅使用缓存,不阻塞返回;触发后台预取)
47
+ export async function getMediaNodeConfig(nodeName) {
48
+ // 后台触发一次预取
49
+ if (!mediaConfigLoadPromise) { try { void fetchMediaConfig(); } catch (e) {} }
50
+
51
+ if (mediaConfigCache && mediaConfigCache[nodeName]) {
52
+ return { nodeName, config: mediaConfigCache[nodeName] };
53
+ }
54
+ return null;
55
+ }
56
+
57
+ // 从媒体配置中提取此节点的输入键(过滤 disable_comfyagent)
58
+ export function getMediaInputKeys(mediaNodeConfig) {
59
+ if (!mediaNodeConfig || !mediaNodeConfig.config || !mediaNodeConfig.config.inputs) return [];
60
+ const inputs = mediaNodeConfig.config.inputs;
61
+ const keys = [];
62
+ for (const key of Object.keys(inputs)) {
63
+ const cfg = inputs[key];
64
+ if (cfg && !cfg.disable_comfyagent) keys.push(key);
65
+ }
66
+ return keys;
67
+ }
68
+
69
+ // 启动时后台预取(不阻塞后续逻辑)
70
+ try { void fetchMediaConfig(); } catch (e) {}
@@ -0,0 +1,296 @@
1
+ import { hideWidget } from '../tool.js'
2
+
3
+ // 动态配置缓存
4
+ let nodeConfigCache = null;
5
+ let configLoadPromise = null;
6
+ let storageClearedOnce = false;
7
+
8
+ // API配置
9
+ const CONFIG_API_URL = 'https://uat87.bizyair.cn/api/special/comfyagent_node_config?t=' + Math.floor(Date.now() / 60000);
10
+
11
+ const HAZY_WHITELIST_NODES = {
12
+
13
+ }
14
+
15
+ export const possibleWidgetNames=[
16
+ "clip_name",
17
+ "clip_name1",
18
+ "clip_name2",
19
+ "clip_name3",
20
+ "clip_name4",
21
+ "ckpt_name",
22
+ "lora_name",
23
+ "name",
24
+ "lora",
25
+ "lora_01",
26
+ "lora_02",
27
+ "lora_03",
28
+ "lora_04",
29
+ "lora_1_name",
30
+ "lora_2_name",
31
+ "lora_3_name",
32
+ "lora_4_name",
33
+ "lora_5_name",
34
+ "lora_6_name",
35
+ "lora_7_name",
36
+ "lora_8_name",
37
+ "lora_9_name",
38
+ "lora_10_name",
39
+ "lora_11_name",
40
+ "lora_12_name",
41
+ "model_name",
42
+ "control_net_name",
43
+ "ipadapter_file",
44
+ "unet_name",
45
+ "vae_name",
46
+ "model",
47
+ "model_name",
48
+ "instantid_file",
49
+ "pulid_file",
50
+ "style_model_name",
51
+ "yolo_model",
52
+ "face_model",
53
+ "bbox_model_name",
54
+ "sam_model_name",
55
+ "model_path",
56
+ "upscale_model",
57
+ "supir_model",
58
+ "sdxl_model",
59
+ "upscale_model_1",
60
+ "upscale_model_2",
61
+ "upscale_model_3",
62
+ "sam_model",
63
+ "sam2_model",
64
+ "grounding_dino_model"
65
+ ]
66
+
67
+ // 获取节点配置的API函数
68
+ export async function fetchNodeConfig() {
69
+ if (nodeConfigCache) {
70
+ return nodeConfigCache;
71
+ }
72
+
73
+ if (configLoadPromise) {
74
+ return configLoadPromise;
75
+ }
76
+
77
+ configLoadPromise = (async () => {
78
+ try {
79
+ console.log('正在从API获取节点配置...');
80
+ const response = await fetch(CONFIG_API_URL, { credentials: 'include' });
81
+
82
+ if (!response.ok) {
83
+ throw new Error(`HTTP error! status: ${response.status}`);
84
+ }
85
+
86
+ const result = await response.json();
87
+
88
+ if (result.code === 20000 && result.data && result.data.weight_load_nodes) {
89
+ nodeConfigCache = result.data.weight_load_nodes;
90
+ console.log('节点配置加载成功:', Object.keys(nodeConfigCache).length, '个节点');
91
+ return nodeConfigCache;
92
+ } else {
93
+ throw new Error('API返回数据格式不正确');
94
+ }
95
+ } catch (error) {
96
+ console.error('获取节点配置失败:', error);
97
+ nodeConfigCache = null;
98
+ return null;
99
+ }
100
+ })();
101
+
102
+ return configLoadPromise;
103
+ }
104
+
105
+ // 读取 mode_type(不再兼容旧的 modelType)
106
+ export function getModelTypeFromInput(inputConfig) {
107
+ console.log('inputConfig', inputConfig);
108
+ if (!inputConfig) return undefined;
109
+ console.log('inputConfig', inputConfig);
110
+ return inputConfig.mode_type;
111
+ }
112
+
113
+ // 根据节点名称获取节点配置信息(名单优先,正则补充;不阻塞返回)
114
+ export async function getNodeConfig(nodeName) {
115
+ if (/bizyair/i.test(nodeName)) {
116
+ return null;
117
+ }
118
+
119
+ // 1) 名单(API)优先(仅用缓存,不等待网络)
120
+ if (nodeConfigCache && nodeConfigCache[nodeName]) {
121
+ return { nodeName, config: nodeConfigCache[nodeName] };
122
+ }
123
+
124
+ // 若尚未发起请求,后台发起一次
125
+ if (!configLoadPromise) { try { void fetchNodeConfig(); } catch (e) {} }
126
+
127
+ // 2) 正则补充:如 XxxLoader => Xxx(立即返回,不等待API)
128
+ const regex = /^(\w+).*Loader.*/i;
129
+ const match = nodeName.match(regex);
130
+ if (match) {
131
+ const inferredType = match[1];
132
+ return { nodeName, config: { inputs: { [nodeName]: { mode_type: inferredType, required: true } } } };
133
+ }
134
+ return null;
135
+ }
136
+
137
+ export function createSetWidgetCallback(nodeConfig, selectedBaseModels = []) {
138
+ return function setWidgetCallback() {
139
+ if (!nodeConfig || !nodeConfig.config || !nodeConfig.config.inputs) {
140
+ console.warn('节点配置无效:', nodeConfig);
141
+ return;
142
+ }
143
+
144
+ const inputs = nodeConfig.config.inputs;
145
+ const inputKeys = Object.keys(inputs);
146
+
147
+ // 根据API配置找到对应的widget
148
+ const targetWidgets = [];
149
+ inputKeys.forEach(inputKey => {
150
+ const widget = this.widgets.find(w => w.name === inputKey);
151
+ if (widget) {
152
+ targetWidgets.push({
153
+ widget: widget,
154
+ inputKey: inputKey,
155
+ inputConfig: inputs[inputKey]
156
+ });
157
+ }
158
+ });
159
+
160
+ // 如果没有找到匹配的widget,使用原来的逻辑作为备选
161
+ if (targetWidgets.length === 0) {
162
+ const fallbackWidgets = this.widgets.filter(widget => possibleWidgetNames.includes(widget.name));
163
+ fallbackWidgets.forEach((wdt, index) => {
164
+ const firstInput = Object.values(inputs)[0];
165
+ if (firstInput) {
166
+ targetWidgets.push({
167
+ widget: wdt,
168
+ inputKey: wdt.name,
169
+ inputConfig: firstInput,
170
+ index: index
171
+ });
172
+ }
173
+ });
174
+ }
175
+
176
+ targetWidgets.forEach(({ widget, inputKey, inputConfig, index }) => {
177
+ // 检查是否禁用comfyagent
178
+ if (inputConfig.disable_comfyagent) {
179
+ console.log(`跳过禁用的widget: ${inputKey}`);
180
+ return;
181
+ }
182
+
183
+ widget.value = widget.value || "to choose";
184
+ widget.mouse = function(e, pos, canvas) {
185
+ try {
186
+ if (e.type === "pointerdown" || e.type === "mousedown" || e.type === "click" || e.type === "pointerup") {
187
+ e.preventDefault();
188
+ e.stopPropagation();
189
+ e.widgetClick = true;
190
+ window.parent.postMessage({
191
+ type: 'collapsePublishWorkflowDialog',
192
+ method: 'collapsePublishWorkflowDialog',
193
+ result: true
194
+ }, '*');
195
+ const currentNode = this.node;
196
+
197
+ if (!currentNode || !currentNode.widgets) {
198
+ console.warn("Node or widgets not available");
199
+ return false;
200
+ }
201
+
202
+ if (typeof bizyAirLib !== 'undefined' && typeof bizyAirLib.showModelSelect === 'function') {
203
+ bizyAirLib.showModelSelect({
204
+ modelType: [getModelTypeFromInput(inputConfig)],
205
+ selectedBaseModels,
206
+ onApply: (version, model) => {
207
+ if (!currentNode || !currentNode.widgets) return;
208
+
209
+ // 更新widget值
210
+ widget.value = version.file_name;
211
+
212
+ // 找到对应的隐藏字段(固定命名:model_version_id, model_version_id2...)
213
+ let modelVersionField;
214
+ // 真实绑定顺序应与targetWidgets相同,因此通过当前widget在targetWidgets的索引定位
215
+ const twIndex = targetWidgets.findIndex(tw => tw.widget === widget);
216
+ const fieldName = twIndex === 0 ? "model_version_id" : `model_version_id${twIndex + 1}`;
217
+ modelVersionField = currentNode.widgets.find(w => w.name === fieldName);
218
+
219
+ if (model && modelVersionField && version) {
220
+ modelVersionField.value = version.id;
221
+ currentNode.setDirtyCanvas(true);
222
+
223
+ // 删除节点上的感叹号徽章
224
+ if (currentNode && currentNode.badges && Array.isArray(currentNode.badges)) {
225
+ // 移除 text 为 '!' 的徽章
226
+ currentNode.badges = currentNode.badges.filter(badgeFn => {
227
+ try {
228
+ const badge = typeof badgeFn === 'function' ? badgeFn() : badgeFn;
229
+ return badge.text !== '!';
230
+ } catch (e) {
231
+ return true;
232
+ }
233
+ });
234
+ // 同时移除 hasTips 标记
235
+ if (currentNode.hasTips) {
236
+ delete currentNode.hasTips;
237
+ }
238
+ }
239
+ }
240
+ }
241
+ });
242
+ } else {
243
+ console.error("bizyAirLib not available");
244
+ }
245
+ return false;
246
+ }
247
+ } catch (error) {
248
+ console.error("Error handling mouse event:", error);
249
+ }
250
+ };
251
+
252
+ widget.options = widget.options || {};
253
+ widget.options.values = () => [];
254
+ widget.options.editable = false;
255
+ widget.clickable = true;
256
+ widget.processMouse = true;
257
+ });
258
+ }
259
+ }
260
+
261
+ export function setupNodeMouseBehavior(node, nodeConfig) {
262
+ // 固定隐藏主版本ID字段(其余编号字段为hidden类型本身不可见)
263
+ hideWidget(node, "model_version_id");
264
+
265
+ // 只设置必要的状态信息,不修改onMouseDown(已在上面的扩展中处理)
266
+ if (!node._bizyairState) {
267
+ node._bizyairState = {
268
+ lastClickTime: 0,
269
+ DEBOUNCE_DELAY: 300,
270
+ nodeConfig: nodeConfig
271
+ };
272
+ }
273
+ }
274
+
275
+ export function addBadge(node) {
276
+ const customBadge = new LGraphBadge({
277
+ text: '!',
278
+ fgColor: 'white',
279
+ bgColor: '#FF6B6B',
280
+ fontSize: 12,
281
+ padding: 8,
282
+ height: 20,
283
+ cornerRadius: 10
284
+ })
285
+ if (!Array.isArray(node.badges)) {
286
+ node.badges = []
287
+ }
288
+ if (node.hasTips) {
289
+ return
290
+ }
291
+ node.badges.push(() => customBadge);
292
+ node.hasTips = true;
293
+ }
294
+
295
+ // 启动时后台预取(不阻塞后续逻辑)
296
+ try { void fetchNodeConfig(); } catch (e) { /* noop */ }
@@ -3,11 +3,9 @@ import { getCookie, computeIsLoadNode, computeExt, hideWidget } from './tool.js'
3
3
  import { getMediaNodeConfig, getMediaInputKeys, possibleMediaWidgetNames } from './hookLoad/media.js';
4
4
 
5
5
 
6
- console.log('hookLoadImage.js 已加载');
7
6
  app.registerExtension({
8
7
  name: "bizyair.image.to.oss",
9
8
  async beforeRegisterNodeDef(nodeType, nodeData) {
10
- console.log('beforeRegisterNodeDef 被调用,节点:', nodeData.name);
11
9
  let workflowParams = null
12
10
  document.addEventListener('workflowLoaded', (event) => {
13
11
  workflowParams = event.detail;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bizydraft
3
- Version: 0.2.75.dev20251022074525
3
+ Version: 0.2.75.dev20251022081333
4
4
  Summary: bizydraft
5
5
  Requires-Dist: loguru
6
6
  Requires-Dist: aiohttp
@@ -15,7 +15,7 @@ bizydraft/static/js/clipspaceToOss.js,sha256=brfEPs71Tky5Dnc47UXNEFeFlESDE3kQvUH
15
15
  bizydraft/static/js/disableComfyWebSocket.js,sha256=nL6DjLUdC2FlAqfYPaFW-dAtkamv01c461W0DUupIKk,1124
16
16
  bizydraft/static/js/freezeModeHandler.js,sha256=SjpHD2nYymR-E13B0YcqkA6e4WycZOVI3c48Ts9qvWE,18027
17
17
  bizydraft/static/js/handleStyle.js,sha256=liIzTu-wnV172g58gHWGLYTfd86xpJxL4A-HuHpFnq4,3616
18
- bizydraft/static/js/hookLoadImage.js,sha256=SOxkmSO8gRiiTw9QZ_LzIGtnFFDkBTieG1f7ZfVF2b0,14980
18
+ bizydraft/static/js/hookLoadImage.js,sha256=zQdz3BMVwuD951vjYTb11cyFHRKJmRrNqUKy1EB5EBY,14856
19
19
  bizydraft/static/js/hookLoadModel.js,sha256=TWVmfKp45ta-nE6U5rY3Bv9wiaEBp0QMNt2xaQ3fs9g,6720
20
20
  bizydraft/static/js/main.js,sha256=PRe4LdsquEQWrZDnVd4ubpVQuD1eDIedAXFFazKdoKQ,188
21
21
  bizydraft/static/js/nodeFocusHandler.js,sha256=24xXbS4Q-GjJdRqf11i-1pBo8MkOJ24F7MHFV44EG6Q,4683
@@ -25,7 +25,9 @@ bizydraft/static/js/socket.js,sha256=VE3fTAgEfM0FZhL526Skt7OCRokOa3mzTCAjAomI_tE
25
25
  bizydraft/static/js/tool.js,sha256=VupamUuh7tYiDnBTrL5Z_yLmhJinskhzRXwE3zfsKZM,2901
26
26
  bizydraft/static/js/uploadFile.js,sha256=WvglKzHMeOzDhOH3P-fLcPHxCLbKOJpo4DntoRxeJtI,4908
27
27
  bizydraft/static/js/workflow_io.js,sha256=FWAjncvWhvy-3nN_legD2fpRwgnIncpRLHU5X016a-U,5236
28
- bizydraft-0.2.75.dev20251022074525.dist-info/METADATA,sha256=uGQlG7rbTjOa9BLkiEPnbEjj2ooLauB2fIUeBqWkJ3E,180
29
- bizydraft-0.2.75.dev20251022074525.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- bizydraft-0.2.75.dev20251022074525.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
31
- bizydraft-0.2.75.dev20251022074525.dist-info/RECORD,,
28
+ bizydraft/static/js/hookLoad/media.js,sha256=BD9RJxTMGO8wagOI9IZNYzKfsOnpyl0JtEUghpURpaI,2620
29
+ bizydraft/static/js/hookLoad/model.js,sha256=C7Hi6BkdtEAgNCwpT71ZRgv9BaYKBsyNu8wt9h5hYvk,10576
30
+ bizydraft-0.2.75.dev20251022081333.dist-info/METADATA,sha256=1oq9Q-YdLKiG6ScohFvuB1do-mmbnXc3gEuymNZCis4,180
31
+ bizydraft-0.2.75.dev20251022081333.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
+ bizydraft-0.2.75.dev20251022081333.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
33
+ bizydraft-0.2.75.dev20251022081333.dist-info/RECORD,,