Random fixes

This commit is contained in:
space-nuko
2023-05-05 23:40:01 -05:00
parent 432ac95c94
commit 0a3010ddd1
12 changed files with 5464 additions and 3291 deletions

View File

@@ -29,7 +29,7 @@
let containerElem: HTMLDivElement; let containerElem: HTMLDivElement;
let resizeTimeout: NodeJS.Timeout | null; let resizeTimeout: NodeJS.Timeout | null;
let hasShownUIHelpToast: boolean = false; let hasShownUIHelpToast: boolean = false;
let uiTheme: string = ""; let uiTheme: string = "anapnoe";
let debugLayout: boolean = false; let debugLayout: boolean = false;
@@ -47,7 +47,8 @@
function queuePrompt() { function queuePrompt() {
console.log("Queuing!"); console.log("Queuing!");
app.queuePrompt(0, 1); const workflow = $layoutState.attrs.defaultSubgraph;
app.queuePrompt(0, 1, workflow);
} }
$: if (app?.lCanvas) app.lCanvas.allow_dragnodes = !$uiState.nodesLocked; $: if (app?.lCanvas) app.lCanvas.allow_dragnodes = !$uiState.nodesLocked;
@@ -56,11 +57,11 @@
$: if ($uiState.uiEditMode) $: if ($uiState.uiEditMode)
$layoutState.currentSelection = [] $layoutState.currentSelection = []
let graphSize = null; let graphSize = 0;
function toggleGraph() { function toggleGraph() {
if (graphSize == 0) { if (graphSize == 0) {
graphSize = 100; graphSize = 50;
app.resizeCanvas(); app.resizeCanvas();
} }
else { else {
@@ -68,7 +69,7 @@
} }
} }
let propsSidebarSize = 15; let propsSidebarSize = 0; //15;
function toggleProps() { function toggleProps() {
if (propsSidebarSize == 0) { if (propsSidebarSize == 0) {
@@ -157,6 +158,8 @@
(window as any).app = app; (window as any).app = app;
(window as any).appPane = uiPane; (window as any).appPane = uiPane;
await import('../../scss/ux.scss');
refreshView(); refreshView();
}) })
@@ -201,7 +204,7 @@
</div> </div>
<div id="bottombar"> <div id="bottombar">
<Button variant="primary" on:click={queuePrompt}> <Button variant="primary" on:click={queuePrompt}>
Run Queue Prompt
</Button> </Button>
<Button variant="secondary" on:click={toggleGraph}> <Button variant="secondary" on:click={toggleGraph}>
Toggle Graph Toggle Graph
@@ -252,7 +255,7 @@
<style lang="scss"> <style lang="scss">
#container { #container {
height: calc(100vh - 60px); height: calc(100vh - 70px);
max-width: 100vw; max-width: 100vw;
display: grid; display: grid;
width: 100%; width: 100%;
@@ -332,7 +335,7 @@
} }
:global(.splitpanes.comfy) { :global(.splitpanes.comfy) {
max-height: calc(100vh - 60px); max-height: calc(100vh - 70px);
max-width: 100vw; max-width: 100vw;
} }

View File

@@ -576,6 +576,9 @@ export default class ComfyApp {
return; return;
} }
if (tag === "")
tag = null;
this.processingQueue = true; this.processingQueue = true;
try { try {
while (this.queueItems.length) { while (this.queueItems.length) {

View File

@@ -57,18 +57,18 @@
$: if (entries) { $: if (entries) {
_entries = [] _entries = []
for (const entry of entries) { // for (const entry of entries) {
for (const outputs of Object.values(entry.outputs)) { // for (const outputs of Object.values(entry.outputs)) {
const allImages = outputs.images.map(r => { // const allImages = outputs.images.map(r => {
// TODO configure backend URL // // TODO configure backend URL
const url = "http://localhost:8188/view?" // const url = "http://localhost:8188/view?"
const params = new URLSearchParams(r) // const params = new URLSearchParams(r)
return url + params // return url + params
}); // });
//
_entries.push({ allImages, name: "Output" }) // _entries.push({ allImages, name: "Output" })
} // }
} // }
} }
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@@ -99,10 +99,7 @@ export default class ComfyImageCacheNode extends ComfyGraphNode {
if (newIndex === this.properties.index && !force) if (newIndex === this.properties.index && !force)
return; return;
console.debug("[ComfyImageCacheNode] setIndex", newIndex, force)
if (!this.properties.images || newIndex < 0 || newIndex >= this.properties.images.images.length) { if (!this.properties.images || newIndex < 0 || newIndex >= this.properties.images.images.length) {
console.debug("[ComfyImageCacheNode] invalid indexes", newIndex, this.properties.images)
return return
} }

View File

@@ -94,9 +94,9 @@ export class ComfySelectorTwo extends ComfyGraphNode {
ctx.fillStyle = "#AFB"; ctx.fillStyle = "#AFB";
var y = (this.selected + 1) * LiteGraph.NODE_SLOT_HEIGHT + 6; var y = (this.selected + 1) * LiteGraph.NODE_SLOT_HEIGHT + 6;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(50, y); ctx.moveTo(65, y);
ctx.lineTo(50, y + LiteGraph.NODE_SLOT_HEIGHT); ctx.lineTo(65, y + LiteGraph.NODE_SLOT_HEIGHT);
ctx.lineTo(34, y + LiteGraph.NODE_SLOT_HEIGHT * 0.5); ctx.lineTo(49, y + LiteGraph.NODE_SLOT_HEIGHT * 0.5);
ctx.fill(); ctx.fill();
}; };

View File

@@ -141,7 +141,7 @@ export abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
inputNode: LGraphNode, inputNode: LGraphNode,
inputIndex: number inputIndex: number
): boolean { ): boolean {
if (this.autoConfig && "config" in input) { if (this.autoConfig && "config" in input && this.outputs.length === 0) {
this.doAutoConfig(input as IComfyInputSlot) this.doAutoConfig(input as IComfyInputSlot)
} }
@@ -397,11 +397,13 @@ export type GalleryOutputEntry = {
} }
export interface ComfyGalleryProperties extends ComfyWidgetProperties { export interface ComfyGalleryProperties extends ComfyWidgetProperties {
index: number
} }
export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> { export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
override properties: ComfyGalleryProperties = { override properties: ComfyGalleryProperties = {
defaultValue: [] defaultValue: [],
index: 0
} }
static slotLayout: SlotLayout = { static slotLayout: SlotLayout = {
@@ -420,14 +422,12 @@ export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
override outputIndex = null; override outputIndex = null;
override changedIndex = null; override changedIndex = null;
index: number = 0;
constructor(name?: string) { constructor(name?: string) {
super(name, []) super(name, [])
} }
override onExecute() { override onExecute() {
this.setOutputData(0, this.index) this.setOutputData(0, this.properties.index)
} }
override onAction(action: any) { override onAction(action: any) {
@@ -446,6 +446,7 @@ export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
// this.setValue(currentValue.concat(galleryItems)) // this.setValue(currentValue.concat(galleryItems))
this.setValue(galleryItems) this.setValue(galleryItems)
} }
this.setProperty("index", 0)
} }
} }
@@ -472,7 +473,11 @@ export class ComfyGalleryNode extends ComfyWidgetNode<GradioFileData[]> {
else { else {
super.setValue([]) super.setValue([])
} }
this.index = 0;
const len = get(this.value).length
if (this.properties.index < 0 || this.properties.index >= len) {
this.setProperty("index", clamp(this.properties.index, 0, len))
}
} }
} }

View File

@@ -12,7 +12,7 @@ type DragItemEntry = {
} }
export type LayoutAttributes = { export type LayoutAttributes = {
defaultWorkflow: string defaultSubgraph: string
} }
export type LayoutState = { export type LayoutState = {
@@ -160,7 +160,7 @@ const ALL_ATTRIBUTES: AttributesSpecList = [
// Workflow // Workflow
{ {
name: "defaultWorkflow", name: "defaultSubgraph",
type: "string", type: "string",
location: "workflow", location: "workflow",
editable: true editable: true
@@ -217,7 +217,7 @@ const store: Writable<LayoutState> = writable({
isMenuOpen: false, isMenuOpen: false,
isConfiguring: true, isConfiguring: true,
attrs: { attrs: {
defaultWorkflow: "" defaultSubgraph: ""
} }
}) })

View File

@@ -8,6 +8,7 @@
import type { ComfyGalleryNode } from "$lib/nodes/ComfyWidgetNodes"; import type { ComfyGalleryNode } from "$lib/nodes/ComfyWidgetNodes";
import type { FileData as GradioFileData } from "@gradio/upload"; import type { FileData as GradioFileData } from "@gradio/upload";
import type { SelectData as GradioSelectData } from "@gradio/utils"; import type { SelectData as GradioSelectData } from "@gradio/utils";
import { clamp } from "$lib/utils";
export let widget: WidgetLayout | null = null; export let widget: WidgetLayout | null = null;
let node: ComfyGalleryNode | null = null; let node: ComfyGalleryNode | null = null;
@@ -22,7 +23,11 @@
node = widget.node as ComfyGalleryNode node = widget.node as ComfyGalleryNode
nodeValue = node.value; nodeValue = node.value;
propsChanged = node.propsChanged; propsChanged = node.propsChanged;
node.index = 0;
const len = $nodeValue.length
if (node.properties.index < 0 || node.properties.index >= len) {
node.setProperty("index", clamp(node.properties.index, 0, len))
}
} }
}; };
@@ -46,7 +51,7 @@
}, 200) }, 200)
// Update index // Update index
node.index = e.detail.index as number; node.setProperty("index", e.detail.index as number)
} }
</script> </script>

View File

@@ -1 +1,5 @@
@import "gradio"; @import "gradio";
body {
overflow: hidden;
}

View File

@@ -504,7 +504,7 @@ input[type=number],
input[type=text], input[type=text],
input[type=password], input[type=password],
input[type=email] { input[type=email] {
height:34px !important; height: 34px;
} }
.gradio-slider input[type=range] { .gradio-slider input[type=range] {
align-self: flex-start; align-self: flex-start;
@@ -742,9 +742,10 @@ input[type=range]::-ms-fill-upper {
.widget > .wrapper.comfy-combo .svelte-select { .widget > .wrapper.comfy-combo .svelte-select {
--font-size: 13px; --font-size: 13px;
--height: 32px; --height: 24px;
--input-padding: 0px; --input-padding: 0px;
--chevron-height: 32px; --chevron-width: 24px;
--chevron-height: 24px;
--padding: 0 0 0 8px; --padding: 0 0 0 8px;
background: var(--ae-input-bg-color) !important; background: var(--ae-input-bg-color) !important;

View File

@@ -8,7 +8,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy'
export default defineConfig({ export default defineConfig({
clearScreen: false, clearScreen: false,
plugins: [ plugins: [
FullReload(["src/**/*.{js,ts,svelte}"]), FullReload(["src/**/*.{js,ts,scss,svelte}"]),
svelte(), , svelte(), ,
viteStaticCopy({ viteStaticCopy({
targets: [ targets: [