File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Shorthand for {@link Parameters} of optional callbacks.
3+ *
4+ * @example
5+ * ```ts
6+ * const { onClick } = CustomClass.prototype
7+ * CustomClass.prototype.onClick = function (...args: CallbackParams<typeof onClick>) {
8+ * const r = onClick?.apply(this, args)
9+ * // ...
10+ * return r
11+ * }
12+ * ```
13+ */
14+ export type CallbackParams < T extends ( ( ...args : any ) => any ) | undefined > =
15+ Parameters < Exclude < T , undefined > >
16+
117/**
218 * Chain multiple callbacks together.
319 *
@@ -14,6 +30,6 @@ export const useChainCallback = <
1430) => {
1531 return function ( this : O , ...args : Parameters < T > ) {
1632 originalCallback ?. call ( this , ...args )
17- callbacks . forEach ( ( callback ) => callback . call ( this , ...args ) )
33+ for ( const callback of callbacks ) callback . call ( this , ...args )
1834 }
1935}
Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ import type {
99} from '@comfyorg/litegraph'
1010import type { CanvasMouseEvent } from '@comfyorg/litegraph/dist/types/events'
1111
12- import { useChainCallback } from '@/composables/functional/useChainCallback'
12+ import {
13+ type CallbackParams ,
14+ useChainCallback
15+ } from '@/composables/functional/useChainCallback'
1316import type { InputSpec } from '@/schemas/nodeDefSchema'
1417import { app } from '@/scripts/app'
1518import { ComfyWidgets , addValueControlWidgets } from '@/scripts/widgets'
@@ -564,12 +567,9 @@ app.registerExtension({
564567 const origOnInputDblClick = nodeType . prototype . onInputDblClick
565568 nodeType . prototype . onInputDblClick = function (
566569 this : LGraphNode ,
567- slot : number
570+ ... [ slot , ... args ] : CallbackParams < typeof origOnInputDblClick >
568571 ) {
569- const r = origOnInputDblClick
570- ? // @ts -expect-error fixme ts strict error
571- origOnInputDblClick . apply ( this , arguments )
572- : undefined
572+ const r = origOnInputDblClick ?. apply ( this , [ slot , ...args ] )
573573
574574 const input = this . inputs [ slot ]
575575 if ( ! input . widget ) {
You can’t perform that action at this time.
0 commit comments