@elicdavis/node-flow 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -156,95 +156,6 @@ interface Box {
156
156
  }
157
157
  declare function InBox(box: Box, position: Vector2): boolean;
158
158
 
159
- declare enum PortType {
160
- Input = "INPUT",
161
- Output = "OUTPUT",
162
- InputArray = "INPUTARRAY"
163
- }
164
- interface PortStyle {
165
- size?: number;
166
- fillColor?: string;
167
- borderColor?: string;
168
- borderSize?: number;
169
- }
170
- type ConnectionChangeCallback = (connection: Connection, connectionIndex: number, port: Port, portType: PortType, node: FlowNode) => void;
171
- interface PortConfig {
172
- name?: string;
173
- type?: string;
174
- description?: string;
175
- array?: boolean;
176
- /**
177
- * Lets this port connect to a port of any type, instead of only to one
178
- * declaring the same `type` string. For a port whose type is decided by
179
- * whatever gets wired into it, where `type` is a placeholder shown to
180
- * the user rather than a promise about the values passing through.
181
- */
182
- anyType?: boolean;
183
- /**
184
- * Every type this port takes, when it takes more than one. For a port
185
- * that works on a single value or an array of them, where `type` is
186
- * only the one it happens to be showing.
187
- *
188
- * An empty or absent list means the port takes exactly its `type`,
189
- * unless `anyType` says otherwise.
190
- */
191
- acceptedTypes?: Array<string>;
192
- /**
193
- * Leaves the port off the node until something is connected to it.
194
- */
195
- hidden?: boolean;
196
- emptyStyle?: PortStyle;
197
- filledStyle?: PortStyle;
198
- onConnectionAdded?: ConnectionChangeCallback;
199
- onConnectionRemoved?: ConnectionChangeCallback;
200
- }
201
- /**
202
- * Whether two ports may be connected, going by their types alone. Each port
203
- * offers the set of types it takes - one entry for an ordinary port, several
204
- * for a port that takes more than one, and none at all for a port that takes
205
- * anything. They connect when those sets overlap.
206
- */
207
- declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
208
- declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
209
- declare function portConfigTypes(config: PortConfig): Array<string>;
210
- declare class Port {
211
- #private;
212
- constructor(node: FlowNode, portType: PortType, config?: PortConfig);
213
- setDataType(type: string): void;
214
- setAnyType(anyType: boolean): void;
215
- /**
216
- * Scope accepted types to singular type
217
- */
218
- settleOn(type: string): void;
219
- addConnection(connection: Connection, index?: number): void;
220
- replaceConnection(connection: Connection, index: number): void;
221
- addConnectionAddedListener(callback: ConnectionChangeCallback): void;
222
- connections(): Array<Connection>;
223
- /**
224
- * How many wires the port has room for: one per connection on an array
225
- * input, so each can be told apart and picked up on its own.
226
- */
227
- slots(): number;
228
- setHidden(hidden: boolean): void;
229
- /**
230
- * A port asked to hide still shows while anything is connected to it.
231
- */
232
- hidden(): boolean;
233
- addConnectionRemovedListener(callback: ConnectionChangeCallback): void;
234
- clearConnection(connection: Connection): void;
235
- getDataType(): string;
236
- acceptsAnyType(): boolean;
237
- /**
238
- * Every type this port takes. Empty means it takes anything.
239
- */
240
- acceptedTypes(): Array<string>;
241
- setAcceptedTypes(types: Array<string>): void;
242
- getPortType(): PortType;
243
- getDisplayName(): string;
244
- filledStyleColor(): string;
245
- render(ctx: CanvasRenderingContext2D, position: Vector2, camera: Camera, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): Box;
246
- }
247
-
248
159
  /**
249
160
  * Where the pointer is, in canvas pixels, and whether it is over the widget.
250
161
  * A press that starts on a widget keeps reporting to it until it is let go,
@@ -299,17 +210,6 @@ declare abstract class WidgetBase implements Widget {
299
210
  protected onClick(pointer: WidgetPointer): void;
300
211
  }
301
212
 
302
- interface StrokeStyleConfig {
303
- size?: number;
304
- color?: string;
305
- }
306
-
307
- interface BoxStyleConfig {
308
- border?: StrokeStyleConfig;
309
- color?: string;
310
- radius?: number;
311
- }
312
-
313
213
  interface ValueWidgetConfig<T> {
314
214
  /**
315
215
  * A node property the widget shows and edits. Setting the property from
@@ -533,6 +433,119 @@ declare class WidgetFactory {
533
433
  }
534
434
  declare const GlobalWidgetFactory: WidgetFactory;
535
435
 
436
+ declare enum PortType {
437
+ Input = "INPUT",
438
+ Output = "OUTPUT",
439
+ InputArray = "INPUTARRAY"
440
+ }
441
+ interface PortStyle {
442
+ size?: number;
443
+ fillColor?: string;
444
+ borderColor?: string;
445
+ borderSize?: number;
446
+ }
447
+ type ConnectionChangeCallback = (connection: Connection, connectionIndex: number, port: Port, portType: PortType, node: FlowNode) => void;
448
+ interface PortConfig {
449
+ name?: string;
450
+ type?: string;
451
+ description?: string;
452
+ array?: boolean;
453
+ /**
454
+ * Lets this port connect to a port of any type, instead of only to one
455
+ * declaring the same `type` string. For a port whose type is decided by
456
+ * whatever gets wired into it, where `type` is a placeholder shown to
457
+ * the user rather than a promise about the values passing through.
458
+ */
459
+ anyType?: boolean;
460
+ /**
461
+ * Every type this port takes, when it takes more than one. For a port
462
+ * that works on a single value or an array of them, where `type` is
463
+ * only the one it happens to be showing.
464
+ *
465
+ * An empty or absent list means the port takes exactly its `type`,
466
+ * unless `anyType` says otherwise.
467
+ */
468
+ acceptedTypes?: Array<string>;
469
+ /**
470
+ * Leaves the port off the node until something is connected to it.
471
+ */
472
+ hidden?: boolean;
473
+ /**
474
+ * A widget drawn on the port's own row while nothing is connected to
475
+ * it, for a value the port holds on its own. Input ports only.
476
+ */
477
+ widget?: WidgetConfig;
478
+ emptyStyle?: PortStyle;
479
+ filledStyle?: PortStyle;
480
+ onConnectionAdded?: ConnectionChangeCallback;
481
+ onConnectionRemoved?: ConnectionChangeCallback;
482
+ }
483
+ /**
484
+ * Whether two ports may be connected, going by their types alone. Each port
485
+ * offers the set of types it takes - one entry for an ordinary port, several
486
+ * for a port that takes more than one, and none at all for a port that takes
487
+ * anything. They connect when those sets overlap.
488
+ */
489
+ declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
490
+ declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
491
+ declare function portConfigTypes(config: PortConfig): Array<string>;
492
+ declare class Port {
493
+ #private;
494
+ constructor(node: FlowNode, portType: PortType, config?: PortConfig);
495
+ setDataType(type: string): void;
496
+ setAnyType(anyType: boolean): void;
497
+ /**
498
+ * Scope accepted types to singular type
499
+ */
500
+ settleOn(type: string): void;
501
+ addConnection(connection: Connection, index?: number): void;
502
+ replaceConnection(connection: Connection, index: number): void;
503
+ addConnectionAddedListener(callback: ConnectionChangeCallback): void;
504
+ connections(): Array<Connection>;
505
+ /**
506
+ * How many wires the port has room for: one per connection on an array
507
+ * input, so each can be told apart and picked up on its own.
508
+ */
509
+ slots(): number;
510
+ setHidden(hidden: boolean): void;
511
+ setWidget(widget: Widget | null): void;
512
+ widget(): Widget | null;
513
+ /**
514
+ * The widget stands in for a wire, so it leaves once one is connected.
515
+ */
516
+ widgetShown(): boolean;
517
+ /**
518
+ * A port asked to hide still shows while anything is connected to it,
519
+ * and while its node is showing its hidden ports.
520
+ */
521
+ hidden(): boolean;
522
+ tucked(): boolean;
523
+ addConnectionRemovedListener(callback: ConnectionChangeCallback): void;
524
+ clearConnection(connection: Connection): void;
525
+ getDataType(): string;
526
+ acceptsAnyType(): boolean;
527
+ /**
528
+ * Every type this port takes. Empty means it takes anything.
529
+ */
530
+ acceptedTypes(): Array<string>;
531
+ setAcceptedTypes(types: Array<string>): void;
532
+ getPortType(): PortType;
533
+ getDisplayName(): string;
534
+ filledStyleColor(): string;
535
+ render(ctx: CanvasRenderingContext2D, position: Vector2, camera: Camera, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): Box;
536
+ }
537
+
538
+ interface StrokeStyleConfig {
539
+ size?: number;
540
+ color?: string;
541
+ }
542
+
543
+ interface BoxStyleConfig {
544
+ border?: StrokeStyleConfig;
545
+ color?: string;
546
+ radius?: number;
547
+ }
548
+
536
549
  interface Metadata {
537
550
  [name: string]: any;
538
551
  }
@@ -644,6 +657,9 @@ declare class FlowNode {
644
657
  calculateBounds(ctx: CanvasRenderingContext2D, camera: Camera): Box;
645
658
  addInput(config: PortConfig): Port;
646
659
  addOutput(config: PortConfig): Port;
660
+ hiddenPortsShown(): boolean;
661
+ setHiddenPortsShown(shown: boolean): void;
662
+ hiddenPortCount(): number;
647
663
  addWidget(widget: Widget): void;
648
664
  insertWidget(index: number, widget: Widget): void;
649
665
  removeWidget(widget: Widget): void;
@@ -1089,7 +1105,7 @@ declare const defaults: {
1089
1105
  };
1090
1106
  type ThemeValues = typeof defaults;
1091
1107
  type DeepPartial<T> = {
1092
- [K in keyof T]?: T[K] extends object | null ? (null extends T[K] ? T[K] : DeepPartial<T[K]>) : T[K];
1108
+ [K in keyof T]?: T[K] extends BevelColors | null ? T[K] : T[K] extends object ? DeepPartial<T[K]> : T[K];
1093
1109
  };
1094
1110
  type ThemeConfig = DeepPartial<ThemeValues>;
1095
1111
  declare const DefaultTheme: Readonly<ThemeValues>;
package/dist/index.d.ts CHANGED
@@ -156,95 +156,6 @@ interface Box {
156
156
  }
157
157
  declare function InBox(box: Box, position: Vector2): boolean;
158
158
 
159
- declare enum PortType {
160
- Input = "INPUT",
161
- Output = "OUTPUT",
162
- InputArray = "INPUTARRAY"
163
- }
164
- interface PortStyle {
165
- size?: number;
166
- fillColor?: string;
167
- borderColor?: string;
168
- borderSize?: number;
169
- }
170
- type ConnectionChangeCallback = (connection: Connection, connectionIndex: number, port: Port, portType: PortType, node: FlowNode) => void;
171
- interface PortConfig {
172
- name?: string;
173
- type?: string;
174
- description?: string;
175
- array?: boolean;
176
- /**
177
- * Lets this port connect to a port of any type, instead of only to one
178
- * declaring the same `type` string. For a port whose type is decided by
179
- * whatever gets wired into it, where `type` is a placeholder shown to
180
- * the user rather than a promise about the values passing through.
181
- */
182
- anyType?: boolean;
183
- /**
184
- * Every type this port takes, when it takes more than one. For a port
185
- * that works on a single value or an array of them, where `type` is
186
- * only the one it happens to be showing.
187
- *
188
- * An empty or absent list means the port takes exactly its `type`,
189
- * unless `anyType` says otherwise.
190
- */
191
- acceptedTypes?: Array<string>;
192
- /**
193
- * Leaves the port off the node until something is connected to it.
194
- */
195
- hidden?: boolean;
196
- emptyStyle?: PortStyle;
197
- filledStyle?: PortStyle;
198
- onConnectionAdded?: ConnectionChangeCallback;
199
- onConnectionRemoved?: ConnectionChangeCallback;
200
- }
201
- /**
202
- * Whether two ports may be connected, going by their types alone. Each port
203
- * offers the set of types it takes - one entry for an ordinary port, several
204
- * for a port that takes more than one, and none at all for a port that takes
205
- * anything. They connect when those sets overlap.
206
- */
207
- declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
208
- declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
209
- declare function portConfigTypes(config: PortConfig): Array<string>;
210
- declare class Port {
211
- #private;
212
- constructor(node: FlowNode, portType: PortType, config?: PortConfig);
213
- setDataType(type: string): void;
214
- setAnyType(anyType: boolean): void;
215
- /**
216
- * Scope accepted types to singular type
217
- */
218
- settleOn(type: string): void;
219
- addConnection(connection: Connection, index?: number): void;
220
- replaceConnection(connection: Connection, index: number): void;
221
- addConnectionAddedListener(callback: ConnectionChangeCallback): void;
222
- connections(): Array<Connection>;
223
- /**
224
- * How many wires the port has room for: one per connection on an array
225
- * input, so each can be told apart and picked up on its own.
226
- */
227
- slots(): number;
228
- setHidden(hidden: boolean): void;
229
- /**
230
- * A port asked to hide still shows while anything is connected to it.
231
- */
232
- hidden(): boolean;
233
- addConnectionRemovedListener(callback: ConnectionChangeCallback): void;
234
- clearConnection(connection: Connection): void;
235
- getDataType(): string;
236
- acceptsAnyType(): boolean;
237
- /**
238
- * Every type this port takes. Empty means it takes anything.
239
- */
240
- acceptedTypes(): Array<string>;
241
- setAcceptedTypes(types: Array<string>): void;
242
- getPortType(): PortType;
243
- getDisplayName(): string;
244
- filledStyleColor(): string;
245
- render(ctx: CanvasRenderingContext2D, position: Vector2, camera: Camera, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): Box;
246
- }
247
-
248
159
  /**
249
160
  * Where the pointer is, in canvas pixels, and whether it is over the widget.
250
161
  * A press that starts on a widget keeps reporting to it until it is let go,
@@ -299,17 +210,6 @@ declare abstract class WidgetBase implements Widget {
299
210
  protected onClick(pointer: WidgetPointer): void;
300
211
  }
301
212
 
302
- interface StrokeStyleConfig {
303
- size?: number;
304
- color?: string;
305
- }
306
-
307
- interface BoxStyleConfig {
308
- border?: StrokeStyleConfig;
309
- color?: string;
310
- radius?: number;
311
- }
312
-
313
213
  interface ValueWidgetConfig<T> {
314
214
  /**
315
215
  * A node property the widget shows and edits. Setting the property from
@@ -533,6 +433,119 @@ declare class WidgetFactory {
533
433
  }
534
434
  declare const GlobalWidgetFactory: WidgetFactory;
535
435
 
436
+ declare enum PortType {
437
+ Input = "INPUT",
438
+ Output = "OUTPUT",
439
+ InputArray = "INPUTARRAY"
440
+ }
441
+ interface PortStyle {
442
+ size?: number;
443
+ fillColor?: string;
444
+ borderColor?: string;
445
+ borderSize?: number;
446
+ }
447
+ type ConnectionChangeCallback = (connection: Connection, connectionIndex: number, port: Port, portType: PortType, node: FlowNode) => void;
448
+ interface PortConfig {
449
+ name?: string;
450
+ type?: string;
451
+ description?: string;
452
+ array?: boolean;
453
+ /**
454
+ * Lets this port connect to a port of any type, instead of only to one
455
+ * declaring the same `type` string. For a port whose type is decided by
456
+ * whatever gets wired into it, where `type` is a placeholder shown to
457
+ * the user rather than a promise about the values passing through.
458
+ */
459
+ anyType?: boolean;
460
+ /**
461
+ * Every type this port takes, when it takes more than one. For a port
462
+ * that works on a single value or an array of them, where `type` is
463
+ * only the one it happens to be showing.
464
+ *
465
+ * An empty or absent list means the port takes exactly its `type`,
466
+ * unless `anyType` says otherwise.
467
+ */
468
+ acceptedTypes?: Array<string>;
469
+ /**
470
+ * Leaves the port off the node until something is connected to it.
471
+ */
472
+ hidden?: boolean;
473
+ /**
474
+ * A widget drawn on the port's own row while nothing is connected to
475
+ * it, for a value the port holds on its own. Input ports only.
476
+ */
477
+ widget?: WidgetConfig;
478
+ emptyStyle?: PortStyle;
479
+ filledStyle?: PortStyle;
480
+ onConnectionAdded?: ConnectionChangeCallback;
481
+ onConnectionRemoved?: ConnectionChangeCallback;
482
+ }
483
+ /**
484
+ * Whether two ports may be connected, going by their types alone. Each port
485
+ * offers the set of types it takes - one entry for an ordinary port, several
486
+ * for a port that takes more than one, and none at all for a port that takes
487
+ * anything. They connect when those sets overlap.
488
+ */
489
+ declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
490
+ declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
491
+ declare function portConfigTypes(config: PortConfig): Array<string>;
492
+ declare class Port {
493
+ #private;
494
+ constructor(node: FlowNode, portType: PortType, config?: PortConfig);
495
+ setDataType(type: string): void;
496
+ setAnyType(anyType: boolean): void;
497
+ /**
498
+ * Scope accepted types to singular type
499
+ */
500
+ settleOn(type: string): void;
501
+ addConnection(connection: Connection, index?: number): void;
502
+ replaceConnection(connection: Connection, index: number): void;
503
+ addConnectionAddedListener(callback: ConnectionChangeCallback): void;
504
+ connections(): Array<Connection>;
505
+ /**
506
+ * How many wires the port has room for: one per connection on an array
507
+ * input, so each can be told apart and picked up on its own.
508
+ */
509
+ slots(): number;
510
+ setHidden(hidden: boolean): void;
511
+ setWidget(widget: Widget | null): void;
512
+ widget(): Widget | null;
513
+ /**
514
+ * The widget stands in for a wire, so it leaves once one is connected.
515
+ */
516
+ widgetShown(): boolean;
517
+ /**
518
+ * A port asked to hide still shows while anything is connected to it,
519
+ * and while its node is showing its hidden ports.
520
+ */
521
+ hidden(): boolean;
522
+ tucked(): boolean;
523
+ addConnectionRemovedListener(callback: ConnectionChangeCallback): void;
524
+ clearConnection(connection: Connection): void;
525
+ getDataType(): string;
526
+ acceptsAnyType(): boolean;
527
+ /**
528
+ * Every type this port takes. Empty means it takes anything.
529
+ */
530
+ acceptedTypes(): Array<string>;
531
+ setAcceptedTypes(types: Array<string>): void;
532
+ getPortType(): PortType;
533
+ getDisplayName(): string;
534
+ filledStyleColor(): string;
535
+ render(ctx: CanvasRenderingContext2D, position: Vector2, camera: Camera, mousePosition: Vector2 | undefined, postProcess: PassSubsystem): Box;
536
+ }
537
+
538
+ interface StrokeStyleConfig {
539
+ size?: number;
540
+ color?: string;
541
+ }
542
+
543
+ interface BoxStyleConfig {
544
+ border?: StrokeStyleConfig;
545
+ color?: string;
546
+ radius?: number;
547
+ }
548
+
536
549
  interface Metadata {
537
550
  [name: string]: any;
538
551
  }
@@ -644,6 +657,9 @@ declare class FlowNode {
644
657
  calculateBounds(ctx: CanvasRenderingContext2D, camera: Camera): Box;
645
658
  addInput(config: PortConfig): Port;
646
659
  addOutput(config: PortConfig): Port;
660
+ hiddenPortsShown(): boolean;
661
+ setHiddenPortsShown(shown: boolean): void;
662
+ hiddenPortCount(): number;
647
663
  addWidget(widget: Widget): void;
648
664
  insertWidget(index: number, widget: Widget): void;
649
665
  removeWidget(widget: Widget): void;
@@ -1089,7 +1105,7 @@ declare const defaults: {
1089
1105
  };
1090
1106
  type ThemeValues = typeof defaults;
1091
1107
  type DeepPartial<T> = {
1092
- [K in keyof T]?: T[K] extends object | null ? (null extends T[K] ? T[K] : DeepPartial<T[K]>) : T[K];
1108
+ [K in keyof T]?: T[K] extends BevelColors | null ? T[K] : T[K] extends object ? DeepPartial<T[K]> : T[K];
1093
1109
  };
1094
1110
  type ThemeConfig = DeepPartial<ThemeValues>;
1095
1111
  declare const DefaultTheme: Readonly<ThemeValues>;