bizydraft 0.2.72.dev20251013070955__py3-none-any.whl → 0.2.73.dev20251015100429__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.

@@ -12,6 +12,11 @@ function findOssUrl(filename) {
12
12
  || window.CLIPSPACE_TO_OSS_MAP[`${filename} [output]`];
13
13
  }
14
14
 
15
+ // 去掉末尾的 " [input]" 或 " [output]" 后缀
16
+ function stripTypeSuffix(value) {
17
+ if (!value || typeof value !== 'string') return value;
18
+ return value.replace(/\s\[(input|output)\]$/i, '');
19
+ }
15
20
  // ═══════════════════════════════════════════════════════════════════════════
16
21
  // 工具函数:替换 clipspace URL 为 OSS URL
17
22
  // ═══════════════════════════════════════════════════════════════════════════
@@ -51,9 +56,6 @@ function replaceClipspaceUrl(urlString) {
51
56
  },
52
57
  set(value) {
53
58
  const modifiedValue = replaceClipspaceUrl(value);
54
- if (modifiedValue !== value) {
55
- console.log('[BizyDraft Image] Redirected:', value, '->', modifiedValue);
56
- }
57
59
  originalSrcDescriptor.set.call(this, modifiedValue);
58
60
  },
59
61
  configurable: true
@@ -63,15 +65,10 @@ function replaceClipspaceUrl(urlString) {
63
65
  HTMLImageElement.prototype.setAttribute = function(name, value) {
64
66
  if (name === 'src') {
65
67
  const modifiedValue = replaceClipspaceUrl(value);
66
- if (modifiedValue !== value) {
67
- console.log('[BizyDraft setAttribute] Redirected to OSS');
68
- }
69
68
  return originalSetAttribute.call(this, name, modifiedValue);
70
69
  }
71
70
  return originalSetAttribute.call(this, name, value);
72
71
  };
73
-
74
- console.log('[BizyDraft] Image interceptor installed');
75
72
  })();
76
73
 
77
74
  // ═══════════════════════════════════════════════════════════════════════════
@@ -87,7 +84,6 @@ api.fetchApi = async function(url, options) {
87
84
  if (!isUploadApi || !response.ok) {
88
85
  return response;
89
86
  }
90
-
91
87
  try {
92
88
  const data = await response.clone().json();
93
89
 
@@ -95,9 +91,7 @@ api.fetchApi = async function(url, options) {
95
91
  const isOssUpload = data.subfolder?.includes('http://') || data.subfolder?.includes('https://')
96
92
  || data.name?.startsWith('http://') || data.name?.startsWith('https://');
97
93
 
98
- if (!isOssUpload) {
99
- return response;
100
- }
94
+ if (!isOssUpload) return response;
101
95
 
102
96
  // 构造完整的 OSS URL
103
97
  const ossUrl = data.subfolder?.includes('http')
@@ -114,9 +108,6 @@ api.fetchApi = async function(url, options) {
114
108
  const idMatch = filename.match(/(\d+)/);
115
109
  const baseId = idMatch?.[1];
116
110
 
117
- console.log('[BizyDraft Upload]', url, '-', filename, `(${imageFile.size} bytes)`);
118
- console.log('[BizyDraft Upload] Backend response:', data.name);
119
-
120
111
  // 第一次 /upload/mask 的结果是涂改后的完整图片
121
112
  if (baseId && url.includes('/upload/mask')) {
122
113
  const firstMaskKey = `__FIRST_MASK_${baseId}__`;
@@ -130,20 +121,15 @@ api.fetchApi = async function(url, options) {
130
121
  `clipspace-painted-${baseId}.png`, `clipspace-painted-masked-${baseId}.png`
131
122
  ].forEach(v => window.CLIPSPACE_TO_OSS_MAP[v] = ossUrl);
132
123
 
133
- console.log('[BizyDraft Upload] ✅ First mask upload, saved to all variants');
134
124
  } else {
135
125
  // 后续 mask 上传,使用首次的 URL
136
126
  finalUrl = window.CLIPSPACE_TO_OSS_MAP[firstMaskKey];
137
- console.log('[BizyDraft Upload] ⏭️ Later mask upload, using first URL');
138
127
  }
139
128
  } else if (baseId) {
140
129
  // /upload/image 的上传,如果已有 mask 则使用 mask 的 URL
141
130
  const firstMaskUrl = window.CLIPSPACE_TO_OSS_MAP[`__FIRST_MASK_${baseId}__`];
142
131
  if (firstMaskUrl) {
143
132
  finalUrl = firstMaskUrl;
144
- console.log('[BizyDraft Upload] 📎 Image upload, using first mask URL');
145
- } else {
146
- console.log('[BizyDraft Upload] ⏳ Image upload, awaiting mask');
147
133
  }
148
134
  }
149
135
 
@@ -157,18 +143,44 @@ api.fetchApi = async function(url, options) {
157
143
  window.CLIPSPACE_TO_OSS_MAP[filenameWithoutSuffix] = finalUrl;
158
144
  }
159
145
 
160
- console.log('[BizyDraft Upload] 💾 Mapped:', filename, '->', finalUrl);
161
146
  }
162
147
  }
163
148
 
164
149
  // 同时保存后端返回的文件名映射
165
150
  window.CLIPSPACE_TO_OSS_MAP[data.name] = finalUrl;
166
151
 
152
+ // 🔧 修改 ComfyApp.clipspace,让它使用 OSS URL 而不是 clipspace 路径
153
+ if (window.app?.constructor?.clipspace) {
154
+ const clipspace = window.app.constructor.clipspace;
155
+
156
+ // 修改 clipspace.images
157
+ if (clipspace.images && clipspace.images.length > 0) {
158
+ const clipImage = clipspace.images[clipspace.selectedIndex || 0];
159
+ if (clipImage && clipImage.subfolder === 'clipspace') {
160
+ clipspace.images[clipspace.selectedIndex || 0] = {
161
+ filename: finalUrl,
162
+ subfolder: ''
163
+ };
164
+ }
165
+ }
166
+
167
+ // 修改 clipspace.widgets
168
+ if (clipspace.widgets) {
169
+ const imageWidgetIndex = clipspace.widgets.findIndex(w => w.name === 'image');
170
+ if (imageWidgetIndex >= 0) {
171
+ const widgetValue = clipspace.widgets[imageWidgetIndex].value;
172
+ if (widgetValue && typeof widgetValue === 'object' && widgetValue.subfolder === 'clipspace') {
173
+ clipspace.widgets[imageWidgetIndex].value = {
174
+ filename: finalUrl,
175
+ subfolder: ''
176
+ };
177
+ }
178
+ }
179
+ }
180
+ }
181
+
167
182
  // 篡改响应,让 ComfyUI 使用完整的 OSS URL
168
183
  const modifiedData = { ...data, name: finalUrl, subfolder: '' };
169
- console.log('[BizyDraft Upload] ✅ Response modified');
170
- console.log('═══════════════════════════════════════════════════════\n');
171
-
172
184
  return new Response(JSON.stringify(modifiedData), {
173
185
  status: response.status,
174
186
  statusText: response.statusText,
@@ -176,7 +188,7 @@ api.fetchApi = async function(url, options) {
176
188
  });
177
189
 
178
190
  } catch (e) {
179
- console.error('[BizyDraft Upload] Error:', e);
191
+ console.error('[BizyDraft Upload] Error:', e);
180
192
  return response;
181
193
  }
182
194
  };
@@ -187,8 +199,6 @@ function convertClipspacePathsInPrompt(prompt) {
187
199
  return prompt;
188
200
  }
189
201
 
190
- let conversionsCount = 0;
191
-
192
202
  for (const [nodeId, node] of Object.entries(prompt)) {
193
203
  if (!node?.inputs) continue;
194
204
 
@@ -200,27 +210,62 @@ function convertClipspacePathsInPrompt(prompt) {
200
210
  const ossUrl = findOssUrl(filename);
201
211
 
202
212
  if (ossUrl) {
203
- console.log('[BizyDraft Prompt] Converting:', inputValue, '->', ossUrl);
204
213
  node.inputs[inputKey] = ossUrl;
205
214
 
206
215
  if (inputKey === 'image' && node.inputs['image_name']) {
207
216
  node.inputs['image_name'] = ossUrl.split('/').pop();
208
217
  }
209
-
210
- conversionsCount++;
211
218
  }
212
219
  }
213
220
  }
214
221
  }
215
222
  }
216
223
 
217
- if (conversionsCount > 0) {
218
- console.log(`[BizyDraft Prompt] Converted ${conversionsCount} path(s)`);
219
- }
220
-
221
224
  return prompt;
222
225
  }
223
226
 
227
+ // ═══════════════════════════════════════════════════════════════════════════
228
+ // 拦截 pasteFromClipspace,确保 widget.value 使用 OSS URL
229
+ // ═══════════════════════════════════════════════════════════════════════════
230
+ function interceptPasteFromClipspace() {
231
+ const ComfyApp = window.app?.constructor;
232
+ if (!ComfyApp || !ComfyApp.pasteFromClipspace) return;
233
+
234
+ const originalPasteFromClipspace = ComfyApp.pasteFromClipspace;
235
+ ComfyApp.pasteFromClipspace = function(node) {
236
+ // 调用原始函数
237
+ originalPasteFromClipspace.call(this, node);
238
+
239
+ // 修正 widget.value
240
+ if (node.widgets) {
241
+ const imageWidget = node.widgets.find(w => w.name === 'image');
242
+ if (imageWidget && typeof imageWidget.value === 'string') {
243
+ const value = imageWidget.value;
244
+
245
+ // 1) 如果是 clipspace 路径格式,替换为 OSS URL
246
+ if (value.includes('clipspace/')) {
247
+ // 提取文件名
248
+ const match = value.match(/clipspace\/([\w-]+\.(?:png|jpg|jpeg|webp|gif))(\s\[(input|output)\])?/i);
249
+ if (match) {
250
+ const filename = match[1];
251
+ const ossUrl = findOssUrl(filename);
252
+
253
+ if (ossUrl) {
254
+ imageWidget.value = ossUrl;
255
+ }
256
+ }
257
+ }
258
+ // 2) 如果是 "https://... [input]" 这样的字符串,移除后缀
259
+ else if (/https?:\/\/.*\.(png|jpg|jpeg|webp|gif)\s\[(input|output)\]$/i.test(value)) {
260
+ const cleaned = stripTypeSuffix(value);
261
+ if (cleaned !== value) {
262
+ imageWidget.value = cleaned;
263
+ }
264
+ }
265
+ }
266
+ }
267
+ };
268
+ }
224
269
  // 注册 ComfyUI 扩展
225
270
  app.registerExtension({
226
271
  name: "bizyair.clipspace.to.oss",
@@ -228,16 +273,44 @@ app.registerExtension({
228
273
  async setup() {
229
274
  const originalGraphToPrompt = app.graphToPrompt;
230
275
 
276
+ // 在构建 Prompt 之前,先清理所有 widget 的值,去掉多余的后缀
277
+ function sanitizeGraphWidgets(graph) {
278
+ const nodes = graph?._nodes || [];
279
+ for (const node of nodes) {
280
+ if (!node?.widgets) continue;
281
+ for (const widget of node.widgets) {
282
+ if (typeof widget?.value === 'string') {
283
+ widget.value = stripTypeSuffix(widget.value);
284
+ }
285
+ }
286
+ }
287
+ }
288
+
231
289
  app.graphToPrompt = async function(...args) {
290
+ // 预清理,避免 workflow.widgets_values 和 prompt 输入里包含 [input]/[output]
291
+ try { sanitizeGraphWidgets(app.graph); } catch (e) {}
292
+
232
293
  const result = await originalGraphToPrompt.apply(this, args);
233
294
 
234
295
  if (result?.output) {
235
- result.output = convertClipspacePathsInPrompt(result.output);
296
+ // 二次清理并转换 clipspace
297
+ const cleaned = convertClipspacePathsInPrompt(result.output);
298
+ // 额外移除任何字符串输入中的类型后缀
299
+ for (const nodeId of Object.keys(cleaned || {})) {
300
+ const node = cleaned[nodeId];
301
+ if (!node?.inputs) continue;
302
+ for (const key of Object.keys(node.inputs)) {
303
+ const v = node.inputs[key];
304
+ node.inputs[key] = typeof v === 'string' ? stripTypeSuffix(v) : v;
305
+ }
306
+ }
307
+ result.output = cleaned;
236
308
  }
237
309
 
238
310
  return result;
239
311
  };
240
312
 
241
- console.log('[BizyDraft] Extension registered');
313
+ // 拦截 pasteFromClipspace
314
+ interceptPasteFromClipspace();
242
315
  }
243
316
  });
@@ -0,0 +1,37 @@
1
+ // 保存原始的 WebSocket 构造函数
2
+ const OriginalWebSocket = window.WebSocket;
3
+
4
+ class FakeWebSocket {
5
+ constructor(url) {
6
+ this.url = url;
7
+ this.readyState = WebSocket.CONNECTING; // 核心:保持 CONNECTING 状态
8
+ console.warn('[BizyDraft] 已阻止 WebSocket 连接:', url);
9
+ }
10
+ send() {}
11
+ close() {}
12
+ addEventListener() {}
13
+ removeEventListener() {}
14
+ }
15
+
16
+ window.WebSocket = function(url, protocols) {
17
+ //精确拦截/ws请求
18
+ if (typeof url === 'string' && /^wss?:\/\/[^/]+\/ws(\?.*)?$/.test(url)) {
19
+ return new FakeWebSocket(url);
20
+ }
21
+ // 其他连接正常创建,不影响
22
+ return new OriginalWebSocket(url, protocols);
23
+ };
24
+
25
+ // 保留 WebSocket 的静态属性和原型
26
+ Object.setPrototypeOf(window.WebSocket, OriginalWebSocket);
27
+ window.WebSocket.prototype = OriginalWebSocket.prototype;
28
+
29
+ // 复制静态常量(使用 defineProperty 避免只读属性错误)
30
+ ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'].forEach(prop => {
31
+ Object.defineProperty(window.WebSocket, prop, {
32
+ value: OriginalWebSocket[prop],
33
+ writable: false,
34
+ enumerable: true,
35
+ configurable: true
36
+ });
37
+ });
@@ -1,4 +1,5 @@
1
1
  // 主入口文件,导入所有模块
2
+ import "./disableComfyWebSocket.js";
2
3
  import "./hookLoadImage.js";
3
4
  import "./postEvent.js";
4
5
  import "./handleStyle.js";
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bizydraft
3
- Version: 0.2.72.dev20251013070955
3
+ Version: 0.2.73.dev20251015100429
4
4
  Summary: bizydraft
5
5
  Requires-Dist: loguru
6
6
  Requires-Dist: aiohttp
@@ -11,12 +11,13 @@ bizydraft/resp.py,sha256=8INvKOe5Dgai3peKfqKjrhUoYeuXWXn358w30-_cY-A,369
11
11
  bizydraft/server.py,sha256=L2zoJgOisr65IRphOyko74AdsLel59gh55peyMaUrO8,2102
12
12
  bizydraft/workflow_io.py,sha256=MYhJbpgkv8hrA5k_aolijOTrWpTtu62nzRznA4hv8JE,4298
13
13
  bizydraft/static/js/aiAppHandler.js,sha256=OQRhhoqvc8iZeCvHTtdaD2VTYBGzkeAGdCk1UMO2RZs,17525
14
- bizydraft/static/js/clipspaceToOss.js,sha256=QEd14hbp-gvsK4EszThcVbsqmUeXt0hcxdfoQyZUpDg,10902
14
+ bizydraft/static/js/clipspaceToOss.js,sha256=brfEPs71Tky5Dnc47UXNEFeFlESDE3kQvUH8ducpIew,14265
15
+ bizydraft/static/js/disableComfyWebSocket.js,sha256=nL6DjLUdC2FlAqfYPaFW-dAtkamv01c461W0DUupIKk,1124
15
16
  bizydraft/static/js/freezeModeHandler.js,sha256=SjpHD2nYymR-E13B0YcqkA6e4WycZOVI3c48Ts9qvWE,18027
16
17
  bizydraft/static/js/handleStyle.js,sha256=liIzTu-wnV172g58gHWGLYTfd86xpJxL4A-HuHpFnq4,3616
17
18
  bizydraft/static/js/hookLoadImage.js,sha256=aFRWkgJW-Cp-YHjZh-3j-vsVcNaDZpBVoQqcFZ2Po0g,8186
18
19
  bizydraft/static/js/hookLoadModel.js,sha256=GIvew1mDcJhgyyaJif0tFGNdFQo_LzlTQfBZQ2lg2Tw,17032
19
- bizydraft/static/js/main.js,sha256=7ijEPNQu9WtZZFQVrxby-ThG3ZJQ53feEiPrQTXrZns,151
20
+ bizydraft/static/js/main.js,sha256=PRe4LdsquEQWrZDnVd4ubpVQuD1eDIedAXFFazKdoKQ,188
20
21
  bizydraft/static/js/nodeFocusHandler.js,sha256=24xXbS4Q-GjJdRqf11i-1pBo8MkOJ24F7MHFV44EG6Q,4683
21
22
  bizydraft/static/js/nodeParamsFilter.js,sha256=H7lBB0G8HNqoGhOCH1hNXqPU-rPlrFyTxg_f_JgLEMk,4168
22
23
  bizydraft/static/js/postEvent.js,sha256=dnstkIU_898KvVka1wP8d1TJDLlAphDYghgpQpkTmLM,39864
@@ -24,7 +25,7 @@ bizydraft/static/js/socket.js,sha256=VE3fTAgEfM0FZhL526Skt7OCRokOa3mzTCAjAomI_tE
24
25
  bizydraft/static/js/tool.js,sha256=VupamUuh7tYiDnBTrL5Z_yLmhJinskhzRXwE3zfsKZM,2901
25
26
  bizydraft/static/js/uploadFile.js,sha256=WvglKzHMeOzDhOH3P-fLcPHxCLbKOJpo4DntoRxeJtI,4908
26
27
  bizydraft/static/js/workflow_io.js,sha256=FWAjncvWhvy-3nN_legD2fpRwgnIncpRLHU5X016a-U,5236
27
- bizydraft-0.2.72.dev20251013070955.dist-info/METADATA,sha256=KIlZZuVsJrep6mJiYaeN-WJEtOFpDK6x5-lH-wF61XQ,180
28
- bizydraft-0.2.72.dev20251013070955.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- bizydraft-0.2.72.dev20251013070955.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
30
- bizydraft-0.2.72.dev20251013070955.dist-info/RECORD,,
28
+ bizydraft-0.2.73.dev20251015100429.dist-info/METADATA,sha256=VQh_RS2B5UguQtmdCPuD0np5AG4PFB5B8WMYLvuxPOo,180
29
+ bizydraft-0.2.73.dev20251015100429.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ bizydraft-0.2.73.dev20251015100429.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
31
+ bizydraft-0.2.73.dev20251015100429.dist-info/RECORD,,