flowGraphConnection.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import type { FlowGraphBlock } from "./flowGraphBlock";
  2. /**
  3. * @experimental
  4. * The type of a connection point - inpput or output.
  5. */
  6. export declare enum FlowGraphConnectionType {
  7. Input = 0,
  8. Output = 1
  9. }
  10. /**
  11. * @experimental
  12. */
  13. export interface IConnectable {
  14. /**
  15. * A uniquely identifying string for the connection.
  16. */
  17. uniqueId: string;
  18. /**
  19. * An array of the points that this point is connected to.
  20. */
  21. _connectedPoint: Array<IConnectable>;
  22. /**
  23. * Returns if the connection can only be connected to one other point.
  24. */
  25. _isSingularConnection(): boolean;
  26. /**
  27. * The type of the connection
  28. */
  29. _connectionType: FlowGraphConnectionType;
  30. /**
  31. * Connect this point to another point.
  32. * @param point the point to connect to.
  33. */
  34. connectTo(point: IConnectable): void;
  35. }
  36. /**
  37. * @experimental
  38. * The base connection class.
  39. */
  40. export declare class FlowGraphConnection<BlockT, ConnectedToT extends IConnectable> implements IConnectable {
  41. _ownerBlock: BlockT;
  42. /** @internal */
  43. _connectedPoint: Array<ConnectedToT>;
  44. /**
  45. * A uniquely identifying string for the connection.
  46. */
  47. uniqueId: string;
  48. /**
  49. * The name of the connection.
  50. */
  51. name: string;
  52. /**
  53. * @internal
  54. */
  55. _connectionType: FlowGraphConnectionType;
  56. /**
  57. * Used for parsing connections.
  58. * @internal
  59. */
  60. connectedPointIds: any[];
  61. constructor(name: string, _connectionType: FlowGraphConnectionType, _ownerBlock: BlockT);
  62. /**
  63. * The type of the connection
  64. */
  65. get connectionType(): FlowGraphConnectionType;
  66. /**
  67. * @internal
  68. * Override this to indicate if a point can connect to more than one point.
  69. */
  70. _isSingularConnection(): boolean;
  71. /**
  72. * Returns if a point is connected to any other point.
  73. * @returns boolean indicating if the point is connected.
  74. */
  75. isConnected(): boolean;
  76. /**
  77. * Connects two connections together.
  78. * @param point the connection to connect to.
  79. */
  80. connectTo(point: ConnectedToT): void;
  81. /**
  82. * Saves the connection to a JSON object.
  83. * @param serializationObject the object to serialize to.
  84. */
  85. serialize(serializationObject?: any): void;
  86. /**
  87. * @returns class name of the connection.
  88. */
  89. getClassName(): string;
  90. /**
  91. * Deserialize from a object into this
  92. * @param serializationObject the object to deserialize from.
  93. */
  94. deserialize(serializationObject: any): void;
  95. /**
  96. * Parses a connection from an object
  97. * @param serializationObject the object to parse from.
  98. * @param ownerBlock the block that owns the connection.
  99. * @returns the parsed connection.
  100. */
  101. static Parse(serializationObject: any, ownerBlock: FlowGraphBlock): any;
  102. }