Proper mobile redirection
This commit is contained in:
@@ -333,7 +333,8 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
|
||||
/**
|
||||
* Handle keypress
|
||||
*
|
||||
* Ctrl + M mute/unmute selected nodes
|
||||
* Ctrl + M mute/unmute selected nodes
|
||||
* Ctrl + Space open node searchbox
|
||||
*/
|
||||
override processKey(e: KeyboardEvent): boolean | undefined {
|
||||
const res = super.processKey(e);
|
||||
@@ -353,7 +354,7 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
|
||||
}
|
||||
|
||||
if (e.type == "keydown") {
|
||||
// Ctrl + M mute/unmute
|
||||
// Ctrl + M - mute/unmute
|
||||
if (e.keyCode == 77 && e.ctrlKey) {
|
||||
if (this.selected_nodes) {
|
||||
for (var i in this.selected_nodes) {
|
||||
@@ -366,6 +367,21 @@ export default class ComfyGraphCanvas extends LGraphCanvas {
|
||||
}
|
||||
block_default = true;
|
||||
}
|
||||
// Ctrl + Space - open node searchbox
|
||||
else if (e.keyCode == 32 && e.ctrlKey) {
|
||||
const event = new MouseEvent("click");
|
||||
const searchBox = this.showSearchBox(event);
|
||||
const rect = this.canvas.getBoundingClientRect();
|
||||
const sbRect = searchBox.getBoundingClientRect();
|
||||
const clientX = rect.left + rect.width / 2 - sbRect.width / 2;
|
||||
const clientY = rect.top + rect.height / 2 - sbRect.height / 2
|
||||
searchBox.style.left = `${clientX}px`;
|
||||
searchBox.style.top = `${clientY}px`;
|
||||
// TODO better API
|
||||
event.initMouseEvent("click", true, true, window, 1, clientX, clientY, clientX, clientY, false, false, false, false, 0, null);
|
||||
this.adjustMouseEvent(event);
|
||||
block_default = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.graph.change();
|
||||
|
||||
@@ -125,8 +125,17 @@ export default class ComfyAPI {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private getHostname(): string {
|
||||
let hostname = this.hostname || location.hostname;
|
||||
if (hostname === "localhost") {
|
||||
// For dev use, assume same hostname as connected server
|
||||
hostname = location.hostname;
|
||||
}
|
||||
return hostname;
|
||||
}
|
||||
|
||||
private getBackendUrl(): string {
|
||||
const hostname = this.hostname || location.hostname;
|
||||
const hostname = this.getHostname()
|
||||
const port = this.port || location.port;
|
||||
return `${window.location.protocol}//${hostname}:${port}`
|
||||
}
|
||||
@@ -146,7 +155,7 @@ export default class ComfyAPI {
|
||||
existingSession = "?clientId=" + existingSession;
|
||||
}
|
||||
|
||||
const hostname = this.hostname || location.hostname;
|
||||
const hostname = this.getHostname()
|
||||
const port = this.port || location.port;
|
||||
|
||||
this.socket = new WebSocket(
|
||||
|
||||
@@ -211,7 +211,13 @@ export default class ComfyApp {
|
||||
this.lCanvas.allow_interaction = uiUnlocked;
|
||||
|
||||
// await this.#invokeExtensionsAsync("init");
|
||||
const defs = await this.api.getNodeDefs();
|
||||
let defs;
|
||||
try {
|
||||
defs = await this.api.getNodeDefs();
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not reach ComfyUI at ${this.api.getBackendUrl()}`);
|
||||
}
|
||||
await this.registerNodes(defs);
|
||||
|
||||
// Load previous workflow
|
||||
|
||||
@@ -24,7 +24,12 @@ let changedOptions: Partial<Record<keyof ConfigState, [any, any]>> = {}
|
||||
|
||||
function getBackendURL(): string {
|
||||
const state = get(store);
|
||||
return `${window.location.protocol}//${state.comfyUIHostname}:${state.comfyUIPort}`
|
||||
let hostname = state.comfyUIHostname
|
||||
if (hostname === "localhost") {
|
||||
// For dev use, assume same hostname as connected server
|
||||
hostname = location.hostname;
|
||||
}
|
||||
return `${window.location.protocol}//${hostname}:${state.comfyUIPort}`
|
||||
}
|
||||
|
||||
function canShowNotificationText(): boolean {
|
||||
|
||||
@@ -618,6 +618,9 @@ export async function readFileToText(file: File): Promise<string> {
|
||||
reader.onload = async () => {
|
||||
resolve(reader.result as string);
|
||||
};
|
||||
reader.onerror = async () => {
|
||||
reject(reader.error);
|
||||
}
|
||||
reader.readAsText(file);
|
||||
})
|
||||
}
|
||||
@@ -709,3 +712,12 @@ export function canvasToBlob(canvas: HTMLCanvasElement): Promise<Blob> {
|
||||
canvas.toBlob(resolve);
|
||||
});
|
||||
}
|
||||
|
||||
export type SafetensorsMetadata = Record<string, string>
|
||||
|
||||
export async function getSafetensorsMetadata(folder: string, filename: string): Promise<SafetensorsMetadata> {
|
||||
const url = configState.getBackendURL();
|
||||
const params = new URLSearchParams({ filename })
|
||||
|
||||
return fetch(new Request(url + `/view_metadata/${folder}?` + params)).then(r => r.json())
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { type WidgetLayout } from "$lib/stores/layoutStates";
|
||||
import { get, writable, type Writable } from "svelte/store";
|
||||
import { isDisabled } from "./utils"
|
||||
import { getSafetensorsMetadata } from '$lib/utils';
|
||||
export let widget: WidgetLayout | null = null;
|
||||
export let isMobile: boolean = false;
|
||||
let node: ComfyComboNode | null = null;
|
||||
|
||||
Reference in New Issue
Block a user