@foresthubai/workflow-builder 0.3.0
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/LICENSE +661 -0
- package/NOTICE +16 -0
- package/README.md +93 -0
- package/dist/BuilderLayout.d.ts +34 -0
- package/dist/BuilderLayout.d.ts.map +1 -0
- package/dist/BuilderLayout.js +172 -0
- package/dist/BuilderLayout.js.map +1 -0
- package/dist/Canvas.d.ts +23 -0
- package/dist/Canvas.d.ts.map +1 -0
- package/dist/Canvas.js +141 -0
- package/dist/Canvas.js.map +1 -0
- package/dist/CanvasEditor.d.ts +46 -0
- package/dist/CanvasEditor.d.ts.map +1 -0
- package/dist/CanvasEditor.js +57 -0
- package/dist/CanvasEditor.js.map +1 -0
- package/dist/CanvasTabsToolbar.d.ts +11 -0
- package/dist/CanvasTabsToolbar.d.ts.map +1 -0
- package/dist/CanvasTabsToolbar.js +101 -0
- package/dist/CanvasTabsToolbar.js.map +1 -0
- package/dist/RightConfigPanel.d.ts +27 -0
- package/dist/RightConfigPanel.d.ts.map +1 -0
- package/dist/RightConfigPanel.js +102 -0
- package/dist/RightConfigPanel.js.map +1 -0
- package/dist/WorkflowBuilder.d.ts +62 -0
- package/dist/WorkflowBuilder.d.ts.map +1 -0
- package/dist/WorkflowBuilder.js +275 -0
- package/dist/WorkflowBuilder.js.map +1 -0
- package/dist/cn.d.ts +3 -0
- package/dist/cn.d.ts.map +1 -0
- package/dist/cn.js +6 -0
- package/dist/cn.js.map +1 -0
- package/dist/components/ui/add-button.d.ts +16 -0
- package/dist/components/ui/add-button.d.ts.map +1 -0
- package/dist/components/ui/add-button.js +21 -0
- package/dist/components/ui/add-button.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +21 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +30 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.d.ts +9 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +23 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +21 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/button.d.ts +13 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +40 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +17 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +9 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +6 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/command.d.ts +82 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +29 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/delete-button.d.ts +11 -0
- package/dist/components/ui/delete-button.d.ts.map +1 -0
- package/dist/components/ui/delete-button.js +14 -0
- package/dist/components/ui/delete-button.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +22 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +27 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +36 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/input.d.ts +13 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +34 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +10 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/readonly-banner.d.ts +7 -0
- package/dist/components/ui/readonly-banner.d.ts.map +1 -0
- package/dist/components/ui/readonly-banner.js +12 -0
- package/dist/components/ui/readonly-banner.js.map +1 -0
- package/dist/components/ui/resizable.d.ts +24 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +9 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +45 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +27 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +30 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +8 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +12 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +34 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toast.d.ts +16 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +34 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toaster.d.ts +2 -0
- package/dist/components/ui/toaster.d.ts.map +1 -0
- package/dist/components/ui/toaster.js +10 -0
- package/dist/components/ui/toaster.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +21 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +13 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +26 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +14 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/dialogs/NodePickerDialog.d.ts +10 -0
- package/dist/dialogs/NodePickerDialog.d.ts.map +1 -0
- package/dist/dialogs/NodePickerDialog.js +39 -0
- package/dist/dialogs/NodePickerDialog.js.map +1 -0
- package/dist/dialogs/ValidationDialog.d.ts +17 -0
- package/dist/dialogs/ValidationDialog.d.ts.map +1 -0
- package/dist/dialogs/ValidationDialog.js +29 -0
- package/dist/dialogs/ValidationDialog.js.map +1 -0
- package/dist/graph/BaseNode.d.ts +9 -0
- package/dist/graph/BaseNode.d.ts.map +1 -0
- package/dist/graph/BaseNode.js +318 -0
- package/dist/graph/BaseNode.js.map +1 -0
- package/dist/graph/CustomEdge.d.ts +14 -0
- package/dist/graph/CustomEdge.d.ts.map +1 -0
- package/dist/graph/CustomEdge.js +107 -0
- package/dist/graph/CustomEdge.js.map +1 -0
- package/dist/graph/CustomNode.d.ts +3 -0
- package/dist/graph/CustomNode.d.ts.map +1 -0
- package/dist/graph/CustomNode.js +15 -0
- package/dist/graph/CustomNode.js.map +1 -0
- package/dist/graph/FunctionCallNode.d.ts +3 -0
- package/dist/graph/FunctionCallNode.d.ts.map +1 -0
- package/dist/graph/FunctionCallNode.js +25 -0
- package/dist/graph/FunctionCallNode.js.map +1 -0
- package/dist/graph/PortHandle.d.ts +21 -0
- package/dist/graph/PortHandle.d.ts.map +1 -0
- package/dist/graph/PortHandle.js +113 -0
- package/dist/graph/PortHandle.js.map +1 -0
- package/dist/graph/reactFlowRegistry.d.ts +65 -0
- package/dist/graph/reactFlowRegistry.d.ts.map +1 -0
- package/dist/graph/reactFlowRegistry.js +24 -0
- package/dist/graph/reactFlowRegistry.js.map +1 -0
- package/dist/hooks/use-toast.d.ts +47 -0
- package/dist/hooks/use-toast.d.ts.map +1 -0
- package/dist/hooks/use-toast.js +95 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/hooks/useAvailableVariables.d.ts +12 -0
- package/dist/hooks/useAvailableVariables.d.ts.map +1 -0
- package/dist/hooks/useAvailableVariables.js +16 -0
- package/dist/hooks/useAvailableVariables.js.map +1 -0
- package/dist/hooks/useCanvasHistory.d.ts +14 -0
- package/dist/hooks/useCanvasHistory.d.ts.map +1 -0
- package/dist/hooks/useCanvasHistory.js +20 -0
- package/dist/hooks/useCanvasHistory.js.map +1 -0
- package/dist/hooks/useCanvasTabs.d.ts +23 -0
- package/dist/hooks/useCanvasTabs.d.ts.map +1 -0
- package/dist/hooks/useCanvasTabs.js +136 -0
- package/dist/hooks/useCanvasTabs.js.map +1 -0
- package/dist/hooks/useFunctionDiagnosticsSync.d.ts +14 -0
- package/dist/hooks/useFunctionDiagnosticsSync.d.ts.map +1 -0
- package/dist/hooks/useFunctionDiagnosticsSync.js +38 -0
- package/dist/hooks/useFunctionDiagnosticsSync.js.map +1 -0
- package/dist/hooks/useFunctionRegistry.d.ts +15 -0
- package/dist/hooks/useFunctionRegistry.d.ts.map +1 -0
- package/dist/hooks/useFunctionRegistry.js +22 -0
- package/dist/hooks/useFunctionRegistry.js.map +1 -0
- package/dist/hooks/useFunctions.d.ts +15 -0
- package/dist/hooks/useFunctions.d.ts.map +1 -0
- package/dist/hooks/useFunctions.js +34 -0
- package/dist/hooks/useFunctions.js.map +1 -0
- package/dist/hooks/useGraph.d.ts +40 -0
- package/dist/hooks/useGraph.d.ts.map +1 -0
- package/dist/hooks/useGraph.js +102 -0
- package/dist/hooks/useGraph.js.map +1 -0
- package/dist/hooks/useNodeDefinitions.d.ts +17 -0
- package/dist/hooks/useNodeDefinitions.d.ts.map +1 -0
- package/dist/hooks/useNodeDefinitions.js +65 -0
- package/dist/hooks/useNodeDefinitions.js.map +1 -0
- package/dist/hooks/useParamErrors.d.ts +12 -0
- package/dist/hooks/useParamErrors.d.ts.map +1 -0
- package/dist/hooks/useParamErrors.js +28 -0
- package/dist/hooks/useParamErrors.js.map +1 -0
- package/dist/hooks/useResolvedTheme.d.ts +10 -0
- package/dist/hooks/useResolvedTheme.d.ts.map +1 -0
- package/dist/hooks/useResolvedTheme.js +29 -0
- package/dist/hooks/useResolvedTheme.js.map +1 -0
- package/dist/hooks/useResourceDiagnosticsSync.d.ts +40 -0
- package/dist/hooks/useResourceDiagnosticsSync.d.ts.map +1 -0
- package/dist/hooks/useResourceDiagnosticsSync.js +39 -0
- package/dist/hooks/useResourceDiagnosticsSync.js.map +1 -0
- package/dist/hooks/useSuppressThemeTransition.d.ts +32 -0
- package/dist/hooks/useSuppressThemeTransition.d.ts.map +1 -0
- package/dist/hooks/useSuppressThemeTransition.js +75 -0
- package/dist/hooks/useSuppressThemeTransition.js.map +1 -0
- package/dist/hooks/useWorkflowSerialization.d.ts +24 -0
- package/dist/hooks/useWorkflowSerialization.d.ts.map +1 -0
- package/dist/hooks/useWorkflowSerialization.js +113 -0
- package/dist/hooks/useWorkflowSerialization.js.map +1 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +46 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locales/de.json +501 -0
- package/dist/i18n/locales/en.json +557 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs/ExpressionInput.d.ts +12 -0
- package/dist/inputs/ExpressionInput.d.ts.map +1 -0
- package/dist/inputs/ExpressionInput.js +203 -0
- package/dist/inputs/ExpressionInput.js.map +1 -0
- package/dist/inputs/ParameterEditor.d.ts +13 -0
- package/dist/inputs/ParameterEditor.d.ts.map +1 -0
- package/dist/inputs/ParameterEditor.js +204 -0
- package/dist/inputs/ParameterEditor.js.map +1 -0
- package/dist/inputs/PortSection.d.ts +31 -0
- package/dist/inputs/PortSection.d.ts.map +1 -0
- package/dist/inputs/PortSection.js +26 -0
- package/dist/inputs/PortSection.js.map +1 -0
- package/dist/panels/BuilderSidebar.d.ts +24 -0
- package/dist/panels/BuilderSidebar.d.ts.map +1 -0
- package/dist/panels/BuilderSidebar.js +202 -0
- package/dist/panels/BuilderSidebar.js.map +1 -0
- package/dist/panels/ChannelConfigPanel.d.ts +8 -0
- package/dist/panels/ChannelConfigPanel.d.ts.map +1 -0
- package/dist/panels/ChannelConfigPanel.js +26 -0
- package/dist/panels/ChannelConfigPanel.js.map +1 -0
- package/dist/panels/ChannelsPanel.d.ts +2 -0
- package/dist/panels/ChannelsPanel.d.ts.map +1 -0
- package/dist/panels/ChannelsPanel.js +16 -0
- package/dist/panels/ChannelsPanel.js.map +1 -0
- package/dist/panels/DebugConsolePanel.d.ts +2 -0
- package/dist/panels/DebugConsolePanel.d.ts.map +1 -0
- package/dist/panels/DebugConsolePanel.js +32 -0
- package/dist/panels/DebugConsolePanel.js.map +1 -0
- package/dist/panels/DebugContextPanel.d.ts +2 -0
- package/dist/panels/DebugContextPanel.d.ts.map +1 -0
- package/dist/panels/DebugContextPanel.js +32 -0
- package/dist/panels/DebugContextPanel.js.map +1 -0
- package/dist/panels/DebugExternalIOPanel.d.ts +9 -0
- package/dist/panels/DebugExternalIOPanel.d.ts.map +1 -0
- package/dist/panels/DebugExternalIOPanel.js +66 -0
- package/dist/panels/DebugExternalIOPanel.js.map +1 -0
- package/dist/panels/DiagnosticsPanel.d.ts +8 -0
- package/dist/panels/DiagnosticsPanel.d.ts.map +1 -0
- package/dist/panels/DiagnosticsPanel.js +86 -0
- package/dist/panels/DiagnosticsPanel.js.map +1 -0
- package/dist/panels/EdgeConfigPanel.d.ts +14 -0
- package/dist/panels/EdgeConfigPanel.d.ts.map +1 -0
- package/dist/panels/EdgeConfigPanel.js +34 -0
- package/dist/panels/EdgeConfigPanel.js.map +1 -0
- package/dist/panels/FunctionConfigPanel.d.ts +16 -0
- package/dist/panels/FunctionConfigPanel.d.ts.map +1 -0
- package/dist/panels/FunctionConfigPanel.js +62 -0
- package/dist/panels/FunctionConfigPanel.js.map +1 -0
- package/dist/panels/FunctionListPanel.d.ts +14 -0
- package/dist/panels/FunctionListPanel.d.ts.map +1 -0
- package/dist/panels/FunctionListPanel.js +25 -0
- package/dist/panels/FunctionListPanel.js.map +1 -0
- package/dist/panels/MemoryConfigPanel.d.ts +8 -0
- package/dist/panels/MemoryConfigPanel.d.ts.map +1 -0
- package/dist/panels/MemoryConfigPanel.js +22 -0
- package/dist/panels/MemoryConfigPanel.js.map +1 -0
- package/dist/panels/MemoryPanel.d.ts +2 -0
- package/dist/panels/MemoryPanel.d.ts.map +1 -0
- package/dist/panels/MemoryPanel.js +25 -0
- package/dist/panels/MemoryPanel.js.map +1 -0
- package/dist/panels/ModelConfigPanel.d.ts +8 -0
- package/dist/panels/ModelConfigPanel.d.ts.map +1 -0
- package/dist/panels/ModelConfigPanel.js +14 -0
- package/dist/panels/ModelConfigPanel.js.map +1 -0
- package/dist/panels/ModelsPanel.d.ts +8 -0
- package/dist/panels/ModelsPanel.d.ts.map +1 -0
- package/dist/panels/ModelsPanel.js +24 -0
- package/dist/panels/ModelsPanel.js.map +1 -0
- package/dist/panels/NodeConfigPanel.d.ts +16 -0
- package/dist/panels/NodeConfigPanel.d.ts.map +1 -0
- package/dist/panels/NodeConfigPanel.js +248 -0
- package/dist/panels/NodeConfigPanel.js.map +1 -0
- package/dist/panels/NodeLibrary.d.ts +16 -0
- package/dist/panels/NodeLibrary.d.ts.map +1 -0
- package/dist/panels/NodeLibrary.js +125 -0
- package/dist/panels/NodeLibrary.js.map +1 -0
- package/dist/panels/ResourceConfigPanel.d.ts +37 -0
- package/dist/panels/ResourceConfigPanel.d.ts.map +1 -0
- package/dist/panels/ResourceConfigPanel.js +35 -0
- package/dist/panels/ResourceConfigPanel.js.map +1 -0
- package/dist/panels/ResourceListPanel.d.ts +35 -0
- package/dist/panels/ResourceListPanel.d.ts.map +1 -0
- package/dist/panels/ResourceListPanel.js +35 -0
- package/dist/panels/ResourceListPanel.js.map +1 -0
- package/dist/panels/VariableConfigPanel.d.ts +9 -0
- package/dist/panels/VariableConfigPanel.d.ts.map +1 -0
- package/dist/panels/VariableConfigPanel.js +50 -0
- package/dist/panels/VariableConfigPanel.js.map +1 -0
- package/dist/panels/VariablesPanel.d.ts +7 -0
- package/dist/panels/VariablesPanel.d.ts.map +1 -0
- package/dist/panels/VariablesPanel.js +56 -0
- package/dist/panels/VariablesPanel.js.map +1 -0
- package/dist/stores/canvasStore.d.ts +41 -0
- package/dist/stores/canvasStore.d.ts.map +1 -0
- package/dist/stores/canvasStore.js +187 -0
- package/dist/stores/canvasStore.js.map +1 -0
- package/dist/stores/debugStore.d.ts +42 -0
- package/dist/stores/debugStore.d.ts.map +1 -0
- package/dist/stores/debugStore.js +22 -0
- package/dist/stores/debugStore.js.map +1 -0
- package/dist/stores/diagnosticsStore.d.ts +41 -0
- package/dist/stores/diagnosticsStore.d.ts.map +1 -0
- package/dist/stores/diagnosticsStore.js +67 -0
- package/dist/stores/diagnosticsStore.js.map +1 -0
- package/dist/stores/editorStore.d.ts +76 -0
- package/dist/stores/editorStore.d.ts.map +1 -0
- package/dist/stores/editorStore.js +116 -0
- package/dist/stores/editorStore.js.map +1 -0
- package/dist/utils/categoryConstants.d.ts +4 -0
- package/dist/utils/categoryConstants.d.ts.map +1 -0
- package/dist/utils/categoryConstants.js +24 -0
- package/dist/utils/categoryConstants.js.map +1 -0
- package/dist/utils/channelOperations.d.ts +21 -0
- package/dist/utils/channelOperations.d.ts.map +1 -0
- package/dist/utils/channelOperations.js +84 -0
- package/dist/utils/channelOperations.js.map +1 -0
- package/dist/utils/connectionRules.d.ts +15 -0
- package/dist/utils/connectionRules.d.ts.map +1 -0
- package/dist/utils/connectionRules.js +113 -0
- package/dist/utils/connectionRules.js.map +1 -0
- package/dist/utils/functionOperations.d.ts +27 -0
- package/dist/utils/functionOperations.d.ts.map +1 -0
- package/dist/utils/functionOperations.js +140 -0
- package/dist/utils/functionOperations.js.map +1 -0
- package/dist/utils/graphOperations.d.ts +54 -0
- package/dist/utils/graphOperations.d.ts.map +1 -0
- package/dist/utils/graphOperations.js +461 -0
- package/dist/utils/graphOperations.js.map +1 -0
- package/dist/utils/history.d.ts +76 -0
- package/dist/utils/history.d.ts.map +1 -0
- package/dist/utils/history.js +93 -0
- package/dist/utils/history.js.map +1 -0
- package/dist/utils/memoryOperations.d.ts +14 -0
- package/dist/utils/memoryOperations.d.ts.map +1 -0
- package/dist/utils/memoryOperations.js +55 -0
- package/dist/utils/memoryOperations.js.map +1 -0
- package/dist/utils/migrateFunctionNodes.d.ts +9 -0
- package/dist/utils/migrateFunctionNodes.d.ts.map +1 -0
- package/dist/utils/migrateFunctionNodes.js +89 -0
- package/dist/utils/migrateFunctionNodes.js.map +1 -0
- package/dist/utils/modelOperations.d.ts +13 -0
- package/dist/utils/modelOperations.d.ts.map +1 -0
- package/dist/utils/modelOperations.js +53 -0
- package/dist/utils/modelOperations.js.map +1 -0
- package/dist/utils/paramDisplay.d.ts +12 -0
- package/dist/utils/paramDisplay.d.ts.map +1 -0
- package/dist/utils/paramDisplay.js +56 -0
- package/dist/utils/paramDisplay.js.map +1 -0
- package/dist/utils/resourceHelpers.d.ts +17 -0
- package/dist/utils/resourceHelpers.d.ts.map +1 -0
- package/dist/utils/resourceHelpers.js +32 -0
- package/dist/utils/resourceHelpers.js.map +1 -0
- package/dist/utils/translation.d.ts +20 -0
- package/dist/utils/translation.d.ts.map +1 -0
- package/dist/utils/translation.js +23 -0
- package/dist/utils/translation.js.map +1 -0
- package/dist/utils/variableOperations.d.ts +15 -0
- package/dist/utils/variableOperations.d.ts.map +1 -0
- package/dist/utils/variableOperations.js +71 -0
- package/dist/utils/variableOperations.js.map +1 -0
- package/package.json +79 -0
- package/src/BuilderLayout.tsx +345 -0
- package/src/Canvas.tsx +261 -0
- package/src/CanvasEditor.tsx +142 -0
- package/src/CanvasTabsToolbar.tsx +176 -0
- package/src/RightConfigPanel.tsx +266 -0
- package/src/WorkflowBuilder.tsx +412 -0
- package/src/cn.ts +6 -0
- package/src/components/ui/add-button.tsx +39 -0
- package/src/components/ui/alert-dialog.tsx +141 -0
- package/src/components/ui/alert.tsx +59 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/button.tsx +85 -0
- package/src/components/ui/card.tsx +79 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/collapsible.tsx +9 -0
- package/src/components/ui/command.tsx +153 -0
- package/src/components/ui/delete-button.tsx +23 -0
- package/src/components/ui/dialog.tsx +125 -0
- package/src/components/ui/dropdown-menu.tsx +198 -0
- package/src/components/ui/input.tsx +55 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/readonly-banner.tsx +15 -0
- package/src/components/ui/resizable.tsx +43 -0
- package/src/components/ui/scroll-area.tsx +102 -0
- package/src/components/ui/select.tsx +160 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/textarea.tsx +51 -0
- package/src/components/ui/toast.tsx +127 -0
- package/src/components/ui/toaster.tsx +33 -0
- package/src/components/ui/toggle-group.tsx +59 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/dialogs/NodePickerDialog.tsx +84 -0
- package/src/dialogs/ValidationDialog.tsx +184 -0
- package/src/graph/BaseNode.tsx +557 -0
- package/src/graph/CustomEdge.tsx +185 -0
- package/src/graph/CustomNode.tsx +16 -0
- package/src/graph/FunctionCallNode.tsx +30 -0
- package/src/graph/PortHandle.tsx +189 -0
- package/src/graph/reactFlowRegistry.ts +26 -0
- package/src/hooks/use-toast.ts +125 -0
- package/src/hooks/useAvailableVariables.ts +20 -0
- package/src/hooks/useCanvasHistory.ts +22 -0
- package/src/hooks/useCanvasTabs.ts +168 -0
- package/src/hooks/useFunctionDiagnosticsSync.ts +40 -0
- package/src/hooks/useFunctionRegistry.ts +26 -0
- package/src/hooks/useFunctions.ts +44 -0
- package/src/hooks/useGraph.ts +161 -0
- package/src/hooks/useNodeDefinitions.ts +82 -0
- package/src/hooks/useParamErrors.ts +26 -0
- package/src/hooks/useResolvedTheme.ts +30 -0
- package/src/hooks/useResourceDiagnosticsSync.ts +58 -0
- package/src/hooks/useSuppressThemeTransition.ts +79 -0
- package/src/hooks/useWorkflowSerialization.ts +127 -0
- package/src/i18n/index.ts +53 -0
- package/src/i18n/locales/de.json +501 -0
- package/src/i18n/locales/en.json +557 -0
- package/src/index.ts +27 -0
- package/src/inputs/ExpressionInput.tsx +297 -0
- package/src/inputs/ParameterEditor.tsx +515 -0
- package/src/inputs/PortSection.tsx +144 -0
- package/src/panels/BuilderSidebar.tsx +301 -0
- package/src/panels/ChannelConfigPanel.tsx +49 -0
- package/src/panels/ChannelsPanel.tsx +28 -0
- package/src/panels/DebugConsolePanel.tsx +73 -0
- package/src/panels/DebugContextPanel.tsx +77 -0
- package/src/panels/DebugExternalIOPanel.tsx +180 -0
- package/src/panels/DiagnosticsPanel.tsx +170 -0
- package/src/panels/EdgeConfigPanel.tsx +104 -0
- package/src/panels/FunctionConfigPanel.tsx +179 -0
- package/src/panels/FunctionListPanel.tsx +45 -0
- package/src/panels/MemoryConfigPanel.tsx +55 -0
- package/src/panels/MemoryPanel.tsx +40 -0
- package/src/panels/ModelConfigPanel.tsx +41 -0
- package/src/panels/ModelsPanel.tsx +36 -0
- package/src/panels/NodeConfigPanel.tsx +630 -0
- package/src/panels/NodeLibrary.tsx +288 -0
- package/src/panels/ResourceConfigPanel.tsx +132 -0
- package/src/panels/ResourceListPanel.tsx +113 -0
- package/src/panels/VariableConfigPanel.tsx +161 -0
- package/src/panels/VariablesPanel.tsx +145 -0
- package/src/stores/canvasStore.test.ts +44 -0
- package/src/stores/canvasStore.ts +245 -0
- package/src/stores/debugStore.ts +74 -0
- package/src/stores/diagnosticsStore.ts +130 -0
- package/src/stores/editorStore.ts +202 -0
- package/src/styles/index.css +526 -0
- package/src/utils/categoryConstants.ts +26 -0
- package/src/utils/channelOperations.ts +86 -0
- package/src/utils/connectionRules.ts +137 -0
- package/src/utils/functionOperations.ts +179 -0
- package/src/utils/graphOperations.ts +550 -0
- package/src/utils/history.ts +207 -0
- package/src/utils/memoryOperations.ts +57 -0
- package/src/utils/migrateFunctionNodes.ts +107 -0
- package/src/utils/modelOperations.ts +55 -0
- package/src/utils/paramDisplay.ts +71 -0
- package/src/utils/resourceHelpers.ts +32 -0
- package/src/utils/translation.ts +28 -0
- package/src/utils/variableOperations.ts +75 -0
- package/tailwind-preset.ts +166 -0
package/src/Canvas.tsx
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyEdgeChanges,
|
|
3
|
+
applyNodeChanges,
|
|
4
|
+
Background,
|
|
5
|
+
BackgroundVariant,
|
|
6
|
+
Connection,
|
|
7
|
+
Controls,
|
|
8
|
+
EdgeChange,
|
|
9
|
+
MiniMap,
|
|
10
|
+
Node,
|
|
11
|
+
NodeChange,
|
|
12
|
+
OnSelectionChangeFunc,
|
|
13
|
+
ReactFlow,
|
|
14
|
+
ReactFlowProvider,
|
|
15
|
+
SelectionMode,
|
|
16
|
+
useNodesInitialized,
|
|
17
|
+
useReactFlow,
|
|
18
|
+
} from "@xyflow/react";
|
|
19
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
20
|
+
import { useResolvedTheme } from "./hooks/useResolvedTheme";
|
|
21
|
+
|
|
22
|
+
import { NodeCategory, NodeDefinition, NodeData } from "@foresthubai/workflow-core/node";
|
|
23
|
+
import { isValidConnection as validateConnection } from "./utils/connectionRules";
|
|
24
|
+
import { getOrCreateCanvasStore } from "./stores/canvasStore";
|
|
25
|
+
import { useEditorStore } from "./stores/editorStore";
|
|
26
|
+
import { nodeTypes, edgeTypes } from "./graph/reactFlowRegistry";
|
|
27
|
+
import { isReadOnly } from "./WorkflowBuilder";
|
|
28
|
+
|
|
29
|
+
interface CanvasProps {
|
|
30
|
+
canvasId: string;
|
|
31
|
+
onConnect: (connection: Connection) => void;
|
|
32
|
+
onSelectionChange: OnSelectionChangeFunc;
|
|
33
|
+
onSelectionStart: () => void;
|
|
34
|
+
onSelectionStop: () => void;
|
|
35
|
+
onPaneClick: (event: React.MouseEvent) => void;
|
|
36
|
+
onAddNode: (nodeType: NodeDefinition, position?: { x: number; y: number }) => void;
|
|
37
|
+
onNodeDragStart: (event: React.MouseEvent, node: Node<NodeData>) => void;
|
|
38
|
+
viewportCenterRef: React.MutableRefObject<(() => { x: number; y: number }) | null>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Inner component that uses useReactFlow - must be inside ReactFlowProvider
|
|
42
|
+
const CanvasArea = ({
|
|
43
|
+
canvasId,
|
|
44
|
+
onConnect,
|
|
45
|
+
onSelectionChange,
|
|
46
|
+
onSelectionStart,
|
|
47
|
+
onSelectionStop,
|
|
48
|
+
onPaneClick,
|
|
49
|
+
onAddNode,
|
|
50
|
+
onNodeDragStart,
|
|
51
|
+
viewportCenterRef,
|
|
52
|
+
}: CanvasProps) => {
|
|
53
|
+
const readOnly = useEditorStore((s) => isReadOnly(s.builderMode));
|
|
54
|
+
const resolvedTheme = useResolvedTheme();
|
|
55
|
+
const { screenToFlowPosition, getViewport, fitView } = useReactFlow();
|
|
56
|
+
const nodesInitialized = useNodesInitialized();
|
|
57
|
+
|
|
58
|
+
// Expose viewport center calculation to parent via ref so new nodes can be dropped there.
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
viewportCenterRef.current = () => {
|
|
61
|
+
const container = document.querySelector(".react-flow");
|
|
62
|
+
if (!container) return { x: 250, y: 100 };
|
|
63
|
+
const { width, height } = container.getBoundingClientRect();
|
|
64
|
+
const { x, y, zoom } = getViewport();
|
|
65
|
+
// Offset by approximate half-node size so the node appears centered, not top-left aligned
|
|
66
|
+
return {
|
|
67
|
+
x: (-x + width / 2) / zoom - 90,
|
|
68
|
+
y: (-y + height / 2) / zoom - 50,
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}, [getViewport, viewportCenterRef]);
|
|
72
|
+
|
|
73
|
+
// Get the independent store for this canvas - direct top-level access
|
|
74
|
+
const useStore = getOrCreateCanvasStore(canvasId);
|
|
75
|
+
const nodes = useStore((s) => s.nodes);
|
|
76
|
+
const edges = useStore((s) => s.edges);
|
|
77
|
+
const setNodes = useStore((s) => s.setNodes);
|
|
78
|
+
const setEdges = useStore((s) => s.setEdges);
|
|
79
|
+
const setViewport = useStore((s) => s.setViewport);
|
|
80
|
+
|
|
81
|
+
// This component remounts per canvas (key={canvasId} in BuilderLayout), so ReactFlow
|
|
82
|
+
// starts cold on every tab switch. Read the stored viewport ONCE at mount, non-reactively
|
|
83
|
+
// (a reactive read would re-render on every pan). Present → restore via defaultViewport so
|
|
84
|
+
// the FIRST painted frame is already correct. Absent (first visit) → fit once nodes are
|
|
85
|
+
// measured (effect below).
|
|
86
|
+
const initialViewport = useRef(useStore.getState().viewport).current;
|
|
87
|
+
|
|
88
|
+
// A first visit has nothing to restore, so the fit must run post-mount and would otherwise
|
|
89
|
+
// paint the default {0,0,1} frame first and jump to the fit on the next frame. Keep the
|
|
90
|
+
// canvas hidden until that fit lands, then reveal the already-correct frame. A restored
|
|
91
|
+
// viewport is right on frame 1, so it starts visible — only the first-visit fit is gated.
|
|
92
|
+
const [ready, setReady] = useState(initialViewport != null);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (ready || initialViewport != null) return;
|
|
96
|
+
// An empty canvas has nothing to fit — and useNodesInitialized stays false forever with
|
|
97
|
+
// zero nodes — so reveal at the default viewport instead of staying hidden (which would
|
|
98
|
+
// blank the canvas: no background, can't drop nodes in).
|
|
99
|
+
if (nodes.length === 0) {
|
|
100
|
+
setReady(true);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!nodesInitialized) return;
|
|
104
|
+
// fitView updates ReactFlow's viewport, but the transform paints ONE FRAME LATER than this
|
|
105
|
+
// call (measured). Revealing now would show one frame at the identity viewport before the
|
|
106
|
+
// fit lands — the twitch. So fit now, then reveal on the next frame, once the transform has
|
|
107
|
+
// painted. Seed the store so re-entering this canvas restores the view instead of refitting.
|
|
108
|
+
fitView({ padding: 0.15, maxZoom: 1 });
|
|
109
|
+
const raf = requestAnimationFrame(() => {
|
|
110
|
+
setViewport(getViewport());
|
|
111
|
+
setReady(true);
|
|
112
|
+
});
|
|
113
|
+
return () => cancelAnimationFrame(raf);
|
|
114
|
+
}, [ready, initialViewport, nodes.length, nodesInitialized, fitView, getViewport, setViewport]);
|
|
115
|
+
|
|
116
|
+
// Function to determine node color for MiniMap (uses ReactFlow node types, not domain NodeType)
|
|
117
|
+
const nodeColor = (node: Node) => {
|
|
118
|
+
switch (node.type) {
|
|
119
|
+
case NodeCategory.Trigger:
|
|
120
|
+
return "hsl(var(--node-trigger))";
|
|
121
|
+
case NodeCategory.Tool:
|
|
122
|
+
return "hsl(var(--node-tool))";
|
|
123
|
+
case NodeCategory.AI:
|
|
124
|
+
return "hsl(var(--node-agent))";
|
|
125
|
+
default:
|
|
126
|
+
return "hsl(var(--muted))";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// ReactFlow change handlers - apply changes directly to store
|
|
131
|
+
const onNodesChange = useCallback(
|
|
132
|
+
(changes: NodeChange<Node<NodeData>>[]) => {
|
|
133
|
+
setNodes((nds) => applyNodeChanges(changes, nds));
|
|
134
|
+
},
|
|
135
|
+
[setNodes],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const onEdgesChange = useCallback(
|
|
139
|
+
(changes: EdgeChange[]) => {
|
|
140
|
+
setEdges((eds) => applyEdgeChanges(changes, eds) as typeof eds);
|
|
141
|
+
},
|
|
142
|
+
[setEdges],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const handleDrop = useCallback(
|
|
146
|
+
(event: React.DragEvent) => {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
|
|
149
|
+
if (!onAddNode || readOnly) return;
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const dragData = JSON.parse(event.dataTransfer.getData("application/json"));
|
|
153
|
+
// Convert screen coordinates to flow coordinates (accounting for pan/zoom)
|
|
154
|
+
const position = screenToFlowPosition({
|
|
155
|
+
x: event.clientX,
|
|
156
|
+
y: event.clientY,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
onAddNode(dragData.nodeDef, position);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error("Failed to parse node data:", error);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
[onAddNode, screenToFlowPosition, readOnly],
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const handleDragOver = (event: React.DragEvent) => {
|
|
168
|
+
if (readOnly) return;
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
event.dataTransfer.dropEffect = "copy";
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// Prevent browser middle-click auto-scroll which causes viewport jumps
|
|
174
|
+
const handleMouseDownCapture = (e: React.MouseEvent) => {
|
|
175
|
+
if (e.button === 1) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const handleAuxClick = (e: React.MouseEvent) => {
|
|
181
|
+
if (e.button === 1) {
|
|
182
|
+
e.preventDefault();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
// Gate the first-visit fit with opacity, NOT visibility/display:
|
|
188
|
+
// - visibility:hidden is overridden by ReactFlow, which sets visibility:visible on each
|
|
189
|
+
// measured node, so the nodes stay on screen and you still see the fit jump.
|
|
190
|
+
// - display:none removes layout boxes, so nodes never measure and the fit can't compute.
|
|
191
|
+
// opacity applies to the whole subtree as a group (children can't override it) yet keeps
|
|
192
|
+
// layout intact, so measurement/fitView work while it's invisible.
|
|
193
|
+
<div className="w-full h-full" style={{ opacity: ready ? 1 : 0 }}>
|
|
194
|
+
<ReactFlow
|
|
195
|
+
nodes={nodes}
|
|
196
|
+
edges={edges}
|
|
197
|
+
onNodesChange={onNodesChange}
|
|
198
|
+
onEdgesChange={onEdgesChange}
|
|
199
|
+
onConnect={onConnect}
|
|
200
|
+
isValidConnection={(c) =>
|
|
201
|
+
!!validateConnection(c.source, c.target, c.sourceHandle, c.targetHandle, nodes, edges)
|
|
202
|
+
}
|
|
203
|
+
onPaneClick={onPaneClick}
|
|
204
|
+
onNodeDragStart={onNodeDragStart}
|
|
205
|
+
onSelectionChange={onSelectionChange}
|
|
206
|
+
onSelectionStart={onSelectionStart}
|
|
207
|
+
onSelectionEnd={onSelectionStop}
|
|
208
|
+
onMoveEnd={(_, vp) => setViewport(vp)}
|
|
209
|
+
nodeTypes={nodeTypes}
|
|
210
|
+
edgeTypes={edgeTypes}
|
|
211
|
+
defaultViewport={initialViewport ?? undefined}
|
|
212
|
+
selectionOnDrag={!readOnly}
|
|
213
|
+
panOnDrag={[1, 2]}
|
|
214
|
+
selectionMode={SelectionMode.Partial}
|
|
215
|
+
selectNodesOnDrag={false}
|
|
216
|
+
nodesConnectable={!readOnly}
|
|
217
|
+
nodesDraggable={!readOnly}
|
|
218
|
+
zoomOnScroll={true}
|
|
219
|
+
zoomOnPinch={true}
|
|
220
|
+
onDrop={handleDrop}
|
|
221
|
+
onDragOver={handleDragOver}
|
|
222
|
+
deleteKeyCode={null} // Disable delete controlled by react flow itself
|
|
223
|
+
onContextMenu={(e) => e.preventDefault()}
|
|
224
|
+
onMouseDownCapture={handleMouseDownCapture}
|
|
225
|
+
onAuxClick={handleAuxClick}
|
|
226
|
+
colorMode={resolvedTheme}
|
|
227
|
+
style={{ "--xy-background-color": "hsl(var(--canvas-background))" } as React.CSSProperties}
|
|
228
|
+
>
|
|
229
|
+
<Background
|
|
230
|
+
variant={BackgroundVariant.Dots}
|
|
231
|
+
color="hsl(var(--muted-foreground))"
|
|
232
|
+
gap={24}
|
|
233
|
+
size={1.5}
|
|
234
|
+
className="opacity-40"
|
|
235
|
+
/>
|
|
236
|
+
<Controls className="glass-forest-panel !border !shadow-lg [&_button]:glass-forest-button [&_button]:!text-foreground hover:[&_button]:!scale-105" />
|
|
237
|
+
<MiniMap
|
|
238
|
+
nodeColor={nodeColor}
|
|
239
|
+
className="glass-forest-panel !border !shadow-lg"
|
|
240
|
+
maskColor="hsl(var(--primary) / 0.15)"
|
|
241
|
+
nodeBorderRadius={12}
|
|
242
|
+
nodeStrokeWidth={2}
|
|
243
|
+
style={{ width: 120, height: 80 }}
|
|
244
|
+
/>
|
|
245
|
+
</ReactFlow>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// Wrapper component that provides ReactFlowProvider context
|
|
251
|
+
const Canvas = (props: CanvasProps) => {
|
|
252
|
+
return (
|
|
253
|
+
<div className="w-full h-full overflow-hidden overscroll-contain">
|
|
254
|
+
<ReactFlowProvider>
|
|
255
|
+
<CanvasArea {...props} />
|
|
256
|
+
</ReactFlowProvider>
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export default Canvas;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import type { Connection, Node, OnSelectionChangeFunc } from "@xyflow/react";
|
|
4
|
+
import type { NodeDefinition, NodeData } from "@foresthubai/workflow-core/node";
|
|
5
|
+
import { getPorts } from "@foresthubai/workflow-core/node";
|
|
6
|
+
import { getCompatibleNodeDefs } from "./utils/connectionRules";
|
|
7
|
+
|
|
8
|
+
import Canvas from "./Canvas";
|
|
9
|
+
import { NodePickerDialog } from "./dialogs/NodePickerDialog";
|
|
10
|
+
import { getOrCreateCanvasStore, MAIN_CANVAS_ID } from "./stores/canvasStore";
|
|
11
|
+
import type { PortActionDetail } from "./graph/PortHandle";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The per-canvas editing surface. Wraps {@link Canvas} (the ReactFlow
|
|
15
|
+
* primitive) with the popup state and viewport-center machinery that has
|
|
16
|
+
* to remount when the user switches canvases.
|
|
17
|
+
*
|
|
18
|
+
* Mounted with `key={canvasId}` by {@link BuilderLayout} — when the active
|
|
19
|
+
* canvas changes, this component fully remounts so port-popup, selection-
|
|
20
|
+
* drag, and the viewport-center ref all reset cleanly without imperative
|
|
21
|
+
* teardown.
|
|
22
|
+
*
|
|
23
|
+
* Graph mutations, history, and keyboard handling live one level up in
|
|
24
|
+
* BuilderLayout so they can drive the sidebar and right panel siblings.
|
|
25
|
+
*/
|
|
26
|
+
export interface CanvasEditorProps {
|
|
27
|
+
canvasId: string;
|
|
28
|
+
|
|
29
|
+
/** Populated by Canvas/ReactFlow on mount; read by sidebar's click-to-add. */
|
|
30
|
+
viewportCenterRef: MutableRefObject<(() => { x: number; y: number }) | null>;
|
|
31
|
+
|
|
32
|
+
/** Node-palette registry for the contextual port-plus picker. */
|
|
33
|
+
nodeDefinitions: NodeDefinition[];
|
|
34
|
+
|
|
35
|
+
// Event handlers wired by BuilderLayout
|
|
36
|
+
onConnect: (connection: Connection) => void;
|
|
37
|
+
onAddNode: (nodeDef: NodeDefinition, position?: { x: number; y: number }) => string | null | undefined;
|
|
38
|
+
onAddNodeAndConnect: (
|
|
39
|
+
nodeDef: NodeDefinition,
|
|
40
|
+
position: { x: number; y: number },
|
|
41
|
+
connection: { source: string; sourceHandle: string; target: string; targetHandle: string },
|
|
42
|
+
) => string | null | undefined;
|
|
43
|
+
onSelectionChange: OnSelectionChangeFunc;
|
|
44
|
+
onPaneClick: () => void;
|
|
45
|
+
onNodeDragStart: (event: React.MouseEvent, node: Node<NodeData>) => void;
|
|
46
|
+
|
|
47
|
+
// Selection-drag flag (lifted to BuilderLayout so the right panel can read it)
|
|
48
|
+
setSelectionDrag: Dispatch<SetStateAction<boolean>>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const CanvasEditor = ({
|
|
52
|
+
canvasId,
|
|
53
|
+
viewportCenterRef,
|
|
54
|
+
nodeDefinitions,
|
|
55
|
+
onConnect,
|
|
56
|
+
onAddNode,
|
|
57
|
+
onAddNodeAndConnect,
|
|
58
|
+
onSelectionChange,
|
|
59
|
+
onPaneClick,
|
|
60
|
+
onNodeDragStart,
|
|
61
|
+
setSelectionDrag,
|
|
62
|
+
}: CanvasEditorProps) => {
|
|
63
|
+
const isFunctionCanvas = canvasId !== MAIN_CANVAS_ID;
|
|
64
|
+
|
|
65
|
+
// Contextual node picker ("+" on output ports). PortHandle lives deep
|
|
66
|
+
// inside ReactFlow's render tree, so it dispatches a bubbling CustomEvent
|
|
67
|
+
// that we catch on this container — no prop drilling through RF needed.
|
|
68
|
+
const [portAction, setPortAction] = useState<PortActionDetail | null>(null);
|
|
69
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const el = containerRef.current;
|
|
72
|
+
if (!el) return;
|
|
73
|
+
const handler = (e: Event) => setPortAction((e as CustomEvent<PortActionDetail>).detail);
|
|
74
|
+
el.addEventListener("port-plus-click", handler);
|
|
75
|
+
return () => el.removeEventListener("port-plus-click", handler);
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const compatibleDefs = useMemo(() => {
|
|
79
|
+
if (!portAction) return [];
|
|
80
|
+
const { nodes, edges } = getOrCreateCanvasStore(canvasId).getState();
|
|
81
|
+
return getCompatibleNodeDefs(
|
|
82
|
+
portAction.nodeId,
|
|
83
|
+
portAction.handleId,
|
|
84
|
+
nodes,
|
|
85
|
+
edges,
|
|
86
|
+
nodeDefinitions,
|
|
87
|
+
isFunctionCanvas,
|
|
88
|
+
);
|
|
89
|
+
}, [portAction, canvasId, nodeDefinitions, isFunctionCanvas]);
|
|
90
|
+
|
|
91
|
+
const handleAddAndConnect = useCallback(
|
|
92
|
+
(nodeDef: NodeDefinition) => {
|
|
93
|
+
if (!portAction) return;
|
|
94
|
+
const { nodes: currentNodes } = getOrCreateCanvasStore(canvasId).getState();
|
|
95
|
+
const originNode = currentNodes.find((n) => n.id === portAction.nodeId);
|
|
96
|
+
if (!originNode) return;
|
|
97
|
+
const originPos = originNode.position;
|
|
98
|
+
const position =
|
|
99
|
+
portAction.portType === "tool"
|
|
100
|
+
? { x: originPos.x, y: originPos.y + 200 }
|
|
101
|
+
: { x: originPos.x + 280, y: originPos.y };
|
|
102
|
+
const newNodePorts = getPorts({ type: nodeDef.type } as NodeData);
|
|
103
|
+
const targetPort = newNodePorts.input.find((p) => p.type === portAction.portType);
|
|
104
|
+
if (!targetPort) return;
|
|
105
|
+
onAddNodeAndConnect(nodeDef, position, {
|
|
106
|
+
source: portAction.nodeId,
|
|
107
|
+
sourceHandle: portAction.handleId,
|
|
108
|
+
target: "",
|
|
109
|
+
targetHandle: targetPort.id,
|
|
110
|
+
});
|
|
111
|
+
setPortAction(null);
|
|
112
|
+
},
|
|
113
|
+
[portAction, canvasId, onAddNodeAndConnect],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div ref={containerRef} className="h-full flex flex-col">
|
|
118
|
+
<div className="flex-1 relative">
|
|
119
|
+
<Canvas
|
|
120
|
+
canvasId={canvasId}
|
|
121
|
+
onConnect={onConnect}
|
|
122
|
+
onSelectionChange={onSelectionChange}
|
|
123
|
+
onSelectionStart={() => setSelectionDrag(true)}
|
|
124
|
+
onSelectionStop={() => setSelectionDrag(false)}
|
|
125
|
+
onPaneClick={onPaneClick}
|
|
126
|
+
onAddNode={onAddNode}
|
|
127
|
+
onNodeDragStart={onNodeDragStart}
|
|
128
|
+
viewportCenterRef={viewportCenterRef}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<NodePickerDialog
|
|
133
|
+
open={portAction !== null}
|
|
134
|
+
onOpenChange={(open) => {
|
|
135
|
+
if (!open) setPortAction(null);
|
|
136
|
+
}}
|
|
137
|
+
compatibleDefs={compatibleDefs}
|
|
138
|
+
onSelect={handleAddAndConnect}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { ScrollArea } from "./components/ui/scroll-area";
|
|
2
|
+
import { cn } from "./cn";
|
|
3
|
+
import { FunctionSquare, Workflow, X } from "lucide-react";
|
|
4
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { CanvasTab } from "./hooks/useCanvasTabs";
|
|
6
|
+
import { MAIN_CANVAS_ID } from "./stores/canvasStore";
|
|
7
|
+
|
|
8
|
+
interface CanvasTabsToolbarProps {
|
|
9
|
+
tabs: CanvasTab[];
|
|
10
|
+
activeTabId: string;
|
|
11
|
+
onTabChange: (tabId: string) => void;
|
|
12
|
+
onTabClose: (tabId: string) => void;
|
|
13
|
+
onTabReorder: (fromIndex: number, toIndex: number) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CanvasTabsToolbar = ({
|
|
17
|
+
tabs,
|
|
18
|
+
activeTabId,
|
|
19
|
+
onTabChange,
|
|
20
|
+
onTabClose,
|
|
21
|
+
onTabReorder,
|
|
22
|
+
}: CanvasTabsToolbarProps) => {
|
|
23
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
24
|
+
const viewportRef = useRef<HTMLDivElement>(null);
|
|
25
|
+
const dragIndex = useRef<number | null>(null);
|
|
26
|
+
|
|
27
|
+
// Translate vertical mouse-wheel deltas into horizontal scroll on the tabs
|
|
28
|
+
// viewport. A non-passive native listener is required because React's
|
|
29
|
+
// synthetic onWheel is passive — preventDefault() there is a no-op, so the
|
|
30
|
+
// page would also scroll vertically alongside the toolbar shift. We leave
|
|
31
|
+
// genuine horizontal wheels (touchpads, tilt wheels) alone by gating on
|
|
32
|
+
// deltaY, and skip the override entirely when there's nothing to scroll
|
|
33
|
+
// so vertical-page scrolling still works when the pointer happens to
|
|
34
|
+
// hover an unfilled toolbar.
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const el = viewportRef.current;
|
|
37
|
+
if (!el) return;
|
|
38
|
+
const handler = (e: WheelEvent) => {
|
|
39
|
+
if (e.deltaY === 0) return;
|
|
40
|
+
if (el.scrollWidth <= el.clientWidth) return;
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
el.scrollLeft += e.deltaY;
|
|
43
|
+
};
|
|
44
|
+
el.addEventListener("wheel", handler, { passive: false });
|
|
45
|
+
return () => el.removeEventListener("wheel", handler);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
// dropSlot: insertion index (before which tab the dragged tab lands)
|
|
49
|
+
const [dropSlot, setDropSlot] = useState<number | null>(null);
|
|
50
|
+
// indicatorX: pixel offset from container left for the visual line
|
|
51
|
+
const [indicatorX, setIndicatorX] = useState<number | null>(null);
|
|
52
|
+
|
|
53
|
+
const isMainTab = (index: number) => tabs[index]?.id === MAIN_CANVAS_ID;
|
|
54
|
+
|
|
55
|
+
const clearDrag = useCallback(() => {
|
|
56
|
+
dragIndex.current = null;
|
|
57
|
+
setDropSlot(null);
|
|
58
|
+
setIndicatorX(null);
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
const handleTabDragOver = useCallback(
|
|
62
|
+
(e: React.DragEvent<HTMLDivElement>, index: number) => {
|
|
63
|
+
if (dragIndex.current === null || !containerRef.current) return;
|
|
64
|
+
// Ignore Main tab entirely — not a valid drag target
|
|
65
|
+
if (tabs[index]?.id === MAIN_CANVAS_ID) return;
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
e.dataTransfer.dropEffect = "move";
|
|
69
|
+
|
|
70
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
71
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
72
|
+
const midX = rect.left + rect.width / 2;
|
|
73
|
+
const isLeftHalf = e.clientX < midX;
|
|
74
|
+
|
|
75
|
+
// Slot: insertion index
|
|
76
|
+
const slot = isLeftHalf ? index : index + 1;
|
|
77
|
+
// Tabs are now flush with a 1px separator between them — land the indicator on that seam.
|
|
78
|
+
const raw = isLeftHalf ? rect.left - containerRect.left : rect.right - containerRect.left;
|
|
79
|
+
// Clamp so the indicator stays fully visible inside the container
|
|
80
|
+
const x = Math.round(Math.max(0, Math.min(raw, containerRef.current.clientWidth - 2)));
|
|
81
|
+
|
|
82
|
+
setDropSlot(slot);
|
|
83
|
+
setIndicatorX(x);
|
|
84
|
+
},
|
|
85
|
+
[tabs],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
// ScrollArea provides the horizontal overlay scrollbar (hover-only, in the
|
|
90
|
+
// panel gutter so the tab row doesn't shift). The Root carries the bg +
|
|
91
|
+
// bottom border; the inner div inside the Viewport stays the drag/drop
|
|
92
|
+
// container — containerRef points at it so the indicator's coordinates
|
|
93
|
+
// remain relative to the (scrollable) tab row, not the fixed Root.
|
|
94
|
+
<ScrollArea className="bg-card/80 border-b border-border/50" viewportRef={viewportRef}>
|
|
95
|
+
<div
|
|
96
|
+
ref={containerRef}
|
|
97
|
+
className="relative flex items-stretch"
|
|
98
|
+
onDragOver={(e) => {
|
|
99
|
+
// Fallback for empty area past last tab
|
|
100
|
+
if (dragIndex.current === null || !containerRef.current) return;
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
e.dataTransfer.dropEffect = "move";
|
|
103
|
+
}}
|
|
104
|
+
onDrop={(e) => {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
if (dragIndex.current !== null && dropSlot !== null) {
|
|
107
|
+
const from = dragIndex.current;
|
|
108
|
+
const target = dropSlot > from ? dropSlot - 1 : dropSlot;
|
|
109
|
+
if (target > 0 && target !== from) {
|
|
110
|
+
onTabReorder(from, target);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
clearDrag();
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{/* Absolute drop indicator — no layout shift */}
|
|
117
|
+
{indicatorX !== null && (
|
|
118
|
+
<div
|
|
119
|
+
className="absolute top-0 bottom-0 bg-primary z-10 pointer-events-none"
|
|
120
|
+
style={{ left: 0, width: "2px", transform: `translateX(${indicatorX}px)` }}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
{tabs.map((tab, index) => {
|
|
125
|
+
const isDraggable = !isMainTab(index);
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<React.Fragment key={tab.id}>
|
|
129
|
+
{index > 0 && <div className="w-px bg-border/70 shrink-0" />}
|
|
130
|
+
<div
|
|
131
|
+
draggable={isDraggable}
|
|
132
|
+
onDragStart={(e) => {
|
|
133
|
+
if (!isDraggable) return;
|
|
134
|
+
dragIndex.current = index;
|
|
135
|
+
e.dataTransfer.effectAllowed = "move";
|
|
136
|
+
}}
|
|
137
|
+
onDragOver={(e) => handleTabDragOver(e, index)}
|
|
138
|
+
onDragEnd={clearDrag}
|
|
139
|
+
className={cn(
|
|
140
|
+
"group flex items-center gap-1.5 pl-2 pr-1 text-sm font-medium cursor-pointer transition-colors",
|
|
141
|
+
"hover:bg-field/80",
|
|
142
|
+
activeTabId === tab.id ? "bg-field text-foreground" : "text-muted-foreground hover:text-foreground",
|
|
143
|
+
isDraggable ? "cursor-grab active:cursor-grabbing" : "select-none",
|
|
144
|
+
)}
|
|
145
|
+
onClick={() => onTabChange(tab.id)}
|
|
146
|
+
>
|
|
147
|
+
{isMainTab(index) ? (
|
|
148
|
+
<Workflow className="w-3.5 h-3.5 shrink-0" />
|
|
149
|
+
) : (
|
|
150
|
+
<FunctionSquare className="w-3.5 h-3.5 shrink-0" />
|
|
151
|
+
)}
|
|
152
|
+
<span className="truncate max-w-[120px] py-1">{tab.label}</span>
|
|
153
|
+
{tab.id !== MAIN_CANVAS_ID ? (
|
|
154
|
+
<button
|
|
155
|
+
type="button"
|
|
156
|
+
aria-label={`Close tab ${tab.label}`}
|
|
157
|
+
title={`Close tab ${tab.label}`}
|
|
158
|
+
className="flex items-center justify-center w-4 h-4 shrink-0 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-destructive/15 hover:text-destructive"
|
|
159
|
+
onClick={(e) => {
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
onTabClose(tab.id);
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
<X className="w-3.5 h-3.5" />
|
|
165
|
+
</button>
|
|
166
|
+
) : (
|
|
167
|
+
<span className="w-1 shrink-0" />
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
170
|
+
</React.Fragment>
|
|
171
|
+
);
|
|
172
|
+
})}
|
|
173
|
+
</div>
|
|
174
|
+
</ScrollArea>
|
|
175
|
+
);
|
|
176
|
+
};
|