repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
rgthree-comfy
github_2023
rgthree
typescript
Bookmark._collapsed_width
override get _collapsed_width() { return this.___collapsed_width; }
//@ts-ignore - TS Doesn't like us overriding a property with accessors but, too bad.
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/bookmark.ts#L35-L37
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Bookmark.shortcutKey
get shortcutKey(): string { return this.widgets[0]?.value?.toLocaleLowerCase() ?? ""; }
// }
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/bookmark.ts#L81-L83
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Bookmark.onMouseDown
override onMouseDown(event: MouseEvent, pos: Vector2, graphCanvas: LGraphCanvas): void { const input = queryOne<HTMLInputElement>(".graphdialog > input.value"); if (input && input.value === this.widgets[0]?.value) { input.addEventListener("keydown", (e) => { // ComfyUI swallows keydown on inputs, ...
/** * Called from LiteGraph's `processMouseDown` after it would invoke the input box for the * shortcut_key, so we check if it exists and then add our own event listener so we can track the * keys down for the user. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/bookmark.ts#L113-L124
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
fieldrow
function fieldrow(item: ConfigurationSchema) { const initialValue = CONFIG_SERVICE.getConfigValue(item.key); const container = $el(`div.fieldrow.-type-${TYPE_TO_STRING[item.type]}`, { dataset: { name: item.key, initial: initialValue, type: item.type, }, }); $el(`label[for="${item.key}...
/** * Creates a new fieldrow for main or sub configuration items. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/config.ts#L189-L259
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
findMatchingIndexByTypeOrName
function findMatchingIndexByTypeOrName( otherNode: TLGraphNode, otherSlot: INodeInputSlot | INodeOutputSlot, ctxSlots: INodeInputSlot[] | INodeOutputSlot[], ) { const otherNodeType = (otherNode.type || "").toUpperCase(); const otherNodeName = (otherNode.title || "").toUpperCase(); let otherSlotType = otherS...
/** * Takes a non-context node and determins for its input or output slot, if there is a valid * connection for an opposite context output or input slot. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/context.ts#L28-L83
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
BaseContextNode._collapsed_width
override get _collapsed_width() { return this.___collapsed_width; }
//@ts-ignore - TS Doesn't like us overriding a property with accessors but, too bad.
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/context.ts#L98-L100
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
BaseContextMultiCtxInputNode.stabilize
private stabilize() { removeUnusedInputsFromEnd(this, 4); this.addContextInput(); }
/** * Stabilizes the inputs; removing any disconnected ones from the bottom, then adding an empty * one to the end so we always have one empty one to expand. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/context.ts#L307-L310
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
infoTableRow
function infoTableRow( name: string, value: string | number, help: string = "", editableFieldName = "", ) { return ` <tr class="${editableFieldName ? "editable" : ""}" ${ editableFieldName ? `data-field-name="${editableFieldName}"` : "" }> <td><span>${name} ${help ? `<span class="-help" ti...
/** * Generates a uniform markup string for a table row. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/dialog_info.ts#L356-L376
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
saveEditableRow
function saveEditableRow(info: RgthreeModelInfo, tr: HTMLElement, saving = true): boolean { const fieldName = tr.dataset["fieldName"] as "file"; const input = queryOne<HTMLInputElement>("input,textarea", tr)!; let newValue = info[fieldName] ?? ""; let modified = false; if (saving) { newValue = input!.valu...
/** * Saves / cancels an editable row. Returns a boolean if the data was modified. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/dialog_info.ts#L396-L417
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
DynamicContextNodeBase.handleUpstreamMutation
handleUpstreamMutation(mutation: InputMutation) { console.log(`[node ${this.id}] handleUpstreamMutation`, mutation); if (mutation.operation === InputMutationOperation.ADDED) { const slot = mutation.slot; if (!slot) { throw new Error("Cannot have an ADDED mutation without a provided slot data...
// }
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/dynamic_context_base.ts#L67-L97
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
DynamicContextNodeBase.onNodeCreated
override onNodeCreated() { const node = this; this.addCustomWidget( new RgthreeInvisibleWidget("output_keys", "RGTHREE_DYNAMIC_CONTEXT_OUTPUTS", "", () => { return (node.outputs || []) .map((o, i) => i > 0 && o.name) .filter((n) => n !== false) .join(","); }), ...
/** * Adds the basic output_keys widget. Should be called _after_ specific nodes setup their inputs * or widgets. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/dynamic_context_base.ts#L116-L126
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
DynamicContextSwitchNode.refreshInputsAndOutputs
private refreshInputsAndOutputs() { const inputs: (InputLike & {count: number})[] = [ {name: "base_ctx", type: "RGTHREE_DYNAMIC_CONTEXT", link: null, count: 0}, ]; let numConnected = 0; for (let i = 0; i < this.inputs.length; i++) { const childCtxs = getConnectedInputNodesAndFilterPassThroug...
/** * This is a "hard" refresh of the list, but looping over the actual context inputs, and * recompiling the shadowInputs and outputs. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/dynamic_context_switch.ts#L105-L167
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastActionsButton.configure
override configure(info: SerializedLGraphNode<LGraphNode>): void { super.configure(info); // Since we add the widgets dynamically, we need to wait to set their values // with a short timeout. setTimeout(() => { if (info.widgets_values) { for (let [index, value] of info.widgets_values.entri...
/** When we're given data to configure, like from a PNG or JSON. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/fast_actions_button.ts#L74-L93
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastActionsButton.executeConnectedNodes
async executeConnectedNodes() { for (const widget of this.widgets) { if (widget == this.buttonWidget) { continue; } const action = widget.value; const { comfy, node } = this.widgetToData.get(widget) ?? {}; if (comfy) { if (action === "Queue Prompt") { await co...
/** * Runs through the widgets, and executes the actions. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/fast_actions_button.ts#L247-L277
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastActionsButton.addComfyActionWidget
addComfyActionWidget(slot?: number, value?: string) { let widget = this.addWidget( "combo", "Comfy Action", "None", () => { if (widget.value.startsWith("MOVE ")) { this.widgets.push(this.widgets.splice(this.widgets.indexOf(widget), 1)[0]!); widget.value = (widget ...
/** * Adds a ComfyActionWidget at the provided slot (or end). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/fast_actions_button.ts#L282-L311
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastGroupsBypasser.constructor
constructor(title = FastGroupsBypasser.title) { super(title); this.onConstructed(); }
// Used by Comfy for "bypass"
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/fast_groups_bypasser.ts#L21-L24
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
clickedOnToggleButton
function clickedOnToggleButton(e: AdjustedMouseEvent, group: TLGraphGroup): string | null { const toggles = getToggles(); const pos = group.pos; const size = group.size; for (let i = 0; i < toggles.length; i++) { const toggle = toggles[i]; if ( LiteGraph.isInsideRectangle( e.canvasX, ...
/** * Determines if the user clicked on an fast header icon. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/feature_group_fast_toggle.ts#L32-L52
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreeImageComparer.setIsPointerDown
private setIsPointerDown(down: boolean = this.isPointerDown) { const newIsDown = down && !!app.canvas.pointer_is_down; if (this.isPointerDown !== newIsDown) { this.isPointerDown = newIsDown; this.setDirtyCanvas(true, false); } this.imageIndex = this.isPointerDown ? 1 : 0; if (this.isPoin...
/** * Sets mouse as down or up based on param. If it's down, we also loop to check pointer is still * down. This is because LiteGraph doesn't fire `onMouseUp` every time there's a mouse up, so we * need to manually monitor `pointer_is_down` and, when it's no longer true, set mouse as up here. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/image_comparer.ts#L134-L146
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
updateCombinerToCollector
async function updateCombinerToCollector(node: TLGraphNode) { if (node.type === CombinerNode.legacyType) { // Create a new CollectorNode. const newNode = new CollectorNode(); if (node.title != CombinerNode.title) { newNode.title = node.title.replace("‼️ ", ""); } // Port the position, size, ...
/** * Updates a Node Combiner to a Node Collector. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/node_collector.ts#L99-L144
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
NodeModeRelay.dispatchModeToRepeater
private dispatchModeToRepeater(mode?: NodeMode | -99 | null) { if (mode != null) { const propertyVal = this.properties?.[MODE_TO_PROPERTY.get(mode) || ""]; const newMode = OPTION_TO_MODE.get(propertyVal); mode = (newMode !== null ? newMode : mode) as NodeMode | -99; if (mode !== null && mode...
/** * Sends the mode to the repeater, checking to see if we're modifying our mode. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/node_mode_relay.ts#L222-L239
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
NodeModeRepeater.onModeChange
override onModeChange(from: NodeMode, to: NodeMode) { super.onModeChange(from, to); const linkedNodes = getConnectedInputNodesAndFilterPassThroughs(this).filter( (node) => node.type !== NodeTypesString.NODE_MODE_RELAY, ); if (linkedNodes.length) { for (const node of linkedNodes) { if...
/** When a mode change, we want all connected nodes to match except for connected relays. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/node_mode_repeater.ts#L162-L188
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.configure
override configure(info: SerializedLGraphNode<TLGraphNode>): void { while (this.widgets?.length) this.removeWidget(0); this.widgetButtonSpacer = null; super.configure(info); (this as any)._tempWidth = this.size[0]; (this as any)._tempHeight = this.size[1]; for (const widgetValue of info.widgets...
/** * Handles configuration from a saved workflow by first removing our default widgets that were * added in `onNodeCreated`, letting `super.configure` and do nothing, then create our lora * widgets and, finally, add back in our default widgets. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L81-L97
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.onNodeCreated
override onNodeCreated() { super.onNodeCreated?.(); this.addNonLoraWidgets(); const computed = this.computeSize(); this.size = this.size || [0, 0]; this.size[0] = Math.max(this.size[0], computed[0]); this.size[1] = Math.max(this.size[1], computed[1]); this.setDirtyCanvas(true, true); }
/** * Adds the non-lora widgets. If we'll be configured then we remove them and add them back, so * this is really only for newly created nodes in the current session. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L103-L111
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.addNewLoraWidget
private addNewLoraWidget(lora?: string) { this.loraWidgetsCounter++; const widget = this.addCustomWidget( new PowerLoraLoaderWidget("lora_" + this.loraWidgetsCounter), ); if (lora) widget.setLora(lora); if (this.widgetButtonSpacer) { moveArrayItem(this.widgets, widget, this.widgets.index...
/** Adds a new lora widget in the proper slot. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L114-L124
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.addNonLoraWidgets
private addNonLoraWidgets() { moveArrayItem( this.widgets, this.addCustomWidget( new RgthreeDividerWidget({ marginTop: 4, marginBottom: 0, thickness: 0 }), ), 0, ); moveArrayItem(this.widgets, this.addCustomWidget(new PowerLoraLoaderHeaderWidget()), 1); this.widgetButton...
/** Adds the non-lora widgets around any lora ones that may be there from configuration. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L127-L170
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.getSlotInPosition
override getSlotInPosition(canvasX: number, canvasY: number): any { const slot = super.getSlotInPosition(canvasX, canvasY); // No slot, let's see if it's a widget. if (!slot) { let lastWidget = null; for (const widget of this.widgets) { // If last_y isn't set, something is wrong. Bail. ...
/** * Hacks the `getSlotInPosition` call made from LiteGraph so we can show a custom context menu * for widgets. * * Normally this method, called from LiteGraph's processContextMenu, will only get Inputs or * Outputs. But that's not good enough because we we also want to provide a custom menu when * c...
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L193-L213
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.getSlotMenuOptions
override getSlotMenuOptions(slot: any): ContextMenuItem[] | null { // Oddly, LiteGraph doesn't call back into our node with a custom menu (even though it let's us // define a custom menu to begin with... wtf?). So, we'll return null so the default is not // triggered and then we'll just show one ourselves b...
/** * Working with the overridden `getSlotInPosition` above, this method checks if the passed in * option is actually a widget from it and then hijacks the context menu all together. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L219-L274
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.refreshComboInNode
refreshComboInNode(defs: any) { rgthreeApi.getLoras(true); }
/** * When `refreshComboInNode` is called from ComfyUI, then we'll kick off a fresh loras fetch. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L279-L281
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.hasLoraWidgets
hasLoraWidgets() { return !!this.widgets?.find((w) => w.name?.startsWith("lora_")); }
/** * Returns true if there are any Lora Widgets. Useful for widgets to ask as they render. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L286-L288
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.allLorasState
allLorasState() { let allOn = true; let allOff = true; for (const widget of this.widgets) { if (widget.name?.startsWith("lora_")) { const on = widget.value?.on; allOn = allOn && on === true; allOff = allOff && on === false; if (!allOn && !allOff) { return null...
/** * This will return true when all lora widgets are on, false when all are off, or null if it's * mixed. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L294-L308
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreePowerLoraLoader.toggleAllLoras
toggleAllLoras() { const allOn = this.allLorasState(); const toggledTo = !allOn ? true : false; for (const widget of this.widgets) { if (widget.name?.startsWith("lora_")) { widget.value.on = toggledTo; } } }
/** * Toggles all the loras on or off. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L313-L321
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
PowerLoraLoaderHeaderWidget.onToggleDown
onToggleDown(event: AdjustedMouseEvent, pos: Vector2, node: TLGraphNode) { (node as RgthreePowerLoraLoader).toggleAllLoras(); this.cancelMouseDown(); return true; }
/** * Handles a pointer down on the toggle's defined hit area. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L440-L444
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
PowerLoraLoaderWidget.draw
draw(ctx: CanvasRenderingContext2D, node: TLGraphNode, w: number, posY: number, height: number) { // Since draw is the loop that runs, this is where we'll check the property state (rather than // expect the node to tell us it's state etc). let currentShowModelAndClip = node.properties[PROP_LABEL_SHOW_...
/** Draws our widget with a toggle, lora selector, and number selector all in a single row. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/power_lora_loader.ts#L533-L674
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.onCanvasSetUpListenerForLinking
async onCanvasSetUpListenerForLinking() { const canvas = await waitForCanvas(); // With the new UI released in August 2024, ComfyUI changed LiteGraph's code, removing // connecting_node, connecting_node, connecting_node, and connecting_node properties and instead // using an array of connecting_links. ...
/** * Waits for canvas to be available, then sets up a property accessor for `connecting_node` so * we can start/stop monitoring for shortcut keys. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L113-L141
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.startingLinking
private startingLinking() { this.isFastLinking = true; KEY_EVENT_SERVICE.addEventListener("keydown", this.handleLinkingKeydownBound as EventListener); KEY_EVENT_SERVICE.addEventListener("keyup", this.handleLinkingKeyupBound as EventListener); }
/** * When the user is actively dragging a link, listens for keydown events so we can enable * shortcuts. * * Is only accessible if both `CONFIG_FAST_REROUTE_ENABLED` is true, and * CONFIG_KEY_CREATE_WHILE_LINKING is not falsy/empty. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L150-L154
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.stoppingLinking
private stoppingLinking() { this.isFastLinking = false; this.fastReroutesHistory = []; KEY_EVENT_SERVICE.removeEventListener("keydown", this.handleLinkingKeydownBound as EventListener); KEY_EVENT_SERVICE.removeEventListener("keyup", this.handleLinkingKeyupBound as EventListener); }
/** * When the user stops actively dragging a link, cleans up motnioring data and events. * * Is only accessible if both `CONFIG_FAST_REROUTE_ENABLED` is true, and * CONFIG_KEY_CREATE_WHILE_LINKING is not falsy/empty. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L162-L167
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.handleLinkingKeydown
private handleLinkingKeydown(event: KeyboardEvent) { if ( !this.handledNewRerouteKeypress && KEY_EVENT_SERVICE.areOnlyKeysDown(CONFIG_KEY_CREATE_WHILE_LINKING) ) { this.handledNewRerouteKeypress = true; this.insertNewRerouteWhileLinking(); } }
/** * Handles the keydown event. * * Is only accessible if both `CONFIG_FAST_REROUTE_ENABLED` is true, and * CONFIG_KEY_CREATE_WHILE_LINKING is not falsy/empty. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L175-L183
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.handleLinkingKeyup
private handleLinkingKeyup(event: KeyboardEvent) { if ( this.handledNewRerouteKeypress && !KEY_EVENT_SERVICE.areOnlyKeysDown(CONFIG_KEY_CREATE_WHILE_LINKING) ) { this.handledNewRerouteKeypress = false; } }
/** * Handles the keyup event. * * Is only accessible if both `CONFIG_FAST_REROUTE_ENABLED` is true, and * CONFIG_KEY_CREATE_WHILE_LINKING is not falsy/empty. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L191-L198
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.insertNewRerouteWhileLinking
private insertNewRerouteWhileLinking() { const canvas = app.canvas; this.connectingData = this.getConnectingData(); if (!this.connectingData) { throw new Error("Error, handling linking keydown, but there's no link."); } const data = this.connectingData; const node = LiteGraph.createNode("...
/** * Inserts a new reroute (while linking) as called from key down handler. * * Is only accessible if both `CONFIG_FAST_REROUTE_ENABLED` is true, and * CONFIG_KEY_CREATE_WHILE_LINKING is not falsy/empty. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L253-L329
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.handleMoveOrResizeNodeMaybeWhileDragging
handleMoveOrResizeNodeMaybeWhileDragging(node: RerouteNode) { const data = this.connectingData!; if (this.isFastLinking && node === data?.node) { const entry = this.fastReroutesHistory[this.fastReroutesHistory.length - 1]; if (entry) { data.pos = entry.node.getConnectionPos(!!data.input, 0);...
/** * Is called from a reroute node when it is resized or moved so the service can check if we're * actively linking to it, and it can update the linking data so the connection moves too, by * updating `connecting_pos`. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L336-L345
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteService.handleRemovedNodeMaybeWhileDragging
handleRemovedNodeMaybeWhileDragging(node: RerouteNode) { const currentEntry = this.fastReroutesHistory[this.fastReroutesHistory.length - 1]; if (currentEntry?.node === node) { this.setCanvasConnectingData(currentEntry.previous); this.fastReroutesHistory.splice(this.fastReroutesHistory.length - 1, 1)...
/** * Is called from a reroute node when it is deleted so the service can check if we're actively * linking to it and go "back" in history to the previous node. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L351-L360
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.onConnectionsChange
override onConnectionsChange( type: number, _slotIndex: number, connected: boolean, _link_info: LLink, _ioSlot: INodeOutputSlot | INodeInputSlot, ) { // Prevent multiple connections to different types when we have no input if (connected && type === LiteGraph.OUTPUT) { // Ignore wildc...
/** * Copied a good bunch of this from the original reroute included with comfy. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L453-L480
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.findInputSlot
override findInputSlot(name: string): number { return 0; }
/** Finds the input slot; since we only ever have one, this is always 0. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L511-L513
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.findOutputSlot
override findOutputSlot(name: string): number { return 0; }
/** Finds the output slot; since we only ever have one, this is always 0. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L516-L518
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.setSize
override setSize(size: Vector2): void { const oldSize: Vector2 = [...this.size]; const newSize: Vector2 = [...size]; super.setSize(newSize); this.properties["size"] = [...this.size]; this.stabilizeLayout(oldSize, newSize); }
/** * When called, sets the node size, and the properties size, and calls out to `stabilizeLayout`. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L755-L761
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.stabilizeLayout
private stabilizeLayout(oldSize: Vector2, newSize: Vector2) { if (newSize[0] === 10 || newSize[1] === 10) { const props = this.properties; props["connections_layout"] = props["connections_layout"] || ["Left", "Right"]; const layout = props["connections_layout"]; props["connections_dir"] = pr...
/** * Looks at the current layout and determins if we also need to set a `connections_dir` based on * the size of the node (and what that connections_dir should be). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L767-L806
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.rotate
rotate(degrees: 90 | -90 | 180) { const w = this.size[0]; const h = this.size[1]; this.properties["connections_layout"] = this.properties["connections_layout"] || (this as RerouteNode).defaultConnectionsLayout; const inputDirIndex = LAYOUT_CLOCKWISE.indexOf(this.properties["connections_layout"][0]...
/** * Rotates the node, including changing size and moving input's and output's layouts. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L821-L847
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.manuallyHandleMove
private manuallyHandleMove(event: PointerEvent) { const shortcut = this.shortcuts.move; if (shortcut.state) { const diffX = Math.round((event.clientX - shortcut.initialMousePos[0]) / 10) * 10; const diffY = Math.round((event.clientY - shortcut.initialMousePos[1]) / 10) * 10; this.pos[0] = shor...
/** * Manually handles a move called from `onMouseMove` while the resize shortcut is active. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L852-L862
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.manuallyHandleResize
private manuallyHandleResize(event: PointerEvent) { const shortcut = this.shortcuts.resize; if (shortcut.state) { let diffX = Math.round((event.clientX - shortcut.initialMousePos[0]) / 10) * 10; let diffY = Math.round((event.clientY - shortcut.initialMousePos[1]) / 10) * 10; diffX *= shortcut....
/** * Manually handles a resize called from `onMouseMove` while the resize shortcut is active. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L867-L887
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.cycleConnection
private cycleConnection(ioDir: IoDirection) { const props = this.properties; props["connections_layout"] = props["connections_layout"] || ["Left", "Right"]; const propIdx = ioDir == IoDirection.INPUT ? 0 : 1; const oppositeIdx = propIdx ? 0 : 1; let currentLayout = props["connections_layout"][propId...
/** * Cycles the connection (input or output) to the next available layout. Note, when the width or * height is only 10px, then layout sticks to the ends of the longer size, and we move a * `connections_dir` property which is only paid attention to in `utils` when size of one axis * is equal to 10. * `ma...
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L896-L929
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.onMouseMove
override onMouseMove(event: PointerEvent): void { if (this.shortcuts.move.state) { const shortcut = this.shortcuts.move; if (shortcut.initialMousePos[0] === -1) { shortcut.initialMousePos[0] = event.clientX; shortcut.initialMousePos[1] = event.clientY; shortcut.initialNodePos[0] ...
/** * Handles a mouse move while this node is selected. Note, though, that the actual work here is * processed bycause the move and resize shortcuts set `canvas.node_capturing_input` to this node * when they start (otherwise onMouseMove only fires when the mouse moves within the node's * bounds). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L937-L963
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.onKeyDown
override onKeyDown(event: KeyboardEvent) { super.onKeyDown(event); const canvas = app.canvas as TLGraphCanvas; // Only handle shortcuts while we're enabled in the config. if (CONFIG_FAST_REROUTE_ENABLED) { for (const [key, shortcut] of Object.entries(this.shortcuts)) { if (!shortcut.state...
/** * Handles a key down while this node is selected, starting a shortcut if the keys are newly * pressed. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L969-L992
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.onKeyUp
override onKeyUp(event: KeyboardEvent) { super.onKeyUp(event); const canvas = app.canvas as TLGraphCanvas; // Only handle shortcuts while we're enabled in the config. if (CONFIG_FAST_REROUTE_ENABLED) { for (const [key, shortcut] of Object.entries(this.shortcuts)) { if (shortcut.state) { ...
/** * Handles a key up while this node is selected, canceling any current shortcut. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L997-L1019
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RerouteNode.onDeselected
override onDeselected(): void { super.onDeselected?.(); const canvas = app.canvas as TLGraphCanvas; for (const [key, shortcut] of Object.entries(this.shortcuts)) { shortcut.state = false; if ((shortcut as any).initialMousePos) { (shortcut as any).initialMousePos = [-1, -1]; if ((...
/** * Handles a deselection of the node, canceling any current shortcut. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/reroute.ts#L1024-L1037
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Logger.log
log(level: LogLevel, message: string, ...args: any[]) { const [n, v] = this.logParts(level, message, ...args); console[n]?.(...v); }
/** Logs a message to the console if it meets the current log level. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L114-L117
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Logger.logParts
logParts(level: LogLevel, message: string, ...args: any[]): [ConsoleLogFns, any[]] { if (level <= GLOBAL_LOG_LEVEL) { const css = LogLevelToCSS[level] || ""; if (level === LogLevel.DEV) { message = `🔧 ${message}`; } return [LogLevelToMethod[level], [`%c${message}`, css, ...args]]; ...
/** * Returns a tuple of the console function and its arguments. Useful for callers to make the * actual console.<fn> call to gain benefits of DevTools knowing the source line. * * If the input is invalid or the level doesn't meet the configuration level, then the return * value is an unknown function an...
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L131-L140
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
LogSession.logParts
logParts(level: LogLevel, message?: string, ...args: any[]): [ConsoleLogFns, any[]] { message = `${this.name || ""}${message ? " " + message : ""}`; return this.logger.logParts(level, message, ...args); }
/** * Returns the console log method to use and the arguments to pass so the call site can log from * there. This extra work at the call site allows for easier debugging in the dev console. * * const [logMethod, logArgs] = logger.logParts(LogLevel.DEBUG, message, ...args); * console[logMethod]?.(...
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L159-L162
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.initializeProgressBar
async initializeProgressBar() { if (CONFIG_SERVICE.getConfigValue("features.progress_bar.enabled")) { await this.rgthreeCssPromise; if (!this.progressBarEl) { this.progressBarEl = RgthreeProgressBar.create(); this.progressBarEl.setAttribute( "title", "Progress Bar by ...
/** * Initializes the top progress bar, if it's configured. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L287-L355
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.initializeGraphAndCanvasHooks
private async initializeGraphAndCanvasHooks() { const rgthree = this; // [🤮] To mitigate changes from https://github.com/rgthree/rgthree-comfy/issues/69 // and https://github.com/comfyanonymous/ComfyUI/issues/2193 we can try to store the workflow // node so our nodes can find the seralized node. Works...
/** * Initialize a bunch of hooks into LiteGraph itself so we can either keep state or context on * what's happening so nodes can respond appropriately. This is usually to fix broken assumptions * in the unowned code [🤮], but sometimes to add features or enhancements too [⭐]. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L362-L423
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.invokeExtensionsAsync
async invokeExtensionsAsync(method: "nodeCreated", ...args: any[]) { const comfyapp = app as ComfyApp; if (CONFIG_SERVICE.getConfigValue("features.invoke_extensions_async.node_created") === false) { const [m, a] = this.logParts( LogLevel.INFO, `Skipping invokeExtensionsAsync for applicable...
/** * [🤮] Handles the same exact thing as ComfyApp's `invokeExtensionsAsync`, but done here since * it is #private in ComfyApp because... of course it us. This is necessary since we purposefully * avoid using the ComfyNode due to historical instability and inflexibility for all the advanced * ui stuff rgth...
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L432-L472
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.dispatchCustomEvent
private dispatchCustomEvent(event: string, detail?: any) { if (detail != null) { return this.dispatchEvent(new CustomEvent(event, {detail})); } return this.dispatchEvent(new CustomEvent(event)); }
/** * Wraps `dispatchEvent` for easier CustomEvent dispatching. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L477-L482
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.initializeContextMenu
private async initializeContextMenu() { const that = this; setTimeout(async () => { const getCanvasMenuOptions = LGraphCanvas.prototype.getCanvasMenuOptions; LGraphCanvas.prototype.getCanvasMenuOptions = function (...args: any[]) { let existingOptions = getCanvasMenuOptions.apply(this, [...a...
/** * Initializes hooks specific to an rgthree-comfy context menu on the root menu. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L487-L526
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.getRgthreeContextMenuItems
private getRgthreeContextMenuItems(): ContextMenuItem[] { const [canvas, graph] = [app.canvas as TLGraphCanvas, app.graph as TLGraph]; const selectedNodes = Object.values(canvas.selected_nodes || {}); let rerouteNodes: LGraphNode[] = []; if (selectedNodes.length) { rerouteNodes = selectedNodes.fil...
/** * Returns the standard menu items for an rgthree-comfy context menu. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L531-L627
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.queueOutputNodes
async queueOutputNodes(nodeIds: number[]) { try { this.queueNodeIds = nodeIds; await app.queuePrompt(); } catch (e) { const [n, v] = this.logParts( LogLevel.ERROR, `There was an error queuing nodes ${nodeIds}`, e, ); console[n]?.(...v); } finally { ...
/** * Wraps an `app.queuePrompt` call setting a specific node id that we will inspect and change the * serialized graph right before being sent (below, in our `api.queuePrompt` override). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L633-L647
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.recursiveAddNodes
private recursiveAddNodes(nodeId: string, oldOutput: ComfyApiFormat, newOutput: ComfyApiFormat) { let currentId = nodeId; let currentNode = oldOutput[currentId]!; if (newOutput[currentId] == null) { newOutput[currentId] = currentNode; for (const inputValue of Object.values(currentNode.inputs || ...
/** * Recusively walks backwards from a node adding its inputs to the `newOutput` from `oldOutput`. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L652-L664
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.initializeComfyUIHooks
private initializeComfyUIHooks() { const rgthree = this; // Keep state for when the app is queuing the prompt. For instance, this is used for seed to // understand if we're serializing because we're queueing (and return the random seed to use) or // for saving the workflow (and keep -1, etc.). cons...
/** * Initialize a bunch of hooks into ComfyUI and/or LiteGraph itself so we can either keep state or * context on what's happening so nodes can respond appropriately. This is usually to fix broken * assumptions in the unowned code [🤮], but sometimes to add features or enhancements too [⭐]. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L671-L833
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.getNodeFromInitialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff
getNodeFromInitialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff( node: LGraphNode, ): SerializedLGraphNode | null { return ( this.initialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff?.nodes?.find( (n: SerializedLGraphNode) => n.id === node.id, ) ?? null ); }
/** * [🤮] Finds a node in the currently serializing workflow from the hook setup above. This is to * mitigate breakages from https://github.com/comfyanonymous/ComfyUI/issues/2193 we can try to * store the workflow node so our nodes can find the seralized node. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L840-L848
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.showMessage
async showMessage(data: RgthreeUiMessage) { let container = document.querySelector(".rgthree-top-messages-container"); if (!container) { container = document.createElement("div"); container.classList.add("rgthree-top-messages-container"); document.body.appendChild(container); } // If w...
/** * Shows a message in the UI. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L853-L917
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.hideMessage
async hideMessage(id: string) { const msg = document.querySelector(`.rgthree-top-messages-container > [msg-id="${id}"]`); if (msg?.classList.contains("-show")) { msg.classList.remove("-show"); await wait(750); } msg && msg.remove(); }
/** * Hides a message in the UI. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L922-L929
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
Rgthree.clearAllMessages
async clearAllMessages() { let container = document.querySelector(".rgthree-top-messages-container"); container && (container.innerHTML = ""); }
/** * Clears all messages in the UI. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/rgthree.ts#L934-L937
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreeSeed.handleApiHijacking
handleApiHijacking(e: CustomEvent<ComfyApiPrompt>) { // Don't do any work if we're muted/bypassed. if (this.mode === LiteGraph.NEVER || this.mode === 4) { return; } const workflow = e.detail.workflow; const output = e.detail.output; let workflowNode = workflow?.nodes?.find((n: Serialized...
/** * Intercepts the prompt right before ComfyUI sends it to the server (as fired from rgthree) so we * can inspect the prompt and workflow data and change swap in the seeds. * * Note, the original implementation tried to change the widget value itself when the graph was * queued (and the relied on Comfy...
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/seed.ts#L202-L244
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreeSeed.getSeedToUse
private getSeedToUse() { const inputSeed: number = this.seedWidget.value; let seedToUse: number | null = null; // If our input seed was a special seed, then handle it. if (SPECIAL_SEEDS.includes(inputSeed)) { // If the last seed was not a special seed and we have increment/decrement, then do that...
/** * Determines a seed to use depending on the seed widget's current value and the last used seed. * There are no sideffects to calling this method. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/seed.ts#L250-L276
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
getTypeFromSlot
function getTypeFromSlot( slot: INodeInputSlot | INodeOutputSlot | undefined, dir: IoDirection, skipSelf = false, ): ConnectionType | null { let graph = app.graph as LGraph; let type = slot?.type; if (!skipSelf && type != null && type != "*") { return { type: type as string, label: slot?.label, name: sl...
/** * Gets the type from a slot. If the type is '*' then it will follow the node to find the next slot. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/utils.ts#L629-L660
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
BookmarksService.getCurrentBookmarks
getCurrentBookmarks() { return app.graph._nodes .filter((n): n is Bookmark => n.type === NodeTypesString.BOOKMARK) .sort((a, b) => a.title.localeCompare(b.title)); }
/** * Gets a list of the current bookmarks within the current workflow. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/bookmarks_services.ts#L10-L14
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
ConfigService.setConfigValues
async setConfigValues(changed: { [key: string]: any }) { const body = new FormData(); body.append("json", JSON.stringify(changed)); const response = await rgthreeApi.fetchJson("/config", { method: "POST", body }); if (response.status === "ok") { for (const [key, value] of Object.entries(changed)) ...
/** * Given an object of key:value changes it will send to the server and wait for a successful * response before setting the values on the local rgthreeConfig. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/config_service.ts#L23-L36
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastGroupsService.getBoundingsForAllNodes
getBoundingsForAllNodes() { if (!this.cachedNodeBoundings) { this.cachedNodeBoundings = {}; for (const node of app.graph._nodes) { this.cachedNodeBoundings[node.id] = node.getBounding(); } setTimeout(() => { this.cachedNodeBoundings = null; }, 50); } return this...
/** * Returns the boundings for all nodes on the graph, then clears it after a short delay. This is * to increase efficiency by caching the nodes' boundings when multiple groups are on the page. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/fast_groups_service.ts#L95-L106
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastGroupsService.recomputeInsideNodesForGroup
recomputeInsideNodesForGroup(group: LGraphGroup) { const cachedBoundings = this.getBoundingsForAllNodes(); const nodes = group.graph._nodes; group._nodes.length = 0; for (const node of nodes) { const node_bounding = cachedBoundings[node.id]; if (!node_bounding || !LiteGraph.overlapBounding(...
/** * This overrides `LGraphGroup.prototype.recomputeInsideNodes` to be much more efficient when * calculating for many groups at once (only compute all nodes once in `getBoundingsForAllNodes`). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/fast_groups_service.ts#L112-L124
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
FastGroupsService.getGroupsUnsorted
private getGroupsUnsorted(now: number) { const canvas = app.canvas as TLGraphCanvas; const graph = app.graph as TLGraph; if ( // Don't recalculate nodes if we're moving a group (added by ComfyUI in app.js) !canvas.selected_group_moving && (!this.groupsUnsorted.length || now - this.msLastU...
/** * Everything goes through getGroupsUnsorted, so we only get groups once. However, LiteGraph's * `recomputeInsideNodes` is inefficient when calling multiple groups (it iterates over all nodes * each time). So, we'll do our own dang thing, once. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/fast_groups_service.ts#L131-L150
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
KeyEventService.handleKeyDownOrUp
handleKeyDownOrUp(e: KeyboardEvent) { const key = e.key.toLocaleUpperCase(); // If we're already down, or already up, then ignore and don't fire. if ((e.type === 'keydown' && this.downKeys[key] === true) || (e.type === 'keyup' && this.downKeys[key] === undefined)) { return; } this.ctr...
/** * Adds a new queue item, unless the last is the same. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/key_events_services.ts#L62-L106
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
KeyEventService.dispatchCustomEvent
private dispatchCustomEvent(event: string, detail?: any) { if (detail != null) { return this.dispatchEvent(new CustomEvent(event, { detail })); } return this.dispatchEvent(new CustomEvent(event)); }
/** * Wraps `dispatchEvent` for easier CustomEvent dispatching. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/key_events_services.ts#L119-L124
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
KeyEventService.getKeysFromShortcut
private getKeysFromShortcut(shortcut: string | string[]) { let keys; if (typeof shortcut === "string") { // Rip all spaces out. Note, Comfy swallows space, so we don't have to handle it. Otherwise, // we would require space to be fed as "Space" or "Spacebar" instead of " ". shortcut = shortcut...
/** * Parses a shortcut string. * * - 's' => ['S'] * - 'shift + c' => ['SHIFT', 'C'] * - 'shift + meta + @' => ['SHIFT', 'META', '@'] * - 'shift + + + @' => ['SHIFT', '__PLUS__', '='] * - '+ + p' => ['__PLUS__', 'P'] */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/key_events_services.ts#L135-L148
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
KeyEventService.areAllKeysDown
areAllKeysDown(keys: string | string[]) { keys = this.getKeysFromShortcut(keys); return keys.every((k) => { return this.downKeys[k]; }); }
/** * Checks if all keys passed in are down. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/key_events_services.ts#L153-L158
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
KeyEventService.areOnlyKeysDown
areOnlyKeysDown(keys: string | string[], alsoAllowShift = false) { keys = this.getKeysFromShortcut(keys); const allKeysDown = this.areAllKeysDown(keys); const downKeysLength = Object.values(this.downKeys).length; // All keys are down and they're the only ones. if (allKeysDown && keys.length === down...
/** * Checks if only the keys passed in are down; optionally and additionally allowing "shift" key. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/comfyui/services/key_events_services.ts#L163-L180
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
patchNodeSlot
async function patchNodeSlot( node: SerializedNode | LGraphNode, ioDir: IoDirection, slot: number, linkId: number, op: "ADD" | "REMOVE", ) { patchedNodeSlots[node.id] = patchedNodeSlots[node.id] || {}; const patchedNode = patchedNodeSlots[node.id]!; if (ioDir == IoDirection.INPUT) { ...
/** * Internal patch node. We keep track of changes in patchedNodeSlots in case we're in a dry run. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/link_fixer.ts#L64-L133
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
nodeHasLinkId
function nodeHasLinkId( node: SerializedNode | LGraphNode, ioDir: IoDirection, slot: number, linkId: number, ) { // Patched data should be canonical. We can double check if fixing too. let has = false; if (ioDir === IoDirection.INPUT) { let nodeHasIt = node.inputs?.[slot]?.link === l...
/** * Internal to check if a node (or patched data) has a linkId. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/link_fixer.ts#L138-L172
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
nodeHasAnyLink
function nodeHasAnyLink(node: SerializedNode | LGraphNode, ioDir: IoDirection, slot: number) { // Patched data should be canonical. We can double check if fixing too. let hasAny = false; if (ioDir === IoDirection.INPUT) { let nodeHasAny = node.inputs?.[slot]?.link != null; if (patchedNodeSlots[n...
/** * Internal to check if a node (or patched data) has a linkId. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/link_fixer.ts#L177-L206
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreeProgressBar.currentNodeId
get currentNodeId() { const prompt = this.currentPromptExecution; const nodeId = prompt?.errorDetails?.node_id || prompt?.currentlyExecuting?.nodeId; return nodeId || null; }
/** The currentNodeId so outside callers can see what we're currently executing against. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/progress_bar.ts#L30-L34
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
PromptExecution.setPrompt
setPrompt(prompt: ComfyApiPrompt) { this.promptApi = prompt.output; this.totalNodes = Object.keys(this.promptApi).length; this.apiPrompt.resolve(null); }
/** * Sets the prompt and prompt-related data. This can technically come in lazily, like if the web * socket fires the 'execution-start' event before we actually get a response back from the * initial prompt call. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/prompt_service.ts#L50-L54
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
PromptExecution.executing
executing(nodeId: string | null, step?: number, maxSteps?: number) { if (nodeId == null) { // We're done, any left over nodes must be skipped... this.currentlyExecuting = null; return; } if (this.currentlyExecuting?.nodeId !== nodeId) { if (this.currentlyExecuting != null) { ...
/** * Updates the execution data depending on the passed data, fed from api events. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/prompt_service.ts#L73-L121
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
PromptExecution.error
error(details: any) { this.errorDetails = details; }
/** * If there's an error, we add the details. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/prompt_service.ts#L126-L128
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
PromptService.queuePrompt
async queuePrompt(prompt: ComfyApiPrompt) { return await api.queuePrompt(-1, prompt); }
/** A helper method, since we extend/override api.queuePrompt above anyway. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/prompt_service.ts#L249-L251
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
RgthreeApi.saveLoraInfo
async saveLoraInfo( file: string, data: Partial<RgthreeModelInfo>, ): Promise<RgthreeModelInfo | null> { return this.saveModelInfo("loras", file, data); }
/** * Saves partial data sending it to the backend.. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/rgthree_api.ts#L76-L81
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
parseWorkflowJson
function parseWorkflowJson(stringJson?: string) { stringJson = stringJson || "null"; // Starting around August 2024 the serialized JSON started to get messy and contained `NaN` (for // an is_changed property, specifically). NaN is not parseable, so we'll get those on out of there // and cleanup anything else we...
/** * Parses the workflow JSON and do any necessary cleanup. */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/utils_workflow.ts#L9-L16
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
getStyleSheet
async function getStyleSheet(name: string) { if (!CSS_STYLE_SHEETS.has(name)) { try { const response = await fetch( `rgthree/common/components/${name.replace("rgthree-", "").replace(/\-/g, "_")}.css`, ); const text = await response.text(); CSS_STYLE_SHEETS.set(name, text); } ca...
/** * Fetches the stylesheet for the component, matched by the element name (minus the "rgthree-" * prefix). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/components/base_custom_element.ts#L10-L23
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
rgthree-comfy
github_2023
rgthree
typescript
getTemplateMarkup
async function getTemplateMarkup(name: string) { if (!HTML_TEMPLATE_FILES.has(name)) { try { const response = await fetch( `rgthree/common/components/${name.replace("rgthree-", "").replace(/\-/g, "_")}.html`, ); const text = await response.text(); HTML_TEMPLATE_FILES.set(name, text...
/** * Fetches the stylesheet for the component, matched by the element name (minus the "rgthree-" * prefix). */
https://github.com/rgthree/rgthree-comfy/blob/5d771b8b56a343c24a26e8cea1f0c87c3d58102f/src_web/common/components/base_custom_element.ts#L29-L42
5d771b8b56a343c24a26e8cea1f0c87c3d58102f
ophiuchi-desktop
github_2023
cheeselemon
typescript
onStartServer
const onStartServer = () => { // Invoke the command };
// Write a text file to the `$APPCONFIG/app.conf` path
https://github.com/cheeselemon/ophiuchi-desktop/blob/d9bdd17b67bb57bdb3a22b3667fd70d3912bef51/src/components/page-components/home/index.tsx#L8-L10
d9bdd17b67bb57bdb3a22b3667fd70d3912bef51
jazz
github_2023
garden-co
typescript
FileShareAccount.migrate
async migrate() { await this._refs.root?.load(); // Initialize root if it doesn't exist if (!this.root || this.root.type !== 'file-share-account') { // Create a group that will own all shared files const publicGroup = Group.create({ owner: this }); publicGroup.addMember('everyone', 'reade...
/** The account migration is run on account creation and on every log-in. * You can use it to set up the account root and any other initial CoValues you need. */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/examples/file-share-svelte/src/lib/schema.ts#L30-L48
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
DraftBubbleTeaOrder.validate
validate() { const errors: string[] = []; if (!this.baseTea) { errors.push("Please select your preferred base tea."); } if (!this.deliveryDate) { errors.push("Plese select a delivery date."); } return { errors }; }
// validate if the draft is a valid order
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/examples/form/src/schema.ts#L46-L57
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
JazzAccount.migrate
migrate(this: JazzAccount) {}
/** The account migration is run on account creation and on every log-in. * You can use it to set up the account root and any other initial CoValues you need. */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/examples/image-upload/src/schema.ts#L13-L13
617ea91a130d64560624421d5e02af198b2d2086
jazz
github_2023
garden-co
typescript
MusicaAccount.migrate
migrate() { if (this.root === undefined) { const tracks = ListOfTracks.create([]); const rootPlaylist = Playlist.create({ tracks, title: "", }); this.root = MusicaAccountRoot.create({ rootPlaylist, playlists: ListOfPlaylists.create([]), activeTrack: n...
/** * The account migration is run on account creation and on every log-in. * You can use it to set up the account root and any other initial CoValues you need. */
https://github.com/garden-co/jazz/blob/617ea91a130d64560624421d5e02af198b2d2086/examples/music-player/src/1_schema.ts#L90-L106
617ea91a130d64560624421d5e02af198b2d2086