flowGraphBlock.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import type { FlowGraphContext } from "./flowGraphContext";
  2. import { FlowGraphDataConnection } from "./flowGraphDataConnection";
  3. import type { RichType } from "./flowGraphRichTypes";
  4. import type { ISerializedFlowGraphBlock, IObjectAccessor } from "./typeDefinitions";
  5. import type { Scene } from "../scene";
  6. import type { IPathToObjectConverter } from "../ObjectModel/objectModelInterfaces";
  7. /**
  8. * @experimental
  9. * Options for parsing a block.
  10. */
  11. export interface IFlowGraphBlockParseOptions {
  12. /**
  13. * A function that parses a value from a serialization object.
  14. * @param key the key of the property
  15. * @param serializationObject the serialization object where the property is located
  16. * @param scene the scene that the block is being parsed in
  17. * @returns the parsed value
  18. */
  19. valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;
  20. /**
  21. * The scene that the block is being parsed in.
  22. */
  23. scene: Scene;
  24. /**
  25. * The path converter to use to convert the path to an object accessor.
  26. */
  27. pathConverter: IPathToObjectConverter<IObjectAccessor>;
  28. }
  29. /**
  30. * @experimental
  31. * Configuration for a block.
  32. */
  33. export interface IFlowGraphBlockConfiguration {
  34. /**
  35. * The name of the block.
  36. */
  37. name?: string;
  38. [extraPropertyKey: string]: any;
  39. }
  40. /**
  41. * @experimental
  42. * A block in a flow graph. The most basic form
  43. * of a block has inputs and outputs that contain
  44. * data.
  45. */
  46. export declare class FlowGraphBlock {
  47. /**
  48. * the configuration of the block
  49. */
  50. config?: IFlowGraphBlockConfiguration | undefined;
  51. /**
  52. * A randomly generated GUID for each block.
  53. */
  54. uniqueId: string;
  55. /**
  56. * The name of the block.
  57. */
  58. name: string;
  59. /**
  60. * The data inputs of the block.
  61. */
  62. dataInputs: FlowGraphDataConnection<any>[];
  63. /**
  64. * The data outputs of the block.
  65. */
  66. dataOutputs: FlowGraphDataConnection<any>[];
  67. /**
  68. * Metadata that can be used by the block.
  69. */
  70. metadata: any;
  71. /** Constructor is protected so only subclasses can be instantiated
  72. * @param config optional configuration for this block
  73. */
  74. protected constructor(
  75. /**
  76. * the configuration of the block
  77. */
  78. config?: IFlowGraphBlockConfiguration | undefined);
  79. /**
  80. * @internal
  81. */
  82. _updateOutputs(_context: FlowGraphContext): void;
  83. /**
  84. * Registers a data input on the block.
  85. * @param name the name of the input
  86. * @param richType the type of the input
  87. * @returns the created connection
  88. */
  89. registerDataInput<T>(name: string, richType: RichType<T>): FlowGraphDataConnection<T>;
  90. /**
  91. * Registers a data output on the block.
  92. * @param name the name of the input
  93. * @param richType the type of the input
  94. * @returns the created connection
  95. */
  96. registerDataOutput<T>(name: string, richType: RichType<T>): FlowGraphDataConnection<T>;
  97. /**
  98. * Given the name of a data input, returns the connection if it exists
  99. * @param name the name of the input
  100. * @returns the connection if it exists, undefined otherwise
  101. */
  102. getDataInput(name: string): FlowGraphDataConnection<any> | undefined;
  103. /**
  104. * Given the name of a data output, returns the connection if it exists
  105. * @param name the name of the output
  106. * @returns the connection if it exists, undefined otherwise
  107. */
  108. getDataOutput(name: string): FlowGraphDataConnection<any> | undefined;
  109. /**
  110. * Serializes this block
  111. * @param serializationObject the object to serialize to
  112. * @param _valueSerializeFunction a function that serializes a specific value
  113. */
  114. serialize(serializationObject?: any, _valueSerializeFunction?: (key: string, value: any, serializationObject: any) => any): void;
  115. /**
  116. * Gets the class name of this block
  117. * @returns the class name
  118. */
  119. getClassName(): string;
  120. /**
  121. * Parses a block from a serialization object
  122. * @param serializationObject the object to parse from
  123. * @param parseOptions options for parsing the block
  124. * @returns the parsed block
  125. */
  126. static Parse(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): FlowGraphBlock;
  127. }