bizydraft 0.2.52__py3-none-any.whl → 0.2.54__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.
- bizydraft/oss_utils.py +22 -0
- bizydraft/static/js/postEvent.js +26 -25
- {bizydraft-0.2.52.dist-info → bizydraft-0.2.54.dist-info}/METADATA +1 -1
- {bizydraft-0.2.52.dist-info → bizydraft-0.2.54.dist-info}/RECORD +6 -6
- {bizydraft-0.2.52.dist-info → bizydraft-0.2.54.dist-info}/WHEEL +0 -0
- {bizydraft-0.2.52.dist-info → bizydraft-0.2.54.dist-info}/top_level.txt +0 -0
bizydraft/oss_utils.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import base64
|
|
2
2
|
import json
|
|
3
3
|
import os
|
|
4
|
+
import re
|
|
5
|
+
import uuid
|
|
4
6
|
from http.cookies import SimpleCookie
|
|
7
|
+
from pathlib import Path
|
|
5
8
|
from time import time
|
|
6
9
|
from typing import Any, Dict
|
|
7
10
|
|
|
@@ -177,6 +180,10 @@ async def upload_to_oss(post, api_key: str):
|
|
|
177
180
|
if not filename:
|
|
178
181
|
return web.Response(status=400)
|
|
179
182
|
|
|
183
|
+
should_clean, filename = clean_filename(filename)
|
|
184
|
+
if should_clean:
|
|
185
|
+
filename = f"{uuid.uuid4()}.{filename}"
|
|
186
|
+
|
|
180
187
|
oss_token = await get_upload_token(filename, api_key)
|
|
181
188
|
result = await upload_filefield_to_oss(image, oss_token)
|
|
182
189
|
if result["status"] != 200:
|
|
@@ -225,3 +232,18 @@ async def upload_image(request):
|
|
|
225
232
|
return web.Response(status=403, text="No validated key found")
|
|
226
233
|
post = await request.post()
|
|
227
234
|
return await upload_to_oss(post, api_key)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _should_clean(name: str) -> bool:
|
|
238
|
+
"""True -> 乱码;False -> 正常"""
|
|
239
|
+
# 主名部分含 URL 参数符号且最后有扩展名
|
|
240
|
+
return bool(re.search(r"[&=,].+\.[\w]+$", name))
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def clean_filename(bad: str) -> (bool, str):
|
|
244
|
+
"""对乱码串提取最后扩展名;正常串直接返回原值"""
|
|
245
|
+
if not _should_clean(bad):
|
|
246
|
+
return False, bad
|
|
247
|
+
# 提取最后扩展名(含点)
|
|
248
|
+
ext = re.search(r"(\.[\w]+)$", bad)
|
|
249
|
+
return True, ext.group(1) if ext else bad # 理论上不会没有扩展名
|
bizydraft/static/js/postEvent.js
CHANGED
|
@@ -519,21 +519,31 @@ app.registerExtension({
|
|
|
519
519
|
}, '*');
|
|
520
520
|
return graph.workflow;
|
|
521
521
|
},
|
|
522
|
+
getWorkflowNotSave: async function () {
|
|
523
|
+
const graph = await app.graphToPrompt();
|
|
524
|
+
// 规范化工作流,移除不影响逻辑的视觉字段,避免颜色等样式变化影响校验
|
|
525
|
+
const normalizeWorkflow = (workflow) => {
|
|
526
|
+
const json = JSON.stringify(workflow, (key, value) => {
|
|
527
|
+
if (key === 'color' || key === 'bgcolor' || key === 'extra') return undefined;
|
|
528
|
+
return value;
|
|
529
|
+
});
|
|
530
|
+
return JSON.parse(json);
|
|
531
|
+
};
|
|
532
|
+
const normalized = normalizeWorkflow(graph.workflow);
|
|
533
|
+
window.parent.postMessage({
|
|
534
|
+
type: 'functionResult',
|
|
535
|
+
method: 'getWorkflowNotSave',
|
|
536
|
+
result: normalized
|
|
537
|
+
}, '*');
|
|
538
|
+
return normalized;
|
|
539
|
+
},
|
|
522
540
|
// 新增:获取 workflow 和 output
|
|
523
541
|
getWorkflowWithOutput: async function () {
|
|
524
542
|
const graph = await app.graphToPrompt();
|
|
525
|
-
graph.
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
graph.output[key]._meta = {};
|
|
530
|
-
}
|
|
531
|
-
graph.output[key]._meta.id = node.id;
|
|
532
|
-
graph.output[key]._meta.class_type = graph.output[key].class_type;
|
|
533
|
-
break; // 找到匹配的就跳出循环
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
});
|
|
543
|
+
for (const key in graph.output) {
|
|
544
|
+
graph.output[key]._meta.id = Number(key);
|
|
545
|
+
graph.output[key]._meta.class_type =graph.output[key].class_type
|
|
546
|
+
}
|
|
537
547
|
window.parent.postMessage({
|
|
538
548
|
type: 'functionResult',
|
|
539
549
|
method: 'getWorkflowWithOutput',
|
|
@@ -613,19 +623,10 @@ app.registerExtension({
|
|
|
613
623
|
}
|
|
614
624
|
|
|
615
625
|
if (Object.keys(resPromptJson.node_errors).length) return
|
|
616
|
-
graph.
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
graph.output[key]._meta = {};
|
|
621
|
-
}
|
|
622
|
-
graph.output[key]._meta.id = node.id;
|
|
623
|
-
graph.output[key]._meta.class_type = graph.output[key].class_type;
|
|
624
|
-
break; // 找到匹配的就跳出循环
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
|
|
626
|
+
for (const key in graph.output) {
|
|
627
|
+
graph.output[key]._meta.id = Number(key);
|
|
628
|
+
graph.output[key]._meta.class_type = graph.output[key].class_type;
|
|
629
|
+
}
|
|
629
630
|
for (let i in graph.output) {
|
|
630
631
|
if (graph.output[i].class_type == 'LoadImage') {
|
|
631
632
|
graph.output[i].inputs.image = graph.output[i].inputs.image.replace('pasted/http', 'http')
|
|
@@ -3,7 +3,7 @@ bizydraft/block_nodes.py,sha256=Lqn3oSCaGDHR2OICc8a2iRoRCVVK9v1-9MM3r-qIZgA,1092
|
|
|
3
3
|
bizydraft/env.py,sha256=nVh4xBKXWnRUPbHL3PqZr6VFN8txKsrsmshu8PFGaqo,299
|
|
4
4
|
bizydraft/hijack_nodes.py,sha256=ktonkuI3NEctELUL9C0Hmv2-DaDr1MClGZWeHrP2VCA,3485
|
|
5
5
|
bizydraft/hijack_routes.py,sha256=lf6x3xDzbo9yQIRwfG_1oxcUNfrX_1ogbiff3WOV9gM,3268
|
|
6
|
-
bizydraft/oss_utils.py,sha256=
|
|
6
|
+
bizydraft/oss_utils.py,sha256=FxTe9TxA9Q13pxKaOpcN0Jui-BG1SBWySM71PqpIlsM,8601
|
|
7
7
|
bizydraft/patch_handlers.py,sha256=WPf4xeV5sBpoJ2MkHHhx0wem7B0KQNuhONElN7c9v3g,5989
|
|
8
8
|
bizydraft/postload.py,sha256=XFElKcmCajT_oO7SVJJBaN04XcWro54N5HB5cSCxfvI,1308
|
|
9
9
|
bizydraft/prestartup_patch.py,sha256=4FGjmRcDHELjtlQOrfTfk2Un5OS89QIqfq-gEcB9WDs,998
|
|
@@ -18,11 +18,11 @@ bizydraft/static/js/hookLoadModel.js,sha256=ovNvz4FRYNcOKJTueotugzIeGQDYAivYB5EQ
|
|
|
18
18
|
bizydraft/static/js/main.js,sha256=oEsVEUZSo8ipx93oqs2WFQSRgp46XQ_D-Xao-wen2S8,121
|
|
19
19
|
bizydraft/static/js/nodeFocusHandler.js,sha256=24xXbS4Q-GjJdRqf11i-1pBo8MkOJ24F7MHFV44EG6Q,4683
|
|
20
20
|
bizydraft/static/js/nodeParamsFilter.js,sha256=H7lBB0G8HNqoGhOCH1hNXqPU-rPlrFyTxg_f_JgLEMk,4168
|
|
21
|
-
bizydraft/static/js/postEvent.js,sha256=
|
|
21
|
+
bizydraft/static/js/postEvent.js,sha256=met19YcUlC8ttKQl9tHJ66NnfltBeOeq28TZBmIGhlM,39249
|
|
22
22
|
bizydraft/static/js/socket.js,sha256=VE3fTAgEfM0FZhL526Skt7OCRokOa3mzTCAjAomI_tE,2432
|
|
23
23
|
bizydraft/static/js/tool.js,sha256=VupamUuh7tYiDnBTrL5Z_yLmhJinskhzRXwE3zfsKZM,2901
|
|
24
24
|
bizydraft/static/js/uploadFile.js,sha256=WvglKzHMeOzDhOH3P-fLcPHxCLbKOJpo4DntoRxeJtI,4908
|
|
25
|
-
bizydraft-0.2.
|
|
26
|
-
bizydraft-0.2.
|
|
27
|
-
bizydraft-0.2.
|
|
28
|
-
bizydraft-0.2.
|
|
25
|
+
bizydraft-0.2.54.dist-info/METADATA,sha256=9HHnNfSi145FUtWlkBxdSa4UcipPMuRe7aBCl6N2ENA,162
|
|
26
|
+
bizydraft-0.2.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
bizydraft-0.2.54.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
|
|
28
|
+
bizydraft-0.2.54.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|