Line data Source code
1 : import type { SerializedNodeId } from './nodeId'
2 : import type { NodeSlotType } from './globalEnums'
3 :
4 : interface NodePropertyChangedEvent {
5 : type: 'node:property:changed'
6 : nodeId: SerializedNodeId
7 : property: string
8 : oldValue: unknown
9 : newValue: unknown
10 : }
11 :
12 : interface NodeSlotLabelChangedEvent {
13 : type: 'node:slot-label:changed'
14 : nodeId: SerializedNodeId
15 : slotType?: NodeSlotType
16 : }
17 :
18 : export type LGraphTriggerEvent =
19 : | NodePropertyChangedEvent
20 : | NodeSlotLabelChangedEvent
21 :
22 2356 : export const LGraphTriggerActions = [
23 : 'node:property:changed',
24 : 'node:slot-label:changed'
25 : ] as const satisfies readonly LGraphTriggerEvent['type'][]
26 :
27 : export type LGraphTriggerAction = (typeof LGraphTriggerActions)[number]
28 :
29 : export type LGraphTriggerParam<A extends LGraphTriggerAction> = Extract<
30 : LGraphTriggerEvent,
31 : { type: A }
32 : >
33 :
34 : export type LGraphTriggerHandler = (event: LGraphTriggerEvent) => void
|