@theclearsky/react-blender-nodes 0.0.3 → 0.0.5
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/README.md +131 -44
- package/dist/index.d.ts +269 -27
- package/dist/react-blender-nodes.css +1 -1
- package/dist/react-blender-nodes.es.js +6991 -4341
- package/dist/react-blender-nodes.es.js.map +1 -1
- package/dist/react-blender-nodes.umd.js +20 -20
- package/dist/react-blender-nodes.umd.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -44,12 +44,21 @@ export declare type Action<DataTypeUniqueId extends string = string, NodeTypeUni
|
|
|
44
44
|
/** Position where to place the node */
|
|
45
45
|
position: XYPosition;
|
|
46
46
|
};
|
|
47
|
+
} | {
|
|
48
|
+
/** Add a new node to the graph and select it */
|
|
49
|
+
type: typeof actionTypesMap.ADD_NODE_AND_SELECT;
|
|
50
|
+
payload: {
|
|
51
|
+
/** Type of node to add */
|
|
52
|
+
type: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['nodeIdToNodeType'][string];
|
|
53
|
+
/** Position where to place the node */
|
|
54
|
+
position: XYPosition;
|
|
55
|
+
};
|
|
47
56
|
} | {
|
|
48
57
|
/** Update nodes based on ReactFlow changes */
|
|
49
58
|
type: typeof actionTypesMap.UPDATE_NODE_BY_REACT_FLOW;
|
|
50
59
|
payload: {
|
|
51
60
|
/** Array of node changes from ReactFlow */
|
|
52
|
-
changes: NodeChanges
|
|
61
|
+
changes: NodeChanges<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
|
|
53
62
|
};
|
|
54
63
|
} | {
|
|
55
64
|
/** Update edges based on ReactFlow changes */
|
|
@@ -81,12 +90,49 @@ export declare type Action<DataTypeUniqueId extends string = string, NodeTypeUni
|
|
|
81
90
|
/** Map of action types for type-safe action dispatching */
|
|
82
91
|
export declare const actionTypesMap: {
|
|
83
92
|
readonly ADD_NODE: "ADD_NODE";
|
|
93
|
+
readonly ADD_NODE_AND_SELECT: "ADD_NODE_AND_SELECT";
|
|
84
94
|
readonly UPDATE_NODE_BY_REACT_FLOW: "UPDATE_NODE_BY_REACT_FLOW";
|
|
85
95
|
readonly UPDATE_EDGES_BY_REACT_FLOW: "UPDATE_EDGES_BY_REACT_FLOW";
|
|
86
96
|
readonly ADD_EDGE_BY_REACT_FLOW: "ADD_EDGE_BY_REACT_FLOW";
|
|
87
97
|
readonly UPDATE_INPUT_VALUE: "UPDATE_INPUT_VALUE";
|
|
88
98
|
};
|
|
89
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Adds a new edge between two handles with type checking and inference
|
|
102
|
+
*
|
|
103
|
+
* This function validates that a connection is allowed between two handles based on
|
|
104
|
+
* their data types, handles type inference for 'inferFromConnection' types, and
|
|
105
|
+
* validates Zod schema compatibility for complex types.
|
|
106
|
+
*
|
|
107
|
+
* @template DataTypeUniqueId - Unique identifier type for data types
|
|
108
|
+
* @template NodeTypeUniqueId - Unique identifier type for node types
|
|
109
|
+
* @template UnderlyingType - Supported underlying data types
|
|
110
|
+
* @template ComplexSchemaType - Zod schema type for complex data types
|
|
111
|
+
* @param nodes - Array of nodes in the graph
|
|
112
|
+
* @param edges - Array of edges in the graph
|
|
113
|
+
* @param newEdgeSourceNodeId - ID of the source node
|
|
114
|
+
* @param newEdgeSourceHandleId - ID of the source handle
|
|
115
|
+
* @param newEdgeTargetNodeId - ID of the target node
|
|
116
|
+
* @param newEdgeTargetHandleId - ID of the target handle
|
|
117
|
+
* @param state - The current graph state
|
|
118
|
+
* @param allowedConversionsBetweenDataTypes - Optional mapping of allowed conversions
|
|
119
|
+
* @param enableTypeInference - Whether to enable type inference
|
|
120
|
+
* @param enableComplexTypeChecking - Whether to enable complex type checking
|
|
121
|
+
* @returns Object containing updated nodes, edges, and validation result
|
|
122
|
+
*/
|
|
123
|
+
export declare function addEdgeWithTypeChecking<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(newEdgeSourceNodeId: string, newEdgeSourceHandleId: string, newEdgeTargetNodeId: string, newEdgeTargetHandleId: string, state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): {
|
|
124
|
+
updatedNodes: Nodes<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
|
|
125
|
+
updatedEdges: Edges;
|
|
126
|
+
validation: ConnectionValidationResult;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Mapping of allowed conversions between data types
|
|
131
|
+
*
|
|
132
|
+
* @template DataTypeUniqueId - Unique identifier type for data types
|
|
133
|
+
*/
|
|
134
|
+
declare type AllowedConversionsBetweenDataTypes<DataTypeUniqueId extends string = string> = Partial<Record<DataTypeUniqueId, Partial<Record<DataTypeUniqueId, boolean>>>>;
|
|
135
|
+
|
|
90
136
|
/**
|
|
91
137
|
* Represents a rectangular bounding box
|
|
92
138
|
*/
|
|
@@ -227,7 +273,7 @@ export declare function cn(...inputs: ClassValue[]): string;
|
|
|
227
273
|
* />
|
|
228
274
|
* ```
|
|
229
275
|
*/
|
|
230
|
-
export declare const ConfigurableEdge: ForwardRefExoticComponent<Pick<ConfigurableEdgeState, "data" | "source" | "style" | "id" | "
|
|
276
|
+
export declare const ConfigurableEdge: ForwardRefExoticComponent<Pick<ConfigurableEdgeState, "data" | "source" | "style" | "id" | "target" | "selectable" | "deletable" | "selected" | "animated"> & EdgePosition & EdgeLabelOptions & {
|
|
231
277
|
sourceHandleId?: string | null;
|
|
232
278
|
targetHandleId?: string | null;
|
|
233
279
|
markerStart?: string;
|
|
@@ -322,9 +368,9 @@ name?: string;
|
|
|
322
368
|
/** Background color of the node header */
|
|
323
369
|
headerColor?: string;
|
|
324
370
|
/** Array of inputs and input panels */
|
|
325
|
-
inputs?: (ConfigurableNodeInput | ConfigurableNodeInputPanel)[];
|
|
371
|
+
inputs?: (ConfigurableNodeInput<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string> | ConfigurableNodeInputPanel<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string>)[] | undefined;
|
|
326
372
|
/** Array of output sockets */
|
|
327
|
-
outputs?: ConfigurableNodeOutput[];
|
|
373
|
+
outputs?: ConfigurableNodeOutput<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string>[] | undefined;
|
|
328
374
|
/** Whether the node is currently inside a ReactFlow context */
|
|
329
375
|
isCurrentlyInsideReactFlow?: boolean;
|
|
330
376
|
/** Props for the node resizer component */
|
|
@@ -337,7 +383,7 @@ nodeResizerProps?: NodeResizerWithMoreControlsProps;
|
|
|
337
383
|
* Defines an input socket on a node with optional interactive input component.
|
|
338
384
|
* Supports both string and number types with type-specific onChange handlers.
|
|
339
385
|
*/
|
|
340
|
-
export declare type ConfigurableNodeInput = {
|
|
386
|
+
export declare type ConfigurableNodeInput<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
|
|
341
387
|
/** Unique identifier for the input */
|
|
342
388
|
id: string;
|
|
343
389
|
/** Display name for the input */
|
|
@@ -348,6 +394,16 @@ export declare type ConfigurableNodeInput = {
|
|
|
348
394
|
handleShape?: HandleShape;
|
|
349
395
|
/** Whether to show an interactive input component when not connected */
|
|
350
396
|
allowInput?: boolean;
|
|
397
|
+
/** Data type of the input, used by full graph */
|
|
398
|
+
dataType?: {
|
|
399
|
+
dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
|
|
400
|
+
dataTypeUniqueId: DataTypeUniqueId;
|
|
401
|
+
};
|
|
402
|
+
/** Inferred data type of the input (only when type inference is enabled and datatype is inferredFromConnection and connected), used by full graph */
|
|
403
|
+
inferredDataType?: {
|
|
404
|
+
dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
|
|
405
|
+
dataTypeUniqueId: DataTypeUniqueId;
|
|
406
|
+
} | null;
|
|
351
407
|
} & ({
|
|
352
408
|
/** String input type */
|
|
353
409
|
type: 'string';
|
|
@@ -369,13 +425,13 @@ export declare type ConfigurableNodeInput = {
|
|
|
369
425
|
*
|
|
370
426
|
* Groups multiple inputs together in a collapsible panel for better organization.
|
|
371
427
|
*/
|
|
372
|
-
export declare type ConfigurableNodeInputPanel = {
|
|
428
|
+
export declare type ConfigurableNodeInputPanel<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
|
|
373
429
|
/** Unique identifier for the panel */
|
|
374
430
|
id: string;
|
|
375
431
|
/** Display name for the panel */
|
|
376
432
|
name: string;
|
|
377
433
|
/** Array of inputs contained in this panel */
|
|
378
|
-
inputs: ConfigurableNodeInput[];
|
|
434
|
+
inputs: ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>[];
|
|
379
435
|
};
|
|
380
436
|
|
|
381
437
|
/**
|
|
@@ -383,7 +439,7 @@ export declare type ConfigurableNodeInputPanel = {
|
|
|
383
439
|
*
|
|
384
440
|
* Defines an output socket on a node that can be connected to inputs.
|
|
385
441
|
*/
|
|
386
|
-
export declare type ConfigurableNodeOutput = {
|
|
442
|
+
export declare type ConfigurableNodeOutput<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
|
|
387
443
|
/** Unique identifier for the output */
|
|
388
444
|
id: string;
|
|
389
445
|
/** Display name for the output */
|
|
@@ -392,6 +448,16 @@ export declare type ConfigurableNodeOutput = {
|
|
|
392
448
|
handleColor?: string;
|
|
393
449
|
/** Shape of the output handle (circle, square, diamond, etc.) */
|
|
394
450
|
handleShape?: HandleShape;
|
|
451
|
+
/** Data type of the output, used by full graph */
|
|
452
|
+
dataType?: {
|
|
453
|
+
dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
|
|
454
|
+
dataTypeUniqueId: DataTypeUniqueId;
|
|
455
|
+
};
|
|
456
|
+
/** Inferred data type of the output (only when type inference is enabled and datatype is inferredFromConnection and connected), used by full graph */
|
|
457
|
+
inferredDataType?: {
|
|
458
|
+
dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
|
|
459
|
+
dataTypeUniqueId: DataTypeUniqueId;
|
|
460
|
+
} | null;
|
|
395
461
|
} & ({
|
|
396
462
|
/** String output type */
|
|
397
463
|
type: 'string';
|
|
@@ -406,15 +472,15 @@ export declare type ConfigurableNodeOutput = {
|
|
|
406
472
|
* Defines the complete configuration for a customizable node with inputs, outputs,
|
|
407
473
|
* and optional panels. Supports both standalone usage and ReactFlow integration.
|
|
408
474
|
*/
|
|
409
|
-
export declare type ConfigurableNodeProps = {
|
|
475
|
+
export declare type ConfigurableNodeProps<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
|
|
410
476
|
/** Display name of the node */
|
|
411
477
|
name?: string;
|
|
412
478
|
/** Background color of the node header */
|
|
413
479
|
headerColor?: string;
|
|
414
480
|
/** Array of inputs and input panels */
|
|
415
|
-
inputs?: (ConfigurableNodeInput | ConfigurableNodeInputPanel)[];
|
|
481
|
+
inputs?: (ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeInputPanel<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>)[];
|
|
416
482
|
/** Array of output sockets */
|
|
417
|
-
outputs?: ConfigurableNodeOutput[];
|
|
483
|
+
outputs?: ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>[];
|
|
418
484
|
/** Whether the node is currently inside a ReactFlow context */
|
|
419
485
|
isCurrentlyInsideReactFlow?: boolean;
|
|
420
486
|
/** Props for the node resizer component */
|
|
@@ -464,17 +530,23 @@ export declare type ConfigurableNodeProps = {
|
|
|
464
530
|
* />
|
|
465
531
|
* ```
|
|
466
532
|
*/
|
|
467
|
-
export declare const ConfigurableNodeReactFlowWrapper: ForwardRefExoticComponent<
|
|
468
|
-
isConnectable: boolean;
|
|
469
|
-
positionAbsoluteX: number;
|
|
470
|
-
positionAbsoluteY: number;
|
|
471
|
-
} & RefAttributes<HTMLDivElement>>;
|
|
533
|
+
export declare const ConfigurableNodeReactFlowWrapper: ForwardRefExoticComponent<Omit<ConfigurableNodeReactFlowWrapperProps<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string>, "position"> & RefAttributes<HTMLDivElement>>;
|
|
472
534
|
|
|
473
535
|
/** Props for the ConfigurableNodeReactFlowWrapper component */
|
|
474
|
-
export declare type ConfigurableNodeReactFlowWrapperProps = NodeProps<ConfigurableNodeState
|
|
536
|
+
export declare type ConfigurableNodeReactFlowWrapperProps<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = NodeProps<ConfigurableNodeState<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>> & {
|
|
537
|
+
position: XYPosition;
|
|
538
|
+
};
|
|
475
539
|
|
|
476
540
|
/** State type for configurable nodes in ReactFlow */
|
|
477
|
-
export declare type ConfigurableNodeState = Node_2<Omit<ConfigurableNodeProps, 'isCurrentlyInsideReactFlow'>, 'configurableNode'>;
|
|
541
|
+
export declare type ConfigurableNodeState<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = Node_2<Omit<ConfigurableNodeProps<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>, 'isCurrentlyInsideReactFlow'>, 'configurableNode'>;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Type for connection validation result
|
|
545
|
+
*/
|
|
546
|
+
declare type ConnectionValidationResult = {
|
|
547
|
+
isValid: boolean;
|
|
548
|
+
reason?: string;
|
|
549
|
+
};
|
|
478
550
|
|
|
479
551
|
/**
|
|
480
552
|
* Constructs a ConfigurableNodeInput or ConfigurableNodeOutput from a type definition
|
|
@@ -514,7 +586,7 @@ export declare type ConfigurableNodeState = Node_2<Omit<ConfigurableNodeProps, '
|
|
|
514
586
|
* );
|
|
515
587
|
* ```
|
|
516
588
|
*/
|
|
517
|
-
export declare function constructInputOrOutputOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(
|
|
589
|
+
export declare function constructInputOrOutputOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(typeOfDataTypeInNode: TypeOfInput<DataTypeUniqueId> | TypeOfNode<DataTypeUniqueId>['outputs'][number], allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes']): ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
|
|
518
590
|
|
|
519
591
|
/**
|
|
520
592
|
* Constructs a ConfigurableNodeInputPanel from a type definition
|
|
@@ -560,13 +632,13 @@ export declare function constructInputOrOutputOfType<DataTypeUniqueId extends st
|
|
|
560
632
|
* );
|
|
561
633
|
* ```
|
|
562
634
|
*/
|
|
563
|
-
export declare function constructInputPanelOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(
|
|
635
|
+
export declare function constructInputPanelOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(typeOfPanelInNode: {
|
|
564
636
|
name: string;
|
|
565
637
|
inputs: {
|
|
566
638
|
name: string;
|
|
567
639
|
dataType: DataTypeUniqueId;
|
|
568
640
|
}[];
|
|
569
|
-
},
|
|
641
|
+
}, allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes']): ConfigurableNodeInputPanel<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
|
|
570
642
|
|
|
571
643
|
/**
|
|
572
644
|
* Constructs a complete node from a node type definition
|
|
@@ -625,7 +697,20 @@ export declare function constructInputPanelOfType<DataTypeUniqueId extends strin
|
|
|
625
697
|
* );
|
|
626
698
|
* ```
|
|
627
699
|
*/
|
|
628
|
-
export declare function constructNodeOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(
|
|
700
|
+
export declare function constructNodeOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes'], nodeType: NodeTypeUniqueId, typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'], nodeId: string, position: XYPosition): State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['nodes'][number];
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Constructs the type of a handle from indices
|
|
704
|
+
*
|
|
705
|
+
* This function constructs the type of a handle from indices, handling both regular inputs and inputs within panels.
|
|
706
|
+
*
|
|
707
|
+
* @param allDataTypes - The all data types
|
|
708
|
+
* @param nodeType - The node type
|
|
709
|
+
* @param typeOfNodes - The type of nodes
|
|
710
|
+
* @param indices - The indices of the handle
|
|
711
|
+
* @returns The type of the handle
|
|
712
|
+
*/
|
|
713
|
+
export declare function constructTypeOfHandleFromIndices<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes'], nodeType: NodeTypeUniqueId, typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'], indices: HandleIndices | undefined): ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | undefined;
|
|
629
714
|
|
|
630
715
|
/**
|
|
631
716
|
* A context-aware handle component for node inputs and outputs
|
|
@@ -890,9 +975,9 @@ export declare type Coordinate = {
|
|
|
890
975
|
* @param contextMenuPosition - The position where the context menu was opened
|
|
891
976
|
* @returns ContextMenuItem array for the context menu
|
|
892
977
|
*/
|
|
893
|
-
export declare function createNodeContextMenu<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends
|
|
978
|
+
export declare function createNodeContextMenu<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>({ typeOfNodes, dispatch, setContextMenu, contextMenuPosition, }: CreateNodeContextMenuProps<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): ContextMenuItem[];
|
|
894
979
|
|
|
895
|
-
export declare type CreateNodeContextMenuProps<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends
|
|
980
|
+
export declare type CreateNodeContextMenuProps<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? any : never = never> = {
|
|
896
981
|
typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'];
|
|
897
982
|
dispatch: ActionDispatch<[
|
|
898
983
|
action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>
|
|
@@ -919,6 +1004,10 @@ export declare type DataType<UnderlyingType extends SupportedUnderlyingTypes = S
|
|
|
919
1004
|
complexSchema: ComplexSchemaType;
|
|
920
1005
|
/** Color used for visual representation */
|
|
921
1006
|
color: string;
|
|
1007
|
+
/** Shape of the handle */
|
|
1008
|
+
shape?: HandleShape;
|
|
1009
|
+
/** Whether this input allows direct user input */
|
|
1010
|
+
allowInput?: boolean;
|
|
922
1011
|
} : {
|
|
923
1012
|
/** Display name of the data type */
|
|
924
1013
|
name: string;
|
|
@@ -928,6 +1017,10 @@ export declare type DataType<UnderlyingType extends SupportedUnderlyingTypes = S
|
|
|
928
1017
|
complexSchema?: undefined;
|
|
929
1018
|
/** Color used for visual representation */
|
|
930
1019
|
color: string;
|
|
1020
|
+
/** Shape of the handle */
|
|
1021
|
+
shape?: HandleShape;
|
|
1022
|
+
/** Whether this input allows direct user input */
|
|
1023
|
+
allowInput?: boolean;
|
|
931
1024
|
};
|
|
932
1025
|
|
|
933
1026
|
/**
|
|
@@ -1053,6 +1146,21 @@ export declare type FullGraphProps<DataTypeUniqueId extends string = string, Nod
|
|
|
1053
1146
|
]>;
|
|
1054
1147
|
};
|
|
1055
1148
|
|
|
1149
|
+
export declare function getResultantDataTypeOfHandleConsideringInferredType<DataTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(handle: ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | undefined): {
|
|
1150
|
+
dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
|
|
1151
|
+
dataTypeUniqueId: DataTypeUniqueId;
|
|
1152
|
+
} | undefined;
|
|
1153
|
+
|
|
1154
|
+
declare type HandleIndices = {
|
|
1155
|
+
type: 'input';
|
|
1156
|
+
index1: number;
|
|
1157
|
+
index2: number | undefined;
|
|
1158
|
+
} | {
|
|
1159
|
+
type: 'output';
|
|
1160
|
+
index1: number;
|
|
1161
|
+
index2: undefined;
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1056
1164
|
/** Type representing all available handle shapes */
|
|
1057
1165
|
export declare type HandleShape = (typeof handleShapesMap)[keyof typeof handleShapesMap];
|
|
1058
1166
|
|
|
@@ -1192,6 +1300,16 @@ export declare function isNumberInRange(number: number, min: number, max: number
|
|
|
1192
1300
|
*/
|
|
1193
1301
|
export declare function isSupportedUnderlyingType(type: string): type is SupportedUnderlyingTypes;
|
|
1194
1302
|
|
|
1303
|
+
/**
|
|
1304
|
+
* Type guard to check if a string is a valid DataTypeUniqueId
|
|
1305
|
+
*/
|
|
1306
|
+
export declare function isValidDataTypeId<DataTypeUniqueId extends string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(id: string, dataTypes: Record<DataTypeUniqueId, DataType<UnderlyingType, ComplexSchemaType>>): id is DataTypeUniqueId;
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Type guard to check if a string is a valid NodeTypeUniqueId
|
|
1310
|
+
*/
|
|
1311
|
+
export declare function isValidNodeTypeUniqueId<NodeTypeUniqueId extends string>(id: string, nodeIdToNodeType: Record<string, NodeTypeUniqueId>): id is NodeTypeUniqueId;
|
|
1312
|
+
|
|
1195
1313
|
/**
|
|
1196
1314
|
* Main reducer function for managing graph state
|
|
1197
1315
|
*
|
|
@@ -1269,6 +1387,36 @@ export declare function isSupportedUnderlyingType(type: string): type is Support
|
|
|
1269
1387
|
*/
|
|
1270
1388
|
export declare function mainReducer<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(oldState: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>, action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>;
|
|
1271
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* Helper function to create a mapping of allowed conversions between data types with automatic type inference
|
|
1392
|
+
*
|
|
1393
|
+
* This function is essential for type safety when creating a mapping of allowed conversions between data types.
|
|
1394
|
+
* It ensures that TypeScript can properly infer and validate the types throughout your graph system,
|
|
1395
|
+
* preventing runtime errors and providing better IDE support.
|
|
1396
|
+
*
|
|
1397
|
+
* @template DataTypeUniqueId - Unique identifier type for data types
|
|
1398
|
+
* @param input - The mapping of allowed conversions between data types
|
|
1399
|
+
* @returns The mapping with proper typing
|
|
1400
|
+
*
|
|
1401
|
+
* @example
|
|
1402
|
+
* ```tsx
|
|
1403
|
+
* // ✅ Type-safe - TypeScript will validate node type references
|
|
1404
|
+
* const allowedConversionsBetweenDataTypes = makeAllowedConversionsBetweenDataTypesWithAutoInfer({
|
|
1405
|
+
* 'inputDataType': {
|
|
1406
|
+
* 'outputDataType': true,
|
|
1407
|
+
* },
|
|
1408
|
+
* });
|
|
1409
|
+
*
|
|
1410
|
+
* // ❌ Without auto-infer - TypeScript can't validate node type references
|
|
1411
|
+
* const allowedConversionsBetweenDataTypes = {
|
|
1412
|
+
* 'inputDataType': {
|
|
1413
|
+
* 'outputDataType': true,
|
|
1414
|
+
* },
|
|
1415
|
+
* };
|
|
1416
|
+
* ```
|
|
1417
|
+
*/
|
|
1418
|
+
export declare function makeAllowedConversionsBetweenDataTypesWithAutoInfer<DataTypeUniqueId extends string = string>(input: AllowedConversionsBetweenDataTypes<DataTypeUniqueId>): Partial<Record<DataTypeUniqueId, Partial<Record<DataTypeUniqueId, boolean>>>>;
|
|
1419
|
+
|
|
1272
1420
|
/**
|
|
1273
1421
|
* Helper function to create a data type with automatic type inference
|
|
1274
1422
|
*
|
|
@@ -1412,7 +1560,7 @@ export declare function makeTypeOfNodeWithAutoInfer<DataTypeUniqueId extends str
|
|
|
1412
1560
|
/**
|
|
1413
1561
|
* Array of node changes for ReactFlow
|
|
1414
1562
|
*/
|
|
1415
|
-
export declare type NodeChanges = NodeChange<
|
|
1563
|
+
export declare type NodeChanges<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = NodeChange<Optional<ConfigurableNodeReactFlowWrapperProps<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>, NodeOptionalKeys>>[];
|
|
1416
1564
|
|
|
1417
1565
|
/**
|
|
1418
1566
|
* Mapping from node IDs to their node types
|
|
@@ -1421,6 +1569,8 @@ export declare type NodeChanges = NodeChange<ConfigurableNodeState>[];
|
|
|
1421
1569
|
*/
|
|
1422
1570
|
export declare type NodeIdToNodeType<NodeTypeUniqueId extends string = string> = Record<string, NodeTypeUniqueId>;
|
|
1423
1571
|
|
|
1572
|
+
declare type NodeOptionalKeys = 'draggable' | 'zIndex' | 'selectable' | 'deletable' | 'dragging' | 'selected' | 'isConnectable' | 'positionAbsoluteX' | 'positionAbsoluteY';
|
|
1573
|
+
|
|
1424
1574
|
/**
|
|
1425
1575
|
* Enhanced node resizer component with customizable controls
|
|
1426
1576
|
*
|
|
@@ -1489,7 +1639,9 @@ export declare type NodeResizerWithMoreControlsProps = NodeResizerProps & {
|
|
|
1489
1639
|
/**
|
|
1490
1640
|
* Array of configurable nodes in the graph
|
|
1491
1641
|
*/
|
|
1492
|
-
export declare type Nodes =
|
|
1642
|
+
export declare type Nodes<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = Optional<ConfigurableNodeReactFlowWrapperProps<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>, NodeOptionalKeys>[];
|
|
1643
|
+
|
|
1644
|
+
declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
1493
1645
|
|
|
1494
1646
|
/**
|
|
1495
1647
|
* ReactFlow-aware input component that automatically updates node data
|
|
@@ -1511,6 +1663,35 @@ export declare type ReactFlowAwareInputProps = {
|
|
|
1511
1663
|
input: ConfigurableNodeInput;
|
|
1512
1664
|
};
|
|
1513
1665
|
|
|
1666
|
+
/**
|
|
1667
|
+
* Removes an edge between two handles with type checking and inference
|
|
1668
|
+
*
|
|
1669
|
+
* This function validates that a connection is removed between two handles based on
|
|
1670
|
+
* their data types, handles type inference for 'inferFromConnection' types, and
|
|
1671
|
+
* validates Zod schema compatibility for complex types.
|
|
1672
|
+
*
|
|
1673
|
+
* @template DataTypeUniqueId - Unique identifier type for data types
|
|
1674
|
+
* @template NodeTypeUniqueId - Unique identifier type for node types
|
|
1675
|
+
* @template UnderlyingType - Supported underlying data types
|
|
1676
|
+
* @template ComplexSchemaType - Zod schema type for complex data types
|
|
1677
|
+
* @param nodes - Array of nodes in the graph
|
|
1678
|
+
* @param edges - Array of edges in the graph
|
|
1679
|
+
* @param removedEdgeSourceNodeId - ID of the source node
|
|
1680
|
+
* @param removedEdgeSourceHandleId - ID of the source handle
|
|
1681
|
+
* @param removedEdgeTargetNodeId - ID of the target node
|
|
1682
|
+
* @param removedEdgeTargetHandleId - ID of the target handle
|
|
1683
|
+
* @param state - The current graph state
|
|
1684
|
+
* @param allowedConversionsBetweenDataTypes - Optional mapping of allowed conversions
|
|
1685
|
+
* @param enableTypeInference - Whether to enable type inference
|
|
1686
|
+
* @param enableComplexTypeChecking - Whether to enable complex type checking
|
|
1687
|
+
* @returns Object containing updated nodes, edges, and validation result
|
|
1688
|
+
*/
|
|
1689
|
+
export declare function removeEdgeWithTypeChecking<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(removedEdge: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['edges'][number], state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>, removedEdgeChange: EdgeChange<ConfigurableEdgeState>): {
|
|
1690
|
+
updatedNodes: Nodes<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
|
|
1691
|
+
updatedEdges: Edges;
|
|
1692
|
+
validation: ConnectionValidationResult;
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1514
1695
|
/**
|
|
1515
1696
|
* Sanitizes a number to be shown as a text, removing the trailing zeros after the decimal point if the number is an integer
|
|
1516
1697
|
* @param value - The number to sanitize
|
|
@@ -1604,11 +1785,59 @@ export declare type State<DataTypeUniqueId extends string = string, NodeTypeUniq
|
|
|
1604
1785
|
/** Map of node type definitions */
|
|
1605
1786
|
typeOfNodes: Record<NodeTypeUniqueId, TypeOfNode<DataTypeUniqueId>>;
|
|
1606
1787
|
/** Array of nodes in the graph */
|
|
1607
|
-
nodes: Nodes
|
|
1788
|
+
nodes: Nodes<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
|
|
1608
1789
|
/** Mapping from node IDs to their types */
|
|
1609
1790
|
nodeIdToNodeType: NodeIdToNodeType<NodeTypeUniqueId>;
|
|
1610
1791
|
/** Array of edges in the graph */
|
|
1611
1792
|
edges: Edges;
|
|
1793
|
+
/**
|
|
1794
|
+
* Optional mapping of allowed conversions between data types
|
|
1795
|
+
* - When not provided, all conversions are allowed
|
|
1796
|
+
* - If provided, only the conversions that are explicitly allowed will be allowed (happens even with empty object)
|
|
1797
|
+
* - By default, it will not allow conversion between complex types unless explicitly allowed here (even if complex type checking is enabled)
|
|
1798
|
+
* - If you want to allow conversion between complex types unless disallowed by complex type checking, you can set `allowConversionBetweenComplexTypesUnlessDisallowedByComplexTypeChecking` to true
|
|
1799
|
+
*
|
|
1800
|
+
* @default undefined
|
|
1801
|
+
*/
|
|
1802
|
+
allowedConversionsBetweenDataTypes?: AllowedConversionsBetweenDataTypes<DataTypeUniqueId>;
|
|
1803
|
+
/**
|
|
1804
|
+
* Whether to allow conversion between complex types unless disallowed by complex type checking
|
|
1805
|
+
* - If not provided, is considered disabled
|
|
1806
|
+
* - Only takes effect if complex type checking is enabled (`allowedConversionsBetweenDataTypes` is provided)
|
|
1807
|
+
* - If enabled, it will allow conversion between complex types unless disallowed by complex type checking
|
|
1808
|
+
* - If disabled, it will not allow conversion between complex types unless explicitly allowed by `allowedConversionsBetweenDataTypes`, even if complex type checking is enabled
|
|
1809
|
+
*
|
|
1810
|
+
* @default undefined
|
|
1811
|
+
*/
|
|
1812
|
+
allowConversionBetweenComplexTypesUnlessDisallowedByComplexTypeChecking?: boolean;
|
|
1813
|
+
/**
|
|
1814
|
+
* Whether to enable type inference
|
|
1815
|
+
* - If not provided, is considered disabled
|
|
1816
|
+
* - When disabled, the types of the nodes are not inferred from the connections
|
|
1817
|
+
* - When enabled, the types of the nodes are inferred from the connections and reset when edges are removed
|
|
1818
|
+
*
|
|
1819
|
+
* @default undefined
|
|
1820
|
+
*/
|
|
1821
|
+
enableTypeInference?: boolean;
|
|
1822
|
+
/**
|
|
1823
|
+
* Whether to enable complex type checking
|
|
1824
|
+
* - If not provided, is considered disabled
|
|
1825
|
+
* - When disabled, the complex types are not checked for compatibility, all connections are allowed
|
|
1826
|
+
* - When enabled, the complex types are checked for compatibility, and connections are not allowed if the complex types are not compatible
|
|
1827
|
+
* - Complex types are compatible if they are the same type or if they have exactly the same schema
|
|
1828
|
+
*
|
|
1829
|
+
* @default undefined
|
|
1830
|
+
*/
|
|
1831
|
+
enableComplexTypeChecking?: boolean;
|
|
1832
|
+
/**
|
|
1833
|
+
* Whether to enable cycle checking
|
|
1834
|
+
* - If not provided, is considered disabled
|
|
1835
|
+
* - When disabled, the cycles are not checked, all connections are allowed
|
|
1836
|
+
* - When enabled, the cycles are checked, and connections are not allowed if they create a cycle
|
|
1837
|
+
*
|
|
1838
|
+
* @default undefined
|
|
1839
|
+
*/
|
|
1840
|
+
enableCycleChecking?: boolean;
|
|
1612
1841
|
};
|
|
1613
1842
|
|
|
1614
1843
|
/**
|
|
@@ -1852,4 +2081,17 @@ export declare function useFullGraph<DataTypeUniqueId extends string = string, N
|
|
|
1852
2081
|
dispatch: ActionDispatch<[action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>]>;
|
|
1853
2082
|
};
|
|
1854
2083
|
|
|
2084
|
+
/**
|
|
2085
|
+
* Checks if adding an edge will create a cycle in the graph
|
|
2086
|
+
*
|
|
2087
|
+
* @template DataTypeUniqueId - Unique identifier type for data types
|
|
2088
|
+
* @template NodeTypeUniqueId - Unique identifier type for node types
|
|
2089
|
+
* @template UnderlyingType - Supported underlying data types
|
|
2090
|
+
* @template ComplexSchemaType - Zod schema type for complex data types
|
|
2091
|
+
* @param state - The current graph state
|
|
2092
|
+
* @param newEdge - The edge to check
|
|
2093
|
+
* @returns Whether the edge will create a cycle
|
|
2094
|
+
*/
|
|
2095
|
+
export declare function willAddingEdgeCreateCycle<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>, sourceNodeId: string, targetNodeId: string): boolean;
|
|
2096
|
+
|
|
1855
2097
|
export { }
|