mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 00:20:07 +00:00
Enable ts-strict for colorUtil, contextMenuFilter and linkRenderMode (#1313)
* Add types for colorUtil.ts * Add types for contextMenuFilter * Add types to linkRenderMode.ts
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { LiteGraph, LGraphCanvas } from '@comfyorg/litegraph'
|
||||
import { app } from '../../scripts/app'
|
||||
|
||||
@@ -33,14 +32,14 @@ const ext = {
|
||||
const clickedComboValue = currentNode.widgets
|
||||
?.filter(
|
||||
(w) =>
|
||||
w.type === 'combo' && w.options.values.length === values.length
|
||||
w.type === 'combo' && w.options.values?.length === values.length
|
||||
)
|
||||
.find((w) =>
|
||||
w.options.values.every((v, i) => v === values[i])
|
||||
w.options.values?.every((v, i) => v === values[i])
|
||||
)?.value
|
||||
|
||||
let selectedIndex = clickedComboValue
|
||||
? values.findIndex((v) => v === clickedComboValue)
|
||||
? values.findIndex((v: string) => v === clickedComboValue)
|
||||
: 0
|
||||
if (selectedIndex < 0) {
|
||||
selectedIndex = 0
|
||||
@@ -122,7 +121,7 @@ const ext = {
|
||||
// When filtering, recompute which items are visible for arrow up/down and maintain selection.
|
||||
displayedItems = items.filter((item) => {
|
||||
const isVisible =
|
||||
!term || item.textContent.toLocaleLowerCase().includes(term)
|
||||
!term || item.textContent?.toLocaleLowerCase().includes(term)
|
||||
item.style.display = isVisible ? 'block' : 'none'
|
||||
return isVisible
|
||||
})
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// @ts-strict-ignore
|
||||
import { app } from '../../scripts/app'
|
||||
import { app, ComfyApp } from '../../scripts/app'
|
||||
import { LiteGraph } from '@comfyorg/litegraph'
|
||||
const id = 'Comfy.LinkRenderMode'
|
||||
const ext = {
|
||||
name: id,
|
||||
async setup(app) {
|
||||
async setup(app: ComfyApp) {
|
||||
app.ui.settings.addSetting({
|
||||
id,
|
||||
category: ['Comfy', 'Graph', 'LinkRenderMode'],
|
||||
@@ -12,10 +11,10 @@ const ext = {
|
||||
defaultValue: 2,
|
||||
type: 'combo',
|
||||
options: [
|
||||
{ value: LiteGraph.STRAIGHT_LINK, text: 'Straight' },
|
||||
{ value: LiteGraph.LINEAR_LINK, text: 'Linear' },
|
||||
{ value: LiteGraph.SPLINE_LINK, text: 'Spline' },
|
||||
{ value: LiteGraph.HIDDEN_LINK, text: 'Hidden' }
|
||||
{ value: LiteGraph.STRAIGHT_LINK.toString(), text: 'Straight' },
|
||||
{ value: LiteGraph.LINEAR_LINK.toString(), text: 'Linear' },
|
||||
{ value: LiteGraph.SPLINE_LINK.toString(), text: 'Spline' },
|
||||
{ value: LiteGraph.HIDDEN_LINK.toString(), text: 'Hidden' }
|
||||
],
|
||||
onChange(value: number) {
|
||||
app.canvas.links_render_mode = +value
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @ts-strict-ignore
|
||||
import { memoize } from 'lodash'
|
||||
|
||||
type RGB = { r: number; g: number; b: number }
|
||||
@@ -17,12 +16,11 @@ function rgbToHsl({ r, g, b }: RGB): HSL {
|
||||
b /= 255
|
||||
const max = Math.max(r, g, b),
|
||||
min = Math.min(r, g, b)
|
||||
let h: number, s: number
|
||||
let h = 0,
|
||||
s = 0
|
||||
const l: number = (max + min) / 2
|
||||
|
||||
if (max === min) {
|
||||
h = s = 0 // achromatic
|
||||
} else {
|
||||
if (max !== min) {
|
||||
const d = max - min
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
|
||||
switch (max) {
|
||||
|
||||
Reference in New Issue
Block a user