@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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps the `byFunctionId` diagnostics slot in sync with the function declarations —
|
|
3
|
+
* the single source for the sidebar tab badge, the function list ring, AND the config
|
|
4
|
+
* panel's per-output rings (they all read this slot). Mounted once at the
|
|
5
|
+
* workflow-builder root so it survives tab open/close.
|
|
6
|
+
*
|
|
7
|
+
* Scope-aware: each function is validated against its own body canvas's variables, so
|
|
8
|
+
* invalid/typed return expressions surface here too — not just missing ones. (Reacts
|
|
9
|
+
* to declaration/expression edits via `functions`; a body-only edit that changes the
|
|
10
|
+
* available variables without touching a declaration refreshes on the next
|
|
11
|
+
* declaration change or a full `validate`.)
|
|
12
|
+
*/
|
|
13
|
+
export declare function useFunctionDiagnosticsSync(): void;
|
|
14
|
+
//# sourceMappingURL=useFunctionDiagnosticsSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFunctionDiagnosticsSync.d.ts","sourceRoot":"","sources":["../../src/hooks/useFunctionDiagnosticsSync.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAoBjD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { validateFunction } from "@foresthubai/workflow-core/diagnostics";
|
|
3
|
+
import { computeAvailableVariables } from "@foresthubai/workflow-core/variable";
|
|
4
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
5
|
+
import { useDiagnosticsStore } from "../stores/diagnosticsStore";
|
|
6
|
+
import { getCanvasStore } from "../stores/canvasStore";
|
|
7
|
+
/**
|
|
8
|
+
* Keeps the `byFunctionId` diagnostics slot in sync with the function declarations —
|
|
9
|
+
* the single source for the sidebar tab badge, the function list ring, AND the config
|
|
10
|
+
* panel's per-output rings (they all read this slot). Mounted once at the
|
|
11
|
+
* workflow-builder root so it survives tab open/close.
|
|
12
|
+
*
|
|
13
|
+
* Scope-aware: each function is validated against its own body canvas's variables, so
|
|
14
|
+
* invalid/typed return expressions surface here too — not just missing ones. (Reacts
|
|
15
|
+
* to declaration/expression edits via `functions`; a body-only edit that changes the
|
|
16
|
+
* available variables without touching a declaration refreshes on the next
|
|
17
|
+
* declaration change or a full `validate`.)
|
|
18
|
+
*/
|
|
19
|
+
export function useFunctionDiagnosticsSync() {
|
|
20
|
+
const functions = useEditorStore((s) => s.functions);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const ds = useDiagnosticsStore.getState();
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (const [id, def] of Object.entries(functions)) {
|
|
25
|
+
seen.add(id);
|
|
26
|
+
const store = getCanvasStore(id);
|
|
27
|
+
const lookup = store
|
|
28
|
+
? computeAvailableVariables(store.getState().variables, store.getState().edges).lookup
|
|
29
|
+
: undefined;
|
|
30
|
+
ds.setFunctionDiagnostics(id, validateFunction(def, lookup));
|
|
31
|
+
}
|
|
32
|
+
for (const id of Object.keys(ds.byFunctionId)) {
|
|
33
|
+
if (!seen.has(id))
|
|
34
|
+
ds.clearFunctionDiagnostics(id);
|
|
35
|
+
}
|
|
36
|
+
}, [functions]);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=useFunctionDiagnosticsSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFunctionDiagnosticsSync.js","sourceRoot":"","sources":["../../src/hooks/useFunctionDiagnosticsSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B;IACxC,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAErD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;QAE1C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACb,MAAM,KAAK,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;YACjC,MAAM,MAAM,GAAG,KAAK;gBAClB,CAAC,CAAC,yBAAyB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM;gBACtF,CAAC,CAAC,SAAS,CAAC;YACd,EAAE,CAAC,sBAAsB,CAAC,EAAE,EAAE,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAE,EAAE,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FunctionDeclaration } from "@foresthubai/workflow-core/function";
|
|
2
|
+
/**
|
|
3
|
+
* Access to all function declarations by id. Reactive over editorStore.functions.
|
|
4
|
+
* - functions: Record of FunctionDeclaration by id
|
|
5
|
+
* - functionsList: array of FunctionDeclaration
|
|
6
|
+
* - getFunction(id): one declaration by id
|
|
7
|
+
*/
|
|
8
|
+
export declare function useFunctionRegistry(): {
|
|
9
|
+
functions: Record<string, FunctionDeclaration>;
|
|
10
|
+
functionsList: FunctionDeclaration[];
|
|
11
|
+
getFunction: (id: string) => FunctionDeclaration | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** All function declarations without React subscription (for non-component code). */
|
|
14
|
+
export declare function getAllFunctions(): Record<string, FunctionDeclaration>;
|
|
15
|
+
//# sourceMappingURL=useFunctionRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFunctionRegistry.d.ts","sourceRoot":"","sources":["../../src/hooks/useFunctionRegistry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAM/E;;;;;GAKG;AACH,wBAAgB,mBAAmB;;;sBAGI,MAAM,KAAG,mBAAmB,GAAG,SAAS;EAG9E;AAED,qFAAqF;AACrF,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAErE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
3
|
+
// Functions are a project-scoped resource: the registry IS editorStore.functions —
|
|
4
|
+
// the domain FunctionDeclaration, no conversion. (Crossing to the flat api FunctionInfo
|
|
5
|
+
// is done only when stamping a call-site snapshot; see useNodeDefinitions/migration.)
|
|
6
|
+
/**
|
|
7
|
+
* Access to all function declarations by id. Reactive over editorStore.functions.
|
|
8
|
+
* - functions: Record of FunctionDeclaration by id
|
|
9
|
+
* - functionsList: array of FunctionDeclaration
|
|
10
|
+
* - getFunction(id): one declaration by id
|
|
11
|
+
*/
|
|
12
|
+
export function useFunctionRegistry() {
|
|
13
|
+
const functions = useEditorStore((s) => s.functions);
|
|
14
|
+
const functionsList = useMemo(() => Object.values(functions), [functions]);
|
|
15
|
+
const getFunction = useCallback((id) => functions[id], [functions]);
|
|
16
|
+
return { functions, functionsList, getFunction };
|
|
17
|
+
}
|
|
18
|
+
/** All function declarations without React subscription (for non-component code). */
|
|
19
|
+
export function getAllFunctions() {
|
|
20
|
+
return useEditorStore.getState().functions;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=useFunctionRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFunctionRegistry.js","sourceRoot":"","sources":["../../src/hooks/useFunctionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,mFAAmF;AACnF,wFAAwF;AACxF,sFAAsF;AAEtF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,EAAU,EAAmC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAE7G,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC;AACnD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,eAAe;IAC7B,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface UseFunctionsOptions {
|
|
2
|
+
/** Open (or focus) a tab for a function canvas. */
|
|
3
|
+
onOpenTab: (id: string, label: string) => void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Coordinates the canvas-tab UI with function declarations (editorStore). The
|
|
7
|
+
* declarations themselves are CRUD'd in utils/functionOperations; this hook only
|
|
8
|
+
* handles the open/create flows that must also touch the tab strip and selection.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useFunctions: ({ onOpenTab }: UseFunctionsOptions) => {
|
|
11
|
+
functions: import("@foresthubai/workflow-core/function").FunctionDeclaration[];
|
|
12
|
+
openFunction: (functionId: string) => void;
|
|
13
|
+
createFunction: () => string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useFunctions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFunctions.d.ts","sourceRoot":"","sources":["../../src/hooks/useFunctions.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,eAAe,mBAAmB;;+BAQ9C,MAAM;;CAmBtB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
3
|
+
import { getOrCreateCanvasStore } from "../stores/canvasStore";
|
|
4
|
+
import { useFunctionRegistry } from "./useFunctionRegistry";
|
|
5
|
+
import { addFunction } from "../utils/functionOperations";
|
|
6
|
+
/**
|
|
7
|
+
* Coordinates the canvas-tab UI with function declarations (editorStore). The
|
|
8
|
+
* declarations themselves are CRUD'd in utils/functionOperations; this hook only
|
|
9
|
+
* handles the open/create flows that must also touch the tab strip and selection.
|
|
10
|
+
*/
|
|
11
|
+
export const useFunctions = ({ onOpenTab }) => {
|
|
12
|
+
const { functionsList: functions, getFunction } = useFunctionRegistry();
|
|
13
|
+
const selectFunction = useEditorStore((s) => s.selectFunction);
|
|
14
|
+
// Open an existing function: ensure its body canvas exists, open its tab, and
|
|
15
|
+
// select it so the right panel shows its definition. onOpenTab switches the active
|
|
16
|
+
// canvas first; selectFunction sets the selection last so it isn't cleared.
|
|
17
|
+
const openFunction = useCallback((functionId) => {
|
|
18
|
+
const fn = getFunction(functionId);
|
|
19
|
+
if (!fn)
|
|
20
|
+
return;
|
|
21
|
+
getOrCreateCanvasStore(functionId);
|
|
22
|
+
onOpenTab(functionId, fn.name);
|
|
23
|
+
selectFunction(functionId);
|
|
24
|
+
}, [getFunction, onOpenTab, selectFunction]);
|
|
25
|
+
// Create a new function and open it (the canvas body is created by addFunction).
|
|
26
|
+
const createFunction = useCallback(() => {
|
|
27
|
+
const fn = addFunction();
|
|
28
|
+
onOpenTab(fn.id, fn.name);
|
|
29
|
+
selectFunction(fn.id);
|
|
30
|
+
return fn.id;
|
|
31
|
+
}, [onOpenTab, selectFunction]);
|
|
32
|
+
return { functions, openFunction, createFunction };
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=useFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use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E,CAAC,EAAE,CAAC;IACf,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAEhC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NodeDefinition, NodeData } from "@foresthubai/workflow-core/node";
|
|
2
|
+
import { Connection, Edge, Node } from "@xyflow/react";
|
|
3
|
+
import type { EdgeData } from "@foresthubai/workflow-core/edge";
|
|
4
|
+
import type { EdgeType } from "@foresthubai/workflow-core/edge";
|
|
5
|
+
/**
|
|
6
|
+
* Hook that provides graph management actions for a specific canvas.
|
|
7
|
+
*
|
|
8
|
+
* All mutations are:
|
|
9
|
+
* - Gated by readOnly (no-op when true)
|
|
10
|
+
* - Automatically wrapped in a history checkpoint (undo/redo)
|
|
11
|
+
*
|
|
12
|
+
* Callers don't need to worry about either concern.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useGraph: (canvasId?: string, readOnly?: boolean) => {
|
|
15
|
+
nodes: Node<NodeData>[];
|
|
16
|
+
edges: Edge<EdgeData>[];
|
|
17
|
+
addNode: (nodeDef: NodeDefinition, position?: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}) => string | null;
|
|
21
|
+
updateNode: (nodeId: string, updates: {
|
|
22
|
+
arguments?: Record<string, unknown>;
|
|
23
|
+
label?: string;
|
|
24
|
+
}) => void;
|
|
25
|
+
updateEdge: (edgeId: string, updates: Record<string, unknown>) => void;
|
|
26
|
+
deleteNode: (nodeId: string) => void;
|
|
27
|
+
deleteEdges: (edgeIds: string[]) => void;
|
|
28
|
+
deleteSelected: (nodeIds: string[], edgeIds: string[]) => void;
|
|
29
|
+
onConnect: (connection: Connection) => EdgeType | false;
|
|
30
|
+
addNodeAndConnect: (nodeDef: NodeDefinition, position: {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
}, connection: Connection) => string | null;
|
|
34
|
+
copySelection: (nodeIds: string[]) => void;
|
|
35
|
+
pasteSelection: (offset?: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}) => import("../utils/graphOperations").PasteResult | undefined;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=useGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../../src/hooks/useGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAahE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAOhE;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,GAAI,WAAU,MAAuB,EAAE,WAAU,OAAe;;;uBAkBvE,cAAc,aAAa;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;yBAOpD,MAAM,WAAW;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;yBAqBxE,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;yBAdxC,MAAM;2BAqBL,MAAM,EAAE;8BAQR,MAAM,EAAE,WAAW,MAAM,EAAE;4BAtBxB,UAAU,KAAG,QAAQ,GAAG,KAAK;iCA+DhC,cAAc,YAAY;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,cAAc,UAAU,KAAG,MAAM,GAAG,IAAI;6BA7B1F,MAAM,EAAE;8BAmBR;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;CAqCrC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { getOrCreateCanvasStore, MAIN_CANVAS_ID } from "../stores/canvasStore";
|
|
3
|
+
import { addNodeToStore, connectNodesInStore, deleteEdgesFromStore, deleteNodeFromStore, pasteToStore, updateEdgeInStore, updateNodeInStore, } from "../utils/graphOperations";
|
|
4
|
+
import { useNodeDefinitions } from "./useNodeDefinitions";
|
|
5
|
+
// Shared across all useGraph instances (one per canvas) so copy/paste works
|
|
6
|
+
// across canvas switches within a single builder session.
|
|
7
|
+
const clipboardRef = { current: null };
|
|
8
|
+
/**
|
|
9
|
+
* Hook that provides graph management actions for a specific canvas.
|
|
10
|
+
*
|
|
11
|
+
* All mutations are:
|
|
12
|
+
* - Gated by readOnly (no-op when true)
|
|
13
|
+
* - Automatically wrapped in a history checkpoint (undo/redo)
|
|
14
|
+
*
|
|
15
|
+
* Callers don't need to worry about either concern.
|
|
16
|
+
*/
|
|
17
|
+
export const useGraph = (canvasId = MAIN_CANVAS_ID, readOnly = false) => {
|
|
18
|
+
const canvasStore = getOrCreateCanvasStore(canvasId);
|
|
19
|
+
const nodes = canvasStore((s) => s.nodes);
|
|
20
|
+
const edges = canvasStore((s) => s.edges);
|
|
21
|
+
const { withCheckpoint } = canvasStore;
|
|
22
|
+
const { getNodeDefinition } = useNodeDefinitions();
|
|
23
|
+
// Guarded checkpoint: skips when readOnly, otherwise wraps in undo history entry
|
|
24
|
+
const guarded = useCallback((operation) => {
|
|
25
|
+
if (readOnly)
|
|
26
|
+
return undefined;
|
|
27
|
+
return withCheckpoint(operation);
|
|
28
|
+
}, [readOnly, withCheckpoint]);
|
|
29
|
+
const addNode = useCallback((nodeDef, position) => {
|
|
30
|
+
return guarded(() => addNodeToStore(canvasStore, nodeDef, position)) ?? null;
|
|
31
|
+
}, [canvasStore, guarded]);
|
|
32
|
+
const updateNode = useCallback((nodeId, updates) => {
|
|
33
|
+
guarded(() => updateNodeInStore(canvasStore, nodeId, updates));
|
|
34
|
+
}, [canvasStore, guarded]);
|
|
35
|
+
const deleteNode = useCallback((nodeId) => {
|
|
36
|
+
guarded(() => deleteNodeFromStore(canvasStore, nodeId, getNodeDefinition));
|
|
37
|
+
}, [canvasStore, getNodeDefinition, guarded]);
|
|
38
|
+
const onConnect = useCallback((connection) => {
|
|
39
|
+
return guarded(() => connectNodesInStore(canvasStore, connection)) ?? false;
|
|
40
|
+
}, [canvasStore, guarded]);
|
|
41
|
+
const updateEdge = useCallback((edgeId, updates) => {
|
|
42
|
+
guarded(() => updateEdgeInStore(canvasStore, edgeId, updates));
|
|
43
|
+
}, [canvasStore, guarded]);
|
|
44
|
+
const deleteEdges = useCallback((edgeIds) => {
|
|
45
|
+
guarded(() => deleteEdgesFromStore(canvasStore, edgeIds));
|
|
46
|
+
}, [canvasStore, guarded]);
|
|
47
|
+
// Batch delete nodes and edges as a single undo entry
|
|
48
|
+
const deleteSelected = useCallback((nodeIds, edgeIds) => {
|
|
49
|
+
if (nodeIds.length === 0 && edgeIds.length === 0)
|
|
50
|
+
return;
|
|
51
|
+
guarded(() => {
|
|
52
|
+
for (const nodeId of nodeIds)
|
|
53
|
+
deleteNodeFromStore(canvasStore, nodeId, getNodeDefinition);
|
|
54
|
+
if (edgeIds.length > 0)
|
|
55
|
+
deleteEdgesFromStore(canvasStore, edgeIds);
|
|
56
|
+
});
|
|
57
|
+
}, [canvasStore, getNodeDefinition, guarded]);
|
|
58
|
+
// Copy is read-only — no checkpoint, no readOnly gate
|
|
59
|
+
const copySelection = useCallback((nodeIds) => {
|
|
60
|
+
if (nodeIds.length === 0)
|
|
61
|
+
return;
|
|
62
|
+
const nodeIdSet = new Set(nodeIds);
|
|
63
|
+
const copiedNodes = nodes
|
|
64
|
+
.filter((node) => nodeIdSet.has(node.id))
|
|
65
|
+
.map((node) => JSON.parse(JSON.stringify(node)));
|
|
66
|
+
const copiedEdges = edges
|
|
67
|
+
.filter((edge) => nodeIdSet.has(edge.source) && nodeIdSet.has(edge.target))
|
|
68
|
+
.map((edge) => JSON.parse(JSON.stringify(edge)));
|
|
69
|
+
clipboardRef.current = { nodes: copiedNodes, edges: copiedEdges };
|
|
70
|
+
}, [nodes, edges]);
|
|
71
|
+
const pasteSelection = useCallback((offset) => {
|
|
72
|
+
const clipboard = clipboardRef.current;
|
|
73
|
+
if (!clipboard)
|
|
74
|
+
return undefined;
|
|
75
|
+
return guarded(() => pasteToStore(canvasStore, clipboard, offset, getNodeDefinition));
|
|
76
|
+
}, [canvasStore, getNodeDefinition, guarded]);
|
|
77
|
+
// Batch add node + connect as a single undo entry (used by contextual node picker)
|
|
78
|
+
const addNodeAndConnect = useCallback((nodeDef, position, connection) => {
|
|
79
|
+
return (guarded(() => {
|
|
80
|
+
const nodeId = addNodeToStore(canvasStore, nodeDef, position);
|
|
81
|
+
if (nodeId == null)
|
|
82
|
+
return null;
|
|
83
|
+
connectNodesInStore(canvasStore, { ...connection, target: nodeId });
|
|
84
|
+
return nodeId;
|
|
85
|
+
}) ?? null);
|
|
86
|
+
}, [canvasStore, guarded]);
|
|
87
|
+
return {
|
|
88
|
+
nodes,
|
|
89
|
+
edges,
|
|
90
|
+
addNode,
|
|
91
|
+
updateNode,
|
|
92
|
+
updateEdge,
|
|
93
|
+
deleteNode,
|
|
94
|
+
deleteEdges,
|
|
95
|
+
deleteSelected,
|
|
96
|
+
onConnect,
|
|
97
|
+
addNodeAndConnect,
|
|
98
|
+
copySelection,
|
|
99
|
+
pasteSelection,
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=useGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraph.js","sourceRoot":"","sources":["../../src/hooks/useGraph.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,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{ type FunctionInfo } from "@foresthubai/workflow-core/function";
|
|
3
|
+
import { FunctionNodeDefinition } from "@foresthubai/workflow-core/node";
|
|
4
|
+
/**
|
|
5
|
+
* Workflow-builder binding for {@link coreBuildFunctionNodeDef} — passes
|
|
6
|
+
* `i18n.t` so descriptions are translated. Consumers continue to call
|
|
7
|
+
* `buildFunctionNodeDef(fn)` unchanged; core's signature is the pure
|
|
8
|
+
* `(fn, t?)` form.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildFunctionNodeDef(fn: FunctionInfo): FunctionNodeDefinition;
|
|
11
|
+
export declare const useNodeDefinitions: () => {
|
|
12
|
+
nodeDefinitions: NodeDefinition[];
|
|
13
|
+
getAllCategories: () => NodeCategory[];
|
|
14
|
+
getNodeDefinition: (node: NodeData) => NodeDefinition | undefined;
|
|
15
|
+
getNodeDefinitionsByCategory: (category: NodeCategory) => NodeDefinition[];
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useNodeDefinitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNodeDefinitions.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodeDefinitions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAgB,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEvG,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAoB,sBAAsB,EAAoD,MAAM,iCAAiC,CAAC;AAE7I;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,YAAY,GAAG,sBAAsB,CAE7E;AAGD,eAAO,MAAM,kBAAkB;;4BAqCY,YAAY,EAAE;8BArB9C,QAAQ,KAAG,cAAc,GAAG,SAAS;6CAWjC,YAAY;CAmC1B,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useMemo, useCallback } from "react";
|
|
2
|
+
import i18n from "../i18n";
|
|
3
|
+
import { NodeCategory, NodeRegistry } from "@foresthubai/workflow-core/node";
|
|
4
|
+
import { useFunctionRegistry } from "./useFunctionRegistry";
|
|
5
|
+
import { toFunctionInfo } from "@foresthubai/workflow-core/function";
|
|
6
|
+
import { buildFunctionNodeDef as coreBuildFunctionNodeDef } from "@foresthubai/workflow-core/node";
|
|
7
|
+
/**
|
|
8
|
+
* Workflow-builder binding for {@link coreBuildFunctionNodeDef} — passes
|
|
9
|
+
* `i18n.t` so descriptions are translated. Consumers continue to call
|
|
10
|
+
* `buildFunctionNodeDef(fn)` unchanged; core's signature is the pure
|
|
11
|
+
* `(fn, t?)` form.
|
|
12
|
+
*/
|
|
13
|
+
export function buildFunctionNodeDef(fn) {
|
|
14
|
+
return coreBuildFunctionNodeDef(fn, i18n.t.bind(i18n));
|
|
15
|
+
}
|
|
16
|
+
// Use function registry to provide dynamic node definitions based on available functions
|
|
17
|
+
export const useNodeDefinitions = () => {
|
|
18
|
+
// Get static node definitions from registry (these never change)
|
|
19
|
+
const staticNodeDefs = NodeRegistry.getAll();
|
|
20
|
+
// Subscribe to function registry (derived from all canvas stores)
|
|
21
|
+
const { functions } = useFunctionRegistry();
|
|
22
|
+
// Dynamically create node definitions for each function. The call-site node def is
|
|
23
|
+
// built from the flat signature snapshot, so project the domain declaration here.
|
|
24
|
+
const functionNodeDefs = useMemo(() => Object.values(functions).map((fn) => buildFunctionNodeDef(toFunctionInfo(fn))), [functions]);
|
|
25
|
+
// Get node definition for a node instance (still depending on all functions)
|
|
26
|
+
const getNodeDefinition = useCallback((node) => {
|
|
27
|
+
if (node.type === "FunctionCall") {
|
|
28
|
+
const fnNode = node;
|
|
29
|
+
return functionNodeDefs.find((def) => def.type === "FunctionCall" && def.functionInfo.id === fnNode.functionInfo.id);
|
|
30
|
+
}
|
|
31
|
+
return NodeRegistry.getByType(node.type);
|
|
32
|
+
}, [functionNodeDefs]);
|
|
33
|
+
const getNodeDefinitionsByCategory = useCallback((category) => {
|
|
34
|
+
const staticNodes = NodeRegistry.getByCategory(category);
|
|
35
|
+
if (category === NodeCategory.Function) {
|
|
36
|
+
return [...staticNodes, ...functionNodeDefs];
|
|
37
|
+
}
|
|
38
|
+
return staticNodes;
|
|
39
|
+
}, [functionNodeDefs]);
|
|
40
|
+
const getAllCategories = useCallback(() => {
|
|
41
|
+
const staticCategories = NodeRegistry.getAllCategories();
|
|
42
|
+
const allCategories = new Set([...staticCategories]);
|
|
43
|
+
if (functionNodeDefs.length > 0) {
|
|
44
|
+
allCategories.add(NodeCategory.Function);
|
|
45
|
+
}
|
|
46
|
+
const categoryOrder = [
|
|
47
|
+
NodeCategory.Trigger,
|
|
48
|
+
NodeCategory.Input,
|
|
49
|
+
NodeCategory.Logic,
|
|
50
|
+
NodeCategory.Data,
|
|
51
|
+
NodeCategory.Function,
|
|
52
|
+
NodeCategory.AI,
|
|
53
|
+
NodeCategory.Tool,
|
|
54
|
+
NodeCategory.Output,
|
|
55
|
+
];
|
|
56
|
+
return categoryOrder.filter((cat) => allCategories.has(cat));
|
|
57
|
+
}, [functionNodeDefs]);
|
|
58
|
+
return {
|
|
59
|
+
nodeDefinitions: [...staticNodeDefs, ...functionNodeDefs],
|
|
60
|
+
getAllCategories,
|
|
61
|
+
getNodeDefinition,
|
|
62
|
+
getNodeDefinitionsByCategory,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=useNodeDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNodeDefinitions.js","sourceRoot":"","sources":["../../src/hooks/useNodeDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,YAAY,EAA4B,MAAM,iCAAiC,CAAC;AACvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,E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"@foresthubai/workflow-core/diagnostics";
|
|
2
|
+
/**
|
|
3
|
+
* Build a per-parameter error map (`paramId → messages`) from a resource's
|
|
4
|
+
* diagnostics, keeping only `error`-severity entries. Shared by every config
|
|
5
|
+
* panel that renders a parameter list (node / edge / channel / memory / model)
|
|
6
|
+
* so the inline Map-building loop lives in exactly one place.
|
|
7
|
+
*
|
|
8
|
+
* Memoized on `diags`, so callers can read it from the diagnostics store with a
|
|
9
|
+
* plain selector and pass the result straight through to `<ParameterEditor>`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useParamErrors(diags: Diagnostic[] | undefined): Map<string, string[]>;
|
|
12
|
+
//# sourceMappingURL=useParamErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useParamErrors.d.ts","sourceRoot":"","sources":["../../src/hooks/useParamErrors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEzE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAarF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Build a per-parameter error map (`paramId → messages`) from a resource's
|
|
4
|
+
* diagnostics, keeping only `error`-severity entries. Shared by every config
|
|
5
|
+
* panel that renders a parameter list (node / edge / channel / memory / model)
|
|
6
|
+
* so the inline Map-building loop lives in exactly one place.
|
|
7
|
+
*
|
|
8
|
+
* Memoized on `diags`, so callers can read it from the diagnostics store with a
|
|
9
|
+
* plain selector and pass the result straight through to `<ParameterEditor>`.
|
|
10
|
+
*/
|
|
11
|
+
export function useParamErrors(diags) {
|
|
12
|
+
return useMemo(() => {
|
|
13
|
+
const map = new Map();
|
|
14
|
+
if (!diags)
|
|
15
|
+
return map;
|
|
16
|
+
for (const d of diags) {
|
|
17
|
+
if (d.paramId && d.severity === "error") {
|
|
18
|
+
const arr = map.get(d.paramId);
|
|
19
|
+
if (arr)
|
|
20
|
+
arr.push(d.message);
|
|
21
|
+
else
|
|
22
|
+
map.set(d.paramId, [d.message]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return map;
|
|
26
|
+
}, [diags]);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=useParamErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useParamErrors.js","sourceRoot":"","sources":["../../src/hooks/useParamErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,KAA+B;IAC5D,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO,GAAG,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;gBACxC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBAC/B,IAAI,GAAG;oBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;;oBACxB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns "light" if `<html>` has the `light` class, else "dark". Subscribes to
|
|
3
|
+
* MutationObserver so toggles by the embedder propagate immediately.
|
|
4
|
+
*
|
|
5
|
+
* Dark is the default — the builder's CSS puts dark tokens on `:root` and
|
|
6
|
+
* overrides them under `.light`. This hook exists so things that need an
|
|
7
|
+
* explicit value — notably ReactFlow's `colorMode` prop — stay in sync.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useResolvedTheme(): "dark" | "light";
|
|
10
|
+
//# sourceMappingURL=useResolvedTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useResolvedTheme.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,OAAO,CAcnD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Returns "light" if `<html>` has the `light` class, else "dark". Subscribes to
|
|
4
|
+
* MutationObserver so toggles by the embedder propagate immediately.
|
|
5
|
+
*
|
|
6
|
+
* Dark is the default — the builder's CSS puts dark tokens on `:root` and
|
|
7
|
+
* overrides them under `.light`. This hook exists so things that need an
|
|
8
|
+
* explicit value — notably ReactFlow's `colorMode` prop — stay in sync.
|
|
9
|
+
*/
|
|
10
|
+
export function useResolvedTheme() {
|
|
11
|
+
const [theme, setTheme] = useState(() => detect());
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (typeof document === "undefined")
|
|
14
|
+
return;
|
|
15
|
+
const root = document.documentElement;
|
|
16
|
+
const observer = new MutationObserver(() => setTheme(detect()));
|
|
17
|
+
observer.observe(root, { attributes: true, attributeFilter: ["class"] });
|
|
18
|
+
// Initial sync in case it changed between mount and effect.
|
|
19
|
+
setTheme(detect());
|
|
20
|
+
return () => observer.disconnect();
|
|
21
|
+
}, []);
|
|
22
|
+
return theme;
|
|
23
|
+
}
|
|
24
|
+
function detect() {
|
|
25
|
+
if (typeof document === "undefined")
|
|
26
|
+
return "dark";
|
|
27
|
+
return document.documentElement.classList.contains("light") ? "light" : "dark";
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=useResolvedTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedTheme.js","sourceRoot":"","sources":["../../src/hooks/useResolvedTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAmB,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,QAAQ,KAAK,WAAW;YAAE,OAAO;QAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAChE,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzE,4DAA4D;QAC5D,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACnB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,MAAM;IACb,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC;IACnD,OAAO,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
2
|
+
import { useDiagnosticsStore } from "../stores/diagnosticsStore";
|
|
3
|
+
import type { Diagnostic } from "@foresthubai/workflow-core/diagnostics";
|
|
4
|
+
type EditorState = ReturnType<typeof useEditorStore.getState>;
|
|
5
|
+
type DiagnosticsState = ReturnType<typeof useDiagnosticsStore.getState>;
|
|
6
|
+
interface ResourceDiagnosticsSyncConfig<I extends {
|
|
7
|
+
id: string;
|
|
8
|
+
}> {
|
|
9
|
+
/** Pick the resource map (e.g. `s.channels`) off the editor store. */
|
|
10
|
+
selectItems: (s: EditorState) => Record<string, I>;
|
|
11
|
+
/** Validate one instance into its diagnostics. */
|
|
12
|
+
validate: (item: I) => Diagnostic[];
|
|
13
|
+
/** Read the matching diagnostics slot (e.g. `d.byChannelId`). */
|
|
14
|
+
getStored: (d: DiagnosticsState) => Record<string, Diagnostic[]>;
|
|
15
|
+
/** Write one instance's diagnostics. */
|
|
16
|
+
set: (d: DiagnosticsState, id: string, diags: Diagnostic[]) => void;
|
|
17
|
+
/** Drop one instance's diagnostics. */
|
|
18
|
+
clear: (d: DiagnosticsState, id: string) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Keeps a project-scoped diagnostics slot (`byChannelId` / `byMemoryId` /
|
|
22
|
+
* `byModelId`) in sync with the editor's resource map.
|
|
23
|
+
*
|
|
24
|
+
* These resources are project-scoped, not canvas-scoped, and are only rendered
|
|
25
|
+
* visually when their sidebar tab is open. Tying diagnostic writes to card
|
|
26
|
+
* lifecycles would mean errors vanish the moment that tab closes, so this hook
|
|
27
|
+
* is mounted once at the workflow-builder root and reactively rewrites the store
|
|
28
|
+
* whenever the resource map changes.
|
|
29
|
+
*
|
|
30
|
+
* Lifecycle handled implicitly by the effect:
|
|
31
|
+
* - Load → setItems fires → effect re-runs → diagnostics written
|
|
32
|
+
* - Edit → store mutates → effect re-runs → entry replaced
|
|
33
|
+
* - Delete → item leaves → orphan branch → entry cleared
|
|
34
|
+
* - Unmount → store goes down with the app (no cleanup needed)
|
|
35
|
+
*/
|
|
36
|
+
export declare function useResourceDiagnosticsSync<I extends {
|
|
37
|
+
id: string;
|
|
38
|
+
}>(config: ResourceDiagnosticsSyncConfig<I>): void;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=useResourceDiagnosticsSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceDiagnosticsSync.d.ts","sourceRoot":"","sources":["../../src/hooks/useResourceDiagnosticsSync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEzE,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;AAC9D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAExE,UAAU,6BAA6B,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IAC9D,sEAAsE;IACtE,WAAW,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnD,kDAAkD;IAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,EAAE,CAAC;IACpC,iEAAiE;IACjE,SAAS,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IACjE,wCAAwC;IACxC,GAAG,EAAE,CAAC,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IACpE,uCAAuC;IACvC,KAAK,EAAE,CAAC,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,6BAA6B,CAAC,CAAC,CAAC,GAAG,IAAI,CAoBnH"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
3
|
+
import { useDiagnosticsStore } from "../stores/diagnosticsStore";
|
|
4
|
+
/**
|
|
5
|
+
* Keeps a project-scoped diagnostics slot (`byChannelId` / `byMemoryId` /
|
|
6
|
+
* `byModelId`) in sync with the editor's resource map.
|
|
7
|
+
*
|
|
8
|
+
* These resources are project-scoped, not canvas-scoped, and are only rendered
|
|
9
|
+
* visually when their sidebar tab is open. Tying diagnostic writes to card
|
|
10
|
+
* lifecycles would mean errors vanish the moment that tab closes, so this hook
|
|
11
|
+
* is mounted once at the workflow-builder root and reactively rewrites the store
|
|
12
|
+
* whenever the resource map changes.
|
|
13
|
+
*
|
|
14
|
+
* Lifecycle handled implicitly by the effect:
|
|
15
|
+
* - Load → setItems fires → effect re-runs → diagnostics written
|
|
16
|
+
* - Edit → store mutates → effect re-runs → entry replaced
|
|
17
|
+
* - Delete → item leaves → orphan branch → entry cleared
|
|
18
|
+
* - Unmount → store goes down with the app (no cleanup needed)
|
|
19
|
+
*/
|
|
20
|
+
export function useResourceDiagnosticsSync(config) {
|
|
21
|
+
const items = useEditorStore(config.selectItems);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const ds = useDiagnosticsStore.getState();
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
for (const item of Object.values(items)) {
|
|
26
|
+
seen.add(item.id);
|
|
27
|
+
config.set(ds, item.id, config.validate(item));
|
|
28
|
+
}
|
|
29
|
+
// Drop entries for items that have been deleted.
|
|
30
|
+
for (const id of Object.keys(config.getStored(ds))) {
|
|
31
|
+
if (!seen.has(id))
|
|
32
|
+
config.clear(ds, id);
|
|
33
|
+
}
|
|
34
|
+
// `config` is recreated each render but only `items` drives a resync; the
|
|
35
|
+
// effect reads the latest closure on every run.
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [items]);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=useResourceDiagnosticsSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceDiagnosticsSync.js","sourceRoot":"","sources":["../../src/hooks/useResourceDiagnosticsSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAmBjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CAA2B,MAAwC;IAC3G,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAEjD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;QAE1C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,iDAAiD;QACjD,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,0EAA0E;QAC1E,gDAAgD;QAChD,uDAAuD;IACzD,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,CAAC"}
|