mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-14 22:13:41 +03:00
bdac53c5a1
* decouple python from js
* bring the painterro btn back
* refactor painterro code
replicate 7ddbd6533a
as close as possible
* improve reliability
* fix big brain import
Co-authored-by: hlky <106811348+hlky@users.noreply.github.com>
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
from os import path
|
|
|
|
def readTextFile(*args):
|
|
dir = path.dirname(__file__)
|
|
entry = path.join(dir, *args)
|
|
with open(entry, "r", encoding="utf8") as f:
|
|
data = f.read()
|
|
return data
|
|
|
|
def css(opt):
|
|
styling = readTextFile("css", "styles.css")
|
|
if not opt.no_progressbar_hiding:
|
|
styling += readTextFile("css", "no_progress_bar.css")
|
|
return styling
|
|
|
|
def js(opt):
|
|
data = readTextFile("js", "index.js")
|
|
data = "(z) => {" + data + "; return z ?? [] }"
|
|
return data
|
|
|
|
# Wrap the typical SD method call into async closure for ease of use
|
|
# If you call frontend method without wrapping
|
|
# DONT FORGET to bind input argument if you need it: SD.with(x)
|
|
def w(sd_method_call):
|
|
return f"async (x) => {{ return await SD.with(x).{sd_method_call} ?? x ?? []; }}"
|
|
|
|
def js_move_image(from_id, to_id):
|
|
return w(f"moveImageFromGallery('{from_id}', '{to_id}')")
|
|
|
|
def js_copy_to_clipboard(from_id):
|
|
return w(f"copyImageFromGalleryToClipboard('{from_id}')")
|
|
|
|
def js_painterro_launch(to_id):
|
|
return w(f"Painterro.init('{to_id}')")
|
|
|