@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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { Button } from "../components/ui/button";
|
|
4
|
+
import { Input } from "../components/ui/input";
|
|
5
|
+
import { Separator } from "../components/ui/separator";
|
|
6
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../components/ui/select";
|
|
7
|
+
import { ChevronRight } from "lucide-react";
|
|
8
|
+
import type { DeclaredVariable } from "@foresthubai/workflow-core/variable";
|
|
9
|
+
import type { DataType } from "@foresthubai/workflow-core";
|
|
10
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
11
|
+
import { isReadOnly } from "../WorkflowBuilder";
|
|
12
|
+
import { ReadOnlyBanner } from "../components/ui/readonly-banner";
|
|
13
|
+
import { DeleteButton } from "../components/ui/delete-button";
|
|
14
|
+
import { deleteDeclaredVariable, setDeclaredVariableType, updateDeclaredVariable } from "../utils/variableOperations";
|
|
15
|
+
|
|
16
|
+
interface VariableConfigPanelProps {
|
|
17
|
+
canvasId: string;
|
|
18
|
+
variable: DeclaredVariable;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DATA_TYPES: DataType[] = ["int", "float", "bool", "string"];
|
|
23
|
+
|
|
24
|
+
export const VariableConfigPanel = ({ canvasId, variable, onClose }: VariableConfigPanelProps) => {
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
const readOnly = useEditorStore((s) => isReadOnly(s.builderMode));
|
|
27
|
+
|
|
28
|
+
// Local name state mirrors the other config panels — preserves cursor position
|
|
29
|
+
// while typing and resets when a different variable is opened.
|
|
30
|
+
const [localName, setLocalName] = useState(variable.name);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setLocalName(variable.name);
|
|
33
|
+
}, [variable.uid, variable.name]);
|
|
34
|
+
|
|
35
|
+
const isEmptyName = variable.name.trim() === "";
|
|
36
|
+
|
|
37
|
+
// The initial-value widget is chosen by dataType: declared variables store
|
|
38
|
+
// `initialValue?: unknown` and the type is enforced here at the input layer,
|
|
39
|
+
// not in the data model (untyped DOM input + JSON round-trip would defeat a
|
|
40
|
+
// discriminated union). Switching dataType clears the value.
|
|
41
|
+
const renderInitialValueInput = () => {
|
|
42
|
+
switch (variable.dataType) {
|
|
43
|
+
case "bool":
|
|
44
|
+
return (
|
|
45
|
+
<Select
|
|
46
|
+
value={variable.initialValue != null ? String(variable.initialValue) : "false"}
|
|
47
|
+
onValueChange={(v) => updateDeclaredVariable(canvasId, variable.uid, { initialValue: v === "true" })}
|
|
48
|
+
>
|
|
49
|
+
<SelectTrigger className="h-8 text-sm">
|
|
50
|
+
<SelectValue />
|
|
51
|
+
</SelectTrigger>
|
|
52
|
+
<SelectContent>
|
|
53
|
+
<SelectItem value="false">false</SelectItem>
|
|
54
|
+
<SelectItem value="true">true</SelectItem>
|
|
55
|
+
</SelectContent>
|
|
56
|
+
</Select>
|
|
57
|
+
);
|
|
58
|
+
case "string":
|
|
59
|
+
return (
|
|
60
|
+
<Input
|
|
61
|
+
className="h-8 text-sm"
|
|
62
|
+
value={(variable.initialValue as string) ?? ""}
|
|
63
|
+
onChange={(e) => updateDeclaredVariable(canvasId, variable.uid, { initialValue: e.target.value })}
|
|
64
|
+
placeholder='""'
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
case "int":
|
|
68
|
+
case "float":
|
|
69
|
+
return (
|
|
70
|
+
<Input
|
|
71
|
+
type="number"
|
|
72
|
+
step={variable.dataType === "float" ? "any" : 1}
|
|
73
|
+
className="h-8 text-sm"
|
|
74
|
+
value={variable.initialValue != null ? Number(variable.initialValue) : ""}
|
|
75
|
+
onChange={(e) => {
|
|
76
|
+
const num = variable.dataType === "float" ? parseFloat(e.target.value) : parseInt(e.target.value, 10);
|
|
77
|
+
updateDeclaredVariable(canvasId, variable.uid, { initialValue: isNaN(num) ? undefined : num });
|
|
78
|
+
}}
|
|
79
|
+
placeholder="0"
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
default:
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="p-4">
|
|
89
|
+
<div className="space-y-4">
|
|
90
|
+
<div className="flex items-center justify-between gap-2">
|
|
91
|
+
<div className="flex-1 min-w-0">
|
|
92
|
+
<div className="group flex items-center gap-1.5 rounded-md border border-transparent px-1.5 -mx-1.5 hover:border-input focus-within:border-input transition-colors">
|
|
93
|
+
<input
|
|
94
|
+
type="text"
|
|
95
|
+
title={t("variableName", "Variable name")}
|
|
96
|
+
className="font-semibold text-lg font-mono bg-transparent w-full outline-none cursor-text py-0.5"
|
|
97
|
+
value={localName}
|
|
98
|
+
readOnly={readOnly}
|
|
99
|
+
onChange={(e) => {
|
|
100
|
+
setLocalName(e.target.value);
|
|
101
|
+
updateDeclaredVariable(canvasId, variable.uid, { name: e.target.value });
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
<p className="text-sm text-muted-foreground">
|
|
106
|
+
{t("variableDescription", "A declared variable you can read and write across this canvas")}
|
|
107
|
+
</p>
|
|
108
|
+
{isEmptyName && (
|
|
109
|
+
<p className="text-xs text-destructive mt-1">{t("variableNameRequired", "Name is required")}</p>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
<Button variant="ghost" size="icon" className="shrink-0" onClick={onClose}>
|
|
113
|
+
<ChevronRight className="h-4 w-4" />
|
|
114
|
+
</Button>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
{readOnly && <ReadOnlyBanner />}
|
|
118
|
+
|
|
119
|
+
<Separator />
|
|
120
|
+
|
|
121
|
+
<div className={`space-y-4 ${readOnly ? "pointer-events-none opacity-60" : ""}`}>
|
|
122
|
+
<div className="space-y-1.5">
|
|
123
|
+
<label className="text-xs font-medium text-foreground/80">{t("dataType", "Data type")}</label>
|
|
124
|
+
<Select
|
|
125
|
+
value={variable.dataType}
|
|
126
|
+
onValueChange={(v) => setDeclaredVariableType(canvasId, variable.uid, v as DataType)}
|
|
127
|
+
>
|
|
128
|
+
<SelectTrigger className="h-8 text-sm">
|
|
129
|
+
<SelectValue />
|
|
130
|
+
</SelectTrigger>
|
|
131
|
+
<SelectContent>
|
|
132
|
+
{DATA_TYPES.map((dt) => (
|
|
133
|
+
<SelectItem key={dt} value={dt}>
|
|
134
|
+
{dt}
|
|
135
|
+
</SelectItem>
|
|
136
|
+
))}
|
|
137
|
+
</SelectContent>
|
|
138
|
+
</Select>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<div className="space-y-1.5">
|
|
142
|
+
<label className="text-xs font-medium text-foreground/80">
|
|
143
|
+
{t("initialValue")}{" "}
|
|
144
|
+
<span className="font-normal text-muted-foreground">({t("optional", "optional")})</span>
|
|
145
|
+
</label>
|
|
146
|
+
{renderInitialValueInput()}
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
{!readOnly && (
|
|
151
|
+
<>
|
|
152
|
+
<Separator />
|
|
153
|
+
<DeleteButton onClick={() => deleteDeclaredVariable(canvasId, variable.uid)}>
|
|
154
|
+
{t("deleteVariable", "Delete variable")}
|
|
155
|
+
</DeleteButton>
|
|
156
|
+
</>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { AddButton } from "../components/ui/add-button";
|
|
4
|
+
import { Variable as VariableIcon } from "lucide-react";
|
|
5
|
+
import { cn } from "../cn";
|
|
6
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
7
|
+
import { isReadOnly } from "../WorkflowBuilder";
|
|
8
|
+
import { useAvailableVariables } from "../hooks/useAvailableVariables";
|
|
9
|
+
import { getOrCreateCanvasStore, MAIN_CANVAS_ID } from "../stores/canvasStore";
|
|
10
|
+
import { type Variable, type DeclaredVariable } from "@foresthubai/workflow-core/variable";
|
|
11
|
+
import { addDeclaredVariable } from "../utils/variableOperations";
|
|
12
|
+
|
|
13
|
+
interface VariablesPanelProps {
|
|
14
|
+
canvasId: string;
|
|
15
|
+
onSelectNode: (nodeId: string) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const VariablesPanel = ({ canvasId, onSelectNode }: VariablesPanelProps) => {
|
|
19
|
+
const readOnly = useEditorStore((s) => isReadOnly(s.builderMode));
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const { list: variables } = useAvailableVariables(canvasId);
|
|
22
|
+
const selection = useEditorStore((s) => s.selection);
|
|
23
|
+
const selectVariable = useEditorStore((s) => s.selectVariable);
|
|
24
|
+
|
|
25
|
+
const store = getOrCreateCanvasStore(canvasId);
|
|
26
|
+
const allVariables = store((s) => s.variables);
|
|
27
|
+
const isMainCanvas = canvasId === MAIN_CANVAS_ID;
|
|
28
|
+
|
|
29
|
+
// Extract declared variables from the unified record
|
|
30
|
+
const declaredVariables = React.useMemo(() => {
|
|
31
|
+
const result: { uid: string; var: DeclaredVariable }[] = [];
|
|
32
|
+
for (const v of Object.values(allVariables)) {
|
|
33
|
+
if (v.kind === "declared") {
|
|
34
|
+
result.push({ uid: v.uid, var: v });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}, [allVariables]);
|
|
39
|
+
|
|
40
|
+
// Create a declared variable and immediately open its config panel.
|
|
41
|
+
const handleAddVariable = () => {
|
|
42
|
+
const uid = addDeclaredVariable(canvasId);
|
|
43
|
+
selectVariable(uid);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Filter variables into groups (each canvas is self-contained — no main-canvas leakage)
|
|
47
|
+
const functionArgs = variables.filter((v) => v.kind === "fnarg");
|
|
48
|
+
const nodeOutputs = variables.filter((v) => v.kind === "node");
|
|
49
|
+
|
|
50
|
+
const hasContent = functionArgs.length > 0 || nodeOutputs.length > 0 || declaredVariables.length > 0;
|
|
51
|
+
|
|
52
|
+
if (!hasContent) {
|
|
53
|
+
return (
|
|
54
|
+
<div className="flex flex-col items-center justify-center py-8 text-center">
|
|
55
|
+
<VariableIcon className="w-10 h-10 text-muted-foreground/50 mb-3" />
|
|
56
|
+
<p className="text-sm text-muted-foreground">{t("noVariables")}</p>
|
|
57
|
+
<p className="text-xs text-muted-foreground/70 mt-1">{t("addNodesForVariables")}</p>
|
|
58
|
+
{!readOnly && (
|
|
59
|
+
<div className="mt-3 w-full px-2">
|
|
60
|
+
<AddButton onClick={handleAddVariable}>{t("addVariable")}</AddButton>
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const renderVariableItem = (ref: Variable, onClick?: () => void, isSelected = false) => {
|
|
68
|
+
const clickable = !!onClick;
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
key={
|
|
73
|
+
ref.kind === "node"
|
|
74
|
+
? `${ref.nodeId}-${ref.outputId}`
|
|
75
|
+
: ref.kind === "declared"
|
|
76
|
+
? `declared-${ref.uid}`
|
|
77
|
+
: `fnarg-${ref.uid}`
|
|
78
|
+
}
|
|
79
|
+
onClick={onClick}
|
|
80
|
+
className={cn(
|
|
81
|
+
"p-3 rounded-lg transition-all",
|
|
82
|
+
isSelected
|
|
83
|
+
? "bg-accent shadow-md border border-primary/40 ring-1 ring-primary/40"
|
|
84
|
+
: "bg-card shadow-sm border border-border",
|
|
85
|
+
clickable ? "hover:shadow-md cursor-pointer" : "cursor-default",
|
|
86
|
+
)}
|
|
87
|
+
>
|
|
88
|
+
<div className="flex items-center justify-between">
|
|
89
|
+
<div className="flex items-center gap-2">
|
|
90
|
+
<VariableIcon className="w-4 h-4 text-muted-foreground" />
|
|
91
|
+
<span className="font-mono text-sm text-foreground">{ref.name}</span>
|
|
92
|
+
</div>
|
|
93
|
+
<span className="text-[10px] font-medium px-1.5 py-0.5 rounded border border-border/50 text-muted-foreground shrink-0">
|
|
94
|
+
{ref.dataType}
|
|
95
|
+
</span>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const SectionHeader = ({ title }: { title: string }) => (
|
|
102
|
+
<div className="flex items-center justify-between px-1 mb-2">
|
|
103
|
+
<span className="text-sm font-medium text-foreground/80">{title}</span>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div className="space-y-5">
|
|
109
|
+
{/* Function Arguments (function canvas only) — read-only, arrive by value */}
|
|
110
|
+
{!isMainCanvas && functionArgs.length > 0 && (
|
|
111
|
+
<div>
|
|
112
|
+
<SectionHeader title={t("functionArguments")} />
|
|
113
|
+
<div className="space-y-1.5">{functionArgs.map((v) => renderVariableItem(v))}</div>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{/* Node Output Variables — click opens the emitting node */}
|
|
118
|
+
{nodeOutputs.length > 0 && (
|
|
119
|
+
<div>
|
|
120
|
+
<SectionHeader title={t("nodeOutputVariables")} />
|
|
121
|
+
<div className="space-y-1.5">
|
|
122
|
+
{nodeOutputs.map((v) =>
|
|
123
|
+
renderVariableItem(v, v.kind === "node" ? () => onSelectNode(v.nodeId) : undefined),
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
|
|
129
|
+
{/* Defined Variables — click opens the VariableConfigPanel */}
|
|
130
|
+
<div>
|
|
131
|
+
<SectionHeader title={t("definedVariables")} />
|
|
132
|
+
<div className="space-y-1.5">
|
|
133
|
+
{declaredVariables.map(({ uid, var: dv }) =>
|
|
134
|
+
renderVariableItem(
|
|
135
|
+
dv,
|
|
136
|
+
readOnly ? undefined : () => selectVariable(uid),
|
|
137
|
+
selection.kind === "variable" && selection.uid === uid,
|
|
138
|
+
),
|
|
139
|
+
)}
|
|
140
|
+
{!readOnly && <AddButton onClick={handleAddVariable}>{t("addVariable")}</AddButton>}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
clearAllCanvasStores,
|
|
4
|
+
getAllCanvasStores,
|
|
5
|
+
getCanvasStore,
|
|
6
|
+
getOrCreateCanvasStore,
|
|
7
|
+
subscribeCanvasRegistryChanges,
|
|
8
|
+
MAIN_CANVAS_ID,
|
|
9
|
+
} from "./canvasStore";
|
|
10
|
+
|
|
11
|
+
// Reset the module-level registry between tests (it's a singleton).
|
|
12
|
+
afterEach(() => clearAllCanvasStores());
|
|
13
|
+
|
|
14
|
+
describe("clearAllCanvasStores", () => {
|
|
15
|
+
it("re-seeds an empty main canvas and drops the rest", () => {
|
|
16
|
+
const mainBefore = getOrCreateCanvasStore(MAIN_CANVAS_ID);
|
|
17
|
+
getOrCreateCanvasStore("fn-1"); // a function canvas
|
|
18
|
+
expect(Object.keys(getAllCanvasStores())).toEqual(expect.arrayContaining([MAIN_CANVAS_ID, "fn-1"]));
|
|
19
|
+
|
|
20
|
+
clearAllCanvasStores();
|
|
21
|
+
|
|
22
|
+
const mainAfter = getCanvasStore(MAIN_CANVAS_ID);
|
|
23
|
+
expect(mainAfter).toBeDefined(); // "main always exists" invariant holds
|
|
24
|
+
expect(mainAfter).not.toBe(mainBefore); // it's a fresh, empty instance
|
|
25
|
+
expect(mainAfter?.getState().nodes).toEqual([]);
|
|
26
|
+
expect(getCanvasStore("fn-1")).toBeUndefined(); // function canvas removed
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("notifies registry listeners with main already present", () => {
|
|
30
|
+
// Regression guard: the notification must fire AFTER main is re-seeded, not
|
|
31
|
+
// while the registry is empty — otherwise subscribers (onChange / history)
|
|
32
|
+
// snapshot an empty set and never re-attach to the recreated main canvas, so
|
|
33
|
+
// edits after New/clear wouldn't mark the workflow dirty.
|
|
34
|
+
let mainPresentAtNotify = false;
|
|
35
|
+
const unsubscribe = subscribeCanvasRegistryChanges(() => {
|
|
36
|
+
mainPresentAtNotify = MAIN_CANVAS_ID in getAllCanvasStores();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
clearAllCanvasStores();
|
|
40
|
+
unsubscribe();
|
|
41
|
+
|
|
42
|
+
expect(mainPresentAtNotify).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { create, UseBoundStore, StoreApi } from "zustand";
|
|
2
|
+
import { Node, Edge, Viewport } from "@xyflow/react";
|
|
3
|
+
import { NodeCategory, type NodeData } from "@foresthubai/workflow-core/node";
|
|
4
|
+
import type { EdgeData } from "@foresthubai/workflow-core/edge";
|
|
5
|
+
import { history, History, type HistoryData, type MutationCount } from "../utils/history";
|
|
6
|
+
import { generateId } from "@foresthubai/workflow-core/id";
|
|
7
|
+
import { fnargKey, type Variable, type ApiVariable } from "@foresthubai/workflow-core/variable";
|
|
8
|
+
import { computeVariablesFromNodes } from "@foresthubai/workflow-core/workflow";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sync fnarg:* entries in a canvas's variables to match a function's arguments.
|
|
12
|
+
* fnarg variables are *derived* from the (project-scoped) function declaration —
|
|
13
|
+
* they are not authored canvas state, so the source of truth is `editorStore`;
|
|
14
|
+
* callers pass the declaration's argument list here. Removes stale fnarg entries
|
|
15
|
+
* and adds the current ones.
|
|
16
|
+
*/
|
|
17
|
+
export function syncFunctionArgVariables(store: CanvasStore, args: readonly ApiVariable[]): void {
|
|
18
|
+
store.getState().setVariables((vars) => {
|
|
19
|
+
const updated = { ...vars };
|
|
20
|
+
// Remove all existing fnarg entries
|
|
21
|
+
for (const key of Object.keys(updated)) {
|
|
22
|
+
if (key.startsWith("fnarg:")) delete updated[key];
|
|
23
|
+
}
|
|
24
|
+
// Add current args
|
|
25
|
+
for (const arg of args) {
|
|
26
|
+
updated[fnargKey(arg.uid)] = { kind: "fnarg", uid: arg.uid, name: arg.name, dataType: arg.dataType };
|
|
27
|
+
}
|
|
28
|
+
return updated;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { MAIN_CANVAS_ID } from "@foresthubai/workflow-core/workflow";
|
|
33
|
+
import { MAIN_CANVAS_ID } from "@foresthubai/workflow-core/workflow";
|
|
34
|
+
const HISTORY_LIMIT = 50 as const;
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Canvas Registry Change Notification System
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
// Listeners notified when the *set* of canvas stores changes (a store is created,
|
|
41
|
+
// deleted, or the whole registry is cleared/retained). This is decoupled from
|
|
42
|
+
// function definitions — those now live in editorStore. Its sole consumer is
|
|
43
|
+
// WorkflowBuilder, which re-subscribes to every live store's mutationCount/history
|
|
44
|
+
// when the set changes so newly created (or dropped) canvases are watched.
|
|
45
|
+
const canvasRegistryListeners = new Set<() => void>();
|
|
46
|
+
|
|
47
|
+
// Notify subscribers that the canvas store set changed.
|
|
48
|
+
export function notifyCanvasRegistryChange(): void {
|
|
49
|
+
canvasRegistryListeners.forEach((listener) => listener());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Subscribe to canvas registry (store set) changes.
|
|
53
|
+
export function subscribeCanvasRegistryChanges(listener: () => void): () => void {
|
|
54
|
+
canvasRegistryListeners.add(listener);
|
|
55
|
+
return () => canvasRegistryListeners.delete(listener);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// Canvas Store Registry
|
|
60
|
+
// ============================================================================
|
|
61
|
+
|
|
62
|
+
// Registry - Module-level map of independent store instances
|
|
63
|
+
const canvasStores = new Map<string, CanvasStore>();
|
|
64
|
+
|
|
65
|
+
canvasStores.set(MAIN_CANVAS_ID, createCanvasStore()); // Always exists
|
|
66
|
+
|
|
67
|
+
export interface CanvasState {
|
|
68
|
+
nodes: Node<NodeData>[];
|
|
69
|
+
edges: Edge<EdgeData>[];
|
|
70
|
+
// Unified variable record: node outputs (nodeId:outputId), declared (declared:uid), fn args (fnarg:uid).
|
|
71
|
+
// fnarg:* entries are derived from the project-scoped function declaration (editorStore) via
|
|
72
|
+
// syncFunctionArgVariables — they are not authored here.
|
|
73
|
+
variables: Record<string, Variable>;
|
|
74
|
+
// Session-only pan/zoom of the canvas viewport. View state, NOT workflow content:
|
|
75
|
+
// kept out of partialize (no history/serialization) so it never enters the contract,
|
|
76
|
+
// and lost on reload like selection. Persisted across tab switches so re-entering a
|
|
77
|
+
// canvas restores its view via defaultViewport instead of a post-paint fitView jump.
|
|
78
|
+
// null until first visited (then fitView seeds it).
|
|
79
|
+
viewport: Viewport | null;
|
|
80
|
+
|
|
81
|
+
setNodes: (updater: (nodes: Node<NodeData>[]) => Node<NodeData>[]) => void;
|
|
82
|
+
setEdges: (updater: (edges: Edge<EdgeData>[]) => Edge<EdgeData>[]) => void;
|
|
83
|
+
setVariables: (updater: (variables: Record<string, Variable>) => Record<string, Variable>) => void;
|
|
84
|
+
setViewport: (viewport: Viewport) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Visual-only: set ReactFlow selected flags on nodes AND edges in one atomic update.
|
|
87
|
+
* This will call a single re-render and a single onSelectionChange callback.
|
|
88
|
+
* Not an update of domain state, so it can be used in read-only mode.
|
|
89
|
+
*/
|
|
90
|
+
setRFselect: (nodeIds: string[], edgeIds: string[]) => void;
|
|
91
|
+
initialize: (nodes: Node<NodeData>[], edges: Edge<EdgeData>[]) => void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Canvas store is a Zustand store + history (undo/redo capabilities) + mutation count.
|
|
95
|
+
export type CanvasStore = UseBoundStore<StoreApi<CanvasState & MutationCount>> & History;
|
|
96
|
+
|
|
97
|
+
function createCanvasStore(): CanvasStore {
|
|
98
|
+
// Create base store with history middleware
|
|
99
|
+
const baseStore = create(
|
|
100
|
+
history<CanvasState>({
|
|
101
|
+
limit: HISTORY_LIMIT,
|
|
102
|
+
partialize: (state) => ({
|
|
103
|
+
nodes: state.nodes,
|
|
104
|
+
edges: state.edges,
|
|
105
|
+
variables: state.variables,
|
|
106
|
+
}),
|
|
107
|
+
equality: (before, after) => before.nodes === after.nodes && before.edges === after.edges && before.variables === after.variables,
|
|
108
|
+
})((set) => ({
|
|
109
|
+
nodes: [],
|
|
110
|
+
edges: [],
|
|
111
|
+
variables: {},
|
|
112
|
+
viewport: null,
|
|
113
|
+
|
|
114
|
+
setNodes: (updater) =>
|
|
115
|
+
set((state) => {
|
|
116
|
+
const next = updater(state.nodes);
|
|
117
|
+
if (next === state.nodes) return state;
|
|
118
|
+
return { nodes: next };
|
|
119
|
+
}),
|
|
120
|
+
|
|
121
|
+
setEdges: (updater) =>
|
|
122
|
+
set((state) => {
|
|
123
|
+
const next = updater(state.edges);
|
|
124
|
+
if (next === state.edges) return state;
|
|
125
|
+
return { edges: next };
|
|
126
|
+
}),
|
|
127
|
+
|
|
128
|
+
setVariables: (updater) =>
|
|
129
|
+
set((state) => {
|
|
130
|
+
const next = updater(state.variables);
|
|
131
|
+
if (next === state.variables) return state;
|
|
132
|
+
return { variables: next };
|
|
133
|
+
}),
|
|
134
|
+
|
|
135
|
+
// View-only — outside partialize, so it neither takes a checkpoint nor bumps
|
|
136
|
+
// mutationCount (no spurious dirty dot / onChange from panning).
|
|
137
|
+
setViewport: (viewport) => set({ viewport }),
|
|
138
|
+
|
|
139
|
+
setRFselect: (nodeIds, edgeIds) => {
|
|
140
|
+
const nodeIdSet = new Set(nodeIds);
|
|
141
|
+
const edgeIdSet = new Set(edgeIds);
|
|
142
|
+
set((state) => ({
|
|
143
|
+
nodes: state.nodes.map((n) => {
|
|
144
|
+
const shouldSelect = nodeIdSet.has(n.id);
|
|
145
|
+
return n.selected === shouldSelect ? n : { ...n, selected: shouldSelect };
|
|
146
|
+
}),
|
|
147
|
+
edges: state.edges.map((e) => {
|
|
148
|
+
const shouldSelect = edgeIdSet.has(e.id);
|
|
149
|
+
return e.selected === shouldSelect ? e : { ...e, selected: shouldSelect };
|
|
150
|
+
}),
|
|
151
|
+
}));
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
initialize: (nodes, edges) => {
|
|
155
|
+
// Build node-output variables. fnarg entries (for function canvases) are
|
|
156
|
+
// seeded separately via syncFunctionArgVariables from the editorStore
|
|
157
|
+
// declaration, since the canvas store no longer owns the signature.
|
|
158
|
+
// computeVariablesFromNodes is the core (NodeData[]) variant; peel the
|
|
159
|
+
// React Flow wrapper at the call site.
|
|
160
|
+
const vars: Record<string, Variable> = computeVariablesFromNodes(nodes.map((n) => n.data));
|
|
161
|
+
set({ nodes, edges, variables: vars });
|
|
162
|
+
},
|
|
163
|
+
})),
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// Bind history methods from state to CanvasStore object
|
|
167
|
+
// This makes them accessible as store.undo() instead of store.getState().undo()
|
|
168
|
+
const store = baseStore as unknown as CanvasStore;
|
|
169
|
+
|
|
170
|
+
store.takeCheckpoint = () => baseStore.getState().takeCheckpoint();
|
|
171
|
+
store.withCheckpoint = <R>(operation: () => R): R => baseStore.getState().withCheckpoint(operation);
|
|
172
|
+
store.undo = () => baseStore.getState().undo();
|
|
173
|
+
store.redo = () => baseStore.getState().redo();
|
|
174
|
+
store.clearHistory = () => baseStore.getState().clearHistory();
|
|
175
|
+
store.canUndo = () => baseStore.getState().canUndo();
|
|
176
|
+
store.canRedo = () => baseStore.getState().canRedo();
|
|
177
|
+
store.exportHistory = () => baseStore.getState().exportHistory();
|
|
178
|
+
store.importHistory = (data: HistoryData) => baseStore.getState().importHistory(data);
|
|
179
|
+
|
|
180
|
+
return store;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// Store Access API
|
|
185
|
+
// ============================================================================
|
|
186
|
+
|
|
187
|
+
// Get a canvas store by ID, or undefined if not exists
|
|
188
|
+
export function getCanvasStore(canvasId: string): CanvasStore | undefined {
|
|
189
|
+
return canvasStores.get(canvasId);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Get or create a canvas store by ID
|
|
193
|
+
// Non-main canvases (function canvases) are initialized with an OnFunctionCall node
|
|
194
|
+
export function getOrCreateCanvasStore(canvasId: string): CanvasStore {
|
|
195
|
+
if (!canvasStores.has(canvasId)) {
|
|
196
|
+
const store = createCanvasStore();
|
|
197
|
+
|
|
198
|
+
// Initialize function canvases with OnFunctionCall trigger node
|
|
199
|
+
if (canvasId !== MAIN_CANVAS_ID) {
|
|
200
|
+
const nodeId = generateId();
|
|
201
|
+
const initialNode: Node<NodeData> = {
|
|
202
|
+
id: nodeId,
|
|
203
|
+
type: NodeCategory.Trigger,
|
|
204
|
+
position: { x: 100, y: 100 },
|
|
205
|
+
data: {
|
|
206
|
+
id: nodeId,
|
|
207
|
+
type: "OnFunctionCall",
|
|
208
|
+
arguments: {},
|
|
209
|
+
} as NodeData,
|
|
210
|
+
};
|
|
211
|
+
store.getState().initialize([initialNode], []);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
canvasStores.set(canvasId, store);
|
|
215
|
+
}
|
|
216
|
+
return canvasStores.get(canvasId)!;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Get all canvas stores
|
|
220
|
+
export function getAllCanvasStores(): Record<string, CanvasStore> {
|
|
221
|
+
const result: Record<string, CanvasStore> = {};
|
|
222
|
+
canvasStores.forEach((store, id) => {
|
|
223
|
+
result[id] = store;
|
|
224
|
+
});
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Delete a canvas store by ID. Cannot delete the main canvas.
|
|
229
|
+
export function deleteCanvasStore(canvasId: string): void {
|
|
230
|
+
if (canvasId === MAIN_CANVAS_ID) return;
|
|
231
|
+
canvasStores.delete(canvasId);
|
|
232
|
+
notifyCanvasRegistryChange();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Clear all canvas stores, including the main canvas.
|
|
236
|
+
export function clearAllCanvasStores(): void {
|
|
237
|
+
canvasStores.clear();
|
|
238
|
+
// Re-seed an empty main canvas BEFORE notifying. Two reasons: it preserves the
|
|
239
|
+
// "main always exists" invariant, and — critically — subscribers re-subscribe to
|
|
240
|
+
// the live store set on this notification. If main were absent here, they'd
|
|
241
|
+
// snapshot an empty registry and never attach to the lazily-recreated main, so
|
|
242
|
+
// edits after New/clear wouldn't fire onChange (no dirty dot, stale undo state).
|
|
243
|
+
canvasStores.set(MAIN_CANVAS_ID, createCanvasStore());
|
|
244
|
+
notifyCanvasRegistryChange();
|
|
245
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Session Phase State Machine
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
export type DebugSessionPhase =
|
|
8
|
+
| { status: "inactive" }
|
|
9
|
+
| { status: "building"; abortController: AbortController }
|
|
10
|
+
| { status: "idle"; sessionId: string }
|
|
11
|
+
| { status: "paused"; sessionId: string; cursorNodeId: string }
|
|
12
|
+
| { status: "stepping"; sessionId: string; cursorNodeId: string }
|
|
13
|
+
| { status: "error"; message: string };
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Console
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
export interface ConsoleEntry {
|
|
20
|
+
id: number;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
type: "message" | "error" | "system";
|
|
23
|
+
text: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Store
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
interface DebugState {
|
|
31
|
+
phase: DebugSessionPhase;
|
|
32
|
+
/** Workflow variable values — client-owned, sent with each step request */
|
|
33
|
+
context: Record<string, unknown>;
|
|
34
|
+
console: ConsoleEntry[];
|
|
35
|
+
nextConsoleId: number;
|
|
36
|
+
|
|
37
|
+
// Actions
|
|
38
|
+
setPhase: (phase: DebugSessionPhase) => void;
|
|
39
|
+
setContext: (ctx: Record<string, unknown>) => void;
|
|
40
|
+
updateContextVar: (key: string, value: unknown) => void;
|
|
41
|
+
appendConsole: (type: ConsoleEntry["type"], text: string) => void;
|
|
42
|
+
clearConsole: () => void;
|
|
43
|
+
reset: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const useDebugStore = create<DebugState>((set) => ({
|
|
47
|
+
phase: { status: "inactive" },
|
|
48
|
+
context: {},
|
|
49
|
+
console: [],
|
|
50
|
+
nextConsoleId: 0,
|
|
51
|
+
|
|
52
|
+
setPhase: (phase) => set({ phase }),
|
|
53
|
+
|
|
54
|
+
setContext: (ctx) => set({ context: ctx }),
|
|
55
|
+
|
|
56
|
+
updateContextVar: (key, value) =>
|
|
57
|
+
set((s) => ({ context: { ...s.context, [key]: value } })),
|
|
58
|
+
|
|
59
|
+
appendConsole: (type, text) =>
|
|
60
|
+
set((s) => ({
|
|
61
|
+
console: [...s.console, { id: s.nextConsoleId, timestamp: Date.now(), type, text }],
|
|
62
|
+
nextConsoleId: s.nextConsoleId + 1,
|
|
63
|
+
})),
|
|
64
|
+
|
|
65
|
+
clearConsole: () => set({ console: [], nextConsoleId: 0 }),
|
|
66
|
+
|
|
67
|
+
reset: () =>
|
|
68
|
+
set({
|
|
69
|
+
phase: { status: "inactive" },
|
|
70
|
+
context: {},
|
|
71
|
+
console: [],
|
|
72
|
+
nextConsoleId: 0,
|
|
73
|
+
}),
|
|
74
|
+
}));
|