"""Fixed frontend is an explicit restoration hypothesis, never source identity.""" import hashlib import json import urllib.request from pathlib import Path REF = Path(__file__).resolve().parent.parent / "resize-compare-reference" OLD = REF.parent / "seedvr2-reference" def main(): j = json.loads((REF / "sources.json").read_bytes()) j["sources"] = [e for e in j["sources"] if e["id"] != "frontend"] old = json.loads((OLD / "sources.json").read_bytes())["sources"] for e in old: if e["id"] == "frontend" and e["file"] in [ "src/lib/litegraph/src/LGraphNode.ts", "src/scripts/widgets.ts", "src/extensions/core/uploadImage.ts", "LICENSE", ]: j["sources"].append( { **e, "local_file": "../seedvr2-reference/" + e["local_file"], "identity_binding": ( "reference hypothesis v1.45.20 only; source frontendVersion absent" ), } ) tree = json.loads((OLD / "frontend-tree.json").read_bytes()) commit = tree["sha"] for f in ["src/renderer/extensions/vueNodes/widgets/composables/useImageUploadWidget.ts"]: url = f"https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/{commit}/{f}" with urllib.request.urlopen(url, timeout=30) as r: b = r.read() blob = hashlib.sha1(b"blob " + str(len(b)).encode() + b"\0" + b).hexdigest() assert blob == next(e["sha"] for e in tree["tree"] if e["path"] == f) name = "frontend__" + f.replace("/", "__") (REF / name).write_bytes(b) j["sources"].append( dict( id="frontend", file=f, local_file=name, url=url, commit=commit, sha256=hashlib.sha256(b).hexdigest(), git_blob_sha1=blob, identity_binding=( "reference hypothesis v1.45.20 only; source frontendVersion absent" ), ) ) (REF / "sources.json").write_text(json.dumps(j, ensure_ascii=False, indent=2) + "\n") if __name__ == "__main__": main()