File tree Expand file tree Collapse file tree 5 files changed +24
-23
lines changed Expand file tree Collapse file tree 5 files changed +24
-23
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @litegraph-ts/core" ,
3
- "version" : " 0.2.19 " ,
3
+ "version" : " 0.2.20 " ,
4
4
"description" : " A graph node editor similar to PD or UDK Blueprints. It works in an HTML5 Canvas and allows to export graphs to be included in applications." ,
5
5
"source" : " src/index.ts" ,
6
6
"types" : " src/index.ts" ,
Original file line number Diff line number Diff line change @@ -22,8 +22,6 @@ import {
22
22
} from "./types" ;
23
23
import { LayoutDirection , NodeMode } from "./types" ;
24
24
import { v4 as uuidv4 } from "uuid" ;
25
- import { UUID } from "./types" ;
26
- import { Disposed } from "./misc/Disposed" ;
27
25
import { EventEmitter } from "./misc/EventEmitter" ;
28
26
29
27
export type LGraphAddNodeMode =
@@ -100,7 +98,6 @@ export default class LGraph {
100
98
static DEFAULT_SUPPORTED_TYPES : string [ ] = [ "number" , "string" , "boolean" ] ;
101
99
supported_types : string [ ] | null = null ;
102
100
103
- disposed = new Disposed ( ) ;
104
101
events = new EventEmitter < {
105
102
play : ( ) => void ;
106
103
stop : ( ) => void ;
@@ -136,9 +133,7 @@ export default class LGraph {
136
133
change : ( graph : LGraph ) => void ;
137
134
serialize : ( data : SerializedLGraph ) => void ;
138
135
configure : ( data : SerializedLGraph ) => void ;
139
- } > ( {
140
- signal : this . disposed . signal ,
141
- } ) ;
136
+ } > ( ) ;
142
137
143
138
constructor ( o ?: SerializedLGraph ) {
144
139
if ( LiteGraph . debug ) {
Original file line number Diff line number Diff line change @@ -42,8 +42,6 @@ import {
42
42
type Vector4 ,
43
43
} from "./types" ;
44
44
import { clamp } from "./utils" ;
45
- import { UUID } from "./types" ;
46
- import { Disposed } from "./misc/Disposed" ;
47
45
import { EventEmitter } from "./misc/EventEmitter" ;
48
46
49
47
export interface IGraphPanel extends HTMLDivElement {
@@ -508,7 +506,6 @@ export default class LGraphCanvas
508
506
search_box : IGraphDialog | null = null ;
509
507
prompt_box : IGraphDialog | null = null ;
510
508
511
- disposed = new Disposed ( ) ;
512
509
events = new EventEmitter < {
513
510
clear : ( ) => void ;
514
511
dropItem : ( e : DragEvent ) => void ;
Original file line number Diff line number Diff line change @@ -206,6 +206,13 @@ export default class LGraphNode {
206
206
this . properties_info = [ ] ; //for the info
207
207
208
208
this . flags = { } ;
209
+
210
+ this . events . once ( "removed" , ( ) => {
211
+ this . disposed . dispose ( ) ;
212
+ this . widgets ?. forEach ( ( w ) => {
213
+ w . onNodeRemoved ?.( this ) ;
214
+ } ) ;
215
+ } ) ;
209
216
}
210
217
211
218
title : string ;
@@ -336,7 +343,9 @@ export default class LGraphNode {
336
343
nodeOptionalOutputAdd : ( slot : INodeOutputSlot ) => void ;
337
344
resize : ( size : Vector2 ) => void ;
338
345
propertyChanged : ( k : string , v : any , prev_v : any ) => void ;
339
- } > ( ) ;
346
+ } > ( {
347
+ signal : this . disposed . signal ,
348
+ } ) ;
340
349
341
350
// sync position with the node
342
351
dom_anchors : {
@@ -3561,11 +3570,7 @@ export default class LGraphNode {
3561
3570
* when removed from graph
3562
3571
* Called by `LGraph.remove` `LGraph.clear`
3563
3572
*/
3564
- onRemoved ( options ?: LGraphRemoveNodeOptions ) : void {
3565
- this . widgets ?. forEach ( ( w ) => {
3566
- w . onNodeRemoved ?.( this ) ;
3567
- } ) ;
3568
- }
3573
+ onRemoved ?( options ?: LGraphRemoveNodeOptions ) : void ;
3569
3574
3570
3575
/**
3571
3576
* if returns false the incoming connection will be canceled
Original file line number Diff line number Diff line change @@ -150,13 +150,17 @@ export class EventEmitter<Events extends EventMap> {
150
150
}
151
151
listeners . push ( listener ) ;
152
152
153
- if ( options ?. signal ) {
154
- options ?. signal . addEventListener ( "abort" , ( ) => {
155
- this . removeListener ( eventName , listener ) ;
156
- } ) ;
157
- }
158
- if ( this . signal ) {
159
- this . signal . addEventListener ( "abort" , ( ) => {
153
+ const signals = [ options ?. signal , this . signal ] . filter (
154
+ Boolean ,
155
+ ) as AbortSignal [ ] ;
156
+
157
+ if ( signals . length !== 0 ) {
158
+ const mergedSignal = new AbortController ( ) ;
159
+ signals . forEach ( ( signal ) =>
160
+ signal . addEventListener ( "abort" , ( ) => mergedSignal . abort ( ) ) ,
161
+ ) ;
162
+
163
+ mergedSignal . signal . addEventListener ( "abort" , ( ) => {
160
164
this . removeListener ( eventName , listener ) ;
161
165
} ) ;
162
166
}
You can’t perform that action at this time.
0 commit comments