@flowdrop/flowdrop 1.0.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 +21 -0
- package/README.md +252 -0
- package/dist/adapters/WorkflowAdapter.d.ts +167 -0
- package/dist/adapters/WorkflowAdapter.js +368 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +96 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.js +626 -0
- package/dist/adapters/agentspec/agentAdapter.d.ts +59 -0
- package/dist/adapters/agentspec/agentAdapter.js +91 -0
- package/dist/adapters/agentspec/autoLayout.d.ts +34 -0
- package/dist/adapters/agentspec/autoLayout.js +127 -0
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +73 -0
- package/dist/adapters/agentspec/componentTypeDefaults.js +238 -0
- package/dist/adapters/agentspec/defaultNodeTypes.d.ts +53 -0
- package/dist/adapters/agentspec/defaultNodeTypes.js +561 -0
- package/dist/adapters/agentspec/index.d.ts +37 -0
- package/dist/adapters/agentspec/index.js +39 -0
- package/dist/adapters/agentspec/validator.d.ts +34 -0
- package/dist/adapters/agentspec/validator.js +169 -0
- package/dist/api/enhanced-client.d.ts +183 -0
- package/dist/api/enhanced-client.js +430 -0
- package/dist/components/App.svelte +981 -0
- package/dist/components/App.svelte.d.ts +54 -0
- package/dist/components/CanvasBanner.stories.svelte +29 -0
- package/dist/components/CanvasBanner.stories.svelte.d.ts +27 -0
- package/dist/components/CanvasBanner.svelte +57 -0
- package/dist/components/CanvasBanner.svelte.d.ts +8 -0
- package/dist/components/ConfigForm.svelte +1138 -0
- package/dist/components/ConfigForm.svelte.d.ts +44 -0
- package/dist/components/ConfigModal.svelte +188 -0
- package/dist/components/ConfigModal.svelte.d.ts +13 -0
- package/dist/components/ConfigPanel.stories.svelte +47 -0
- package/dist/components/ConfigPanel.stories.svelte.d.ts +27 -0
- package/dist/components/ConfigPanel.svelte +182 -0
- package/dist/components/ConfigPanel.svelte.d.ts +32 -0
- package/dist/components/ConnectionLine.svelte +32 -0
- package/dist/components/ConnectionLine.svelte.d.ts +3 -0
- package/dist/components/EdgeRefresher.svelte +41 -0
- package/dist/components/EdgeRefresher.svelte.d.ts +9 -0
- package/dist/components/FlowDropZone.svelte +83 -0
- package/dist/components/FlowDropZone.svelte.d.ts +13 -0
- package/dist/components/LoadingSpinner.stories.svelte +30 -0
- package/dist/components/LoadingSpinner.stories.svelte.d.ts +27 -0
- package/dist/components/LoadingSpinner.svelte +36 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +8 -0
- package/dist/components/Logo.stories.svelte +22 -0
- package/dist/components/Logo.stories.svelte.d.ts +27 -0
- package/dist/components/Logo.svelte +102 -0
- package/dist/components/Logo.svelte.d.ts +26 -0
- package/dist/components/LogsSidebar.svelte +563 -0
- package/dist/components/LogsSidebar.svelte.d.ts +17 -0
- package/dist/components/MarkdownDisplay.stories.svelte +36 -0
- package/dist/components/MarkdownDisplay.stories.svelte.d.ts +27 -0
- package/dist/components/MarkdownDisplay.svelte +29 -0
- package/dist/components/MarkdownDisplay.svelte.d.ts +7 -0
- package/dist/components/Navbar.stories.svelte +53 -0
- package/dist/components/Navbar.stories.svelte.d.ts +27 -0
- package/dist/components/Navbar.svelte +726 -0
- package/dist/components/Navbar.svelte.d.ts +29 -0
- package/dist/components/NodeSidebar.svelte +762 -0
- package/dist/components/NodeSidebar.svelte.d.ts +9 -0
- package/dist/components/NodeStatusOverlay.stories.svelte +85 -0
- package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +27 -0
- package/dist/components/NodeStatusOverlay.svelte +327 -0
- package/dist/components/NodeStatusOverlay.svelte.d.ts +11 -0
- package/dist/components/PipelineStatus.svelte +314 -0
- package/dist/components/PipelineStatus.svelte.d.ts +20 -0
- package/dist/components/PortCoordinateTracker.svelte +58 -0
- package/dist/components/PortCoordinateTracker.svelte.d.ts +12 -0
- package/dist/components/ReadOnlyDetails.svelte +170 -0
- package/dist/components/ReadOnlyDetails.svelte.d.ts +25 -0
- package/dist/components/SchemaForm.stories.svelte +116 -0
- package/dist/components/SchemaForm.stories.svelte.d.ts +27 -0
- package/dist/components/SchemaForm.svelte +536 -0
- package/dist/components/SchemaForm.svelte.d.ts +83 -0
- package/dist/components/SettingsModal.svelte +279 -0
- package/dist/components/SettingsModal.svelte.d.ts +23 -0
- package/dist/components/SettingsPanel.svelte +638 -0
- package/dist/components/SettingsPanel.svelte.d.ts +21 -0
- package/dist/components/StatusIcon.stories.svelte +60 -0
- package/dist/components/StatusIcon.stories.svelte.d.ts +27 -0
- package/dist/components/StatusIcon.svelte +119 -0
- package/dist/components/StatusIcon.svelte.d.ts +10 -0
- package/dist/components/StatusLabel.stories.svelte +17 -0
- package/dist/components/StatusLabel.stories.svelte.d.ts +27 -0
- package/dist/components/StatusLabel.svelte +33 -0
- package/dist/components/StatusLabel.svelte.d.ts +7 -0
- package/dist/components/ThemeToggle.stories.svelte +25 -0
- package/dist/components/ThemeToggle.stories.svelte.d.ts +27 -0
- package/dist/components/ThemeToggle.svelte +185 -0
- package/dist/components/ThemeToggle.svelte.d.ts +14 -0
- package/dist/components/UniversalNode.svelte +155 -0
- package/dist/components/UniversalNode.svelte.d.ts +15 -0
- package/dist/components/WorkflowEditor.svelte +1035 -0
- package/dist/components/WorkflowEditor.svelte.d.ts +23 -0
- package/dist/components/form/FormArray.svelte +1049 -0
- package/dist/components/form/FormArray.svelte.d.ts +22 -0
- package/dist/components/form/FormAutocomplete.svelte +1009 -0
- package/dist/components/form/FormAutocomplete.svelte.d.ts +25 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte +28 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormCheckboxGroup.svelte +155 -0
- package/dist/components/form/FormCheckboxGroup.svelte.d.ts +17 -0
- package/dist/components/form/FormCodeEditor.svelte +458 -0
- package/dist/components/form/FormCodeEditor.svelte.d.ts +25 -0
- package/dist/components/form/FormField.svelte +417 -0
- package/dist/components/form/FormField.svelte.d.ts +29 -0
- package/dist/components/form/FormFieldLight.svelte +425 -0
- package/dist/components/form/FormFieldLight.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte +53 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormFieldWrapper.svelte +125 -0
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldset.svelte +142 -0
- package/dist/components/form/FormFieldset.svelte.d.ts +11 -0
- package/dist/components/form/FormMarkdownEditor.svelte +752 -0
- package/dist/components/form/FormMarkdownEditor.svelte.d.ts +33 -0
- package/dist/components/form/FormNumberField.stories.svelte +36 -0
- package/dist/components/form/FormNumberField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormNumberField.svelte +112 -0
- package/dist/components/form/FormNumberField.svelte.d.ts +25 -0
- package/dist/components/form/FormRangeField.stories.svelte +31 -0
- package/dist/components/form/FormRangeField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormRangeField.svelte +246 -0
- package/dist/components/form/FormRangeField.svelte.d.ts +23 -0
- package/dist/components/form/FormSelect.stories.svelte +50 -0
- package/dist/components/form/FormSelect.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormSelect.svelte +129 -0
- package/dist/components/form/FormSelect.svelte.d.ts +20 -0
- package/dist/components/form/FormTemplateEditor.svelte +825 -0
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +41 -0
- package/dist/components/form/FormTextField.stories.svelte +30 -0
- package/dist/components/form/FormTextField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextField.svelte +91 -0
- package/dist/components/form/FormTextField.svelte.d.ts +19 -0
- package/dist/components/form/FormTextarea.stories.svelte +34 -0
- package/dist/components/form/FormTextarea.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextarea.svelte +97 -0
- package/dist/components/form/FormTextarea.svelte.d.ts +21 -0
- package/dist/components/form/FormToggle.stories.svelte +30 -0
- package/dist/components/form/FormToggle.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormToggle.svelte +126 -0
- package/dist/components/form/FormToggle.svelte.d.ts +19 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +136 -0
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +32 -0
- package/dist/components/form/index.d.ts +50 -0
- package/dist/components/form/index.js +54 -0
- package/dist/components/form/templateAutocomplete.d.ts +29 -0
- package/dist/components/form/templateAutocomplete.js +254 -0
- package/dist/components/form/types.d.ts +485 -0
- package/dist/components/form/types.js +73 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte +52 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +401 -0
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +71 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte +292 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +25 -0
- package/dist/components/interrupt/FormPrompt.svelte +236 -0
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/InterruptBubble.svelte +601 -0
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte +67 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ReviewPrompt.svelte +861 -0
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte +47 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/TextInputPrompt.svelte +346 -0
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/index.d.ts +13 -0
- package/dist/components/interrupt/index.js +15 -0
- package/dist/components/layouts/MainLayout.svelte +718 -0
- package/dist/components/layouts/MainLayout.svelte.d.ts +62 -0
- package/dist/components/nodes/GatewayNode.stories.svelte +108 -0
- package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/GatewayNode.svelte +591 -0
- package/dist/components/nodes/GatewayNode.svelte.d.ts +15 -0
- package/dist/components/nodes/IdeaNode.stories.svelte +52 -0
- package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/IdeaNode.svelte +455 -0
- package/dist/components/nodes/IdeaNode.svelte.d.ts +24 -0
- package/dist/components/nodes/NotesNode.stories.svelte +76 -0
- package/dist/components/nodes/NotesNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/NotesNode.svelte +378 -0
- package/dist/components/nodes/NotesNode.svelte.d.ts +24 -0
- package/dist/components/nodes/SimpleNode.stories.svelte +159 -0
- package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SimpleNode.svelte +451 -0
- package/dist/components/nodes/SimpleNode.svelte.d.ts +25 -0
- package/dist/components/nodes/SquareNode.stories.svelte +82 -0
- package/dist/components/nodes/SquareNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SquareNode.svelte +407 -0
- package/dist/components/nodes/SquareNode.svelte.d.ts +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/TerminalNode.svelte +690 -0
- package/dist/components/nodes/TerminalNode.svelte.d.ts +25 -0
- package/dist/components/nodes/ToolNode.stories.svelte +189 -0
- package/dist/components/nodes/ToolNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/ToolNode.svelte +471 -0
- package/dist/components/nodes/ToolNode.svelte.d.ts +36 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte +55 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/WorkflowNode.svelte +571 -0
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +15 -0
- package/dist/components/playground/ChatPanel.svelte +905 -0
- package/dist/components/playground/ChatPanel.svelte.d.ts +46 -0
- package/dist/components/playground/ExecutionLogs.svelte +488 -0
- package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
- package/dist/components/playground/InputCollector.svelte +444 -0
- package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
- package/dist/components/playground/MessageBubble.stories.svelte +62 -0
- package/dist/components/playground/MessageBubble.stories.svelte.d.ts +27 -0
- package/dist/components/playground/MessageBubble.svelte +633 -0
- package/dist/components/playground/MessageBubble.svelte.d.ts +24 -0
- package/dist/components/playground/Playground.svelte +1075 -0
- package/dist/components/playground/Playground.svelte.d.ts +25 -0
- package/dist/components/playground/PlaygroundModal.svelte +220 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +25 -0
- package/dist/components/playground/SessionManager.svelte +538 -0
- package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
- package/dist/config/agentSpecEndpoints.d.ts +70 -0
- package/dist/config/agentSpecEndpoints.js +65 -0
- package/dist/config/constants.d.ts +43 -0
- package/dist/config/constants.js +31 -0
- package/dist/config/defaultCategories.d.ts +7 -0
- package/dist/config/defaultCategories.js +126 -0
- package/dist/config/defaultPortConfig.d.ts +6 -0
- package/dist/config/defaultPortConfig.js +201 -0
- package/dist/config/endpoints.d.ts +160 -0
- package/dist/config/endpoints.js +146 -0
- package/dist/config/runtimeConfig.d.ts +47 -0
- package/dist/config/runtimeConfig.js +80 -0
- package/dist/core/index.d.ts +75 -0
- package/dist/core/index.js +92 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +36 -0
- package/dist/editor/index.d.ts +95 -0
- package/dist/editor/index.js +138 -0
- package/dist/form/code.d.ts +101 -0
- package/dist/form/code.js +168 -0
- package/dist/form/fieldRegistry.d.ts +169 -0
- package/dist/form/fieldRegistry.js +152 -0
- package/dist/form/full.d.ts +56 -0
- package/dist/form/full.js +80 -0
- package/dist/form/index.d.ts +77 -0
- package/dist/form/index.js +91 -0
- package/dist/form/markdown.d.ts +69 -0
- package/dist/form/markdown.js +103 -0
- package/dist/helpers/nodeLayoutHelper.d.ts +14 -0
- package/dist/helpers/nodeLayoutHelper.js +19 -0
- package/dist/helpers/proximityConnect.d.ts +94 -0
- package/dist/helpers/proximityConnect.js +314 -0
- package/dist/helpers/workflowEditorHelper.d.ts +183 -0
- package/dist/helpers/workflowEditorHelper.js +595 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +64 -0
- package/dist/mocks/app-environment.d.ts +8 -0
- package/dist/mocks/app-environment.js +16 -0
- package/dist/mocks/app-forms.d.ts +2 -0
- package/dist/mocks/app-forms.js +22 -0
- package/dist/mocks/app-navigation.d.ts +5 -0
- package/dist/mocks/app-navigation.js +36 -0
- package/dist/mocks/app-stores.d.ts +14 -0
- package/dist/mocks/app-stores.js +26 -0
- package/dist/playground/index.d.ts +131 -0
- package/dist/playground/index.js +172 -0
- package/dist/playground/mount.d.ts +203 -0
- package/dist/playground/mount.js +235 -0
- package/dist/registry/BaseRegistry.d.ts +92 -0
- package/dist/registry/BaseRegistry.js +124 -0
- package/dist/registry/builtinFormats.d.ts +23 -0
- package/dist/registry/builtinFormats.js +70 -0
- package/dist/registry/builtinNodes.d.ts +77 -0
- package/dist/registry/builtinNodes.js +211 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/nodeComponentRegistry.d.ts +276 -0
- package/dist/registry/nodeComponentRegistry.js +262 -0
- package/dist/registry/plugin.d.ts +215 -0
- package/dist/registry/plugin.js +249 -0
- package/dist/registry/workflowFormatRegistry.d.ts +122 -0
- package/dist/registry/workflowFormatRegistry.js +96 -0
- package/dist/schema/index.d.ts +23 -0
- package/dist/schema/index.js +23 -0
- package/dist/schemas/v1/workflow.schema.json +1078 -0
- package/dist/services/agentSpecExecutionService.d.ts +106 -0
- package/dist/services/agentSpecExecutionService.js +334 -0
- package/dist/services/api.d.ts +115 -0
- package/dist/services/api.js +214 -0
- package/dist/services/apiVariableService.d.ts +114 -0
- package/dist/services/apiVariableService.js +338 -0
- package/dist/services/autoSaveService.d.ts +112 -0
- package/dist/services/autoSaveService.js +227 -0
- package/dist/services/categoriesApi.d.ts +14 -0
- package/dist/services/categoriesApi.js +49 -0
- package/dist/services/draftStorage.d.ts +171 -0
- package/dist/services/draftStorage.js +299 -0
- package/dist/services/dynamicSchemaService.d.ts +108 -0
- package/dist/services/dynamicSchemaService.js +444 -0
- package/dist/services/globalSave.d.ts +69 -0
- package/dist/services/globalSave.js +248 -0
- package/dist/services/historyService.d.ts +208 -0
- package/dist/services/historyService.js +321 -0
- package/dist/services/interruptService.d.ts +133 -0
- package/dist/services/interruptService.js +280 -0
- package/dist/services/nodeExecutionService.d.ts +63 -0
- package/dist/services/nodeExecutionService.js +266 -0
- package/dist/services/playgroundService.d.ts +130 -0
- package/dist/services/playgroundService.js +321 -0
- package/dist/services/portConfigApi.d.ts +14 -0
- package/dist/services/portConfigApi.js +54 -0
- package/dist/services/settingsService.d.ts +92 -0
- package/dist/services/settingsService.js +196 -0
- package/dist/services/toastService.d.ts +156 -0
- package/dist/services/toastService.js +265 -0
- package/dist/services/variableService.d.ts +141 -0
- package/dist/services/variableService.js +463 -0
- package/dist/services/workflowStorage.d.ts +37 -0
- package/dist/services/workflowStorage.js +116 -0
- package/dist/settings/index.d.ts +25 -0
- package/dist/settings/index.js +33 -0
- package/dist/stores/categoriesStore.svelte.d.ts +32 -0
- package/dist/stores/categoriesStore.svelte.js +77 -0
- package/dist/stores/editorStateMachine.svelte.d.ts +42 -0
- package/dist/stores/editorStateMachine.svelte.js +132 -0
- package/dist/stores/historyStore.svelte.d.ts +136 -0
- package/dist/stores/historyStore.svelte.js +207 -0
- package/dist/stores/interruptStore.svelte.d.ts +179 -0
- package/dist/stores/interruptStore.svelte.js +346 -0
- package/dist/stores/playgroundStore.svelte.d.ts +230 -0
- package/dist/stores/playgroundStore.svelte.js +515 -0
- package/dist/stores/portCoordinateStore.svelte.d.ts +66 -0
- package/dist/stores/portCoordinateStore.svelte.js +186 -0
- package/dist/stores/settingsStore.svelte.d.ts +158 -0
- package/dist/stores/settingsStore.svelte.js +544 -0
- package/dist/stores/workflowStore.svelte.d.ts +260 -0
- package/dist/stores/workflowStore.svelte.js +649 -0
- package/dist/stories/CanvasDecorator.svelte +49 -0
- package/dist/stories/CanvasDecorator.svelte.d.ts +8 -0
- package/dist/stories/NodeDecorator.svelte +73 -0
- package/dist/stories/NodeDecorator.svelte.d.ts +8 -0
- package/dist/stories/utils.d.ts +93 -0
- package/dist/stories/utils.js +122 -0
- package/dist/styles/base.css +1300 -0
- package/dist/styles/toast.css +35 -0
- package/dist/styles/tokens.css +475 -0
- package/dist/svelte-app.d.ts +150 -0
- package/dist/svelte-app.js +295 -0
- package/dist/types/agentspec.d.ts +318 -0
- package/dist/types/agentspec.js +48 -0
- package/dist/types/auth.d.ts +263 -0
- package/dist/types/auth.js +229 -0
- package/dist/types/config.d.ts +151 -0
- package/dist/types/config.js +7 -0
- package/dist/types/events.d.ts +190 -0
- package/dist/types/events.js +30 -0
- package/dist/types/index.d.ts +1234 -0
- package/dist/types/index.js +27 -0
- package/dist/types/interrupt.d.ts +390 -0
- package/dist/types/interrupt.js +145 -0
- package/dist/types/interruptState.d.ts +211 -0
- package/dist/types/interruptState.js +308 -0
- package/dist/types/playground.d.ts +351 -0
- package/dist/types/playground.js +95 -0
- package/dist/types/settings.d.ts +189 -0
- package/dist/types/settings.js +97 -0
- package/dist/types/uischema.d.ts +144 -0
- package/dist/types/uischema.js +51 -0
- package/dist/utils/colors.d.ts +288 -0
- package/dist/utils/colors.js +548 -0
- package/dist/utils/config.d.ts +37 -0
- package/dist/utils/config.js +226 -0
- package/dist/utils/connections.d.ts +125 -0
- package/dist/utils/connections.js +414 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.js +44 -0
- package/dist/utils/fetchWithAuth.d.ts +25 -0
- package/dist/utils/fetchWithAuth.js +34 -0
- package/dist/utils/handleIds.d.ts +35 -0
- package/dist/utils/handleIds.js +58 -0
- package/dist/utils/handlePositioning.d.ts +31 -0
- package/dist/utils/handlePositioning.js +35 -0
- package/dist/utils/icons.d.ts +106 -0
- package/dist/utils/icons.js +157 -0
- package/dist/utils/logger.d.ts +47 -0
- package/dist/utils/logger.js +72 -0
- package/dist/utils/nodeStatus.d.ts +53 -0
- package/dist/utils/nodeStatus.js +183 -0
- package/dist/utils/nodeTypes.d.ts +117 -0
- package/dist/utils/nodeTypes.js +244 -0
- package/dist/utils/nodeWrapper.d.ts +39 -0
- package/dist/utils/nodeWrapper.js +62 -0
- package/dist/utils/performanceUtils.d.ts +30 -0
- package/dist/utils/performanceUtils.js +108 -0
- package/dist/utils/sanitize.d.ts +19 -0
- package/dist/utils/sanitize.js +31 -0
- package/dist/utils/uischema.d.ts +52 -0
- package/dist/utils/uischema.js +88 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.js +39 -0
- package/package.json +292 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory workflow storage service
|
|
3
|
+
* This can be replaced with a database implementation later
|
|
4
|
+
*/
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
// In-memory storage
|
|
7
|
+
const workflows = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* Generate a unique workflow ID using UUID v4
|
|
10
|
+
*/
|
|
11
|
+
function generateWorkflowId() {
|
|
12
|
+
return uuidv4();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Save a workflow
|
|
16
|
+
*/
|
|
17
|
+
export async function saveWorkflow(workflow) {
|
|
18
|
+
const id = generateWorkflowId();
|
|
19
|
+
const newWorkflow = {
|
|
20
|
+
...workflow,
|
|
21
|
+
id,
|
|
22
|
+
metadata: {
|
|
23
|
+
version: '1.0.0',
|
|
24
|
+
createdAt: new Date().toISOString(),
|
|
25
|
+
updatedAt: new Date().toISOString(),
|
|
26
|
+
...workflow.metadata
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
workflows.set(id, newWorkflow);
|
|
30
|
+
return newWorkflow;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Update an existing workflow
|
|
34
|
+
*/
|
|
35
|
+
export async function updateWorkflow(id, workflow) {
|
|
36
|
+
const existing = workflows.get(id);
|
|
37
|
+
if (!existing) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const updatedWorkflow = {
|
|
41
|
+
...existing,
|
|
42
|
+
...workflow,
|
|
43
|
+
id, // Ensure ID doesn't change
|
|
44
|
+
metadata: {
|
|
45
|
+
version: existing.metadata?.version || '1.0.0',
|
|
46
|
+
createdAt: existing.metadata?.createdAt || new Date().toISOString(),
|
|
47
|
+
updatedAt: new Date().toISOString(),
|
|
48
|
+
author: workflow.metadata?.author || existing.metadata?.author,
|
|
49
|
+
tags: workflow.metadata?.tags || existing.metadata?.tags
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
workflows.set(id, updatedWorkflow);
|
|
53
|
+
return updatedWorkflow;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get a workflow by ID
|
|
57
|
+
*/
|
|
58
|
+
export async function getWorkflow(id) {
|
|
59
|
+
return workflows.get(id) || null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get all workflows with optional filtering
|
|
63
|
+
*/
|
|
64
|
+
export async function getWorkflows(options) {
|
|
65
|
+
let filteredWorkflows = Array.from(workflows.values());
|
|
66
|
+
// Apply search filter
|
|
67
|
+
if (options?.search) {
|
|
68
|
+
const searchLower = options.search.toLowerCase();
|
|
69
|
+
filteredWorkflows = filteredWorkflows.filter((workflow) => workflow.name.toLowerCase().includes(searchLower) ||
|
|
70
|
+
workflow.description?.toLowerCase().includes(searchLower) ||
|
|
71
|
+
workflow.metadata?.tags?.some((tag) => tag.toLowerCase().includes(searchLower)));
|
|
72
|
+
}
|
|
73
|
+
// Sort by updated date (newest first)
|
|
74
|
+
filteredWorkflows.sort((a, b) => new Date(b.metadata?.updatedAt || 0).getTime() -
|
|
75
|
+
new Date(a.metadata?.updatedAt || 0).getTime());
|
|
76
|
+
// Apply pagination
|
|
77
|
+
const offset = options?.offset || 0;
|
|
78
|
+
const limit = options?.limit || filteredWorkflows.length;
|
|
79
|
+
return filteredWorkflows.slice(offset, offset + limit);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Delete a workflow
|
|
83
|
+
*/
|
|
84
|
+
export async function deleteWorkflow(id) {
|
|
85
|
+
return workflows.delete(id);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get workflow count
|
|
89
|
+
*/
|
|
90
|
+
export async function getWorkflowCount() {
|
|
91
|
+
return workflows.size;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Initialize with sample workflows (for development)
|
|
95
|
+
*/
|
|
96
|
+
export async function initializeSampleWorkflows() {
|
|
97
|
+
// Only initialize if no workflows exist
|
|
98
|
+
if (workflows.size > 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Add a sample workflow
|
|
102
|
+
const sampleWorkflow = {
|
|
103
|
+
name: 'Sample Chat Workflow',
|
|
104
|
+
description: 'A simple workflow demonstrating chat completion',
|
|
105
|
+
nodes: [],
|
|
106
|
+
edges: [],
|
|
107
|
+
metadata: {
|
|
108
|
+
version: '1.0.0',
|
|
109
|
+
createdAt: new Date().toISOString(),
|
|
110
|
+
updatedAt: new Date().toISOString(),
|
|
111
|
+
author: 'System',
|
|
112
|
+
tags: ['sample', 'chat']
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
await saveWorkflow(sampleWorkflow);
|
|
116
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Settings Module
|
|
3
|
+
*
|
|
4
|
+
* Provides settings stores, services, and components for user-configurable
|
|
5
|
+
* preferences with hybrid persistence (localStorage + optional API sync).
|
|
6
|
+
*
|
|
7
|
+
* Theme stores and functions (theme, resolvedTheme, setTheme, toggleTheme,
|
|
8
|
+
* cycleTheme, initializeTheme) are exported from `@flowdrop/flowdrop/core`
|
|
9
|
+
* (sourced from settingsStore).
|
|
10
|
+
*
|
|
11
|
+
* @module settings
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { settingsStore, updateSettings, SettingsPanel } from "@flowdrop/flowdrop/settings";
|
|
16
|
+
* import { theme, setTheme } from "@flowdrop/flowdrop/core";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { default as ThemeToggle } from '../components/ThemeToggle.svelte';
|
|
20
|
+
export { default as SettingsPanel } from '../components/SettingsPanel.svelte';
|
|
21
|
+
export { default as SettingsModal } from '../components/SettingsModal.svelte';
|
|
22
|
+
export type { ThemeSettings, EditorSettings, UISettings, BehaviorSettings, ApiSettings, FlowDropSettings, SettingsCategory, PartialSettings, DeepPartial, SettingsChangeEvent, SettingsChangeCallback, SyncStatus, SettingsStoreState } from '../types/settings.js';
|
|
23
|
+
export { SETTINGS_CATEGORIES, SETTINGS_CATEGORY_LABELS, SETTINGS_CATEGORY_ICONS, DEFAULT_THEME_SETTINGS, DEFAULT_EDITOR_SETTINGS, DEFAULT_UI_SETTINGS, DEFAULT_BEHAVIOR_SETTINGS, DEFAULT_API_SETTINGS, DEFAULT_SETTINGS, SETTINGS_STORAGE_KEY } from '../types/settings.js';
|
|
24
|
+
export { getSettings as settingsStore, getThemeSettings as themeSettings, getEditorSettings as editorSettings, getUiSettings as uiSettings, getBehaviorSettings as behaviorSettings, getApiSettings as apiSettings, getSyncStatus as syncStatusStore, updateSettings, resetSettings, getSettings, initializeSettings, setSettingsService, syncSettingsToApi, loadSettingsFromApi, onSettingsChange } from '../stores/settingsStore.svelte.js';
|
|
25
|
+
export { settingsApi, SettingsService, createSettingsService, setSettingsEndpointConfig, getSettingsEndpointConfig } from '../services/settingsService.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Settings Module
|
|
3
|
+
*
|
|
4
|
+
* Provides settings stores, services, and components for user-configurable
|
|
5
|
+
* preferences with hybrid persistence (localStorage + optional API sync).
|
|
6
|
+
*
|
|
7
|
+
* Theme stores and functions (theme, resolvedTheme, setTheme, toggleTheme,
|
|
8
|
+
* cycleTheme, initializeTheme) are exported from `@flowdrop/flowdrop/core`
|
|
9
|
+
* (sourced from settingsStore).
|
|
10
|
+
*
|
|
11
|
+
* @module settings
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { settingsStore, updateSettings, SettingsPanel } from "@flowdrop/flowdrop/settings";
|
|
16
|
+
* import { theme, setTheme } from "@flowdrop/flowdrop/core";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Components
|
|
21
|
+
// ============================================================================
|
|
22
|
+
export { default as ThemeToggle } from '../components/ThemeToggle.svelte';
|
|
23
|
+
export { default as SettingsPanel } from '../components/SettingsPanel.svelte';
|
|
24
|
+
export { default as SettingsModal } from '../components/SettingsModal.svelte';
|
|
25
|
+
export { SETTINGS_CATEGORIES, SETTINGS_CATEGORY_LABELS, SETTINGS_CATEGORY_ICONS, DEFAULT_THEME_SETTINGS, DEFAULT_EDITOR_SETTINGS, DEFAULT_UI_SETTINGS, DEFAULT_BEHAVIOR_SETTINGS, DEFAULT_API_SETTINGS, DEFAULT_SETTINGS, SETTINGS_STORAGE_KEY } from '../types/settings.js';
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Settings Stores
|
|
28
|
+
// ============================================================================
|
|
29
|
+
export { getSettings as settingsStore, getThemeSettings as themeSettings, getEditorSettings as editorSettings, getUiSettings as uiSettings, getBehaviorSettings as behaviorSettings, getApiSettings as apiSettings, getSyncStatus as syncStatusStore, updateSettings, resetSettings, getSettings, initializeSettings, setSettingsService, syncSettingsToApi, loadSettingsFromApi, onSettingsChange } from '../stores/settingsStore.svelte.js';
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Settings Service
|
|
32
|
+
// ============================================================================
|
|
33
|
+
export { settingsApi, SettingsService, createSettingsService, setSettingsEndpointConfig, getSettingsEndpointConfig } from '../services/settingsService.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Categories Store for FlowDrop (Svelte 5 Runes)
|
|
3
|
+
*
|
|
4
|
+
* Manages category definitions with merged defaults and API-provided overrides.
|
|
5
|
+
* Exposes lookup helpers for icon, color, and label resolution.
|
|
6
|
+
*/
|
|
7
|
+
import type { CategoryDefinition, NodeCategory } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Get all category definitions, sorted by weight.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCategories(): CategoryDefinition[];
|
|
12
|
+
/**
|
|
13
|
+
* Initialize categories with API data, merging with defaults.
|
|
14
|
+
* API categories override defaults by name; custom categories are appended.
|
|
15
|
+
*/
|
|
16
|
+
export declare function initializeCategories(apiCategories: CategoryDefinition[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Get the display label for a category.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getCategoryLabel(category: NodeCategory): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the icon for a category.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getCategoryIcon(category: NodeCategory): string;
|
|
25
|
+
/**
|
|
26
|
+
* Get the color token for a category.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getCategoryColor(category: NodeCategory): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get the full category definition, or undefined if not found.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getCategoryDefinition(category: NodeCategory): CategoryDefinition | undefined;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Categories Store for FlowDrop (Svelte 5 Runes)
|
|
3
|
+
*
|
|
4
|
+
* Manages category definitions with merged defaults and API-provided overrides.
|
|
5
|
+
* Exposes lookup helpers for icon, color, and label resolution.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_CATEGORIES } from '../config/defaultCategories.js';
|
|
8
|
+
/**
|
|
9
|
+
* Internal reactive state holding the category definitions.
|
|
10
|
+
* Initialized with defaults, updated when API data is fetched.
|
|
11
|
+
*/
|
|
12
|
+
let categoriesState = $state([...DEFAULT_CATEGORIES]);
|
|
13
|
+
/**
|
|
14
|
+
* Derived lookup map: category name → CategoryDefinition
|
|
15
|
+
*/
|
|
16
|
+
let categoryMap = $derived((() => {
|
|
17
|
+
const map = new Map();
|
|
18
|
+
for (const cat of categoriesState) {
|
|
19
|
+
map.set(cat.name, cat);
|
|
20
|
+
}
|
|
21
|
+
return map;
|
|
22
|
+
})());
|
|
23
|
+
/**
|
|
24
|
+
* Get all category definitions, sorted by weight.
|
|
25
|
+
*/
|
|
26
|
+
export function getCategories() {
|
|
27
|
+
return [...categoriesState].sort((a, b) => (a.weight ?? 999) - (b.weight ?? 999));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Initialize categories with API data, merging with defaults.
|
|
31
|
+
* API categories override defaults by name; custom categories are appended.
|
|
32
|
+
*/
|
|
33
|
+
export function initializeCategories(apiCategories) {
|
|
34
|
+
const defaultMap = new Map();
|
|
35
|
+
for (const cat of DEFAULT_CATEGORIES) {
|
|
36
|
+
defaultMap.set(cat.name, cat);
|
|
37
|
+
}
|
|
38
|
+
// API categories override defaults by name
|
|
39
|
+
for (const cat of apiCategories) {
|
|
40
|
+
defaultMap.set(cat.name, {
|
|
41
|
+
...defaultMap.get(cat.name),
|
|
42
|
+
...cat
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
categoriesState = Array.from(defaultMap.values());
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the display label for a category.
|
|
49
|
+
*/
|
|
50
|
+
export function getCategoryLabel(category) {
|
|
51
|
+
const def = categoryMap.get(category);
|
|
52
|
+
if (def?.label)
|
|
53
|
+
return def.label;
|
|
54
|
+
// Auto-generate: capitalize each word
|
|
55
|
+
return category
|
|
56
|
+
.split(/[\s_-]+/)
|
|
57
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
58
|
+
.join(' ');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the icon for a category.
|
|
62
|
+
*/
|
|
63
|
+
export function getCategoryIcon(category) {
|
|
64
|
+
return categoryMap.get(category)?.icon ?? 'mdi:folder';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the color token for a category.
|
|
68
|
+
*/
|
|
69
|
+
export function getCategoryColor(category) {
|
|
70
|
+
return categoryMap.get(category)?.color ?? 'var(--fd-node-slate)';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the full category definition, or undefined if not found.
|
|
74
|
+
*/
|
|
75
|
+
export function getCategoryDefinition(category) {
|
|
76
|
+
return categoryMap.get(category);
|
|
77
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor State Machine for WorkflowEditor (Svelte 5 Runes)
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all reactive guard logic into explicit states and transitions.
|
|
5
|
+
* Replaces scattered boolean flags (isDraggingNode, isRestoringFromHistory,
|
|
6
|
+
* lastEditorStoreValue identity checks) with a single source of truth.
|
|
7
|
+
*
|
|
8
|
+
* @module stores/editorStateMachine
|
|
9
|
+
*/
|
|
10
|
+
export type EditorState = 'uninitialized' | 'loading' | 'idle' | 'dragging' | 'connecting' | 'dropping' | 'restoring' | 'deleting' | 'updating_node';
|
|
11
|
+
export type EditorEvent = 'WORKFLOW_LOADED' | 'LOAD_COMPLETE' | 'START_DRAG' | 'STOP_DRAG' | 'START_CONNECT' | 'CONNECTION_MADE' | 'CONNECTION_CANCELLED' | 'START_DROP' | 'DROP_COMPLETE' | 'DROP_CANCELLED' | 'START_RESTORE' | 'RESTORE_COMPLETE' | 'EXTERNAL_STORE_CHANGE' | 'SYNC_COMPLETE' | 'START_DELETE' | 'DELETE_COMPLETE' | 'START_NODE_UPDATE' | 'UPDATE_COMPLETE' | 'WORKFLOW_SWITCHED' | 'WORKFLOW_CLEARED' | 'RESET';
|
|
12
|
+
/** What operations are permitted in the current state */
|
|
13
|
+
export interface StatePermissions {
|
|
14
|
+
/** Whether the editor can write to the global workflow store */
|
|
15
|
+
canWriteToStore: boolean;
|
|
16
|
+
/** Whether the editor can push to undo/redo history */
|
|
17
|
+
canPushHistory: boolean;
|
|
18
|
+
/** Suppress the store → flowNodes/flowEdges sync effect */
|
|
19
|
+
suppressEffect: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface EditorStateMachine {
|
|
22
|
+
/** Current state (reactive via $state) */
|
|
23
|
+
readonly current: EditorState;
|
|
24
|
+
/** Current permissions (reactive, derived from current state) */
|
|
25
|
+
readonly permissions: StatePermissions;
|
|
26
|
+
/** Attempt a transition. Returns true if the transition was valid. */
|
|
27
|
+
send(event: EditorEvent): boolean;
|
|
28
|
+
/** Check if an event is valid from the current state */
|
|
29
|
+
canSend(event: EditorEvent): boolean;
|
|
30
|
+
/** Subscribe to state changes (for debugging/logging). Returns unsubscribe function. */
|
|
31
|
+
onTransition(callback: (from: EditorState, event: EditorEvent, to: EditorState) => void): () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create an editor state machine instance.
|
|
35
|
+
*
|
|
36
|
+
* Uses Svelte 5 `$state` rune for reactivity so that components can
|
|
37
|
+
* read `machine.current` and `machine.permissions` inside `$derived`
|
|
38
|
+
* or `$effect` blocks and react to state changes.
|
|
39
|
+
*
|
|
40
|
+
* Each WorkflowEditor component instance should create its own machine.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createEditorStateMachine(initialState?: EditorState): EditorStateMachine;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor State Machine for WorkflowEditor (Svelte 5 Runes)
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all reactive guard logic into explicit states and transitions.
|
|
5
|
+
* Replaces scattered boolean flags (isDraggingNode, isRestoringFromHistory,
|
|
6
|
+
* lastEditorStoreValue identity checks) with a single source of truth.
|
|
7
|
+
*
|
|
8
|
+
* @module stores/editorStateMachine
|
|
9
|
+
*/
|
|
10
|
+
import { logger } from '../utils/logger.js';
|
|
11
|
+
const transitions = {
|
|
12
|
+
uninitialized: {
|
|
13
|
+
WORKFLOW_LOADED: 'loading'
|
|
14
|
+
},
|
|
15
|
+
loading: {
|
|
16
|
+
LOAD_COMPLETE: 'idle'
|
|
17
|
+
},
|
|
18
|
+
idle: {
|
|
19
|
+
START_DRAG: 'dragging',
|
|
20
|
+
START_CONNECT: 'connecting',
|
|
21
|
+
START_DROP: 'dropping',
|
|
22
|
+
START_RESTORE: 'restoring',
|
|
23
|
+
EXTERNAL_STORE_CHANGE: 'loading',
|
|
24
|
+
START_DELETE: 'deleting',
|
|
25
|
+
START_NODE_UPDATE: 'updating_node',
|
|
26
|
+
WORKFLOW_SWITCHED: 'loading',
|
|
27
|
+
WORKFLOW_CLEARED: 'uninitialized'
|
|
28
|
+
},
|
|
29
|
+
dragging: {
|
|
30
|
+
STOP_DRAG: 'idle'
|
|
31
|
+
},
|
|
32
|
+
connecting: {
|
|
33
|
+
CONNECTION_MADE: 'idle',
|
|
34
|
+
CONNECTION_CANCELLED: 'idle'
|
|
35
|
+
},
|
|
36
|
+
dropping: {
|
|
37
|
+
DROP_COMPLETE: 'idle',
|
|
38
|
+
DROP_CANCELLED: 'idle'
|
|
39
|
+
},
|
|
40
|
+
restoring: {
|
|
41
|
+
RESTORE_COMPLETE: 'idle'
|
|
42
|
+
},
|
|
43
|
+
deleting: {
|
|
44
|
+
DELETE_COMPLETE: 'idle'
|
|
45
|
+
},
|
|
46
|
+
updating_node: {
|
|
47
|
+
UPDATE_COMPLETE: 'idle'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/** Global transitions valid from any state */
|
|
51
|
+
const globalTransitions = {
|
|
52
|
+
RESET: 'uninitialized',
|
|
53
|
+
WORKFLOW_CLEARED: 'uninitialized'
|
|
54
|
+
};
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Permissions table
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
const permissions = {
|
|
59
|
+
uninitialized: { canWriteToStore: false, canPushHistory: false, suppressEffect: false },
|
|
60
|
+
loading: { canWriteToStore: false, canPushHistory: false, suppressEffect: false },
|
|
61
|
+
idle: { canWriteToStore: true, canPushHistory: true, suppressEffect: false },
|
|
62
|
+
dragging: { canWriteToStore: true, canPushHistory: false, suppressEffect: true },
|
|
63
|
+
connecting: { canWriteToStore: true, canPushHistory: false, suppressEffect: true },
|
|
64
|
+
dropping: { canWriteToStore: true, canPushHistory: false, suppressEffect: true },
|
|
65
|
+
restoring: { canWriteToStore: true, canPushHistory: false, suppressEffect: true },
|
|
66
|
+
deleting: { canWriteToStore: true, canPushHistory: false, suppressEffect: true },
|
|
67
|
+
updating_node: { canWriteToStore: true, canPushHistory: false, suppressEffect: true }
|
|
68
|
+
};
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Factory
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
/**
|
|
73
|
+
* Create an editor state machine instance.
|
|
74
|
+
*
|
|
75
|
+
* Uses Svelte 5 `$state` rune for reactivity so that components can
|
|
76
|
+
* read `machine.current` and `machine.permissions` inside `$derived`
|
|
77
|
+
* or `$effect` blocks and react to state changes.
|
|
78
|
+
*
|
|
79
|
+
* Each WorkflowEditor component instance should create its own machine.
|
|
80
|
+
*/
|
|
81
|
+
export function createEditorStateMachine(initialState = 'uninitialized') {
|
|
82
|
+
let _current = $state(initialState);
|
|
83
|
+
let _permissions = $state(permissions[initialState]);
|
|
84
|
+
const _listeners = new Set();
|
|
85
|
+
function send(event) {
|
|
86
|
+
// Check global transitions first (valid from any state)
|
|
87
|
+
const globalTarget = globalTransitions[event];
|
|
88
|
+
if (globalTarget !== undefined) {
|
|
89
|
+
const from = _current;
|
|
90
|
+
_current = globalTarget;
|
|
91
|
+
_permissions = permissions[globalTarget];
|
|
92
|
+
for (const cb of _listeners)
|
|
93
|
+
cb(from, event, globalTarget);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
// Check state-specific transitions
|
|
97
|
+
const stateTransitions = transitions[_current];
|
|
98
|
+
const target = stateTransitions?.[event];
|
|
99
|
+
if (target === undefined) {
|
|
100
|
+
logger.warn(`[EditorFSM] Invalid transition: ${_current} + ${event}`);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
const from = _current;
|
|
104
|
+
_current = target;
|
|
105
|
+
_permissions = permissions[target];
|
|
106
|
+
for (const cb of _listeners)
|
|
107
|
+
cb(from, event, target);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
function canSend(event) {
|
|
111
|
+
if (globalTransitions[event] !== undefined)
|
|
112
|
+
return true;
|
|
113
|
+
return transitions[_current]?.[event] !== undefined;
|
|
114
|
+
}
|
|
115
|
+
function onTransition(callback) {
|
|
116
|
+
_listeners.add(callback);
|
|
117
|
+
return () => {
|
|
118
|
+
_listeners.delete(callback);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
get current() {
|
|
123
|
+
return _current;
|
|
124
|
+
},
|
|
125
|
+
get permissions() {
|
|
126
|
+
return _permissions;
|
|
127
|
+
},
|
|
128
|
+
send,
|
|
129
|
+
canSend,
|
|
130
|
+
onTransition
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Store for FlowDrop (Svelte 5 Runes)
|
|
3
|
+
*
|
|
4
|
+
* Provides reactive Svelte 5 rune-based bindings for the history service.
|
|
5
|
+
* Exposes undo/redo state and actions for the workflow editor.
|
|
6
|
+
*
|
|
7
|
+
* @module stores/historyStore
|
|
8
|
+
*/
|
|
9
|
+
import { type HistoryState, type PushOptions } from '../services/historyService.js';
|
|
10
|
+
import type { Workflow } from '../types/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Clean up the historyService subscription created at module initialisation.
|
|
13
|
+
* Call this when tearing down the history store (e.g., in tests or on app
|
|
14
|
+
* unmount) to prevent memory leaks.
|
|
15
|
+
*/
|
|
16
|
+
export declare function cleanupHistorySubscription(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Get the current history state snapshot.
|
|
19
|
+
*
|
|
20
|
+
* Use this for binding to UI elements like undo/redo buttons.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```svelte
|
|
24
|
+
* <script>
|
|
25
|
+
* import { getHistoryState } from "./historyStore.svelte.js";
|
|
26
|
+
*
|
|
27
|
+
* const state = $derived(getHistoryState());
|
|
28
|
+
* </script>
|
|
29
|
+
*
|
|
30
|
+
* <button disabled={!state.canUndo} onclick={historyActions.undo}>
|
|
31
|
+
* Undo
|
|
32
|
+
* </button>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function getHistoryState(): HistoryState;
|
|
36
|
+
/**
|
|
37
|
+
* Convenience getter for canUndo state.
|
|
38
|
+
*
|
|
39
|
+
* @returns Whether undo is currently available
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCanUndo(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Convenience getter for canRedo state.
|
|
44
|
+
*
|
|
45
|
+
* @returns Whether redo is currently available
|
|
46
|
+
*/
|
|
47
|
+
export declare function getCanRedo(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Set the callback for restoring workflow state
|
|
50
|
+
*
|
|
51
|
+
* This callback is invoked when undo/redo operations return a workflow.
|
|
52
|
+
* Use this to update the workflow store or other state management.
|
|
53
|
+
*
|
|
54
|
+
* @param callback - Function to call with restored workflow
|
|
55
|
+
*/
|
|
56
|
+
export declare function setOnRestoreCallback(callback: ((workflow: Workflow) => void) | null): void;
|
|
57
|
+
/**
|
|
58
|
+
* History actions for undo/redo operations
|
|
59
|
+
*
|
|
60
|
+
* Use these functions to interact with the history service.
|
|
61
|
+
* They handle the coordination between history and workflow state.
|
|
62
|
+
*/
|
|
63
|
+
export declare const historyActions: {
|
|
64
|
+
/**
|
|
65
|
+
* Initialize history with the current workflow
|
|
66
|
+
*
|
|
67
|
+
* Call this when loading a new workflow to reset history.
|
|
68
|
+
*
|
|
69
|
+
* @param workflow - The initial workflow state
|
|
70
|
+
*/
|
|
71
|
+
initialize: (workflow: Workflow) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Push the current state to history before making changes
|
|
74
|
+
*
|
|
75
|
+
* Call this BEFORE modifying the workflow to capture the "before" state.
|
|
76
|
+
*
|
|
77
|
+
* @param workflow - The current workflow state (before changes)
|
|
78
|
+
* @param options - Options for this history entry
|
|
79
|
+
*/
|
|
80
|
+
pushState: (workflow: Workflow, options?: PushOptions) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Undo the last change
|
|
83
|
+
*
|
|
84
|
+
* Restores the previous workflow state and invokes the restore callback.
|
|
85
|
+
*
|
|
86
|
+
* @returns true if undo was successful, false if at beginning of history
|
|
87
|
+
*/
|
|
88
|
+
undo: () => boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Redo the last undone change
|
|
91
|
+
*
|
|
92
|
+
* Restores the next workflow state and invokes the restore callback.
|
|
93
|
+
*
|
|
94
|
+
* @returns true if redo was successful, false if at end of history
|
|
95
|
+
*/
|
|
96
|
+
redo: () => boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Start a transaction for grouping multiple changes
|
|
99
|
+
*
|
|
100
|
+
* All changes during a transaction are combined into a single undo entry.
|
|
101
|
+
*
|
|
102
|
+
* @param workflow - The current workflow state (before changes)
|
|
103
|
+
* @param description - Description for the combined change
|
|
104
|
+
*/
|
|
105
|
+
startTransaction: (workflow: Workflow, description?: string) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Commit the current transaction
|
|
108
|
+
*/
|
|
109
|
+
commitTransaction: () => void;
|
|
110
|
+
/**
|
|
111
|
+
* Cancel the current transaction without committing
|
|
112
|
+
*/
|
|
113
|
+
cancelTransaction: () => void;
|
|
114
|
+
/**
|
|
115
|
+
* Clear all history
|
|
116
|
+
*
|
|
117
|
+
* @param currentWorkflow - If provided, keeps this as the initial state
|
|
118
|
+
*/
|
|
119
|
+
clear: (currentWorkflow?: Workflow) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Check if undo is available
|
|
122
|
+
*/
|
|
123
|
+
canUndo: () => boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Check if redo is available
|
|
126
|
+
*/
|
|
127
|
+
canRedo: () => boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Get the current history state synchronously
|
|
130
|
+
*
|
|
131
|
+
* @returns The current history state
|
|
132
|
+
*/
|
|
133
|
+
getState: () => HistoryState;
|
|
134
|
+
};
|
|
135
|
+
export type { HistoryEntry, HistoryState, PushOptions } from '../services/historyService.js';
|
|
136
|
+
export { HistoryService, historyService } from '../services/historyService.js';
|