mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-27 02:04:09 +00:00
[TS] Enable strict mode (#3136)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { type StatusWsMessageStatus, TaskItem } from '@/schemas/apiSchema'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useLitegraphService } from '@/services/litegraphService'
|
||||
@@ -92,6 +91,7 @@ export function $el<TTag extends string>(
|
||||
return element as ElementType<TTag>
|
||||
}
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
function dragElement(dragEl): () => void {
|
||||
var posDiffX = 0,
|
||||
posDiffY = 0,
|
||||
@@ -148,6 +148,7 @@ function dragElement(dragEl): () => void {
|
||||
dragEl.style.top = newPosY + 'px'
|
||||
dragEl.style.bottom = 'unset'
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
if (savePos) {
|
||||
localStorage.setItem(
|
||||
'Comfy.MenuPosition',
|
||||
@@ -170,10 +171,12 @@ function dragElement(dragEl): () => void {
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
let savePos = undefined
|
||||
restorePos()
|
||||
savePos = true
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
function dragMouseDown(e) {
|
||||
e = e || window.event
|
||||
e.preventDefault()
|
||||
@@ -185,6 +188,7 @@ function dragElement(dragEl): () => void {
|
||||
document.onmousemove = elementDrag
|
||||
}
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
function elementDrag(e) {
|
||||
e = e || window.event
|
||||
e.preventDefault()
|
||||
@@ -229,6 +233,7 @@ class ComfyList {
|
||||
element: HTMLDivElement
|
||||
button?: HTMLButtonElement
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
constructor(text, type?, reverse?) {
|
||||
this.#text = text
|
||||
this.#type = type || text.toLowerCase()
|
||||
@@ -249,6 +254,7 @@ class ComfyList {
|
||||
textContent: section
|
||||
}),
|
||||
$el('div.comfy-list-items', [
|
||||
// @ts-expect-error fixme ts strict error
|
||||
...(this.#reverse ? items[section].reverse() : items[section]).map(
|
||||
(item: TaskItem) => {
|
||||
// Allow items to specify a custom remove action (e.g. for interrupt current prompt)
|
||||
@@ -264,6 +270,7 @@ class ComfyList {
|
||||
textContent: 'Load',
|
||||
onclick: async () => {
|
||||
await app.loadGraphData(
|
||||
// @ts-expect-error fixme ts strict error
|
||||
item.prompt[3].extra_pnginfo.workflow,
|
||||
true,
|
||||
false
|
||||
@@ -310,6 +317,7 @@ class ComfyList {
|
||||
|
||||
async show() {
|
||||
this.element.style.display = 'block'
|
||||
// @ts-expect-error fixme ts strict error
|
||||
this.button.textContent = 'Close'
|
||||
|
||||
await this.load()
|
||||
@@ -317,6 +325,7 @@ class ComfyList {
|
||||
|
||||
hide() {
|
||||
this.element.style.display = 'none'
|
||||
// @ts-expect-error fixme ts strict error
|
||||
this.button.textContent = 'View ' + this.#text
|
||||
}
|
||||
|
||||
@@ -339,14 +348,22 @@ export class ComfyUI {
|
||||
lastQueueSize: number
|
||||
queue: ComfyList
|
||||
history: ComfyList
|
||||
// @ts-expect-error fixme ts strict error
|
||||
autoQueueMode: string
|
||||
// @ts-expect-error fixme ts strict error
|
||||
graphHasChanged: boolean
|
||||
// @ts-expect-error fixme ts strict error
|
||||
autoQueueEnabled: boolean
|
||||
// @ts-expect-error fixme ts strict error
|
||||
menuContainer: HTMLDivElement
|
||||
// @ts-expect-error fixme ts strict error
|
||||
queueSize: Element
|
||||
// @ts-expect-error fixme ts strict error
|
||||
restoreMenuPosition: () => void
|
||||
// @ts-expect-error fixme ts strict error
|
||||
loadFile: () => void
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
constructor(app) {
|
||||
this.app = app
|
||||
this.dialog = new ComfyDialog()
|
||||
@@ -373,6 +390,7 @@ export class ComfyUI {
|
||||
style: { display: 'none' },
|
||||
parent: document.body,
|
||||
onchange: async () => {
|
||||
// @ts-expect-error fixme ts strict error
|
||||
await app.handleFile(fileInput.files[0])
|
||||
fileInput.value = ''
|
||||
}
|
||||
@@ -394,6 +412,7 @@ export class ComfyUI {
|
||||
}
|
||||
],
|
||||
{
|
||||
// @ts-expect-error fixme ts strict error
|
||||
onChange: (value) => {
|
||||
this.autoQueueMode = value.item.value
|
||||
}
|
||||
@@ -456,7 +475,9 @@ export class ComfyUI {
|
||||
$el('label', { innerHTML: 'Extra options' }, [
|
||||
$el('input', {
|
||||
type: 'checkbox',
|
||||
// @ts-expect-error fixme ts strict error
|
||||
onchange: (i) => {
|
||||
// @ts-expect-error fixme ts strict error
|
||||
document.getElementById('extraOptions').style.display = i
|
||||
.srcElement.checked
|
||||
? 'block'
|
||||
@@ -492,6 +513,7 @@ export class ComfyUI {
|
||||
value: this.batchCount,
|
||||
min: '1',
|
||||
style: { width: '35%', marginLeft: '0.4em' },
|
||||
// @ts-expect-error fixme ts strict error
|
||||
oninput: (i) => {
|
||||
this.batchCount = i.target.value
|
||||
/* Even though an <input> element with a type of range logically represents a number (since
|
||||
@@ -511,6 +533,7 @@ export class ComfyUI {
|
||||
min: '1',
|
||||
max: '100',
|
||||
value: this.batchCount,
|
||||
// @ts-expect-error fixme ts strict error
|
||||
oninput: (i) => {
|
||||
this.batchCount = i.srcElement.value
|
||||
// Note
|
||||
@@ -532,6 +555,7 @@ export class ComfyUI {
|
||||
type: 'checkbox',
|
||||
checked: false,
|
||||
title: 'Automatically queue prompt when the queue size hits 0',
|
||||
// @ts-expect-error fixme ts strict error
|
||||
onchange: (e) => {
|
||||
this.autoQueueEnabled = e.target.checked
|
||||
autoQueueModeEl.style.display = this.autoQueueEnabled
|
||||
|
||||
Reference in New Issue
Block a user