6 Commits

Author SHA1 Message Date
space-nuko
abd31401f0 Merge pull request #148 from haze/hb/vibrateIfPossible
`vibrateIfPossible`: fixes iOS safari uncaught exceptions & etc
2023-08-25 23:43:22 -05:00
haze
2f48f96830 Update CheckboxWidget.svelte 2023-08-25 15:26:15 -04:00
Haze Booth
63d51e9119 Introduce vibrateIfPossible into the utils package. This will check if the browser
has support for vibrating. This fixes a number of bugs for iOS safari & friends.
2023-08-24 12:02:22 -04:00
space-nuko
6f02912d2e Merge pull request #125 from space-nuko/restore-params2
Upgrade Svelte and dependency versions
2023-07-07 09:49:39 -05:00
space-nuko
3b49bac47b Merge pull request #126 from space-nuko/server-args
Add arguments to serve.py
2023-07-07 09:49:27 -05:00
space-nuko
33ed379a98 Add arguments to serve.py 2023-07-07 09:12:28 -05:00
13 changed files with 65 additions and 50 deletions

View File

@@ -2,15 +2,19 @@
import http.server import http.server
import socketserver import socketserver
import argparse
PORT = 8000 parser = argparse.ArgumentParser()
parser.add_argument("-l", "--listen", type=str, default="localhost", help="Listen address for ComfyBox server")
parser.add_argument("-p", "--port", type=int, default=8000, help="Port for ComfyBox server")
args = parser.parse_args()
message = f"""Starting ComfyBox. message = f"""Starting ComfyBox.
Be sure you've started ComfyUI already using this command: Be sure you've started ComfyUI already using this command:
python main.py --enable-cors-header python main.py --enable-cors-header
Serving at http://localhost:{PORT}... Serving at http://{args.listen}:{args.port}...
""" """
# python -m http.server will sometimes send incorrect MIME types. # python -m http.server will sometimes send incorrect MIME types.
@@ -19,33 +23,34 @@ Serving at http://localhost:{PORT}...
# Hopefully this will cover everything. # Hopefully this will cover everything.
class HttpRequestHandler(http.server.SimpleHTTPRequestHandler): class HttpRequestHandler(http.server.SimpleHTTPRequestHandler):
extensions_map = { extensions_map = {
'': 'application/octet-stream', "": "application/octet-stream",
'.manifest': 'text/cache-manifest', ".manifest": "text/cache-manifest",
'.html': 'text/html', ".html": "text/html",
'.png': 'image/png', ".png": "image/png",
'.jpg': 'image/jpg', ".jpg": "image/jpg",
'.jpeg': 'image/jpeg', ".jpeg": "image/jpeg",
'.gif': 'image/gif', ".gif": "image/gif",
'.svg': 'image/svg+xml', ".svg": "image/svg+xml",
'.css': 'text/css', ".css": "text/css",
'.js': 'application/x-javascript', ".js": "application/x-javascript",
'.mjs': 'application/x-javascript', ".mjs": "application/x-javascript",
'.cjs': 'application/x-javascript', ".cjs": "application/x-javascript",
'.wasm': 'application/wasm', ".wasm": "application/wasm",
'.json': 'application/json', ".json": "application/json",
'.xml': 'application/xml', ".xml": "application/xml",
'.xml': 'application/xml', ".xml": "application/xml",
'.pdf': 'application/pdf', ".pdf": "application/pdf",
'.webp': 'image/webp', ".webp": "image/webp",
'.avif': 'image/avif', ".avif": "image/avif",
'.heic': 'image/heic', ".heic": "image/heic",
'.heif': 'image/heif', ".heif": "image/heif",
'.mp3': 'audio/mpeg', ".mp3": "audio/mpeg",
'.mp4': 'video/mp4', ".mp4": "video/mp4",
'.m4v': 'video/mp4' ".m4v": "video/mp4",
} }
httpd = socketserver.TCPServer(("localhost", PORT), HttpRequestHandler)
httpd = socketserver.TCPServer((args.listen, args.port), HttpRequestHandler)
try: try:
print(message) print(message)

View File

@@ -12,7 +12,7 @@
import {cubicIn} from 'svelte/easing'; import {cubicIn} from 'svelte/easing';
import { flip } from 'svelte/animate'; import { flip } from 'svelte/animate';
import { type ContainerLayout, type WidgetLayout, type IDragItem } from "$lib/stores/layoutStates"; import { type ContainerLayout, type WidgetLayout, type IDragItem } from "$lib/stores/layoutStates";
import { startDrag, stopDrag } from "$lib/utils" import { startDrag, stopDrag, vibrateIfPossible } from "$lib/utils"
import { writable, type Writable } from "svelte/store"; import { writable, type Writable } from "svelte/store";
import { isHidden } from "$lib/widgets/utils"; import { isHidden } from "$lib/widgets/utils";
import { handleContainerConsider, handleContainerFinalize } from "./utils"; import { handleContainerConsider, handleContainerFinalize } from "./utils";
@@ -56,7 +56,7 @@
}; };
function handleClick(e: CustomEvent<boolean>) { function handleClick(e: CustomEvent<boolean>) {
navigator.vibrate(20) vibrateIfPossible(20)
$isOpen = e.detail $isOpen = e.detail
} }

View File

@@ -12,7 +12,7 @@
import {cubicIn} from 'svelte/easing'; import {cubicIn} from 'svelte/easing';
import { flip } from 'svelte/animate'; import { flip } from 'svelte/animate';
import { type ContainerLayout, type WidgetLayout, type IDragItem, type WritableLayoutStateStore } from "$lib/stores/layoutStates"; import { type ContainerLayout, type WidgetLayout, type IDragItem, type WritableLayoutStateStore } from "$lib/stores/layoutStates";
import { startDrag, stopDrag } from "$lib/utils" import { startDrag, stopDrag, vibrateIfPossible } from "$lib/utils"
import type { Writable } from "svelte/store"; import type { Writable } from "svelte/store";
import { isHidden } from "$lib/widgets/utils"; import { isHidden } from "$lib/widgets/utils";
import { handleContainerConsider, handleContainerFinalize } from "./utils"; import { handleContainerConsider, handleContainerFinalize } from "./utils";
@@ -62,7 +62,7 @@
} }
function handleSelect() { function handleSelect() {
navigator.vibrate(20) vibrateIfPossible(20)
} }
function _startDrag(e: MouseEvent | TouchEvent) { function _startDrag(e: MouseEvent | TouchEvent) {

View File

@@ -828,3 +828,9 @@ const MOBILE_USER_AGENTS = ["iPhone", "iPad", "Android", "BlackBerry", "WebOs"].
export function isMobileBrowser(userAgent: string): boolean { export function isMobileBrowser(userAgent: string): boolean {
return MOBILE_USER_AGENTS.some(a => userAgent.match(a)) return MOBILE_USER_AGENTS.some(a => userAgent.match(a))
} }
export function vibrateIfPossible(strength: number | Array<number>) {
if (window.navigator.vibrate) {
window.navigator.vibrate(strength);
}
}

View File

@@ -3,6 +3,7 @@
import { Button } from "@gradio/button"; import { Button } from "@gradio/button";
import { get, type Writable, writable } from "svelte/store"; import { get, type Writable, writable } from "svelte/store";
import { isDisabled } from "./utils" import { isDisabled } from "./utils"
import { vibrateIfPossible } from "$lib/utils";
import type { ComfyButtonNode } from "$lib/nodes/widgets"; import type { ComfyButtonNode } from "$lib/nodes/widgets";
export let widget: WidgetLayout | null = null; export let widget: WidgetLayout | null = null;
@@ -24,7 +25,7 @@
function onClick(e: MouseEvent) { function onClick(e: MouseEvent) {
node.onClick(); node.onClick();
navigator.vibrate(20) vibrateIfPossible(20)
} }
const style = { const style = {

View File

@@ -4,6 +4,7 @@
import { Checkbox } from "@gradio/form"; import { Checkbox } from "@gradio/form";
import { get, type Writable, writable } from "svelte/store"; import { get, type Writable, writable } from "svelte/store";
import { isDisabled } from "./utils" import { isDisabled } from "./utils"
import { vibrateIfPossible } from "$lib/utils";
import type { SelectData } from "@gradio/utils"; import type { SelectData } from "@gradio/utils";
import type { ComfyCheckboxNode } from "$lib/nodes/widgets"; import type { ComfyCheckboxNode } from "$lib/nodes/widgets";
@@ -25,7 +26,7 @@
function onSelect(e: CustomEvent<SelectData>) { function onSelect(e: CustomEvent<SelectData>) {
$nodeValue = e.detail.selected $nodeValue = e.detail.selected
navigator.vibrate(20) vibrateIfPossible(20)
} }
</script> </script>

View File

@@ -8,7 +8,7 @@
import { type WidgetLayout } from "$lib/stores/layoutStates"; import { type WidgetLayout } from "$lib/stores/layoutStates";
import { get, writable, type Writable } from "svelte/store"; import { get, writable, type Writable } from "svelte/store";
import { isDisabled } from "./utils" import { isDisabled } from "./utils"
import { clamp, getSafetensorsMetadata } from '$lib/utils'; import { clamp, getSafetensorsMetadata, vibrateIfPossible } from '$lib/utils';
export let widget: WidgetLayout | null = null; export let widget: WidgetLayout | null = null;
export let isMobile: boolean = false; export let isMobile: boolean = false;
let node: ComfyComboNode | null = null; let node: ComfyComboNode | null = null;
@@ -70,7 +70,7 @@
function onFocus() { function onFocus() {
// console.warn("FOCUS") // console.warn("FOCUS")
if (listOpen) { if (listOpen) {
navigator.vibrate(20) vibrateIfPossible(20)
} }
} }
@@ -86,7 +86,7 @@
function handleSelect(index: number) { function handleSelect(index: number) {
// console.warn("SEL", index) // console.warn("SEL", index)
navigator.vibrate(20) vibrateIfPossible(20)
const item = $valuesForCombo[index] const item = $valuesForCombo[index]
activeIndex = index; activeIndex = index;
$nodeValue = item.value $nodeValue = item.value

View File

@@ -3,7 +3,7 @@
import { type WidgetLayout } from "$lib/stores/layoutStates"; import { type WidgetLayout } from "$lib/stores/layoutStates";
import { Range } from "$lib/components/gradio/form"; import { Range } from "$lib/components/gradio/form";
import { get, type Writable } from "svelte/store"; import { get, type Writable } from "svelte/store";
import { debounce } from "$lib/utils"; import { debounce, vibrateIfPossible } from "$lib/utils";
import interfaceState from "$lib/stores/interfaceState"; import interfaceState from "$lib/stores/interfaceState";
import { isDisabled } from "./utils" import { isDisabled } from "./utils"
export let widget: WidgetLayout | null = null; export let widget: WidgetLayout | null = null;
@@ -96,7 +96,7 @@
lastDisplayValue = option; lastDisplayValue = option;
canVibrate = false; canVibrate = false;
setTimeout(() => { canVibrate = true }, 30) setTimeout(() => { canVibrate = true }, 30)
navigator.vibrate(10) vibrateIfPossible(10)
} }
} }
</script> </script>

View File

@@ -5,7 +5,7 @@
import { get, type Writable, writable } from "svelte/store"; import { get, type Writable, writable } from "svelte/store";
import { isDisabled } from "./utils" import { isDisabled } from "./utils"
import type { SelectData } from "@gradio/utils"; import type { SelectData } from "@gradio/utils";
import { clamp } from "$lib/utils"; import { clamp, vibrateIfPossible } from "$lib/utils";
import type { ComfyRadioNode } from "$lib/nodes/widgets"; import type { ComfyRadioNode } from "$lib/nodes/widgets";
export let widget: WidgetLayout | null = null; export let widget: WidgetLayout | null = null;
@@ -34,7 +34,7 @@
function onSelect(e: CustomEvent<SelectData>) { function onSelect(e: CustomEvent<SelectData>) {
node.setValue(e.detail.value) node.setValue(e.detail.value)
node.index = e.detail.index as number node.index = e.detail.index as number
navigator.vibrate(20) vibrateIfPossible(20)
} }
</script> </script>

View File

@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import ComfyApp, { type SerializedAppState } from "$lib/components/ComfyApp"; import ComfyApp, { type SerializedAppState } from "$lib/components/ComfyApp";
import workflowState, { ComfyBoxWorkflow } from "$lib/stores/workflowState"; import workflowState, { ComfyBoxWorkflow } from "$lib/stores/workflowState";
import { vibrateIfPossible } from "$lib/utils";
import { Link, Toolbar } from "framework7-svelte" import { Link, Toolbar } from "framework7-svelte"
@@ -11,7 +12,7 @@
$: workflow = $workflowState.activeWorkflow; $: workflow = $workflowState.activeWorkflow;
function queuePrompt() { function queuePrompt() {
navigator.vibrate(20) vibrateIfPossible(20)
app.runDefaultQueueAction() app.runDefaultQueueAction()
} }
</script> </script>

View File

@@ -2,7 +2,7 @@
import ComfyApp, { type SerializedAppState } from "$lib/components/ComfyApp"; import ComfyApp, { type SerializedAppState } from "$lib/components/ComfyApp";
import queueState from "$lib/stores/queueState"; import queueState from "$lib/stores/queueState";
import workflowState, { ComfyBoxWorkflow } from "$lib/stores/workflowState"; import workflowState, { ComfyBoxWorkflow } from "$lib/stores/workflowState";
import { getNodeInfo } from "$lib/utils" import { getNodeInfo, vibrateIfPossible } from "$lib/utils"
import { LayoutTextSidebarReverse, Image, Grid } from "svelte-bootstrap-icons"; import { LayoutTextSidebarReverse, Image, Grid } from "svelte-bootstrap-icons";
import { Link, Toolbar } from "framework7-svelte" import { Link, Toolbar } from "framework7-svelte"
@@ -21,12 +21,12 @@
$: workflow = $workflowState.activeWorkflow; $: workflow = $workflowState.activeWorkflow;
function queuePrompt() { function queuePrompt() {
navigator.vibrate(20) vibrateIfPossible(20)
app.runDefaultQueueAction() app.runDefaultQueueAction()
} }
async function refreshCombos() { async function refreshCombos() {
navigator.vibrate(20) vibrateIfPossible(20)
await app.refreshComboInNodes() await app.refreshComboInNodes()
} }
@@ -34,7 +34,7 @@
if (!fileInput) if (!fileInput)
return; return;
navigator.vibrate(20) vibrateIfPossible(20)
app.querySave() app.querySave()
} }
@@ -42,7 +42,7 @@
if (!fileInput) if (!fileInput)
return; return;
navigator.vibrate(20) vibrateIfPossible(20)
fileInput.value = null; fileInput.value = null;
fileInput.click(); fileInput.click();
} }
@@ -52,7 +52,7 @@
} }
function doSaveLocal(): void { function doSaveLocal(): void {
navigator.vibrate(20) vibrateIfPossible(20)
app.saveStateToLocalStorage(); app.saveStateToLocalStorage();
} }

View File

@@ -34,12 +34,12 @@
} }
async function refreshCombos() { async function refreshCombos() {
navigator.vibrate(20) vibrateIfPossible(20)
await app.refreshComboInNodes() await app.refreshComboInNodes()
} }
function doSaveLocal(): void { function doSaveLocal(): void {
navigator.vibrate(20) vibrateIfPossible(20)
app.saveStateToLocalStorage(); app.saveStateToLocalStorage();
} }

View File

@@ -3,6 +3,7 @@
import workflowState, { ComfyBoxWorkflow, type WorkflowInstID } from "$lib/stores/workflowState"; import workflowState, { ComfyBoxWorkflow, type WorkflowInstID } from "$lib/stores/workflowState";
import { onMount } from "svelte"; import { onMount } from "svelte";
import interfaceState from "$lib/stores/interfaceState"; import interfaceState from "$lib/stores/interfaceState";
import { vibrateIfPossible } from "$lib/utils";
import { f7 } from 'framework7-svelte'; import { f7 } from 'framework7-svelte';
import { XCircle } from 'svelte-bootstrap-icons'; import { XCircle } from 'svelte-bootstrap-icons';
@@ -31,7 +32,7 @@
if (!fileInput) if (!fileInput)
return; return;
navigator.vibrate(20) vibrateIfPossible(20);
fileInput.value = null; fileInput.value = null;
fileInput.click(); fileInput.click();
} }