docs(HEL-892): bind Flux anime-to-real reference documentation

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-31 06:53:37 +08:00
co-authored by multica-agent
parent 20b097835e
commit 41b07c5887
91 changed files with 73463 additions and 1 deletions
@@ -0,0 +1,647 @@
from __future__ import annotations
import nodes
import folder_paths
import json
import os
import re
import torch
import comfy.utils
from server import PromptServer
from comfy_api.latest import ComfyExtension, IO, UI
from typing_extensions import override
SVG = IO.SVG.Type # TODO: temporary solution for backward compatibility, will be removed later.
MAX_RESOLUTION = nodes.MAX_RESOLUTION
class ImageCrop(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageCrop",
display_name="Image Crop",
category="image/transform",
inputs=[
IO.Image.Input("image"),
IO.Int.Input("width", default=512, min=1, max=nodes.MAX_RESOLUTION, step=1),
IO.Int.Input("height", default=512, min=1, max=nodes.MAX_RESOLUTION, step=1),
IO.Int.Input("x", default=0, min=0, max=nodes.MAX_RESOLUTION, step=1),
IO.Int.Input("y", default=0, min=0, max=nodes.MAX_RESOLUTION, step=1),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, width, height, x, y) -> IO.NodeOutput:
x = min(x, image.shape[2] - 1)
y = min(y, image.shape[1] - 1)
to_x = width + x
to_y = height + y
img = image[:,y:to_y, x:to_x, :]
return IO.NodeOutput(img)
crop = execute # TODO: remove
class RepeatImageBatch(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="RepeatImageBatch",
category="image/batch",
inputs=[
IO.Image.Input("image"),
IO.Int.Input("amount", default=1, min=1, max=4096),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, amount) -> IO.NodeOutput:
s = image.repeat((amount, 1,1,1))
return IO.NodeOutput(s)
repeat = execute # TODO: remove
class ImageFromBatch(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageFromBatch",
category="image/batch",
inputs=[
IO.Image.Input("image"),
IO.Int.Input("batch_index", default=0, min=0, max=4095),
IO.Int.Input("length", default=1, min=1, max=4096),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, batch_index, length) -> IO.NodeOutput:
s_in = image
batch_index = min(s_in.shape[0] - 1, batch_index)
length = min(s_in.shape[0] - batch_index, length)
s = s_in[batch_index:batch_index + length].clone()
return IO.NodeOutput(s)
frombatch = execute # TODO: remove
class ImageAddNoise(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageAddNoise",
category="image",
inputs=[
IO.Image.Input("image"),
IO.Int.Input(
"seed",
default=0,
min=0,
max=0xFFFFFFFFFFFFFFFF,
control_after_generate=True,
tooltip="The random seed used for creating the noise.",
),
IO.Float.Input("strength", default=0.5, min=0.0, max=1.0, step=0.01),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, seed, strength) -> IO.NodeOutput:
generator = torch.manual_seed(seed)
s = torch.clip((image + strength * torch.randn(image.size(), generator=generator, device="cpu").to(image)), min=0.0, max=1.0)
return IO.NodeOutput(s)
repeat = execute # TODO: remove
class SaveAnimatedWEBP(IO.ComfyNode):
COMPRESS_METHODS = {"default": 4, "fastest": 0, "slowest": 6}
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="SaveAnimatedWEBP",
category="image/animation",
inputs=[
IO.Image.Input("images"),
IO.String.Input("filename_prefix", default="ComfyUI"),
IO.Float.Input("fps", default=6.0, min=0.01, max=1000.0, step=0.01),
IO.Boolean.Input("lossless", default=True),
IO.Int.Input("quality", default=80, min=0, max=100),
IO.Combo.Input("method", options=list(cls.COMPRESS_METHODS.keys())),
# "num_frames": ("INT", {"default": 0, "min": 0, "max": 8192}),
],
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
is_output_node=True,
)
@classmethod
def execute(cls, images, fps, filename_prefix, lossless, quality, method, num_frames=0) -> IO.NodeOutput:
return IO.NodeOutput(
ui=UI.ImageSaveHelper.get_save_animated_webp_ui(
images=images,
filename_prefix=filename_prefix,
cls=cls,
fps=fps,
lossless=lossless,
quality=quality,
method=cls.COMPRESS_METHODS.get(method)
)
)
save_images = execute # TODO: remove
class SaveAnimatedPNG(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="SaveAnimatedPNG",
category="image/animation",
inputs=[
IO.Image.Input("images"),
IO.String.Input("filename_prefix", default="ComfyUI"),
IO.Float.Input("fps", default=6.0, min=0.01, max=1000.0, step=0.01),
IO.Int.Input("compress_level", default=4, min=0, max=9),
],
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
is_output_node=True,
)
@classmethod
def execute(cls, images, fps, compress_level, filename_prefix="ComfyUI") -> IO.NodeOutput:
return IO.NodeOutput(
ui=UI.ImageSaveHelper.get_save_animated_png_ui(
images=images,
filename_prefix=filename_prefix,
cls=cls,
fps=fps,
compress_level=compress_level,
)
)
save_images = execute # TODO: remove
class ImageStitch(IO.ComfyNode):
"""Upstreamed from https://github.com/kijai/ComfyUI-KJNodes"""
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageStitch",
display_name="Image Stitch",
description="Stitches image2 to image1 in the specified direction.\n"
"If image2 is not provided, returns image1 unchanged.\n"
"Optional spacing can be added between images.",
category="image/transform",
inputs=[
IO.Image.Input("image1"),
IO.Combo.Input("direction", options=["right", "down", "left", "up"], default="right"),
IO.Boolean.Input("match_image_size", default=True),
IO.Int.Input("spacing_width", default=0, min=0, max=1024, step=2),
IO.Combo.Input("spacing_color", options=["white", "black", "red", "green", "blue"], default="white"),
IO.Image.Input("image2", optional=True),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(
cls,
image1,
direction,
match_image_size,
spacing_width,
spacing_color,
image2=None,
) -> IO.NodeOutput:
if image2 is None:
return IO.NodeOutput(image1)
# Handle batch size differences
if image1.shape[0] != image2.shape[0]:
max_batch = max(image1.shape[0], image2.shape[0])
if image1.shape[0] < max_batch:
image1 = torch.cat(
[image1, image1[-1:].repeat(max_batch - image1.shape[0], 1, 1, 1)]
)
if image2.shape[0] < max_batch:
image2 = torch.cat(
[image2, image2[-1:].repeat(max_batch - image2.shape[0], 1, 1, 1)]
)
# Match image sizes if requested
if match_image_size:
h1, w1 = image1.shape[1:3]
h2, w2 = image2.shape[1:3]
aspect_ratio = w2 / h2
if direction in ["left", "right"]:
target_h, target_w = h1, int(h1 * aspect_ratio)
else: # up, down
target_w, target_h = w1, int(w1 / aspect_ratio)
image2 = comfy.utils.common_upscale(
image2.movedim(-1, 1), target_w, target_h, "lanczos", "disabled"
).movedim(1, -1)
color_map = {
"white": 1.0,
"black": 0.0,
"red": (1.0, 0.0, 0.0),
"green": (0.0, 1.0, 0.0),
"blue": (0.0, 0.0, 1.0),
}
color_val = color_map[spacing_color]
# When not matching sizes, pad to align non-concat dimensions
if not match_image_size:
h1, w1 = image1.shape[1:3]
h2, w2 = image2.shape[1:3]
pad_value = 0.0
if not isinstance(color_val, tuple):
pad_value = color_val
if direction in ["left", "right"]:
# For horizontal concat, pad heights to match
if h1 != h2:
target_h = max(h1, h2)
if h1 < target_h:
pad_h = target_h - h1
pad_top, pad_bottom = pad_h // 2, pad_h - pad_h // 2
image1 = torch.nn.functional.pad(image1, (0, 0, 0, 0, pad_top, pad_bottom), mode='constant', value=pad_value)
if h2 < target_h:
pad_h = target_h - h2
pad_top, pad_bottom = pad_h // 2, pad_h - pad_h // 2
image2 = torch.nn.functional.pad(image2, (0, 0, 0, 0, pad_top, pad_bottom), mode='constant', value=pad_value)
else: # up, down
# For vertical concat, pad widths to match
if w1 != w2:
target_w = max(w1, w2)
if w1 < target_w:
pad_w = target_w - w1
pad_left, pad_right = pad_w // 2, pad_w - pad_w // 2
image1 = torch.nn.functional.pad(image1, (0, 0, pad_left, pad_right), mode='constant', value=pad_value)
if w2 < target_w:
pad_w = target_w - w2
pad_left, pad_right = pad_w // 2, pad_w - pad_w // 2
image2 = torch.nn.functional.pad(image2, (0, 0, pad_left, pad_right), mode='constant', value=pad_value)
# Ensure same number of channels
if image1.shape[-1] != image2.shape[-1]:
max_channels = max(image1.shape[-1], image2.shape[-1])
if image1.shape[-1] < max_channels:
image1 = torch.cat(
[
image1,
torch.ones(
*image1.shape[:-1],
max_channels - image1.shape[-1],
device=image1.device,
),
],
dim=-1,
)
if image2.shape[-1] < max_channels:
image2 = torch.cat(
[
image2,
torch.ones(
*image2.shape[:-1],
max_channels - image2.shape[-1],
device=image2.device,
),
],
dim=-1,
)
# Add spacing if specified
if spacing_width > 0:
spacing_width = spacing_width + (spacing_width % 2) # Ensure even
if direction in ["left", "right"]:
spacing_shape = (
image1.shape[0],
max(image1.shape[1], image2.shape[1]),
spacing_width,
image1.shape[-1],
)
else:
spacing_shape = (
image1.shape[0],
spacing_width,
max(image1.shape[2], image2.shape[2]),
image1.shape[-1],
)
spacing = torch.full(spacing_shape, 0.0, device=image1.device)
if isinstance(color_val, tuple):
for i, c in enumerate(color_val):
if i < spacing.shape[-1]:
spacing[..., i] = c
if spacing.shape[-1] == 4: # Add alpha
spacing[..., 3] = 1.0
else:
spacing[..., : min(3, spacing.shape[-1])] = color_val
if spacing.shape[-1] == 4:
spacing[..., 3] = 1.0
# Concatenate images
images = [image2, image1] if direction in ["left", "up"] else [image1, image2]
if spacing_width > 0:
images.insert(1, spacing)
concat_dim = 2 if direction in ["left", "right"] else 1
return IO.NodeOutput(torch.cat(images, dim=concat_dim))
stitch = execute # TODO: remove
class ResizeAndPadImage(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ResizeAndPadImage",
category="image/transform",
inputs=[
IO.Image.Input("image"),
IO.Int.Input("target_width", default=512, min=1, max=nodes.MAX_RESOLUTION, step=1),
IO.Int.Input("target_height", default=512, min=1, max=nodes.MAX_RESOLUTION, step=1),
IO.Combo.Input("padding_color", options=["white", "black"]),
IO.Combo.Input("interpolation", options=["area", "bicubic", "nearest-exact", "bilinear", "lanczos"]),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, target_width, target_height, padding_color, interpolation) -> IO.NodeOutput:
batch_size, orig_height, orig_width, channels = image.shape
scale_w = target_width / orig_width
scale_h = target_height / orig_height
scale = min(scale_w, scale_h)
new_width = int(orig_width * scale)
new_height = int(orig_height * scale)
image_permuted = image.permute(0, 3, 1, 2)
resized = comfy.utils.common_upscale(image_permuted, new_width, new_height, interpolation, "disabled")
pad_value = 0.0 if padding_color == "black" else 1.0
padded = torch.full(
(batch_size, channels, target_height, target_width),
pad_value,
dtype=image.dtype,
device=image.device
)
y_offset = (target_height - new_height) // 2
x_offset = (target_width - new_width) // 2
padded[:, :, y_offset:y_offset + new_height, x_offset:x_offset + new_width] = resized
output = padded.permute(0, 2, 3, 1)
return IO.NodeOutput(output)
resize_and_pad = execute # TODO: remove
class SaveSVGNode(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="SaveSVGNode",
description="Save SVG files on disk.",
category="image/save",
inputs=[
IO.SVG.Input("svg"),
IO.String.Input(
"filename_prefix",
default="svg/ComfyUI",
tooltip="The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes.",
),
],
hidden=[IO.Hidden.prompt, IO.Hidden.extra_pnginfo],
is_output_node=True,
)
@classmethod
def execute(cls, svg: IO.SVG.Type, filename_prefix="svg/ComfyUI") -> IO.NodeOutput:
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, folder_paths.get_output_directory())
results: list[UI.SavedResult] = []
# Prepare metadata JSON
metadata_dict = {}
if cls.hidden.prompt is not None:
metadata_dict["prompt"] = cls.hidden.prompt
if cls.hidden.extra_pnginfo is not None:
metadata_dict.update(cls.hidden.extra_pnginfo)
# Convert metadata to JSON string
metadata_json = json.dumps(metadata_dict, indent=2) if metadata_dict else None
for batch_number, svg_bytes in enumerate(svg.data):
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
file = f"{filename_with_batch_num}_{counter:05}_.svg"
# Read SVG content
svg_bytes.seek(0)
svg_content = svg_bytes.read().decode('utf-8')
# Inject metadata if available
if metadata_json:
# Create metadata element with CDATA section
metadata_element = f""" <metadata>
<![CDATA[
{metadata_json}
]]>
</metadata>
"""
# Insert metadata after opening svg tag using regex with a replacement function
def replacement(match):
# match.group(1) contains the captured <svg> tag
return match.group(1) + '\n' + metadata_element
# Apply the substitution
svg_content = re.sub(r'(<svg[^>]*>)', replacement, svg_content, flags=re.UNICODE)
# Write the modified SVG to file
with open(os.path.join(full_output_folder, file), 'wb') as svg_file:
svg_file.write(svg_content.encode('utf-8'))
results.append(UI.SavedResult(filename=file, subfolder=subfolder, type=IO.FolderType.output))
counter += 1
return IO.NodeOutput(ui={"images": results})
save_svg = execute # TODO: remove
class GetImageSize(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="GetImageSize",
display_name="Get Image Size",
description="Returns width and height of the image, and passes it through unchanged.",
category="image",
inputs=[
IO.Image.Input("image"),
],
outputs=[
IO.Int.Output(display_name="width"),
IO.Int.Output(display_name="height"),
IO.Int.Output(display_name="batch_size"),
],
hidden=[IO.Hidden.unique_id],
)
@classmethod
def execute(cls, image) -> IO.NodeOutput:
height = image.shape[1]
width = image.shape[2]
batch_size = image.shape[0]
# Send progress text to display size on the node
if cls.hidden.unique_id:
PromptServer.instance.send_progress_text(f"width: {width}, height: {height}\n batch size: {batch_size}", cls.hidden.unique_id)
return IO.NodeOutput(width, height, batch_size)
get_size = execute # TODO: remove
class ImageRotate(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageRotate",
category="image/transform",
inputs=[
IO.Image.Input("image"),
IO.Combo.Input("rotation", options=["none", "90 degrees", "180 degrees", "270 degrees"]),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, rotation) -> IO.NodeOutput:
rotate_by = 0
if rotation.startswith("90"):
rotate_by = 1
elif rotation.startswith("180"):
rotate_by = 2
elif rotation.startswith("270"):
rotate_by = 3
image = torch.rot90(image, k=rotate_by, dims=[2, 1])
return IO.NodeOutput(image)
rotate = execute # TODO: remove
class ImageFlip(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageFlip",
category="image/transform",
inputs=[
IO.Image.Input("image"),
IO.Combo.Input("flip_method", options=["x-axis: vertically", "y-axis: horizontally"]),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, flip_method) -> IO.NodeOutput:
if flip_method.startswith("x"):
image = torch.flip(image, dims=[1])
elif flip_method.startswith("y"):
image = torch.flip(image, dims=[2])
return IO.NodeOutput(image)
flip = execute # TODO: remove
class ImageScaleToMaxDimension(IO.ComfyNode):
@classmethod
def define_schema(cls):
return IO.Schema(
node_id="ImageScaleToMaxDimension",
category="image/upscaling",
inputs=[
IO.Image.Input("image"),
IO.Combo.Input(
"upscale_method",
options=["area", "lanczos", "bilinear", "nearest-exact", "bilinear", "bicubic"],
),
IO.Int.Input("largest_size", default=512, min=0, max=MAX_RESOLUTION, step=1),
],
outputs=[IO.Image.Output()],
)
@classmethod
def execute(cls, image, upscale_method, largest_size) -> IO.NodeOutput:
height = image.shape[1]
width = image.shape[2]
if height > width:
width = round((width / height) * largest_size)
height = largest_size
elif width > height:
height = round((height / width) * largest_size)
width = largest_size
else:
height = largest_size
width = largest_size
samples = image.movedim(-1, 1)
s = comfy.utils.common_upscale(samples, width, height, upscale_method, "disabled")
s = s.movedim(1, -1)
return IO.NodeOutput(s)
upscale = execute # TODO: remove
class ImagesExtension(ComfyExtension):
@override
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
return [
ImageCrop,
RepeatImageBatch,
ImageFromBatch,
ImageAddNoise,
SaveAnimatedWEBP,
SaveAnimatedPNG,
SaveSVGNode,
ImageStitch,
ResizeAndPadImage,
GetImageSize,
ImageRotate,
ImageFlip,
ImageScaleToMaxDimension,
]
async def comfy_entrypoint() -> ImagesExtension:
return ImagesExtension()
@@ -0,0 +1,612 @@
from typing_extensions import override
import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image
import math
from enum import Enum
from typing import TypedDict, Literal
import comfy.utils
import comfy.model_management
from comfy_extras.nodes_latent import reshape_latent_to
import node_helpers
from comfy_api.latest import ComfyExtension, io
from nodes import MAX_RESOLUTION
class Blend(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="ImageBlend",
category="image/postprocessing",
inputs=[
io.Image.Input("image1"),
io.Image.Input("image2"),
io.Float.Input("blend_factor", default=0.5, min=0.0, max=1.0, step=0.01),
io.Combo.Input("blend_mode", options=["normal", "multiply", "screen", "overlay", "soft_light", "difference"]),
],
outputs=[
io.Image.Output(),
],
)
@classmethod
def execute(cls, image1: torch.Tensor, image2: torch.Tensor, blend_factor: float, blend_mode: str) -> io.NodeOutput:
image1, image2 = node_helpers.image_alpha_fix(image1, image2)
image2 = image2.to(image1.device)
if image1.shape != image2.shape:
image2 = image2.permute(0, 3, 1, 2)
image2 = comfy.utils.common_upscale(image2, image1.shape[2], image1.shape[1], upscale_method='bicubic', crop='center')
image2 = image2.permute(0, 2, 3, 1)
blended_image = cls.blend_mode(image1, image2, blend_mode)
blended_image = image1 * (1 - blend_factor) + blended_image * blend_factor
blended_image = torch.clamp(blended_image, 0, 1)
return io.NodeOutput(blended_image)
@classmethod
def blend_mode(cls, img1, img2, mode):
if mode == "normal":
return img2
elif mode == "multiply":
return img1 * img2
elif mode == "screen":
return 1 - (1 - img1) * (1 - img2)
elif mode == "overlay":
return torch.where(img1 <= 0.5, 2 * img1 * img2, 1 - 2 * (1 - img1) * (1 - img2))
elif mode == "soft_light":
return torch.where(img2 <= 0.5, img1 - (1 - 2 * img2) * img1 * (1 - img1), img1 + (2 * img2 - 1) * (cls.g(img1) - img1))
elif mode == "difference":
return img1 - img2
raise ValueError(f"Unsupported blend mode: {mode}")
@classmethod
def g(cls, x):
return torch.where(x <= 0.25, ((16 * x - 12) * x + 4) * x, torch.sqrt(x))
def gaussian_kernel(kernel_size: int, sigma: float, device=None):
x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size, device=device), torch.linspace(-1, 1, kernel_size, device=device), indexing="ij")
d = torch.sqrt(x * x + y * y)
g = torch.exp(-(d * d) / (2.0 * sigma * sigma))
return g / g.sum()
class Blur(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="ImageBlur",
category="image/postprocessing",
inputs=[
io.Image.Input("image"),
io.Int.Input("blur_radius", default=1, min=1, max=31, step=1),
io.Float.Input("sigma", default=1.0, min=0.1, max=10.0, step=0.1),
],
outputs=[
io.Image.Output(),
],
)
@classmethod
def execute(cls, image: torch.Tensor, blur_radius: int, sigma: float) -> io.NodeOutput:
if blur_radius == 0:
return io.NodeOutput(image)
image = image.to(comfy.model_management.get_torch_device())
batch_size, height, width, channels = image.shape
kernel_size = blur_radius * 2 + 1
kernel = gaussian_kernel(kernel_size, sigma, device=image.device).repeat(channels, 1, 1).unsqueeze(1)
image = image.permute(0, 3, 1, 2) # Torch wants (B, C, H, W) we use (B, H, W, C)
padded_image = F.pad(image, (blur_radius,blur_radius,blur_radius,blur_radius), 'reflect')
blurred = F.conv2d(padded_image, kernel, padding=kernel_size // 2, groups=channels)[:,:,blur_radius:-blur_radius, blur_radius:-blur_radius]
blurred = blurred.permute(0, 2, 3, 1)
return io.NodeOutput(blurred.to(comfy.model_management.intermediate_device()))
class Quantize(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="ImageQuantize",
category="image/postprocessing",
inputs=[
io.Image.Input("image"),
io.Int.Input("colors", default=256, min=1, max=256, step=1),
io.Combo.Input("dither", options=["none", "floyd-steinberg", "bayer-2", "bayer-4", "bayer-8", "bayer-16"]),
],
outputs=[
io.Image.Output(),
],
)
@staticmethod
def bayer(im, pal_im, order):
def normalized_bayer_matrix(n):
if n == 0:
return np.zeros((1,1), "float32")
else:
q = 4 ** n
m = q * normalized_bayer_matrix(n - 1)
return np.bmat(((m-1.5, m+0.5), (m+1.5, m-0.5))) / q
num_colors = len(pal_im.getpalette()) // 3
spread = 2 * 256 / num_colors
bayer_n = int(math.log2(order))
bayer_matrix = torch.from_numpy(spread * normalized_bayer_matrix(bayer_n) + 0.5)
result = torch.from_numpy(np.array(im).astype(np.float32))
tw = math.ceil(result.shape[0] / bayer_matrix.shape[0])
th = math.ceil(result.shape[1] / bayer_matrix.shape[1])
tiled_matrix = bayer_matrix.tile(tw, th).unsqueeze(-1)
result.add_(tiled_matrix[:result.shape[0],:result.shape[1]]).clamp_(0, 255)
result = result.to(dtype=torch.uint8)
im = Image.fromarray(result.cpu().numpy())
im = im.quantize(palette=pal_im, dither=Image.Dither.NONE)
return im
@classmethod
def execute(cls, image: torch.Tensor, colors: int, dither: str) -> io.NodeOutput:
batch_size, height, width, _ = image.shape
result = torch.zeros_like(image)
for b in range(batch_size):
im = Image.fromarray((image[b] * 255).to(torch.uint8).numpy(), mode='RGB')
pal_im = im.quantize(colors=colors) # Required as described in https://github.com/python-pillow/Pillow/issues/5836
if dither == "none":
quantized_image = im.quantize(palette=pal_im, dither=Image.Dither.NONE)
elif dither == "floyd-steinberg":
quantized_image = im.quantize(palette=pal_im, dither=Image.Dither.FLOYDSTEINBERG)
elif dither.startswith("bayer"):
order = int(dither.split('-')[-1])
quantized_image = Quantize.bayer(im, pal_im, order)
quantized_array = torch.tensor(np.array(quantized_image.convert("RGB"))).float() / 255
result[b] = quantized_array
return io.NodeOutput(result)
class Sharpen(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="ImageSharpen",
category="image/postprocessing",
inputs=[
io.Image.Input("image"),
io.Int.Input("sharpen_radius", default=1, min=1, max=31, step=1),
io.Float.Input("sigma", default=1.0, min=0.1, max=10.0, step=0.01),
io.Float.Input("alpha", default=1.0, min=0.0, max=5.0, step=0.01),
],
outputs=[
io.Image.Output(),
],
)
@classmethod
def execute(cls, image: torch.Tensor, sharpen_radius: int, sigma:float, alpha: float) -> io.NodeOutput:
if sharpen_radius == 0:
return io.NodeOutput(image)
batch_size, height, width, channels = image.shape
image = image.to(comfy.model_management.get_torch_device())
kernel_size = sharpen_radius * 2 + 1
kernel = gaussian_kernel(kernel_size, sigma, device=image.device) * -(alpha*10)
kernel = kernel.to(dtype=image.dtype)
center = kernel_size // 2
kernel[center, center] = kernel[center, center] - kernel.sum() + 1.0
kernel = kernel.repeat(channels, 1, 1).unsqueeze(1)
tensor_image = image.permute(0, 3, 1, 2) # Torch wants (B, C, H, W) we use (B, H, W, C)
tensor_image = F.pad(tensor_image, (sharpen_radius,sharpen_radius,sharpen_radius,sharpen_radius), 'reflect')
sharpened = F.conv2d(tensor_image, kernel, padding=center, groups=channels)[:,:,sharpen_radius:-sharpen_radius, sharpen_radius:-sharpen_radius]
sharpened = sharpened.permute(0, 2, 3, 1)
result = torch.clamp(sharpened, 0, 1)
return io.NodeOutput(result.to(comfy.model_management.intermediate_device()))
class ImageScaleToTotalPixels(io.ComfyNode):
upscale_methods = ["nearest-exact", "bilinear", "area", "bicubic", "lanczos"]
crop_methods = ["disabled", "center"]
@classmethod
def define_schema(cls):
return io.Schema(
node_id="ImageScaleToTotalPixels",
category="image/upscaling",
inputs=[
io.Image.Input("image"),
io.Combo.Input("upscale_method", options=cls.upscale_methods),
io.Float.Input("megapixels", default=1.0, min=0.01, max=16.0, step=0.01),
io.Int.Input("resolution_steps", default=1, min=1, max=256),
],
outputs=[
io.Image.Output(),
],
)
@classmethod
def execute(cls, image, upscale_method, megapixels, resolution_steps) -> io.NodeOutput:
samples = image.movedim(-1,1)
total = megapixels * 1024 * 1024
scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2]))
width = round(samples.shape[3] * scale_by / resolution_steps) * resolution_steps
height = round(samples.shape[2] * scale_by / resolution_steps) * resolution_steps
s = comfy.utils.common_upscale(samples, int(width), int(height), upscale_method, "disabled")
s = s.movedim(1,-1)
return io.NodeOutput(s)
class ResizeType(str, Enum):
SCALE_BY = "scale by multiplier"
SCALE_DIMENSIONS = "scale dimensions"
SCALE_LONGER_DIMENSION = "scale longer dimension"
SCALE_SHORTER_DIMENSION = "scale shorter dimension"
SCALE_WIDTH = "scale width"
SCALE_HEIGHT = "scale height"
SCALE_TOTAL_PIXELS = "scale total pixels"
MATCH_SIZE = "match size"
def is_image(input: torch.Tensor) -> bool:
# images have 4 dimensions: [batch, height, width, channels]
# masks have 3 dimensions: [batch, height, width]
return len(input.shape) == 4
def init_image_mask_input(input: torch.Tensor, is_type_image: bool) -> torch.Tensor:
if is_type_image:
input = input.movedim(-1, 1)
else:
input = input.unsqueeze(1)
return input
def finalize_image_mask_input(input: torch.Tensor, is_type_image: bool) -> torch.Tensor:
if is_type_image:
input = input.movedim(1, -1)
else:
input = input.squeeze(1)
return input
def scale_by(input: torch.Tensor, multiplier: float, scale_method: str) -> torch.Tensor:
is_type_image = is_image(input)
input = init_image_mask_input(input, is_type_image)
width = round(input.shape[-1] * multiplier)
height = round(input.shape[-2] * multiplier)
input = comfy.utils.common_upscale(input, width, height, scale_method, "disabled")
input = finalize_image_mask_input(input, is_type_image)
return input
def scale_dimensions(input: torch.Tensor, width: int, height: int, scale_method: str, crop: str="disabled") -> torch.Tensor:
if width == 0 and height == 0:
return input
is_type_image = is_image(input)
input = init_image_mask_input(input, is_type_image)
if width == 0:
width = max(1, round(input.shape[-1] * height / input.shape[-2]))
elif height == 0:
height = max(1, round(input.shape[-2] * width / input.shape[-1]))
input = comfy.utils.common_upscale(input, width, height, scale_method, crop)
input = finalize_image_mask_input(input, is_type_image)
return input
def scale_longer_dimension(input: torch.Tensor, longer_size: int, scale_method: str) -> torch.Tensor:
is_type_image = is_image(input)
input = init_image_mask_input(input, is_type_image)
width = input.shape[-1]
height = input.shape[-2]
if height > width:
width = round((width / height) * longer_size)
height = longer_size
elif width > height:
height = round((height / width) * longer_size)
width = longer_size
else:
height = longer_size
width = longer_size
input = comfy.utils.common_upscale(input, width, height, scale_method, "disabled")
input = finalize_image_mask_input(input, is_type_image)
return input
def scale_shorter_dimension(input: torch.Tensor, shorter_size: int, scale_method: str) -> torch.Tensor:
is_type_image = is_image(input)
input = init_image_mask_input(input, is_type_image)
width = input.shape[-1]
height = input.shape[-2]
if height < width:
width = round((width / height) * shorter_size)
height = shorter_size
elif width > height:
height = round((height / width) * shorter_size)
width = shorter_size
else:
height = shorter_size
width = shorter_size
input = comfy.utils.common_upscale(input, width, height, scale_method, "disabled")
input = finalize_image_mask_input(input, is_type_image)
return input
def scale_total_pixels(input: torch.Tensor, megapixels: float, scale_method: str) -> torch.Tensor:
is_type_image = is_image(input)
input = init_image_mask_input(input, is_type_image)
total = int(megapixels * 1024 * 1024)
scale_by = math.sqrt(total / (input.shape[-1] * input.shape[-2]))
width = round(input.shape[-1] * scale_by)
height = round(input.shape[-2] * scale_by)
input = comfy.utils.common_upscale(input, width, height, scale_method, "disabled")
input = finalize_image_mask_input(input, is_type_image)
return input
def scale_match_size(input: torch.Tensor, match: torch.Tensor, scale_method: str, crop: str) -> torch.Tensor:
is_type_image = is_image(input)
input = init_image_mask_input(input, is_type_image)
match = init_image_mask_input(match, is_image(match))
width = match.shape[-1]
height = match.shape[-2]
input = comfy.utils.common_upscale(input, width, height, scale_method, crop)
input = finalize_image_mask_input(input, is_type_image)
return input
class ResizeImageMaskNode(io.ComfyNode):
scale_methods = ["nearest-exact", "bilinear", "area", "bicubic", "lanczos"]
crop_methods = ["disabled", "center"]
class ResizeTypedDict(TypedDict):
resize_type: ResizeType
scale_method: Literal["nearest-exact", "bilinear", "area", "bicubic", "lanczos"]
crop: Literal["disabled", "center"]
multiplier: float
width: int
height: int
longer_size: int
shorter_size: int
megapixels: float
@classmethod
def define_schema(cls):
template = io.MatchType.Template("input_type", [io.Image, io.Mask])
crop_combo = io.Combo.Input("crop", options=cls.crop_methods, default="center")
return io.Schema(
node_id="ResizeImageMaskNode",
display_name="Resize Image/Mask",
category="transform",
inputs=[
io.MatchType.Input("input", template=template),
io.DynamicCombo.Input("resize_type", options=[
io.DynamicCombo.Option(ResizeType.SCALE_BY, [
io.Float.Input("multiplier", default=1.00, min=0.01, max=8.0, step=0.01),
]),
io.DynamicCombo.Option(ResizeType.SCALE_DIMENSIONS, [
io.Int.Input("width", default=512, min=0, max=MAX_RESOLUTION, step=1),
io.Int.Input("height", default=512, min=0, max=MAX_RESOLUTION, step=1),
crop_combo,
]),
io.DynamicCombo.Option(ResizeType.SCALE_LONGER_DIMENSION, [
io.Int.Input("longer_size", default=512, min=0, max=MAX_RESOLUTION, step=1),
]),
io.DynamicCombo.Option(ResizeType.SCALE_SHORTER_DIMENSION, [
io.Int.Input("shorter_size", default=512, min=0, max=MAX_RESOLUTION, step=1),
]),
io.DynamicCombo.Option(ResizeType.SCALE_WIDTH, [
io.Int.Input("width", default=512, min=0, max=MAX_RESOLUTION, step=1),
]),
io.DynamicCombo.Option(ResizeType.SCALE_HEIGHT, [
io.Int.Input("height", default=512, min=0, max=MAX_RESOLUTION, step=1),
]),
io.DynamicCombo.Option(ResizeType.SCALE_TOTAL_PIXELS, [
io.Float.Input("megapixels", default=1.0, min=0.01, max=16.0, step=0.01),
]),
io.DynamicCombo.Option(ResizeType.MATCH_SIZE, [
io.MultiType.Input("match", [io.Image, io.Mask]),
crop_combo,
]),
]),
io.Combo.Input("scale_method", options=cls.scale_methods, default="area"),
],
outputs=[io.MatchType.Output(template=template, display_name="resized")]
)
@classmethod
def execute(cls, input: io.Image.Type | io.Mask.Type, scale_method: io.Combo.Type, resize_type: ResizeTypedDict) -> io.NodeOutput:
selected_type = resize_type["resize_type"]
if selected_type == ResizeType.SCALE_BY:
return io.NodeOutput(scale_by(input, resize_type["multiplier"], scale_method))
elif selected_type == ResizeType.SCALE_DIMENSIONS:
return io.NodeOutput(scale_dimensions(input, resize_type["width"], resize_type["height"], scale_method, resize_type["crop"]))
elif selected_type == ResizeType.SCALE_LONGER_DIMENSION:
return io.NodeOutput(scale_longer_dimension(input, resize_type["longer_size"], scale_method))
elif selected_type == ResizeType.SCALE_SHORTER_DIMENSION:
return io.NodeOutput(scale_shorter_dimension(input, resize_type["shorter_size"], scale_method))
elif selected_type == ResizeType.SCALE_WIDTH:
return io.NodeOutput(scale_dimensions(input, resize_type["width"], 0, scale_method))
elif selected_type == ResizeType.SCALE_HEIGHT:
return io.NodeOutput(scale_dimensions(input, 0, resize_type["height"], scale_method))
elif selected_type == ResizeType.SCALE_TOTAL_PIXELS:
return io.NodeOutput(scale_total_pixels(input, resize_type["megapixels"], scale_method))
elif selected_type == ResizeType.MATCH_SIZE:
return io.NodeOutput(scale_match_size(input, resize_type["match"], scale_method, resize_type["crop"]))
raise ValueError(f"Unsupported resize type: {selected_type}")
def batch_images(images: list[torch.Tensor]) -> torch.Tensor | None:
if len(images) == 0:
return None
# first, get the max channels count
max_channels = max(image.shape[-1] for image in images)
# then, pad all images to have the same channels count
padded_images: list[torch.Tensor] = []
for image in images:
if image.shape[-1] < max_channels:
padded_images.append(torch.nn.functional.pad(image, (0,1), mode='constant', value=1.0))
else:
padded_images.append(image)
# resize all images to be the same size as the first image
resized_images: list[torch.Tensor] = []
first_image_shape = padded_images[0].shape
for image in padded_images:
if image.shape[1:] != first_image_shape[1:]:
resized_images.append(comfy.utils.common_upscale(image.movedim(-1,1), first_image_shape[2], first_image_shape[1], "bilinear", "center").movedim(1,-1))
else:
resized_images.append(image)
# batch the images in the format [b, h, w, c]
return torch.cat(resized_images, dim=0)
def batch_masks(masks: list[torch.Tensor]) -> torch.Tensor | None:
if len(masks) == 0:
return None
# resize all masks to be the same size as the first mask
resized_masks: list[torch.Tensor] = []
first_mask_shape = masks[0].shape
for mask in masks:
if mask.shape[1:] != first_mask_shape[1:]:
mask = init_image_mask_input(mask, is_type_image=False)
mask = comfy.utils.common_upscale(mask, first_mask_shape[2], first_mask_shape[1], "bilinear", "center")
resized_masks.append(finalize_image_mask_input(mask, is_type_image=False))
else:
resized_masks.append(mask)
# batch the masks in the format [b, h, w]
return torch.cat(resized_masks, dim=0)
def batch_latents(latents: list[dict[str, torch.Tensor]]) -> dict[str, torch.Tensor] | None:
if len(latents) == 0:
return None
samples_out = latents[0].copy()
samples_out["batch_index"] = []
first_samples = latents[0]["samples"]
tensors: list[torch.Tensor] = []
for latent in latents:
# first, deal with latent tensors
tensors.append(reshape_latent_to(first_samples.shape, latent["samples"], repeat_batch=False))
# next, deal with batch_index
samples_out["batch_index"].extend(latent.get("batch_index", [x for x in range(0, latent["samples"].shape[0])]))
samples_out["samples"] = torch.cat(tensors, dim=0)
return samples_out
class BatchImagesNode(io.ComfyNode):
@classmethod
def define_schema(cls):
autogrow_template = io.Autogrow.TemplatePrefix(io.Image.Input("image"), prefix="image", min=2, max=50)
return io.Schema(
node_id="BatchImagesNode",
display_name="Batch Images",
category="image",
inputs=[
io.Autogrow.Input("images", template=autogrow_template)
],
outputs=[
io.Image.Output()
]
)
@classmethod
def execute(cls, images: io.Autogrow.Type) -> io.NodeOutput:
return io.NodeOutput(batch_images(list(images.values())))
class BatchMasksNode(io.ComfyNode):
@classmethod
def define_schema(cls):
autogrow_template = io.Autogrow.TemplatePrefix(io.Mask.Input("mask"), prefix="mask", min=2, max=50)
return io.Schema(
node_id="BatchMasksNode",
display_name="Batch Masks",
category="mask",
inputs=[
io.Autogrow.Input("masks", template=autogrow_template)
],
outputs=[
io.Mask.Output()
]
)
@classmethod
def execute(cls, masks: io.Autogrow.Type) -> io.NodeOutput:
return io.NodeOutput(batch_masks(list(masks.values())))
class BatchLatentsNode(io.ComfyNode):
@classmethod
def define_schema(cls):
autogrow_template = io.Autogrow.TemplatePrefix(io.Latent.Input("latent"), prefix="latent", min=2, max=50)
return io.Schema(
node_id="BatchLatentsNode",
display_name="Batch Latents",
category="latent",
inputs=[
io.Autogrow.Input("latents", template=autogrow_template)
],
outputs=[
io.Latent.Output()
]
)
@classmethod
def execute(cls, latents: io.Autogrow.Type) -> io.NodeOutput:
return io.NodeOutput(batch_latents(list(latents.values())))
class BatchImagesMasksLatentsNode(io.ComfyNode):
@classmethod
def define_schema(cls):
matchtype_template = io.MatchType.Template("input", allowed_types=[io.Image, io.Mask, io.Latent])
autogrow_template = io.Autogrow.TemplatePrefix(
io.MatchType.Input("input", matchtype_template),
prefix="input", min=1, max=50)
return io.Schema(
node_id="BatchImagesMasksLatentsNode",
display_name="Batch Images/Masks/Latents",
category="util",
inputs=[
io.Autogrow.Input("inputs", template=autogrow_template)
],
outputs=[
io.MatchType.Output(id=None, template=matchtype_template)
]
)
@classmethod
def execute(cls, inputs: io.Autogrow.Type) -> io.NodeOutput:
batched = None
values = list(inputs.values())
# latents
if isinstance(values[0], dict):
batched = batch_latents(values)
# images
elif is_image(values[0]):
batched = batch_images(values)
# masks
else:
batched = batch_masks(values)
return io.NodeOutput(batched)
class PostProcessingExtension(ComfyExtension):
@override
async def get_node_list(self) -> list[type[io.ComfyNode]]:
return [
Blend,
Blur,
Quantize,
Sharpen,
ImageScaleToTotalPixels,
ResizeImageMaskNode,
BatchImagesNode,
BatchMasksNode,
BatchLatentsNode,
# BatchImagesMasksLatentsNode,
]
async def comfy_entrypoint() -> PostProcessingExtension:
return PostProcessingExtension()
@@ -0,0 +1 @@
[]
@@ -0,0 +1,36 @@
tree 62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526
parent 475d7035f7a9d45a0c69487a1cb2bfa99c02c6db
author Comfy Org PR Bot <snomiao+comfy-pr@gmail.com> 1770779208 +0900
committer GitHub <noreply@github.com> 1770779208 -0800
gpgsig -----BEGIN PGP SIGNATURE-----
wsFcBAABCAAQBQJpi/JICRC1aQ7uu5UhlAAAnGwQAGJNjyJkwGX1UMjk5tKMH53p
DuxXCOBhOx6Ym+C+Qv/rNibf73bXut72bcs15ya+b8fgWmqcnnA/S9QbooNu2njs
tUb8miis0clLaM719kXqG/Ar5dwoIAQ4CDEqeNrEjJj+6jnAQ1rZCkB+pa8J0z34
DFepFvHPEfCoHiuzZA6JWDXQsK9Sz6G/N5WA/5XbhZZ3vDFCZ3eeW8n7SVdVkHPr
4z6xc2LXSYkduyPes8EUx2Gc+9GXDytqAveaCMPNFP1GBauQuFF15YiOB/7DjQgA
NPSU+OMF8tk7BbpxVRO3rWErNBUwVVRxbz4kl/u1SHELZXpqyDs8K5QlZWH1NKTb
iK5fxqtuPi13kJZHJ9+7I19VTM8XrrQs3JHEvf8zmNUypLXFMugpmEiJ066K2orM
InVDiNu/RqHf5oV3yZUA4TULuSAx/n4wfD8jS7zy+aOBjARqK4Qs4GsLDW3GuHnh
QX1fKbJwrBMYNJIUdENfyzpHJkND2apDR7upovgqNsdJbu6JEbnnMh2e65XgsF11
vrJSu0xA53E6BINzZSDrOJdEy9VIoa1Tr/d1erkusEmI5na3zmmFtxuASJEK3Esp
c+VdRHtmadtLYF+aj3EVtz6A8XzFcZ8cJH/n6rrwy0RXluANqaAKKosNGQYPz5Lr
cXGKUOFWWQbElv3qswZj
=I1um
-----END PGP SIGNATURE-----
1.40.0 (#8797)
Minor version increment to 1.40.0
**Base branch:** `main`
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8797-1-40-0-3046d73d36508109b4b7ed3f6ca4530e)
by [Unito](https://www.unito.io)
---------
Co-authored-by: AustinMroz <4284322+AustinMroz@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
@@ -0,0 +1,5 @@
{
"ref": "refs/tags/v1.40.0",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"object": "d873c8048fe765ba08f758bbd9891788facceed5"
}
@@ -0,0 +1,36 @@
tree 62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526
parent 475d7035f7a9d45a0c69487a1cb2bfa99c02c6db
author Comfy Org PR Bot <snomiao+comfy-pr@gmail.com> 1770779208 +0900
committer GitHub <noreply@github.com> 1770779208 -0800
gpgsig -----BEGIN PGP SIGNATURE-----
wsFcBAABCAAQBQJpi/JICRC1aQ7uu5UhlAAAnGwQAGJNjyJkwGX1UMjk5tKMH53p
DuxXCOBhOx6Ym+C+Qv/rNibf73bXut72bcs15ya+b8fgWmqcnnA/S9QbooNu2njs
tUb8miis0clLaM719kXqG/Ar5dwoIAQ4CDEqeNrEjJj+6jnAQ1rZCkB+pa8J0z34
DFepFvHPEfCoHiuzZA6JWDXQsK9Sz6G/N5WA/5XbhZZ3vDFCZ3eeW8n7SVdVkHPr
4z6xc2LXSYkduyPes8EUx2Gc+9GXDytqAveaCMPNFP1GBauQuFF15YiOB/7DjQgA
NPSU+OMF8tk7BbpxVRO3rWErNBUwVVRxbz4kl/u1SHELZXpqyDs8K5QlZWH1NKTb
iK5fxqtuPi13kJZHJ9+7I19VTM8XrrQs3JHEvf8zmNUypLXFMugpmEiJ066K2orM
InVDiNu/RqHf5oV3yZUA4TULuSAx/n4wfD8jS7zy+aOBjARqK4Qs4GsLDW3GuHnh
QX1fKbJwrBMYNJIUdENfyzpHJkND2apDR7upovgqNsdJbu6JEbnnMh2e65XgsF11
vrJSu0xA53E6BINzZSDrOJdEy9VIoa1Tr/d1erkusEmI5na3zmmFtxuASJEK3Esp
c+VdRHtmadtLYF+aj3EVtz6A8XzFcZ8cJH/n6rrwy0RXluANqaAKKosNGQYPz5Lr
cXGKUOFWWQbElv3qswZj
=I1um
-----END PGP SIGNATURE-----
1.40.0 (#8797)
Minor version increment to 1.40.0
**Base branch:** `main`
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8797-1-40-0-3046d73d36508109b4b7ed3f6ca4530e)
by [Unito](https://www.unito.io)
---------
Co-authored-by: AustinMroz <4284322+AustinMroz@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
@@ -0,0 +1,199 @@
{
"name": "@comfyorg/comfyui-frontend",
"version": "1.40.0",
"private": true,
"description": "Official front-end implementation of ComfyUI",
"homepage": "https://comfy.org",
"license": "GPL-3.0-only",
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
"type": "module",
"scripts": {
"build:desktop": "nx build @comfyorg/desktop-ui",
"build-storybook": "storybook build",
"build:types": "nx build --config vite.types.config.mts && node scripts/prepare-types.js",
"build:analyze": "cross-env ANALYZE_BUNDLE=true pnpm build",
"build": "cross-env NODE_OPTIONS='--max-old-space-size=8192' pnpm typecheck && nx build",
"size:collect": "node scripts/size-collect.js",
"size:report": "node scripts/size-report.js",
"collect-i18n": "pnpm exec playwright test --config=playwright.i18n.config.ts",
"dev:cloud": "cross-env DEV_SERVER_COMFYUI_URL='https://testcloud.comfy.org/' nx serve",
"dev:desktop": "nx dev @comfyorg/desktop-ui",
"dev:electron": "cross-env DISTRIBUTION=desktop nx serve --config vite.electron.config.mts",
"dev:no-vue": "cross-env DISABLE_VUE_PLUGINS=true nx serve",
"dev": "nx serve",
"devtools:pycheck": "python3 -m compileall -q tools/devtools",
"format:check": "oxfmt --check",
"format": "oxfmt --write",
"json-schema": "tsx scripts/generate-json-schema.ts",
"knip:no-cache": "knip",
"knip": "knip --cache",
"lint:fix:no-cache": "oxlint src --type-aware --fix && eslint src --fix",
"lint:fix": "oxlint src --type-aware --fix && eslint src --cache --fix",
"lint:no-cache": "oxlint src --type-aware && eslint src",
"lint:unstaged:fix": "git diff --name-only HEAD | grep -E '\\.(js|ts|vue|mts)$' | xargs -r eslint --cache --fix",
"lint:unstaged": "git diff --name-only HEAD | grep -E '\\.(js|ts|vue|mts)$' | xargs -r eslint --cache",
"lint": "oxlint src --type-aware && eslint src --cache",
"lint:desktop": "nx run @comfyorg/desktop-ui:lint",
"locale": "lobe-i18n locale",
"oxlint": "oxlint src --type-aware",
"preinstall": "pnpm dlx only-allow pnpm",
"prepare": "husky || true && git config blame.ignoreRevsFile .git-blame-ignore-revs || true",
"preview": "nx preview",
"storybook": "nx storybook",
"storybook:desktop": "nx run @comfyorg/desktop-ui:storybook",
"stylelint:fix": "stylelint --cache --fix '{apps,packages,src}/**/*.{css,vue}'",
"stylelint": "stylelint --cache '{apps,packages,src}/**/*.{css,vue}'",
"test:browser": "pnpm exec nx e2e",
"test:browser:local": "cross-env PLAYWRIGHT_LOCAL=1 pnpm test:browser",
"test:unit": "nx run test",
"typecheck": "vue-tsc --noEmit",
"typecheck:browser": "vue-tsc --project browser_tests/tsconfig.json",
"typecheck:desktop": "nx run @comfyorg/desktop-ui:typecheck",
"zipdist": "node scripts/zipdist.js",
"clean": "nx reset"
},
"dependencies": {
"@alloc/quick-lru": "catalog:",
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@comfyorg/comfyui-electron-types": "catalog:",
"@comfyorg/design-system": "workspace:*",
"@comfyorg/registry-types": "workspace:*",
"@comfyorg/shared-frontend-utils": "workspace:*",
"@comfyorg/tailwind-utils": "workspace:*",
"@iconify/json": "catalog:",
"@primeuix/forms": "catalog:",
"@primeuix/styled": "catalog:",
"@primeuix/utils": "catalog:",
"@primevue/core": "catalog:",
"@primevue/forms": "catalog:",
"@primevue/icons": "catalog:",
"@primevue/themes": "catalog:",
"@sentry/vue": "catalog:",
"@sparkjsdev/spark": "catalog:",
"@tiptap/core": "^2.10.4",
"@tiptap/extension-link": "^2.10.4",
"@tiptap/extension-table": "^2.10.4",
"@tiptap/extension-table-cell": "^2.10.4",
"@tiptap/extension-table-header": "^2.10.4",
"@tiptap/extension-table-row": "^2.10.4",
"@tiptap/starter-kit": "^2.10.4",
"@vueuse/core": "catalog:",
"@vueuse/integrations": "catalog:",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-serialize": "^0.13.0",
"@xterm/xterm": "^5.5.0",
"algoliasearch": "catalog:",
"axios": "catalog:",
"chart.js": "^4.5.0",
"cva": "catalog:",
"dompurify": "^3.2.5",
"dotenv": "catalog:",
"es-toolkit": "^1.39.9",
"extendable-media-recorder": "^9.2.27",
"extendable-media-recorder-wav-encoder": "^7.0.129",
"firebase": "catalog:",
"fuse.js": "^7.0.0",
"glob": "^11.0.3",
"jsonata": "catalog:",
"jsondiffpatch": "^0.6.0",
"loglevel": "^1.9.2",
"marked": "^15.0.11",
"pinia": "catalog:",
"primeicons": "catalog:",
"primevue": "catalog:",
"reka-ui": "catalog:",
"semver": "^7.7.2",
"three": "^0.170.0",
"tiptap-markdown": "^0.8.10",
"typegpu": "catalog:",
"vue": "catalog:",
"vue-i18n": "catalog:",
"vue-router": "catalog:",
"vuefire": "catalog:",
"wwobjloader2": "catalog:",
"yjs": "catalog:",
"zod": "catalog:",
"zod-validation-error": "catalog:"
},
"devDependencies": {
"@eslint/js": "catalog:",
"@intlify/eslint-plugin-vue-i18n": "catalog:",
"@lobehub/i18n-cli": "catalog:",
"@nx/eslint": "catalog:",
"@nx/playwright": "catalog:",
"@nx/storybook": "catalog:",
"@nx/vite": "catalog:",
"@pinia/testing": "catalog:",
"@playwright/test": "catalog:",
"@sentry/vite-plugin": "catalog:",
"@storybook/addon-docs": "catalog:",
"@storybook/addon-mcp": "catalog:",
"@storybook/vue3": "catalog:",
"@storybook/vue3-vite": "catalog:",
"@tailwindcss/vite": "catalog:",
"@types/fs-extra": "catalog:",
"@types/jsdom": "catalog:",
"@types/node": "catalog:",
"@types/semver": "catalog:",
"@types/three": "catalog:",
"@vitejs/plugin-vue": "catalog:",
"@vitest/coverage-v8": "catalog:",
"@vitest/ui": "catalog:",
"@vue/test-utils": "catalog:",
"@webgpu/types": "catalog:",
"cross-env": "catalog:",
"eslint": "catalog:",
"eslint-config-prettier": "catalog:",
"eslint-import-resolver-typescript": "catalog:",
"eslint-plugin-import-x": "catalog:",
"eslint-plugin-oxlint": "catalog:",
"eslint-plugin-storybook": "catalog:",
"eslint-plugin-unused-imports": "catalog:",
"eslint-plugin-vue": "catalog:",
"fs-extra": "^11.2.0",
"globals": "catalog:",
"happy-dom": "catalog:",
"husky": "catalog:",
"jiti": "catalog:",
"jsdom": "catalog:",
"knip": "catalog:",
"lint-staged": "catalog:",
"markdown-table": "catalog:",
"mixpanel-browser": "catalog:",
"nx": "catalog:",
"oxfmt": "catalog:",
"oxlint": "catalog:",
"oxlint-tsgolint": "catalog:",
"picocolors": "catalog:",
"postcss-html": "catalog:",
"pretty-bytes": "catalog:",
"rollup-plugin-visualizer": "catalog:",
"storybook": "catalog:",
"stylelint": "catalog:",
"tailwindcss": "catalog:",
"tailwindcss-primeui": "catalog:",
"tsx": "catalog:",
"tw-animate-css": "catalog:",
"typescript": "catalog:",
"typescript-eslint": "catalog:",
"unplugin-icons": "catalog:",
"unplugin-typegpu": "catalog:",
"unplugin-vue-components": "catalog:",
"uuid": "^11.1.0",
"vite": "catalog:",
"vite-plugin-dts": "catalog:",
"vite-plugin-html": "catalog:",
"vite-plugin-vue-devtools": "catalog:",
"vitest": "catalog:",
"vue-component-type-helpers": "catalog:",
"vue-eslint-parser": "catalog:",
"vue-tsc": "catalog:",
"zip-dir": "^2.0.0",
"zod-to-json-schema": "catalog:"
},
"pnpm": {
"overrides": {
"vite": "^8.0.0-beta.8"
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,53 @@
import {
type ComfyNodeDef,
type InputSpec,
isComboInputSpecV1
} from '@/schemas/nodeDefSchema'
import { app } from '../../scripts/app'
// Adds an upload button to the nodes
const isMediaUploadComboInput = (inputSpec: InputSpec) => {
const [inputName, inputOptions] = inputSpec
if (!inputOptions) return false
const isUploadInput =
inputOptions['image_upload'] === true ||
inputOptions['video_upload'] === true ||
inputOptions['animated_image_upload'] === true
return (
isUploadInput && (isComboInputSpecV1(inputSpec) || inputName === 'COMBO')
)
}
const createUploadInput = (
imageInputName: string,
imageInputOptions: InputSpec
): InputSpec => [
'IMAGEUPLOAD',
{
...imageInputOptions[1],
imageInputName
}
]
app.registerExtension({
name: 'Comfy.UploadImage',
beforeRegisterNodeDef(_nodeType, nodeData: ComfyNodeDef) {
const { input } = nodeData ?? {}
const { required } = input ?? {}
if (!required) return
const found = Object.entries(required).find(([_, input]) =>
isMediaUploadComboInput(input)
)
// If media combo input found, attach upload input
if (found) {
const [inputName, inputSpec] = found
required.upload = createUploadInput(inputName, inputSpec)
}
}
})
@@ -0,0 +1,19 @@
Copyright (C) 2013 by Javi Agenjo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,316 @@
import { t } from '@/i18n'
import { type LGraphNode, isComboWidget } from '@/lib/litegraph/src/litegraph'
import type {
IBaseWidget,
IComboWidget,
IStringWidget
} from '@/lib/litegraph/src/types/widgets'
import { useSettingStore } from '@/platform/settings/settingStore'
import { dynamicWidgets } from '@/core/graph/widgets/dynamicWidgets'
import { useBooleanWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget'
import { useBoundingBoxWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBoundingBoxWidget'
import { useChartWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useChartWidget'
import { useColorWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useColorWidget'
import { useComboWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useComboWidget'
import { useFloatWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useFloatWidget'
import { useGalleriaWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useGalleriaWidget'
import { useImageCompareWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImageCompareWidget'
import { useImageUploadWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImageUploadWidget'
import { useIntWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useIntWidget'
import { useMarkdownWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget'
import { useStringWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useStringWidget'
import { useTextareaWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useTextareaWidget'
import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration'
import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2'
import type { InputSpec } from '@/schemas/nodeDefSchema'
import type { ComfyApp } from './app'
import './domWidget'
import './errorNodeWidgets'
export type ComfyWidgetConstructorV2 = (
node: LGraphNode,
inputSpec: InputSpecV2
) => IBaseWidget
export type ComfyWidgetConstructor = (
node: LGraphNode,
inputName: string,
inputData: InputSpec,
app: ComfyApp,
widgetName?: string
) => { widget: IBaseWidget; minWidth?: number; minHeight?: number }
/**
* Transforms a V2 widget constructor to a V1 widget constructor.
* @param widgetConstructorV2 The V2 widget constructor to transform.
* @returns The transformed V1 widget constructor.
*/
const transformWidgetConstructorV2ToV1 = (
widgetConstructorV2: ComfyWidgetConstructorV2
): ComfyWidgetConstructor => {
return (node, inputName, inputData) => {
const inputSpec = transformInputSpecV1ToV2(inputData, {
name: inputName
})
const widget = widgetConstructorV2(node, inputSpec)
return {
widget,
minWidth: widget.options.minNodeSize?.[0],
minHeight: widget.options.minNodeSize?.[1]
}
}
}
function controlValueRunBefore() {
return useSettingStore().get('Comfy.WidgetControlMode') === 'before'
}
export function updateControlWidgetLabel(widget: IBaseWidget) {
if (controlValueRunBefore()) {
widget.label = t('g.control_before_generate')
} else {
widget.label = t('g.control_after_generate')
}
}
export const IS_CONTROL_WIDGET = Symbol()
const HAS_EXECUTED = Symbol()
export function addValueControlWidget(
node: LGraphNode,
targetWidget: IBaseWidget,
defaultValue?: string,
_values?: unknown,
widgetName?: string,
inputData?: InputSpec
): IComboWidget {
let name = inputData?.[1]?.control_after_generate
if (typeof name !== 'string') {
name = widgetName
}
const widgets = addValueControlWidgets(
node,
targetWidget,
defaultValue ?? 'randomize',
{
addFilterList: false,
controlAfterGenerateName: name
},
inputData
)
return widgets[0]
}
export function addValueControlWidgets(
node: LGraphNode,
targetWidget: IBaseWidget,
defaultValue?: string,
options?: Record<string, any>,
inputData?: InputSpec
): [IComboWidget, ...IStringWidget[]] {
if (!defaultValue) defaultValue = 'randomize'
if (!options) options = {}
const getName = (defaultName: string, optionName: string) => {
let name = defaultName
if (options[optionName]) {
name = options[optionName]
} else if (typeof inputData?.[1]?.[defaultName] === 'string') {
name = inputData?.[1]?.[defaultName]
} else if (inputData?.[1]?.control_prefix) {
name = inputData?.[1]?.control_prefix + ' ' + name
}
return name
}
const valueControl = node.addWidget(
'combo',
getName('control_after_generate', 'controlAfterGenerateName'),
defaultValue,
function () {},
{
values: ['fixed', 'increment', 'decrement', 'randomize'],
serialize: false, // Don't include this in prompt.
canvasOnly: true
}
) as IComboWidget
valueControl.tooltip =
'Allows the linked widget to be changed automatically, for example randomizing the noise seed.'
valueControl[IS_CONTROL_WIDGET] = true
updateControlWidgetLabel(valueControl)
Object.defineProperty(valueControl, 'disabled', {
get: () => targetWidget.computedDisabled
})
const widgets: [IComboWidget, ...IStringWidget[]] = [valueControl]
const isCombo = isComboWidget(targetWidget)
let comboFilter: IStringWidget
if (isCombo && valueControl.options.values) {
// @ts-expect-error Combo widget values may be a dictionary or legacy function type
valueControl.options.values.push('increment-wrap')
}
if (isCombo && options.addFilterList !== false) {
comboFilter = node.addWidget(
'string',
getName('control_filter_list', 'controlFilterListName'),
'',
function () {},
{
serialize: false // Don't include this in prompt.
}
) as IStringWidget
updateControlWidgetLabel(comboFilter)
comboFilter.tooltip =
"Allows for filtering the list of values when changing the value via the control generate mode. Allows for RegEx matches in the format /abc/ to only filter to values containing 'abc'."
Object.defineProperty(comboFilter, 'disabled', {
get: () => targetWidget.computedDisabled
})
widgets.push(comboFilter)
}
const applyWidgetControl = () => {
var v = valueControl.value
if (isCombo && v !== 'fixed') {
let values = targetWidget.options.values ?? []
const filter = comboFilter?.value
if (filter) {
let check
if (filter.startsWith('/') && filter.endsWith('/')) {
try {
const regex = new RegExp(filter.substring(1, filter.length - 1))
check = (item: string) => regex.test(item)
} catch (error) {
console.error(
'Error constructing RegExp filter for node ' + node.id,
filter,
error
)
}
}
if (!check) {
const lower = filter.toLocaleLowerCase()
check = (item: string) => item.toLocaleLowerCase().includes(lower)
}
// @ts-expect-error Combo widget values may be a dictionary or legacy function type
values = values.filter((item: string) => check(item))
if (!values.length && targetWidget.options.values?.length) {
console.warn(
'Filter for node ' + node.id + ' has filtered out all items',
filter
)
}
}
// @ts-expect-error targetWidget.value can be number or string
let current_index = values.indexOf(targetWidget.value)
let current_length = values.length
switch (v) {
case 'increment':
current_index += 1
break
case 'increment-wrap':
current_index += 1
if (current_index >= current_length) {
current_index = 0
}
break
case 'decrement':
current_index -= 1
break
case 'randomize':
// @ts-expect-error Combo widget values may be a dictionary or legacy function type
current_index = Math.floor(Math.random() * current_length)
break
default:
break
}
current_index = Math.max(0, current_index)
// @ts-expect-error Combo widget values may be a dictionary or legacy function type
current_index = Math.min(current_length - 1, current_index)
if (current_index >= 0) {
// @ts-expect-error Combo widget values may be a dictionary or legacy function type
let value = values[current_index]
targetWidget.value = value
targetWidget.callback?.(value)
}
} else {
//number
let { min = 0, max = 1, step2 = 1 } = targetWidget.options
// limit to something that javascript can handle
max = Math.min(1125899906842624, max)
min = Math.max(-1125899906842624, min)
let range = (max - min) / step2
//adjust values based on valueControl Behaviour
switch (v) {
case 'fixed':
break
case 'increment':
// @ts-expect-error targetWidget.value can be number or string
targetWidget.value += step2
break
case 'decrement':
// @ts-expect-error targetWidget.value can be number or string
targetWidget.value -= step2
break
case 'randomize':
targetWidget.value = Math.floor(Math.random() * range) * step2 + min
break
default:
break
}
/*check if values are over or under their respective
* ranges and set them to min or max.*/
// @ts-expect-error targetWidget.value can be number or string
if (targetWidget.value < min) targetWidget.value = min
// @ts-expect-error targetWidget.value can be number or string
if (targetWidget.value > max) targetWidget.value = max
targetWidget.callback?.(targetWidget.value)
}
}
valueControl.beforeQueued = ({ isPartialExecution } = {}) => {
if (!isPartialExecution && controlValueRunBefore()) {
// Don't run on first execution
if (valueControl[HAS_EXECUTED]) {
applyWidgetControl()
}
}
valueControl[HAS_EXECUTED] = true
}
valueControl.afterQueued = ({ isPartialExecution } = {}) => {
if (!isPartialExecution && !controlValueRunBefore()) {
applyWidgetControl()
}
}
return widgets
}
export const ComfyWidgets = {
INT: transformWidgetConstructorV2ToV1(useIntWidget()),
FLOAT: transformWidgetConstructorV2ToV1(useFloatWidget()),
BOOLEAN: transformWidgetConstructorV2ToV1(useBooleanWidget()),
STRING: transformWidgetConstructorV2ToV1(useStringWidget()),
MARKDOWN: transformWidgetConstructorV2ToV1(useMarkdownWidget()),
COMBO: transformWidgetConstructorV2ToV1(useComboWidget()),
IMAGEUPLOAD: useImageUploadWidget(),
COLOR: transformWidgetConstructorV2ToV1(useColorWidget()),
IMAGECOMPARE: transformWidgetConstructorV2ToV1(useImageCompareWidget()),
BOUNDING_BOX: transformWidgetConstructorV2ToV1(useBoundingBoxWidget()),
CHART: transformWidgetConstructorV2ToV1(useChartWidget()),
GALLERIA: transformWidgetConstructorV2ToV1(useGalleriaWidget()),
TEXTAREA: transformWidgetConstructorV2ToV1(useTextareaWidget()),
...dynamicWidgets
} as const
export function isValidWidgetType(
key: unknown
): key is keyof typeof ComfyWidgets {
return ComfyWidgets[key as keyof typeof ComfyWidgets] !== undefined
}
@@ -0,0 +1 @@
[]
@@ -0,0 +1,6 @@
tree 7b8cbb865be9b72a3a8ef838595d34dfaa90e82a
parent 88d05fe483a9f420a69d681e615422930404292b
author comfyanonymous <comfyanonymous@protonmail.com> 1772139562 -0500
committer comfyanonymous <comfyanonymous@protonmail.com> 1772139562 -0500
ComfyUI v0.15.1
@@ -0,0 +1,5 @@
{
"ref": "refs/tags/v0.15.1",
"commit": "3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f",
"object": "3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f"
}
@@ -0,0 +1,6 @@
tree 7b8cbb865be9b72a3a8ef838595d34dfaa90e82a
parent 88d05fe483a9f420a69d681e615422930404292b
author comfyanonymous <comfyanonymous@protonmail.com> 1772139562 -0500
committer comfyanonymous <comfyanonymous@protonmail.com> 1772139562 -0500
ComfyUI v0.15.1
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
@@ -0,0 +1,496 @@
from __future__ import annotations
import os
import time
import mimetypes
import logging
from typing import Literal, List
from collections.abc import Collection
from comfy.cli_args import args
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
# --base-directory - Resets all default paths configured in folder_paths with a new base path
if args.base_directory:
base_path = os.path.abspath(args.base_directory)
else:
base_path = os.path.dirname(os.path.realpath(__file__))
models_dir = os.path.join(base_path, "models")
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions)
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
folder_names_and_paths["loras"] = ([os.path.join(models_dir, "loras")], supported_pt_extensions)
folder_names_and_paths["vae"] = ([os.path.join(models_dir, "vae")], supported_pt_extensions)
folder_names_and_paths["text_encoders"] = ([os.path.join(models_dir, "text_encoders"), os.path.join(models_dir, "clip")], supported_pt_extensions)
folder_names_and_paths["diffusion_models"] = ([os.path.join(models_dir, "unet"), os.path.join(models_dir, "diffusion_models")], supported_pt_extensions)
folder_names_and_paths["clip_vision"] = ([os.path.join(models_dir, "clip_vision")], supported_pt_extensions)
folder_names_and_paths["style_models"] = ([os.path.join(models_dir, "style_models")], supported_pt_extensions)
folder_names_and_paths["embeddings"] = ([os.path.join(models_dir, "embeddings")], supported_pt_extensions)
folder_names_and_paths["diffusers"] = ([os.path.join(models_dir, "diffusers")], ["folder"])
folder_names_and_paths["vae_approx"] = ([os.path.join(models_dir, "vae_approx")], supported_pt_extensions)
folder_names_and_paths["controlnet"] = ([os.path.join(models_dir, "controlnet"), os.path.join(models_dir, "t2i_adapter")], supported_pt_extensions)
folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], supported_pt_extensions)
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
folder_names_and_paths["latent_upscale_models"] = ([os.path.join(models_dir, "latent_upscale_models")], supported_pt_extensions)
folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], set())
folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions)
folder_names_and_paths["photomaker"] = ([os.path.join(models_dir, "photomaker")], supported_pt_extensions)
folder_names_and_paths["classifiers"] = ([os.path.join(models_dir, "classifiers")], {""})
folder_names_and_paths["model_patches"] = ([os.path.join(models_dir, "model_patches")], supported_pt_extensions)
folder_names_and_paths["audio_encoders"] = ([os.path.join(models_dir, "audio_encoders")], supported_pt_extensions)
output_directory = os.path.join(base_path, "output")
temp_directory = os.path.join(base_path, "temp")
input_directory = os.path.join(base_path, "input")
user_directory = os.path.join(base_path, "user")
filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
class CacheHelper:
"""
Helper class for managing file list cache data.
"""
def __init__(self):
self.cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
self.active = False
def get(self, key: str, default=None) -> tuple[list[str], dict[str, float], float]:
if not self.active:
return default
return self.cache.get(key, default)
def set(self, key: str, value: tuple[list[str], dict[str, float], float]) -> None:
if self.active:
self.cache[key] = value
def clear(self):
self.cache.clear()
def __enter__(self):
self.active = True
return self
def __exit__(self, exc_type, exc_value, traceback):
self.active = False
self.clear()
cache_helper = CacheHelper()
extension_mimetypes_cache = {
"webp" : "image",
"fbx" : "model",
}
def map_legacy(folder_name: str) -> str:
legacy = {"unet": "diffusion_models",
"clip": "text_encoders"}
return legacy.get(folder_name, folder_name)
if not os.path.exists(input_directory):
try:
os.makedirs(input_directory)
except:
logging.error("Failed to create input directory")
def set_output_directory(output_dir: str) -> None:
global output_directory
output_directory = output_dir
def set_temp_directory(temp_dir: str) -> None:
global temp_directory
temp_directory = temp_dir
def set_input_directory(input_dir: str) -> None:
global input_directory
input_directory = input_dir
def get_output_directory() -> str:
global output_directory
return output_directory
def get_temp_directory() -> str:
global temp_directory
return temp_directory
def get_input_directory() -> str:
global input_directory
return input_directory
def get_user_directory() -> str:
return user_directory
def set_user_directory(user_dir: str) -> None:
global user_directory
user_directory = user_dir
# System User Protection - Protects system directories from HTTP endpoint access
# System Users are internal-only users that cannot be accessed via HTTP endpoints.
# They use the '__' prefix convention (similar to Python's private member convention).
SYSTEM_USER_PREFIX = "__"
def get_system_user_directory(name: str = "system") -> str:
"""
Get the path to a System User directory.
System User directories (prefixed with '__') are only accessible via internal API,
not through HTTP endpoints. Use this for storing system-internal data that
should not be exposed to users.
Args:
name: System user name (e.g., "system", "cache"). Must be alphanumeric
with underscores allowed, but cannot start with underscore.
Returns:
Absolute path to the system user directory.
Raises:
ValueError: If name is empty, invalid, or starts with underscore.
Example:
>>> get_system_user_directory("cache")
'/path/to/user/__cache'
"""
if not name or not isinstance(name, str):
raise ValueError("System user name cannot be empty")
if not name.replace("_", "").isalnum():
raise ValueError(f"Invalid system user name: '{name}'")
if name.startswith("_"):
raise ValueError("System user name should not start with underscore")
return os.path.join(get_user_directory(), f"{SYSTEM_USER_PREFIX}{name}")
def get_public_user_directory(user_id: str) -> str | None:
"""
Get the path to a Public User directory for HTTP endpoint access.
This function provides structural security by returning None for any
System User (prefixed with '__'). All HTTP endpoints should use this
function instead of directly constructing user paths.
Args:
user_id: User identifier from HTTP request.
Returns:
Absolute path to the user directory, or None if user_id is invalid
or refers to a System User.
Example:
>>> get_public_user_directory("default")
'/path/to/user/default'
>>> get_public_user_directory("__system")
None
"""
if not user_id or not isinstance(user_id, str):
return None
if user_id.startswith(SYSTEM_USER_PREFIX):
return None
return os.path.join(get_user_directory(), user_id)
#NOTE: used in http server so don't put folders that should not be accessed remotely
def get_directory_by_type(type_name: str) -> str | None:
if type_name == "output":
return get_output_directory()
if type_name == "temp":
return get_temp_directory()
if type_name == "input":
return get_input_directory()
return None
def filter_files_content_types(files: list[str], content_types: List[Literal["image", "video", "audio", "model"]]) -> list[str]:
"""
Example:
files = os.listdir(folder_paths.get_input_directory())
videos = filter_files_content_types(files, ["video"])
Note:
- 'model' in MIME context refers to 3D models, not files containing trained weights and parameters
"""
global extension_mimetypes_cache
result = []
for file in files:
extension = file.split('.')[-1]
if extension not in extension_mimetypes_cache:
mime_type, _ = mimetypes.guess_type(file, strict=False)
if not mime_type:
continue
content_type = mime_type.split('/')[0]
extension_mimetypes_cache[extension] = content_type
else:
content_type = extension_mimetypes_cache[extension]
if content_type in content_types:
result.append(file)
return result
# determine base_dir rely on annotation if name is 'filename.ext [annotation]' format
# otherwise use default_path as base_dir
def annotated_filepath(name: str) -> tuple[str, str | None]:
if name.endswith("[output]"):
base_dir = get_output_directory()
name = name[:-9]
elif name.endswith("[input]"):
base_dir = get_input_directory()
name = name[:-8]
elif name.endswith("[temp]"):
base_dir = get_temp_directory()
name = name[:-7]
else:
return name, None
return name, base_dir
def get_annotated_filepath(name: str, default_dir: str | None=None) -> str:
name, base_dir = annotated_filepath(name)
if base_dir is None:
if default_dir is not None:
base_dir = default_dir
else:
base_dir = get_input_directory() # fallback path
return os.path.join(base_dir, name)
def exists_annotated_filepath(name) -> bool:
name, base_dir = annotated_filepath(name)
if base_dir is None:
base_dir = get_input_directory() # fallback path
filepath = os.path.join(base_dir, name)
return os.path.exists(filepath)
def add_model_folder_path(folder_name: str, full_folder_path: str, is_default: bool = False) -> None:
global folder_names_and_paths
folder_name = map_legacy(folder_name)
if folder_name in folder_names_and_paths:
paths, _exts = folder_names_and_paths[folder_name]
if full_folder_path in paths:
if is_default and paths[0] != full_folder_path:
# If the path to the folder is not the first in the list, move it to the beginning.
paths.remove(full_folder_path)
paths.insert(0, full_folder_path)
else:
if is_default:
paths.insert(0, full_folder_path)
else:
paths.append(full_folder_path)
else:
folder_names_and_paths[folder_name] = ([full_folder_path], set())
def get_folder_paths(folder_name: str) -> list[str]:
folder_name = map_legacy(folder_name)
return folder_names_and_paths[folder_name][0][:]
def recursive_search(directory: str, excluded_dir_names: list[str] | None=None) -> tuple[list[str], dict[str, float]]:
if not os.path.isdir(directory):
return [], {}
if excluded_dir_names is None:
excluded_dir_names = []
result = []
dirs = {}
# Attempt to add the initial directory to dirs with error handling
try:
dirs[directory] = os.path.getmtime(directory)
except FileNotFoundError:
logging.warning(f"Warning: Unable to access {directory}. Skipping this path.")
logging.debug("recursive file list on directory {}".format(directory))
dirpath: str
subdirs: list[str]
filenames: list[str]
for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True):
subdirs[:] = [d for d in subdirs if d not in excluded_dir_names]
for file_name in filenames:
try:
relative_path = os.path.relpath(os.path.join(dirpath, file_name), directory)
result.append(relative_path)
except:
logging.warning(f"Warning: Unable to access {file_name}. Skipping this file.")
continue
for d in subdirs:
path: str = os.path.join(dirpath, d)
try:
dirs[path] = os.path.getmtime(path)
except FileNotFoundError:
logging.warning(f"Warning: Unable to access {path}. Skipping this path.")
continue
logging.debug("found {} files".format(len(result)))
return result, dirs
def filter_files_extensions(files: Collection[str], extensions: Collection[str]) -> list[str]:
return sorted(list(filter(lambda a: os.path.splitext(a)[-1].lower() in extensions or len(extensions) == 0, files)))
def get_full_path(folder_name: str, filename: str) -> str | None:
"""
Get the full path of a file in a folder, has to be a file
"""
global folder_names_and_paths
folder_name = map_legacy(folder_name)
if folder_name not in folder_names_and_paths:
return None
folders = folder_names_and_paths[folder_name]
filename = os.path.relpath(os.path.join("/", filename), "/")
for x in folders[0]:
full_path = os.path.join(x, filename)
if os.path.isfile(full_path):
return full_path
elif os.path.islink(full_path):
logging.warning("WARNING path {} exists but doesn't link anywhere, skipping.".format(full_path))
return None
def get_full_path_or_raise(folder_name: str, filename: str) -> str:
"""
Get the full path of a file in a folder, has to be a file
"""
full_path = get_full_path(folder_name, filename)
if full_path is None:
raise FileNotFoundError(f"Model in folder '{folder_name}' with filename '{filename}' not found.")
return full_path
def get_filename_list_(folder_name: str) -> tuple[list[str], dict[str, float], float]:
folder_name = map_legacy(folder_name)
global folder_names_and_paths
output_list = set()
folders = folder_names_and_paths[folder_name]
output_folders = {}
for x in folders[0]:
files, folders_all = recursive_search(x, excluded_dir_names=[".git"])
output_list.update(filter_files_extensions(files, folders[1]))
output_folders = {**output_folders, **folders_all}
return sorted(list(output_list)), output_folders, time.perf_counter()
def cached_filename_list_(folder_name: str) -> tuple[list[str], dict[str, float], float] | None:
strong_cache = cache_helper.get(folder_name)
if strong_cache is not None:
return strong_cache
global filename_list_cache
global folder_names_and_paths
folder_name = map_legacy(folder_name)
if folder_name not in filename_list_cache:
return None
out = filename_list_cache[folder_name]
for x in out[1]:
time_modified = out[1][x]
folder = x
if os.path.getmtime(folder) != time_modified:
return None
folders = folder_names_and_paths[folder_name]
for x in folders[0]:
if os.path.isdir(x):
if x not in out[1]:
return None
return out
def get_filename_list(folder_name: str) -> list[str]:
folder_name = map_legacy(folder_name)
out = cached_filename_list_(folder_name)
if out is None:
out = get_filename_list_(folder_name)
global filename_list_cache
filename_list_cache[folder_name] = out
cache_helper.set(folder_name, out)
return list(out[0])
def get_save_image_path(filename_prefix: str, output_dir: str, image_width=0, image_height=0) -> tuple[str, str, int, str, str]:
def map_filename(filename: str) -> tuple[int, str]:
prefix_len = len(os.path.basename(filename_prefix))
prefix = filename[:prefix_len + 1]
try:
digits = int(filename[prefix_len + 1:].split('_')[0])
except:
digits = 0
return digits, prefix
def compute_vars(input: str, image_width: int, image_height: int) -> str:
input = input.replace("%width%", str(image_width))
input = input.replace("%height%", str(image_height))
now = time.localtime()
input = input.replace("%year%", str(now.tm_year))
input = input.replace("%month%", str(now.tm_mon).zfill(2))
input = input.replace("%day%", str(now.tm_mday).zfill(2))
input = input.replace("%hour%", str(now.tm_hour).zfill(2))
input = input.replace("%minute%", str(now.tm_min).zfill(2))
input = input.replace("%second%", str(now.tm_sec).zfill(2))
return input
if "%" in filename_prefix:
filename_prefix = compute_vars(filename_prefix, image_width, image_height)
subfolder = os.path.dirname(os.path.normpath(filename_prefix))
filename = os.path.basename(os.path.normpath(filename_prefix))
full_output_folder = os.path.join(output_dir, subfolder)
if os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) != output_dir:
err = "**** ERROR: Saving image outside the output folder is not allowed." + \
"\n full_output_folder: " + os.path.abspath(full_output_folder) + \
"\n output_dir: " + output_dir + \
"\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder)))
logging.error(err)
raise Exception(err)
try:
counter = max(filter(lambda a: os.path.normcase(a[1][:-1]) == os.path.normcase(filename) and a[1][-1] == "_", map(map_filename, os.listdir(full_output_folder))))[0] + 1
except ValueError:
counter = 1
except FileNotFoundError:
os.makedirs(full_output_folder, exist_ok=True)
counter = 1
return full_output_folder, filename, counter, subfolder, filename_prefix
def get_input_subfolders() -> list[str]:
"""Returns a list of all subfolder paths in the input directory, recursively.
Returns:
List of folder paths relative to the input directory, excluding the root directory
"""
input_dir = get_input_directory()
folders = []
try:
if not os.path.exists(input_dir):
return []
for root, dirs, _ in os.walk(input_dir):
rel_path = os.path.relpath(root, input_dir)
if rel_path != ".": # Only include non-root directories
# Normalize path separators to forward slashes
folders.append(rel_path.replace(os.sep, '/'))
return sorted(folders)
except FileNotFoundError:
return []
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,226 @@
{
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"size": 4051430,
"headers": {
"x-guploader-uploadid": "AFy3sg3S7HFryZ7_WZB_-W5BoZeJloXQhfvdgjLQh8DRskOGtvimeSljweRdahO6hWtSUvL8gvifkuY",
"x-goog-generation": "1765504447438832",
"x-goog-metageneration": "1",
"x-goog-stored-content-encoding": "identity",
"x-goog-stored-content-length": "4051430",
"x-goog-hash": "crc32c=voZuRg==",
"x-goog-storage-class": "STANDARD",
"accept-ranges": "bytes",
"access-control-allow-origin": "*",
"access-control-expose-headers": "*",
"server": "UploadServer",
"via": "1.1 google",
"Date": "Fri, 30 Oct 2026 22:44:57 GMT",
"Last-Modified": "Fri, 12 Dec 2025 01:54:07 GMT",
"ETag": "\"e5c61db9073fcc1d32a7829502fbff4c\"",
"Content-Type": "application/zip",
"Content-Length": "4051430",
"Age": "38",
"Cache-Control": "public,max-age=3600",
"Alt-Svc": "h3=\":443\"; ma=2592000",
"Connection": "close"
},
"ranges": [
{
"start": 4051408,
"end": 4051429,
"sha256": "b06902263ce6a085b7feb989dcbeb66402eebc00b39afef3bf6a558fe36aa716"
},
{
"start": 4051388,
"end": 4051407,
"sha256": "908975ac70a522bf33070f03c2d5168af0493d1bf0db62a004b3bb762eca55e3"
},
{
"start": 4032211,
"end": 4051407,
"sha256": "daa01cc94a2cc0540c4bc7c5dae5a5b14c761159a65223fb7d1559923c2e59bd"
},
{
"start": 21327,
"end": 21356,
"sha256": "6fcc8626086fa000ceb534f4a100cdd298ca3b7e841d7b3196c172f102c46703"
},
{
"start": 21357,
"end": 21367,
"sha256": "8e2c1f727276d30ced72fa67cb848772a9802162bec39b42a8df5359fd063a4c"
},
{
"start": 21368,
"end": 23201,
"sha256": "834978548b729ac90555144c1fcfdec9bf8bf2974cdfb3fa3128087f6de4bb02"
},
{
"start": 3196060,
"end": 3196089,
"sha256": "07a22132f192900466f85a9b48cdcf527611e7b67f87cbd78c21b4c089560976"
},
{
"start": 3196090,
"end": 3196109,
"sha256": "ac53ebde94fcad0684890e6ac64784cd4971afeda3c96879caea4d882514c227"
},
{
"start": 3196110,
"end": 3196685,
"sha256": "322960fc37241b401660d951fab7fe331771b41fbc781b229c09e90de7ef1381"
},
{
"start": 3188896,
"end": 3188925,
"sha256": "3541575431327578f2e8f2ff30cd8ece564dacdf38fd19851ef33de8e862c6f4"
},
{
"start": 3188926,
"end": 3188940,
"sha256": "c3f23203b7bc38baf51d8347b9d400305b13f50de54e6ddd1284956255bef3a6"
},
{
"start": 3188941,
"end": 3189082,
"sha256": "51966fe74f3716786123c073e76153a772421f33b8712c4425b63230f6d3fa4a"
},
{
"start": 3716552,
"end": 3716581,
"sha256": "1995655cfbd210adeb293488744ce704bb06323dab7ecd3aa99d13c129d153e0"
},
{
"start": 3716582,
"end": 3716610,
"sha256": "5e9aef46243bd99e20513082665d672c70573105757770ba611222148e1870fe"
},
{
"start": 3716611,
"end": 3720200,
"sha256": "03f5cea746f971c4f234bdf3b1eb73649d05d6efd42e4f5355832ddc6c969464"
},
{
"start": 3672954,
"end": 3672983,
"sha256": "bef3d5d547c59650c84befcb8a5793431a5dfb91a5c99713834a59e0da693e90"
},
{
"start": 3672984,
"end": 3673007,
"sha256": "158d6185d4a31277d882894490aa805133a572b9e56affaa1571f189b8d5fa95"
},
{
"start": 3673008,
"end": 3676120,
"sha256": "74f79443833083aacd9e8b7e4e9e5c82dcc27e9ecd8005fc2761f7a767b2b489"
},
{
"start": 3689254,
"end": 3689283,
"sha256": "5a38d4d483085424510168988be457164bd15562e9aef914ce54537a70e0f220"
},
{
"start": 3689284,
"end": 3689307,
"sha256": "f9c7612bb4bd3fc7e49b702c164a8b20dd70ddf862efe89eeb4cf715048e4c35"
},
{
"start": 3689308,
"end": 3690257,
"sha256": "c961c84ebc3ea2f50303454a60357fed9f031212052f1bd9575faed9b8f6eca0"
},
{
"start": 3787232,
"end": 3787261,
"sha256": "9b12c37a61de79bdfdffc9d245fccf7ac8c788918699d0786c1f78b3c2749d7c"
},
{
"start": 3787262,
"end": 3787289,
"sha256": "a11b87179ab4822aec57dc5fb004b2f17116c636ffb5639101b3870204c51873"
},
{
"start": 3787290,
"end": 3789673,
"sha256": "4a4cbe548c8060359aa340fd786f030e6e41f10d8debfb0e0936f01aca2aa0c8"
},
{
"start": 3775382,
"end": 3775411,
"sha256": "679ff1cba7659a760a57575db692b51f1a444932201e61d52c8fbf64fa7f3a71"
},
{
"start": 3775412,
"end": 3775431,
"sha256": "0d03dfde180503e41e8e57f92d10b64651d611b3bd4f97de3d5a5a9ee83d007a"
},
{
"start": 3775432,
"end": 3782152,
"sha256": "3b266819ae38225cf961c3624be65d8b58bcda1bf0c445f8979f3a417f033575"
},
{
"start": 3782153,
"end": 3782182,
"sha256": "5762bafb817d1054efedd68f7c2bb456e48025de62a0ca9609526a186c0c963a"
},
{
"start": 3782183,
"end": 3782209,
"sha256": "fbe28b6fdb36ef9d1c3b8b528085666f6bf66c4040d8c0d822dca471202b1ec1"
},
{
"start": 3782210,
"end": 3784296,
"sha256": "4e4e29c008227fb37abba533cd7f6b6515a7edbb122c08aa46d2a5b8221859d1"
},
{
"start": 3826338,
"end": 3826367,
"sha256": "cd45c6732c7740d331e7279f8593f02fe46034c078932e674a83b3ec28aee0aa"
},
{
"start": 3826368,
"end": 3826392,
"sha256": "3a461905bd9f8422951bd106a9ba20b4d4a0fa356f14813d06ae9983e4801031"
},
{
"start": 3826393,
"end": 3827560,
"sha256": "52ffc8a128680076bdbd1473a07470de81cae7c4550e9833ef73d91902801e3e"
},
{
"start": 8118,
"end": 8147,
"sha256": "28bd1d5d422550144b70de9c60db97195b32113753e86b981f6ff315ae625cd9"
},
{
"start": 8148,
"end": 8154,
"sha256": "c693279643b8cd5d248172d9c22cb7cf4ed163a3c98c8a3f69c2717edd3eacb7"
},
{
"start": 8155,
"end": 8806,
"sha256": "966503e73c7cbda1ae32caa6e566dbd4f4d3e227e016a71321c2b10a0e33c494"
},
{
"start": 3235386,
"end": 3235415,
"sha256": "a8e543ea7c50156a38bafa9e82033ece3aeb4a3d32557c6ef59c5066f20f9964"
},
{
"start": 3235416,
"end": 3235429,
"sha256": "50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711"
},
{
"start": 3235430,
"end": 3235656,
"sha256": "623cbc055d778c344eabbdb872e0f310d7247435ac270f9821a240c732407f2c"
}
],
"package_sha256": "unknown; full archive intentionally not fetched",
"git_binding": "unknown"
}
@@ -0,0 +1 @@
{"changelog":"","createdAt":"2025-12-12T01:54:05.690176Z","dependencies":[],"deprecated":false,"downloadUrl":"https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip","id":"811cfe95-7c95-4715-98ec-d18e5c4c908e","node_id":"rgthree-comfy","status":"NodeVersionStatusActive","supported_accelerators":[],"supported_comfyui_frontend_version":"","supported_comfyui_version":"","supported_os":[],"tags":[],"version":"1.0.2512112053"}
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Regis Gaughan, III (rgthree)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,126 @@
"""
@author: rgthree
@title: Comfy Nodes
@nickname: rgthree
@description: A bunch of nodes I created that I also find useful.
"""
from glob import glob
import json
import os
import shutil
import re
import random
import execution
from .py.log import log
from .py.config import get_config_value
from .py.server.rgthree_server import *
from .py.context import RgthreeContext
from .py.context_switch import RgthreeContextSwitch
from .py.context_switch_big import RgthreeContextSwitchBig
from .py.display_any import RgthreeDisplayAny, RgthreeDisplayInt
from .py.lora_stack import RgthreeLoraLoaderStack
from .py.seed import RgthreeSeed
from .py.sdxl_empty_latent_image import RgthreeSDXLEmptyLatentImage
from .py.power_prompt import RgthreePowerPrompt
from .py.power_prompt_simple import RgthreePowerPromptSimple
from .py.image_inset_crop import RgthreeImageInsetCrop
from .py.context_big import RgthreeBigContext
from .py.dynamic_context import RgthreeDynamicContext
from .py.dynamic_context_switch import RgthreeDynamicContextSwitch
from .py.ksampler_config import RgthreeKSamplerConfig
from .py.sdxl_power_prompt_postive import RgthreeSDXLPowerPromptPositive
from .py.sdxl_power_prompt_simple import RgthreeSDXLPowerPromptSimple
from .py.any_switch import RgthreeAnySwitch
from .py.context_merge import RgthreeContextMerge
from .py.context_merge_big import RgthreeContextMergeBig
from .py.image_comparer import RgthreeImageComparer
from .py.power_lora_loader import RgthreePowerLoraLoader
from .py.power_primitive import RgthreePowerPrimitive
from .py.image_or_latent_size import RgthreeImageOrLatentSize
from .py.image_resize import RgthreeImageResize
from .py.power_puter import RgthreePowerPuter
NODE_CLASS_MAPPINGS = {
RgthreeBigContext.NAME: RgthreeBigContext,
RgthreeContext.NAME: RgthreeContext,
RgthreeContextSwitch.NAME: RgthreeContextSwitch,
RgthreeContextSwitchBig.NAME: RgthreeContextSwitchBig,
RgthreeContextMerge.NAME: RgthreeContextMerge,
RgthreeContextMergeBig.NAME: RgthreeContextMergeBig,
RgthreeDisplayInt.NAME: RgthreeDisplayInt,
RgthreeDisplayAny.NAME: RgthreeDisplayAny,
RgthreeLoraLoaderStack.NAME: RgthreeLoraLoaderStack,
RgthreeSeed.NAME: RgthreeSeed,
RgthreeImageInsetCrop.NAME: RgthreeImageInsetCrop,
RgthreePowerPrompt.NAME: RgthreePowerPrompt,
RgthreePowerPromptSimple.NAME: RgthreePowerPromptSimple,
RgthreeKSamplerConfig.NAME: RgthreeKSamplerConfig,
RgthreeSDXLEmptyLatentImage.NAME: RgthreeSDXLEmptyLatentImage,
RgthreeSDXLPowerPromptPositive.NAME: RgthreeSDXLPowerPromptPositive,
RgthreeSDXLPowerPromptSimple.NAME: RgthreeSDXLPowerPromptSimple,
RgthreeAnySwitch.NAME: RgthreeAnySwitch,
RgthreeImageComparer.NAME: RgthreeImageComparer,
RgthreePowerLoraLoader.NAME: RgthreePowerLoraLoader,
RgthreePowerPrimitive.NAME: RgthreePowerPrimitive,
RgthreeImageOrLatentSize.NAME: RgthreeImageOrLatentSize,
RgthreeImageResize.NAME: RgthreeImageResize,
RgthreePowerPuter.NAME: RgthreePowerPuter,
}
if get_config_value('unreleased.dynamic_context.enabled') is True:
NODE_CLASS_MAPPINGS[RgthreeDynamicContext.NAME] = RgthreeDynamicContext
NODE_CLASS_MAPPINGS[RgthreeDynamicContextSwitch.NAME] = RgthreeDynamicContextSwitch
# WEB_DIRECTORY is the comfyui nodes directory that ComfyUI will link and auto-load.
WEB_DIRECTORY = "./web/comfyui"
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DIR_WEB = os.path.abspath(f'{THIS_DIR}/{WEB_DIRECTORY}')
DIR_PY = os.path.abspath(f'{THIS_DIR}/py')
# remove old directories
OLD_DIRS = [
os.path.abspath(f'{THIS_DIR}/../../web/extensions/rgthree'),
os.path.abspath(f'{THIS_DIR}/../../web/extensions/rgthree-comfy'),
]
for old_dir in OLD_DIRS:
if os.path.exists(old_dir):
shutil.rmtree(old_dir)
__all__ = ['NODE_CLASS_MAPPINGS', 'WEB_DIRECTORY']
NOT_NODES = ['constants', 'log', 'utils', 'rgthree', 'rgthree_server', 'image_clipbaord', 'config']
nodes = []
for file in glob(os.path.join(DIR_PY, '*.py')) + glob(os.path.join(DIR_WEB, '*.js')):
name = os.path.splitext(os.path.basename(file))[0]
if name in NOT_NODES or name in nodes:
continue
if name.startswith('_') or name.startswith('base') or 'utils' in name:
continue
nodes.append(name)
if name == 'display_any':
nodes.append('display_int')
print()
adjs = ['exciting', 'extraordinary', 'epic', 'fantastic', 'magnificent']
log(f'Loaded {len(nodes)} {random.choice(adjs)} nodes. 🎉', color='BRIGHT_GREEN')
print()
if get_config_value('announcements.comfy-nodes-20.incompatible', True):
message = (
"ComfyUI's new Node 2.0 rendering may be incompatible with some rgthree-comfy nodes "
"and features, breaking some rendering as well as losing the ability to "
"access a node's properties (a vital part of many nodes). It also appears to run MUCH more "
"slowly spiking CPU usage and causing jankiness and unresponsiveness, especially with large "
"workflows. Personally I am not planning to use the new Nodes 2.0 and, unfortunately, am not "
"able to invest the time to investigate and overhaul rgthree-comfy where needed. "
"If you have issues when Nodes 2.0 is enabled, I'd urge you to switch it off as well and "
"join me in hoping ComfyUI is not planning to deprecate the existing, stable canvas rendering "
"all together.\n"
)
log(message, color='YELLOW', id='announcements.comfy-nodes-20.incompatible', at_most_secs=60)
@@ -0,0 +1,11 @@
NAMESPACE='rgthree'
def get_name(name):
return '{} ({})'.format(name, NAMESPACE)
def get_category(sub_dirs = None):
if sub_dirs is None:
return NAMESPACE
else:
return "{}/utils".format(NAMESPACE)
@@ -0,0 +1,42 @@
from nodes import PreviewImage
from .constants import get_category, get_name
class RgthreeImageComparer(PreviewImage):
"""A node that compares two images in the UI."""
NAME = get_name('Image Comparer')
CATEGORY = get_category()
FUNCTION = "compare_images"
DESCRIPTION = "Compares two images with a hover slider, or click from properties."
@classmethod
def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstring
return {
"required": {},
"optional": {
"image_a": ("IMAGE",),
"image_b": ("IMAGE",),
},
"hidden": {
"prompt": "PROMPT",
"extra_pnginfo": "EXTRA_PNGINFO"
},
}
def compare_images(self,
image_a=None,
image_b=None,
filename_prefix="rgthree.compare.",
prompt=None,
extra_pnginfo=None):
result = { "ui": { "a_images":[], "b_images": [] } }
if image_a is not None and len(image_a) > 0:
result['ui']['a_images'] = self.save_images(image_a, filename_prefix, prompt, extra_pnginfo)['ui']['images']
if image_b is not None and len(image_b) > 0:
result['ui']['b_images'] = self.save_images(image_b, filename_prefix, prompt, extra_pnginfo)['ui']['images']
return result
@@ -0,0 +1,14 @@
[project]
name = "rgthree-comfy"
description = "Making ComfyUI more comfortable."
version = "1.0.2512112053"
license = { file = "LICENSE" }
dependencies = []
[project.urls]
Repository = "https://github.com/rgthree/rgthree-comfy"
[tool.comfy]
PublisherId = "rgthree"
DisplayName = "rgthree-comfy"
Icon = "https://comfy.rgthree.com/media/rgthree.svg"
@@ -0,0 +1,316 @@
import { app } from "../../scripts/app.js";
import { ComfyWidgets } from "../../scripts/widgets.js";
import { SERVICE as KEY_EVENT_SERVICE } from "./services/key_events_services.js";
import { LogLevel, rgthree } from "./rgthree.js";
import { addHelpMenuItem } from "./utils.js";
import { RgthreeHelpDialog } from "../../rgthree/common/dialog.js";
import { importIndividualNodesInnerOnDragDrop, importIndividualNodesInnerOnDragOver, } from "./feature_import_individual_nodes.js";
import { defineProperty, moveArrayItem } from "../../rgthree/common/shared_utils.js";
export class RgthreeBaseNode extends LGraphNode {
constructor(title = RgthreeBaseNode.title, skipOnConstructedCall = true) {
super(title);
this.comfyClass = "__NEED_COMFY_CLASS__";
this.nickname = "rgthree";
this.isVirtualNode = false;
this.isDropEnabled = false;
this.removed = false;
this.configuring = false;
this._tempWidth = 0;
this.__constructed__ = false;
this.helpDialog = null;
if (title == "__NEED_CLASS_TITLE__") {
throw new Error("RgthreeBaseNode needs overrides.");
}
this.widgets = this.widgets || [];
this.properties = this.properties || {};
setTimeout(() => {
if (this.comfyClass == "__NEED_COMFY_CLASS__") {
throw new Error("RgthreeBaseNode needs a comfy class override.");
}
if (this.constructor.type == "__NEED_CLASS_TYPE__") {
throw new Error("RgthreeBaseNode needs overrides.");
}
this.checkAndRunOnConstructed();
});
defineProperty(this, "mode", {
get: () => {
return this.rgthree_mode;
},
set: (mode) => {
if (this.rgthree_mode != mode) {
const oldMode = this.rgthree_mode;
this.rgthree_mode = mode;
this.onModeChange(oldMode, mode);
}
},
});
}
checkAndRunOnConstructed() {
var _a;
if (!this.__constructed__) {
this.onConstructed();
const [n, v] = rgthree.logger.logParts(LogLevel.DEV, `[RgthreeBaseNode] Child class did not call onConstructed for "${this.type}.`);
(_a = console[n]) === null || _a === void 0 ? void 0 : _a.call(console, ...v);
}
return this.__constructed__;
}
onDragOver(e) {
if (!this.isDropEnabled)
return false;
return importIndividualNodesInnerOnDragOver(this, e);
}
async onDragDrop(e) {
if (!this.isDropEnabled)
return false;
return importIndividualNodesInnerOnDragDrop(this, e);
}
onConstructed() {
var _a;
if (this.__constructed__)
return false;
this.type = (_a = this.type) !== null && _a !== void 0 ? _a : undefined;
this.__constructed__ = true;
rgthree.invokeExtensionsAsync("nodeCreated", this);
return this.__constructed__;
}
configure(info) {
this.configuring = true;
super.configure(info);
for (const w of this.widgets || []) {
w.last_y = w.last_y || 0;
}
this.configuring = false;
}
clone() {
const cloned = super.clone();
if ((cloned === null || cloned === void 0 ? void 0 : cloned.properties) && !!window.structuredClone) {
cloned.properties = structuredClone(cloned.properties);
}
cloned.graph = this.graph;
return cloned;
}
onModeChange(from, to) {
}
async handleAction(action) {
action;
}
removeWidget(widget) {
var _a;
if (typeof widget === "number") {
widget = this.widgets[widget];
}
if (!widget)
return;
const canUseComfyUIRemoveWidget = false;
if (canUseComfyUIRemoveWidget && typeof super.removeWidget === 'function') {
super.removeWidget(widget);
}
else {
const index = this.widgets.indexOf(widget);
if (index > -1) {
this.widgets.splice(index, 1);
}
(_a = widget.onRemove) === null || _a === void 0 ? void 0 : _a.call(widget);
}
}
replaceWidget(widgetOrSlot, newWidget) {
let index = null;
if (widgetOrSlot) {
index = typeof widgetOrSlot === "number" ? widgetOrSlot : this.widgets.indexOf(widgetOrSlot);
this.removeWidget(this.widgets[index]);
}
index = index != null ? index : this.widgets.length - 1;
if (this.widgets.includes(newWidget)) {
moveArrayItem(this.widgets, newWidget, index);
}
else {
this.widgets.splice(index, 0, newWidget);
}
}
defaultGetSlotMenuOptions(slot) {
var _a, _b;
const menu_info = [];
if ((_b = (_a = slot === null || slot === void 0 ? void 0 : slot.output) === null || _a === void 0 ? void 0 : _a.links) === null || _b === void 0 ? void 0 : _b.length) {
menu_info.push({ content: "Disconnect Links", slot });
}
let inputOrOutput = slot.input || slot.output;
if (inputOrOutput) {
if (inputOrOutput.removable) {
menu_info.push(inputOrOutput.locked ? { content: "Cannot remove" } : { content: "Remove Slot", slot });
}
if (!inputOrOutput.nameLocked) {
menu_info.push({ content: "Rename Slot", slot });
}
}
return menu_info;
}
onRemoved() {
var _a;
(_a = super.onRemoved) === null || _a === void 0 ? void 0 : _a.call(this);
this.removed = true;
}
static setUp(...args) {
}
getHelp() {
return "";
}
showHelp() {
const help = this.getHelp() || this.constructor.help;
if (help) {
this.helpDialog = new RgthreeHelpDialog(this, help).show();
this.helpDialog.addEventListener("close", (e) => {
this.helpDialog = null;
});
}
}
onKeyDown(event) {
KEY_EVENT_SERVICE.handleKeyDownOrUp(event);
if (event.key == "?" && !this.helpDialog) {
this.showHelp();
}
}
onKeyUp(event) {
KEY_EVENT_SERVICE.handleKeyDownOrUp(event);
}
getExtraMenuOptions(canvas, options) {
var _a, _b, _c, _d, _e, _f;
if (super.getExtraMenuOptions) {
(_a = super.getExtraMenuOptions) === null || _a === void 0 ? void 0 : _a.apply(this, [canvas, options]);
}
else if ((_c = (_b = this.constructor.nodeType) === null || _b === void 0 ? void 0 : _b.prototype) === null || _c === void 0 ? void 0 : _c.getExtraMenuOptions) {
(_f = (_e = (_d = this.constructor.nodeType) === null || _d === void 0 ? void 0 : _d.prototype) === null || _e === void 0 ? void 0 : _e.getExtraMenuOptions) === null || _f === void 0 ? void 0 : _f.apply(this, [canvas, options]);
}
const help = this.getHelp() || this.constructor.help;
if (help) {
addHelpMenuItem(this, help, options);
}
return [];
}
}
RgthreeBaseNode.exposedActions = [];
RgthreeBaseNode.title = "__NEED_CLASS_TITLE__";
RgthreeBaseNode.type = "__NEED_CLASS_TYPE__";
RgthreeBaseNode.category = "rgthree";
RgthreeBaseNode._category = "rgthree";
export class RgthreeBaseVirtualNode extends RgthreeBaseNode {
constructor(title = RgthreeBaseNode.title) {
super(title, false);
this.isVirtualNode = true;
}
static setUp() {
if (!this.type) {
throw new Error(`Missing type for RgthreeBaseVirtualNode: ${this.title}`);
}
LiteGraph.registerNodeType(this.type, this);
if (this._category) {
this.category = this._category;
}
}
}
export class RgthreeBaseServerNode extends RgthreeBaseNode {
constructor(title) {
super(title, true);
this.isDropEnabled = true;
this.serialize_widgets = true;
this.setupFromServerNodeData();
this.onConstructed();
}
getWidgets() {
return ComfyWidgets;
}
async setupFromServerNodeData() {
var _a, _b, _c, _d, _e;
const nodeData = this.constructor.nodeData;
if (!nodeData) {
throw Error("No node data");
}
this.comfyClass = nodeData.name;
let inputs = nodeData["input"]["required"];
if (nodeData["input"]["optional"] != undefined) {
inputs = Object.assign({}, inputs, nodeData["input"]["optional"]);
}
const WIDGETS = this.getWidgets();
const config = {
minWidth: 1,
minHeight: 1,
widget: null,
};
for (const inputName in inputs) {
const inputData = inputs[inputName];
const type = inputData[0];
if ((_a = inputData[1]) === null || _a === void 0 ? void 0 : _a.forceInput) {
this.addInput(inputName, type);
}
else {
let widgetCreated = true;
if (Array.isArray(type)) {
Object.assign(config, WIDGETS.COMBO(this, inputName, inputData, app) || {});
}
else if (`${type}:${inputName}` in WIDGETS) {
Object.assign(config, WIDGETS[`${type}:${inputName}`](this, inputName, inputData, app) || {});
}
else if (type in WIDGETS) {
Object.assign(config, WIDGETS[type](this, inputName, inputData, app) || {});
}
else {
this.addInput(inputName, type);
widgetCreated = false;
}
if (widgetCreated && ((_b = inputData[1]) === null || _b === void 0 ? void 0 : _b.forceInput) && (config === null || config === void 0 ? void 0 : config.widget)) {
if (!config.widget.options)
config.widget.options = {};
config.widget.options.forceInput = inputData[1].forceInput;
}
if (widgetCreated && ((_c = inputData[1]) === null || _c === void 0 ? void 0 : _c.defaultInput) && (config === null || config === void 0 ? void 0 : config.widget)) {
if (!config.widget.options)
config.widget.options = {};
config.widget.options.defaultInput = inputData[1].defaultInput;
}
}
}
for (const o in nodeData["output"]) {
let output = nodeData["output"][o];
if (output instanceof Array)
output = "COMBO";
const outputName = nodeData["output_name"][o] || output;
const outputShape = nodeData["output_is_list"][o]
? LiteGraph.GRID_SHAPE
: LiteGraph.CIRCLE_SHAPE;
this.addOutput(outputName, output, { shape: outputShape });
}
const s = this.computeSize();
s[0] = Math.max((_d = config.minWidth) !== null && _d !== void 0 ? _d : 1, s[0] * 1.5);
s[1] = Math.max((_e = config.minHeight) !== null && _e !== void 0 ? _e : 1, s[1]);
this.size = s;
this.serialize_widgets = true;
}
static registerForOverride(comfyClass, nodeData, rgthreeClass) {
if (OVERRIDDEN_SERVER_NODES.has(comfyClass)) {
throw Error(`Already have a class to override ${comfyClass.type || comfyClass.name || comfyClass.title}`);
}
OVERRIDDEN_SERVER_NODES.set(comfyClass, rgthreeClass);
if (!rgthreeClass.__registeredForOverride__) {
rgthreeClass.__registeredForOverride__ = true;
rgthreeClass.nodeType = comfyClass;
rgthreeClass.nodeData = nodeData;
rgthreeClass.onRegisteredForOverride(comfyClass, rgthreeClass);
}
}
static onRegisteredForOverride(comfyClass, rgthreeClass) {
}
}
RgthreeBaseServerNode.nodeType = null;
RgthreeBaseServerNode.nodeData = null;
RgthreeBaseServerNode.__registeredForOverride__ = false;
const OVERRIDDEN_SERVER_NODES = new Map();
const oldregisterNodeType = LiteGraph.registerNodeType;
LiteGraph.registerNodeType = async function (nodeId, baseClass) {
var _a;
const clazz = OVERRIDDEN_SERVER_NODES.get(baseClass) || baseClass;
if (clazz !== baseClass) {
const classLabel = clazz.type || clazz.name || clazz.title;
const [n, v] = rgthree.logger.logParts(LogLevel.DEBUG, `${nodeId}: replacing default ComfyNode implementation with custom ${classLabel} class.`);
(_a = console[n]) === null || _a === void 0 ? void 0 : _a.call(console, ...v);
}
return oldregisterNodeType.call(LiteGraph, nodeId, clazz);
};
@@ -0,0 +1,62 @@
import { SERVICE as CONFIG_SERVICE } from "./services/config_service.js";
export function addRgthree(str) {
return str + " (rgthree)";
}
export function stripRgthree(str) {
return str.replace(/\s*\(rgthree\)$/, "");
}
export const NodeTypesString = {
ANY_SWITCH: addRgthree("Any Switch"),
CONTEXT: addRgthree("Context"),
CONTEXT_BIG: addRgthree("Context Big"),
CONTEXT_SWITCH: addRgthree("Context Switch"),
CONTEXT_SWITCH_BIG: addRgthree("Context Switch Big"),
CONTEXT_MERGE: addRgthree("Context Merge"),
CONTEXT_MERGE_BIG: addRgthree("Context Merge Big"),
DYNAMIC_CONTEXT: addRgthree("Dynamic Context"),
DYNAMIC_CONTEXT_SWITCH: addRgthree("Dynamic Context Switch"),
DISPLAY_ANY: addRgthree("Display Any"),
IMAGE_OR_LATENT_SIZE: addRgthree("Image or Latent Size"),
NODE_MODE_RELAY: addRgthree("Mute / Bypass Relay"),
NODE_MODE_REPEATER: addRgthree("Mute / Bypass Repeater"),
FAST_MUTER: addRgthree("Fast Muter"),
FAST_BYPASSER: addRgthree("Fast Bypasser"),
FAST_GROUPS_MUTER: addRgthree("Fast Groups Muter"),
FAST_GROUPS_BYPASSER: addRgthree("Fast Groups Bypasser"),
FAST_ACTIONS_BUTTON: addRgthree("Fast Actions Button"),
LABEL: addRgthree("Label"),
POWER_PRIMITIVE: addRgthree("Power Primitive"),
POWER_PROMPT: addRgthree("Power Prompt"),
POWER_PROMPT_SIMPLE: addRgthree("Power Prompt - Simple"),
POWER_PUTER: addRgthree("Power Puter"),
POWER_CONDUCTOR: addRgthree("Power Conductor"),
SDXL_EMPTY_LATENT_IMAGE: addRgthree("SDXL Empty Latent Image"),
SDXL_POWER_PROMPT_POSITIVE: addRgthree("SDXL Power Prompt - Positive"),
SDXL_POWER_PROMPT_NEGATIVE: addRgthree("SDXL Power Prompt - Simple / Negative"),
POWER_LORA_LOADER: addRgthree("Power Lora Loader"),
KSAMPLER_CONFIG: addRgthree("KSampler Config"),
NODE_COLLECTOR: addRgthree("Node Collector"),
REROUTE: addRgthree("Reroute"),
RANDOM_UNMUTER: addRgthree("Random Unmuter"),
SEED: addRgthree("Seed"),
BOOKMARK: addRgthree("Bookmark"),
IMAGE_COMPARER: addRgthree("Image Comparer"),
IMAGE_INSET_CROP: addRgthree("Image Inset Crop"),
};
const UNRELEASED_KEYS = {
[NodeTypesString.DYNAMIC_CONTEXT]: "dynamic_context",
[NodeTypesString.DYNAMIC_CONTEXT_SWITCH]: "dynamic_context",
[NodeTypesString.POWER_CONDUCTOR]: "power_conductor",
};
export function getNodeTypeStrings() {
const unreleasedKeys = Object.keys(UNRELEASED_KEYS);
return Object.values(NodeTypesString)
.map((i) => stripRgthree(i))
.filter((i) => {
if (unreleasedKeys.includes(i)) {
return !!CONFIG_SERVICE.getConfigValue(`unreleased.${UNRELEASED_KEYS[i]}.enabled`);
}
return true;
})
.sort();
}
@@ -0,0 +1,365 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
import { RgthreeBaseServerNode } from "./base_node.js";
import { NodeTypesString } from "./constants.js";
import { addConnectionLayoutSupport } from "./utils.js";
import { RgthreeBaseWidget } from "./utils_widgets.js";
import { measureText } from "./utils_canvas.js";
function imageDataToUrl(data) {
return api.apiURL(`/view?filename=${encodeURIComponent(data.filename)}&type=${data.type}&subfolder=${data.subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`);
}
export class RgthreeImageComparer extends RgthreeBaseServerNode {
constructor(title = RgthreeImageComparer.title) {
super(title);
this.imageIndex = 0;
this.imgs = [];
this.serialize_widgets = true;
this.isPointerDown = false;
this.isPointerOver = false;
this.pointerOverPos = [0, 0];
this.canvasWidget = null;
this.properties["comparer_mode"] = "Slide";
}
onExecuted(output) {
var _a;
(_a = super.onExecuted) === null || _a === void 0 ? void 0 : _a.call(this, output);
if ("images" in output) {
this.canvasWidget.value = {
images: (output.images || []).map((d, i) => {
return {
name: i === 0 ? "A" : "B",
selected: true,
url: imageDataToUrl(d),
};
}),
};
}
else {
output.a_images = output.a_images || [];
output.b_images = output.b_images || [];
const imagesToChoose = [];
const multiple = output.a_images.length + output.b_images.length > 2;
for (const [i, d] of output.a_images.entries()) {
imagesToChoose.push({
name: output.a_images.length > 1 || multiple ? `A${i + 1}` : "A",
selected: i === 0,
url: imageDataToUrl(d),
});
}
for (const [i, d] of output.b_images.entries()) {
imagesToChoose.push({
name: output.b_images.length > 1 || multiple ? `B${i + 1}` : "B",
selected: i === 0,
url: imageDataToUrl(d),
});
}
this.canvasWidget.value = { images: imagesToChoose };
}
}
onSerialize(serialised) {
var _a;
super.onSerialize && super.onSerialize(serialised);
for (let [index, widget_value] of (serialised.widgets_values || []).entries()) {
if (((_a = this.widgets[index]) === null || _a === void 0 ? void 0 : _a.name) === "rgthree_comparer") {
serialised.widgets_values[index] = this.widgets[index].value.images.map((d) => {
d = { ...d };
delete d.img;
return d;
});
}
}
}
onNodeCreated() {
this.canvasWidget = this.addCustomWidget(new RgthreeImageComparerWidget("rgthree_comparer", this));
this.setSize(this.computeSize());
this.setDirtyCanvas(true, true);
}
setIsPointerDown(down = this.isPointerDown) {
const newIsDown = down && !!app.canvas.pointer_is_down;
if (this.isPointerDown !== newIsDown) {
this.isPointerDown = newIsDown;
this.setDirtyCanvas(true, false);
}
this.imageIndex = this.isPointerDown ? 1 : 0;
if (this.isPointerDown) {
requestAnimationFrame(() => {
this.setIsPointerDown();
});
}
}
onMouseDown(event, pos, canvas) {
var _a;
(_a = super.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(this, event, pos, canvas);
this.setIsPointerDown(true);
return false;
}
onMouseEnter(event) {
var _a;
(_a = super.onMouseEnter) === null || _a === void 0 ? void 0 : _a.call(this, event);
this.setIsPointerDown(!!app.canvas.pointer_is_down);
this.isPointerOver = true;
}
onMouseLeave(event) {
var _a;
(_a = super.onMouseLeave) === null || _a === void 0 ? void 0 : _a.call(this, event);
this.setIsPointerDown(false);
this.isPointerOver = false;
}
onMouseMove(event, pos, canvas) {
var _a;
(_a = super.onMouseMove) === null || _a === void 0 ? void 0 : _a.call(this, event, pos, canvas);
this.pointerOverPos = [...pos];
this.imageIndex = this.pointerOverPos[0] > this.size[0] / 2 ? 1 : 0;
}
getHelp() {
return `
<p>
The ${this.type.replace("(rgthree)", "")} node compares two images on top of each other.
</p>
<ul>
<li>
<p>
<strong>Notes</strong>
</p>
<ul>
<li><p>
The right-click menu may show image options (Open Image, Save Image, etc.) which will
correspond to the first image (image_a) if clicked on the left-half of the node, or
the second image if on the right half of the node.
</p></li>
</ul>
</li>
<li>
<p>
<strong>Inputs</strong>
</p>
<ul>
<li><p>
<code>image_a</code> <i>Optional.</i> The first image to use to compare.
image_a.
</p></li>
<li><p>
<code>image_b</code> <i>Optional.</i> The second image to use to compare.
</p></li>
<li><p>
<b>Note</b> <code>image_a</code> and <code>image_b</code> work best when a single
image is provided. However, if each/either are a batch, you can choose which item
from each batch are chosen to be compared. If either <code>image_a</code> or
<code>image_b</code> are not provided, the node will choose the first two from the
provided input if it's a batch, otherwise only show the single image (just as
Preview Image would).
</p></li>
</ul>
</li>
<li>
<p>
<strong>Properties.</strong> You can change the following properties (by right-clicking
on the node, and select "Properties" or "Properties Panel" from the menu):
</p>
<ul>
<li><p>
<code>comparer_mode</code> - Choose between "Slide" and "Click". Defaults to "Slide".
</p></li>
</ul>
</li>
</ul>`;
}
static setUp(comfyClass, nodeData) {
RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, RgthreeImageComparer);
}
static onRegisteredForOverride(comfyClass) {
addConnectionLayoutSupport(RgthreeImageComparer, app, [
["Left", "Right"],
["Right", "Left"],
]);
setTimeout(() => {
RgthreeImageComparer.category = comfyClass.category;
});
}
}
RgthreeImageComparer.title = NodeTypesString.IMAGE_COMPARER;
RgthreeImageComparer.type = NodeTypesString.IMAGE_COMPARER;
RgthreeImageComparer.comfyClass = NodeTypesString.IMAGE_COMPARER;
RgthreeImageComparer["@comparer_mode"] = {
type: "combo",
values: ["Slide", "Click"],
};
class RgthreeImageComparerWidget extends RgthreeBaseWidget {
constructor(name, node) {
super(name);
this.type = "custom";
this.hitAreas = {};
this.selected = [];
this._value = { images: [] };
this.node = node;
}
set value(v) {
let cleanedVal;
if (Array.isArray(v)) {
cleanedVal = v.map((d, i) => {
if (!d || typeof d === "string") {
d = { url: d, name: i == 0 ? "A" : "B", selected: true };
}
return d;
});
}
else {
cleanedVal = v.images || [];
}
if (cleanedVal.length > 2) {
const hasAAndB = cleanedVal.some((i) => i.name.startsWith("A")) &&
cleanedVal.some((i) => i.name.startsWith("B"));
if (!hasAAndB) {
cleanedVal = [cleanedVal[0], cleanedVal[1]];
}
}
let selected = cleanedVal.filter((d) => d.selected);
if (!selected.length && cleanedVal.length) {
cleanedVal[0].selected = true;
}
selected = cleanedVal.filter((d) => d.selected);
if (selected.length === 1 && cleanedVal.length > 1) {
cleanedVal.find((d) => !d.selected).selected = true;
}
this._value.images = cleanedVal;
selected = cleanedVal.filter((d) => d.selected);
this.setSelected(selected);
}
get value() {
return this._value;
}
setSelected(selected) {
this._value.images.forEach((d) => (d.selected = false));
this.node.imgs.length = 0;
for (const sel of selected) {
if (!sel.img) {
sel.img = new Image();
sel.img.src = sel.url;
this.node.imgs.push(sel.img);
}
sel.selected = true;
}
this.selected = selected;
}
draw(ctx, node, width, y) {
var _a;
this.hitAreas = {};
if (this.value.images.length > 2) {
ctx.textAlign = "left";
ctx.textBaseline = "top";
ctx.font = `14px Arial`;
const drawData = [];
const spacing = 5;
let x = 0;
for (const img of this.value.images) {
const width = measureText(ctx, img.name);
drawData.push({
img,
text: img.name,
x,
width: measureText(ctx, img.name),
});
x += width + spacing;
}
x = (node.size[0] - (x - spacing)) / 2;
for (const d of drawData) {
ctx.fillStyle = d.img.selected ? "rgba(180, 180, 180, 1)" : "rgba(180, 180, 180, 0.5)";
ctx.fillText(d.text, x, y);
this.hitAreas[d.text] = {
bounds: [x, y, d.width, 14],
data: d.img,
onDown: this.onSelectionDown,
};
x += d.width + spacing;
}
y += 20;
}
if (((_a = node.properties) === null || _a === void 0 ? void 0 : _a["comparer_mode"]) === "Click") {
this.drawImage(ctx, this.selected[this.node.isPointerDown ? 1 : 0], y);
}
else {
this.drawImage(ctx, this.selected[0], y);
if (node.isPointerOver) {
this.drawImage(ctx, this.selected[1], y, this.node.pointerOverPos[0]);
}
}
}
onSelectionDown(event, pos, node, bounds) {
const selected = [...this.selected];
if (bounds === null || bounds === void 0 ? void 0 : bounds.data.name.startsWith("A")) {
selected[0] = bounds.data;
}
else if (bounds === null || bounds === void 0 ? void 0 : bounds.data.name.startsWith("B")) {
selected[1] = bounds.data;
}
this.setSelected(selected);
}
drawImage(ctx, image, y, cropX) {
var _a, _b;
if (!((_a = image === null || image === void 0 ? void 0 : image.img) === null || _a === void 0 ? void 0 : _a.naturalWidth) || !((_b = image === null || image === void 0 ? void 0 : image.img) === null || _b === void 0 ? void 0 : _b.naturalHeight)) {
return;
}
let [nodeWidth, nodeHeight] = this.node.size;
const imageAspect = (image === null || image === void 0 ? void 0 : image.img.naturalWidth) / (image === null || image === void 0 ? void 0 : image.img.naturalHeight);
let height = nodeHeight - y;
const widgetAspect = nodeWidth / height;
let targetWidth, targetHeight;
let offsetX = 0;
if (imageAspect > widgetAspect) {
targetWidth = nodeWidth;
targetHeight = nodeWidth / imageAspect;
}
else {
targetHeight = height;
targetWidth = height * imageAspect;
offsetX = (nodeWidth - targetWidth) / 2;
}
const widthMultiplier = (image === null || image === void 0 ? void 0 : image.img.naturalWidth) / targetWidth;
const sourceX = 0;
const sourceY = 0;
const sourceWidth = cropX != null ? (cropX - offsetX) * widthMultiplier : image === null || image === void 0 ? void 0 : image.img.naturalWidth;
const sourceHeight = image === null || image === void 0 ? void 0 : image.img.naturalHeight;
const destX = (nodeWidth - targetWidth) / 2;
const destY = y + (height - targetHeight) / 2;
const destWidth = cropX != null ? cropX - offsetX : targetWidth;
const destHeight = targetHeight;
ctx.save();
ctx.beginPath();
let globalCompositeOperation = ctx.globalCompositeOperation;
if (cropX) {
ctx.rect(destX, destY, destWidth, destHeight);
ctx.clip();
}
ctx.drawImage(image === null || image === void 0 ? void 0 : image.img, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight);
if (cropX != null && cropX >= (nodeWidth - targetWidth) / 2 && cropX <= targetWidth + offsetX) {
ctx.beginPath();
ctx.moveTo(cropX, destY);
ctx.lineTo(cropX, destY + destHeight);
ctx.globalCompositeOperation = "difference";
ctx.strokeStyle = "rgba(255,255,255, 1)";
ctx.stroke();
}
ctx.globalCompositeOperation = globalCompositeOperation;
ctx.restore();
}
computeSize(width) {
return [width, 20];
}
serializeValue(node, index) {
const v = [];
for (const data of this._value.images) {
const d = { ...data };
delete d.img;
v.push(d);
}
return { images: v };
}
}
app.registerExtension({
name: "rgthree.ImageComparer",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData.name === RgthreeImageComparer.type) {
RgthreeImageComparer.setUp(nodeType, nodeData);
}
},
});
@@ -0,0 +1,723 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
import { getResolver, wait } from "../../rgthree/common/shared_utils.js";
import { RgthreeHelpDialog } from "../../rgthree/common/dialog.js";
const oldApiGetNodeDefs = api.getNodeDefs;
api.getNodeDefs = async function () {
const defs = await oldApiGetNodeDefs.call(api);
this.dispatchEvent(new CustomEvent("fresh-node-defs", { detail: defs }));
return defs;
};
export var IoDirection;
(function (IoDirection) {
IoDirection[IoDirection["INPUT"] = 0] = "INPUT";
IoDirection[IoDirection["OUTPUT"] = 1] = "OUTPUT";
})(IoDirection || (IoDirection = {}));
const PADDING = 0;
export const LAYOUT_LABEL_TO_DATA = {
Left: [LiteGraph.LEFT, [0, 0.5], [PADDING, 0]],
Right: [LiteGraph.RIGHT, [1, 0.5], [-PADDING, 0]],
Top: [LiteGraph.UP, [0.5, 0], [0, PADDING]],
Bottom: [LiteGraph.DOWN, [0.5, 1], [0, -PADDING]],
};
export const LAYOUT_LABEL_OPPOSITES = {
Left: "Right",
Right: "Left",
Top: "Bottom",
Bottom: "Top",
};
export const LAYOUT_CLOCKWISE = ["Top", "Right", "Bottom", "Left"];
export function addMenuItem(node, _app, config, after = "Shape") {
const oldGetExtraMenuOptions = node.prototype.getExtraMenuOptions;
node.prototype.getExtraMenuOptions = function (canvas, menuOptions) {
oldGetExtraMenuOptions && oldGetExtraMenuOptions.apply(this, [canvas, menuOptions]);
addMenuItemOnExtraMenuOptions(this, config, menuOptions, after);
};
}
let canvasResolver = null;
export function waitForCanvas() {
if (canvasResolver === null) {
canvasResolver = getResolver();
function _waitForCanvas() {
if (!canvasResolver.completed) {
if (app === null || app === void 0 ? void 0 : app.canvas) {
canvasResolver.resolve(app.canvas);
}
else {
requestAnimationFrame(_waitForCanvas);
}
}
}
_waitForCanvas();
}
return canvasResolver.promise;
}
let graphResolver = null;
export function waitForGraph() {
if (graphResolver === null) {
graphResolver = getResolver();
function _wait() {
if (!graphResolver.completed) {
if (app === null || app === void 0 ? void 0 : app.graph) {
graphResolver.resolve(app.graph);
}
else {
requestAnimationFrame(_wait);
}
}
}
_wait();
}
return graphResolver.promise;
}
export function addMenuItemOnExtraMenuOptions(node, config, menuOptions, after = "Shape") {
let idx = menuOptions
.slice()
.reverse()
.findIndex((option) => option === null || option === void 0 ? void 0 : option.isRgthree);
if (idx == -1) {
idx = menuOptions.findIndex((option) => { var _a; return (_a = option === null || option === void 0 ? void 0 : option.content) === null || _a === void 0 ? void 0 : _a.includes(after); }) + 1;
if (!idx) {
idx = menuOptions.length - 1;
}
menuOptions.splice(idx, 0, null);
idx++;
}
else {
idx = menuOptions.length - idx;
}
const subMenuOptions = typeof config.subMenuOptions === "function"
? config.subMenuOptions(node)
: config.subMenuOptions;
menuOptions.splice(idx, 0, {
content: typeof config.name == "function" ? config.name(node) : config.name,
has_submenu: !!(subMenuOptions === null || subMenuOptions === void 0 ? void 0 : subMenuOptions.length),
isRgthree: true,
callback: (value, _options, event, parentMenu, _node) => {
if (!!(subMenuOptions === null || subMenuOptions === void 0 ? void 0 : subMenuOptions.length)) {
new LiteGraph.ContextMenu(subMenuOptions.map((option) => (option ? { content: option } : null)), {
event,
parentMenu,
callback: (subValue, _options, _event, _parentMenu, _node) => {
if (config.property) {
node.properties = node.properties || {};
node.properties[config.property] = config.prepareValue
? config.prepareValue(subValue.content || "", node)
: subValue.content || "";
}
config.callback && config.callback(node, subValue === null || subValue === void 0 ? void 0 : subValue.content);
},
});
return;
}
if (config.property) {
node.properties = node.properties || {};
node.properties[config.property] = config.prepareValue
? config.prepareValue(node.properties[config.property], node)
: !node.properties[config.property];
}
config.callback && config.callback(node, value === null || value === void 0 ? void 0 : value.content);
},
});
}
export function addConnectionLayoutSupport(node, app, options = [
["Left", "Right"],
["Right", "Left"],
], callback) {
addMenuItem(node, app, {
name: "Connections Layout",
property: "connections_layout",
subMenuOptions: options.map((option) => option[0] + (option[1] ? " -> " + option[1] : "")),
prepareValue: (value, node) => {
var _a;
const values = String(value).split(" -> ");
if (!values[1] && !((_a = node.outputs) === null || _a === void 0 ? void 0 : _a.length)) {
values[1] = LAYOUT_LABEL_OPPOSITES[values[0]];
}
if (!LAYOUT_LABEL_TO_DATA[values[0]] || !LAYOUT_LABEL_TO_DATA[values[1]]) {
throw new Error(`New Layout invalid: [${values[0]}, ${values[1]}]`);
}
return values;
},
callback: (node) => {
var _a;
callback && callback(node);
(_a = node.graph) === null || _a === void 0 ? void 0 : _a.setDirtyCanvas(true, true);
},
});
node.prototype.getConnectionPos = function (isInput, slotNumber, out) {
return getConnectionPosForLayout(this, isInput, slotNumber, out);
};
node.prototype.getInputPos = function (slotNumber) {
return getConnectionPosForLayout(this, true, slotNumber, [0, 0]);
};
node.prototype.getOutputPos = function (slotNumber) {
return getConnectionPosForLayout(this, false, slotNumber, [0, 0]);
};
}
export function setConnectionsLayout(node, newLayout) {
var _a;
newLayout = newLayout || node.defaultConnectionsLayout || ["Left", "Right"];
if (!newLayout[1] && !((_a = node.outputs) === null || _a === void 0 ? void 0 : _a.length)) {
newLayout[1] = LAYOUT_LABEL_OPPOSITES[newLayout[0]];
}
if (!LAYOUT_LABEL_TO_DATA[newLayout[0]] || !LAYOUT_LABEL_TO_DATA[newLayout[1]]) {
throw new Error(`New Layout invalid: [${newLayout[0]}, ${newLayout[1]}]`);
}
node.properties = node.properties || {};
node.properties["connections_layout"] = newLayout;
}
export function setConnectionsCollapse(node, collapseConnections = null) {
node.properties = node.properties || {};
collapseConnections =
collapseConnections !== null ? collapseConnections : !node.properties["collapse_connections"];
node.properties["collapse_connections"] = collapseConnections;
}
export function getConnectionPosForLayout(node, isInput, slotNumber, out) {
var _a, _b, _c;
out = out || new Float32Array(2);
node.properties = node.properties || {};
const layout = node.properties["connections_layout"] ||
node.defaultConnectionsLayout || ["Left", "Right"];
const collapseConnections = node.properties["collapse_connections"] || false;
const offset = (_a = node.constructor.layout_slot_offset) !== null && _a !== void 0 ? _a : LiteGraph.NODE_SLOT_HEIGHT * 0.5;
let side = isInput ? layout[0] : layout[1];
const otherSide = isInput ? layout[1] : layout[0];
let data = LAYOUT_LABEL_TO_DATA[side];
const slotList = node[isInput ? "inputs" : "outputs"];
const cxn = slotList[slotNumber];
if (!cxn) {
console.log("No connection found.. weird", isInput, slotNumber);
return out;
}
if (cxn.disabled) {
if (cxn.color_on !== "#666665") {
cxn._color_on_org = cxn._color_on_org || cxn.color_on;
cxn._color_off_org = cxn._color_off_org || cxn.color_off;
}
cxn.color_on = "#666665";
cxn.color_off = "#666665";
}
else if (cxn.color_on === "#666665") {
cxn.color_on = cxn._color_on_org || undefined;
cxn.color_off = cxn._color_off_org || undefined;
}
const displaySlot = collapseConnections
? 0
: slotNumber -
slotList.reduce((count, ioput, index) => {
count += index < slotNumber && ioput.hidden ? 1 : 0;
return count;
}, 0);
cxn.dir = data[0];
const connections_dir = node.properties["connections_dir"];
if ((node.size[0] == 10 || node.size[1] == 10) && connections_dir) {
cxn.dir = connections_dir[isInput ? 0 : 1];
}
if (side === "Left") {
if (node.flags.collapsed) {
var w = node._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH;
out[0] = node.pos[0];
out[1] = node.pos[1] - LiteGraph.NODE_TITLE_HEIGHT * 0.5;
}
else {
toggleConnectionLabel(cxn, !isInput || collapseConnections || !!node.hideSlotLabels);
out[0] = node.pos[0] + offset;
if ((_b = node.constructor) === null || _b === void 0 ? void 0 : _b.type.includes("Reroute")) {
out[1] = node.pos[1] + node.size[1] * 0.5;
}
else {
out[1] =
node.pos[1] +
(displaySlot + 0.7) * LiteGraph.NODE_SLOT_HEIGHT +
(node.constructor.slot_start_y || 0);
}
}
}
else if (side === "Right") {
if (node.flags.collapsed) {
var w = node._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH;
out[0] = node.pos[0] + w;
out[1] = node.pos[1] - LiteGraph.NODE_TITLE_HEIGHT * 0.5;
}
else {
toggleConnectionLabel(cxn, isInput || collapseConnections || !!node.hideSlotLabels);
out[0] = node.pos[0] + node.size[0] + 1 - offset;
if ((_c = node.constructor) === null || _c === void 0 ? void 0 : _c.type.includes("Reroute")) {
out[1] = node.pos[1] + node.size[1] * 0.5;
}
else {
out[1] =
node.pos[1] +
(displaySlot + 0.7) * LiteGraph.NODE_SLOT_HEIGHT +
(node.constructor.slot_start_y || 0);
}
}
}
else if (side === "Top") {
if (!cxn.has_old_label) {
cxn.has_old_label = true;
cxn.old_label = cxn.label;
cxn.label = " ";
}
out[0] = node.pos[0] + node.size[0] * 0.5;
out[1] = node.pos[1] + offset;
}
else if (side === "Bottom") {
if (!cxn.has_old_label) {
cxn.has_old_label = true;
cxn.old_label = cxn.label;
cxn.label = " ";
}
out[0] = node.pos[0] + node.size[0] * 0.5;
out[1] = node.pos[1] + node.size[1] - offset;
}
return out;
}
function toggleConnectionLabel(cxn, hide = true) {
if (hide) {
if (!cxn.has_old_label) {
cxn.has_old_label = true;
cxn.old_label = cxn.label;
}
cxn.label = " ";
}
else if (!hide && cxn.has_old_label) {
cxn.has_old_label = false;
cxn.label = cxn.old_label;
cxn.old_label = undefined;
}
return cxn;
}
export function addHelpMenuItem(node, content, menuOptions) {
addMenuItemOnExtraMenuOptions(node, {
name: "🛟 Node Help",
callback: (node) => {
if (node.showHelp) {
node.showHelp();
}
else {
new RgthreeHelpDialog(node, content).show();
}
},
}, menuOptions, "Properties Panel");
}
export var PassThroughFollowing;
(function (PassThroughFollowing) {
PassThroughFollowing[PassThroughFollowing["ALL"] = 0] = "ALL";
PassThroughFollowing[PassThroughFollowing["NONE"] = 1] = "NONE";
PassThroughFollowing[PassThroughFollowing["REROUTE_ONLY"] = 2] = "REROUTE_ONLY";
})(PassThroughFollowing || (PassThroughFollowing = {}));
export function shouldPassThrough(node, passThroughFollowing = PassThroughFollowing.ALL) {
var _a;
const type = (_a = node === null || node === void 0 ? void 0 : node.constructor) === null || _a === void 0 ? void 0 : _a.type;
if (!type || passThroughFollowing === PassThroughFollowing.NONE) {
return false;
}
if (passThroughFollowing === PassThroughFollowing.REROUTE_ONLY) {
return type.includes("Reroute");
}
return (type.includes("Reroute") || type.includes("Node Combiner") || type.includes("Node Collector"));
}
function filterOutPassthroughNodes(infos, passThroughFollowing = PassThroughFollowing.ALL) {
return infos.filter((i) => !shouldPassThrough(i.node, passThroughFollowing));
}
export function getConnectedInputNodes(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) {
return getConnectedNodesInfo(startNode, IoDirection.INPUT, currentNode, slot, passThroughFollowing).map((n) => n.node);
}
export function getConnectedInputInfosAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) {
return filterOutPassthroughNodes(getConnectedNodesInfo(startNode, IoDirection.INPUT, currentNode, slot, passThroughFollowing), passThroughFollowing);
}
export function getConnectedInputNodesAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) {
return getConnectedInputInfosAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing).map((n) => n.node);
}
export function getConnectedOutputNodes(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) {
return getConnectedNodesInfo(startNode, IoDirection.OUTPUT, currentNode, slot, passThroughFollowing).map((n) => n.node);
}
export function getConnectedOutputNodesAndFilterPassThroughs(startNode, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL) {
return filterOutPassthroughNodes(getConnectedNodesInfo(startNode, IoDirection.OUTPUT, currentNode, slot, passThroughFollowing), passThroughFollowing).map((n) => n.node);
}
export function getConnectedNodesInfo(startNode, dir = IoDirection.INPUT, currentNode, slot, passThroughFollowing = PassThroughFollowing.ALL, originTravelFromSlot) {
var _a, _b, _c, _d, _e, _f, _g, _h;
currentNode = currentNode || startNode;
let rootNodes = [];
if (startNode === currentNode || shouldPassThrough(currentNode, passThroughFollowing)) {
let linkIds;
slot = slot != null && slot > -1 ? slot : undefined;
if (dir == IoDirection.OUTPUT) {
if (slot != null) {
linkIds = [...(((_b = (_a = currentNode.outputs) === null || _a === void 0 ? void 0 : _a[slot]) === null || _b === void 0 ? void 0 : _b.links) || [])];
}
else {
linkIds = ((_c = currentNode.outputs) === null || _c === void 0 ? void 0 : _c.flatMap((i) => i.links)) || [];
}
}
else {
if (slot != null) {
linkIds = [(_e = (_d = currentNode.inputs) === null || _d === void 0 ? void 0 : _d[slot]) === null || _e === void 0 ? void 0 : _e.link];
}
else {
linkIds = ((_f = currentNode.inputs) === null || _f === void 0 ? void 0 : _f.map((i) => i.link)) || [];
}
}
const graph = (_g = currentNode.graph) !== null && _g !== void 0 ? _g : app.graph;
for (const linkId of linkIds) {
let link = null;
if (typeof linkId == "number") {
link = (_h = graph.links[linkId]) !== null && _h !== void 0 ? _h : null;
}
if (!link) {
continue;
}
const travelFromSlot = dir == IoDirection.OUTPUT ? link.origin_slot : link.target_slot;
const connectedId = dir == IoDirection.OUTPUT ? link.target_id : link.origin_id;
const travelToSlot = dir == IoDirection.OUTPUT ? link.target_slot : link.origin_slot;
originTravelFromSlot = originTravelFromSlot != null ? originTravelFromSlot : travelFromSlot;
const originNode = graph.getNodeById(connectedId);
if (!link) {
console.error("No connected node found... weird");
continue;
}
if (rootNodes.some((n) => n.node == originNode)) {
console.log(`${startNode.title} (${startNode.id}) seems to have two links to ${originNode.title} (${originNode.id}). One may be stale: ${linkIds.join(", ")}`);
}
else {
rootNodes.push({ node: originNode, travelFromSlot, travelToSlot, originTravelFromSlot });
if (shouldPassThrough(originNode, passThroughFollowing)) {
for (const foundNode of getConnectedNodesInfo(startNode, dir, originNode, undefined, undefined, originTravelFromSlot)) {
if (!rootNodes.map((n) => n.node).includes(foundNode.node)) {
rootNodes.push(foundNode);
}
}
}
}
}
}
return rootNodes;
}
export function followConnectionUntilType(node, dir, slotNum, skipSelf = false) {
const slots = dir === IoDirection.OUTPUT ? node.outputs : node.inputs;
if (!slots || !slots.length) {
return null;
}
let type = null;
if (slotNum) {
if (!slots[slotNum]) {
return null;
}
type = getTypeFromSlot(slots[slotNum], dir, skipSelf);
}
else {
for (const slot of slots) {
type = getTypeFromSlot(slot, dir, skipSelf);
if (type) {
break;
}
}
}
return type;
}
function getTypeFromSlot(slot, dir, skipSelf = false) {
let graph = app.canvas.getCurrentGraph();
let type = slot === null || slot === void 0 ? void 0 : slot.type;
if (!skipSelf && type != null && type != "*") {
return { type: type, label: slot === null || slot === void 0 ? void 0 : slot.label, name: slot === null || slot === void 0 ? void 0 : slot.name };
}
const links = getSlotLinks(slot);
for (const link of links) {
const connectedId = dir == IoDirection.OUTPUT ? link.link.target_id : link.link.origin_id;
const connectedSlotNum = dir == IoDirection.OUTPUT ? link.link.target_slot : link.link.origin_slot;
const connectedNode = graph.getNodeById(connectedId);
const connectedSlots = dir === IoDirection.OUTPUT ? connectedNode.inputs : connectedNode.outputs;
let connectedSlot = connectedSlots[connectedSlotNum];
if ((connectedSlot === null || connectedSlot === void 0 ? void 0 : connectedSlot.type) != null && (connectedSlot === null || connectedSlot === void 0 ? void 0 : connectedSlot.type) != "*") {
return {
type: connectedSlot.type,
label: connectedSlot === null || connectedSlot === void 0 ? void 0 : connectedSlot.label,
name: connectedSlot === null || connectedSlot === void 0 ? void 0 : connectedSlot.name,
};
}
else if ((connectedSlot === null || connectedSlot === void 0 ? void 0 : connectedSlot.type) == "*") {
return followConnectionUntilType(connectedNode, dir);
}
}
return null;
}
export async function replaceNode(existingNode, typeOrNewNode, inputNameMap) {
const existingCtor = existingNode.constructor;
const newNode = typeof typeOrNewNode === "string" ? LiteGraph.createNode(typeOrNewNode) : typeOrNewNode;
if (existingNode.title != existingCtor.title) {
newNode.title = existingNode.title;
}
newNode.pos = [...existingNode.pos];
newNode.properties = { ...existingNode.properties };
const oldComputeSize = [...existingNode.computeSize()];
const oldSize = [
existingNode.size[0] === oldComputeSize[0] ? null : existingNode.size[0],
existingNode.size[1] === oldComputeSize[1] ? null : existingNode.size[1],
];
let setSizeIters = 0;
const setSizeFn = () => {
const newComputesize = newNode.computeSize();
newNode.size[0] = Math.max(oldSize[0] || 0, newComputesize[0]);
newNode.size[1] = Math.max(oldSize[1] || 0, newComputesize[1]);
setSizeIters++;
if (setSizeIters > 10) {
requestAnimationFrame(setSizeFn);
}
};
setSizeFn();
const links = [];
const graph = existingNode.graph || app.graph;
for (const [index, output] of existingNode.outputs.entries()) {
for (const linkId of output.links || []) {
const link = graph.links[linkId];
if (!link)
continue;
const targetNode = graph.getNodeById(link.target_id);
links.push({ node: newNode, slot: output.name, targetNode, targetSlot: link.target_slot });
}
}
for (const [index, input] of existingNode.inputs.entries()) {
const linkId = input.link;
if (linkId) {
const link = graph.links[linkId];
const originNode = graph.getNodeById(link.origin_id);
links.push({
node: originNode,
slot: link.origin_slot,
targetNode: newNode,
targetSlot: (inputNameMap === null || inputNameMap === void 0 ? void 0 : inputNameMap.has(input.name))
? inputNameMap.get(input.name)
: input.name || index,
});
}
}
graph.add(newNode);
await wait();
for (const link of links) {
link.node.connect(link.slot, link.targetNode, link.targetSlot);
}
await wait();
graph.remove(existingNode);
newNode.size = newNode.computeSize();
newNode.setDirtyCanvas(true, true);
return newNode;
}
export function getOriginNodeByLink(linkId) {
let node = null;
if (linkId != null) {
const link = getLinkById(linkId);
node = (link != null && getNodeById(link.origin_id)) || null;
}
return node;
}
export function getLinkById(linkId) {
var _a, _b, _c;
if (linkId == null)
return null;
let link = (_a = app.graph.links[linkId]) !== null && _a !== void 0 ? _a : null;
link = (_c = link !== null && link !== void 0 ? link : (_b = app.canvas.getCurrentGraph()) === null || _b === void 0 ? void 0 : _b.links[linkId]) !== null && _c !== void 0 ? _c : null;
return link || findSomethingInAllSubgraphs((subgraph) => { var _a; return (_a = subgraph === null || subgraph === void 0 ? void 0 : subgraph.links[linkId]) !== null && _a !== void 0 ? _a : null; });
}
export function getNodeById(id) {
var _a, _b;
if (id == null)
return null;
let node = app.graph.getNodeById(id);
node = (_b = node !== null && node !== void 0 ? node : (_a = app.canvas.getCurrentGraph()) === null || _a === void 0 ? void 0 : _a.getNodeById(id)) !== null && _b !== void 0 ? _b : null;
return node || findSomethingInAllSubgraphs((subgraph) => { var _a; return (_a = subgraph === null || subgraph === void 0 ? void 0 : subgraph.getNodeById(id)) !== null && _a !== void 0 ? _a : null; });
}
export function findFromNodeForSubgraph(subgraphId) {
var _a;
const node = (_a = findSomethingInAllSubgraphs((subgraph) => subgraph.nodes
.filter((node) => node.isSubgraphNode())
.find((node) => node.subgraph.id === subgraphId))) !== null && _a !== void 0 ? _a : null;
return node;
}
function findSomethingInAllSubgraphs(fn) {
var _a, _b;
const rootGraph = (_a = app.rootGraph) !== null && _a !== void 0 ? _a : app.graph.rootGraph;
const subgraphs = [rootGraph, ...(_b = rootGraph.subgraphs) === null || _b === void 0 ? void 0 : _b.values()];
for (const subgraph of subgraphs) {
const thing = fn(subgraph);
if (thing)
return thing;
}
return null;
}
export function applyMixins(original, constructors) {
constructors.forEach((baseCtor) => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
Object.defineProperty(original.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
});
});
}
export function getSlotLinks(inputOrOutput) {
var _a;
const links = [];
if (!inputOrOutput) {
return links;
}
if ((_a = inputOrOutput.links) === null || _a === void 0 ? void 0 : _a.length) {
const output = inputOrOutput;
for (const linkId of output.links || []) {
const link = app.graph.links[linkId];
if (link) {
links.push({ id: linkId, link: link });
}
}
}
if (inputOrOutput.link) {
const input = inputOrOutput;
const link = app.graph.links[input.link];
if (link) {
links.push({ id: input.link, link: link });
}
}
return links;
}
export async function matchLocalSlotsToServer(node, direction, serverNodeData) {
var _a, _b, _c;
const serverSlotNames = direction == IoDirection.INPUT
? Object.keys(((_a = serverNodeData.input) === null || _a === void 0 ? void 0 : _a.optional) || {})
: serverNodeData.output_name;
const serverSlotTypes = direction == IoDirection.INPUT
? Object.values(((_b = serverNodeData.input) === null || _b === void 0 ? void 0 : _b.optional) || {}).map((i) => i[0])
: serverNodeData.output;
const slots = direction == IoDirection.INPUT ? node.inputs : node.outputs;
let firstIndex = slots.findIndex((o, i) => i !== serverSlotNames.indexOf(o.name));
if (firstIndex > -1) {
const links = {};
slots.map((slot) => {
var _a;
links[slot.name] = links[slot.name] || [];
(_a = links[slot.name]) === null || _a === void 0 ? void 0 : _a.push(...getSlotLinks(slot));
});
for (const [index, serverSlotName] of serverSlotNames.entries()) {
const currentNodeSlot = slots.map((s) => s.name).indexOf(serverSlotName);
if (currentNodeSlot > -1) {
if (currentNodeSlot != index) {
const splicedItem = slots.splice(currentNodeSlot, 1)[0];
slots.splice(index, 0, splicedItem);
}
}
else if (currentNodeSlot === -1) {
const splicedItem = {
name: serverSlotName,
type: serverSlotTypes[index],
links: [],
};
slots.splice(index, 0, splicedItem);
}
}
if (slots.length > serverSlotNames.length) {
for (let i = slots.length - 1; i > serverSlotNames.length - 1; i--) {
if (direction == IoDirection.INPUT) {
node.disconnectInput(i);
node.removeInput(i);
}
else {
node.disconnectOutput(i);
node.removeOutput(i);
}
}
}
for (const [name, slotLinks] of Object.entries(links)) {
let currentNodeSlot = slots.map((s) => s.name).indexOf(name);
if (currentNodeSlot > -1) {
for (const linkData of slotLinks) {
if (direction == IoDirection.INPUT) {
linkData.link.target_slot = currentNodeSlot;
}
else {
linkData.link.origin_slot = currentNodeSlot;
const nextNode = app.graph.getNodeById(linkData.link.target_id);
if (nextNode && ((_c = nextNode.constructor) === null || _c === void 0 ? void 0 : _c.type.includes("Reroute"))) {
nextNode.stabilize && nextNode.stabilize();
}
}
}
}
}
}
}
export function isValidConnection(ioA, ioB) {
if (!ioA || !ioB) {
return false;
}
const typeA = String(ioA.type);
const typeB = String(ioB.type);
let isValid = LiteGraph.isValidConnection(typeA, typeB);
if (!isValid) {
let areCombos = (typeA.includes(",") && typeB === "COMBO") || (typeA === "COMBO" && typeB.includes(","));
if (areCombos) {
const nameA = ioA.name.toUpperCase().replace("_NAME", "").replace("CKPT", "MODEL");
const nameB = ioB.name.toUpperCase().replace("_NAME", "").replace("CKPT", "MODEL");
isValid = nameA.includes(nameB) || nameB.includes(nameA);
}
}
return isValid;
}
const oldIsValidConnection = LiteGraph.isValidConnection;
LiteGraph.isValidConnection = function (typeA, typeB) {
let isValid = oldIsValidConnection.call(LiteGraph, typeA, typeB);
if (!isValid) {
typeA = String(typeA);
typeB = String(typeB);
let areCombos = (typeA.includes(",") && typeB === "COMBO") || (typeA === "COMBO" && typeB.includes(","));
isValid = areCombos;
}
return isValid;
};
export function getOutputNodes(nodes) {
return ((nodes === null || nodes === void 0 ? void 0 : nodes.filter((n) => {
var _a;
return (n.mode != LiteGraph.NEVER && ((_a = n.constructor.nodeData) === null || _a === void 0 ? void 0 : _a.output_node));
})) || []);
}
export function changeModeOfNodes(nodeOrNodes, mode) {
reduceNodesDepthFirst(nodeOrNodes, (n) => {
n.mode = mode;
});
}
export function reduceNodesDepthFirst(nodeOrNodes, reduceFn, reduceTo) {
var _a;
const nodes = Array.isArray(nodeOrNodes) ? nodeOrNodes : [nodeOrNodes];
const stack = nodes.map((node) => ({ node }));
while (stack.length > 0) {
const { node } = stack.pop();
const result = reduceFn(node, reduceTo);
if (result !== undefined && result !== reduceTo) {
reduceTo = result;
}
if (((_a = node.isSubgraphNode) === null || _a === void 0 ? void 0 : _a.call(node)) && node.subgraph) {
const children = node.subgraph.nodes;
for (let i = children.length - 1; i >= 0; i--) {
stack.push({ node: children[i] });
}
}
}
return reduceTo;
}
export function getGroupNodes(group) {
return Array.from(group._children).filter((c) => c instanceof LGraphNode);
}
export function getGraphDependantNodeKey(node) {
var _a;
const graph = (_a = node.graph) !== null && _a !== void 0 ? _a : app.graph;
return `${graph.id}:${node.id}`;
}
export function getFullColor(color, liteGraphKey = "color") {
if (!color) {
return "";
}
if (LGraphCanvas.node_colors[color]) {
color = LGraphCanvas.node_colors[color][liteGraphKey];
}
color = color.replace("#", "").toLocaleLowerCase();
if (color.length === 3) {
color = color.replace(/(.)(.)(.)/, "$1$1$2$2$3$3");
}
return `#${color}`;
}
@@ -0,0 +1,225 @@
import { app } from "../../scripts/app.js";
function binarySearch(max, getValue, match) {
let min = 0;
while (min <= max) {
let guess = Math.floor((min + max) / 2);
const compareVal = getValue(guess);
if (compareVal === match)
return guess;
if (compareVal < match)
min = guess + 1;
else
max = guess - 1;
}
return max;
}
export function fitString(ctx, str, maxWidth) {
let width = ctx.measureText(str).width;
const ellipsis = "…";
const ellipsisWidth = measureText(ctx, ellipsis);
if (width <= maxWidth || width <= ellipsisWidth) {
return str;
}
const index = binarySearch(str.length, (guess) => measureText(ctx, str.substring(0, guess)), maxWidth - ellipsisWidth);
return str.substring(0, index) + ellipsis;
}
export function measureText(ctx, str) {
return ctx.measureText(str).width;
}
export function isLowQuality() {
var _a;
const canvas = app.canvas;
return (((_a = canvas.ds) === null || _a === void 0 ? void 0 : _a.scale) || 1) <= 0.5;
}
export function drawNodeWidget(ctx, options) {
const lowQuality = isLowQuality();
const data = {
width: options.size[0],
height: options.size[1],
posY: options.pos[1],
lowQuality,
margin: 15,
colorOutline: LiteGraph.WIDGET_OUTLINE_COLOR,
colorBackground: LiteGraph.WIDGET_BGCOLOR,
colorText: LiteGraph.WIDGET_TEXT_COLOR,
colorTextSecondary: LiteGraph.WIDGET_SECONDARY_TEXT_COLOR,
};
ctx.strokeStyle = options.colorStroke || data.colorOutline;
ctx.fillStyle = options.colorBackground || data.colorBackground;
ctx.beginPath();
ctx.roundRect(data.margin, data.posY, data.width - data.margin * 2, data.height, lowQuality ? [0] : options.borderRadius ? [options.borderRadius] : [options.size[1] * 0.5]);
ctx.fill();
if (!lowQuality) {
ctx.stroke();
}
return data;
}
export function drawRoundedRectangle(ctx, options) {
const lowQuality = isLowQuality();
options = { ...options };
ctx.save();
ctx.strokeStyle = options.colorStroke || LiteGraph.WIDGET_OUTLINE_COLOR;
ctx.fillStyle = options.colorBackground || LiteGraph.WIDGET_BGCOLOR;
ctx.beginPath();
ctx.roundRect(...options.pos, ...options.size, lowQuality ? [0] : options.borderRadius ? [options.borderRadius] : [options.size[1] * 0.5]);
ctx.fill();
!lowQuality && ctx.stroke();
ctx.restore();
}
export function drawNumberWidgetPart(ctx, options) {
const arrowWidth = 9;
const arrowHeight = 10;
const innerMargin = 3;
const numberWidth = 32;
const xBoundsArrowLess = [0, 0];
const xBoundsNumber = [0, 0];
const xBoundsArrowMore = [0, 0];
ctx.save();
let posX = options.posX;
const { posY, height, value, textColor } = options;
const midY = posY + height / 2;
if (options.direction === -1) {
posX = posX - arrowWidth - innerMargin - numberWidth - innerMargin - arrowWidth;
}
ctx.fill(new Path2D(`M ${posX} ${midY} l ${arrowWidth} ${arrowHeight / 2} l 0 -${arrowHeight} L ${posX} ${midY} z`));
xBoundsArrowLess[0] = posX;
xBoundsArrowLess[1] = arrowWidth;
posX += arrowWidth + innerMargin;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
const oldTextcolor = ctx.fillStyle;
if (textColor) {
ctx.fillStyle = textColor;
}
ctx.fillText(fitString(ctx, value.toFixed(2), numberWidth), posX + numberWidth / 2, midY);
ctx.fillStyle = oldTextcolor;
xBoundsNumber[0] = posX;
xBoundsNumber[1] = numberWidth;
posX += numberWidth + innerMargin;
ctx.fill(new Path2D(`M ${posX} ${midY - arrowHeight / 2} l ${arrowWidth} ${arrowHeight / 2} l -${arrowWidth} ${arrowHeight / 2} v -${arrowHeight} z`));
xBoundsArrowMore[0] = posX;
xBoundsArrowMore[1] = arrowWidth;
ctx.restore();
return [xBoundsArrowLess, xBoundsNumber, xBoundsArrowMore];
}
drawNumberWidgetPart.WIDTH_TOTAL = 9 + 3 + 32 + 3 + 9;
export function drawTogglePart(ctx, options) {
const lowQuality = isLowQuality();
ctx.save();
const { posX, posY, height, value } = options;
const toggleRadius = height * 0.36;
const toggleBgWidth = height * 1.5;
if (!lowQuality) {
ctx.beginPath();
ctx.roundRect(posX + 4, posY + 4, toggleBgWidth - 8, height - 8, [height * 0.5]);
ctx.globalAlpha = app.canvas.editor_alpha * 0.25;
ctx.fillStyle = "rgba(255,255,255,0.45)";
ctx.fill();
ctx.globalAlpha = app.canvas.editor_alpha;
}
ctx.fillStyle = value === true ? "#89B" : "#888";
const toggleX = lowQuality || value === false
? posX + height * 0.5
: value === true
? posX + height
: posX + height * 0.75;
ctx.beginPath();
ctx.arc(toggleX, posY + height * 0.5, toggleRadius, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
return [posX, toggleBgWidth];
}
export function drawInfoIcon(ctx, x, y, size = 12) {
ctx.save();
ctx.beginPath();
ctx.roundRect(x, y, size, size, [size * 0.1]);
ctx.fillStyle = "#2f82ec";
ctx.strokeStyle = "#0f2a5e";
ctx.fill();
ctx.strokeStyle = "#FFF";
ctx.lineWidth = 2;
const midX = x + size / 2;
const serifSize = size * 0.175;
ctx.stroke(new Path2D(`
M ${midX} ${y + size * 0.15}
v 2
M ${midX - serifSize} ${y + size * 0.45}
h ${serifSize}
v ${size * 0.325}
h ${serifSize}
h -${serifSize * 2}
`));
ctx.restore();
}
export function drawPlusIcon(ctx, x, midY, size = 12) {
ctx.save();
const s = size / 3;
const plus = new Path2D(`
M ${x} ${midY + s / 2}
v-${s} h${s} v-${s} h${s}
v${s} h${s} v${s} h-${s}
v${s} h-${s} v-${s} h-${s}
z
`);
ctx.lineJoin = "round";
ctx.lineCap = "round";
ctx.fillStyle = "#3a3";
ctx.strokeStyle = "#383";
ctx.fill(plus);
ctx.stroke(plus);
ctx.restore();
}
export function drawWidgetButton(ctx, options, text = null, isMouseDownedAndOver = false) {
var _a;
const borderRadius = isLowQuality() ? 0 : ((_a = options.borderRadius) !== null && _a !== void 0 ? _a : 4);
ctx.save();
if (!isLowQuality() && !isMouseDownedAndOver) {
drawRoundedRectangle(ctx, {
size: [options.size[0] - 2, options.size[1]],
pos: [options.pos[0] + 1, options.pos[1] + 1],
borderRadius,
colorBackground: "#000000aa",
colorStroke: "#000000aa",
});
}
drawRoundedRectangle(ctx, {
size: options.size,
pos: [options.pos[0], options.pos[1] + (isMouseDownedAndOver ? 1 : 0)],
borderRadius,
colorBackground: isMouseDownedAndOver ? "#444" : LiteGraph.WIDGET_BGCOLOR,
colorStroke: "transparent",
});
if (isLowQuality()) {
ctx.restore();
return;
}
if (!isMouseDownedAndOver) {
drawRoundedRectangle(ctx, {
size: [options.size[0] - 0.75, options.size[1] - 0.75],
pos: options.pos,
borderRadius: borderRadius - 0.5,
colorBackground: "transparent",
colorStroke: "#00000044",
});
drawRoundedRectangle(ctx, {
size: [options.size[0] - 0.75, options.size[1] - 0.75],
pos: [options.pos[0] + 0.75, options.pos[1] + 0.75],
borderRadius: borderRadius - 0.5,
colorBackground: "transparent",
colorStroke: "#ffffff11",
});
}
drawRoundedRectangle(ctx, {
size: options.size,
pos: [options.pos[0], options.pos[1] + (isMouseDownedAndOver ? 1 : 0)],
borderRadius,
colorBackground: "transparent",
});
if (!isLowQuality() && text) {
ctx.textBaseline = "middle";
ctx.textAlign = "center";
ctx.fillStyle = LiteGraph.WIDGET_TEXT_COLOR;
ctx.fillText(text, options.size[0] / 2, options.pos[1] + options.size[1] / 2 + (isMouseDownedAndOver ? 1 : 0));
}
ctx.restore();
}
@@ -0,0 +1,291 @@
import { app } from "../../scripts/app.js";
import { drawNodeWidget, drawWidgetButton, fitString, isLowQuality } from "./utils_canvas.js";
export function drawLabelAndValue(ctx, label, value, width, posY, height, options) {
var _a;
const outerMargin = 15;
const innerMargin = 10;
const midY = posY + height / 2;
ctx.save();
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = LiteGraph.WIDGET_SECONDARY_TEXT_COLOR;
const labelX = outerMargin + innerMargin + ((_a = options === null || options === void 0 ? void 0 : options.offsetLeft) !== null && _a !== void 0 ? _a : 0);
ctx.fillText(label, labelX, midY);
const valueXLeft = labelX + ctx.measureText(label).width + 7;
const valueXRight = width - (outerMargin + innerMargin);
ctx.fillStyle = LiteGraph.WIDGET_TEXT_COLOR;
ctx.textAlign = "right";
ctx.fillText(fitString(ctx, value, valueXRight - valueXLeft), valueXRight, midY);
ctx.restore();
}
export class RgthreeBaseWidget {
constructor(name) {
this.type = "custom";
this.options = {};
this.y = 0;
this.last_y = 0;
this.mouseDowned = null;
this.isMouseDownedAndOver = false;
this.hitAreas = {};
this.downedHitAreasForMove = [];
this.downedHitAreasForClick = [];
this.name = name;
}
serializeValue(node, index) {
return this.value;
}
clickWasWithinBounds(pos, bounds) {
let xStart = bounds[0];
let xEnd = xStart + (bounds.length > 2 ? bounds[2] : bounds[1]);
const clickedX = pos[0] >= xStart && pos[0] <= xEnd;
if (bounds.length === 2) {
return clickedX;
}
return clickedX && pos[1] >= bounds[1] && pos[1] <= bounds[1] + bounds[3];
}
mouse(event, pos, node) {
var _a, _b, _c;
const canvas = app.canvas;
if (event.type == "pointerdown") {
this.mouseDowned = [...pos];
this.isMouseDownedAndOver = true;
this.downedHitAreasForMove.length = 0;
this.downedHitAreasForClick.length = 0;
let anyHandled = false;
for (const part of Object.values(this.hitAreas)) {
if (this.clickWasWithinBounds(pos, part.bounds)) {
if (part.onMove) {
this.downedHitAreasForMove.push(part);
}
if (part.onClick) {
this.downedHitAreasForClick.push(part);
}
if (part.onDown) {
const thisHandled = part.onDown.apply(this, [event, pos, node, part]);
anyHandled = anyHandled || thisHandled == true;
}
part.wasMouseClickedAndIsOver = true;
}
}
return (_a = this.onMouseDown(event, pos, node)) !== null && _a !== void 0 ? _a : anyHandled;
}
if (event.type == "pointerup") {
if (!this.mouseDowned)
return true;
this.downedHitAreasForMove.length = 0;
const wasMouseDownedAndOver = this.isMouseDownedAndOver;
this.cancelMouseDown();
let anyHandled = false;
for (const part of Object.values(this.hitAreas)) {
if (part.onUp && this.clickWasWithinBounds(pos, part.bounds)) {
const thisHandled = part.onUp.apply(this, [event, pos, node, part]);
anyHandled = anyHandled || thisHandled == true;
}
part.wasMouseClickedAndIsOver = false;
}
for (const part of this.downedHitAreasForClick) {
if (this.clickWasWithinBounds(pos, part.bounds)) {
const thisHandled = part.onClick.apply(this, [event, pos, node, part]);
anyHandled = anyHandled || thisHandled == true;
}
}
this.downedHitAreasForClick.length = 0;
if (wasMouseDownedAndOver) {
const thisHandled = this.onMouseClick(event, pos, node);
anyHandled = anyHandled || thisHandled == true;
}
return (_b = this.onMouseUp(event, pos, node)) !== null && _b !== void 0 ? _b : anyHandled;
}
if (event.type == "pointermove") {
this.isMouseDownedAndOver = !!this.mouseDowned;
if (this.mouseDowned &&
(pos[0] < 15 ||
pos[0] > node.size[0] - 15 ||
pos[1] < this.last_y ||
pos[1] > this.last_y + LiteGraph.NODE_WIDGET_HEIGHT)) {
this.isMouseDownedAndOver = false;
}
for (const part of Object.values(this.hitAreas)) {
if (this.downedHitAreasForMove.includes(part)) {
part.onMove.apply(this, [event, pos, node, part]);
}
if (this.downedHitAreasForClick.includes(part)) {
part.wasMouseClickedAndIsOver = this.clickWasWithinBounds(pos, part.bounds);
}
}
return (_c = this.onMouseMove(event, pos, node)) !== null && _c !== void 0 ? _c : true;
}
return false;
}
cancelMouseDown() {
this.mouseDowned = null;
this.isMouseDownedAndOver = false;
this.downedHitAreasForMove.length = 0;
}
onMouseDown(event, pos, node) {
return;
}
onMouseUp(event, pos, node) {
return;
}
onMouseClick(event, pos, node) {
return;
}
onMouseMove(event, pos, node) {
return;
}
}
export class RgthreeBetterButtonWidget extends RgthreeBaseWidget {
constructor(name, mouseClickCallback, label) {
super(name);
this.type = "custom";
this.value = "";
this.label = "";
this.mouseClickCallback = mouseClickCallback;
this.label = label || name;
}
draw(ctx, node, width, y, height) {
drawWidgetButton(ctx, { size: [width - 30, height], pos: [15, y] }, this.label, this.isMouseDownedAndOver);
}
onMouseClick(event, pos, node) {
return this.mouseClickCallback(event, pos, node);
}
}
export class RgthreeBetterTextWidget extends RgthreeBaseWidget {
constructor(name, value) {
super(name);
this.name = name;
this.value = value;
}
draw(ctx, node, width, y, height) {
const widgetData = drawNodeWidget(ctx, { size: [width, height], pos: [15, y] });
if (!widgetData.lowQuality) {
drawLabelAndValue(ctx, this.name, this.value, width, y, height);
}
}
mouse(event, pos, node) {
const canvas = app.canvas;
if (event.type == "pointerdown") {
canvas.prompt("Label", this.value, (v) => (this.value = v), event);
return true;
}
return false;
}
}
export class RgthreeDividerWidget extends RgthreeBaseWidget {
constructor(widgetOptions) {
super("divider");
this.value = {};
this.options = { serialize: false };
this.type = "custom";
this.widgetOptions = {
marginTop: 7,
marginBottom: 7,
marginLeft: 15,
marginRight: 15,
color: LiteGraph.WIDGET_OUTLINE_COLOR,
thickness: 1,
};
Object.assign(this.widgetOptions, widgetOptions || {});
}
draw(ctx, node, width, posY, h) {
if (this.widgetOptions.thickness) {
ctx.strokeStyle = this.widgetOptions.color;
const x = this.widgetOptions.marginLeft;
const y = posY + this.widgetOptions.marginTop;
const w = width - this.widgetOptions.marginLeft - this.widgetOptions.marginRight;
ctx.stroke(new Path2D(`M ${x} ${y} h ${w}`));
}
}
computeSize(width) {
return [
width,
this.widgetOptions.marginTop + this.widgetOptions.marginBottom + this.widgetOptions.thickness,
];
}
}
export class RgthreeLabelWidget extends RgthreeBaseWidget {
constructor(name, widgetOptions) {
super(name);
this.type = "custom";
this.options = { serialize: false };
this.value = "";
this.widgetOptions = {};
this.posY = 0;
Object.assign(this.widgetOptions, widgetOptions);
}
update(widgetOptions) {
Object.assign(this.widgetOptions, widgetOptions);
}
draw(ctx, node, width, posY, height) {
var _a;
this.posY = posY;
ctx.save();
let text = (_a = this.widgetOptions.text) !== null && _a !== void 0 ? _a : this.name;
if (typeof text === "function") {
text = text();
}
ctx.textAlign = this.widgetOptions.align || "left";
ctx.fillStyle = this.widgetOptions.color || LiteGraph.WIDGET_TEXT_COLOR;
const oldFont = ctx.font;
if (this.widgetOptions.italic) {
ctx.font = "italic " + ctx.font;
}
if (this.widgetOptions.size) {
ctx.font = ctx.font.replace(/\d+px/, `${this.widgetOptions.size}px`);
}
const midY = posY + height / 2;
ctx.textBaseline = "middle";
if (this.widgetOptions.align === "center") {
ctx.fillText(text, node.size[0] / 2, midY);
}
else {
ctx.fillText(text, 15, midY);
}
ctx.font = oldFont;
if (this.widgetOptions.actionLabel === "__PLUS_ICON__") {
const plus = new Path2D(`M${node.size[0] - 15 - 2} ${posY + 7} v4 h-4 v4 h-4 v-4 h-4 v-4 h4 v-4 h4 v4 h4 z`);
ctx.lineJoin = "round";
ctx.lineCap = "round";
ctx.fillStyle = "#3a3";
ctx.strokeStyle = "#383";
ctx.fill(plus);
ctx.stroke(plus);
}
ctx.restore();
}
mouse(event, nodePos, node) {
if (event.type !== "pointerdown" ||
isLowQuality() ||
!this.widgetOptions.actionLabel ||
!this.widgetOptions.actionCallback) {
return false;
}
const pos = [nodePos[0], nodePos[1] - this.posY];
const rightX = node.size[0] - 15;
if (pos[0] > rightX || pos[0] < rightX - 16) {
return false;
}
this.widgetOptions.actionCallback(event);
return true;
}
}
export class RgthreeInvisibleWidget extends RgthreeBaseWidget {
constructor(name, type, value, serializeValueFn) {
super(name);
this.type = "custom";
this.value = value;
this.serializeValueFn = serializeValueFn;
}
draw() {
return;
}
computeSize(width) {
return [0, 0];
}
serializeValue(node, index) {
return this.serializeValueFn != null
? this.serializeValueFn(node, index)
: super.serializeValue(node, index);
}
}
@@ -0,0 +1,131 @@
class RgthreeApi {
constructor(baseUrl) {
this.getCheckpointsPromise = null;
this.getSamplersPromise = null;
this.getSchedulersPromise = null;
this.getLorasPromise = null;
this.getWorkflowsPromise = null;
this.setBaseUrl(baseUrl);
}
setBaseUrl(baseUrlArg) {
var _a;
let baseUrl = null;
if (baseUrlArg) {
baseUrl = baseUrlArg;
}
else if (window.location.pathname.includes("/rgthree/")) {
const parts = (_a = window.location.pathname.split("/rgthree/")[1]) === null || _a === void 0 ? void 0 : _a.split("/");
if (parts && parts.length) {
baseUrl = parts.map(() => "../").join("") + "rgthree/api";
}
}
this.baseUrl = baseUrl || "./rgthree/api";
const comfyBasePathname = location.pathname.includes("/rgthree/")
? location.pathname.split("rgthree/")[0]
: location.pathname;
this.comfyBaseUrl = comfyBasePathname.split("/").slice(0, -1).join("/");
}
apiURL(route) {
return `${this.baseUrl}${route}`;
}
fetchApi(route, options) {
return fetch(this.apiURL(route), options);
}
async fetchJson(route, options) {
const r = await this.fetchApi(route, options);
return await r.json();
}
async postJson(route, json) {
const body = new FormData();
body.append("json", JSON.stringify(json));
return await rgthreeApi.fetchJson(route, { method: "POST", body });
}
getLoras(force = false) {
if (!this.getLorasPromise || force) {
this.getLorasPromise = this.fetchJson("/loras?format=details", { cache: "no-store" });
}
return this.getLorasPromise;
}
async fetchApiJsonOrNull(route, options) {
const response = await this.fetchJson(route, options);
if (response.status === 200 && response.data) {
return response.data || null;
}
return null;
}
async getModelsInfo(options) {
var _a;
const params = new URLSearchParams();
if ((_a = options.files) === null || _a === void 0 ? void 0 : _a.length) {
params.set("files", options.files.join(","));
}
if (options.light) {
params.set("light", "1");
}
if (options.format) {
params.set("format", options.format);
}
const path = `/${options.type}/info?` + params.toString();
return (await this.fetchApiJsonOrNull(path)) || [];
}
async getLorasInfo(options = {}) {
return this.getModelsInfo({ type: "loras", ...options });
}
async getCheckpointsInfo(options = {}) {
return this.getModelsInfo({ type: "checkpoints", ...options });
}
async refreshModelsInfo(options) {
var _a;
const params = new URLSearchParams();
if ((_a = options.files) === null || _a === void 0 ? void 0 : _a.length) {
params.set("files", options.files.join(","));
}
const path = `/${options.type}/info/refresh?` + params.toString();
const infos = await this.fetchApiJsonOrNull(path);
return infos;
}
async refreshLorasInfo(options = {}) {
return this.refreshModelsInfo({ type: "loras", ...options });
}
async refreshCheckpointsInfo(options = {}) {
return this.refreshModelsInfo({ type: "checkpoints", ...options });
}
async clearModelsInfo(options) {
var _a;
const params = new URLSearchParams();
if ((_a = options.files) === null || _a === void 0 ? void 0 : _a.length) {
params.set("files", options.files.join(","));
}
const path = `/${options.type}/info/clear?` + params.toString();
await this.fetchApiJsonOrNull(path);
return;
}
async clearLorasInfo(options = {}) {
return this.clearModelsInfo({ type: "loras", ...options });
}
async clearCheckpointsInfo(options = {}) {
return this.clearModelsInfo({ type: "checkpoints", ...options });
}
async saveModelInfo(type, file, data) {
const body = new FormData();
body.append("json", JSON.stringify(data));
return await this.fetchApiJsonOrNull(`/${type}/info?file=${encodeURIComponent(file)}`, { cache: "no-store", method: "POST", body });
}
async saveLoraInfo(file, data) {
return this.saveModelInfo("loras", file, data);
}
async saveCheckpointsInfo(file, data) {
return this.saveModelInfo("checkpoints", file, data);
}
fetchComfyApi(route, options) {
const url = this.comfyBaseUrl + "/api" + route;
options = options || {};
options.headers = options.headers || {};
options.cache = options.cache || "no-cache";
return fetch(url, options);
}
print(messageType) {
this.fetchApi(`/print?type=${messageType}`, {});
}
}
export const rgthreeApi = new RgthreeApi();
@@ -0,0 +1,684 @@
{
"sources": [
{
"id": "lora",
"repo": "Comfy-Org/ComfyUI",
"file": "nodes.py",
"local_file": "lora__nodes.py",
"commit": "3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f",
"tree": "7b8cbb865be9b72a3a8ef838595d34dfaa90e82a",
"tag": "v0.15.1",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f/nodes.py",
"sha256": "548098f3a94e7a7cf69979b8450c382921fd9b5577d250d16b4ceaaca0fff879",
"git_blob_sha1": "bff073e3030487592d8cb6af4c69f8ddb97aefe5",
"acquisition_time": "2026-10-30T22:44:42.999488+00:00",
"license_file": "lora__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "lora",
"repo": "Comfy-Org/ComfyUI",
"file": "folder_paths.py",
"local_file": "lora__folder_paths.py",
"commit": "3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f",
"tree": "7b8cbb865be9b72a3a8ef838595d34dfaa90e82a",
"tag": "v0.15.1",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f/folder_paths.py",
"sha256": "da62dbe3cc99c8d2bce4dd1df01c5a0ca149f9ed8522cc477e661629052ce112",
"git_blob_sha1": "9c96540e3dd90626e9a6d4c1e3e00b80fffb2df8",
"acquisition_time": "2026-10-30T22:44:43.002065+00:00",
"license_file": "lora__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "lora",
"repo": "Comfy-Org/ComfyUI",
"file": "LICENSE",
"local_file": "lora__LICENSE",
"commit": "3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f",
"tree": "7b8cbb865be9b72a3a8ef838595d34dfaa90e82a",
"tag": "v0.15.1",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/3dd10a59c00248d00f0cb0ab794ff1bb9fb00a5f/LICENSE",
"sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986",
"git_blob_sha1": "f288702d2fa16d3cdf0035b15a9fcbc552cd88e7",
"acquisition_time": "2026-10-30T22:44:43.005035+00:00",
"license_file": "lora__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "package.json",
"local_file": "frontend__package.json",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/package.json",
"sha256": "5124264c12991b7613b2a3ffb598bdbd04ec669c1c30accb4ac16552e9011735",
"git_blob_sha1": "98a05e96ddc377ee4eff504b8e742faa81eff582",
"acquisition_time": "2026-10-30T22:44:46.471149+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "pnpm-lock.yaml",
"local_file": "frontend__pnpm-lock.yaml",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/pnpm-lock.yaml",
"sha256": "06ec7aebc1b407a477b41ee41065250bd67d0af2e7ddb04ad07e71e85edaf61e",
"git_blob_sha1": "1539fc2dc93e49cbb242bff938740a9c8b36125d",
"acquisition_time": "2026-10-30T22:44:46.476323+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "src/scripts/widgets.ts",
"local_file": "frontend__src__scripts__widgets.ts",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/src/scripts/widgets.ts",
"sha256": "a538a4d4dd033b4b336abc6ac68b19eb31dee600294f9eba8e57e0802322fafd",
"git_blob_sha1": "071ebff3ee4a41d4ef719f60603b9e0bca7353d7",
"acquisition_time": "2026-10-30T22:44:46.478876+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "src/scripts/app.ts",
"local_file": "frontend__src__scripts__app.ts",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/src/scripts/app.ts",
"sha256": "770e060d982f4af221aef0c4204fe631ed2aa4b7cda3f05f06fef954c79b4c81",
"git_blob_sha1": "b38b7ac5344a178dc49fa4766f98b6814f6aef85",
"acquisition_time": "2026-10-30T22:44:46.480558+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "src/extensions/core/uploadImage.ts",
"local_file": "frontend__src__extensions__core__uploadImage.ts",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/src/extensions/core/uploadImage.ts",
"sha256": "935687284bebc3bbb49616976ccaf83c31998dd7abba231e5c8eaab0e8aa9e04",
"git_blob_sha1": "4cb910dae13d47bbaacc9733dc7bf0d38b9ae095",
"acquisition_time": "2026-10-30T22:44:46.482577+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "src/lib/litegraph/src/LGraphNode.ts",
"local_file": "frontend__src__lib__litegraph__src__LGraphNode.ts",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/src/lib/litegraph/src/LGraphNode.ts",
"sha256": "24e48e7d8886a968cd825042bd4d5eb075bc24731dcca266ebb8f8ef1a75f033",
"git_blob_sha1": "baf6a4419022cbc6a9ae9f8bb964d3acde173d43",
"acquisition_time": "2026-10-30T22:44:46.487512+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "src/lib/litegraph/LICENSE",
"local_file": "frontend__src__lib__litegraph__LICENSE",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/src/lib/litegraph/LICENSE",
"sha256": "1b38cc30fe774bcc77538ab99eb460f4e1c8a47c4fddc6e991ee3b5cc2a96bb9",
"git_blob_sha1": "1b52aa11c186c25f8d66f1de74c0d378851bfcff",
"acquisition_time": "2026-10-30T22:44:46.489837+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "frontend",
"repo": "Comfy-Org/ComfyUI_frontend",
"file": "LICENSE",
"local_file": "frontend__LICENSE",
"commit": "d873c8048fe765ba08f758bbd9891788facceed5",
"tree": "62e9ed6b9d4daf1afc6ce16c909cecfa0ab14526",
"tag": "v1.40.0",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/d873c8048fe765ba08f758bbd9891788facceed5/LICENSE",
"sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986",
"git_blob_sha1": "f288702d2fa16d3cdf0035b15a9fcbc552cd88e7",
"acquisition_time": "2026-10-30T22:44:46.491087+00:00",
"license_file": "frontend__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图准确声明版本;目标安装与UE恢复未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "nodes.py",
"local_file": "../flux2-img-reference/core__nodes.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/nodes.py",
"sha256": "dd4b10eebd746da29178e0f8f75781f98edbf1f0620eb42afe2d03156a6c7c33",
"git_blob_sha1": "56b74ebe31303dd420542d8096abf7e1c1226bfb",
"acquisition_time": "2026-10-30T21:08:28.247217+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "folder_paths.py",
"local_file": "../flux2-img-reference/core__folder_paths.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/folder_paths.py",
"sha256": "da62dbe3cc99c8d2bce4dd1df01c5a0ca149f9ed8522cc477e661629052ce112",
"git_blob_sha1": "9c96540e3dd90626e9a6d4c1e3e00b80fffb2df8",
"acquisition_time": "2026-10-30T21:08:28.248691+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_extras/nodes_custom_sampler.py",
"local_file": "../flux2-img-reference/core__comfy_extras__nodes_custom_sampler.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_extras/nodes_custom_sampler.py",
"sha256": "8e8c3763a618fa9058f2333dcc09be3b60889362875b8c6377aee23f9ea1abd2",
"git_blob_sha1": "f19adf4b9eb52de4105188de1c457e5d796ca4aa",
"acquisition_time": "2026-10-30T21:08:28.250324+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_extras/nodes_flux.py",
"local_file": "../flux2-img-reference/core__comfy_extras__nodes_flux.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_extras/nodes_flux.py",
"sha256": "a10f6890f81589e43f5384fc9d5e4e68e3d53b900abce84cb07740376e0135c6",
"git_blob_sha1": "12c8ed3e6492162ade6c32822c6fde4e5fd69aea",
"acquisition_time": "2026-10-30T21:08:28.251736+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_extras/nodes_primitive.py",
"local_file": "../flux2-img-reference/core__comfy_extras__nodes_primitive.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_extras/nodes_primitive.py",
"sha256": "e3916389cbf848f73fd79f67feca97f3e666a2c541409bba2aef4500b6f7393b",
"git_blob_sha1": "937321800249090e3949b4cadcab17864f858d01",
"acquisition_time": "2026-10-30T21:08:28.252762+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy/samplers.py",
"local_file": "../flux2-img-reference/core__comfy__samplers.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy/samplers.py",
"sha256": "a7b0dec5aea19214cc640dd725d927ac8246377885d46c956a5c0d9fe79b1a47",
"git_blob_sha1": "1989ef107adca2e5c560caa623ce746afe27d312",
"acquisition_time": "2026-10-30T21:08:28.254065+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy/sample.py",
"local_file": "../flux2-img-reference/core__comfy__sample.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy/sample.py",
"sha256": "794be52ca4ad9be470aedfc79a595492f8116c2666101cf48c108a09cdc6dac6",
"git_blob_sha1": "2f8f3a51c5fc30e804e643c75a1b267fb0a94697",
"acquisition_time": "2026-10-30T21:08:28.255055+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy/sd.py",
"local_file": "../flux2-img-reference/core__comfy__sd.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy/sd.py",
"sha256": "e20431cac19074ff6ab931d4076aa867b2be1419c6a3be42b0700002f8184727",
"git_blob_sha1": "5a7221620290bec7841cbbad990ae7f5d2adf83e",
"acquisition_time": "2026-10-30T21:08:28.256755+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "LICENSE",
"local_file": "../flux2-img-reference/core__LICENSE",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/LICENSE",
"sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986",
"git_blob_sha1": "f288702d2fa16d3cdf0035b15a9fcbc552cd88e7",
"acquisition_time": "2026-10-30T21:08:28.258556+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_api/latest/_io.py",
"local_file": "../flux2-img-reference/core__comfy_api__latest___io.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_api/latest/_io.py",
"sha256": "41ebad9670bf980b7f85527a4839e3a15b18094583746515ea2d516d3946a1e5",
"git_blob_sha1": "764fa8b2b4dabddf313bf0821bb2d9e436d3b8b4",
"acquisition_time": "2026-10-30T21:08:55.269845+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_api/latest/_io_public.py",
"local_file": "../flux2-img-reference/core__comfy_api__latest___io_public.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_api/latest/_io_public.py",
"sha256": "c805d754d61aba1ea72ed2d9d5c371de35be9affa5305d35426fb298fcb7c046",
"git_blob_sha1": "43c7680f3283cec64bf89023ca7ec90314a3499d",
"acquisition_time": "2026-10-30T21:08:55.272201+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy/cli_args.py",
"local_file": "../flux2-img-reference/core__comfy__cli_args.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy/cli_args.py",
"sha256": "b08dd1d029b3b7d64efee2c3125e7046ed5f07840200fffef4d564c600615e34",
"git_blob_sha1": "dae9a895de8a8449910133e481a657c0645479f1",
"acquisition_time": "2026-10-30T21:08:55.274830+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "latent_preview.py",
"local_file": "../flux2-img-reference/core__latent_preview.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/latent_preview.py",
"sha256": "c59708b07494615d2f7640d528df17f9281f4d77affe638b2e0efb9a49fa3cee",
"git_blob_sha1": "d52e3f7a1fd03a343161ba4d62580a357b486ade",
"acquisition_time": "2026-10-30T21:08:55.277141+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_extras/nodes_edit_model.py",
"local_file": "../flux2-img-reference/core__comfy_extras__nodes_edit_model.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_extras/nodes_edit_model.py",
"sha256": "e8d03a4ca5f7b8025f565d0fa7b4f0119693f2f35837db2a4114361537f78da3",
"git_blob_sha1": "36da66f34e1d19e54ed2ffc8338a232bf8879945",
"acquisition_time": "2026-10-30T21:20:30.726665+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "node_helpers.py",
"local_file": "../flux2-img-reference/core__node_helpers.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/node_helpers.py",
"sha256": "5ee43a50f57b84c64781f1bcfeb717d17ee2d07038d5d7d75eb788898fb72de0",
"git_blob_sha1": "4ff960ef8afeadd935b6e48a9a683b7ef6970b2f",
"acquisition_time": "2026-10-30T21:20:31.119372+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy/utils.py",
"local_file": "../flux2-img-reference/core__comfy__utils.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy/utils.py",
"sha256": "dfd937c200548753a053befe53357c32deafb2384c9895bdde96b01a1d9ee4d6",
"git_blob_sha1": "ffa98c9b1b8149917238ef0431c8e77211de669c",
"acquisition_time": "2026-10-30T21:20:31.545290+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_extras/nodes_images.py",
"local_file": "core__comfy_extras__nodes_images.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_extras/nodes_images.py",
"sha256": "695f34b53f21ff714629bdcc3811a231de96458644be297fc1c506f2001c2bd3",
"git_blob_sha1": "ce21caade8cf9e1783507bafe5b3626566400c1d",
"acquisition_time": "2026-10-30T21:08:28.247217+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "core",
"repo": "Comfy-Org/ComfyUI",
"file": "comfy_extras/nodes_post_processing.py",
"local_file": "core__comfy_extras__nodes_post_processing.py",
"commit": "2e9d51680a90bca9cc375ba7767f7bf3ed27d563",
"tree": "618eabb5ce059e55ba51a90a4f0a7dbd297c5cec",
"tag": "v0.8.2",
"url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/2e9d51680a90bca9cc375ba7767f7bf3ed27d563/comfy_extras/nodes_post_processing.py",
"sha256": "082571da46d01e5d7f260ab43a4fe0944a8d2446511986810ac7295775acb48f",
"git_blob_sha1": "01afa13a18eefe313f9517be4d1f6e0e035d610c",
"acquisition_time": "2026-10-30T21:08:28.247217+00:00",
"license_file": "core__LICENSE",
"transport": "git exact tag text; no execution",
"applicability": "本图独立comfy-core0.8.2声明;同字节重新绑定;目标安装未知"
},
{
"id": "rgthree",
"file": "__init__.py",
"local_file": "rgthree____init__.py",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "06174f22e7246b2b0771961cc0681846f452b853ccb927ca507e074f340abc61",
"member_crc32": 2275993398,
"acquisition_time": "2026-10-30T22:45:38.643981+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "py/image_comparer.py",
"local_file": "rgthree__py__image_comparer.py",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "43ccce9b6f9413d5196ce4a7a3ef544969ae1ce2b52c44345f6cc8fb28c596fc",
"member_crc32": 526403025,
"acquisition_time": "2026-10-30T22:45:39.269299+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "py/constants.py",
"local_file": "rgthree__py__constants.py",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "50dee946013b1d88d01fe9d63c2a7ab4d4c59be218cf80171f3542b43f0d8558",
"member_crc32": 3439315536,
"acquisition_time": "2026-10-30T22:45:39.940025+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/comfyui/image_comparer.js",
"local_file": "rgthree__web__comfyui__image_comparer.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "b6dd39b71a2722774ecad101e12823220c6905f9f2a3d1cefca077e1aaa08a49",
"member_crc32": 914019580,
"acquisition_time": "2026-10-30T22:45:40.557472+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/comfyui/base_node.js",
"local_file": "rgthree__web__comfyui__base_node.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "c3ff5ba72f284f8e894dd464b2936f01369838291fb817cc4e304df576a1eba6",
"member_crc32": 1635828396,
"acquisition_time": "2026-10-30T22:45:41.210813+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/comfyui/constants.js",
"local_file": "rgthree__web__comfyui__constants.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "01bddadcbeb27f4f3519987fb1e3f8fbed5b8c5e0bff1180e0f6cf3348c89ad9",
"member_crc32": 4186641302,
"acquisition_time": "2026-10-30T22:45:41.857505+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/comfyui/utils_widgets.js",
"local_file": "rgthree__web__comfyui__utils_widgets.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "d0fa8e5bcda2aa9b9e14369338ab383469a072e7d6b8495d1a665fa7e6824ed4",
"member_crc32": 1773374183,
"acquisition_time": "2026-10-30T22:45:42.491497+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/comfyui/utils.js",
"local_file": "rgthree__web__comfyui__utils.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "ff0c44fa93852147b73721baf556da2b17a39dddbc9e518b1723d7634d944ecb",
"member_crc32": 891119965,
"acquisition_time": "2026-10-30T22:45:43.121147+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/comfyui/utils_canvas.js",
"local_file": "rgthree__web__comfyui__utils_canvas.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "1a7f6e50fd9a1d04e436356c5e7481c585800dfb5a9ada8fe19b28e2db4fca59",
"member_crc32": 4213873831,
"acquisition_time": "2026-10-30T22:45:43.800847+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "web/common/rgthree_api.js",
"local_file": "rgthree__web__common__rgthree_api.js",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "59bab54e22af1d3e85dd6a9c0779238fba881e24d544b5eede943d620d213151",
"member_crc32": 202904653,
"acquisition_time": "2026-10-30T22:45:44.436451+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "LICENSE",
"local_file": "rgthree__LICENSE",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "b34faf7c3e2975fe08d0169958e2b39f076d4d4289cbe2560dd7dd5b1a613ed1",
"member_crc32": 2654743090,
"acquisition_time": "2026-10-30T22:45:45.110693+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
},
{
"id": "rgthree",
"file": "pyproject.toml",
"local_file": "rgthree__pyproject.toml",
"url": "https://cdn.comfy.org/rgthree/rgthree-comfy/1.0.2512112053/node.zip",
"commit": "rgthree-comfy@1.0.2512112053;Git绑定未知",
"tag": "1.0.2512112053",
"tree": "发布包中央目录;Git tree未知",
"repo": "rgthree-comfy",
"git_commit_binding": "unknown",
"package_sha256": "unknown: Range仅必要文本,未获取完整包",
"sha256": "e5f8e5ffc7be3d760d7e6d6d5866d3e2ff8f82ada9137ee9f055cffa9a2ce45f",
"member_crc32": 509273976,
"acquisition_time": "2026-10-30T22:45:45.763914+00:00",
"license_file": "rgthree__LICENSE",
"transport": "HTTP206 Range selected text ZIP members; CRC checked by zipfile",
"applicability": "本图准确cnr_id/ver;不证明目标安装或Label身份"
}
]
}