[fix] some typescript issues in src/composables

This commit is contained in:
Arjan Singh
2025-09-10 21:50:18 -07:00
parent ca220440b2
commit 444ca5db9e
7 changed files with 38 additions and 19 deletions

View File

@@ -36,7 +36,14 @@ interface CivitaiModelVersionResponse {
model: CivitaiModel
modelId: number
files: CivitaiModelFile[]
[key: string]: any
// Common optional Civitai API fields
createdAt?: string
publishedAt?: string
trainedWords?: string[]
stats?: Record<string, number>
description?: string
// Allow additional API evolution
[key: string]: string | number | boolean | object | undefined
}
/**

View File

@@ -220,9 +220,9 @@ export function useConflictDetection() {
abortController.value?.signal
)
if (bulkResponse && bulkResponse.node_versions) {
if (bulkResponse?.node_versions) {
// Process bulk response
bulkResponse.node_versions.forEach((result) => {
bulkResponse?.node_versions?.forEach((result) => {
if (result.status === 'success' && result.node_version) {
versionDataMap.set(
result.identifier.node_id,
@@ -265,7 +265,7 @@ export function useConflictDetection() {
const requirement: NodePackRequirements = {
// Basic package info
id: packageId,
name: packInfo?.name || packageId,
name: packInfo?.name ?? packageId,
installed_version: installedVersion,
is_enabled: isEnabled,
@@ -291,7 +291,7 @@ export function useConflictDetection() {
// Create fallback requirement without Registry data
const fallbackRequirement: NodePackRequirements = {
id: packageId,
name: packInfo?.name || packageId,
name: packInfo?.name ?? packageId,
installed_version: installedVersion,
is_enabled: isEnabled,
is_banned: false,
@@ -326,7 +326,9 @@ export function useConflictDetection() {
const conflicts: ConflictDetail[] = []
// Helper function to check if a value indicates "compatible with all"
const isCompatibleWithAll = (value: any): boolean => {
const isCompatibleWithAll = (
value: string | string[] | null | undefined
): boolean => {
if (value === null || value === undefined) return true
if (typeof value === 'string' && value.trim() === '') return true
if (Array.isArray(value) && value.length === 0) return true

View File

@@ -8,6 +8,11 @@ import type {
import { LGraphCanvas, LiteGraph } from '@/lib/litegraph/src/litegraph'
import { normalizeI18nKey } from '@/utils/formatUtil'
interface ContextMenuExtraInfo {
inputs?: INodeInputSlot[]
widgets?: IWidget[]
}
/**
* Add translation for litegraph context menu.
*/
@@ -50,18 +55,20 @@ export const useContextMenuTranslation = () => {
}
// for capture translation text of input and widget
const extraInfo: any = options.extra || options.parentMenu?.options?.extra
const extraInfo: ContextMenuExtraInfo | undefined =
(options.extra as ContextMenuExtraInfo) ||
(options.parentMenu?.options?.extra as ContextMenuExtraInfo)
// widgets and inputs
const matchInput = value.content?.match(reInput)
if (matchInput) {
let match = matchInput[1]
extraInfo?.inputs?.find((i: INodeInputSlot) => {
if (i.name != match) return false
match = i.label ? i.label : i.name
match = i.label ?? i.name
})
extraInfo?.widgets?.find((i: IWidget) => {
if (i.name != match) return false
match = i.label ? i.label : i.name
match = i.label ?? i.name
})
value.content = cvt + match + tinp
continue
@@ -71,11 +78,11 @@ export const useContextMenuTranslation = () => {
let match = matchWidget[1]
extraInfo?.inputs?.find((i: INodeInputSlot) => {
if (i.name != match) return false
match = i.label ? i.label : i.name
match = i.label ?? i.name
})
extraInfo?.widgets?.find((i: IWidget) => {
if (i.name != match) return false
match = i.label ? i.label : i.name
match = i.label ?? i.name
})
value.content = cvt + match + twgt
continue

View File

@@ -30,7 +30,7 @@ import { useSettingStore } from '@/stores/settingStore'
import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore'
import { useSubgraphStore } from '@/stores/subgraphStore'
import { useToastStore } from '@/stores/toastStore'
import { type ComfyWorkflow, useWorkflowStore } from '@/stores/workflowStore'
import { useWorkflowStore } from '@/stores/workflowStore'
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
import { useSearchBoxStore } from '@/stores/workspace/searchBoxStore'
@@ -106,7 +106,7 @@ export function useCoreCommands(): ComfyCommand[] {
menubarLabel: 'Save',
category: 'essentials' as const,
function: async () => {
const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow
const workflow = useWorkflowStore().activeWorkflow
if (!workflow) return
await workflowService.saveWorkflow(workflow)
@@ -128,7 +128,7 @@ export function useCoreCommands(): ComfyCommand[] {
menubarLabel: 'Save As',
category: 'essentials' as const,
function: async () => {
const workflow = useWorkflowStore().activeWorkflow as ComfyWorkflow
const workflow = useWorkflowStore().activeWorkflow
if (!workflow) return
await workflowService.saveWorkflowAs(workflow)

View File

@@ -41,7 +41,7 @@ export function useDownload(url: string, fileName?: string) {
link.href = downloadUrlToHfRepoUrl(url)
} else {
link.href = url
link.download = fileName || url.split('/').pop() || 'download'
link.download = fileName ?? url.split('/').pop() ?? 'download'
}
link.target = '_blank' // Opens in new tab if download attribute is not supported
link.rel = 'noopener noreferrer' // Security best practice for _blank links

View File

@@ -13,7 +13,7 @@ export function useErrorHandling() {
}
const wrapWithErrorHandling =
<TArgs extends any[], TReturn>(
<TArgs extends readonly unknown[], TReturn>(
action: (...args: TArgs) => TReturn,
errorHandler?: (error: any) => void,
finallyHandler?: () => void
@@ -29,7 +29,7 @@ export function useErrorHandling() {
}
const wrapWithErrorHandlingAsync =
<TArgs extends any[], TReturn>(
<TArgs extends readonly unknown[], TReturn>(
action: (...args: TArgs) => Promise<TReturn> | TReturn,
errorHandler?: (error: any) => void,
finallyHandler?: () => void

View File

@@ -3,6 +3,7 @@ import { ref, toRaw, watch } from 'vue'
import Load3d from '@/extensions/core/load3d/Load3d'
import Load3dUtils from '@/extensions/core/load3d/Load3dUtils'
import {
CameraState,
CameraType,
MaterialMode,
UpDirection
@@ -18,7 +19,7 @@ interface Load3dViewerState {
cameraType: CameraType
fov: number
lightIntensity: number
cameraState: any
cameraState: CameraState | null
backgroundImage: string
upDirection: UpDirection
materialMode: MaterialMode
@@ -274,7 +275,9 @@ export const useLoad3dViewer = (node: LGraphNode) => {
nodeValue.properties['FOV'] = initialState.value.fov
nodeValue.properties['Light Intensity'] =
initialState.value.lightIntensity
nodeValue.properties['Camera Info'] = initialState.value.cameraState
if (initialState.value.cameraState) {
nodeValue.properties['Camera Info'] = initialState.value.cameraState
}
nodeValue.properties['Background Image'] =
initialState.value.backgroundImage
}