@flowdrop/flowdrop 2.13.0 → 2.15.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/CHANGELOG.md +82 -0
- package/dist/commands/executor.js +58 -8
- package/dist/commands/parser.js +3 -3
- package/dist/commands/types.d.ts +8 -2
- package/dist/commands/uiActionTarget.d.ts +24 -0
- package/dist/commands/uiActionTarget.js +31 -0
- package/dist/commands/validate.d.ts +15 -0
- package/dist/commands/validate.js +115 -0
- package/dist/components/App.svelte +44 -2
- package/dist/components/App.svelte.d.ts +3 -1
- package/dist/components/Button.svelte +7 -7
- package/dist/components/Button.svelte.d.ts +10 -0
- package/dist/components/CanvasBanner.svelte +19 -6
- package/dist/components/CanvasBanner.svelte.d.ts +15 -3
- package/dist/components/CanvasContextMenu.svelte +9 -9
- package/dist/components/CanvasContextMenu.svelte.d.ts +10 -0
- package/dist/components/CanvasToolbar.svelte +8 -7
- package/dist/components/CanvasToolbar.svelte.d.ts +10 -0
- package/dist/components/CanvasZoomControls.svelte +10 -9
- package/dist/components/CanvasZoomControls.svelte.d.ts +13 -0
- package/dist/components/ConfigForm.svelte +51 -18
- package/dist/components/ConfigForm.svelte.d.ts +20 -1
- package/dist/components/ConfigPanel.svelte +9 -5
- package/dist/components/ConfigPanel.svelte.d.ts +10 -0
- package/dist/components/EditorStatusBar.svelte +6 -5
- package/dist/components/EditorStatusBar.svelte.d.ts +7 -0
- package/dist/components/ExternalLinkRow.svelte +16 -1
- package/dist/components/ExternalLinkRow.svelte.d.ts +5 -0
- package/dist/components/FlowDropEdge.svelte +15 -12
- package/dist/components/FlowDropEdge.svelte.d.ts +16 -0
- package/dist/components/InterfaceTag.svelte +13 -15
- package/dist/components/InterfaceTag.svelte.d.ts +19 -0
- package/dist/components/LoadingSpinner.svelte +8 -2
- package/dist/components/LoadingSpinner.svelte.d.ts +9 -0
- package/dist/components/Logo.svelte +11 -0
- package/dist/components/Logo.svelte.d.ts +9 -0
- package/dist/components/LogoWordmark.svelte +8 -3
- package/dist/components/LogoWordmark.svelte.d.ts +9 -0
- package/dist/components/LoopbackLanes.svelte +12 -6
- package/dist/components/LoopbackLanes.svelte.d.ts +13 -0
- package/dist/components/MarkdownDisplay.svelte +10 -3
- package/dist/components/MarkdownDisplay.svelte.d.ts +11 -0
- package/dist/components/Navbar.svelte +13 -5
- package/dist/components/Navbar.svelte.d.ts +14 -0
- package/dist/components/NodeInspector.svelte +7 -8
- package/dist/components/NodeInspector.svelte.d.ts +10 -0
- package/dist/components/NodeSidebar.svelte +9 -3
- package/dist/components/NodeSidebar.svelte.d.ts +10 -0
- package/dist/components/NodeStatusOverlay.svelte +30 -19
- package/dist/components/NodeStatusOverlay.svelte.d.ts +19 -0
- package/dist/components/NodeSwapPicker.svelte +1 -1
- package/dist/components/RunBar.svelte +10 -13
- package/dist/components/RunBar.svelte.d.ts +15 -0
- package/dist/components/RunsMenu.svelte +14 -13
- package/dist/components/RunsMenu.svelte.d.ts +15 -0
- package/dist/components/SchemaForm.svelte +10 -13
- package/dist/components/SchemaForm.svelte.d.ts +51 -0
- package/dist/components/SettingsPanel.svelte +5 -5
- package/dist/components/StatusIcon.svelte +14 -3
- package/dist/components/StatusIcon.svelte.d.ts +15 -0
- package/dist/components/StatusLabel.svelte +10 -2
- package/dist/components/StatusLabel.svelte.d.ts +11 -0
- package/dist/components/ThemeToggle.svelte +8 -5
- package/dist/components/ThemeToggle.svelte.d.ts +10 -0
- package/dist/components/UniversalNode.svelte +13 -5
- package/dist/components/UniversalNode.svelte.d.ts +15 -0
- package/dist/components/WorkflowInterfaceEntryCard.svelte +1 -1
- package/dist/components/WorkflowInterfaceEntryComposer.svelte +1 -2
- package/dist/components/ZoomTier.svelte +13 -10
- package/dist/components/ZoomTier.svelte.d.ts +14 -0
- package/dist/components/console/CommandConsole.svelte +9 -3
- package/dist/components/console/CommandConsole.svelte.d.ts +10 -0
- package/dist/components/console/ConsoleAutocomplete.svelte +4 -4
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +5 -0
- package/dist/components/console/ConsoleInput.svelte +6 -4
- package/dist/components/console/ConsoleInput.svelte.d.ts +7 -0
- package/dist/components/console/ConsoleOutput.svelte +5 -3
- package/dist/components/console/ConsoleOutput.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleStrip.svelte +9 -5
- package/dist/components/console/ConsoleStrip.svelte.d.ts +10 -0
- package/dist/components/form/FieldFactory.svelte +6 -2
- package/dist/components/form/FieldFactory.svelte.d.ts +46 -0
- package/dist/components/form/FormArray.svelte +9 -16
- package/dist/components/form/FormArray.svelte.d.ts +10 -0
- package/dist/components/form/FormArrayRows.svelte +8 -8
- package/dist/components/form/FormArrayRows.svelte.d.ts +11 -0
- package/dist/components/form/FormAutocomplete.svelte +6 -3
- package/dist/components/form/FormAutocomplete.svelte.d.ts +23 -0
- package/dist/components/form/FormCheckboxGroup.svelte +5 -5
- package/dist/components/form/FormCheckboxGroup.svelte.d.ts +6 -0
- package/dist/components/form/FormCodeEditor.svelte +8 -13
- package/dist/components/form/FormCodeEditor.svelte.d.ts +9 -0
- package/dist/components/form/FormField.svelte +7 -8
- package/dist/components/form/FormField.svelte.d.ts +10 -0
- package/dist/components/form/FormFieldLight.svelte +6 -5
- package/dist/components/form/FormFieldLight.svelte.d.ts +8 -0
- package/dist/components/form/FormFieldWrapper.svelte +8 -8
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +9 -0
- package/dist/components/form/FormFieldset.svelte +6 -12
- package/dist/components/form/FormFieldset.svelte.d.ts +7 -0
- package/dist/components/form/FormMarkdownEditor.svelte +8 -15
- package/dist/components/form/FormMarkdownEditor.svelte.d.ts +9 -0
- package/dist/components/form/FormNumberField.svelte +5 -7
- package/dist/components/form/FormNumberField.svelte.d.ts +6 -0
- package/dist/components/form/FormPorts.svelte +133 -27
- package/dist/components/form/FormPorts.svelte.d.ts +19 -0
- package/dist/components/form/FormRangeField.svelte +5 -9
- package/dist/components/form/FormRangeField.svelte.d.ts +6 -0
- package/dist/components/form/FormSelect.svelte +5 -7
- package/dist/components/form/FormSelect.svelte.d.ts +6 -0
- package/dist/components/form/FormTemplateEditor.svelte +8 -16
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +9 -0
- package/dist/components/form/FormTextField.svelte +5 -7
- package/dist/components/form/FormTextField.svelte.d.ts +6 -0
- package/dist/components/form/FormTextarea.svelte +5 -7
- package/dist/components/form/FormTextarea.svelte.d.ts +6 -0
- package/dist/components/form/FormToggle.svelte +6 -8
- package/dist/components/form/FormToggle.svelte.d.ts +7 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +5 -9
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +7 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +6 -6
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +7 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte +6 -5
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +7 -0
- package/dist/components/interrupt/FormPrompt.svelte +6 -6
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +7 -0
- package/dist/components/interrupt/InterruptBubble.svelte +10 -9
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +11 -0
- package/dist/components/interrupt/ReviewPrompt.svelte +5 -6
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +7 -0
- package/dist/components/interrupt/TextInputPrompt.svelte +6 -6
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +7 -0
- package/dist/components/nodes/AtomNode.svelte +31 -6
- package/dist/components/nodes/AtomNode.svelte.d.ts +15 -0
- package/dist/components/nodes/CaptionNode.svelte +50 -7
- package/dist/components/nodes/CaptionNode.svelte.d.ts +13 -0
- package/dist/components/nodes/GatewayNode.svelte +18 -11
- package/dist/components/nodes/GatewayNode.svelte.d.ts +21 -0
- package/dist/components/nodes/IdeaNode.svelte +47 -6
- package/dist/components/nodes/IdeaNode.svelte.d.ts +17 -0
- package/dist/components/nodes/NodeCard.svelte +26 -18
- package/dist/components/nodes/NodeCard.svelte.d.ts +20 -0
- package/dist/components/nodes/NodeConfigButton.svelte +15 -2
- package/dist/components/nodes/NodeConfigButton.svelte.d.ts +11 -0
- package/dist/components/nodes/NodeProblemMark.svelte +15 -10
- package/dist/components/nodes/NodeProblemMark.svelte.d.ts +16 -0
- package/dist/components/nodes/NodeTip.svelte +10 -7
- package/dist/components/nodes/NodeTip.svelte.d.ts +13 -0
- package/dist/components/nodes/NotesNode.svelte +30 -0
- package/dist/components/nodes/NotesNode.svelte.d.ts +14 -0
- package/dist/components/nodes/SimpleNode.svelte +35 -8
- package/dist/components/nodes/SimpleNode.svelte.d.ts +17 -0
- package/dist/components/nodes/SquareNode.svelte +38 -8
- package/dist/components/nodes/SquareNode.svelte.d.ts +17 -0
- package/dist/components/nodes/TerminalNode.svelte +24 -10
- package/dist/components/nodes/TerminalNode.svelte.d.ts +17 -0
- package/dist/components/nodes/ToolNode.svelte +14 -5
- package/dist/components/nodes/ToolNode.svelte.d.ts +15 -0
- package/dist/components/nodes/WorkflowNode.svelte +18 -15
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +21 -0
- package/dist/components/playground/ChatBubble.svelte +4 -3
- package/dist/components/playground/ChatBubble.svelte.d.ts +5 -0
- package/dist/components/playground/ChatInput.svelte +11 -6
- package/dist/components/playground/ChatInput.svelte.d.ts +14 -0
- package/dist/components/playground/ChatPanel.svelte +15 -7
- package/dist/components/playground/ChatPanel.svelte.d.ts +17 -0
- package/dist/components/playground/ControlPanel.svelte +26 -9
- package/dist/components/playground/ControlPanel.svelte.d.ts +29 -0
- package/dist/components/playground/DockedPlayground.svelte +7 -10
- package/dist/components/playground/DockedPlayground.svelte.d.ts +10 -0
- package/dist/components/playground/ExecutionConsole.svelte +10 -5
- package/dist/components/playground/ExecutionConsole.svelte.d.ts +12 -0
- package/dist/components/playground/ExecutionList.svelte +13 -0
- package/dist/components/playground/ExecutionList.svelte.d.ts +11 -0
- package/dist/components/playground/ExecutionLogs.svelte +6 -9
- package/dist/components/playground/ExecutionLogs.svelte.d.ts +7 -0
- package/dist/components/playground/HeaderMenu.svelte +6 -8
- package/dist/components/playground/HeaderMenu.svelte.d.ts +9 -0
- package/dist/components/playground/HierarchyTrail.svelte +6 -6
- package/dist/components/playground/HierarchyTrail.svelte.d.ts +8 -0
- package/dist/components/playground/InputCollector.svelte +6 -5
- package/dist/components/playground/InputCollector.svelte.d.ts +7 -0
- package/dist/components/playground/InputFields.svelte +8 -12
- package/dist/components/playground/InputFields.svelte.d.ts +9 -0
- package/dist/components/playground/InterfaceInputForm.svelte +6 -13
- package/dist/components/playground/InterfaceInputForm.svelte.d.ts +9 -0
- package/dist/components/playground/InterfaceJsonInput.svelte +6 -5
- package/dist/components/playground/InterfaceJsonInput.svelte.d.ts +8 -0
- package/dist/components/playground/LogRow.svelte +4 -5
- package/dist/components/playground/LogRow.svelte.d.ts +6 -0
- package/dist/components/playground/MessageBubble.svelte +13 -7
- package/dist/components/playground/MessageBubble.svelte.d.ts +15 -0
- package/dist/components/playground/MessageCard.svelte +5 -2
- package/dist/components/playground/MessageCard.svelte.d.ts +6 -0
- package/dist/components/playground/MessageMarkdown.svelte +8 -9
- package/dist/components/playground/MessageMarkdown.svelte.d.ts +11 -0
- package/dist/components/playground/MessageNotice.svelte +7 -0
- package/dist/components/playground/MessageNotice.svelte.d.ts +5 -0
- package/dist/components/playground/MessageStream.svelte +8 -6
- package/dist/components/playground/MessageStream.svelte.d.ts +11 -0
- package/dist/components/playground/MessageTagChip.svelte +7 -7
- package/dist/components/playground/MessageTagChip.svelte.d.ts +10 -0
- package/dist/components/playground/MessageTagStrip.svelte +6 -3
- package/dist/components/playground/MessageTagStrip.svelte.d.ts +8 -0
- package/dist/components/playground/OriginBadge.svelte +7 -4
- package/dist/components/playground/OriginBadge.svelte.d.ts +8 -0
- package/dist/components/playground/PipelineKanbanView.svelte +14 -0
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +12 -0
- package/dist/components/playground/PipelinePanel.svelte +14 -0
- package/dist/components/playground/PipelinePanel.svelte.d.ts +12 -0
- package/dist/components/playground/PipelineTableView.svelte +14 -0
- package/dist/components/playground/PipelineTableView.svelte.d.ts +12 -0
- package/dist/components/playground/Playground.svelte +17 -11
- package/dist/components/playground/Playground.svelte.d.ts +20 -0
- package/dist/components/playground/PlaygroundApp.svelte +24 -10
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +26 -0
- package/dist/components/playground/PlaygroundHeader.svelte +8 -12
- package/dist/components/playground/PlaygroundHeader.svelte.d.ts +11 -0
- package/dist/components/playground/PlaygroundModal.svelte +6 -8
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +7 -0
- package/dist/components/playground/PlaygroundStudio.svelte +9 -0
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +7 -0
- package/dist/components/playground/PlaygroundSurface.svelte +19 -14
- package/dist/components/playground/PlaygroundSurface.svelte.d.ts +20 -0
- package/dist/components/playground/SessionManager.svelte +6 -5
- package/dist/components/playground/SessionManager.svelte.d.ts +7 -0
- package/dist/components/playground/StepsSummary.svelte +8 -9
- package/dist/components/playground/StepsSummary.svelte.d.ts +10 -0
- package/dist/components/primitives/Button.svelte +15 -7
- package/dist/components/primitives/Button.svelte.d.ts +18 -1
- package/dist/components/primitives/Card.svelte +8 -6
- package/dist/components/primitives/Card.svelte.d.ts +11 -0
- package/dist/components/primitives/Checkbox.svelte +8 -5
- package/dist/components/primitives/Checkbox.svelte.d.ts +11 -0
- package/dist/components/primitives/Chip.svelte +8 -4
- package/dist/components/primitives/Chip.svelte.d.ts +11 -0
- package/dist/components/primitives/Combobox.svelte +27 -18
- package/dist/components/primitives/Combobox.svelte.d.ts +33 -0
- package/dist/components/primitives/Composer.svelte +15 -16
- package/dist/components/primitives/Composer.svelte.d.ts +20 -0
- package/dist/components/primitives/EmptyState.svelte +9 -3
- package/dist/components/primitives/EmptyState.svelte.d.ts +11 -0
- package/dist/components/primitives/Field.svelte +12 -9
- package/dist/components/primitives/Field.svelte.d.ts +16 -0
- package/dist/components/primitives/IconButton.svelte +10 -5
- package/dist/components/primitives/IconButton.svelte.d.ts +13 -0
- package/dist/components/primitives/Menu.svelte +15 -14
- package/dist/components/primitives/Menu.svelte.d.ts +20 -0
- package/dist/components/primitives/Notice.svelte +11 -8
- package/dist/components/primitives/Notice.svelte.d.ts +14 -0
- package/dist/components/primitives/PanelHeader.svelte +10 -7
- package/dist/components/primitives/PanelHeader.svelte.d.ts +13 -0
- package/dist/components/primitives/Segmented.svelte +11 -4
- package/dist/components/primitives/Segmented.svelte.d.ts +14 -0
- package/dist/components/primitives/Select.svelte +13 -16
- package/dist/components/primitives/Select.svelte.d.ts +18 -0
- package/dist/components/primitives/StatusPill.svelte +11 -8
- package/dist/components/primitives/StatusPill.svelte.d.ts +15 -0
- package/dist/components/primitives/Switch.svelte +9 -6
- package/dist/components/primitives/Switch.svelte.d.ts +12 -0
- package/dist/components/primitives/Tabs.svelte +16 -15
- package/dist/components/primitives/Tabs.svelte.d.ts +22 -0
- package/dist/components/primitives/Toolbar.svelte +14 -13
- package/dist/components/primitives/Toolbar.svelte.d.ts +18 -0
- package/dist/components/primitives/ToolbarSeparator.svelte +5 -4
- package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +7 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/editor/index.d.ts +3 -3
- package/dist/index.d.ts +3 -2
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/toWorkflow.d.ts +8 -7
- package/dist/layout/toWorkflow.js +20 -40
- package/dist/messages/defaults.d.ts +24 -0
- package/dist/messages/defaults.js +15 -0
- package/dist/skins/graphite.d.ts +1 -1
- package/dist/skins/graphite.js +1 -1
- package/dist/stores/settingsStore.svelte.js +3 -0
- package/dist/stores/workflowStore.svelte.d.ts +10 -0
- package/dist/stores/workflowStore.svelte.js +65 -20
- package/dist/styles/base.css +2 -126
- package/dist/styles/tokenAliases.js +1 -0
- package/dist/styles/tokens.css +9 -5
- package/dist/svelte-app.d.ts +63 -2
- package/dist/svelte-app.js +144 -1
- package/dist/themes/classic.d.ts +9 -0
- package/dist/themes/classic.js +16 -0
- package/dist/themes/index.d.ts +7 -2
- package/dist/themes/index.js +20 -10
- package/dist/types/events.d.ts +18 -1
- package/dist/types/index.d.ts +10 -0
- package/dist/types/settings.d.ts +6 -2
- package/dist/types/theme.d.ts +6 -2
- package/dist/utils/externalEdit.svelte.d.ts +48 -0
- package/dist/utils/externalEdit.svelte.js +62 -0
- package/dist/utils/inspectorContext.d.ts +5 -0
- package/dist/utils/playgroundChat.d.ts +10 -0
- package/dist/utils/playgroundChat.js +25 -0
- package/dist/utils/portExposure.d.ts +24 -1
- package/dist/utils/portExposure.js +46 -13
- package/dist/utils/portUtils.d.ts +5 -1
- package/dist/utils/portUtils.js +15 -4
- package/package.json +2 -1
- package/dist/components/IconButton.svelte +0 -80
- package/dist/components/IconButton.svelte.d.ts +0 -30
- package/dist/themes/default.d.ts +0 -2
- package/dist/themes/default.js +0 -9
package/dist/svelte-app.js
CHANGED
|
@@ -19,6 +19,12 @@ import { initializeSettings, getHostColorSchemeRegistration, releaseHostColorSch
|
|
|
19
19
|
import { logger } from './utils/logger.js';
|
|
20
20
|
import { globalSaveWorkflow, globalExportWorkflow } from './services/globalSave.js';
|
|
21
21
|
import { whenWorkflowLoaded } from './utils/whenWorkflowLoaded.svelte.js';
|
|
22
|
+
import { parseCommand } from './commands/parser.js';
|
|
23
|
+
import { executeCommand } from './commands/executor.js';
|
|
24
|
+
import { isSessionLine } from './commands/session.js';
|
|
25
|
+
import { createStoreCommandContext } from './commands/storeIntegration.svelte.js';
|
|
26
|
+
import { dispatchUIAction } from './commands/uiActionTarget.js';
|
|
27
|
+
import { validateCommand } from './commands/validate.js';
|
|
22
28
|
// ---------------------------------------------------------------------------
|
|
23
29
|
// Instance acquisition
|
|
24
30
|
// ---------------------------------------------------------------------------
|
|
@@ -134,6 +140,120 @@ function attachWebMCPToMount(fd, options, isDestroyed) {
|
|
|
134
140
|
});
|
|
135
141
|
});
|
|
136
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Build `runCommand` for a mount (shared by `mountFlowDropApp` and
|
|
145
|
+
* `mountWorkflowEditor`).
|
|
146
|
+
*
|
|
147
|
+
* @param isDestroyed - Whether the mount is gone.
|
|
148
|
+
* @param registerCancel - Registers a callback the mount calls on destroy to
|
|
149
|
+
* settle a call still waiting for the workflow; returns its unregister.
|
|
150
|
+
* @param onBaseline - Runs after a successful baseline run, e.g. to tell a
|
|
151
|
+
* draft manager the re-baselined workflow is not an unsaved draft.
|
|
152
|
+
*/
|
|
153
|
+
function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
|
|
154
|
+
const gone = () => ({
|
|
155
|
+
ok: false,
|
|
156
|
+
code: 'NO_WORKFLOW',
|
|
157
|
+
error: 'The editor was destroyed before a workflow was available.'
|
|
158
|
+
});
|
|
159
|
+
const run = (command, options) => {
|
|
160
|
+
if (isDestroyed() || !fd.workflow.current)
|
|
161
|
+
return gone();
|
|
162
|
+
let parsed;
|
|
163
|
+
if (typeof command === 'string') {
|
|
164
|
+
if (isSessionLine(command)) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
code: 'SESSION_REFUSED',
|
|
168
|
+
error: '`session` commands run only in the editor Console; they are not available here.'
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const result = parseCommand(command);
|
|
172
|
+
if (!result.ok)
|
|
173
|
+
return { ok: false, code: 'PARSE_ERROR', error: result.error };
|
|
174
|
+
parsed = result.command;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// Not from the parser: a host may have built it by hand, in plain JS.
|
|
178
|
+
const problem = validateCommand(command);
|
|
179
|
+
if (problem)
|
|
180
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: problem };
|
|
181
|
+
parsed = command;
|
|
182
|
+
}
|
|
183
|
+
const baseline = options?.baseline === true;
|
|
184
|
+
if (baseline && fd.workflow.isDirty) {
|
|
185
|
+
return {
|
|
186
|
+
ok: false,
|
|
187
|
+
code: 'DIRTY',
|
|
188
|
+
error: 'baseline needs a workflow with no unsaved changes; save or discard them first. Nothing was run.'
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
// Undo/redo would step past the saved state and then call it clean.
|
|
192
|
+
if (baseline && (parsed.type === 'undo' || parsed.type === 'redo')) {
|
|
193
|
+
return {
|
|
194
|
+
ok: false,
|
|
195
|
+
code: 'INVALID_ARGUMENT',
|
|
196
|
+
error: `${parsed.type} cannot be run as a baseline. Nothing was run.`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const context = createStoreCommandContext(fd.nodeTypes.current ?? [], (action) => dispatchUIAction(fd, action), fd);
|
|
200
|
+
if (!context)
|
|
201
|
+
return gone();
|
|
202
|
+
// A baseline run is not a change the host should hear about: on release
|
|
203
|
+
// it is told only what is still true (a failed command that left changes).
|
|
204
|
+
const release = baseline ? fd.workflow.muteCallbacks() : null;
|
|
205
|
+
try {
|
|
206
|
+
const result = executeCommand(parsed, context);
|
|
207
|
+
// A command that changed nothing (`info`, `list nodes`, ...) leaves the
|
|
208
|
+
// workflow clean: keep its undo history.
|
|
209
|
+
if (baseline && result.ok && fd.workflow.isDirty) {
|
|
210
|
+
const current = fd.workflow.current;
|
|
211
|
+
if (current)
|
|
212
|
+
fd.workflow.initialize(current);
|
|
213
|
+
onBaseline?.();
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
release?.();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
// The promise never rejects, whatever the executor does.
|
|
222
|
+
const settle = (command, options) => {
|
|
223
|
+
try {
|
|
224
|
+
return run(command, options);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
logger.error('runCommand failed:', error);
|
|
228
|
+
return {
|
|
229
|
+
ok: false,
|
|
230
|
+
code: 'INTERNAL_ERROR',
|
|
231
|
+
error: `The command failed: ${error instanceof Error ? error.message : String(error)}`
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return (command, options) => new Promise((resolve) => {
|
|
236
|
+
if (isDestroyed())
|
|
237
|
+
return resolve(gone());
|
|
238
|
+
let settled = false;
|
|
239
|
+
let unregister = null;
|
|
240
|
+
const finish = (result) => {
|
|
241
|
+
if (settled)
|
|
242
|
+
return;
|
|
243
|
+
settled = true;
|
|
244
|
+
unregister?.();
|
|
245
|
+
resolve(result);
|
|
246
|
+
};
|
|
247
|
+
// Fires at once when the workflow is already loaded.
|
|
248
|
+
const stopWaiting = whenWorkflowLoaded(fd, () => finish(settle(command, options)));
|
|
249
|
+
if (!settled) {
|
|
250
|
+
unregister = registerCancel(() => {
|
|
251
|
+
stopWaiting();
|
|
252
|
+
finish(gone());
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
137
257
|
/**
|
|
138
258
|
* Mount the full FlowDrop App with navbar, sidebars, and workflow editor
|
|
139
259
|
*
|
|
@@ -159,7 +279,7 @@ function attachWebMCPToMount(fd, options, isDestroyed) {
|
|
|
159
279
|
* ```
|
|
160
280
|
*/
|
|
161
281
|
export async function mountFlowDropApp(container, options = {}) {
|
|
162
|
-
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
282
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
|
|
163
283
|
// Per-instance state container — this is what allows multiple FlowDrop
|
|
164
284
|
// editors to coexist on one page without sharing workflow/history state.
|
|
165
285
|
const { fd, isDefault } = acquireInstance(instanceId);
|
|
@@ -239,6 +359,9 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
239
359
|
onSaveError: eventHandlers?.onSaveError,
|
|
240
360
|
onApiError: eventHandlers?.onApiError,
|
|
241
361
|
onWorkflowLoad: eventHandlers?.onWorkflowLoad,
|
|
362
|
+
onExternalEdit: eventHandlers?.onExternalEdit
|
|
363
|
+
? (node, link) => eventHandlers.onExternalEdit(node, link)
|
|
364
|
+
: undefined,
|
|
242
365
|
onBeforeSwap: eventHandlers?.onBeforeSwap,
|
|
243
366
|
onAfterSwap: eventHandlers?.onAfterSwap,
|
|
244
367
|
features,
|
|
@@ -247,6 +370,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
247
370
|
showSettingsSyncButton,
|
|
248
371
|
showSettingsResetButton,
|
|
249
372
|
workflowFormats,
|
|
373
|
+
workflowSettingsSchema,
|
|
250
374
|
contextMenu
|
|
251
375
|
}
|
|
252
376
|
});
|
|
@@ -295,6 +419,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
295
419
|
// its default `onSave` is `mountedApp.save()`.
|
|
296
420
|
let webmcpHandle;
|
|
297
421
|
let destroyed = false;
|
|
422
|
+
// Calls to runCommand still waiting for the workflow; settled on destroy.
|
|
423
|
+
const pendingRuns = new Set();
|
|
298
424
|
// Create the mounted app interface
|
|
299
425
|
const mountedApp = {
|
|
300
426
|
instance: fd,
|
|
@@ -305,6 +431,8 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
305
431
|
// Remove the agent-facing tools before anything else goes away.
|
|
306
432
|
destroyed = true;
|
|
307
433
|
webmcpHandle?.detach();
|
|
434
|
+
for (const cancel of [...pendingRuns])
|
|
435
|
+
cancel();
|
|
308
436
|
// Call onBeforeUnmount if provided
|
|
309
437
|
if (state.eventHandlers?.onBeforeUnmount) {
|
|
310
438
|
const currentWorkflow = fd.workflow.current;
|
|
@@ -355,6 +483,12 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
355
483
|
}
|
|
356
484
|
},
|
|
357
485
|
getWorkflow: () => fd.workflow.current,
|
|
486
|
+
runCommand: createRunCommand(fd, () => destroyed, (cancel) => {
|
|
487
|
+
pendingRuns.add(cancel);
|
|
488
|
+
return () => pendingRuns.delete(cancel);
|
|
489
|
+
},
|
|
490
|
+
// The re-baselined workflow is clean, so it is not a draft to restore.
|
|
491
|
+
() => state.draftManager?.markAsSaved()),
|
|
358
492
|
save: async () => {
|
|
359
493
|
return globalSaveWorkflow({
|
|
360
494
|
instance: fd,
|
|
@@ -462,16 +596,25 @@ export async function mountWorkflowEditor(container, options = {}) {
|
|
|
462
596
|
contextMenu
|
|
463
597
|
}
|
|
464
598
|
});
|
|
599
|
+
let destroyed = false;
|
|
600
|
+
const pendingRuns = new Set();
|
|
465
601
|
// Create the mounted app interface (simpler version)
|
|
466
602
|
const mountedApp = {
|
|
467
603
|
instance: fd,
|
|
468
604
|
destroy: () => {
|
|
605
|
+
destroyed = true;
|
|
606
|
+
for (const cancel of [...pendingRuns])
|
|
607
|
+
cancel();
|
|
469
608
|
releaseInstance(fd, isDefault);
|
|
470
609
|
unmount(svelteApp);
|
|
471
610
|
},
|
|
472
611
|
isDirty: () => fd.workflow.isDirty,
|
|
473
612
|
markAsSaved: () => fd.workflow.markAsSaved(),
|
|
474
613
|
getWorkflow: () => fd.workflow.current,
|
|
614
|
+
runCommand: createRunCommand(fd, () => destroyed, (cancel) => {
|
|
615
|
+
pendingRuns.add(cancel);
|
|
616
|
+
return () => pendingRuns.delete(cancel);
|
|
617
|
+
}),
|
|
475
618
|
save: async () => {
|
|
476
619
|
return globalSaveWorkflow({ instance: fd });
|
|
477
620
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FlowDropTheme } from '../types/theme.js';
|
|
2
|
+
/**
|
|
3
|
+
* Classic: the original FlowDrop look, drawn by the stock tokens in
|
|
4
|
+
* tokens.css with no skin on top (blue primary, card sidebar, bubbles).
|
|
5
|
+
* It was called 'default' until 2.14; Graphite is what the editor opens in.
|
|
6
|
+
*/
|
|
7
|
+
export declare const classicTheme: FlowDropTheme;
|
|
8
|
+
/** @deprecated Renamed to `classicTheme`; removed in 3.0. */
|
|
9
|
+
export declare const defaultTheme: FlowDropTheme;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classic: the original FlowDrop look, drawn by the stock tokens in
|
|
3
|
+
* tokens.css with no skin on top (blue primary, card sidebar, bubbles).
|
|
4
|
+
* It was called 'default' until 2.14; Graphite is what the editor opens in.
|
|
5
|
+
*/
|
|
6
|
+
export const classicTheme = {
|
|
7
|
+
name: 'classic',
|
|
8
|
+
config: {
|
|
9
|
+
sidebar: {
|
|
10
|
+
defaultOpen: true,
|
|
11
|
+
categoriesDefaultOpen: false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** @deprecated Renamed to `classicTheme`; removed in 3.0. */
|
|
16
|
+
export const defaultTheme = classicTheme;
|
package/dist/themes/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { FlowDropTheme, FlowDropThemeName } from '../types/theme.js';
|
|
2
|
-
import { defaultTheme } from './
|
|
2
|
+
import { classicTheme, defaultTheme } from './classic.js';
|
|
3
3
|
import { minimalTheme } from './minimal.js';
|
|
4
4
|
import { drafterTheme } from './drafter.js';
|
|
5
5
|
import { graphiteTheme } from './graphite.js';
|
|
6
|
+
/**
|
|
7
|
+
* The current name of a built-in theme: `'default'` (its name until 2.14)
|
|
8
|
+
* becomes `'classic'`. Any other name is returned as it is.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeThemeName(name: string): string;
|
|
6
11
|
/**
|
|
7
12
|
* Resolve a theme prop to a complete FlowDropTheme object.
|
|
8
13
|
*
|
|
@@ -12,4 +17,4 @@ import { graphiteTheme } from './graphite.js';
|
|
|
12
17
|
* → minimal theme + { skin.tokens.primary: '#e11d48' }
|
|
13
18
|
*/
|
|
14
19
|
export declare function resolveTheme(theme: FlowDropTheme | FlowDropThemeName | undefined): FlowDropTheme;
|
|
15
|
-
export { defaultTheme, minimalTheme, drafterTheme, graphiteTheme };
|
|
20
|
+
export { classicTheme, defaultTheme, minimalTheme, drafterTheme, graphiteTheme };
|
package/dist/themes/index.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { defaultTheme } from './
|
|
1
|
+
import { classicTheme, defaultTheme } from './classic.js';
|
|
2
2
|
import { minimalTheme } from './minimal.js';
|
|
3
3
|
import { drafterTheme } from './drafter.js';
|
|
4
4
|
import { graphiteTheme } from './graphite.js';
|
|
5
5
|
const builtinThemes = {
|
|
6
|
-
|
|
6
|
+
classic: classicTheme,
|
|
7
|
+
default: classicTheme,
|
|
7
8
|
minimal: minimalTheme,
|
|
8
9
|
drafter: drafterTheme,
|
|
9
10
|
graphite: graphiteTheme
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* The current name of a built-in theme: `'default'` (its name until 2.14)
|
|
14
|
+
* becomes `'classic'`. Any other name is returned as it is.
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeThemeName(name) {
|
|
17
|
+
return name === 'default' ? 'classic' : name;
|
|
18
|
+
}
|
|
11
19
|
/**
|
|
12
20
|
* Resolve a theme prop to a complete FlowDropTheme object.
|
|
13
21
|
*
|
|
@@ -17,13 +25,14 @@ const builtinThemes = {
|
|
|
17
25
|
* → minimal theme + { skin.tokens.primary: '#e11d48' }
|
|
18
26
|
*/
|
|
19
27
|
export function resolveTheme(theme) {
|
|
20
|
-
if (!theme
|
|
21
|
-
return
|
|
22
|
-
if (typeof theme === 'string')
|
|
23
|
-
return builtinThemes[theme] ??
|
|
28
|
+
if (!theme)
|
|
29
|
+
return classicTheme;
|
|
30
|
+
if (typeof theme === 'string') {
|
|
31
|
+
return builtinThemes[normalizeThemeName(theme)] ?? classicTheme;
|
|
32
|
+
}
|
|
24
33
|
// Object form — check for a named base to merge on top of
|
|
25
|
-
const baseName = theme.name;
|
|
26
|
-
if (baseName && baseName !== '
|
|
34
|
+
const baseName = theme.name ? normalizeThemeName(theme.name) : undefined;
|
|
35
|
+
if (baseName && baseName !== 'classic' && builtinThemes[baseName]) {
|
|
27
36
|
const base = builtinThemes[baseName];
|
|
28
37
|
return {
|
|
29
38
|
name: baseName,
|
|
@@ -64,6 +73,7 @@ export function resolveTheme(theme) {
|
|
|
64
73
|
}
|
|
65
74
|
};
|
|
66
75
|
}
|
|
67
|
-
|
|
76
|
+
// Classic has no skin to merge; only its old name is brought up to date.
|
|
77
|
+
return baseName === 'classic' ? { ...theme, name: 'classic' } : theme;
|
|
68
78
|
}
|
|
69
|
-
export { defaultTheme, minimalTheme, drafterTheme, graphiteTheme };
|
|
79
|
+
export { classicTheme, defaultTheme, minimalTheme, drafterTheme, graphiteTheme };
|
package/dist/types/events.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module types/events
|
|
8
8
|
*/
|
|
9
|
-
import type { Workflow, NodeExecutionInfo, WorkflowNode } from './index.js';
|
|
9
|
+
import type { Workflow, NodeExecutionInfo, WorkflowNode, ConfigValues, ExternalEditLink } from './index.js';
|
|
10
10
|
import type { SwapEventContext, SwapResult } from '../utils/nodeSwap.js';
|
|
11
11
|
/**
|
|
12
12
|
* Types of workflow changes
|
|
@@ -36,6 +36,23 @@ export type WorkflowChangeType = 'node_add' | 'node_remove' | 'node_move' | 'nod
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export interface FlowDropEventHandlers {
|
|
39
|
+
/**
|
|
40
|
+
* Called instead of opening a node's externalEditLink. Resolve with the new
|
|
41
|
+
* config to write it into the node (one undo step), or with nothing to leave
|
|
42
|
+
* the node as it is.
|
|
43
|
+
*
|
|
44
|
+
* `node` and `link` are copies: changing them does not change the workflow;
|
|
45
|
+
* return the config instead. The returned config replaces the node's
|
|
46
|
+
* config; it is not merged, and it is copied, so changing the object later
|
|
47
|
+
* does not change the workflow either. Anything but a plain object is
|
|
48
|
+
* ignored. A rejection is logged and leaves the node unchanged. While the
|
|
49
|
+
* editor is read-only or locked the handler is still called but its result
|
|
50
|
+
* is not written (a console warning says so).
|
|
51
|
+
*
|
|
52
|
+
* @param node - The node whose external edit link was activated
|
|
53
|
+
* @param link - That node's resolved external edit link
|
|
54
|
+
*/
|
|
55
|
+
onExternalEdit?(node: WorkflowNode, link: ExternalEditLink): ConfigValues | void | Promise<ConfigValues | void>;
|
|
39
56
|
/**
|
|
40
57
|
* Called when workflow changes (any modification)
|
|
41
58
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -156,6 +156,13 @@ export interface NodePort {
|
|
|
156
156
|
* `false`. The instance's `ports` config can override it per port.
|
|
157
157
|
*/
|
|
158
158
|
exposedByDefault?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Whether the port is locked on by its node type: always shown, whatever
|
|
161
|
+
* `exposedByDefault` or the instance's `ports` config says, and the editor
|
|
162
|
+
* offers no Show/Hide toggle. The server decides which ports are locked;
|
|
163
|
+
* absent means `false`.
|
|
164
|
+
*/
|
|
165
|
+
exposureLocked?: boolean;
|
|
159
166
|
/**
|
|
160
167
|
* Default sort weight for the port's render position, ascending; ties break
|
|
161
168
|
* on declaration order. Author-declared ports default to `0`. Reserved ports
|
|
@@ -539,6 +546,9 @@ export interface ExternalEditLink {
|
|
|
539
546
|
/**
|
|
540
547
|
* Callback URL parameter name for FlowDrop to receive updates
|
|
541
548
|
* If set, the external form should redirect back with config updates
|
|
549
|
+
*
|
|
550
|
+
* @deprecated Nothing passes a callback URL, so this has no effect. Handle the
|
|
551
|
+
* round trip in the host with `FlowDropEventHandlers.onExternalEdit` instead.
|
|
542
552
|
*/
|
|
543
553
|
callbackUrlParam?: string;
|
|
544
554
|
}
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module types/settings
|
|
8
8
|
*/
|
|
9
9
|
import { type ZoomTierConfig } from '../utils/zoomTier.js';
|
|
10
|
+
import type { FlowDropThemeName } from './theme.js';
|
|
10
11
|
/**
|
|
11
12
|
* Theme preference options
|
|
12
13
|
* - 'light': Force light theme
|
|
@@ -158,8 +159,11 @@ export interface UISettings {
|
|
|
158
159
|
sidebarCollapsed: boolean;
|
|
159
160
|
/** Enable compact mode for denser UI */
|
|
160
161
|
compactMode: boolean;
|
|
161
|
-
/**
|
|
162
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Active theme name — overridden by the theme prop when explicitly provided.
|
|
164
|
+
* A saved `'default'` (the old name of `'classic'`) is read as `'classic'`.
|
|
165
|
+
*/
|
|
166
|
+
theme: FlowDropThemeName;
|
|
163
167
|
/** Whether the command console panel is open */
|
|
164
168
|
consoleOpen: boolean;
|
|
165
169
|
/** Height of the command console panel in pixels (opens at 220, saved on resize) */
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface FlowDropThemeConfig {
|
|
|
66
66
|
/**
|
|
67
67
|
* A FlowDrop theme bundles a visual skin (CSS tokens) with UI config (behavioral defaults).
|
|
68
68
|
*
|
|
69
|
-
* Built-in themes: '
|
|
69
|
+
* Built-in themes: 'graphite' (the editor's default) | 'classic' | 'minimal' | 'drafter'
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* // Use a built-in theme by name
|
|
@@ -84,4 +84,8 @@ export interface FlowDropTheme {
|
|
|
84
84
|
/** Behavioral configuration defaults */
|
|
85
85
|
config?: FlowDropThemeConfig;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Names of the built-in themes. `'default'` is the old name of `'classic'`
|
|
89
|
+
* and still resolves to it; it is removed in 3.0.
|
|
90
|
+
*/
|
|
91
|
+
export type FlowDropThemeName = 'classic' | 'minimal' | 'drafter' | 'graphite' | 'default';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-handled external editing (`onExternalEdit`).
|
|
3
|
+
*
|
|
4
|
+
* Calls the host's handler for a node's external edit link and, when the host
|
|
5
|
+
* resolves with a config, writes it into the node as one undo step.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/externalEdit
|
|
8
|
+
*/
|
|
9
|
+
import type { ConfigValues, ExternalEditLink, Workflow, WorkflowNode } from '../types/index.js';
|
|
10
|
+
/** The slice of the workflow store this needs. */
|
|
11
|
+
export interface ExternalEditStore {
|
|
12
|
+
readonly current: Workflow | null;
|
|
13
|
+
updateNodeConfig(nodeId: string, updates: Partial<WorkflowNode>): void;
|
|
14
|
+
finalizeNodeConfig(): void;
|
|
15
|
+
}
|
|
16
|
+
export interface RunExternalEditOptions {
|
|
17
|
+
node: WorkflowNode;
|
|
18
|
+
link: ExternalEditLink;
|
|
19
|
+
/** The host's `onExternalEdit` handler. */
|
|
20
|
+
handler: (node: WorkflowNode, link: ExternalEditLink) => ConfigValues | void | Promise<ConfigValues | void>;
|
|
21
|
+
store: ExternalEditStore;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the editor accepts the result, asked when the handler resolves
|
|
24
|
+
* (the editor may have been locked while the host form was open). False
|
|
25
|
+
* when read-only or locked: the handler is still called (the link is shown
|
|
26
|
+
* there), but its result is not written. Defaults to writable.
|
|
27
|
+
*/
|
|
28
|
+
canWrite?: () => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Ids of nodes whose host form is open. A node already in it is skipped
|
|
31
|
+
* (the handler is not called again); the caller keeps the set alive.
|
|
32
|
+
*/
|
|
33
|
+
pending?: Set<string>;
|
|
34
|
+
/** Called with the node as written, e.g. to refresh the canvas. */
|
|
35
|
+
onWritten?: (node: WorkflowNode) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run the host handler and apply its result.
|
|
39
|
+
*
|
|
40
|
+
* - A config replaces the node's config (not merged): one undo step, workflow dirty.
|
|
41
|
+
* It is copied, so the host keeps no reference into the workflow.
|
|
42
|
+
* - Anything but a plain object (an array, a string, ...) is logged and dropped.
|
|
43
|
+
* - Nothing resolved: the node is left as it is.
|
|
44
|
+
* - A rejection is logged and swallowed.
|
|
45
|
+
* - A node deleted while the host form was open: the result is dropped.
|
|
46
|
+
* - A node whose host form is already open (`pending`): nothing happens.
|
|
47
|
+
*/
|
|
48
|
+
export declare function runExternalEdit(options: RunExternalEditOptions): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-handled external editing (`onExternalEdit`).
|
|
3
|
+
*
|
|
4
|
+
* Calls the host's handler for a node's external edit link and, when the host
|
|
5
|
+
* resolves with a config, writes it into the node as one undo step.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/externalEdit
|
|
8
|
+
*/
|
|
9
|
+
import { logger } from './logger.js';
|
|
10
|
+
/**
|
|
11
|
+
* Run the host handler and apply its result.
|
|
12
|
+
*
|
|
13
|
+
* - A config replaces the node's config (not merged): one undo step, workflow dirty.
|
|
14
|
+
* It is copied, so the host keeps no reference into the workflow.
|
|
15
|
+
* - Anything but a plain object (an array, a string, ...) is logged and dropped.
|
|
16
|
+
* - Nothing resolved: the node is left as it is.
|
|
17
|
+
* - A rejection is logged and swallowed.
|
|
18
|
+
* - A node deleted while the host form was open: the result is dropped.
|
|
19
|
+
* - A node whose host form is already open (`pending`): nothing happens.
|
|
20
|
+
*/
|
|
21
|
+
export async function runExternalEdit(options) {
|
|
22
|
+
const { node, link, handler, store, canWrite, pending, onWritten } = options;
|
|
23
|
+
if (pending?.has(node.id))
|
|
24
|
+
return;
|
|
25
|
+
pending?.add(node.id);
|
|
26
|
+
let result;
|
|
27
|
+
try {
|
|
28
|
+
result = await handler(node, link);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
logger.warn('onExternalEdit rejected; node left unchanged:', error);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
pending?.delete(node.id);
|
|
36
|
+
}
|
|
37
|
+
if (result === undefined || result === null)
|
|
38
|
+
return;
|
|
39
|
+
if (typeof result !== 'object' || Array.isArray(result)) {
|
|
40
|
+
logger.warn('onExternalEdit resolved with something other than a config object; ignored:', result);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (canWrite && !canWrite()) {
|
|
44
|
+
logger.warn('onExternalEdit result ignored: the editor is read-only or locked');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// A copy, so the host keeps no reference into the workflow (a Svelte host's
|
|
48
|
+
// `$state` proxy included).
|
|
49
|
+
const config = $state.snapshot(result);
|
|
50
|
+
const current = store.current?.nodes.find((n) => n.id === node.id);
|
|
51
|
+
if (!current) {
|
|
52
|
+
logger.debug(`onExternalEdit result dropped: node ${node.id} no longer exists`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Close any open field-editing session first so this is a step of its own.
|
|
56
|
+
store.finalizeNodeConfig();
|
|
57
|
+
store.updateNodeConfig(node.id, { data: { ...current.data, config } });
|
|
58
|
+
store.finalizeNodeConfig();
|
|
59
|
+
const written = store.current?.nodes.find((n) => n.id === node.id);
|
|
60
|
+
if (written)
|
|
61
|
+
onWritten?.(written);
|
|
62
|
+
}
|
|
@@ -8,6 +8,11 @@ export interface ExternalLinkInfo {
|
|
|
8
8
|
title?: string;
|
|
9
9
|
href: string;
|
|
10
10
|
newTab: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* When set, a plain left click calls this instead of following the link
|
|
13
|
+
* (the host opens its own form). Modified clicks still follow the href.
|
|
14
|
+
*/
|
|
15
|
+
onActivate?: () => void;
|
|
11
16
|
}
|
|
12
17
|
export interface InspectorContext {
|
|
13
18
|
/** The form tab currently shown. */
|
|
@@ -105,6 +105,16 @@ export declare function rewritePlaygroundReplies(playground: WorkflowPlayground
|
|
|
105
105
|
oldPortId: string;
|
|
106
106
|
newPortId: string;
|
|
107
107
|
}>): WorkflowPlayground | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The workflow once the nodes `removed` names are gone: Playground replies on
|
|
110
|
+
* them are dropped, so the stored binding never prints a reply from a node the
|
|
111
|
+
* workflow no longer has (the server refuses such a save). The inputs stay:
|
|
112
|
+
* they name interface entries, not nodes. When that leaves settings that bind
|
|
113
|
+
* nothing, the interface's deprecated `turn` marks go too, or they would take
|
|
114
|
+
* over as the chat. The same object when no reply is on a removed node, or
|
|
115
|
+
* nothing is stored.
|
|
116
|
+
*/
|
|
117
|
+
export declare function withoutRepliesOnNodes<W extends Pick<Workflow, 'playground' | 'interface'>>(workflow: W, removed: ReadonlySet<string>): W;
|
|
108
118
|
/**
|
|
109
119
|
* Whether the interface still carries a deprecated `turn` mark this library
|
|
110
120
|
* knows (one `withoutInterfaceTurns` removes).
|
|
@@ -226,6 +226,31 @@ export function rewritePlaygroundReplies(playground, oldNodeId, newNodeId, portM
|
|
|
226
226
|
});
|
|
227
227
|
return withPlaygroundChat(playground, { ...chat, replies });
|
|
228
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* The workflow once the nodes `removed` names are gone: Playground replies on
|
|
231
|
+
* them are dropped, so the stored binding never prints a reply from a node the
|
|
232
|
+
* workflow no longer has (the server refuses such a save). The inputs stay:
|
|
233
|
+
* they name interface entries, not nodes. When that leaves settings that bind
|
|
234
|
+
* nothing, the interface's deprecated `turn` marks go too, or they would take
|
|
235
|
+
* over as the chat. The same object when no reply is on a removed node, or
|
|
236
|
+
* nothing is stored.
|
|
237
|
+
*/
|
|
238
|
+
export function withoutRepliesOnNodes(workflow, removed) {
|
|
239
|
+
if (!workflow.playground?.chat || removed.size === 0)
|
|
240
|
+
return workflow;
|
|
241
|
+
const chat = normalizePlaygroundChat(workflow.playground.chat);
|
|
242
|
+
if (!chat.replies.some((reply) => removed.has(reply.node_id)))
|
|
243
|
+
return workflow;
|
|
244
|
+
const playground = withPlaygroundChat(workflow.playground, {
|
|
245
|
+
...chat,
|
|
246
|
+
replies: chat.replies.filter((reply) => !removed.has(reply.node_id))
|
|
247
|
+
});
|
|
248
|
+
const next = { ...workflow, playground };
|
|
249
|
+
if (playground.chat === null && workflow.interface !== undefined) {
|
|
250
|
+
next.interface = withoutInterfaceTurns(workflow.interface);
|
|
251
|
+
}
|
|
252
|
+
return next;
|
|
253
|
+
}
|
|
229
254
|
/**
|
|
230
255
|
* Whether the interface still carries a deprecated `turn` mark this library
|
|
231
256
|
* knows (one `withoutInterfaceTurns` removes).
|
|
@@ -23,10 +23,33 @@ export interface PortExposureCandidate {
|
|
|
23
23
|
* of it (they are always drawn).
|
|
24
24
|
*/
|
|
25
25
|
export declare function nodePortsFor(node: Pick<WorkflowNode, 'data'>, direction: PortsDirection): NodePort[];
|
|
26
|
+
/** Why an exposed port can't be hidden right now. */
|
|
27
|
+
export type ExposureBlock = {
|
|
28
|
+
kind: 'locked';
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'wired';
|
|
31
|
+
count: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'published';
|
|
34
|
+
};
|
|
35
|
+
/** Whether the node type fixes a port as always shown (a trigger's event input included). */
|
|
36
|
+
export declare function isExposureLocked(node: Pick<WorkflowNode, 'id' | 'data'>, direction: PortsDirection, port: NodePort): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Edges on each of the node's ports, counted in one pass. Keyed
|
|
39
|
+
* `${direction}:${portId}`. An edge counts on a port when its handle is the
|
|
40
|
+
* port's full handle id or the bare port id.
|
|
41
|
+
*/
|
|
42
|
+
export declare function countPortWires(node: Pick<WorkflowNode, 'id'>, workflow: Workflow): Map<string, number>;
|
|
43
|
+
/**
|
|
44
|
+
* Why an exposed port can't be hidden, or `null` when it can. Locked (the node
|
|
45
|
+
* type decides) comes before wired, which comes before published on the
|
|
46
|
+
* workflow interface. `wires` is {@link countPortWires} for the node.
|
|
47
|
+
*/
|
|
48
|
+
export declare function hideBlock(node: Pick<WorkflowNode, 'id' | 'data'>, workflow: Workflow, direction: PortsDirection, port: NodePort, wires: ReadonlyMap<string, number>): ExposureBlock | null;
|
|
26
49
|
/**
|
|
27
50
|
* Exposed data ports with no edge on them, the ones worth hiding. Left out:
|
|
28
51
|
* reserved ports (error output, trigger and tool types), control-flow ports
|
|
29
|
-
* (loop-back), a trigger's event input
|
|
52
|
+
* (loop-back), locked ports (a trigger's event input), ports published on
|
|
30
53
|
* the workflow interface (hiding them would break the binding), and a required
|
|
31
54
|
* input with no config value (hiding it would only hide the missing value).
|
|
32
55
|
*/
|