Vendor the viewer JavaScript into javascript/ and drop the comfy-3d-viewers dependency. The viewers were previously copied into web/ at every startup by prestartup_script.py, which made the served frontend depend on a second package resolving at runtime. Bundles are vendored as .mjs so ComfyUI's **/*.js auto-import glob skips them: they are iframe-only and must never enter the shared main browser realm. Only the widget entry points stay .js. Also replace comfy_env.copy_files with a local helper. Its two extra features (frame-derived source dir, silent no-op on a missing source) were unused here, and the asset seeding now resolves the input directory through folder_paths.get_input_directory() so it follows ComfyUI Desktop and --input-directory instead of writing into the code tree. comfy-test.toml moves to the current schema: [test.workflows] cuda (there is no "gpu" key -- the accelerator is named by backend, and the old spelling parsed to an empty list, so CUDA runners silently ran the full unfiltered set), an explicit [test.platforms] platforms allowlist (per-platform booleans are no longer supported), and the javascript level. DisplayName becomes "DepthAnythingV3": the namespace enforced on registerExtension names is derived from it, and the space in "Depth Anything V3" made that prefix invalid. Delete the 21 loose js/viewer/*.js modules -- they are already inside viewer-bundle-vtk.mjs, so shipping them loose leaked the whole viewer into the shared realm.
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""ComfyUI-DepthAnythingV3 Prestartup Script."""
|
|
|
|
import logging
|
|
import shutil
|
|
from pathlib import Path
|
|
import folder_paths
|
|
from comfy_env import setup_env
|
|
|
|
log = logging.getLogger("depthanythingv3")
|
|
|
|
setup_env()
|
|
|
|
# The CONFIGURED input directory, never the code-tree one. ComfyUI Desktop
|
|
# (--base-directory) and --input-directory both relocate it, and the load
|
|
# nodes only ever scan folder_paths.get_input_directory(). main.py runs
|
|
# apply_custom_paths() before prestartup scripts, so this is already resolved.
|
|
INPUT = Path(folder_paths.get_input_directory())
|
|
|
|
|
|
def copy_files(src: Path, dst: Path, pattern: str = "*") -> int:
|
|
"""Copy bundled assets into a directory. Returns files written.
|
|
|
|
Seeds rather than syncs: an existing file is left alone, so a user's
|
|
edited demo asset survives every relaunch. Raises if `src` is missing --
|
|
a typo'd asset directory is a packaging bug, and silence is how it stays
|
|
one.
|
|
"""
|
|
src, dst = Path(src), Path(dst)
|
|
if not src.is_dir():
|
|
raise FileNotFoundError(f"asset directory not found: {src}")
|
|
written = 0
|
|
for f in src.glob(pattern):
|
|
if not f.is_file():
|
|
continue
|
|
target = dst / f.relative_to(src)
|
|
if target.exists():
|
|
continue
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(f, target)
|
|
written += 1
|
|
return written
|
|
|
|
|
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
|
|
# Copy assets
|
|
copy_files(SCRIPT_DIR / "assets", INPUT, "**/*")
|