HEL-892: record case04 fixed sources and saved-state validation
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,150 @@
|
||||
# Internal infrastructure for ComfyAPI
|
||||
from .api_registry import (
|
||||
ComfyAPIBase as ComfyAPIBase,
|
||||
ComfyAPIWithVersion as ComfyAPIWithVersion,
|
||||
register_versions as register_versions,
|
||||
get_all_versions as get_all_versions,
|
||||
)
|
||||
|
||||
import asyncio
|
||||
from dataclasses import asdict
|
||||
from typing import Callable, Optional
|
||||
|
||||
|
||||
def first_real_override(cls: type, name: str, *, base: type=None) -> Optional[Callable]:
|
||||
"""Return the *callable* override of `name` visible on `cls`, or None if every
|
||||
implementation up to (and including) `base` is the placeholder defined on `base`.
|
||||
|
||||
If base is not provided, it will assume cls has a GET_BASE_CLASS
|
||||
"""
|
||||
if base is None:
|
||||
if not hasattr(cls, "GET_BASE_CLASS"):
|
||||
raise ValueError("base is required if cls does not have a GET_BASE_CLASS; is this a valid ComfyNode subclass?")
|
||||
base = cls.GET_BASE_CLASS()
|
||||
base_attr = getattr(base, name, None)
|
||||
if base_attr is None:
|
||||
return None
|
||||
base_func = base_attr.__func__
|
||||
for c in cls.mro(): # NodeB, NodeA, ComfyNode, object …
|
||||
if c is base: # reached the placeholder – we're done
|
||||
break
|
||||
if name in c.__dict__: # first class that *defines* the attr
|
||||
func = getattr(c, name).__func__
|
||||
if func is not base_func: # real override
|
||||
return getattr(cls, name) # bound to *cls*
|
||||
return None
|
||||
|
||||
|
||||
class _ComfyNodeInternal:
|
||||
"""Class that all V3-based APIs inherit from for ComfyNode.
|
||||
|
||||
This is intended to only be referenced within execution.py, as it has to handle all V3 APIs going forward."""
|
||||
@classmethod
|
||||
def GET_NODE_INFO_V1(cls):
|
||||
...
|
||||
|
||||
|
||||
class _NodeOutputInternal:
|
||||
"""Class that all V3-based APIs inherit from for NodeOutput.
|
||||
|
||||
This is intended to only be referenced within execution.py, as it has to handle all V3 APIs going forward."""
|
||||
...
|
||||
|
||||
|
||||
def as_pruned_dict(dataclass_obj):
|
||||
'''Return dict of dataclass object with pruned None values.'''
|
||||
return prune_dict(asdict(dataclass_obj))
|
||||
|
||||
def prune_dict(d: dict):
|
||||
return {k: v for k,v in d.items() if v is not None}
|
||||
|
||||
|
||||
def is_class(obj):
|
||||
'''
|
||||
Returns True if is a class type.
|
||||
Returns False if is a class instance.
|
||||
'''
|
||||
return isinstance(obj, type)
|
||||
|
||||
|
||||
def copy_class(cls: type) -> type:
|
||||
'''
|
||||
Copy a class and its attributes.
|
||||
'''
|
||||
if cls is None:
|
||||
return None
|
||||
cls_dict = {
|
||||
k: v for k, v in cls.__dict__.items()
|
||||
if k not in ('__dict__', '__weakref__', '__module__', '__doc__')
|
||||
}
|
||||
# new class
|
||||
new_cls = type(
|
||||
cls.__name__,
|
||||
(cls,),
|
||||
cls_dict
|
||||
)
|
||||
# metadata preservation
|
||||
new_cls.__module__ = cls.__module__
|
||||
new_cls.__doc__ = cls.__doc__
|
||||
return new_cls
|
||||
|
||||
|
||||
class classproperty(object):
|
||||
def __init__(self, f):
|
||||
self.f = f
|
||||
def __get__(self, obj, owner):
|
||||
return self.f(owner)
|
||||
|
||||
|
||||
# NOTE: this was ai generated and validated by hand
|
||||
def shallow_clone_class(cls, new_name=None):
|
||||
'''
|
||||
Shallow clone a class while preserving super() functionality.
|
||||
'''
|
||||
new_name = new_name or f"{cls.__name__}Clone"
|
||||
# Include the original class in the bases to maintain proper inheritance
|
||||
new_bases = (cls,) + cls.__bases__
|
||||
return type(new_name, new_bases, dict(cls.__dict__))
|
||||
|
||||
# NOTE: this was ai generated and validated by hand
|
||||
def lock_class(cls):
|
||||
'''
|
||||
Lock a class so that its top-levelattributes cannot be modified.
|
||||
'''
|
||||
# Locked instance __setattr__
|
||||
def locked_instance_setattr(self, name, value):
|
||||
raise AttributeError(
|
||||
f"Cannot set attribute '{name}' on immutable instance of {type(self).__name__}"
|
||||
)
|
||||
# Locked metaclass
|
||||
class LockedMeta(type(cls)):
|
||||
def __setattr__(cls_, name, value):
|
||||
raise AttributeError(
|
||||
f"Cannot modify class attribute '{name}' on locked class '{cls_.__name__}'"
|
||||
)
|
||||
# Rebuild class with locked behavior
|
||||
locked_dict = dict(cls.__dict__)
|
||||
locked_dict['__setattr__'] = locked_instance_setattr
|
||||
|
||||
return LockedMeta(cls.__name__, cls.__bases__, locked_dict)
|
||||
|
||||
|
||||
def make_locked_method_func(type_obj, func, class_clone):
|
||||
"""
|
||||
Returns a function that, when called with **inputs, will execute:
|
||||
getattr(type_obj, func).__func__(lock_class(class_clone), **inputs)
|
||||
|
||||
Supports both synchronous and asynchronous methods.
|
||||
"""
|
||||
locked_class = lock_class(class_clone)
|
||||
method = getattr(type_obj, func).__func__
|
||||
|
||||
# Check if the original method is async
|
||||
if asyncio.iscoroutinefunction(method):
|
||||
async def wrapped_async_func(**inputs):
|
||||
return await method(locked_class, **inputs)
|
||||
return wrapped_async_func
|
||||
else:
|
||||
def wrapped_func(**inputs):
|
||||
return method(locked_class, **inputs)
|
||||
return wrapped_func
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
from ._io import * # noqa: F403
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
import json
|
||||
from comfy.comfy_types.node_typing import IO
|
||||
import torch
|
||||
|
||||
# Preview Any - original implement from
|
||||
# https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
|
||||
# upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes
|
||||
class PreviewAny():
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"source": (IO.ANY, {})},
|
||||
}
|
||||
|
||||
RETURN_TYPES = (IO.STRING,)
|
||||
FUNCTION = "main"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
CATEGORY = "utilities"
|
||||
SEARCH_ALIASES = ["preview", "preview text", "show output", "inspect", "debug", "print value", "show text"]
|
||||
DESCRIPTION = "Preview any input value as text."
|
||||
|
||||
def main(self, source=None):
|
||||
torch.set_printoptions(edgeitems=6)
|
||||
value = 'None'
|
||||
if isinstance(source, str):
|
||||
value = source
|
||||
elif isinstance(source, (int, float, bool)):
|
||||
value = str(source)
|
||||
elif source is not None:
|
||||
try:
|
||||
value = json.dumps(source, indent=4, ensure_ascii=False)
|
||||
except Exception:
|
||||
try:
|
||||
value = str(source)
|
||||
except Exception:
|
||||
value = 'source exists, but could not be serialized.'
|
||||
|
||||
torch.set_printoptions()
|
||||
return {"ui": {"text": (value,)}, "result": (value,)}
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"PreviewAny": PreviewAny,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"PreviewAny": "Preview as Text",
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import math
|
||||
from enum import Enum
|
||||
from typing_extensions import override
|
||||
from comfy_api.latest import ComfyExtension, io
|
||||
|
||||
|
||||
class AspectRatio(str, Enum):
|
||||
SQUARE = "1:1 (Square)"
|
||||
PHOTO_V = "2:3 (Portrait Photo)"
|
||||
PHOTO_H = "3:2 (Photo)"
|
||||
STANDARD_V = "3:4 (Portrait Standard)"
|
||||
STANDARD_H = "4:3 (Standard)"
|
||||
WIDESCREEN_V = "9:16 (Portrait Widescreen)"
|
||||
WIDESCREEN_H = "16:9 (Widescreen)"
|
||||
ULTRAWIDE_H = "21:9 (Ultrawide)"
|
||||
|
||||
|
||||
ASPECT_RATIOS: dict[AspectRatio, tuple[int, int]] = {
|
||||
AspectRatio.SQUARE: (1, 1),
|
||||
AspectRatio.PHOTO_V: (2, 3),
|
||||
AspectRatio.PHOTO_H: (3, 2),
|
||||
AspectRatio.STANDARD_V: (3, 4),
|
||||
AspectRatio.STANDARD_H: (4, 3),
|
||||
AspectRatio.WIDESCREEN_V: (9, 16),
|
||||
AspectRatio.WIDESCREEN_H: (16, 9),
|
||||
AspectRatio.ULTRAWIDE_H: (21, 9),
|
||||
}
|
||||
|
||||
|
||||
class ResolutionSelector(io.ComfyNode):
|
||||
"""Calculate width and height from aspect ratio and megapixel target."""
|
||||
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
return io.Schema(
|
||||
node_id="ResolutionSelector",
|
||||
display_name="Resolution Selector",
|
||||
category="utilities",
|
||||
description="Calculate width and height from aspect ratio and megapixel target. Useful for setting up Empty Latent Image dimensions.",
|
||||
inputs=[
|
||||
io.Combo.Input(
|
||||
"aspect_ratio",
|
||||
options=AspectRatio,
|
||||
default=AspectRatio.SQUARE,
|
||||
tooltip="The aspect ratio for the output dimensions.",
|
||||
),
|
||||
io.Float.Input(
|
||||
"megapixels",
|
||||
default=1.0,
|
||||
min=0.1,
|
||||
max=16.0,
|
||||
step=0.1,
|
||||
tooltip="Target total megapixels. 1.0 MP ≈ 1024x1024 for square.",
|
||||
),
|
||||
io.ResolutionPreview.Input(
|
||||
"preview",
|
||||
tooltip="Live preview of the calculated output resolution.",
|
||||
),
|
||||
io.Int.Input(
|
||||
id="multiple",
|
||||
default=8,
|
||||
min=8,
|
||||
max=128,
|
||||
step=4,
|
||||
tooltip="Nearest multiple of the result to set the selected resolution to.",
|
||||
advanced=True,
|
||||
),
|
||||
],
|
||||
outputs=[
|
||||
io.Int.Output(
|
||||
"width", tooltip="Calculated width in pixels multiplied by the selected multiple."
|
||||
),
|
||||
io.Int.Output(
|
||||
"height", tooltip="Calculated height in pixels multiplied by the selected multiple."
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, aspect_ratio: str, megapixels: float, multiple: int, preview=None) -> io.NodeOutput:
|
||||
w_ratio, h_ratio = ASPECT_RATIOS[aspect_ratio]
|
||||
total_pixels = megapixels * 1024 * 1024
|
||||
scale = math.sqrt(total_pixels / (w_ratio * h_ratio))
|
||||
width = round(w_ratio * scale / multiple) * multiple
|
||||
height = round(h_ratio * scale / multiple) * multiple
|
||||
return io.NodeOutput(width, height)
|
||||
|
||||
|
||||
class ResolutionExtension(ComfyExtension):
|
||||
@override
|
||||
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||
return [
|
||||
ResolutionSelector,
|
||||
]
|
||||
|
||||
|
||||
async def comfy_entrypoint() -> ResolutionExtension:
|
||||
return ResolutionExtension()
|
||||
+772
@@ -0,0 +1,772 @@
|
||||
import type { operations } from '@comfyorg/registry-types'
|
||||
|
||||
export function formatCamelCase(str: string): string {
|
||||
// Check if the string is camel case
|
||||
const isCamelCase = /^([A-Z][a-z]*)+$/.test(str)
|
||||
|
||||
if (!isCamelCase) {
|
||||
return str // Return original string if not camel case
|
||||
}
|
||||
|
||||
// Split the string into words, keeping acronyms together
|
||||
const words = str.split(/(?=[A-Z][a-z])|\d+/)
|
||||
|
||||
// Process each word
|
||||
const processedWords = words.map((word) => {
|
||||
// If the word is all uppercase and longer than one character, it's likely an acronym
|
||||
if (word.length > 1 && word === word.toUpperCase()) {
|
||||
return word // Keep acronyms as is
|
||||
}
|
||||
// For other words, ensure the first letter is capitalized
|
||||
return word.charAt(0).toUpperCase() + word.slice(1)
|
||||
})
|
||||
|
||||
// Join the words with spaces
|
||||
return processedWords.join(' ')
|
||||
}
|
||||
|
||||
// Metadata cannot be associated with workflows, so extension encodes the mode.
|
||||
const JSON_SUFFIX = 'json'
|
||||
const APP_JSON_SUFFIX = `app.${JSON_SUFFIX}`
|
||||
const JSON_EXT = `.${JSON_SUFFIX}`
|
||||
const APP_JSON_EXT = `.${APP_JSON_SUFFIX}`
|
||||
|
||||
export function appendJsonExt(path: string) {
|
||||
if (!path.toLowerCase().endsWith(JSON_EXT)) {
|
||||
path += JSON_EXT
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
export type WorkflowSuffix = typeof JSON_SUFFIX | typeof APP_JSON_SUFFIX
|
||||
|
||||
export function getWorkflowSuffix(
|
||||
suffix: string | null | undefined
|
||||
): WorkflowSuffix {
|
||||
return suffix === APP_JSON_SUFFIX ? APP_JSON_SUFFIX : JSON_SUFFIX
|
||||
}
|
||||
|
||||
export function appendWorkflowJsonExt(path: string, isApp: boolean): string {
|
||||
return ensureWorkflowSuffix(path, isApp ? APP_JSON_SUFFIX : JSON_SUFFIX)
|
||||
}
|
||||
|
||||
export function ensureWorkflowSuffix(
|
||||
name: string,
|
||||
suffix: WorkflowSuffix
|
||||
): string {
|
||||
const lower = name.toLowerCase()
|
||||
if (lower.endsWith(APP_JSON_EXT)) {
|
||||
name = name.slice(0, -APP_JSON_EXT.length)
|
||||
} else if (lower.endsWith(JSON_EXT)) {
|
||||
name = name.slice(0, -JSON_EXT.length)
|
||||
}
|
||||
return name + '.' + suffix
|
||||
}
|
||||
|
||||
interface HighlightQueryPart {
|
||||
text: string
|
||||
highlighted: boolean
|
||||
}
|
||||
|
||||
export function highlightQuery(
|
||||
text: string,
|
||||
query: string
|
||||
): HighlightQueryPart[] {
|
||||
if (!query) return [{ text, highlighted: false }]
|
||||
|
||||
// Escape special regex characters, then join with an optional single
|
||||
// space so cross-word matches (e.g. "geto" → "imaGE TO") are
|
||||
// highlighted without spanning tabs, newlines, or multi-space gaps.
|
||||
const pattern = Array.from(query)
|
||||
.map((ch) => ch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
||||
.join('[ ]?')
|
||||
|
||||
const regex = new RegExp(pattern, 'gi')
|
||||
const parts: HighlightQueryPart[] = []
|
||||
let lastIndex = 0
|
||||
|
||||
for (const match of text.matchAll(regex)) {
|
||||
if (match.index > lastIndex) {
|
||||
parts.push({
|
||||
text: text.slice(lastIndex, match.index),
|
||||
highlighted: false
|
||||
})
|
||||
}
|
||||
parts.push({ text: match[0], highlighted: true })
|
||||
lastIndex = match.index + match[0].length
|
||||
}
|
||||
|
||||
if (lastIndex < text.length || parts.length === 0) {
|
||||
parts.push({ text: text.slice(lastIndex), highlighted: false })
|
||||
}
|
||||
|
||||
return parts
|
||||
}
|
||||
|
||||
export function formatNumberWithSuffix(
|
||||
num: number,
|
||||
{
|
||||
precision = 1,
|
||||
roundToInt = false
|
||||
}: { precision?: number; roundToInt?: boolean } = {}
|
||||
): string {
|
||||
const suffixes = ['', 'k', 'm', 'b', 't']
|
||||
const absNum = Math.abs(num)
|
||||
|
||||
if (absNum < 1000) {
|
||||
return roundToInt ? Math.round(num).toString() : num.toFixed(precision)
|
||||
}
|
||||
|
||||
const exp = Math.min(Math.floor(Math.log10(absNum) / 3), suffixes.length - 1)
|
||||
const formattedNum = (num / Math.pow(1000, exp)).toFixed(precision)
|
||||
|
||||
return `${formattedNum}${suffixes[exp]}`
|
||||
}
|
||||
|
||||
export function formatSize(value?: number) {
|
||||
if (value === null || value === undefined) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
const bytes = value
|
||||
if (bytes === 0) return '0 B'
|
||||
const k = 1024
|
||||
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a commit hash by truncating long (40-char) hashes to 7 chars.
|
||||
* Returns the original string if not a valid full commit hash.
|
||||
*/
|
||||
export function formatCommitHash(value: string): string {
|
||||
if (/^[a-f0-9]{40}$/i.test(value)) {
|
||||
return value.slice(0, 7)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns various filename components.
|
||||
* Recognises compound extensions like `.app.json`.
|
||||
* Example:
|
||||
* - fullFilename: 'file.txt' → { filename: 'file', suffix: 'txt' }
|
||||
* - fullFilename: 'file.app.json' → { filename: 'file', suffix: 'app.json' }
|
||||
*/
|
||||
export function getFilenameDetails(fullFilename: string) {
|
||||
const lower = fullFilename.toLowerCase()
|
||||
if (
|
||||
lower.endsWith(APP_JSON_EXT) &&
|
||||
fullFilename.length > APP_JSON_EXT.length
|
||||
) {
|
||||
return {
|
||||
filename: fullFilename.slice(0, -APP_JSON_EXT.length),
|
||||
suffix: APP_JSON_SUFFIX
|
||||
}
|
||||
}
|
||||
const dotIndex = fullFilename.lastIndexOf('.')
|
||||
if (dotIndex <= 0) return { filename: fullFilename, suffix: null }
|
||||
return {
|
||||
filename: fullFilename.slice(0, dotIndex),
|
||||
suffix: fullFilename.slice(dotIndex + 1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns various path components.
|
||||
* Example:
|
||||
* - path: 'dir/file.txt'
|
||||
* - directory: 'dir'
|
||||
* - fullFilename: 'file.txt'
|
||||
* - filename: 'file'
|
||||
* - suffix: 'txt'
|
||||
*/
|
||||
export function getPathDetails(path: string) {
|
||||
const directory = path.split('/').slice(0, -1).join('/')
|
||||
const fullFilename = path.split('/').pop() ?? path
|
||||
return { directory, fullFilename, ...getFilenameDetails(fullFilename) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a string to be used as an i18n key.
|
||||
* Replaces dots with underscores.
|
||||
*/
|
||||
export function normalizeI18nKey(key: string) {
|
||||
return typeof key === 'string' ? key.replace(/\./g, '_') : ''
|
||||
}
|
||||
|
||||
const VUE_I18N_BACKSLASH = /\\/g
|
||||
const VUE_I18N_SYNTAX_CHARS = /[@${}|%]/g
|
||||
|
||||
/**
|
||||
* Escapes vue-i18n message syntax so arbitrary text can be stored as a locale
|
||||
* message and rendered verbatim by `t()`.
|
||||
*
|
||||
* Backslash is doubled rather than wrapped in a literal interpolation: since
|
||||
* vue-i18n 11 the message compiler reads `\` as an escape introducer, so a
|
||||
* backslash before an escaped character would swallow the `{` this emits, and
|
||||
* `{'\'}` would escape its own closing quote. Doubling must therefore run
|
||||
* first; the literal interpolations it emits contain no backslashes.
|
||||
*
|
||||
* Apply exactly once. This is NOT idempotent, because the escape output itself
|
||||
* contains `{`/`}`.
|
||||
*
|
||||
* Apply only to values read back through `t()`/`st()`. Values read through
|
||||
* `tm()`/`stRaw()` are never compiled, so escaping them renders the escape
|
||||
* syntax literally.
|
||||
*/
|
||||
export function escapeI18nMessage(text: string): string {
|
||||
if (typeof text !== 'string') return ''
|
||||
return text
|
||||
.replace(VUE_I18N_BACKSLASH, '\\\\')
|
||||
.replace(VUE_I18N_SYNTAX_CHARS, (char) => `{'${char}'}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a dynamic prompt in the format {opt1|opt2|{optA|optB}|} and randomly replaces groups. Supports C style comments.
|
||||
* @param input The dynamic prompt to process
|
||||
* @returns
|
||||
*/
|
||||
export function processDynamicPrompt(input: string): string {
|
||||
/*
|
||||
* Strips C-style line and block comments from a string
|
||||
*/
|
||||
function stripComments(str: string) {
|
||||
return str.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '')
|
||||
}
|
||||
|
||||
let i = 0
|
||||
let result = ''
|
||||
input = stripComments(input)
|
||||
|
||||
const handleEscape = () => {
|
||||
const nextChar = input[i++]
|
||||
return '\\' + nextChar
|
||||
}
|
||||
|
||||
function parseChoiceBlock() {
|
||||
// Parse the content inside {}
|
||||
const options: string[] = []
|
||||
let choice = ''
|
||||
let depth = 0
|
||||
|
||||
while (i < input.length) {
|
||||
const char = input[i++]
|
||||
|
||||
if (char === '\\') {
|
||||
choice += handleEscape()
|
||||
continue
|
||||
} else if (char === '{') {
|
||||
depth++
|
||||
} else if (char === '}') {
|
||||
if (!depth) break
|
||||
depth--
|
||||
} else if (char === '|') {
|
||||
if (!depth) {
|
||||
options.push(choice)
|
||||
choice = ''
|
||||
continue
|
||||
}
|
||||
}
|
||||
choice += char
|
||||
}
|
||||
|
||||
options.push(choice)
|
||||
|
||||
const chosenOption = options[Math.floor(Math.random() * options.length)]
|
||||
return processDynamicPrompt(chosenOption)
|
||||
}
|
||||
|
||||
while (i < input.length) {
|
||||
const char = input[i++]
|
||||
if (char === '\\') {
|
||||
result += handleEscape()
|
||||
} else if (char === '{') {
|
||||
result += parseChoiceBlock()
|
||||
} else {
|
||||
result += char
|
||||
}
|
||||
}
|
||||
|
||||
return result.replace(/\\([{}|])/g, '$1')
|
||||
}
|
||||
|
||||
export function isValidUrl(url: string): boolean {
|
||||
try {
|
||||
new URL(url)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function joinFilePath(
|
||||
subfolder: string | null | undefined,
|
||||
filename: string | null | undefined
|
||||
): string {
|
||||
const normalizedSubfolder = normalizeFilePathSeparators(
|
||||
subfolder ?? ''
|
||||
).replace(/^\/+|\/+$/g, '')
|
||||
const normalizedFilename = normalizeFilePathSeparators(
|
||||
filename ?? ''
|
||||
).replace(/^\/+/g, '')
|
||||
if (!normalizedSubfolder) return normalizedFilename
|
||||
if (!normalizedFilename) return normalizedSubfolder
|
||||
return `${normalizedSubfolder}/${normalizedFilename}`
|
||||
}
|
||||
|
||||
export function getFilePathSeparatorVariants(filepath: string): string[] {
|
||||
const slashPath = normalizeFilePathSeparators(filepath)
|
||||
const backslashPath = slashPath.replace(/\//g, '\\')
|
||||
return slashPath === backslashPath ? [slashPath] : [slashPath, backslashPath]
|
||||
}
|
||||
|
||||
function normalizeFilePathSeparators(filepath: string): string {
|
||||
return filepath.replace(/[\\/]+/g, '/')
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a filepath into its filename and subfolder components.
|
||||
*
|
||||
* @example
|
||||
* parseFilePath('folder/file.txt') // → { filename: 'file.txt', subfolder: 'folder' }
|
||||
* parseFilePath('/folder/file.txt') // → { filename: 'file.txt', subfolder: 'folder' }
|
||||
* parseFilePath('file.txt') // → { filename: 'file.txt', subfolder: '' }
|
||||
* parseFilePath('folder//file.txt') // → { filename: 'file.txt', subfolder: 'folder' }
|
||||
*
|
||||
* @param filepath The filepath to parse
|
||||
* @returns Object containing filename and subfolder
|
||||
*/
|
||||
export function parseFilePath(filepath: string): {
|
||||
filename: string
|
||||
subfolder: string
|
||||
} {
|
||||
if (!filepath?.trim()) return { filename: '', subfolder: '' }
|
||||
|
||||
const normalizedPath = normalizeFilePathSeparators(filepath)
|
||||
.replace(/^\//, '') // Remove leading slash
|
||||
.replace(/\/$/, '') // Remove trailing slash
|
||||
|
||||
const lastSlashIndex = normalizedPath.lastIndexOf('/')
|
||||
|
||||
if (lastSlashIndex === -1) {
|
||||
return {
|
||||
filename: normalizedPath,
|
||||
subfolder: ''
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
filename: normalizedPath.slice(lastSlashIndex + 1),
|
||||
subfolder: normalizedPath.slice(0, lastSlashIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// Simple date formatter
|
||||
const parts = {
|
||||
d: (d: Date) => d.getDate(),
|
||||
M: (d: Date) => d.getMonth() + 1,
|
||||
h: (d: Date) => d.getHours(),
|
||||
m: (d: Date) => d.getMinutes(),
|
||||
s: (d: Date) => d.getSeconds()
|
||||
}
|
||||
const format =
|
||||
Object.keys(parts)
|
||||
.map((k) => k + k + '?')
|
||||
.join('|') + '|yyy?y?'
|
||||
|
||||
export function formatDate(text: string, date: Date) {
|
||||
return text.replace(new RegExp(format, 'g'), (text: string): string => {
|
||||
if (text === 'yy') return (date.getFullYear() + '').substring(2)
|
||||
if (text === 'yyyy') return date.getFullYear().toString()
|
||||
if (text[0] in parts) {
|
||||
const p = parts[text[0] as keyof typeof parts](date)
|
||||
return (p + '').padStart(text.length, '0')
|
||||
}
|
||||
return text
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a cache key from parameters
|
||||
* Sorts the parameters to ensure consistent keys regardless of parameter order
|
||||
*/
|
||||
export const paramsToCacheKey = (params: unknown): string => {
|
||||
if (typeof params === 'string') return params
|
||||
if (typeof params === 'object' && params !== null)
|
||||
return Object.keys(params)
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.map((key) => `${key}:${params[key as keyof typeof params]}`)
|
||||
.join('&')
|
||||
|
||||
return String(params)
|
||||
}
|
||||
|
||||
const UUID_PATTERN =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
|
||||
/** Accepts canonical UUIDs of any version or variant for legacy compatibility. */
|
||||
export const isValidUuid = (value: unknown): value is string =>
|
||||
typeof value === 'string' && UUID_PATTERN.test(value)
|
||||
|
||||
/**
|
||||
* Generates a RFC4122 compliant UUID v4 using the native crypto API when available
|
||||
* @returns A properly formatted UUID string
|
||||
*/
|
||||
export const generateUUID = (): string => {
|
||||
// Use native crypto.randomUUID() if available (modern browsers)
|
||||
if (
|
||||
typeof crypto !== 'undefined' &&
|
||||
typeof crypto.randomUUID === 'function'
|
||||
) {
|
||||
return crypto.randomUUID()
|
||||
}
|
||||
|
||||
// Fallback implementation for older browsers
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0
|
||||
const v = c === 'x' ? r : (r & 0x3) | 0x8
|
||||
return v.toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
const isCivitaiHost = (hostname: string): boolean =>
|
||||
hostname === 'civitai.com' ||
|
||||
hostname.endsWith('.civitai.com') ||
|
||||
hostname === 'civitai.red' ||
|
||||
hostname.endsWith('.civitai.red')
|
||||
|
||||
/**
|
||||
* Checks if a URL belongs to any Civitai domain (civitai.com or civitai.red).
|
||||
* Use this for source-name detection; use `isCivitaiModelUrl` when the URL
|
||||
* must also match a specific model API path format.
|
||||
*/
|
||||
export const isCivitaiUrl = (url: string): boolean => {
|
||||
if (!isValidUrl(url)) return false
|
||||
return isCivitaiHost(new URL(url).hostname.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a URL is a Civitai model URL
|
||||
* @example
|
||||
* isCivitaiModelUrl('https://civitai.com/api/download/models/1234567890') // true
|
||||
* isCivitaiModelUrl('https://civitai.com/api/v1/models/1234567890') // true
|
||||
* isCivitaiModelUrl('https://civitai.com/api/v1/models-versions/15342') // true
|
||||
* isCivitaiModelUrl('https://example.com/model.safetensors') // false
|
||||
*/
|
||||
export const isCivitaiModelUrl = (url: string): boolean => {
|
||||
if (!isValidUrl(url)) return false
|
||||
|
||||
const urlObj = new URL(url)
|
||||
if (!isCivitaiHost(urlObj.hostname.toLowerCase())) return false
|
||||
|
||||
const pathname = urlObj.pathname
|
||||
return (
|
||||
/^\/api\/download\/models\/(\d+)$/.test(pathname) ||
|
||||
/^\/api\/v1\/models\/(\d+)$/.test(pathname) ||
|
||||
/^\/api\/v1\/models-versions\/(\d+)$/.test(pathname)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Hugging Face download URL to a repository page URL
|
||||
* @param url The download URL to convert
|
||||
* @returns The repository page URL or the Hugging Face root if conversion fails
|
||||
* @example
|
||||
* downloadUrlToHfRepoUrl(
|
||||
* 'https://huggingface.co/bfl/FLUX.1/resolve/main/flux1-canny-dev.safetensors?download=true'
|
||||
* ) // https://huggingface.co/bfl/FLUX.1
|
||||
*/
|
||||
export const downloadUrlToHfRepoUrl = (url: string): string => {
|
||||
try {
|
||||
const urlObj = new URL(url)
|
||||
const pathname = urlObj.pathname
|
||||
|
||||
// Use regex to match everything before /resolve/ or /blob/
|
||||
const regex = /^(.*?)(?:\/resolve\/|\/blob\/|$)/
|
||||
const repoPathMatch = regex.exec(pathname)
|
||||
|
||||
// Extract the repository path and remove leading slash if present
|
||||
const repoPath = repoPathMatch?.[1]?.replace(/^\//, '') || ''
|
||||
|
||||
return `https://huggingface.co/${repoPath}`
|
||||
} catch {
|
||||
return 'https://huggingface.co/'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Metronome's integer amount back to a formatted currency string.
|
||||
* For USD, converts from cents to dollars.
|
||||
* For all other currencies (including custom pricing units), returns the amount as is.
|
||||
* This is specific to Metronome's API requirements.
|
||||
*
|
||||
* @param amount - The amount in Metronome's integer format (cents for USD, base units for others)
|
||||
* @param currency - The currency to convert
|
||||
* @returns The formatted amount in currency with 2 decimal places for USD
|
||||
* @example
|
||||
* formatMetronomeCurrency(123, 'usd') // returns "1.23" (cents to USD)
|
||||
* formatMetronomeCurrency(1000, 'jpy') // returns "1000" (yen)
|
||||
*/
|
||||
export function formatMetronomeCurrency(
|
||||
amount: number,
|
||||
currency: string
|
||||
): string {
|
||||
if (currency === 'usd') {
|
||||
return (amount / 100).toFixed(2)
|
||||
}
|
||||
return amount.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a USD amount to microdollars (1/1,000,000 of a dollar).
|
||||
* This conversion is commonly used in financial systems to avoid floating-point precision issues
|
||||
* by representing monetary values as integers.
|
||||
*
|
||||
* @param usd - The amount in US dollars to convert
|
||||
* @returns The amount in microdollars (multiplied by 1,000,000)
|
||||
* @example
|
||||
* usdToMicros(1.23) // returns 1230000
|
||||
*/
|
||||
export function usdToMicros(usd: number): number {
|
||||
return Math.round(usd * 1_000_000)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts URLs in a string to HTML links.
|
||||
* @param text - The string to convert
|
||||
* @returns The string with URLs converted to HTML links
|
||||
* @example
|
||||
* linkifyHtml('Visit https://example.com for more info') // returns 'Visit <a href="https://example.com" target="_blank" rel="noopener noreferrer" class="text-primary-400 hover:underline">https://example.com</a> for more info'
|
||||
*/
|
||||
export function linkifyHtml(text: string): string {
|
||||
if (!text) return ''
|
||||
const urlRegex =
|
||||
/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%?=~_|])|(\bwww\.[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%?=~_|])/gi
|
||||
return text.replace(urlRegex, (_match, p1, _p2, p3) => {
|
||||
const url = p1 || p3
|
||||
const href = p3 ? `http://${url}` : url
|
||||
return `<a href="${href}" target="_blank" rel="noopener noreferrer" class="text-primary-400 hover:underline">${url}</a>`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts newline characters to HTML <br> tags.
|
||||
* @param text - The string to convert
|
||||
* @returns The string with newline characters converted to <br> tags
|
||||
* @example
|
||||
* nl2br('Hello\nWorld') // returns 'Hello<br />World'
|
||||
*/
|
||||
export function nl2br(text: string): string {
|
||||
if (!text) return ''
|
||||
return text.replace(/\n/g, '<br />')
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a version string to an anchor-safe format by replacing dots with dashes.
|
||||
* @param version The version string (e.g., "1.0.0", "2.1.3-beta.1")
|
||||
* @returns The anchor-safe version string (e.g., "v1-0-0", "v2-1-3-beta-1")
|
||||
* @example
|
||||
* formatVersionAnchor("1.0.0") // returns "v1-0-0"
|
||||
* formatVersionAnchor("2.1.3-beta.1") // returns "v2-1-3-beta-1"
|
||||
*/
|
||||
export function formatVersionAnchor(version: string): string {
|
||||
return `v${version.replace(/\./g, '-')}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported locale types for the application (from OpenAPI schema)
|
||||
*/
|
||||
type SupportedLocale = NonNullable<
|
||||
operations['getReleaseNotes']['parameters']['query']['locale']
|
||||
>
|
||||
|
||||
/**
|
||||
* Converts a string to a valid locale type with 'en' as default
|
||||
* @param locale - The locale string to validate and convert
|
||||
* @returns A valid SupportedLocale type, defaults to 'en' if invalid
|
||||
* @example
|
||||
* stringToLocale('fr') // returns 'fr'
|
||||
* stringToLocale('invalid') // returns 'en'
|
||||
* stringToLocale('') // returns 'en'
|
||||
*/
|
||||
export function stringToLocale(locale: string): SupportedLocale {
|
||||
const supportedLocales: SupportedLocale[] = [
|
||||
'en',
|
||||
'es',
|
||||
'fr',
|
||||
'ja',
|
||||
'ko',
|
||||
'ru',
|
||||
'zh'
|
||||
]
|
||||
return supportedLocales.includes(locale as SupportedLocale)
|
||||
? (locale as SupportedLocale)
|
||||
: 'en'
|
||||
}
|
||||
|
||||
export function formatDuration(milliseconds: number): string {
|
||||
if (!milliseconds || milliseconds < 0) return '0s'
|
||||
|
||||
const totalSeconds = Math.floor(milliseconds / 1000)
|
||||
const hours = Math.floor(totalSeconds / 3600)
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||
const remainingSeconds = Math.floor(totalSeconds % 60)
|
||||
|
||||
const parts: string[] = []
|
||||
|
||||
if (hours > 0) {
|
||||
parts.push(`${hours}h`)
|
||||
}
|
||||
if (minutes > 0) {
|
||||
parts.push(`${minutes}m`)
|
||||
}
|
||||
if (remainingSeconds > 0 || parts.length === 0) {
|
||||
parts.push(`${remainingSeconds}s`)
|
||||
}
|
||||
|
||||
return parts.join(' ')
|
||||
}
|
||||
|
||||
const IMAGE_EXTENSIONS = [
|
||||
'png',
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'gif',
|
||||
'webp',
|
||||
'bmp',
|
||||
'avif',
|
||||
'tif',
|
||||
'tiff',
|
||||
'svg'
|
||||
] as const
|
||||
const VIDEO_EXTENSIONS = ['mp4', 'm4v', 'webm', 'mov', 'avi', 'mkv'] as const
|
||||
const AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'flac', 'opus', 'm4a'] as const
|
||||
const THREE_D_EXTENSIONS = [
|
||||
'obj',
|
||||
'fbx',
|
||||
'gltf',
|
||||
'glb',
|
||||
'stl',
|
||||
'usdz',
|
||||
'ply',
|
||||
'spz',
|
||||
'splat',
|
||||
'ksplat'
|
||||
] as const
|
||||
const TEXT_EXTENSIONS = [
|
||||
'txt',
|
||||
'md',
|
||||
'markdown',
|
||||
'json',
|
||||
'csv',
|
||||
'yaml',
|
||||
'yml',
|
||||
'xml',
|
||||
'log'
|
||||
] as const
|
||||
|
||||
const MEDIA_TYPES = ['image', 'video', 'audio', '3D', 'text', 'other'] as const
|
||||
export type MediaType = (typeof MEDIA_TYPES)[number]
|
||||
|
||||
// Type guard helper for checking array membership
|
||||
type ImageExtension = (typeof IMAGE_EXTENSIONS)[number]
|
||||
type VideoExtension = (typeof VIDEO_EXTENSIONS)[number]
|
||||
type AudioExtension = (typeof AUDIO_EXTENSIONS)[number]
|
||||
type ThreeDExtension = (typeof THREE_D_EXTENSIONS)[number]
|
||||
type TextExtension = (typeof TEXT_EXTENSIONS)[number]
|
||||
|
||||
/**
|
||||
* Truncates a filename while preserving the extension
|
||||
* @param filename The filename to truncate
|
||||
* @param maxLength Maximum length for the filename without extension
|
||||
* @returns Truncated filename with extension preserved
|
||||
*/
|
||||
export function truncateFilename(
|
||||
filename: string,
|
||||
maxLength: number = 20
|
||||
): string {
|
||||
if (!filename || filename.length <= maxLength) {
|
||||
return filename
|
||||
}
|
||||
|
||||
const lastDotIndex = filename.lastIndexOf('.')
|
||||
const nameWithoutExt =
|
||||
lastDotIndex > -1 ? filename.substring(0, lastDotIndex) : filename
|
||||
const extension = lastDotIndex > -1 ? filename.substring(lastDotIndex) : ''
|
||||
|
||||
// If the name without extension is short enough, return as is
|
||||
if (nameWithoutExt.length <= maxLength) {
|
||||
return filename
|
||||
}
|
||||
|
||||
// Calculate how to split the truncation
|
||||
const halfLength = Math.floor((maxLength - 3) / 2) // -3 for '...'
|
||||
const start = nameWithoutExt.substring(0, halfLength)
|
||||
const end = nameWithoutExt.substring(nameWithoutExt.length - halfLength)
|
||||
|
||||
return `${start}...${end}${extension}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the media type from a filename's extension (singular form)
|
||||
* @param filename The filename to analyze
|
||||
* @returns The media type: 'image', 'video', 'audio', '3D', 'text', or 'other'
|
||||
*/
|
||||
export function getMediaTypeFromFilename(
|
||||
filename: string | null | undefined
|
||||
): MediaType {
|
||||
if (!filename) return 'other'
|
||||
const ext = filename.split('.').pop()?.toLowerCase()
|
||||
if (!ext) return 'other'
|
||||
|
||||
// Type-safe array includes check using type assertion
|
||||
if (IMAGE_EXTENSIONS.includes(ext as ImageExtension)) return 'image'
|
||||
if (VIDEO_EXTENSIONS.includes(ext as VideoExtension)) return 'video'
|
||||
if (AUDIO_EXTENSIONS.includes(ext as AudioExtension)) return 'audio'
|
||||
if (THREE_D_EXTENSIONS.includes(ext as ThreeDExtension)) return '3D'
|
||||
if (TEXT_EXTENSIONS.includes(ext as TextExtension)) return 'text'
|
||||
|
||||
return 'other'
|
||||
}
|
||||
|
||||
export function isPreviewableMediaType(mediaType: MediaType): boolean {
|
||||
return mediaType !== 'other'
|
||||
}
|
||||
|
||||
export function formatTime(seconds: number): string {
|
||||
if (isNaN(seconds) || seconds === 0) return '0:00'
|
||||
const mins = Math.floor(seconds / 60)
|
||||
const secs = Math.floor(seconds % 60)
|
||||
return `${mins}:${secs.toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a number with the given BCP-47 locale.
|
||||
* Returns an em-dash for non-numeric, NaN, or infinite inputs.
|
||||
*/
|
||||
export function formatLocalizedNumber(
|
||||
value: number | undefined,
|
||||
locale: string
|
||||
): string {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value)) return '—'
|
||||
return new Intl.NumberFormat(locale).format(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Format an ISO 8601 date string with the given BCP-47 locale using the
|
||||
* `medium` date style (e.g. "Apr 19, 2026"). Returns an em-dash for missing
|
||||
* or unparseable inputs.
|
||||
*/
|
||||
export function formatLocalizedMediumDate(
|
||||
value: string | undefined,
|
||||
locale: string
|
||||
): string {
|
||||
if (!value) return '—'
|
||||
const timestamp = Date.parse(value)
|
||||
if (Number.isNaN(timestamp)) return '—'
|
||||
return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(
|
||||
timestamp
|
||||
)
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
import type { INodeInputSlot } from '@/lib/litegraph/src/interfaces'
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
||||
import { useWidgetValueStore } from '@/stores/widgetValueStore'
|
||||
import type { NodeId } from '@/types/nodeId'
|
||||
|
||||
import { resolveSubgraphInputTarget } from './resolveSubgraphInputTarget'
|
||||
|
||||
/**
|
||||
* Where a promoted subgraph input is sourced from inside the subgraph. The
|
||||
* interior node id + widget name that the host input slot forwards to. Resolved
|
||||
* by walking the live link, so it is authoritative derived data — never stored
|
||||
* on the projected widget.
|
||||
*/
|
||||
export interface PromotedSource {
|
||||
nodeId: NodeId
|
||||
widgetName: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The interior source of a host input slot, or undefined when the slot is not a
|
||||
* promoted widget input.
|
||||
*/
|
||||
export function promotedInputSource(
|
||||
node: LGraphNode,
|
||||
input: INodeInputSlot
|
||||
): PromotedSource | undefined {
|
||||
if (!input.widgetId) return undefined
|
||||
return resolveSubgraphInputTarget(node, input.name)
|
||||
}
|
||||
|
||||
/** The host input slot backing a projected widget, matched by widgetId. */
|
||||
export function inputForWidget(
|
||||
node: LGraphNode,
|
||||
widget: IBaseWidget
|
||||
): INodeInputSlot | undefined {
|
||||
return node.getSlotFromWidget(widget)
|
||||
}
|
||||
|
||||
/**
|
||||
* Projects a promoted subgraph input into an ordinary widget descriptor. The
|
||||
* descriptor is store-backed: type/value/options read live from
|
||||
* {@link useWidgetValueStore} by widgetId (mirroring BaseWidget), so the row
|
||||
* list does not reactively rebuild — and re-key — on every value edit.
|
||||
*
|
||||
* `name` is the input slot name (unique + fixed; widgetId derives from it), and
|
||||
* `label` is the mutable display label. Returns null when the input is not a
|
||||
* promoted widget input.
|
||||
*/
|
||||
export function promotedInputWidget(input: INodeInputSlot): IBaseWidget | null {
|
||||
const id = input.widgetId
|
||||
if (!id) return null
|
||||
const store = useWidgetValueStore()
|
||||
return {
|
||||
get name() {
|
||||
return store.getWidget(id)?.name ?? input.name
|
||||
},
|
||||
get label() {
|
||||
return store.getWidget(id)?.label ?? input.label ?? input.name
|
||||
},
|
||||
set label(next) {
|
||||
const state = store.getWidget(id)
|
||||
if (state) state.label = next
|
||||
},
|
||||
get y() {
|
||||
return store.getWidget(id)?.y ?? 0
|
||||
},
|
||||
set y(next) {
|
||||
const state = store.getWidget(id)
|
||||
if (state) state.y = next
|
||||
},
|
||||
widgetId: id,
|
||||
get type() {
|
||||
return store.getWidget(id)?.type ?? 'text'
|
||||
},
|
||||
get options() {
|
||||
return store.getWidget(id)?.options ?? {}
|
||||
},
|
||||
get value() {
|
||||
return store.getWidget(id)?.value
|
||||
},
|
||||
set value(next) {
|
||||
store.setValue(id, next)
|
||||
},
|
||||
// Canvas edits operate on a transient concrete widget (toConcreteWidget),
|
||||
// so the value setter above is never invoked; BaseWidget.setValue writes its
|
||||
// own local state and then calls this callback, which is the only bridge
|
||||
// back to the store.
|
||||
callback(next) {
|
||||
store.setValue(id, next)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function promotedInputWidgets(node: LGraphNode): IBaseWidget[] {
|
||||
return node.inputs.flatMap((input) => {
|
||||
const widget = promotedInputWidget(input)
|
||||
return widget ? [widget] : []
|
||||
})
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
import type { ResolvedPromotedWidget } from '@/core/graph/subgraph/promotedWidgetTypes'
|
||||
import { resolveSubgraphInputTarget } from '@/core/graph/subgraph/resolveSubgraphInputTarget'
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode'
|
||||
import { LGraphEventMode } from '@/lib/litegraph/src/types/globalEnums'
|
||||
import type { NodeExecutionId } from '@/types/nodeIdentification'
|
||||
import { createNodeExecutionId } from '@/types/nodeIdentification'
|
||||
import { toNodeId } from '@/types/nodeId'
|
||||
import type { NodeId, SerializedNodeId } from '@/types/nodeId'
|
||||
|
||||
type PromotedWidgetResolutionFailure =
|
||||
| 'invalid-host'
|
||||
| 'cycle'
|
||||
| 'missing-node'
|
||||
| 'missing-widget'
|
||||
| 'max-depth-exceeded'
|
||||
|
||||
type PromotedWidgetResolutionResult =
|
||||
| { status: 'resolved'; resolved: ResolvedPromotedWidget }
|
||||
| { status: 'failure'; failure: PromotedWidgetResolutionFailure }
|
||||
|
||||
const MAX_PROMOTED_WIDGET_CHAIN_DEPTH = 100
|
||||
|
||||
function isNodeActive(node: LGraphNode): boolean {
|
||||
return (
|
||||
node.mode !== LGraphEventMode.NEVER && node.mode !== LGraphEventMode.BYPASS
|
||||
)
|
||||
}
|
||||
|
||||
function hasActiveConsumer(
|
||||
hostNode: SubgraphNode,
|
||||
inputName: string,
|
||||
depth: number,
|
||||
visitedByHost: WeakMap<SubgraphNode, Set<string>>
|
||||
): boolean {
|
||||
if (depth >= MAX_PROMOTED_WIDGET_CHAIN_DEPTH) return false
|
||||
|
||||
const visited = visitedByHost.get(hostNode) ?? new Set<string>()
|
||||
if (visited.has(inputName)) return false
|
||||
visited.add(inputName)
|
||||
visitedByHost.set(hostNode, visited)
|
||||
|
||||
const inputSlot = hostNode.subgraph.inputNode.slots.find(
|
||||
(slot) => slot.name === inputName
|
||||
)
|
||||
if (!inputSlot) return false
|
||||
|
||||
for (const linkId of inputSlot.linkIds) {
|
||||
const link = hostNode.subgraph.getLink(linkId)
|
||||
if (!link) continue
|
||||
|
||||
const { inputNode } = link.resolve(hostNode.subgraph)
|
||||
if (!inputNode || !isNodeActive(inputNode)) continue
|
||||
const targetInput = inputNode.inputs?.find((entry) => entry.link === linkId)
|
||||
if (!targetInput) continue
|
||||
|
||||
if (inputNode.isSubgraphNode()) {
|
||||
if (
|
||||
targetInput.widgetId &&
|
||||
hasActiveConsumer(inputNode, targetInput.name, depth + 1, visitedByHost)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if (inputNode.getWidgetFromSlot(targetInput)) return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export function hasActivePromotedWidgetConsumer(
|
||||
hostNode: LGraphNode,
|
||||
inputName: string
|
||||
): boolean {
|
||||
return (
|
||||
hostNode.isSubgraphNode() &&
|
||||
hasActiveConsumer(hostNode, inputName, 0, new WeakMap())
|
||||
)
|
||||
}
|
||||
|
||||
function traversePromotedWidgetChain(
|
||||
hostNode: SubgraphNode,
|
||||
nodeId: NodeId,
|
||||
widgetName: string
|
||||
): PromotedWidgetResolutionResult {
|
||||
const visitedByHost = new WeakMap<SubgraphNode, Set<string>>()
|
||||
let currentHost = hostNode
|
||||
let currentNodeId = nodeId
|
||||
let currentWidgetName = widgetName
|
||||
const nodePath: NodeId[] = []
|
||||
|
||||
for (let depth = 0; depth < MAX_PROMOTED_WIDGET_CHAIN_DEPTH; depth++) {
|
||||
const key = `${currentNodeId}:${currentWidgetName}`
|
||||
const visited = visitedByHost.get(currentHost) ?? new Set<string>()
|
||||
if (visited.has(key)) {
|
||||
return { status: 'failure', failure: 'cycle' }
|
||||
}
|
||||
visited.add(key)
|
||||
visitedByHost.set(currentHost, visited)
|
||||
|
||||
const sourceNode = currentHost.subgraph.getNodeById(currentNodeId)
|
||||
if (!sourceNode) {
|
||||
return { status: 'failure', failure: 'missing-node' }
|
||||
}
|
||||
nodePath.push(sourceNode.id)
|
||||
|
||||
if (sourceNode.isSubgraphNode()) {
|
||||
const target = resolveSubgraphInputTarget(sourceNode, currentWidgetName)
|
||||
if (!target) {
|
||||
return { status: 'failure', failure: 'missing-widget' }
|
||||
}
|
||||
currentHost = sourceNode
|
||||
currentNodeId = target.nodeId
|
||||
currentWidgetName = target.widgetName
|
||||
continue
|
||||
}
|
||||
|
||||
const sourceWidget = sourceNode.widgets?.find(
|
||||
(entry) => entry.name === currentWidgetName
|
||||
)
|
||||
if (!sourceWidget) {
|
||||
return { status: 'failure', failure: 'missing-widget' }
|
||||
}
|
||||
|
||||
return {
|
||||
status: 'resolved',
|
||||
resolved: { node: sourceNode, nodePath, widget: sourceWidget }
|
||||
}
|
||||
}
|
||||
|
||||
return { status: 'failure', failure: 'max-depth-exceeded' }
|
||||
}
|
||||
|
||||
export function resolveConcretePromotedWidget(
|
||||
hostNode: LGraphNode,
|
||||
rawNodeId: SerializedNodeId,
|
||||
widgetName: string
|
||||
): PromotedWidgetResolutionResult {
|
||||
if (!hostNode.isSubgraphNode()) {
|
||||
return { status: 'failure', failure: 'invalid-host' }
|
||||
}
|
||||
const nodeId = toNodeId(rawNodeId)
|
||||
return traversePromotedWidgetChain(hostNode, nodeId, widgetName)
|
||||
}
|
||||
|
||||
export function buildPromotedSourceExecutionId(
|
||||
hostExecutionId: NodeExecutionId,
|
||||
nodePath: readonly NodeId[]
|
||||
): NodeExecutionId | undefined {
|
||||
const hostNodeIds = hostExecutionId.split(':').map(toNodeId)
|
||||
return nodePath.length
|
||||
? (createNodeExecutionId([...hostNodeIds, ...nodePath]) ?? undefined)
|
||||
: undefined
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import type { INodeInputSlot } from '@/lib/litegraph/src/interfaces'
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
|
||||
type SubgraphInputLinkContext = {
|
||||
inputNode: LGraphNode
|
||||
targetInput: INodeInputSlot
|
||||
getTargetWidget: () => ReturnType<LGraphNode['getWidgetFromSlot']>
|
||||
}
|
||||
|
||||
export function resolveSubgraphInputLink<TResult>(
|
||||
node: LGraphNode,
|
||||
inputName: string,
|
||||
resolve: (context: SubgraphInputLinkContext) => TResult | undefined
|
||||
): TResult | undefined {
|
||||
if (!node.isSubgraphNode()) return undefined
|
||||
|
||||
const inputSlot = node.subgraph.inputNode.slots.find(
|
||||
(slot) => slot.name === inputName
|
||||
)
|
||||
if (!inputSlot) return undefined
|
||||
|
||||
// Iterate forward so the first connected source is the promoted representative,
|
||||
// matching SubgraphNode._resolveLinkedPromotionBySubgraphInput.
|
||||
for (const linkId of inputSlot.linkIds) {
|
||||
const link = node.subgraph.getLink(linkId)
|
||||
if (!link) continue
|
||||
|
||||
const { inputNode, input: targetInput } = link.resolve(node.subgraph)
|
||||
if (!inputNode || !targetInput) continue
|
||||
|
||||
let cachedTargetWidget:
|
||||
| ReturnType<LGraphNode['getWidgetFromSlot']>
|
||||
| undefined
|
||||
let hasCachedTargetWidget = false
|
||||
|
||||
const resolved = resolve({
|
||||
inputNode,
|
||||
targetInput,
|
||||
getTargetWidget: () => {
|
||||
if (!hasCachedTargetWidget) {
|
||||
cachedTargetWidget = inputNode.getWidgetFromSlot(targetInput)
|
||||
hasCachedTargetWidget = true
|
||||
}
|
||||
return cachedTargetWidget
|
||||
}
|
||||
})
|
||||
if (resolved !== undefined) return resolved
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type { NodeId } from '@/types/nodeId'
|
||||
|
||||
import { resolveSubgraphInputLink } from './resolveSubgraphInputLink'
|
||||
|
||||
type ResolvedSubgraphInputTarget = {
|
||||
nodeId: NodeId
|
||||
widgetName: string
|
||||
}
|
||||
|
||||
export function resolveSubgraphInputTarget(
|
||||
node: LGraphNode,
|
||||
inputName: string
|
||||
): ResolvedSubgraphInputTarget | undefined {
|
||||
return resolveSubgraphInputLink(
|
||||
node,
|
||||
inputName,
|
||||
({ inputNode, targetInput, getTargetWidget }) => {
|
||||
if (inputNode.isSubgraphNode()) {
|
||||
return {
|
||||
nodeId: inputNode.id,
|
||||
widgetName: targetInput.name
|
||||
}
|
||||
}
|
||||
|
||||
const targetWidget = getTargetWidget()
|
||||
if (!targetWidget) return undefined
|
||||
|
||||
return {
|
||||
nodeId: inputNode.id,
|
||||
widgetName: targetWidget.name
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,706 @@
|
||||
import { remove } from 'es-toolkit'
|
||||
import { shallowReactive } from 'vue'
|
||||
|
||||
import { useChainCallback } from '@/composables/functional/useChainCallback'
|
||||
import type { ISlotType, INodeInputSlot } from '@/lib/litegraph/src/interfaces'
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
|
||||
import type { LLink } from '@/lib/litegraph/src/LLink'
|
||||
import { commonType } from '@/lib/litegraph/src/utils/type'
|
||||
import {
|
||||
getWidgetIds,
|
||||
resolveNodeRootGraphId
|
||||
} from '@/lib/litegraph/src/utils/widget'
|
||||
import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration'
|
||||
import type { ComboInputSpec, InputSpec } from '@/schemas/nodeDefSchema'
|
||||
import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import {
|
||||
zAutogrowOptions,
|
||||
zDynamicComboInputSpec,
|
||||
zMatchTypeOptions
|
||||
} from '@/schemas/nodeDefSchema'
|
||||
import { useLitegraphService } from '@/services/litegraphService'
|
||||
import { app } from '@/scripts/app'
|
||||
import type { ComfyApp } from '@/scripts/app'
|
||||
import {
|
||||
captureInputLayout,
|
||||
replaceNodeInputs
|
||||
} from '@/lib/litegraph/src/node/slotLinks'
|
||||
import type { InputLayoutSnapshot } from '@/lib/litegraph/src/node/slotLinks'
|
||||
import { useLinkStore } from '@/stores/linkStore'
|
||||
import { graphScopeOf } from '@/types/graphScopeId'
|
||||
import { useWidgetValueStore } from '@/stores/widgetValueStore'
|
||||
import type { WidgetValue } from '@/types/simplifiedWidget'
|
||||
import { widgetId } from '@/types/widgetId'
|
||||
|
||||
const INLINE_INPUTS = false
|
||||
|
||||
type MatchTypeNode = LGraphNode &
|
||||
Pick<Required<LGraphNode>, 'onConnectionsChange'> & {
|
||||
comfyDynamic: { matchType: Record<string, Record<string, string>> }
|
||||
}
|
||||
type AutogrowNode = LGraphNode &
|
||||
Pick<Required<LGraphNode>, 'onConnectionsChange' | 'widgets'> & {
|
||||
comfyDynamic: {
|
||||
autogrow: Record<
|
||||
string,
|
||||
{
|
||||
min: number
|
||||
max: number
|
||||
inputSpecs: InputSpecV2[]
|
||||
prefix?: string
|
||||
names?: string[]
|
||||
}
|
||||
>
|
||||
}
|
||||
}
|
||||
|
||||
function commitMutatedInputs(
|
||||
node: LGraphNode,
|
||||
previous: InputLayoutSnapshot,
|
||||
assignments: ReadonlyMap<INodeInputSlot, LLink>
|
||||
) {
|
||||
const finalInputs = [...node.inputs]
|
||||
node.inputs.splice(0, node.inputs.length, ...previous.inputs)
|
||||
return replaceNodeInputs(node, previous, finalInputs, assignments)
|
||||
}
|
||||
|
||||
function syncNodeWidgetOrder(node: LGraphNode) {
|
||||
const graphId = resolveNodeRootGraphId(node)
|
||||
if (!graphId || !node.widgets) return
|
||||
useWidgetValueStore().setNodeWidgetOrder(
|
||||
graphId,
|
||||
node.id,
|
||||
getWidgetIds(node.widgets)
|
||||
)
|
||||
}
|
||||
|
||||
function ensureWidgetForInput(node: LGraphNode, input: INodeInputSlot) {
|
||||
node.widgets ??= []
|
||||
const { widget } = input
|
||||
if (widget && node.widgets.some((w) => w.name === widget.name)) return
|
||||
node.widgets.push({
|
||||
draw(ctx, _n, _w, y) {
|
||||
ctx.save()
|
||||
ctx.fillStyle = LiteGraph.NODE_TEXT_COLOR
|
||||
ctx.fillText(input.label ?? input.name, 20, y + 15)
|
||||
ctx.restore()
|
||||
},
|
||||
name: input.name,
|
||||
options: {},
|
||||
serialize: false,
|
||||
type: 'shim',
|
||||
y: 0
|
||||
})
|
||||
input.alwaysVisible = true
|
||||
input.widget = { name: input.name }
|
||||
}
|
||||
|
||||
function dynamicComboWidget(
|
||||
node: LGraphNode,
|
||||
inputName: string,
|
||||
untypedInputData: InputSpec,
|
||||
appArg: ComfyApp,
|
||||
widgetName?: string
|
||||
) {
|
||||
const { addNodeInput } = useLitegraphService()
|
||||
const { deleteWidget } = useWidgetValueStore()
|
||||
const parseResult = zDynamicComboInputSpec.safeParse(untypedInputData)
|
||||
if (!parseResult.success) throw new Error('invalid DynamicCombo spec')
|
||||
const inputData = parseResult.data
|
||||
const options = Object.fromEntries(
|
||||
inputData[1].options.map(({ key, inputs }) => [key, inputs])
|
||||
)
|
||||
const subSpec: ComboInputSpec = [Object.keys(options), {}]
|
||||
const { widget, minWidth, minHeight } = app.widgets['COMBO'](
|
||||
node,
|
||||
inputName,
|
||||
subSpec,
|
||||
appArg,
|
||||
widgetName
|
||||
)
|
||||
const removedWidgetValues = new Map<
|
||||
string | undefined,
|
||||
Map<string, { type: string; value: WidgetValue }>
|
||||
>()
|
||||
let activeOption = widget.value as string | undefined
|
||||
function isInGroup(e: { name: string }): boolean {
|
||||
return e.name.startsWith(inputName + '.')
|
||||
}
|
||||
function restoreRemovedValues(
|
||||
value: string | undefined,
|
||||
widgetNames: string[]
|
||||
) {
|
||||
const widgets = node.widgets
|
||||
if (!widgets) return
|
||||
const graphId = resolveNodeRootGraphId(node)
|
||||
const removedValues = removedWidgetValues.get(value)
|
||||
const names = new Set(widgetNames)
|
||||
for (const name of removedValues?.keys() ?? []) names.add(name)
|
||||
for (const name of names) {
|
||||
const addedWidget = widgets.find((widget) => widget.name === name)
|
||||
if (!addedWidget) continue
|
||||
const removed = removedValues?.get(name)
|
||||
const positionalIndex = widgets
|
||||
.filter((widget) => widget.serialize !== false)
|
||||
.indexOf(addedWidget)
|
||||
const restored =
|
||||
graphId && positionalIndex >= 0
|
||||
? useWidgetValueStore().getRestoredWidgetValue(
|
||||
graphId,
|
||||
node.id,
|
||||
name,
|
||||
positionalIndex
|
||||
)
|
||||
: undefined
|
||||
if (!restored && removed?.type === addedWidget.type) {
|
||||
addedWidget.value = removed.value
|
||||
}
|
||||
}
|
||||
}
|
||||
const updateWidgets = (value?: string) => {
|
||||
if (!node.widgets) throw new Error('Not Reachable')
|
||||
const newSpec = value ? options[value] : undefined
|
||||
const removedOption = activeOption
|
||||
activeOption = value
|
||||
|
||||
const previous = captureInputLayout(node)
|
||||
const inputLinks = new Map(previous.links)
|
||||
const removedInputs = remove(node.inputs, isInGroup)
|
||||
for (const widget of remove(node.widgets, isInGroup)) {
|
||||
const optionValues = removedWidgetValues.get(removedOption) ?? new Map()
|
||||
optionValues.set(widget.name, {
|
||||
type: widget.type,
|
||||
value: widget.value
|
||||
})
|
||||
removedWidgetValues.set(removedOption, optionValues)
|
||||
widget.onRemove?.()
|
||||
if (widget.widgetId) deleteWidget(widget.widgetId)
|
||||
}
|
||||
|
||||
if (!newSpec) {
|
||||
const result = commitMutatedInputs(node, previous, inputLinks)
|
||||
if (!result.ok) return
|
||||
syncNodeWidgetOrder(node)
|
||||
return
|
||||
}
|
||||
|
||||
const insertionPoint = node.widgets.findIndex((w) => w === widget) + 1
|
||||
const startingLength = node.widgets.length
|
||||
const startingInputLength = node.inputs.length
|
||||
|
||||
if (insertionPoint === 0)
|
||||
throw new Error("Dynamic widget doesn't exist on node")
|
||||
const inputTypes: (Record<string, InputSpec> | undefined)[] = [
|
||||
newSpec.required,
|
||||
newSpec.optional
|
||||
]
|
||||
inputTypes.forEach((inputType, idx) => {
|
||||
for (const key in inputType ?? {}) {
|
||||
const name = `${widget.name}.${key}`
|
||||
const specToAdd = transformInputSpecV1ToV2(inputType![key], {
|
||||
name,
|
||||
isOptional: idx !== 0
|
||||
})
|
||||
specToAdd.display_name = key
|
||||
addNodeInput(node, specToAdd)
|
||||
const newInputs = node.inputs
|
||||
.slice(startingInputLength)
|
||||
.filter((inp) => inp.name.startsWith(name))
|
||||
for (const newInput of newInputs) {
|
||||
if (INLINE_INPUTS && !newInput.widget)
|
||||
ensureWidgetForInput(node, newInput)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const inputInsertionPoint =
|
||||
node.inputs.findIndex((i) => i.name === widget.name) + 1
|
||||
const addedWidgets = node.widgets.splice(startingLength)
|
||||
const addedWidgetNames = addedWidgets.map(({ name }) => name)
|
||||
node.widgets.splice(insertionPoint, 0, ...addedWidgets)
|
||||
syncNodeWidgetOrder(node)
|
||||
if (inputInsertionPoint === 0) {
|
||||
if (
|
||||
addedWidgets.length === 0 &&
|
||||
node.inputs.length !== startingInputLength
|
||||
)
|
||||
//input is inputOnly, but lacks an insertion point
|
||||
throw new Error('Failed to find input socket for ' + widget.name)
|
||||
const result = commitMutatedInputs(node, previous, inputLinks)
|
||||
if (!result.ok) return
|
||||
restoreRemovedValues(value, addedWidgetNames)
|
||||
return
|
||||
}
|
||||
const addedInputs = node.inputs
|
||||
.splice(startingInputLength)
|
||||
.map((addedInput) => {
|
||||
const existingInput = node.inputs.findIndex(
|
||||
(existingInput) => addedInput.name === existingInput.name
|
||||
)
|
||||
return existingInput === -1
|
||||
? addedInput
|
||||
: node.inputs.splice(existingInput, 1)[0]
|
||||
})
|
||||
//assume existing inputs are in correct order
|
||||
node.inputs.splice(inputInsertionPoint, 0, ...addedInputs)
|
||||
|
||||
for (const input of removedInputs) {
|
||||
const replacement = node.inputs.find((item) => item.name === input.name)
|
||||
const link = inputLinks.get(input)
|
||||
if (replacement && link) inputLinks.set(replacement, link)
|
||||
}
|
||||
const result = commitMutatedInputs(node, previous, inputLinks)
|
||||
if (!result.ok) return
|
||||
for (const { input, link, slot } of result.replacements) {
|
||||
node.onConnectionsChange?.(LiteGraph.INPUT, slot, true, link, input)
|
||||
}
|
||||
restoreRemovedValues(value, addedWidgetNames)
|
||||
|
||||
if (!node.graph) return
|
||||
node._setConcreteSlots()
|
||||
node.arrange()
|
||||
app.canvas?.setDirty(true, true)
|
||||
}
|
||||
//Refit height on the callback channel: interaction fires it after the value
|
||||
//setter, while configure (load, clone, paste) only fires the setter and must
|
||||
//keep the serialised height.
|
||||
widget.callback = useChainCallback(widget.callback, () => {
|
||||
node.size = [node.size[0], node.computeSize([...node.size])[1]]
|
||||
app.canvas?.setDirty(true, true)
|
||||
})
|
||||
//A little hacky, but onConfigure won't work.
|
||||
//It fires too late and is overly disruptive
|
||||
let widgetValue = widget.value
|
||||
const getState = () => {
|
||||
const graphId = resolveNodeRootGraphId(node)
|
||||
if (!graphId) return undefined
|
||||
return useWidgetValueStore().getWidget(
|
||||
widgetId(graphId, node.id, widget.name)
|
||||
)
|
||||
}
|
||||
Object.defineProperty(widget, 'value', {
|
||||
get() {
|
||||
return getState()?.value ?? widgetValue
|
||||
},
|
||||
set(value) {
|
||||
const state = getState()
|
||||
if (state) state.value = value
|
||||
widgetValue = value
|
||||
updateWidgets(value)
|
||||
}
|
||||
})
|
||||
widget.value = widgetValue
|
||||
return { widget, minWidth, minHeight }
|
||||
}
|
||||
|
||||
export const dynamicWidgets = { COMFY_DYNAMICCOMBO_V3: dynamicComboWidget }
|
||||
const dynamicInputs: Record<
|
||||
string,
|
||||
(node: LGraphNode, inputSpec: InputSpecV2) => void
|
||||
> = {
|
||||
COMFY_AUTOGROW_V3: applyAutogrow,
|
||||
COMFY_MATCHTYPE_V3: applyMatchType
|
||||
}
|
||||
|
||||
export function applyDynamicInputs(
|
||||
node: LGraphNode,
|
||||
inputSpec: InputSpecV2
|
||||
): boolean {
|
||||
if (!(inputSpec.type in dynamicInputs)) return false
|
||||
//TODO: move parsing/validation of inputSpec here?
|
||||
dynamicInputs[inputSpec.type](node, inputSpec)
|
||||
return true
|
||||
}
|
||||
|
||||
function changeOutputType(
|
||||
node: LGraphNode,
|
||||
slot: number,
|
||||
combinedType: ISlotType
|
||||
) {
|
||||
const output = node.outputs[slot]
|
||||
if (output.type === combinedType) return
|
||||
output.type = combinedType
|
||||
|
||||
//check and potentially remove links
|
||||
if (!node.graph) return
|
||||
const topologies = useLinkStore().getOutputSlotLinks(
|
||||
graphScopeOf(node.graph),
|
||||
node.id,
|
||||
slot
|
||||
)
|
||||
for (const topology of topologies) {
|
||||
const link = node.graph.getLink(topology.id)
|
||||
if (!link) continue
|
||||
const { input, inputNode, subgraphOutput } = link.resolve(node.graph)
|
||||
const inputType = (input ?? subgraphOutput)?.type
|
||||
if (!inputType) continue
|
||||
const keep = LiteGraph.isValidConnection(combinedType, inputType)
|
||||
if (!keep && subgraphOutput) subgraphOutput.disconnect()
|
||||
else if (!keep && inputNode) inputNode.disconnectInput(link.target_slot)
|
||||
if (input && inputNode?.onConnectionsChange)
|
||||
inputNode.onConnectionsChange(
|
||||
LiteGraph.INPUT,
|
||||
link.target_slot,
|
||||
keep,
|
||||
link,
|
||||
input
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function withComfyMatchType(node: LGraphNode): asserts node is MatchTypeNode {
|
||||
if (node.comfyDynamic?.matchType) return
|
||||
node.comfyDynamic ??= {}
|
||||
node.comfyDynamic.matchType = {}
|
||||
|
||||
const outputGroups = node.constructor.nodeData?.output_matchtypes
|
||||
node.onConnectionsChange = useChainCallback(
|
||||
node.onConnectionsChange,
|
||||
function (
|
||||
this: MatchTypeNode,
|
||||
contype: ISlotType,
|
||||
slot: number,
|
||||
iscon: boolean,
|
||||
linf: LLink | null | undefined
|
||||
) {
|
||||
const input = this.inputs[slot]
|
||||
if (contype !== LiteGraph.INPUT || !this.graph || !input) return
|
||||
if (app.configuringGraph) return
|
||||
const [matchKey, matchGroup] = Object.entries(
|
||||
this.comfyDynamic.matchType
|
||||
).find(([, group]) => input.name in group) ?? ['', undefined]
|
||||
if (!matchGroup) return
|
||||
if (iscon && linf) {
|
||||
const { output, subgraphInput } = linf.resolve(this.graph)
|
||||
const connectingType = (output ?? subgraphInput)?.type
|
||||
if (connectingType) linf.type = connectingType
|
||||
}
|
||||
//NOTE: inputs contains input
|
||||
const groupInputs: INodeInputSlot[] = node.inputs.filter(
|
||||
(inp) => inp.name in matchGroup
|
||||
)
|
||||
const connectedTypes = groupInputs.map((inp) => {
|
||||
const link = this.getInputLink(this.inputs.indexOf(inp))
|
||||
if (!link) return '*'
|
||||
const { output, subgraphInput } = link.resolve(this.graph!)
|
||||
return (output ?? subgraphInput)?.type ?? '*'
|
||||
})
|
||||
//An input slot can accept a connection that is
|
||||
// - Compatible with original type
|
||||
// - Compatible with all other input types
|
||||
//An output slot can output
|
||||
// - Only what every input can output
|
||||
groupInputs.forEach((input, idx) => {
|
||||
const otherConnected = [
|
||||
...connectedTypes.slice(0, idx),
|
||||
...connectedTypes.slice(idx + 1)
|
||||
]
|
||||
const combinedType = commonType(
|
||||
...otherConnected,
|
||||
matchGroup[input.name]
|
||||
)
|
||||
if (!combinedType) throw new Error('invalid connection')
|
||||
input.type = combinedType
|
||||
})
|
||||
const outputType = commonType(...connectedTypes)
|
||||
if (!outputType) throw new Error('invalid connection')
|
||||
this.outputs.forEach((_output, idx) => {
|
||||
if (!(outputGroups?.[idx] == matchKey)) return
|
||||
changeOutputType(this, idx, outputType)
|
||||
})
|
||||
app.canvas?.setDirty(true, true)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function applyMatchType(node: LGraphNode, inputSpec: InputSpecV2) {
|
||||
const { addNodeInput } = useLitegraphService()
|
||||
const name = inputSpec.name
|
||||
const parseResult = zMatchTypeOptions.safeParse(inputSpec)
|
||||
if (!parseResult.success) {
|
||||
console.warn(
|
||||
`Unparseable COMFY_MATCHTYPE_V3 spec for input "${name}"; falling back to a wildcard socket.`,
|
||||
parseResult.error.issues
|
||||
)
|
||||
addNodeInput(node, { ...inputSpec, type: '*' })
|
||||
return
|
||||
}
|
||||
const matchTypeSpec = parseResult.data
|
||||
|
||||
const { allowed_types, template_id } = matchTypeSpec.template
|
||||
const typedSpec = { ...inputSpec, type: allowed_types }
|
||||
addNodeInput(node, typedSpec)
|
||||
withComfyMatchType(node)
|
||||
node.comfyDynamic.matchType[template_id] ??= {}
|
||||
node.comfyDynamic.matchType[template_id][name] = allowed_types
|
||||
|
||||
//TODO: instead apply on output add?
|
||||
//ensure outputs get updated
|
||||
const index = node.inputs.length - 1
|
||||
requestAnimationFrame(() => {
|
||||
const input = node.inputs[index]
|
||||
if (!input || !node.graph) return
|
||||
node.inputs[index] = shallowReactive(input)
|
||||
const existingLink = node.getInputLink(index)
|
||||
node.onConnectionsChange?.(
|
||||
LiteGraph.INPUT,
|
||||
index,
|
||||
!!existingLink,
|
||||
existingLink ?? undefined,
|
||||
input
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function autogrowOrdinalToName(
|
||||
ordinal: number,
|
||||
key: string,
|
||||
groupName: string,
|
||||
node: AutogrowNode
|
||||
) {
|
||||
const {
|
||||
names,
|
||||
prefix = '',
|
||||
inputSpecs
|
||||
} = node.comfyDynamic.autogrow[groupName]
|
||||
const baseName = names
|
||||
? names[ordinal]
|
||||
: (inputSpecs.length == 1 ? prefix : key) + ordinal
|
||||
return { name: `${groupName}.${baseName}`, display_name: baseName }
|
||||
}
|
||||
|
||||
function addAutogrowGroup(
|
||||
ordinal: number,
|
||||
groupName: string,
|
||||
node: AutogrowNode
|
||||
) {
|
||||
const { addNodeInput } = useLitegraphService()
|
||||
const { max, min, inputSpecs } = node.comfyDynamic.autogrow[groupName]
|
||||
if (ordinal >= max) return
|
||||
|
||||
const previous = captureInputLayout(node)
|
||||
const inputLinks = new Map(previous.links)
|
||||
const namedSpecs = inputSpecs.map((input) => ({
|
||||
...input,
|
||||
isOptional: ordinal >= (min ?? 0) || input.isOptional,
|
||||
...autogrowOrdinalToName(ordinal, input.name, groupName, node)
|
||||
}))
|
||||
|
||||
const newInputs = namedSpecs.map((namedSpec) => {
|
||||
addNodeInput(node, namedSpec)
|
||||
const input = node.inputs.splice(node.inputs.length - 1, 1)[0]
|
||||
if (inputSpecs.length !== 1 || (INLINE_INPUTS && !input.widget))
|
||||
ensureWidgetForInput(node, input)
|
||||
return input
|
||||
})
|
||||
|
||||
for (const newInput of newInputs) {
|
||||
for (const existingInput of remove(
|
||||
node.inputs,
|
||||
(inp) => inp.name === newInput.name
|
||||
)) {
|
||||
const link = inputLinks.get(existingInput)
|
||||
if (link && !inputLinks.has(newInput)) inputLinks.set(newInput, link)
|
||||
}
|
||||
}
|
||||
|
||||
const targetName = autogrowOrdinalToName(
|
||||
ordinal - 1,
|
||||
inputSpecs.at(-1)!.name,
|
||||
groupName,
|
||||
node
|
||||
).name
|
||||
const lastIndex = node.inputs.findLastIndex((inp) =>
|
||||
inp.name.startsWith(targetName)
|
||||
)
|
||||
const insertionIndex = lastIndex === -1 ? node.inputs.length : lastIndex + 1
|
||||
node.inputs.splice(insertionIndex, 0, ...newInputs)
|
||||
const result = commitMutatedInputs(node, previous, inputLinks)
|
||||
if (!result.ok) return
|
||||
app.canvas?.setDirty(true, true)
|
||||
}
|
||||
|
||||
const ORDINAL_REGEX = /\d+$/
|
||||
function resolveAutogrowOrdinal(
|
||||
inputName: string,
|
||||
groupName: string,
|
||||
node: AutogrowNode
|
||||
): number | undefined {
|
||||
//TODO preslice groupname?
|
||||
const name = inputName.slice(groupName.length + 1)
|
||||
const { names } = node.comfyDynamic.autogrow[groupName]
|
||||
if (names) {
|
||||
const ordinal = names.findIndex((s) => s === name)
|
||||
return ordinal === -1 ? undefined : ordinal
|
||||
}
|
||||
const match = name.match(ORDINAL_REGEX)
|
||||
if (!match) return undefined
|
||||
const ordinal = parseInt(match[0])
|
||||
return ordinal !== ordinal ? undefined : ordinal
|
||||
}
|
||||
function autogrowInputConnected(index: number, node: AutogrowNode) {
|
||||
const input = node.inputs[index]
|
||||
const groupName = input.name.slice(0, input.name.lastIndexOf('.'))
|
||||
const lastInput = node.inputs.findLast((inp) =>
|
||||
inp.name.startsWith(groupName + '.')
|
||||
)
|
||||
const ordinal = resolveAutogrowOrdinal(input.name, groupName, node)
|
||||
if (
|
||||
!lastInput ||
|
||||
ordinal == undefined ||
|
||||
(ordinal !== resolveAutogrowOrdinal(lastInput.name, groupName, node) &&
|
||||
!app.configuringGraph)
|
||||
)
|
||||
return
|
||||
addAutogrowGroup(ordinal + 1, groupName, node)
|
||||
}
|
||||
function autogrowInputDisconnected(index: number, node: AutogrowNode) {
|
||||
const input = node.inputs[index]
|
||||
if (!input) return
|
||||
const groupName = input.name.slice(0, input.name.lastIndexOf('.'))
|
||||
const autogrowGroup = node.comfyDynamic.autogrow[groupName]
|
||||
if (!autogrowGroup) return
|
||||
|
||||
const { min = 1, inputSpecs } = autogrowGroup
|
||||
const ordinal = resolveAutogrowOrdinal(input.name, groupName, node)
|
||||
if (ordinal == undefined || ordinal + 1 < min) return
|
||||
|
||||
//resolve all inputs in group
|
||||
const groupInputs = node.inputs.filter(
|
||||
(inp) =>
|
||||
inp.name.startsWith(groupName + '.') &&
|
||||
inp.name.lastIndexOf('.') === groupName.length
|
||||
)
|
||||
const stride = inputSpecs.length
|
||||
if (stride + index >= node.inputs.length) return
|
||||
if (groupInputs.length % stride !== 0) {
|
||||
console.error('Failed to group multi-input autogrow inputs')
|
||||
return
|
||||
}
|
||||
app.canvas?.setDirty(true, true)
|
||||
const previous = captureInputLayout(node)
|
||||
const inputLinks = new Map(previous.links)
|
||||
const transplants: { input: INodeInputSlot; link: LLink }[] = []
|
||||
|
||||
for (let column = 0; column < stride; column++) {
|
||||
for (
|
||||
let bubbleOrdinal = ordinal * stride + column;
|
||||
bubbleOrdinal + stride < groupInputs.length;
|
||||
bubbleOrdinal += stride
|
||||
) {
|
||||
const input = groupInputs[bubbleOrdinal]
|
||||
const donor = groupInputs[bubbleOrdinal + stride]
|
||||
const link = inputLinks.get(donor)
|
||||
inputLinks.delete(input)
|
||||
inputLinks.delete(donor)
|
||||
if (link) {
|
||||
inputLinks.set(input, link)
|
||||
transplants.push({ input, link })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const removalChecks = groupInputs.slice(min * stride)
|
||||
let i
|
||||
for (i = removalChecks.length - stride; i >= 0; i -= stride) {
|
||||
if (
|
||||
removalChecks.slice(i, i + stride).some((input) => inputLinks.has(input))
|
||||
)
|
||||
break
|
||||
}
|
||||
const toRemove = removalChecks.slice(i + stride * 2)
|
||||
const finalInputs = node.inputs.filter((input) => !toRemove.includes(input))
|
||||
const result = replaceNodeInputs(node, previous, finalInputs, inputLinks)
|
||||
if (!result.ok) return
|
||||
|
||||
for (const { input, link } of transplants) {
|
||||
const slot = node.inputs.indexOf(input)
|
||||
if (slot === -1) continue
|
||||
node.onConnectionsChange?.(LiteGraph.INPUT, slot, true, link, input)
|
||||
}
|
||||
for (const input of toRemove) {
|
||||
const widgetName = input?.widget?.name
|
||||
if (!widgetName) continue
|
||||
for (const widget of remove(node.widgets, (w) => w.name === widgetName)) {
|
||||
widget.onRemove?.()
|
||||
if (widget.widgetId) useWidgetValueStore().deleteWidget(widget.widgetId)
|
||||
}
|
||||
syncNodeWidgetOrder(node)
|
||||
}
|
||||
node.size = [node.size[0], node.computeSize([...node.size])[1]]
|
||||
}
|
||||
|
||||
function withComfyAutogrow(node: LGraphNode): asserts node is AutogrowNode {
|
||||
if (node.comfyDynamic?.autogrow) return
|
||||
node.comfyDynamic ??= {}
|
||||
node.comfyDynamic.autogrow = {}
|
||||
|
||||
let pendingConnection: number | undefined
|
||||
let swappingConnection = false
|
||||
|
||||
const originalOnConnectInput = node.onConnectInput
|
||||
node.onConnectInput = function (slot: number, ...args) {
|
||||
pendingConnection = slot
|
||||
requestAnimationFrame(() => (pendingConnection = undefined))
|
||||
return originalOnConnectInput?.apply(this, [slot, ...args]) ?? true
|
||||
}
|
||||
|
||||
node.onConnectionsChange = useChainCallback(
|
||||
node.onConnectionsChange,
|
||||
function (
|
||||
this: AutogrowNode,
|
||||
contype: ISlotType,
|
||||
slot: number,
|
||||
iscon: boolean,
|
||||
linf: LLink | null | undefined
|
||||
) {
|
||||
const input = this.inputs[slot]
|
||||
if (contype !== LiteGraph.INPUT || !input) return
|
||||
//Return if input isn't known autogrow
|
||||
const key = input.name.slice(0, input.name.lastIndexOf('.'))
|
||||
const autogrowGroup = this.comfyDynamic.autogrow[key]
|
||||
if (!autogrowGroup) return
|
||||
if (app.configuringGraph && input.widget)
|
||||
ensureWidgetForInput(node, input)
|
||||
if (iscon) {
|
||||
if (swappingConnection || !linf) return
|
||||
autogrowInputConnected(slot, this)
|
||||
} else {
|
||||
if (pendingConnection === slot) {
|
||||
swappingConnection = true
|
||||
requestAnimationFrame(() => (swappingConnection = false))
|
||||
return
|
||||
}
|
||||
requestAnimationFrame(() => autogrowInputDisconnected(slot, this))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
function applyAutogrow(node: LGraphNode, inputSpecV2: InputSpecV2) {
|
||||
withComfyAutogrow(node)
|
||||
|
||||
const parseResult = zAutogrowOptions.safeParse(inputSpecV2)
|
||||
if (!parseResult.success) throw new Error('invalid Autogrow spec')
|
||||
const inputSpec = parseResult.data
|
||||
const { input, min = 1, names, prefix, max = 100 } = inputSpec.template
|
||||
|
||||
const inputTypes: (Record<string, InputSpec> | undefined)[] = [
|
||||
input.required,
|
||||
input.optional
|
||||
]
|
||||
const inputsV2 = inputTypes.flatMap((inputType, index) =>
|
||||
Object.entries(inputType ?? {}).map(([name, v]) =>
|
||||
transformInputSpecV1ToV2(v, { name, isOptional: index === 1 })
|
||||
)
|
||||
)
|
||||
node.comfyDynamic.autogrow[inputSpecV2.name] = {
|
||||
names,
|
||||
min,
|
||||
max: names?.length ?? max,
|
||||
prefix,
|
||||
inputSpecs: inputsV2
|
||||
}
|
||||
for (let i = 0; i === 0 || i < min + 1; i++)
|
||||
addAutogrowGroup(i, inputSpecV2.name, node)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Preview Any - original implement from
|
||||
https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
|
||||
upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes
|
||||
*/
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import {
|
||||
addTextPreviewWidgets,
|
||||
updateTextPreviewWidgets
|
||||
} from '@/extensions/core/textPreviewWidgets'
|
||||
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useExtensionService } from '@/services/extensionService'
|
||||
import { getNodeByLocatorId } from '@/utils/graphTraversalUtil'
|
||||
|
||||
useExtensionService().registerExtension({
|
||||
name: 'Comfy.PreviewAny',
|
||||
async beforeRegisterNodeDef(
|
||||
nodeType: typeof LGraphNode,
|
||||
nodeData: ComfyNodeDef
|
||||
) {
|
||||
if (nodeData.name !== 'PreviewAny') return
|
||||
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
onNodeCreated?.apply(this, [])
|
||||
addTextPreviewWidgets(this)
|
||||
}
|
||||
|
||||
const onExecuted = nodeType.prototype.onExecuted
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
onExecuted?.apply(this, [message])
|
||||
updateTextPreviewWidgets(this, message)
|
||||
}
|
||||
},
|
||||
onNodeOutputsUpdated(nodeOutputs) {
|
||||
for (const [nodeLocatorId, output] of Object.entries(nodeOutputs)) {
|
||||
const node = getNodeByLocatorId(app.rootGraph, nodeLocatorId)
|
||||
if (node?.type === 'PreviewAny') updateTextPreviewWidgets(node, output)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
import { applyTextReplacements } from '@/utils/searchAndReplace'
|
||||
|
||||
import { app } from '../../scripts/app'
|
||||
|
||||
const saveNodeTypes = new Set([
|
||||
'SaveImage',
|
||||
'SaveImageAdvanced',
|
||||
'SaveSVGNode',
|
||||
'SaveVideo',
|
||||
'SaveAnimatedWEBP',
|
||||
'SaveWEBM',
|
||||
'SaveAudio',
|
||||
'SaveAudioMP3',
|
||||
'SaveAudioOpus',
|
||||
'SaveAudioAdvanced',
|
||||
'SaveGLB',
|
||||
'Save3DAdvanced',
|
||||
'SaveGaussianSplat',
|
||||
'SavePointCloud',
|
||||
'SaveAnimatedPNG',
|
||||
'CLIPSave',
|
||||
'VAESave',
|
||||
'ModelSave',
|
||||
'LoraSave',
|
||||
'SaveLatent'
|
||||
])
|
||||
|
||||
// Use widget values and dates in output filenames
|
||||
|
||||
app.registerExtension({
|
||||
name: 'Comfy.SaveImageExtraOutput',
|
||||
async beforeRegisterNodeDef(
|
||||
nodeType: typeof LGraphNode,
|
||||
nodeData: ComfyNodeDef
|
||||
) {
|
||||
if (saveNodeTypes.has(nodeData.name)) {
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||
// When the SaveImage node is created we want to override the serialization of the output name widget to run our S&R
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated
|
||||
? // @ts-expect-error fixme ts strict error
|
||||
onNodeCreated.apply(this, arguments)
|
||||
: undefined
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
const widget = this.widgets.find((w) => w.name === 'filename_prefix')
|
||||
// @ts-expect-error fixme ts strict error
|
||||
widget.serializeValue = () => {
|
||||
// @ts-expect-error fixme ts strict error
|
||||
return applyTextReplacements(app.graph, widget.value)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
} else {
|
||||
// When any other node is created add a property to alias the node
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated
|
||||
? // @ts-expect-error fixme ts strict error
|
||||
onNodeCreated.apply(this, arguments)
|
||||
: undefined
|
||||
|
||||
if (!this.properties || !('Node name for S&R' in this.properties)) {
|
||||
this.addProperty('Node name for S&R', this.constructor.type, 'string')
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,85 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import { resolveNodeRootGraphId } from '@/lib/litegraph/src/litegraph'
|
||||
import WidgetTextPreview from '@/renderer/extensions/vueNodes/widgets/components/WidgetTextPreview.vue'
|
||||
import type { NodeExecutionOutput } from '@/schemas/apiSchema'
|
||||
import type { CustomInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import { app } from '@/scripts/app'
|
||||
import { ComponentWidgetImpl, addWidget } from '@/scripts/domWidget'
|
||||
import { ComfyWidgets } from '@/scripts/widgets'
|
||||
import { useWidgetValueStore } from '@/stores/widgetValueStore'
|
||||
import { widgetId } from '@/types/widgetId'
|
||||
|
||||
const PREVIEW_WIDGET_NAME = 'preview_text'
|
||||
const MODE_WIDGET_NAME = 'preview_mode'
|
||||
|
||||
const inputSpecTextPreview: CustomInputSpec = {
|
||||
name: PREVIEW_WIDGET_NAME,
|
||||
type: 'TEXT_PREVIEW',
|
||||
isPreview: true
|
||||
}
|
||||
|
||||
export function addTextPreviewWidgets(node: LGraphNode) {
|
||||
const widgetStore = useWidgetValueStore()
|
||||
let fallbackValue = ''
|
||||
|
||||
const previewWidgetId = () =>
|
||||
widgetId(
|
||||
resolveNodeRootGraphId(node, app.rootGraph.id),
|
||||
node.id,
|
||||
PREVIEW_WIDGET_NAME
|
||||
)
|
||||
|
||||
const preview = new ComponentWidgetImpl<string | object>({
|
||||
node,
|
||||
name: PREVIEW_WIDGET_NAME,
|
||||
component: WidgetTextPreview,
|
||||
inputSpec: inputSpecTextPreview,
|
||||
type: 'textPreview',
|
||||
options: {
|
||||
serialize: false,
|
||||
hideInPanel: true,
|
||||
getMinHeight: () => 60,
|
||||
getValue: () => {
|
||||
const stored = widgetStore.getWidget(previewWidgetId())?.value
|
||||
return typeof stored === 'string' ? stored : fallbackValue
|
||||
},
|
||||
setValue: (value: string | object) => {
|
||||
fallbackValue = typeof value === 'string' ? value : ''
|
||||
const state = widgetStore.getWidget(previewWidgetId())
|
||||
if (state) state.value = fallbackValue
|
||||
}
|
||||
}
|
||||
})
|
||||
preview.serialize = false
|
||||
addWidget(node, preview)
|
||||
|
||||
const modeWidget = ComfyWidgets['BOOLEAN'](
|
||||
node,
|
||||
MODE_WIDGET_NAME,
|
||||
[
|
||||
'BOOLEAN',
|
||||
{ label_on: 'Markdown', label_off: 'Plain text', default: false }
|
||||
],
|
||||
app
|
||||
).widget
|
||||
|
||||
modeWidget.options.serialize = false
|
||||
modeWidget.serialize = false
|
||||
}
|
||||
|
||||
function toPreviewText(text: unknown): string {
|
||||
if (text == null) return ''
|
||||
if (Array.isArray(text))
|
||||
return text.filter((part) => part != null).join('\n\n')
|
||||
return String(text)
|
||||
}
|
||||
|
||||
export function updateTextPreviewWidgets(
|
||||
node: LGraphNode,
|
||||
message: NodeExecutionOutput | null | undefined
|
||||
) {
|
||||
const preview = node.widgets?.find((w) => w.name === PREVIEW_WIDGET_NAME)
|
||||
if (!preview) return
|
||||
|
||||
preview.value = toPreviewText(message?.text)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import {
|
||||
type ComfyNodeDef,
|
||||
type InputSpec,
|
||||
isMediaUploadComboInput
|
||||
} from '@/schemas/nodeDefSchema'
|
||||
|
||||
import { app } from '../../scripts/app'
|
||||
|
||||
// Adds an upload button to the nodes
|
||||
|
||||
const createUploadInput = (
|
||||
imageInputName: string,
|
||||
imageInputOptions: InputSpec
|
||||
): InputSpec => [
|
||||
'IMAGEUPLOAD',
|
||||
{
|
||||
...imageInputOptions[1],
|
||||
imageInputName
|
||||
}
|
||||
]
|
||||
|
||||
app.registerExtension({
|
||||
name: 'Comfy.UploadImage',
|
||||
beforeRegisterNodeDef(_nodeType: typeof LGraphNode, 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)
|
||||
}
|
||||
}
|
||||
})
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type { INumericWidget } from '@/lib/litegraph/src/types/widgets'
|
||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||
import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import { isIntInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
|
||||
import { addValueControlWidget } from '@/scripts/widgets'
|
||||
import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration'
|
||||
|
||||
function onValueChange(this: INumericWidget, v: number) {
|
||||
// For integers, always round to the nearest step
|
||||
// step === 0 is invalid, assign 1 if options.step is 0
|
||||
const step = this.options.step2 || 1
|
||||
|
||||
if (step === 1) {
|
||||
// Simple case: round to nearest integer
|
||||
this.value = Math.round(v)
|
||||
} else {
|
||||
// Round to nearest multiple of step
|
||||
// First, determine if min value creates an offset
|
||||
const min = this.options.min ?? 0
|
||||
const offset = min % step
|
||||
|
||||
// Round to nearest step, accounting for offset
|
||||
this.value = Math.round((v - offset) / step) * step + offset
|
||||
}
|
||||
}
|
||||
|
||||
export const _for_testing = {
|
||||
onValueChange
|
||||
}
|
||||
|
||||
export const useIntWidget = () => {
|
||||
const widgetConstructor: ComfyWidgetConstructorV2 = (
|
||||
node: LGraphNode,
|
||||
inputSpec: InputSpec
|
||||
) => {
|
||||
if (!isIntInputSpec(inputSpec)) {
|
||||
throw new Error(`Invalid input data: ${inputSpec}`)
|
||||
}
|
||||
|
||||
const settingStore = useSettingStore()
|
||||
const sliderEnabled = !settingStore.get('Comfy.DisableSliders')
|
||||
const display_type = inputSpec.display
|
||||
const widgetType =
|
||||
sliderEnabled && display_type == 'slider'
|
||||
? 'slider'
|
||||
: display_type == 'knob'
|
||||
? 'knob'
|
||||
: 'number'
|
||||
|
||||
const step = inputSpec.step ?? 1
|
||||
/** Assertion {@link inputSpec.default} */
|
||||
const defaultValue = (inputSpec.default as number | undefined) ?? 0
|
||||
const widget = node.addWidget(
|
||||
widgetType,
|
||||
inputSpec.name,
|
||||
defaultValue,
|
||||
onValueChange,
|
||||
{
|
||||
min: inputSpec.min ?? 0,
|
||||
max: inputSpec.max ?? 2048,
|
||||
/** @deprecated Use step2 instead. The 10x value is a legacy implementation. */
|
||||
step: step * 10,
|
||||
step2: step,
|
||||
precision: 0
|
||||
}
|
||||
)
|
||||
|
||||
const controlAfterGenerate =
|
||||
inputSpec.control_after_generate ??
|
||||
['seed', 'noise_seed'].includes(inputSpec.name)
|
||||
|
||||
if (controlAfterGenerate) {
|
||||
const defaultType =
|
||||
typeof inputSpec.control_after_generate === 'string'
|
||||
? inputSpec.control_after_generate
|
||||
: 'randomize'
|
||||
const controlWidget = addValueControlWidget(
|
||||
node,
|
||||
widget,
|
||||
defaultType,
|
||||
undefined,
|
||||
undefined,
|
||||
transformInputSpecV2ToV1(inputSpec)
|
||||
)
|
||||
widget.linkedWidgets = [controlWidget]
|
||||
}
|
||||
|
||||
return widget
|
||||
}
|
||||
return widgetConstructor
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type {
|
||||
IResolutionPreviewWidget,
|
||||
IWidgetResolutionPreviewOptions
|
||||
} from '@/lib/litegraph/src/types/widgets'
|
||||
import { isResolutionPreviewInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
|
||||
|
||||
export const useResolutionPreviewWidget = (): ComfyWidgetConstructorV2 => {
|
||||
return (
|
||||
node: LGraphNode,
|
||||
inputSpec: InputSpecV2
|
||||
): IResolutionPreviewWidget => {
|
||||
const spec = isResolutionPreviewInputSpec(inputSpec) ? inputSpec : undefined
|
||||
const options: IWidgetResolutionPreviewOptions = {
|
||||
serialize: false,
|
||||
canvasOnly: false,
|
||||
hideInPanel: true,
|
||||
ratio_widget: spec?.ratio_widget,
|
||||
megapixels_widget: spec?.megapixels_widget,
|
||||
multiple_widget: spec?.multiple_widget
|
||||
}
|
||||
const rawWidget = node.addWidget(
|
||||
'resolutionpreview',
|
||||
inputSpec.name,
|
||||
null,
|
||||
() => {},
|
||||
options
|
||||
)
|
||||
rawWidget.serialize = false
|
||||
|
||||
return rawWidget as IResolutionPreviewWidget
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import { resolveNodeRootGraphId } from '@/lib/litegraph/src/litegraph'
|
||||
import { defineDeprecatedProperty } from '@/lib/litegraph/src/utils/feedback'
|
||||
import {
|
||||
bindMultilineTextareaWidget,
|
||||
createMultilineInputElement
|
||||
} from '@/renderer/extensions/vueNodes/widgets/utils/multilineTextarea'
|
||||
import { isStringInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import { app } from '@/scripts/app'
|
||||
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
|
||||
import { useWidgetValueStore } from '@/stores/widgetValueStore'
|
||||
import { widgetId } from '@/types/widgetId'
|
||||
|
||||
function addMultilineWidget(
|
||||
node: LGraphNode,
|
||||
name: string,
|
||||
opts: { defaultVal: string; placeholder?: string }
|
||||
) {
|
||||
const widgetStore = useWidgetValueStore()
|
||||
const inputEl = createMultilineInputElement(
|
||||
opts.defaultVal,
|
||||
opts.placeholder || name
|
||||
)
|
||||
|
||||
const widget = node.addDOMWidget(name, 'customtext', inputEl, {
|
||||
getValue(): string {
|
||||
const graphId = resolveNodeRootGraphId(node, app.rootGraph.id)
|
||||
const widgetState = widgetStore.getWidget(
|
||||
widgetId(graphId, node.id, name)
|
||||
)
|
||||
|
||||
return (widgetState?.value as string) ?? inputEl.value
|
||||
},
|
||||
setValue(v: string) {
|
||||
inputEl.value = v
|
||||
const graphId = resolveNodeRootGraphId(node, app.rootGraph.id)
|
||||
const id = widgetId(graphId, node.id, name)
|
||||
const widgetState = widgetStore.getWidget(id)
|
||||
if (widgetState) {
|
||||
widgetState.value = v
|
||||
return
|
||||
}
|
||||
widgetStore.registerWidget(id, {
|
||||
type: 'customtext',
|
||||
value: v,
|
||||
options: widget.options ?? {}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
widget.element = inputEl
|
||||
|
||||
/** @deprecated Use {@link widget.element} instead (renamed in PR #8594). */
|
||||
defineDeprecatedProperty(
|
||||
widget,
|
||||
'inputEl',
|
||||
'element',
|
||||
'widget.inputEl is deprecated. Use widget.element instead.'
|
||||
)
|
||||
widget.options.minNodeSize = [400, 200]
|
||||
|
||||
bindMultilineTextareaWidget(widget, inputEl)
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
export const useStringWidget = () => {
|
||||
const widgetConstructor: ComfyWidgetConstructorV2 = (
|
||||
node: LGraphNode,
|
||||
inputSpec: InputSpec
|
||||
) => {
|
||||
if (!isStringInputSpec(inputSpec)) {
|
||||
throw new Error(`Invalid input data: ${inputSpec}`)
|
||||
}
|
||||
|
||||
const defaultVal = inputSpec.default ?? ''
|
||||
const multiline = inputSpec.multiline
|
||||
|
||||
const widget = multiline
|
||||
? addMultilineWidget(node, inputSpec.name, {
|
||||
defaultVal,
|
||||
placeholder: inputSpec.placeholder
|
||||
})
|
||||
: node.addWidget('text', inputSpec.name, defaultVal, () => {}, {})
|
||||
|
||||
if (typeof inputSpec.dynamicPrompts === 'boolean') {
|
||||
widget.dynamicPrompts = inputSpec.dynamicPrompts
|
||||
}
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
return widgetConstructor
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import type {
|
||||
ComfyNodeDef as ComfyNodeDefV2,
|
||||
InputSpec as InputSpecV2,
|
||||
OutputSpec as OutputSpecV2
|
||||
} from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import type {
|
||||
ComfyNodeDef as ComfyNodeDefV1,
|
||||
InputSpec as InputSpecV1
|
||||
} from '@/schemas/nodeDefSchema'
|
||||
import {
|
||||
getComboSpecComboOptions,
|
||||
isComboInputSpec,
|
||||
isComboInputSpecV1
|
||||
} from '@/schemas/nodeDefSchema'
|
||||
|
||||
/**
|
||||
* Transforms a V1 node definition to V2 format
|
||||
* @param nodeDefV1 The V1 node definition to transform
|
||||
* @returns The transformed V2 node definition
|
||||
*/
|
||||
export function transformNodeDefV1ToV2(
|
||||
nodeDefV1: ComfyNodeDefV1
|
||||
): ComfyNodeDefV2 {
|
||||
// Transform inputs
|
||||
const inputs: Record<string, InputSpecV2> = {}
|
||||
|
||||
// Process required inputs
|
||||
if (nodeDefV1.input?.required) {
|
||||
Object.entries(nodeDefV1.input.required).forEach(([name, inputSpecV1]) => {
|
||||
inputs[name] = transformInputSpecV1ToV2(inputSpecV1, {
|
||||
name,
|
||||
isOptional: false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Process optional inputs
|
||||
if (nodeDefV1.input?.optional) {
|
||||
Object.entries(nodeDefV1.input.optional).forEach(([name, inputSpecV1]) => {
|
||||
inputs[name] = transformInputSpecV1ToV2(inputSpecV1, {
|
||||
name,
|
||||
isOptional: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Transform outputs
|
||||
const outputs: OutputSpecV2[] = []
|
||||
|
||||
if (nodeDefV1.output) {
|
||||
if (Array.isArray(nodeDefV1.output)) {
|
||||
nodeDefV1.output.forEach((outputType, index) => {
|
||||
const outputSpec: OutputSpecV2 = {
|
||||
index,
|
||||
name: nodeDefV1.output_name?.[index] || `output_${index}`,
|
||||
type: Array.isArray(outputType) ? 'COMBO' : outputType,
|
||||
is_list: nodeDefV1.output_is_list?.[index] || false,
|
||||
tooltip: nodeDefV1.output_tooltips?.[index]
|
||||
}
|
||||
|
||||
// Add options for combo outputs
|
||||
if (Array.isArray(outputType)) {
|
||||
outputSpec.options = outputType
|
||||
}
|
||||
|
||||
outputs.push(outputSpec)
|
||||
})
|
||||
} else {
|
||||
console.warn('nodeDefV1.output is not an array:', nodeDefV1.output)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the V2 node definition
|
||||
return {
|
||||
inputs,
|
||||
outputs,
|
||||
hidden: nodeDefV1.input?.hidden,
|
||||
name: nodeDefV1.name,
|
||||
display_name: nodeDefV1.display_name,
|
||||
description: nodeDefV1.description,
|
||||
category: nodeDefV1.category,
|
||||
output_node: nodeDefV1.output_node,
|
||||
python_module: nodeDefV1.python_module,
|
||||
deprecated: nodeDefV1.deprecated,
|
||||
experimental: nodeDefV1.experimental
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a V1 input specification to V2 format
|
||||
* @param inputSpecV1 The V1 input specification to transform
|
||||
* @param name The name of the input
|
||||
* @param isOptional Whether the input is optional
|
||||
* @returns The transformed V2 input specification
|
||||
*/
|
||||
export function transformInputSpecV1ToV2(
|
||||
inputSpecV1: InputSpecV1,
|
||||
kwargs: {
|
||||
name: string
|
||||
isOptional?: boolean
|
||||
}
|
||||
): InputSpecV2 {
|
||||
const { name, isOptional = false } = kwargs
|
||||
|
||||
// Extract options from the input spec
|
||||
const options = inputSpecV1[1] || {}
|
||||
|
||||
// Base properties for all input types
|
||||
const baseProps = {
|
||||
name,
|
||||
isOptional,
|
||||
...options
|
||||
}
|
||||
|
||||
// Handle different input types
|
||||
if (isComboInputSpec(inputSpecV1)) {
|
||||
return {
|
||||
type: 'COMBO',
|
||||
...baseProps,
|
||||
options: isComboInputSpecV1(inputSpecV1)
|
||||
? inputSpecV1[0]
|
||||
: getComboSpecComboOptions(inputSpecV1)
|
||||
}
|
||||
} else if (typeof inputSpecV1[0] === 'string') {
|
||||
// Handle standard types (INT, FLOAT, BOOLEAN, STRING) and custom types
|
||||
return {
|
||||
type: inputSpecV1[0],
|
||||
...baseProps
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for any unhandled cases
|
||||
return {
|
||||
type: 'UNKNOWN',
|
||||
...baseProps
|
||||
}
|
||||
}
|
||||
|
||||
export function transformInputSpecV2ToV1(
|
||||
inputSpecV2: InputSpecV2
|
||||
): InputSpecV1 {
|
||||
return [inputSpecV2.type, inputSpecV2]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,107 @@
|
||||
import { promotedInputSource } from '@/core/graph/subgraph/promotedInputWidget'
|
||||
import { resolveConcretePromotedWidget } from '@/core/graph/subgraph/resolveConcretePromotedWidget'
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
||||
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||
|
||||
import { isValueControlWidget, nextValueForLinkedTarget } from './valueControl'
|
||||
|
||||
/**
|
||||
* A promoted subgraph host widget whose interior source widget is driven by a
|
||||
* `control_after_generate` widget. The host owns the value (store-backed), while
|
||||
* the interior linked widgets supply the control mode and filter (ADR 0009).
|
||||
*/
|
||||
interface PromotedControlTarget {
|
||||
hostWidget: IBaseWidget
|
||||
linkedWidgets: IBaseWidget[]
|
||||
}
|
||||
|
||||
function collectPromotedControlTargets(
|
||||
node: LGraphNode
|
||||
): PromotedControlTarget[] {
|
||||
if (!node.isSubgraphNode()) return []
|
||||
|
||||
const targets: PromotedControlTarget[] = []
|
||||
for (const [index, input] of node.inputs.entries()) {
|
||||
// Promoted inputs are store-backed and addressed by widgetId.
|
||||
if (!input.widgetId) continue
|
||||
|
||||
// An incoming link means the value is fed externally (or by an outer
|
||||
// subgraph boundary in the nested case), so the host store is not the
|
||||
// authoritative source and control must not run here.
|
||||
if (node.isInputConnected(index)) continue
|
||||
|
||||
const source = promotedInputSource(node, input)
|
||||
if (!source) continue
|
||||
|
||||
const resolution = resolveConcretePromotedWidget(
|
||||
node,
|
||||
source.nodeId,
|
||||
source.widgetName
|
||||
)
|
||||
if (resolution.status !== 'resolved') continue
|
||||
|
||||
const { linkedWidgets } = resolution.resolved.widget
|
||||
if (!linkedWidgets?.some(isValueControlWidget)) continue
|
||||
|
||||
const hostWidget = node.getWidgetFromSlot(input)
|
||||
if (!hostWidget) continue
|
||||
|
||||
targets.push({ hostWidget, linkedWidgets })
|
||||
}
|
||||
return targets
|
||||
}
|
||||
|
||||
function applyTarget(target: PromotedControlTarget, nodeId: unknown): void {
|
||||
const next = nextValueForLinkedTarget({
|
||||
target: target.hostWidget,
|
||||
linkedWidgets: target.linkedWidgets,
|
||||
nodeId
|
||||
})
|
||||
if (next === undefined) return
|
||||
|
||||
target.hostWidget.value = next
|
||||
target.hostWidget.callback?.(next)
|
||||
}
|
||||
|
||||
function controlValueRunBefore(): boolean {
|
||||
return useSettingStore().get('Comfy.WidgetControlMode') === 'before'
|
||||
}
|
||||
|
||||
/**
|
||||
* Host widgets that have run control at least once, so `before` mode can skip
|
||||
* the first execution (mirroring the interior control widget's HAS_EXECUTED).
|
||||
*
|
||||
* Keyed by the widget instance so entries are released when the graph is
|
||||
* cleared and its widgets are recreated, avoiding stale state across reloads.
|
||||
*/
|
||||
const executedWidgets = new WeakSet<IBaseWidget>()
|
||||
|
||||
/**
|
||||
* Applies `control_after_generate` to a subgraph host node's promoted widgets.
|
||||
*
|
||||
* The interior control widget short-circuits for promoted inputs because the
|
||||
* interior widget is link-fed by the subgraph boundary, so its value is dead.
|
||||
* The authoritative value lives on the host node (store-backed), and this
|
||||
* applies the next controlled value there.
|
||||
*/
|
||||
export function applyPromotedWidgetControl(
|
||||
node: LGraphNode,
|
||||
phase: 'beforeQueued' | 'afterQueued'
|
||||
): void {
|
||||
const runBefore = controlValueRunBefore()
|
||||
if (phase === 'beforeQueued' && !runBefore) return
|
||||
if (phase === 'afterQueued' && runBefore) return
|
||||
|
||||
for (const target of collectPromotedControlTargets(node)) {
|
||||
if (phase === 'afterQueued') {
|
||||
applyTarget(target, node.id)
|
||||
continue
|
||||
}
|
||||
|
||||
if (executedWidgets.has(target.hostWidget)) {
|
||||
applyTarget(target, node.id)
|
||||
}
|
||||
executedWidgets.add(target.hostWidget)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { isComboWidget } from '@/lib/litegraph/src/litegraph'
|
||||
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
||||
|
||||
import { IS_CONTROL_WIDGET } from './controlWidgetMarker'
|
||||
|
||||
type ValueControlMode =
|
||||
| 'fixed'
|
||||
| 'increment'
|
||||
| 'increment-wrap'
|
||||
| 'decrement'
|
||||
| 'randomize'
|
||||
|
||||
export function nextValueForLinkedTarget(params: {
|
||||
target: IBaseWidget
|
||||
linkedWidgets: IBaseWidget[] | undefined
|
||||
nodeId: unknown
|
||||
}): IBaseWidget['value'] | undefined {
|
||||
const linked = params.linkedWidgets
|
||||
if (!linked) return undefined
|
||||
|
||||
const controlWidget = linked.find(isValueControlWidget)
|
||||
if (!controlWidget) return undefined
|
||||
|
||||
const comboFilter = linked.find(
|
||||
(w) => w !== controlWidget && w.type === 'string'
|
||||
)
|
||||
const filterValue =
|
||||
typeof comboFilter?.value === 'string' ? comboFilter.value : undefined
|
||||
|
||||
const mode = controlWidget.value as ValueControlMode
|
||||
return computeNextControlledValue(params.target, mode, {
|
||||
comboFilter: filterValue,
|
||||
nodeId: params.nodeId
|
||||
})
|
||||
}
|
||||
|
||||
const SAFE_INTEGER_MAX = 1125899906842624
|
||||
const SAFE_INTEGER_MIN = -1125899906842624
|
||||
|
||||
export function isValueControlWidget(widget: IBaseWidget): boolean {
|
||||
return (
|
||||
(widget as Record<symbol, unknown>)[IS_CONTROL_WIDGET] === true &&
|
||||
typeof widget.beforeQueued === 'function' &&
|
||||
typeof widget.afterQueued === 'function'
|
||||
)
|
||||
}
|
||||
|
||||
function buildComboFilter(
|
||||
filter: string | undefined,
|
||||
nodeId?: unknown
|
||||
): ((item: string) => boolean) | undefined {
|
||||
if (!filter) return undefined
|
||||
|
||||
if (filter.startsWith('/') && filter.endsWith('/')) {
|
||||
try {
|
||||
const regex = new RegExp(filter.substring(1, filter.length - 1))
|
||||
return (item: string) => regex.test(item)
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'Error constructing RegExp filter for node ' + String(nodeId),
|
||||
filter,
|
||||
error
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const lower = filter.toLocaleLowerCase()
|
||||
return (item: string) => item.toLocaleLowerCase().includes(lower)
|
||||
}
|
||||
|
||||
export function computeNextControlledValue(
|
||||
target: IBaseWidget,
|
||||
mode: ValueControlMode,
|
||||
options: { comboFilter?: string; nodeId?: unknown } = {}
|
||||
): IBaseWidget['value'] | undefined {
|
||||
if (mode === 'fixed') return undefined
|
||||
|
||||
if (isComboWidget(target)) {
|
||||
return computeNextComboValue(target, mode, options)
|
||||
}
|
||||
|
||||
return computeNextNumberValue(target, mode)
|
||||
}
|
||||
|
||||
function computeNextComboValue(
|
||||
target: IBaseWidget,
|
||||
mode: ValueControlMode,
|
||||
{ comboFilter, nodeId }: { comboFilter?: string; nodeId?: unknown }
|
||||
): IBaseWidget['value'] | undefined {
|
||||
const rawValues = target.options.values
|
||||
if (!Array.isArray(rawValues)) return undefined
|
||||
|
||||
const allValues = rawValues.filter(
|
||||
(value): value is string => typeof value === 'string'
|
||||
)
|
||||
const check = buildComboFilter(comboFilter, nodeId)
|
||||
const values = check ? allValues.filter(check) : allValues
|
||||
|
||||
if (!values.length) {
|
||||
if (allValues.length) {
|
||||
console.warn(
|
||||
'Filter for node ' + String(nodeId) + ' has filtered out all items',
|
||||
comboFilter
|
||||
)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
let currentIndex = values.indexOf(target.value as string)
|
||||
const length = values.length
|
||||
|
||||
switch (mode) {
|
||||
case 'increment':
|
||||
currentIndex += 1
|
||||
break
|
||||
case 'increment-wrap':
|
||||
currentIndex += 1
|
||||
if (currentIndex >= length) currentIndex = 0
|
||||
break
|
||||
case 'decrement':
|
||||
currentIndex -= 1
|
||||
break
|
||||
case 'randomize':
|
||||
currentIndex = Math.floor(Math.random() * length)
|
||||
break
|
||||
}
|
||||
|
||||
currentIndex = Math.max(0, Math.min(length - 1, currentIndex))
|
||||
return values[currentIndex]
|
||||
}
|
||||
|
||||
function computeNextNumberValue(
|
||||
target: IBaseWidget,
|
||||
mode: ValueControlMode
|
||||
): number | undefined {
|
||||
if (typeof target.value !== 'number') return undefined
|
||||
|
||||
const { min: rawMin = 0, max: rawMax = 1, step2 = 1 } = target.options
|
||||
const max = Math.min(SAFE_INTEGER_MAX, rawMax)
|
||||
const min = Math.max(SAFE_INTEGER_MIN, rawMin)
|
||||
const range = (max - min) / step2
|
||||
|
||||
let next = target.value
|
||||
switch (mode) {
|
||||
case 'increment':
|
||||
case 'increment-wrap':
|
||||
next += step2
|
||||
break
|
||||
case 'decrement':
|
||||
next -= step2
|
||||
break
|
||||
case 'randomize':
|
||||
next = Math.floor(Math.random() * range) * step2 + min
|
||||
break
|
||||
}
|
||||
|
||||
return Math.min(Math.max(next, min), max)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
||||
import type { LGraph, Subgraph } from '@/lib/litegraph/src/litegraph'
|
||||
import { formatDate } from '@/utils/formatUtil'
|
||||
import { collectAllNodes } from '@/utils/graphTraversalUtil'
|
||||
|
||||
export function applyTextReplacements(
|
||||
graph: LGraph | Subgraph,
|
||||
value: string
|
||||
): string {
|
||||
const allNodes = collectAllNodes(graph)
|
||||
|
||||
return value.replace(/%([^%]+)%/g, function (match, text) {
|
||||
const split = text.split('.')
|
||||
if (split.length !== 2) {
|
||||
// Special handling for dates
|
||||
if (split[0].startsWith('date:')) {
|
||||
return formatDate(split[0].substring(5), new Date())
|
||||
}
|
||||
|
||||
if (text !== 'width' && text !== 'height') {
|
||||
// Dont warn on standard replacements
|
||||
console.warn('Invalid replacement pattern', text)
|
||||
}
|
||||
return match
|
||||
}
|
||||
|
||||
// Find node with matching S&R property name
|
||||
let nodes = allNodes.filter(
|
||||
(n) => n.properties?.['Node name for S&R'] === split[0]
|
||||
)
|
||||
// If we can't, see if there is a node with that title
|
||||
if (!nodes.length) {
|
||||
nodes = allNodes.filter((n) => n.title === split[0])
|
||||
}
|
||||
if (!nodes.length) {
|
||||
console.warn('Unable to find node', split[0])
|
||||
return match
|
||||
}
|
||||
|
||||
if (nodes.length > 1) {
|
||||
console.warn('Multiple nodes matched', split[0], 'using first match')
|
||||
}
|
||||
|
||||
const node = nodes[0]
|
||||
|
||||
const widget = node.widgets?.find((w) => w.name === split[1])
|
||||
if (!widget) {
|
||||
console.warn('Unable to find widget', split[1], 'on node', split[0], node)
|
||||
return match
|
||||
}
|
||||
|
||||
return ((widget.value ?? '') + '').replaceAll(
|
||||
// eslint-disable-next-line no-control-regex
|
||||
/[/?<>\\:*|"\x00-\x1F\x7F]/g,
|
||||
'_'
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
{
|
||||
"profile": "comfy-frontend-1.53.6-core-0.38.0-saved-state-reference",
|
||||
"phase": "restored_saved_state_before_queue_hooks",
|
||||
"constructors": [
|
||||
{
|
||||
"type": "ResolutionSelector",
|
||||
"source_file": "case04-reference/0.38.0__comfy_extras__nodes_resolution.py",
|
||||
"sha256": "3fe5c3f9aeceed343725a91c6feaa13377b5ebad2c95fd633e3806d69d10bcc8",
|
||||
"constructor_lines": [
|
||||
[
|
||||
7,
|
||||
80
|
||||
]
|
||||
],
|
||||
"source_manifest": "sources.json"
|
||||
},
|
||||
{
|
||||
"type": "SaveImageAdvanced",
|
||||
"source_file": "case04-reference/0.38.0__comfy_extras__nodes_images.py",
|
||||
"sha256": "f8e171f428e2e81de8d7b1cd582ac4ac82cd7ae5a3c947f118ecf85df920bf50",
|
||||
"constructor_lines": [
|
||||
[
|
||||
1769,
|
||||
1875
|
||||
]
|
||||
],
|
||||
"source_manifest": "sources.json"
|
||||
},
|
||||
{
|
||||
"type": "KSampler",
|
||||
"source_file": "promoted-reference/core-0.38.0__nodes.py",
|
||||
"sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38",
|
||||
"constructor_lines": [
|
||||
[
|
||||
1605,
|
||||
1631
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "TextGenerate",
|
||||
"source_file": "promoted-reference/core-0.38.0__comfy_extras__nodes_textgen.py",
|
||||
"sha256": "ce41b40babe829cf8773aee3c3e43079f91205db921f6d964685e5fb0e5d7f54",
|
||||
"constructor_lines": [
|
||||
[
|
||||
4,
|
||||
49
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "TextEncodeQwenImage21",
|
||||
"source_file": "promoted-reference/core-0.38.0__comfy_extras__nodes_qwen.py",
|
||||
"sha256": "54ce02aa9e167c0b497ce026ac6b558f539427d2d1ed4fc1fcc2ec8e6bc529da",
|
||||
"constructor_lines": [
|
||||
[
|
||||
111,
|
||||
141
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "VAEDecode",
|
||||
"source_file": "promoted-reference/core-0.38.0__nodes.py",
|
||||
"sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38",
|
||||
"constructor_lines": [
|
||||
[
|
||||
320,
|
||||
345
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "PreviewAny",
|
||||
"source_file": "case04-reference/0.38.0__comfy_extras__nodes_preview_any.py",
|
||||
"sha256": "48cffa3b2ddd08c311af609642da8703abc9bac9e624c400c3dc41f6edcea930",
|
||||
"constructor_lines": [
|
||||
[
|
||||
9,
|
||||
44
|
||||
]
|
||||
],
|
||||
"source_manifest": "sources.json"
|
||||
},
|
||||
{
|
||||
"type": "ComfySwitchNode",
|
||||
"source_file": "promoted-reference/core-0.38.0__comfy_extras__nodes_logic.py",
|
||||
"sha256": "6a146d3a814e37c65c9e749c2fde6d8f0ea8c1fc3f215cb249009e87303908bf",
|
||||
"constructor_lines": [
|
||||
[
|
||||
86,
|
||||
112
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "UNETLoader",
|
||||
"source_file": "promoted-reference/core-0.38.0__nodes.py",
|
||||
"sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38",
|
||||
"constructor_lines": [
|
||||
[
|
||||
991,
|
||||
1015
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "CLIPLoader",
|
||||
"source_file": "promoted-reference/core-0.38.0__nodes.py",
|
||||
"sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38",
|
||||
"constructor_lines": [
|
||||
[
|
||||
1016,
|
||||
1041
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "VAELoader",
|
||||
"source_file": "promoted-reference/core-0.38.0__nodes.py",
|
||||
"sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38",
|
||||
"constructor_lines": [
|
||||
[
|
||||
775,
|
||||
806
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "EmptyLatentImage",
|
||||
"source_file": "promoted-reference/core-0.38.0__nodes.py",
|
||||
"sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38",
|
||||
"constructor_lines": [
|
||||
[
|
||||
1254,
|
||||
1274
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "PrimitiveStringMultiline",
|
||||
"source_file": "promoted-reference/core-0.38.0__comfy_extras__nodes_primitive.py",
|
||||
"sha256": "329963dd20fbf8985539b7b990780291f4b82ee9cfd42b96b571288b77eaa47a",
|
||||
"constructor_lines": [
|
||||
[
|
||||
25,
|
||||
40
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
},
|
||||
{
|
||||
"type": "QwenImage21Cache",
|
||||
"source_file": "promoted-reference/core-0.38.0__comfy_extras__nodes_qwen.py",
|
||||
"sha256": "54ce02aa9e167c0b497ce026ac6b558f539427d2d1ed4fc1fcc2ec8e6bc529da",
|
||||
"constructor_lines": [
|
||||
[
|
||||
185,
|
||||
215
|
||||
]
|
||||
],
|
||||
"source_manifest": "../promoted-reference/sources.json"
|
||||
}
|
||||
],
|
||||
"assumption": "unmodified pinned frontend/core constructors and built-in extensions; target unknown",
|
||||
"coverage": "TextGenerate.on; SaveImageAdvanced.png; STRING MatchType; contiguous image autogrow with final empty socket; fixed control only",
|
||||
"not_covered": [
|
||||
"beforeQueued/afterQueued history/settings",
|
||||
"nonfixed control RNG",
|
||||
"other dynamic branches",
|
||||
"dynamic text expressions",
|
||||
"filename replacements",
|
||||
"third-party custom serializer overrides",
|
||||
"target dynamic model/file availability"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"identity": "git_tree_sha plus sorted fixed paths",
|
||||
"trees": [
|
||||
{
|
||||
"tree_file": "docs/hel-892/case04-reference/frontend-tree.json",
|
||||
"git_tree_sha": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"path_count": 7340,
|
||||
"fixed_paths_sha256": "e60e38f4e6fbeb04c3ae73ee0c40bdcf2a6c3a0b9f6da5547d901dfc1fa60118",
|
||||
"truncated": false,
|
||||
"received_response_bytes_sha256": "05d8f4d77b564d46829bbc258ec0e9d24f2cb38cd97f63f496ea2fe0c4689648",
|
||||
"response_hash_scope": "local received bytes only; not a canonical cross-request identifier",
|
||||
"retrieval": "frontend fetched this run; core reused previous audited original; no new 0.31.0 search"
|
||||
},
|
||||
{
|
||||
"tree_file": "docs/hel-892/promoted-reference/core-tree-0.38.0.json",
|
||||
"git_tree_sha": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"path_count": 1439,
|
||||
"fixed_paths_sha256": "b8b4b3d52df03dcd67be3c393709cba96f2e56c952064b88782393716279ffba",
|
||||
"truncated": false,
|
||||
"received_response_bytes_sha256": "d2389807d456d8b68ec6b15d4f609a7e31ee6bf459e0620697fce652b472a185",
|
||||
"response_hash_scope": "local received bytes only; not a canonical cross-request identifier",
|
||||
"retrieval": "frontend fetched this run; core reused previous audited original; no new 0.31.0 search"
|
||||
},
|
||||
{
|
||||
"tree_file": "docs/hel-892/promoted-reference/core-tree-0.31.0.json",
|
||||
"git_tree_sha": "43cb4fffc89bba20ab7bd61467a36d0339338dab",
|
||||
"path_count": 1194,
|
||||
"fixed_paths_sha256": "5166b14a245b077efa1be96c60058b908a833eac576374a6ee0e5d33ac4065ce",
|
||||
"truncated": false,
|
||||
"received_response_bytes_sha256": "a301df0e968dee355a92afa84e3b6252de8eec054efbe6e611429149df49b2d2",
|
||||
"response_hash_scope": "local received bytes only; not a canonical cross-request identifier",
|
||||
"retrieval": "frontend fetched this run; core reused previous audited original; no new 0.31.0 search"
|
||||
}
|
||||
],
|
||||
"bounded_absent_path": "src/services/comfyWidgetService.ts returned 404; actual widget dispatch proven in src/services/litegraphService.ts"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,742 @@
|
||||
{
|
||||
"authority": "public_reference_only",
|
||||
"sources": [
|
||||
{
|
||||
"id": "0.38.0:comfy_extras/nodes_resolution.py",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"file": "comfy_extras/nodes_resolution.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_extras/nodes_resolution.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_extras/nodes_resolution.py",
|
||||
"sha256": "3fe5c3f9aeceed343725a91c6feaa13377b5ebad2c95fd633e3806d69d10bcc8",
|
||||
"local_file": "0.38.0__comfy_extras__nodes_resolution.py",
|
||||
"retrieved_at": "2026-10-29T17:20:33.368905+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
98
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
7,
|
||||
24
|
||||
],
|
||||
[
|
||||
30,
|
||||
47
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0.38.0:comfy_extras/nodes_images.py",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"file": "comfy_extras/nodes_images.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_extras/nodes_images.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_extras/nodes_images.py",
|
||||
"sha256": "f8e171f428e2e81de8d7b1cd582ac4ac82cd7ae5a3c947f118ecf85df920bf50",
|
||||
"local_file": "0.38.0__comfy_extras__nodes_images.py",
|
||||
"retrieved_at": "2026-10-29T17:20:33.792525+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
1956
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
1769,
|
||||
1786
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0.38.0:comfy_extras/nodes_preview_any.py",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"file": "comfy_extras/nodes_preview_any.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_extras/nodes_preview_any.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_extras/nodes_preview_any.py",
|
||||
"sha256": "48cffa3b2ddd08c311af609642da8703abc9bac9e624c400c3dc41f6edcea930",
|
||||
"local_file": "0.38.0__comfy_extras__nodes_preview_any.py",
|
||||
"retrieved_at": "2026-10-29T17:20:33.168904+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
48
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
8,
|
||||
25
|
||||
],
|
||||
[
|
||||
15,
|
||||
32
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0.38.0:comfy_api/latest/_io.py",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"file": "comfy_api/latest/_io.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_api/latest/_io.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_api/latest/_io.py",
|
||||
"sha256": "e697ed00732deffb46d7a017d82dae48ee2504a8d356f911a1447ec6146294f7",
|
||||
"local_file": "0.38.0__comfy_api__latest___io.py",
|
||||
"retrieved_at": "2026-10-29T17:20:33.718750+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
2562
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
268,
|
||||
285
|
||||
],
|
||||
[
|
||||
323,
|
||||
340
|
||||
],
|
||||
[
|
||||
1083,
|
||||
1100
|
||||
],
|
||||
[
|
||||
1220,
|
||||
1237
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0.38.0:comfy_api/latest/_io_public.py",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"file": "comfy_api/latest/_io_public.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_api/latest/_io_public.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_api/latest/_io_public.py",
|
||||
"sha256": "c805d754d61aba1ea72ed2d9d5c371de35be9affa5305d35426fb298fcb7c046",
|
||||
"local_file": "0.38.0__comfy_api__latest___io_public.py",
|
||||
"retrieved_at": "2026-10-29T17:20:33.537924+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
1
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "0.38.0:comfy/samplers.py",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"file": "comfy/samplers.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy/samplers.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy/samplers.py",
|
||||
"sha256": "f2c264ca9d394612f828e3ffe167c856a278a10e1711b269f0ba65dccb66393f",
|
||||
"local_file": "0.38.0__comfy__samplers.py",
|
||||
"retrieved_at": "2026-10-29T17:20:33.774416+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
1463
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
971,
|
||||
988
|
||||
],
|
||||
[
|
||||
1356,
|
||||
1373
|
||||
],
|
||||
[
|
||||
1365,
|
||||
1382
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/scripts/valueControl.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/scripts/valueControl.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/scripts/valueControl.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/scripts/valueControl.ts",
|
||||
"sha256": "007c7204d1fe88d156e07fee783a55e79fa7610e98a8a9f7761704a076a60458",
|
||||
"local_file": "1.53.6__src__scripts__valueControl.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.063764+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
158
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
37,
|
||||
54
|
||||
],
|
||||
[
|
||||
71,
|
||||
88
|
||||
],
|
||||
[
|
||||
132,
|
||||
149
|
||||
],
|
||||
[
|
||||
139,
|
||||
156
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/scripts/app.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/scripts/app.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/scripts/app.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/scripts/app.ts",
|
||||
"sha256": "ba650ea75b14affbdd1fbf4d821679d29dde59bd09986666a4734c8a160f7027",
|
||||
"local_file": "1.53.6__src__scripts__app.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:52.938497+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
2602
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
1758,
|
||||
1775
|
||||
],
|
||||
[
|
||||
1760,
|
||||
1777
|
||||
],
|
||||
[
|
||||
1769,
|
||||
1786
|
||||
],
|
||||
[
|
||||
1974,
|
||||
1991
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useResolutionPreviewWidget.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/renderer/extensions/vueNodes/widgets/composables/useResolutionPreviewWidget.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/renderer/extensions/vueNodes/widgets/composables/useResolutionPreviewWidget.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/renderer/extensions/vueNodes/widgets/composables/useResolutionPreviewWidget.ts",
|
||||
"sha256": "4316e8869b8673488ea9b136dbd4027160626c53cab9372fa1ca7aab059cf124",
|
||||
"local_file": "1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useResolutionPreviewWidget.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.082702+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
35
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
17,
|
||||
34
|
||||
],
|
||||
[
|
||||
31,
|
||||
35
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/extensions/core/previewAny.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/extensions/core/previewAny.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/previewAny.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/previewAny.ts",
|
||||
"sha256": "da8f4361b054d8619c09b4abaae1c2c464d6c8927968e60f18e61b467d2a3366",
|
||||
"local_file": "1.53.6__src__extensions__core__previewAny.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.504586+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
42
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
27,
|
||||
42
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/core/graph/widgets/dynamicWidgets.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/core/graph/widgets/dynamicWidgets.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/widgets/dynamicWidgets.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/widgets/dynamicWidgets.ts",
|
||||
"sha256": "35cbe6eae6470bdd9aa45f17000ba444dce21597fdb8edf54da43ffb840936c1",
|
||||
"local_file": "1.53.6__src__core__graph__widgets__dynamicWidgets.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.662790+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
706
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
99,
|
||||
116
|
||||
],
|
||||
[
|
||||
200,
|
||||
217
|
||||
],
|
||||
[
|
||||
293,
|
||||
310
|
||||
],
|
||||
[
|
||||
456,
|
||||
473
|
||||
],
|
||||
[
|
||||
680,
|
||||
697
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/schemas/nodeDef/migration.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/schemas/nodeDef/migration.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/schemas/nodeDef/migration.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/schemas/nodeDef/migration.ts",
|
||||
"sha256": "ae357da184625b93c492c0b73ce9bd2f3b49d158ca19a2944c6500f924a7a533",
|
||||
"local_file": "1.53.6__src__schemas__nodeDef__migration.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.532218+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
143
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts",
|
||||
"sha256": "8720d5a8194c9987eddbb42d0e925bcbb20e96e94f52c5f21750ba90b2113e02",
|
||||
"local_file": "1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.838175+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
93
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
70,
|
||||
87
|
||||
],
|
||||
[
|
||||
79,
|
||||
93
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts",
|
||||
"sha256": "9d015f423d90ac563f55c9f92d016948ac0e4496d660f6020bced8fa0e0d43a6",
|
||||
"local_file": "1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts",
|
||||
"retrieved_at": "2026-10-29T17:20:34.538389+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
95
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; original LICENSE retained in ../promoted-reference (core) or ../structure-reference (frontend)",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/scripts/promotedWidgetControl.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/scripts/promotedWidgetControl.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/scripts/promotedWidgetControl.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/scripts/promotedWidgetControl.ts",
|
||||
"sha256": "30b0703305b8c3f921be3e700d9a1406f5721a7d5f8a8d1be56c8964e32743a4",
|
||||
"local_file": "1.53.6__src__scripts__promotedWidgetControl.ts",
|
||||
"retrieved_at": "2026-10-29T17:21:30.633547+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
107
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
19,
|
||||
36
|
||||
],
|
||||
[
|
||||
88,
|
||||
105
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/extensions/core/textPreviewWidgets.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/extensions/core/textPreviewWidgets.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/textPreviewWidgets.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/textPreviewWidgets.ts",
|
||||
"sha256": "453e4c11c902e84dc9950475f8439d4364d0244bfe370c4b74770b84c2592a75",
|
||||
"local_file": "1.53.6__src__extensions__core__textPreviewWidgets.ts",
|
||||
"retrieved_at": "2026-10-29T17:21:30.369331+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
85
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
21,
|
||||
38
|
||||
],
|
||||
[
|
||||
66,
|
||||
83
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/services/litegraphService.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/services/litegraphService.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/services/litegraphService.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/services/litegraphService.ts",
|
||||
"sha256": "84ffdeae56bc73065fd2a44ae924b6ab4fd48bb7e79a710210e858cce508784e",
|
||||
"local_file": "1.53.6__src__services__litegraphService.ts",
|
||||
"retrieved_at": "2026-10-29T17:21:31.568254+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
1030
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
229,
|
||||
246
|
||||
],
|
||||
[
|
||||
285,
|
||||
302
|
||||
],
|
||||
[
|
||||
303,
|
||||
320
|
||||
],
|
||||
[
|
||||
308,
|
||||
325
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:packages/shared-frontend-utils/src/formatUtil.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "packages/shared-frontend-utils/src/formatUtil.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/packages/shared-frontend-utils/src/formatUtil.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/packages/shared-frontend-utils/src/formatUtil.ts",
|
||||
"sha256": "939faea5d135ce2aeb78c4dc92232de7e4836ab90d9fb61a804a457bbc910253",
|
||||
"local_file": "1.53.6__packages__shared-frontend-utils__src__formatUtil.ts",
|
||||
"retrieved_at": "2026-10-29T17:21:30.089827+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
772
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
231,
|
||||
248
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/extensions/core/saveImageExtraOutput.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/extensions/core/saveImageExtraOutput.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/saveImageExtraOutput.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/saveImageExtraOutput.ts",
|
||||
"sha256": "2115ffeb31f3099e0e97b46304b802653c1ba58ad746323d1b094a1605265682",
|
||||
"local_file": "1.53.6__src__extensions__core__saveImageExtraOutput.ts",
|
||||
"retrieved_at": "2026-10-29T17:21:30.500010+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
74
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
50,
|
||||
67
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/extensions/core/uploadImage.ts",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"file": "src/extensions/core/uploadImage.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/uploadImage.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/extensions/core/uploadImage.ts",
|
||||
"sha256": "48d062c2ee95bd77c537c539e6c8f8bc03bd71dcec94c5b82487c014ea3e9c06",
|
||||
"local_file": "1.53.6__src__extensions__core__uploadImage.ts",
|
||||
"retrieved_at": "2026-10-29T17:21:30.881586+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
40
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/utils/searchAndReplace.ts",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"file": "src/utils/searchAndReplace.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/utils/searchAndReplace.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/utils/searchAndReplace.ts",
|
||||
"sha256": "c7462edebf266b8b8cc62954a371ca3ec3fd1ee4c188e1b80a675003b49887d4",
|
||||
"local_file": "1.53.6__src__utils__searchAndReplace.ts",
|
||||
"retrieved_at": "2026-10-29T17:22:32.366223+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
57
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
11,
|
||||
28
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/core/graph/subgraph/promotedInputWidget.ts",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"file": "src/core/graph/subgraph/promotedInputWidget.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/promotedInputWidget.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/promotedInputWidget.ts",
|
||||
"sha256": "9d785e3515e0cfc84cbfbdaf33dc00cd668b243fcab9739a66c1954c22e15936",
|
||||
"local_file": "1.53.6__src__core__graph__subgraph__promotedInputWidget.ts",
|
||||
"retrieved_at": "2026-10-29T17:22:32.860757+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
100
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/core/graph/subgraph/resolveConcretePromotedWidget.ts",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"file": "src/core/graph/subgraph/resolveConcretePromotedWidget.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/resolveConcretePromotedWidget.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/resolveConcretePromotedWidget.ts",
|
||||
"sha256": "9833f86c3533518ed6ce2085a38afc8039cf903e4729bb10572551bd148a317d",
|
||||
"local_file": "1.53.6__src__core__graph__subgraph__resolveConcretePromotedWidget.ts",
|
||||
"retrieved_at": "2026-10-29T17:22:33.394683+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
156
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "0.38.0:comfy_api/internal/__init__.py",
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI",
|
||||
"file": "comfy_api/internal/__init__.py",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_api/internal/__init__.py",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI/blob/6b747c0428c343e1417219641db93a4fb7cb69ae/comfy_api/internal/__init__.py",
|
||||
"sha256": "50786f7e2ebc910ed9becddf066e92d7924b7f6080189651067bbcd839e8a410",
|
||||
"local_file": "0.38.0__comfy_api__internal____init__.py",
|
||||
"retrieved_at": "2026-10-29T17:27:47.073834+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
150
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE retained in previous reference directories",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
58,
|
||||
75
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/core/graph/subgraph/resolveSubgraphInputTarget.ts",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"file": "src/core/graph/subgraph/resolveSubgraphInputTarget.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/resolveSubgraphInputTarget.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/resolveSubgraphInputTarget.ts",
|
||||
"sha256": "11395e93cf9199ea2a7a9f097306e01434a43d6a9df2c0db773170c5ecd85451",
|
||||
"local_file": "1.53.6__src__core__graph__subgraph__resolveSubgraphInputTarget.ts",
|
||||
"retrieved_at": "2026-10-29T17:27:47.517113+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
35
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE retained in previous reference directories",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": []
|
||||
},
|
||||
{
|
||||
"id": "1.53.6:src/core/graph/subgraph/resolveSubgraphInputLink.ts",
|
||||
"version": "1.53.6",
|
||||
"commit": "7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1",
|
||||
"repository": "https://github.com/Comfy-Org/ComfyUI_frontend",
|
||||
"file": "src/core/graph/subgraph/resolveSubgraphInputLink.ts",
|
||||
"raw_url": "https://raw.githubusercontent.com/Comfy-Org/ComfyUI_frontend/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/resolveSubgraphInputLink.ts",
|
||||
"url": "https://github.com/Comfy-Org/ComfyUI_frontend/blob/7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1/src/core/graph/subgraph/resolveSubgraphInputLink.ts",
|
||||
"sha256": "20fe9c7dd9a30f316e8b903df53db693434f0827187286a4dfb6a7f4c7fff6f7",
|
||||
"local_file": "1.53.6__src__core__graph__subgraph__resolveSubgraphInputLink.ts",
|
||||
"retrieved_at": "2026-10-29T17:28:27.424722+00:00",
|
||||
"lines": [
|
||||
[
|
||||
1,
|
||||
51
|
||||
]
|
||||
],
|
||||
"license": "GPL-3.0; LICENSE retained in ../structure-reference",
|
||||
"target_version_match": "unknown",
|
||||
"rule_locations": [
|
||||
[
|
||||
24,
|
||||
41
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user