More template work & configure backend URL

This commit is contained in:
space-nuko
2023-05-24 23:21:06 -05:00
parent 4ae4e71616
commit 0fedef30c0
17 changed files with 764 additions and 623 deletions

View File

@@ -3,6 +3,12 @@ import { get, writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
export type ConfigState = {
/** Backend domain for ComfyUI */
comfyUIHostname: string,
/** Backend port for ComfyUI */
comfyUIPort: number,
/** Strip user state even if saving to local storage */
alwaysStripUserState: boolean,
@@ -14,18 +20,27 @@ export type ConfigState = {
}
type ConfigStateOps = {
getBackendURL: () => string
}
export type WritableConfigStateStore = Writable<ConfigState> & ConfigStateOps;
const store: Writable<ConfigState> = writable(
{
comfyUIHostname: "localhost",
comfyUIPort: 8188,
alwaysStripUserState: false,
promptForWorkflowName: false,
confirmWhenUnloadingUnsavedChanges: true
})
function getBackendURL(): string {
const state = get(store);
return `${window.location.protocol}://${state.comfyUIHostname}:${state.comfyUIPort}`
}
const configStateStore: WritableConfigStateStore =
{
...store
...store,
getBackendURL
}
export default configStateStore;

View File

@@ -1005,6 +1005,9 @@ function createRaw(workflow: ComfyBoxWorkflow | null = null): WritableLayoutStat
store.set(state)
}
/*
* NOTE: Modifies the template in-place, be sure you cloned it beforehand!
*/
function insertTemplate(template: SerializedComfyBoxTemplate, graph: LGraph, templateNodeIDToNode: Record<NodeID, LGraphNode>, container: ContainerLayout, childIndex: number): IDragItem {
const idMapping: Record<DragItemID, DragItemID> = {};

View File

@@ -7,7 +7,7 @@ export type ModalState = Record<string, any>;
export type ModalButton = {
name: string,
variant: "primary" | "secondary",
onClick: (state: ModalData) => void,
onClick: (state: ModalData) => boolean | void,
closeOnClick?: boolean
}
export interface ModalData {

View File

@@ -11,7 +11,7 @@ export type UIState = {
uiEditMode: UIEditMode,
reconnecting: boolean,
isSavingToLocalStorage: boolean
forceSaveUserState: boolean | null
}
type UIStateOps = {
@@ -29,7 +29,7 @@ const store: Writable<UIState> = writable(
uiEditMode: "widgets",
reconnecting: false,
isSavingToLocalStorage: false,
forceSaveUserState: null,
})
function reconnecting() {