window object does weird things, rename root ID

when used with (window as any).app, it uses the element with id #app instead
This commit is contained in:
space-nuko
2023-05-17 21:31:37 -05:00
parent 0cecbee21c
commit 967989494c
15 changed files with 51 additions and 42 deletions

View File

@@ -1,13 +1,13 @@
import { parseWhateverIntoImageMetadata, type ComfyBoxImageMetadata, type ComfyUploadImageType } from "$lib/utils";
import { BuiltInSlotType, LiteGraph, type IComboWidget, type ITextWidget, type PropertyLayout, type SlotLayout } from "@litegraph-ts/core";
import { get } from "svelte/store";
import { get, writable, type Writable } from "svelte/store";
import GalleryWidget from "$lib/widgets/GalleryWidget.svelte";
import type { ComfyWidgetProperties } from "./ComfyWidgetNode";
import ComfyWidgetNode from "./ComfyWidgetNode";
export interface ComfyGalleryProperties extends ComfyWidgetProperties {
index: number,
index: number | null,
updateMode: "replace" | "append",
}
@@ -45,6 +45,9 @@ export default class ComfyGalleryNode extends ComfyWidgetNode<ComfyBoxImageMetad
selectedIndexWidget: ITextWidget;
modeWidget: IComboWidget;
imageWidth: Writable<number> = writable(0);
imageHeight: Writable<number> = writable(0);
constructor(name?: string) {
super(name, [])
this.selectedIndexWidget = this.addWidget("text", "Selected", String(this.properties.index), "index")
@@ -59,8 +62,15 @@ export default class ComfyGalleryNode extends ComfyWidgetNode<ComfyBoxImageMetad
}
override onExecute() {
this.setOutputData(0, get(this.value))
const value = get(this.value)
this.setOutputData(0, value)
this.setOutputData(1, this.properties.index)
if (this.properties.index != null && value && value[this.properties.index] != null) {
const image = value[this.properties.index];
image.width = get(this.imageWidth)
image.height = get(this.imageHeight)
}
}
override onAction(action: any, param: any, options: { action_call?: string }) {

View File

@@ -152,6 +152,9 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
}
private triggerChangeEvent(value: any) {
if (this.changedEventName == null)
return;
// console.debug("[Widget] trigger changed", this, value)
this.trigger(this.changedEventName, value)
}