Better seed randomizer

This commit is contained in:
space-nuko
2023-04-25 07:34:27 -07:00
parent cd0fde0f55
commit f0a520b9a1
11 changed files with 108 additions and 92 deletions

View File

@@ -206,8 +206,6 @@ export default class ComfyApp {
private registerNodeTypeOverrides() {
ComfyApp.node_type_overrides["SaveImage"] = nodes.ComfySaveImageNode;
ComfyApp.node_type_overrides["PreviewImage"] = nodes.ComfyPreviewImageNode;
ComfyApp.node_type_overrides["KSampler"] = nodes.ComfyKSamplerNode;
ComfyApp.node_type_overrides["KSamplerAdvanced"] = nodes.ComfyKSamplerAdvancedNode;
}
private registerWidgetTypeOverrides() {
@@ -389,10 +387,6 @@ export default class ComfyApp {
this.api.addEventListener("executing", ({ detail }: CustomEvent) => {
queueState.executingUpdated(detail.node);
const node = this.lGraph.getNodeById(detail.node) as ComfyGraphNode;
if (node?.onExecuting) {
node.onExecuting();
}
this.lGraph.setDirtyCanvas(true, false);
});
@@ -496,7 +490,10 @@ export default class ComfyApp {
if (widgets) {
for (let i = 0; i < widgets.length; i++) {
const widget = widgets[i];
if (!widget.options || widget.options.serialize !== false) {
let isVirtual = false;
if ("isVirtual" in widget)
isVirtual = (widget as ComfyWidget<any, any>).isVirtual;
if ((!widget.options || widget.options.serialize !== false) && !isVirtual) {
let value = widget.serializeValue ? await widget.serializeValue(n, i) : widget.value;
inputs[widget.name] = value
}
@@ -575,9 +572,9 @@ export default class ComfyApp {
for (const widget of node.widgets) {
// Allow widgets to run callbacks after a prompt has been queued
// e.g. random seed after every gen
// if (widget.afterQueued) {
// widget.afterQueued();
// }
if ("afterQueued" in widget) {
(widget as ComfyWidget<any, any>).afterQueued();
}
}
}
}

View File

@@ -60,20 +60,18 @@
let ctor: any = null;
// custom widgets with TypeScript sources
if (item.isVirtual) {
let override = ComfyApp.widget_type_overrides[item.widget.type]
if (override) {
return override;
}
let override = ComfyApp.widget_type_overrides[item.widget.type]
if (override) {
return override;
}
// litegraph.ts built-in widgets
switch (item.widget.type) {
case "combo":
case "combo":
return ComboWidget;
case "number":
case "number":
return RangeWidget;
case "text":
case "text":
return TextWidget;
}
@@ -81,8 +79,7 @@
}
function updateNodeName(node: LGraphNode, value: string) {
console.log("CHA")
nodeState.nodeStateChanged(node);
nodeState.nodeStateChanged(node);
}
</script>
@@ -98,20 +95,20 @@
<div class="animation-wrapper" class:is-executing={dragItem.isNodeExecuting} animate:flip={{duration:flipDurationMs}}>
<Block>
{#if $uiState.unlocked}
<div class="handle" on:mousedown={startDrag} on:touchstart={startDrag} on:mouseup={stopDrag} on:touchend={stopDrag}>
<Move/>
</div>
<div class="handle" on:mousedown={startDrag} on:touchstart={startDrag} on:mouseup={stopDrag} on:touchend={stopDrag}>
<Move/>
</div>
{/if}
<label for={String(id)}>
<BlockTitle>
{#if $uiState.unlocked}
<input bind:value={dragItem.node.title} type="text" minlength="1" on:input="{(v) => { updateNodeName(node, v) }}"/>
{:else}
{node.title}
{/if}
{#if node.title !== node.type}
<span class="node-type">({node.type})</span>
{/if}
{#if $uiState.unlocked}
<input bind:value={dragItem.node.title} type="text" minlength="1" on:input="{(v) => { updateNodeName(node, v) }}"/>
{:else}
{node.title}
{/if}
{#if node.title !== node.type}
<span class="node-type">({node.type})</span>
{/if}
</BlockTitle>
</label>
{#each $widgetState[id] as item}
@@ -166,7 +163,7 @@
}
.node-type {
font-size: smaller;
color: var(--neutral-400);
}
font-size: smaller;
color: var(--neutral-400);
}
</style>