@elicdavis/node-flow 0.2.3 → 0.2.4

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
@@ -488,7 +488,22 @@ interface PortConfig {
488
488
  */
489
489
  declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
490
490
  declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
491
+ /**
492
+ * Lets an output of type `from` feed an input of type `to`, and only that
493
+ * way round.
494
+ */
495
+ interface Cast {
496
+ from: string;
497
+ to: string;
498
+ }
499
+ /**
500
+ * Whether an output may feed an input: their types overlap, or a cast takes
501
+ * one of the output's types to one of the input's.
502
+ */
503
+ declare function portsConnect(output: Port | undefined | null, input: Port | undefined | null, casts?: Array<Cast>): boolean;
504
+ declare function typeSetsConnect(output: Array<string>, input: Array<string>, casts?: Array<Cast>): boolean;
491
505
  declare function portConfigTypes(config: PortConfig): Array<string>;
506
+ declare function portTypeColor(type: string): string;
492
507
  declare class Port {
493
508
  #private;
494
509
  constructor(node: FlowNode, portType: PortType, config?: PortConfig);
@@ -625,6 +640,8 @@ declare class FlowNode {
625
640
  metadata(): any;
626
641
  selected(): boolean;
627
642
  select(): void;
643
+ highlighted(): boolean;
644
+ setHighlighted(highlighted: boolean): void;
628
645
  raiseDragStoppedEvent(): void;
629
646
  addTitleChangeListener(callback: TitleChangeCallback): void;
630
647
  addInfoChangeListener(callback: InfoChangeCallback): void;
@@ -699,6 +716,7 @@ declare class FlowNode {
699
716
 
700
717
  type NodeAddedCallback = (node: FlowNode) => void;
701
718
  type NodeRemovedCallback = (node: FlowNode) => void;
719
+ type NodeHoverCallback = (node: FlowNode | null) => void;
702
720
  /**
703
721
  * A connection between two nodes of a copied set, by their position in that
704
722
  * set rather than by node, so it can be rebuilt against the copies.
@@ -732,15 +750,19 @@ interface ConnectionRendererConfiguration {
732
750
  interface NodeSubsystemConfig {
733
751
  idleConnection?: ConnectionRendererConfiguration;
734
752
  nodes?: NodeFactoryConfig;
753
+ casts?: Array<Cast>;
735
754
  }
736
755
  declare class NodeSubsystem {
737
756
  #private;
738
757
  constructor(postProcessPass: PassSubsystem, config?: NodeSubsystemConfig);
758
+ setCasts(casts: Array<Cast>): void;
759
+ casts(): Array<Cast>;
739
760
  addPublisher(identifier: string, publisher: Publisher): void;
740
761
  addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
741
762
  nodeFactory(): NodeFactory;
742
763
  addOnNodeAddedListener(callback: NodeAddedCallback): void;
743
764
  addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
765
+ addNodeHoverListener(callback: NodeHoverCallback): void;
744
766
  clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
745
767
  mouseDragEvent(delta: Vector2, scale: number): boolean;
746
768
  clearNodeInputConnection(node: FlowNode, index: number): void;
@@ -786,6 +808,7 @@ interface NodeMenuFilter {
786
808
  needs: PortType;
787
809
  /** Types that side has to accept. An empty list takes anything. */
788
810
  types: Array<string>;
811
+ casts?: Array<Cast>;
789
812
  onCreated?: (node: FlowNode) => void;
790
813
  }
791
814
  interface PublisherNodes {
@@ -914,6 +937,7 @@ interface FlowNodeGraphConfiguration {
914
937
  idleConnection?: ConnectionRendererConfiguration;
915
938
  contextMenu?: ContextMenuConfig;
916
939
  nodes?: NodeFactoryConfig;
940
+ casts?: Array<Cast>;
917
941
  board?: NoteSubsystemConfig;
918
942
  minimap?: MinimapConfig;
919
943
  }
@@ -942,6 +966,7 @@ declare class NodeFlowGraph {
942
966
  currentView(): GraphView;
943
967
  organize(): void;
944
968
  addPublisher(identifier: string, publisher: Publisher): void;
969
+ setCasts(casts: Array<Cast>): void;
945
970
  getNodes(): Array<FlowNode>;
946
971
  /**
947
972
  * Returns currently selected nodes in stable graph order (same selection
@@ -980,6 +1005,7 @@ declare class NodeFlowGraph {
980
1005
  addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
981
1006
  addOnNodeAddedListener(callback: NodeAddedCallback): void;
982
1007
  addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
1008
+ addNodeHoverListener(callback: NodeHoverCallback): void;
983
1009
  requestRender(): void;
984
1010
  renderContinuously(): () => void;
985
1011
  dispose(): void;
@@ -1009,6 +1035,7 @@ declare const defaults: {
1009
1035
  MouseOver: string;
1010
1036
  Grabbed: string;
1011
1037
  Selected: string;
1038
+ Highlighted: string;
1012
1039
  };
1013
1040
  Bevel: BevelColors | null;
1014
1041
  Port: {
@@ -1095,6 +1122,7 @@ declare const defaults: {
1095
1122
  H3: {
1096
1123
  FontSize: number;
1097
1124
  };
1125
+ CodeFontFamily: string | null;
1098
1126
  CodeBlock: {
1099
1127
  BackgroundColor: string;
1100
1128
  FontColor: string;
@@ -1166,4 +1194,4 @@ interface InPlaceEdit {
1166
1194
  */
1167
1195
  declare function editInPlace(config: InPlaceEditConfig): InPlaceEdit | null;
1168
1196
 
1169
- export { type BevelColors, type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, CursorStyle, type DanglingConnection, DefaultConnectionRenderer, DefaultTheme, type FieldLook, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, GraphView, ImageWidget, type ImageWidgetConfig, InBox, type InPlaceEdit, type InPlaceEditConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, RowWidget, type RowWidgetConfig, type RowWidgetFactoryConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ThemeConfig, type ThemeValues, ToggleWidget, type ToggleWidgetConfig, ValueWidget, type ValueWidgetConfig, type Vector2, type Widget, WidgetBase, type WidgetBuilder, type WidgetConfig, type WidgetConfigs, WidgetFactory, type WidgetPointer, type WidgetTypes, drawField, drawFieldBox, drawFieldText, editInPlace, formatNumber, onThemeChange, portConfigTypes, portsCompatible, renderContinuously, requestRender, setTheme, themeVersion, typeSetsCompatible, widgetFont };
1197
+ export { type BevelColors, type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, type Cast, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, CursorStyle, type DanglingConnection, DefaultConnectionRenderer, DefaultTheme, type FieldLook, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, GraphView, ImageWidget, type ImageWidgetConfig, InBox, type InPlaceEdit, type InPlaceEditConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeHoverCallback, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, RowWidget, type RowWidgetConfig, type RowWidgetFactoryConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ThemeConfig, type ThemeValues, ToggleWidget, type ToggleWidgetConfig, ValueWidget, type ValueWidgetConfig, type Vector2, type Widget, WidgetBase, type WidgetBuilder, type WidgetConfig, type WidgetConfigs, WidgetFactory, type WidgetPointer, type WidgetTypes, drawField, drawFieldBox, drawFieldText, editInPlace, formatNumber, onThemeChange, portConfigTypes, portTypeColor, portsCompatible, portsConnect, renderContinuously, requestRender, setTheme, themeVersion, typeSetsCompatible, typeSetsConnect, widgetFont };
package/dist/index.d.ts CHANGED
@@ -488,7 +488,22 @@ interface PortConfig {
488
488
  */
489
489
  declare function portsCompatible(a: Port | undefined | null, b: Port | undefined | null): boolean;
490
490
  declare function typeSetsCompatible(a: Array<string>, b: Array<string>): boolean;
491
+ /**
492
+ * Lets an output of type `from` feed an input of type `to`, and only that
493
+ * way round.
494
+ */
495
+ interface Cast {
496
+ from: string;
497
+ to: string;
498
+ }
499
+ /**
500
+ * Whether an output may feed an input: their types overlap, or a cast takes
501
+ * one of the output's types to one of the input's.
502
+ */
503
+ declare function portsConnect(output: Port | undefined | null, input: Port | undefined | null, casts?: Array<Cast>): boolean;
504
+ declare function typeSetsConnect(output: Array<string>, input: Array<string>, casts?: Array<Cast>): boolean;
491
505
  declare function portConfigTypes(config: PortConfig): Array<string>;
506
+ declare function portTypeColor(type: string): string;
492
507
  declare class Port {
493
508
  #private;
494
509
  constructor(node: FlowNode, portType: PortType, config?: PortConfig);
@@ -625,6 +640,8 @@ declare class FlowNode {
625
640
  metadata(): any;
626
641
  selected(): boolean;
627
642
  select(): void;
643
+ highlighted(): boolean;
644
+ setHighlighted(highlighted: boolean): void;
628
645
  raiseDragStoppedEvent(): void;
629
646
  addTitleChangeListener(callback: TitleChangeCallback): void;
630
647
  addInfoChangeListener(callback: InfoChangeCallback): void;
@@ -699,6 +716,7 @@ declare class FlowNode {
699
716
 
700
717
  type NodeAddedCallback = (node: FlowNode) => void;
701
718
  type NodeRemovedCallback = (node: FlowNode) => void;
719
+ type NodeHoverCallback = (node: FlowNode | null) => void;
702
720
  /**
703
721
  * A connection between two nodes of a copied set, by their position in that
704
722
  * set rather than by node, so it can be rebuilt against the copies.
@@ -732,15 +750,19 @@ interface ConnectionRendererConfiguration {
732
750
  interface NodeSubsystemConfig {
733
751
  idleConnection?: ConnectionRendererConfiguration;
734
752
  nodes?: NodeFactoryConfig;
753
+ casts?: Array<Cast>;
735
754
  }
736
755
  declare class NodeSubsystem {
737
756
  #private;
738
757
  constructor(postProcessPass: PassSubsystem, config?: NodeSubsystemConfig);
758
+ setCasts(casts: Array<Cast>): void;
759
+ casts(): Array<Cast>;
739
760
  addPublisher(identifier: string, publisher: Publisher): void;
740
761
  addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
741
762
  nodeFactory(): NodeFactory;
742
763
  addOnNodeAddedListener(callback: NodeAddedCallback): void;
743
764
  addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
765
+ addNodeHoverListener(callback: NodeHoverCallback): void;
744
766
  clickStart(mousePosition: Vector2, camera: Camera, ctrlKey: boolean): boolean;
745
767
  mouseDragEvent(delta: Vector2, scale: number): boolean;
746
768
  clearNodeInputConnection(node: FlowNode, index: number): void;
@@ -786,6 +808,7 @@ interface NodeMenuFilter {
786
808
  needs: PortType;
787
809
  /** Types that side has to accept. An empty list takes anything. */
788
810
  types: Array<string>;
811
+ casts?: Array<Cast>;
789
812
  onCreated?: (node: FlowNode) => void;
790
813
  }
791
814
  interface PublisherNodes {
@@ -914,6 +937,7 @@ interface FlowNodeGraphConfiguration {
914
937
  idleConnection?: ConnectionRendererConfiguration;
915
938
  contextMenu?: ContextMenuConfig;
916
939
  nodes?: NodeFactoryConfig;
940
+ casts?: Array<Cast>;
917
941
  board?: NoteSubsystemConfig;
918
942
  minimap?: MinimapConfig;
919
943
  }
@@ -942,6 +966,7 @@ declare class NodeFlowGraph {
942
966
  currentView(): GraphView;
943
967
  organize(): void;
944
968
  addPublisher(identifier: string, publisher: Publisher): void;
969
+ setCasts(casts: Array<Cast>): void;
945
970
  getNodes(): Array<FlowNode>;
946
971
  /**
947
972
  * Returns currently selected nodes in stable graph order (same selection
@@ -980,6 +1005,7 @@ declare class NodeFlowGraph {
980
1005
  addOnNodeCreatedListener(callback: NodeCreatedCallback): void;
981
1006
  addOnNodeAddedListener(callback: NodeAddedCallback): void;
982
1007
  addOnNodeRemovedListener(callback: NodeRemovedCallback): void;
1008
+ addNodeHoverListener(callback: NodeHoverCallback): void;
983
1009
  requestRender(): void;
984
1010
  renderContinuously(): () => void;
985
1011
  dispose(): void;
@@ -1009,6 +1035,7 @@ declare const defaults: {
1009
1035
  MouseOver: string;
1010
1036
  Grabbed: string;
1011
1037
  Selected: string;
1038
+ Highlighted: string;
1012
1039
  };
1013
1040
  Bevel: BevelColors | null;
1014
1041
  Port: {
@@ -1095,6 +1122,7 @@ declare const defaults: {
1095
1122
  H3: {
1096
1123
  FontSize: number;
1097
1124
  };
1125
+ CodeFontFamily: string | null;
1098
1126
  CodeBlock: {
1099
1127
  BackgroundColor: string;
1100
1128
  FontColor: string;
@@ -1166,4 +1194,4 @@ interface InPlaceEdit {
1166
1194
  */
1167
1195
  declare function editInPlace(config: InPlaceEditConfig): InPlaceEdit | null;
1168
1196
 
1169
- export { type BevelColors, type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, CursorStyle, type DanglingConnection, DefaultConnectionRenderer, DefaultTheme, type FieldLook, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, GraphView, ImageWidget, type ImageWidgetConfig, InBox, type InPlaceEdit, type InPlaceEditConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, RowWidget, type RowWidgetConfig, type RowWidgetFactoryConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ThemeConfig, type ThemeValues, ToggleWidget, type ToggleWidgetConfig, ValueWidget, type ValueWidgetConfig, type Vector2, type Widget, WidgetBase, type WidgetBuilder, type WidgetConfig, type WidgetConfigs, WidgetFactory, type WidgetPointer, type WidgetTypes, drawField, drawFieldBox, drawFieldText, editInPlace, formatNumber, onThemeChange, portConfigTypes, portsCompatible, renderContinuously, requestRender, setTheme, themeVersion, typeSetsCompatible, widgetFont };
1197
+ export { type BevelColors, type Box, ButtonWidget, type ButtonWidgetConfig, type CameraOrientation, type Cast, ColorWidget, type ColorWidgetConfig, Connection, type ConnectionRenderer, type ConnectionRendererParams, type ContextMenuConfig, type ContextMenuItemConfig, ContextMenuItemState, type CopyCallback, CursorStyle, type DanglingConnection, DefaultConnectionRenderer, DefaultTheme, type FieldLook, FlowNode, type FlowNodeConfig, type FlowNodeGraphConfiguration, type FlowNodeStyle, type FlowNodeTitleConfig, FlowNote, type FlowNoteConfig, GlobalWidgetFactory, type GraphRenderer, GraphView, ImageWidget, type ImageWidgetConfig, InBox, type InPlaceEdit, type InPlaceEditConfig, type InternalConnection, MessageType, Minimap, type MinimapConfig, type NodeCreatedCallback, NodeFactory, type NodeFactoryConfig, NodeFlowGraph, type NodeHoverCallback, type NodeIntersection, type NodeMenuFilter, type NodeMessageConfig, NodeState, type NoteAddedCallback, type NoteContentChangeCallback, type NoteDragStartCallback, type NoteDragStopCallback, type NoteRemovedCallback, type NoteSubsystemConfig, type NoteWidthChangeCallback, NumberWidget, type NumberWidgetConfig, type PasteCallback, Port, type PortConfig, type PortStyle, PortType, Publisher, type PublisherConfig, RowWidget, type RowWidgetConfig, type RowWidgetFactoryConfig, SliderWidget, type SliderWidgetConfig, StringWidget, type StringWidgetConfig, TextWidget, type TextWidgetConfig, Theme, type ThemeConfig, type ThemeValues, ToggleWidget, type ToggleWidgetConfig, ValueWidget, type ValueWidgetConfig, type Vector2, type Widget, WidgetBase, type WidgetBuilder, type WidgetConfig, type WidgetConfigs, WidgetFactory, type WidgetPointer, type WidgetTypes, drawField, drawFieldBox, drawFieldText, editInPlace, formatNumber, onThemeChange, portConfigTypes, portTypeColor, portsCompatible, portsConnect, renderContinuously, requestRender, setTheme, themeVersion, typeSetsCompatible, typeSetsConnect, widgetFont };