@flowdrop/flowdrop 2.16.0 → 2.18.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 +95 -0
- package/README.md +6 -1
- package/dist/api/enhanced-client.d.ts +3 -1
- package/dist/api/enhanced-client.js +4 -2
- package/dist/commands/executor.js +9 -0
- package/dist/commands/storeIntegration.svelte.js +6 -0
- package/dist/commands/types.d.ts +8 -0
- package/dist/components/App.svelte +414 -105
- package/dist/components/App.svelte.d.ts +31 -0
- package/dist/components/CanvasToolbar.svelte +40 -3
- package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
- package/dist/components/ConnectPortPicker.svelte +8 -4
- package/dist/components/DoctorMenu.svelte +208 -126
- package/dist/components/FlowDropZone.svelte +7 -1
- package/dist/components/FlowDropZone.svelte.d.ts +5 -0
- package/dist/components/ImpactConfirm.svelte +554 -0
- package/dist/components/ImpactConfirm.svelte.d.ts +22 -0
- package/dist/components/Input.svelte +8 -2
- package/dist/components/LockBanner.svelte +76 -0
- package/dist/components/LockBanner.svelte.d.ts +14 -0
- package/dist/components/LockFence.svelte +33 -0
- package/dist/components/LockFence.svelte.d.ts +19 -0
- package/dist/components/Navbar.svelte +77 -9
- package/dist/components/Navbar.svelte.d.ts +10 -0
- package/dist/components/NodeSidebar.svelte +36 -15
- package/dist/components/NodeSidebar.svelte.d.ts +2 -0
- package/dist/components/NodeSwapPicker.svelte +4 -14
- package/dist/components/RunBar.svelte +50 -3
- package/dist/components/RunBar.svelte.d.ts +5 -0
- package/dist/components/RunInputsDialog.svelte +198 -0
- package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
- package/dist/components/Textarea.svelte +7 -1
- package/dist/components/WorkflowCompareDialog.svelte +177 -0
- package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
- package/dist/components/WorkflowEditor.svelte +120 -15
- package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +17 -4
- package/dist/components/WorkflowInterfaceEntryCard.svelte +40 -7
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
- package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
- package/dist/components/form/FieldFactory.svelte +13 -6
- package/dist/components/form/FormArray.svelte +0 -1
- package/dist/components/form/FormArrayRows.svelte +4 -4
- package/dist/components/form/FormCodeEditor.svelte +18 -2
- package/dist/components/form/FormMarkdownEditor.svelte +22 -8
- package/dist/components/form/FormTemplateEditor.svelte +17 -1
- package/dist/components/form/readOnly.d.ts +13 -0
- package/dist/components/form/readOnly.js +18 -0
- package/dist/components/nodes/CaptionNode.svelte +1 -0
- package/dist/components/nodes/NodeCard.svelte +2 -2
- package/dist/components/primitives/Checkbox.svelte +5 -1
- package/dist/components/primitives/Select.svelte +6 -1
- package/dist/components/primitives/Switch.svelte +5 -1
- package/dist/components/toast/DismissibleToast.svelte +25 -6
- package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
- package/dist/config/endpoints.d.ts +7 -0
- package/dist/config/endpoints.js +2 -1
- package/dist/editor/connectCandidates.d.ts +3 -0
- package/dist/editor/connectCandidates.js +14 -5
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/index.js +1 -1
- package/dist/helpers/workflowEditorHelper.d.ts +15 -0
- package/dist/helpers/workflowEditorHelper.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/messages/defaults.d.ts +145 -0
- package/dist/messages/defaults.js +139 -1
- package/dist/openapi/v1/openapi.yaml +492 -0
- package/dist/registry/nodeComponentRegistry.d.ts +5 -0
- package/dist/schemas/v1/workflow.schema.json +2 -0
- package/dist/services/draftStorage.d.ts +24 -10
- package/dist/services/draftStorage.js +60 -35
- package/dist/services/globalSave.d.ts +45 -10
- package/dist/services/globalSave.js +296 -32
- package/dist/services/impactGate.d.ts +38 -0
- package/dist/services/impactGate.js +72 -0
- package/dist/services/impactService.d.ts +45 -0
- package/dist/services/impactService.js +157 -0
- package/dist/services/runsService.d.ts +9 -0
- package/dist/services/runsService.js +13 -0
- package/dist/services/toastQueue.d.ts +9 -0
- package/dist/services/toastService.d.ts +4 -0
- package/dist/services/toastService.js +9 -3
- package/dist/services/workflowLaunchService.d.ts +6 -0
- package/dist/services/workflowLaunchService.js +5 -1
- package/dist/settings/index.d.ts +2 -2
- package/dist/settings/index.js +1 -1
- package/dist/stores/doctorStore.svelte.d.ts +24 -1
- package/dist/stores/doctorStore.svelte.js +105 -2
- package/dist/stores/historyStore.svelte.d.ts +12 -2
- package/dist/stores/historyStore.svelte.js +25 -2
- package/dist/stores/instanceContainer.svelte.d.ts +23 -0
- package/dist/stores/instanceContainer.svelte.js +32 -2
- package/dist/stores/lockStore.svelte.d.ts +39 -0
- package/dist/stores/lockStore.svelte.js +109 -0
- package/dist/stores/runController.svelte.d.ts +2 -0
- package/dist/stores/runController.svelte.js +27 -11
- package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
- package/dist/stores/saveConflictStore.svelte.js +169 -0
- package/dist/stores/workflowStore.svelte.d.ts +14 -4
- package/dist/stores/workflowStore.svelte.js +55 -18
- package/dist/styles/base.css +6 -0
- package/dist/styles/toast.css +10 -1
- package/dist/svelte-app.d.ts +33 -0
- package/dist/svelte-app.js +178 -22
- package/dist/types/doctor.d.ts +3 -1
- package/dist/types/events.d.ts +37 -0
- package/dist/types/events.js +2 -0
- package/dist/types/impact.d.ts +77 -0
- package/dist/types/impact.js +7 -0
- package/dist/types/lock.d.ts +35 -0
- package/dist/types/lock.js +13 -0
- package/dist/types/navbar.d.ts +6 -0
- package/dist/types/settings.d.ts +31 -0
- package/dist/types/settings.js +132 -0
- package/dist/utils/draftRestore.d.ts +27 -0
- package/dist/utils/draftRestore.js +36 -0
- package/dist/utils/interfaceTags.js +4 -1
- package/dist/utils/links.d.ts +29 -0
- package/dist/utils/links.js +63 -0
- package/dist/utils/nodeSearch.d.ts +10 -0
- package/dist/utils/nodeSearch.js +37 -0
- package/dist/utils/runOffer.d.ts +21 -0
- package/dist/utils/runOffer.js +13 -0
- package/dist/utils/workflowCompare.d.ts +35 -0
- package/dist/utils/workflowCompare.js +84 -0
- package/dist/utils/workflowInterface.d.ts +26 -1
- package/dist/utils/workflowInterface.js +91 -11
- package/dist/webmcp/runtime.js +16 -3
- package/dist/webmcp/types.d.ts +11 -1
- package/package.json +3 -2
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
} from '../stores/settingsStore.svelte.js';
|
|
23
23
|
import type { WorkflowNode as WorkflowNodeType, Workflow, WorkflowEdge } from '../types/index.js';
|
|
24
24
|
import CanvasBanner from './CanvasBanner.svelte';
|
|
25
|
+
import LockBanner from './LockBanner.svelte';
|
|
25
26
|
import CanvasToolbar from './CanvasToolbar.svelte';
|
|
26
27
|
import CanvasController from './CanvasController.svelte';
|
|
27
28
|
import StraightGuides from './StraightGuides.svelte';
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
type ContextMenuTarget
|
|
43
44
|
} from '../editor/contextMenu.js';
|
|
44
45
|
import type { NodeMetadata } from '../types/index.js';
|
|
46
|
+
import { extractConfigDefaults } from '../utils/nodeIds.js';
|
|
45
47
|
import { resolveComponentName } from '../utils/nodeTypes.js';
|
|
46
48
|
import { nodeAriaLabel } from '../utils/nodeAriaLabel.js';
|
|
47
49
|
import { decideInlineCommit } from '../utils/captionText.js';
|
|
@@ -62,7 +64,8 @@
|
|
|
62
64
|
EdgeStylingHelper,
|
|
63
65
|
NodeOperationsHelper,
|
|
64
66
|
WorkflowOperationsHelper,
|
|
65
|
-
ConfigurationHelper
|
|
67
|
+
ConfigurationHelper,
|
|
68
|
+
placementForNewNode
|
|
66
69
|
} from '../helpers/workflowEditorHelper.js';
|
|
67
70
|
import { Toaster } from 'svelte-5-french-toast';
|
|
68
71
|
import {
|
|
@@ -195,6 +198,10 @@
|
|
|
195
198
|
* while a run waits for them. Without it the button is not shown.
|
|
196
199
|
*/
|
|
197
200
|
onOpenTest?: () => void;
|
|
201
|
+
/** Start the workflow: the canvas toolbar's Run button (Edit mode). Without it the button is not shown. */
|
|
202
|
+
onRun?: () => void;
|
|
203
|
+
/** A run is being started: the Run button spins. */
|
|
204
|
+
runBusy?: boolean;
|
|
198
205
|
/** Current editor mode, shown in the canvas toolbar's Edit | Test switch. @default 'edit' */
|
|
199
206
|
editorMode?: 'edit' | 'test';
|
|
200
207
|
/** Switch the editor mode. The toolbar's Edit | Test switch is shown only when this is set. */
|
|
@@ -241,8 +248,11 @@
|
|
|
241
248
|
});
|
|
242
249
|
|
|
243
250
|
// `mode` is the public API; the canvas only needs to know whether editing is
|
|
244
|
-
// enabled. 'readonly' and 'locked' both disable interaction identically
|
|
245
|
-
|
|
251
|
+
// enabled. 'readonly' and 'locked' both disable interaction identically, and
|
|
252
|
+
// so does a lock on the instance (`fd.lock`), even when this editor is mounted
|
|
253
|
+
// on its own without App.
|
|
254
|
+
const hostEditable = $derived((props.mode ?? 'edit') === 'edit');
|
|
255
|
+
const canvasEditable = $derived(hostEditable && !fd.lock.isLocked);
|
|
246
256
|
|
|
247
257
|
// Canvas grid pattern, supplied by the active theme's config.canvas.grid
|
|
248
258
|
// (App passes it down). BackgroundVariant's enum values are the same strings
|
|
@@ -861,6 +871,8 @@
|
|
|
861
871
|
options: { history?: boolean; emptyLabel?: boolean } = {}
|
|
862
872
|
): { id: string | null; done: Promise<void> } {
|
|
863
873
|
const { history = true, emptyLabel = false } = options;
|
|
874
|
+
// The store refuses the node when locked; the canvas must not show it either.
|
|
875
|
+
if (!canvasEditable) return { id: null, done: Promise.resolve() };
|
|
864
876
|
// The machine's `dropping` state is what holds the store -> canvas sync
|
|
865
877
|
// off while a node is added (see its permissions), so every placement
|
|
866
878
|
// goes through it, not only a sidebar drop.
|
|
@@ -1000,11 +1012,12 @@
|
|
|
1000
1012
|
function handleInlineCommit(id: string, text: string | null): void {
|
|
1001
1013
|
const node = flowNodes.find((n) => n.id === id);
|
|
1002
1014
|
const isNew = pendingNewIds.delete(id);
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1015
|
+
// Gone (undo, workflow switch).
|
|
1016
|
+
if (!node) return;
|
|
1017
|
+
// A locked store refuses every change, so the canvas must not make one
|
|
1018
|
+
// either: the node stays as it is. A read-only editor is not locked: the
|
|
1019
|
+
// edit that was in progress ends like any other.
|
|
1020
|
+
if (fd.workflow.locked) return;
|
|
1008
1021
|
|
|
1009
1022
|
const { outcome, label } = decideInlineCommit(text, node.data.label ?? '', isNew);
|
|
1010
1023
|
if (outcome === 'none') return;
|
|
@@ -1515,6 +1528,11 @@
|
|
|
1515
1528
|
return true;
|
|
1516
1529
|
}
|
|
1517
1530
|
|
|
1531
|
+
// A name being typed beside a port is saved when the lock arrives, while the
|
|
1532
|
+
// store still accepts it. (A node's own label is saved by the caption's blur,
|
|
1533
|
+
// which the lock store triggers right after.)
|
|
1534
|
+
$effect(() => fd.lock.onBeforeLock(() => tagEdit && commitTagEdit()));
|
|
1535
|
+
|
|
1518
1536
|
// A name being typed never outlives edit mode, its workflow, or its port (undo).
|
|
1519
1537
|
$effect(() => {
|
|
1520
1538
|
if (!canvasEditable) tagEdit = null;
|
|
@@ -1547,6 +1565,15 @@
|
|
|
1547
1565
|
if (showContextMenu('pane', [], event.clientX, event.clientY)) event.preventDefault();
|
|
1548
1566
|
}
|
|
1549
1567
|
|
|
1568
|
+
/**
|
|
1569
|
+
* A key press belongs to the canvas when it comes from inside it, or from the canvas region
|
|
1570
|
+
* around it: a click on the empty canvas and the "Skip to the canvas" link both focus that region.
|
|
1571
|
+
*/
|
|
1572
|
+
function onCanvas(target: HTMLElement): boolean {
|
|
1573
|
+
if (target.closest('.flowdrop-canvas')) return true;
|
|
1574
|
+
return target.getAttribute('role') === 'region' && !!canvasEl && target.contains(canvasEl);
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1550
1577
|
/**
|
|
1551
1578
|
* Shift+F10 / the Menu key: on a focused node wrapper open that node's menu
|
|
1552
1579
|
* anchored at the node; elsewhere in the canvas open the pane menu at the
|
|
@@ -1555,7 +1582,7 @@
|
|
|
1555
1582
|
function handleMenuKey(event: KeyboardEvent, target: HTMLElement): boolean {
|
|
1556
1583
|
const isMenuKey = event.key === 'ContextMenu' || (event.key === 'F10' && event.shiftKey);
|
|
1557
1584
|
if (!isMenuKey || !canvasEditable) return false;
|
|
1558
|
-
if (!target
|
|
1585
|
+
if (!onCanvas(target) || target.closest('.canvas-context-menu')) return false;
|
|
1559
1586
|
|
|
1560
1587
|
event.preventDefault();
|
|
1561
1588
|
|
|
@@ -1602,8 +1629,12 @@
|
|
|
1602
1629
|
* loads it into the workflow store. Shows a toast on validation failure or read error.
|
|
1603
1630
|
*/
|
|
1604
1631
|
function handleWorkflowFileDrop(file: File): void {
|
|
1632
|
+
// `initialize` ignores the lock on purpose, so a drop must check it itself:
|
|
1633
|
+
// now, and again when the file has been read (a lock may arrive meanwhile).
|
|
1634
|
+
if (!canvasEditable) return;
|
|
1605
1635
|
const reader = new FileReader();
|
|
1606
1636
|
reader.onload = (event) => {
|
|
1637
|
+
if (!canvasEditable) return;
|
|
1607
1638
|
try {
|
|
1608
1639
|
const text = event.target?.result;
|
|
1609
1640
|
if (typeof text !== 'string') {
|
|
@@ -1697,6 +1728,53 @@
|
|
|
1697
1728
|
nodeIdToRefresh = nodeId;
|
|
1698
1729
|
}
|
|
1699
1730
|
|
|
1731
|
+
/**
|
|
1732
|
+
* Add a node from a palette click or Enter: right of the selected node,
|
|
1733
|
+
* else the middle of the view. Goes through placeNode like a drop.
|
|
1734
|
+
*/
|
|
1735
|
+
export function addNodeFromPalette(metadata: NodeMetadata): void {
|
|
1736
|
+
if (!canvasEditable || !canvasControllerRef) return;
|
|
1737
|
+
const grid = getEditorSettings().gridSize;
|
|
1738
|
+
const selected = flowNodes.find((n) => n.selected);
|
|
1739
|
+
const flowEl = canvasEl?.querySelector('.svelte-flow') ?? canvasEl;
|
|
1740
|
+
const rect = flowEl?.getBoundingClientRect();
|
|
1741
|
+
const centre = rect
|
|
1742
|
+
? canvasControllerRef.canvasScreenToFlow({
|
|
1743
|
+
x: rect.left + rect.width / 2,
|
|
1744
|
+
y: rect.top + rect.height / 2
|
|
1745
|
+
})
|
|
1746
|
+
: { x: 0, y: 0 };
|
|
1747
|
+
const position = snapPosition(
|
|
1748
|
+
placementForNewNode(
|
|
1749
|
+
selected
|
|
1750
|
+
? {
|
|
1751
|
+
x: selected.position.x,
|
|
1752
|
+
y: selected.position.y,
|
|
1753
|
+
width: selected.measured?.width ?? selected.width ?? grid * 10
|
|
1754
|
+
}
|
|
1755
|
+
: null,
|
|
1756
|
+
centre,
|
|
1757
|
+
grid * 2
|
|
1758
|
+
)
|
|
1759
|
+
);
|
|
1760
|
+
const { id } = placeNode(
|
|
1761
|
+
JSON.stringify({
|
|
1762
|
+
type: 'node',
|
|
1763
|
+
nodeType: metadata.node_type_id,
|
|
1764
|
+
nodeData: {
|
|
1765
|
+
label: metadata.name,
|
|
1766
|
+
config: extractConfigDefaults(metadata.configSchema),
|
|
1767
|
+
metadata
|
|
1768
|
+
}
|
|
1769
|
+
}),
|
|
1770
|
+
position
|
|
1771
|
+
);
|
|
1772
|
+
if (!id) return;
|
|
1773
|
+
flowNodes = flowNodes.map((n) =>
|
|
1774
|
+
n.selected === (n.id === id) ? n : { ...n, selected: n.id === id }
|
|
1775
|
+
);
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1700
1778
|
// Canvas viewport methods (forwarded to CanvasController inside <SvelteFlow>)
|
|
1701
1779
|
|
|
1702
1780
|
export function canvasFitView(): void {
|
|
@@ -1751,6 +1829,24 @@
|
|
|
1751
1829
|
function handleKeydown(event: KeyboardEvent): void {
|
|
1752
1830
|
// Don't handle shortcuts if user is typing in an input, textarea, or contenteditable
|
|
1753
1831
|
const target = event.target as HTMLElement;
|
|
1832
|
+
|
|
1833
|
+
// A focused port pin: Enter, Space, Menu or Shift+F10 opens its port menu.
|
|
1834
|
+
const pin = target.closest?.('.svelte-flow__handle');
|
|
1835
|
+
if (
|
|
1836
|
+
pin instanceof HTMLElement &&
|
|
1837
|
+
canvasEl?.contains(pin) &&
|
|
1838
|
+
canvasEditable &&
|
|
1839
|
+
(event.key === 'Enter' ||
|
|
1840
|
+
event.key === ' ' ||
|
|
1841
|
+
event.key === 'ContextMenu' ||
|
|
1842
|
+
(event.key === 'F10' && event.shiftKey))
|
|
1843
|
+
) {
|
|
1844
|
+
event.preventDefault();
|
|
1845
|
+
const rect = pin.getBoundingClientRect();
|
|
1846
|
+
showPortMenu(pin, rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1754
1850
|
const isInputElement =
|
|
1755
1851
|
target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
|
|
1756
1852
|
|
|
@@ -1778,7 +1874,7 @@
|
|
|
1778
1874
|
!event.metaKey &&
|
|
1779
1875
|
!event.altKey &&
|
|
1780
1876
|
canvasEditable &&
|
|
1781
|
-
target
|
|
1877
|
+
onCanvas(target)
|
|
1782
1878
|
) {
|
|
1783
1879
|
const ids = flowNodes.filter((n) => n.selected).map((n) => n.id);
|
|
1784
1880
|
if (ids.length > 0) {
|
|
@@ -1788,8 +1884,8 @@
|
|
|
1788
1884
|
return;
|
|
1789
1885
|
}
|
|
1790
1886
|
|
|
1791
|
-
// Shift+Alt+T on the canvas, or with nothing focused
|
|
1792
|
-
//
|
|
1887
|
+
// Shift+Alt+T on the canvas, or with nothing focused: tidy up the whole graph.
|
|
1888
|
+
// By code: Alt changes the key on a Mac.
|
|
1793
1889
|
if (
|
|
1794
1890
|
event.code === 'KeyT' &&
|
|
1795
1891
|
event.shiftKey &&
|
|
@@ -1797,7 +1893,7 @@
|
|
|
1797
1893
|
!event.ctrlKey &&
|
|
1798
1894
|
!event.metaKey &&
|
|
1799
1895
|
canvasEditable &&
|
|
1800
|
-
(target === document.body || target
|
|
1896
|
+
(target === document.body || onCanvas(target))
|
|
1801
1897
|
) {
|
|
1802
1898
|
event.preventDefault();
|
|
1803
1899
|
tidyLayout();
|
|
@@ -1811,6 +1907,9 @@
|
|
|
1811
1907
|
return;
|
|
1812
1908
|
}
|
|
1813
1909
|
|
|
1910
|
+
// A locked or read-only canvas has nothing to undo or redo.
|
|
1911
|
+
if (!canvasEditable) return;
|
|
1912
|
+
|
|
1814
1913
|
// Undo: Ctrl+Z (without Shift)
|
|
1815
1914
|
if (event.key === 'z' && !event.shiftKey) {
|
|
1816
1915
|
event.preventDefault();
|
|
@@ -1832,6 +1931,7 @@
|
|
|
1832
1931
|
<div class="flowdrop-scope flowdrop-workflow-editor">
|
|
1833
1932
|
<!-- Main Editor Area -->
|
|
1834
1933
|
<div class="flowdrop-workflow-editor__main">
|
|
1934
|
+
<LockBanner />
|
|
1835
1935
|
<!-- Flow Canvas.
|
|
1836
1936
|
Capture-phase mousedown so dragging from a port never turns into a
|
|
1837
1937
|
WebKit text-selection drag — see suppressPortDragSelection. -->
|
|
@@ -1846,6 +1946,7 @@
|
|
|
1846
1946
|
<FlowDropZone
|
|
1847
1947
|
ondrop={handleNodeDrop}
|
|
1848
1948
|
onfiledrop={handleWorkflowFileDrop}
|
|
1949
|
+
editable={canvasEditable}
|
|
1849
1950
|
toFlowPosition={(point) => canvasControllerRef?.canvasScreenToFlow(point) ?? null}
|
|
1850
1951
|
>
|
|
1851
1952
|
{#key svelteFlowKey}
|
|
@@ -1889,7 +1990,8 @@
|
|
|
1889
1990
|
fitViewOptions={{ padding: CANVAS_FIT_PADDING }}
|
|
1890
1991
|
nodesDraggable={canvasEditable}
|
|
1891
1992
|
nodesConnectable={canvasEditable}
|
|
1892
|
-
elementsSelectable={canvasEditable}
|
|
1993
|
+
elementsSelectable={canvasEditable || fd.lock.isLocked}
|
|
1994
|
+
deleteKey={canvasEditable ? undefined : null}
|
|
1893
1995
|
>
|
|
1894
1996
|
<!-- Renderless helpers. They live inside <SvelteFlow>, not beside it
|
|
1895
1997
|
under a provider: @xyflow/svelte >= 1.6.6 replaces the provider's
|
|
@@ -1990,11 +2092,14 @@
|
|
|
1990
2092
|
{/if}
|
|
1991
2093
|
</FlowDropZone>
|
|
1992
2094
|
|
|
1993
|
-
|
|
2095
|
+
<!-- Edit | Test, Run and the run bar change nothing in the workflow: a lock keeps them. -->
|
|
2096
|
+
{#if hostEditable}
|
|
1994
2097
|
<CanvasToolbar
|
|
1995
2098
|
editorMode={props.editorMode}
|
|
1996
2099
|
onEditorModeChange={props.onEditorModeChange}
|
|
1997
2100
|
onOpenTest={props.onOpenTest}
|
|
2101
|
+
onRun={props.onRun}
|
|
2102
|
+
runBusy={props.runBusy}
|
|
1998
2103
|
onAskAssistant={props.onAskAssistant}
|
|
1999
2104
|
showRun={props.showRunBar ?? true}
|
|
2000
2105
|
showRuns={props.showRuns}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '@xyflow/svelte/dist/style.css';
|
|
2
2
|
import type { WorkflowNode as WorkflowNodeType } from '../types/index.js';
|
|
3
3
|
import { type ContextMenuOptions } from '../editor/contextMenu.js';
|
|
4
|
+
import type { NodeMetadata } from '../types/index.js';
|
|
4
5
|
import type { EndpointConfig } from '../config/endpoints.js';
|
|
5
6
|
import type { AuthProvider } from '../types/auth.js';
|
|
6
7
|
import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
|
|
@@ -86,6 +87,10 @@ interface Props {
|
|
|
86
87
|
* while a run waits for them. Without it the button is not shown.
|
|
87
88
|
*/
|
|
88
89
|
onOpenTest?: () => void;
|
|
90
|
+
/** Start the workflow: the canvas toolbar's Run button (Edit mode). Without it the button is not shown. */
|
|
91
|
+
onRun?: () => void;
|
|
92
|
+
/** A run is being started: the Run button spins. */
|
|
93
|
+
runBusy?: boolean;
|
|
89
94
|
/** Current editor mode, shown in the canvas toolbar's Edit | Test switch. @default 'edit' */
|
|
90
95
|
editorMode?: 'edit' | 'test';
|
|
91
96
|
/** Switch the editor mode. The toolbar's Edit | Test switch is shown only when this is set. */
|
|
@@ -99,6 +104,7 @@ interface Props {
|
|
|
99
104
|
declare const WorkflowEditor: import("svelte").Component<Props, {
|
|
100
105
|
updateNodeData: (nodeId: string, dataUpdates: Partial<WorkflowNodeType["data"]>) => void;
|
|
101
106
|
refreshEdgePositions: (nodeId: string) => Promise<void>;
|
|
107
|
+
addNodeFromPalette: (metadata: NodeMetadata) => void;
|
|
102
108
|
canvasFitView: () => void;
|
|
103
109
|
canvasFocusNode: (nodeId: string) => void;
|
|
104
110
|
canvasZoomIn: () => void;
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
|
|
32
32
|
<script lang="ts">
|
|
33
33
|
import Icon from '@iconify/svelte';
|
|
34
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
34
35
|
import Button from './primitives/Button.svelte';
|
|
36
|
+
import { useFormReadOnly } from './form/readOnly.js';
|
|
35
37
|
import { m } from '../messages/index.js';
|
|
36
38
|
import WorkflowInterfaceEntryCard from './WorkflowInterfaceEntryCard.svelte';
|
|
37
39
|
import WorkflowInterfaceEntryComposer from './WorkflowInterfaceEntryComposer.svelte';
|
|
@@ -54,7 +56,8 @@
|
|
|
54
56
|
validateWorkflowInterface,
|
|
55
57
|
type InterfaceIssue,
|
|
56
58
|
type RankedBindablePort,
|
|
57
|
-
type ResolvedInterfaceEntry
|
|
59
|
+
type ResolvedInterfaceEntry,
|
|
60
|
+
nodeCanvasLabel
|
|
58
61
|
} from '../utils/workflowInterface.js';
|
|
59
62
|
|
|
60
63
|
interface Props {
|
|
@@ -92,6 +95,7 @@
|
|
|
92
95
|
dataTypes = DEFAULT_PORT_CONFIG.dataTypes.filter((dt) => dt.enabled !== false),
|
|
93
96
|
checker = new PortCompatibilityChecker(DEFAULT_PORT_CONFIG)
|
|
94
97
|
}: Props = $props();
|
|
98
|
+
const readOnly = useFormReadOnly();
|
|
95
99
|
|
|
96
100
|
type Direction = 'inputs' | 'outputs';
|
|
97
101
|
|
|
@@ -166,7 +170,7 @@
|
|
|
166
170
|
const edge = workflow.edges.find((e) => e.targetHandle === handleId);
|
|
167
171
|
if (!edge) return undefined;
|
|
168
172
|
const source = workflow.nodes.find((n) => n.id === edge.source);
|
|
169
|
-
return source
|
|
173
|
+
return source ? nodeCanvasLabel(source) : edge.source;
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
/**
|
|
@@ -188,6 +192,9 @@
|
|
|
188
192
|
*/
|
|
189
193
|
let rowIdSeq = 0;
|
|
190
194
|
|
|
195
|
+
/** Row ids of entries appended this session; their cards start open. */
|
|
196
|
+
const addedRowIds = new SvelteSet<string>();
|
|
197
|
+
|
|
191
198
|
function mintRowId(): string {
|
|
192
199
|
rowIdSeq += 1;
|
|
193
200
|
return `row-${rowIdSeq}`;
|
|
@@ -282,7 +289,9 @@
|
|
|
282
289
|
function appendEntry(direction: Direction, entry: WorkflowInterfaceEntry): void {
|
|
283
290
|
// A row id of its own, so adding an entry leaves every other card — and
|
|
284
291
|
// every other card's disclosure — exactly as the author left it.
|
|
285
|
-
|
|
292
|
+
const addedId = mintRowId();
|
|
293
|
+
addedRowIds.add(addedId);
|
|
294
|
+
rowIds[direction] = [...rowIds[direction], addedId];
|
|
286
295
|
commit(direction, [...entriesFor(direction), entry]);
|
|
287
296
|
composerFor = null;
|
|
288
297
|
}
|
|
@@ -298,7 +307,9 @@
|
|
|
298
307
|
direction,
|
|
299
308
|
entryFromBindablePort(
|
|
300
309
|
candidate,
|
|
301
|
-
entriesFor(direction).map((entry) => entry.id)
|
|
310
|
+
entriesFor(direction).map((entry) => entry.id),
|
|
311
|
+
workflow,
|
|
312
|
+
entryDirectionOf(direction)
|
|
302
313
|
)
|
|
303
314
|
);
|
|
304
315
|
}
|
|
@@ -412,6 +423,7 @@
|
|
|
412
423
|
: undefined}
|
|
413
424
|
{onOpenPlaygroundSettings}
|
|
414
425
|
turnSelector={workflow.playground === undefined}
|
|
426
|
+
initiallyOpen={addedRowIds.has(rowIds[section.key][index] ?? '')}
|
|
415
427
|
isFirst={index === 0}
|
|
416
428
|
isLast={index === list.length - 1}
|
|
417
429
|
onPatch={(patch: Partial<WorkflowInterfaceEntry>) =>
|
|
@@ -441,6 +453,7 @@
|
|
|
441
453
|
variant="ghost"
|
|
442
454
|
size="sm"
|
|
443
455
|
class="wf-interface__add"
|
|
456
|
+
disabled={readOnly()}
|
|
444
457
|
onclick={() => toggleComposer(section.key)}
|
|
445
458
|
>
|
|
446
459
|
{#snippet leadingIcon()}<Icon icon="heroicons:plus" />{/snippet}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import Icon from '@iconify/svelte';
|
|
23
23
|
import Button from './Button.svelte';
|
|
24
24
|
import IconButton from './primitives/IconButton.svelte';
|
|
25
|
+
import { useFormReadOnly } from './form/readOnly.js';
|
|
25
26
|
import Input from './Input.svelte';
|
|
26
27
|
import Select from './primitives/Select.svelte';
|
|
27
28
|
import Checkbox from './primitives/Checkbox.svelte';
|
|
@@ -47,7 +48,8 @@
|
|
|
47
48
|
turnsFor,
|
|
48
49
|
type RankedBindablePort,
|
|
49
50
|
type InterfaceIssue,
|
|
50
|
-
type ResolvedInterfaceEntry
|
|
51
|
+
type ResolvedInterfaceEntry,
|
|
52
|
+
nodeCanvasLabel
|
|
51
53
|
} from '../utils/workflowInterface.js';
|
|
52
54
|
|
|
53
55
|
interface Props {
|
|
@@ -81,6 +83,8 @@
|
|
|
81
83
|
* up. With settings, a stored `turn` shows as a deprecated chip instead.
|
|
82
84
|
*/
|
|
83
85
|
turnSelector?: boolean;
|
|
86
|
+
/** Open the secondary fields from the start (a row the author just added). */
|
|
87
|
+
initiallyOpen?: boolean;
|
|
84
88
|
isFirst: boolean;
|
|
85
89
|
isLast: boolean;
|
|
86
90
|
onPatch: (patch: Partial<WorkflowInterfaceEntry>) => void;
|
|
@@ -101,6 +105,7 @@
|
|
|
101
105
|
turnTakenBy,
|
|
102
106
|
onOpenPlaygroundSettings,
|
|
103
107
|
turnSelector = false,
|
|
108
|
+
initiallyOpen = false,
|
|
104
109
|
isFirst,
|
|
105
110
|
isLast,
|
|
106
111
|
onPatch,
|
|
@@ -116,7 +121,9 @@
|
|
|
116
121
|
*/
|
|
117
122
|
// The seed is meant to be read once.
|
|
118
123
|
// svelte-ignore state_referenced_locally
|
|
119
|
-
let fieldsOpen = $state(
|
|
124
|
+
let fieldsOpen = $state(
|
|
125
|
+
initiallyOpen || status?.status === 'type-mismatch' || turnTakenBy !== undefined
|
|
126
|
+
);
|
|
120
127
|
|
|
121
128
|
/** Statuses still explained in the footer (the rest render inline or as the dot). */
|
|
122
129
|
const FOOTER_STATUSES = new Set(['unbound', 'dangling', 'hidden', 'over-bound']);
|
|
@@ -185,18 +192,22 @@
|
|
|
185
192
|
* remove are never on screen at rest; the menu is the one way in, and it is a
|
|
186
193
|
* real menu (arrow keys, type-ahead, Escape), so the keyboard reaches all of it.
|
|
187
194
|
*/
|
|
195
|
+
/** Read-only (for example while the editor is locked): look, but do not change. */
|
|
196
|
+
const formReadOnly = useFormReadOnly();
|
|
197
|
+
const readOnly = $derived(formReadOnly());
|
|
198
|
+
|
|
188
199
|
const rowMenu = $derived<MenuEntry[]>([
|
|
189
200
|
{
|
|
190
201
|
label: m().workflowInterface.menuMoveUp,
|
|
191
202
|
icon: 'heroicons:chevron-up',
|
|
192
|
-
disabled: isFirst,
|
|
203
|
+
disabled: readOnly || isFirst,
|
|
193
204
|
testId: 'wf-entry-move-up',
|
|
194
205
|
onselect: () => onMove(-1)
|
|
195
206
|
},
|
|
196
207
|
{
|
|
197
208
|
label: m().workflowInterface.menuMoveDown,
|
|
198
209
|
icon: 'heroicons:chevron-down',
|
|
199
|
-
disabled: isLast,
|
|
210
|
+
disabled: readOnly || isLast,
|
|
200
211
|
testId: 'wf-entry-move-down',
|
|
201
212
|
onselect: () => onMove(1)
|
|
202
213
|
},
|
|
@@ -211,6 +222,7 @@
|
|
|
211
222
|
{
|
|
212
223
|
label: m().workflowInterface.menuRemove,
|
|
213
224
|
icon: 'heroicons:trash',
|
|
225
|
+
disabled: readOnly,
|
|
214
226
|
testId: 'wf-entry-remove',
|
|
215
227
|
onselect: onRemove
|
|
216
228
|
}
|
|
@@ -314,6 +326,7 @@
|
|
|
314
326
|
aria-label={m().workflowInterface.idLabel}
|
|
315
327
|
title={m().workflowInterface.idLabel}
|
|
316
328
|
spellcheck="false"
|
|
329
|
+
disabled={readOnly}
|
|
317
330
|
value={entry.id}
|
|
318
331
|
onchange={(e) => {
|
|
319
332
|
// An input needs an id: an emptied field goes back to the old one
|
|
@@ -334,6 +347,7 @@
|
|
|
334
347
|
aria-haspopup="listbox"
|
|
335
348
|
aria-expanded={pickerOpen}
|
|
336
349
|
title={m().workflowInterface.bindingChange}
|
|
350
|
+
disabled={readOnly}
|
|
337
351
|
onclick={() => (pickerOpen = !pickerOpen)}
|
|
338
352
|
>
|
|
339
353
|
<span class="wf-interface__sr">{m().workflowInterface.bindingLabel}:</span>
|
|
@@ -345,7 +359,7 @@
|
|
|
345
359
|
></span>
|
|
346
360
|
<span class="wf-interface__binding-path">
|
|
347
361
|
<span class="wf-interface__binding-node">
|
|
348
|
-
{boundTarget.node
|
|
362
|
+
{nodeCanvasLabel(boundTarget.node)}
|
|
349
363
|
</span>
|
|
350
364
|
<Icon icon="heroicons:chevron-right" />
|
|
351
365
|
<span class="wf-interface__binding-port">{boundTarget.port.name}</span>
|
|
@@ -374,6 +388,11 @@
|
|
|
374
388
|
{turnLabel}
|
|
375
389
|
</span>
|
|
376
390
|
{/if}
|
|
391
|
+
{#if isInput && !entry.name && !fieldsOpen}
|
|
392
|
+
<span class="wf-interface__turn-chip" data-testid="wf-entry-no-title">
|
|
393
|
+
{m().workflowInterface.noTitle}
|
|
394
|
+
</span>
|
|
395
|
+
{/if}
|
|
377
396
|
<Menu
|
|
378
397
|
size="sm"
|
|
379
398
|
align="end"
|
|
@@ -404,7 +423,7 @@
|
|
|
404
423
|
/>
|
|
405
424
|
<div class="wf-interface__picker-actions">
|
|
406
425
|
{#if entry.bindings[0]}
|
|
407
|
-
<Button variant="ghost" size="sm" onclick={unbind}>
|
|
426
|
+
<Button variant="ghost" size="sm" disabled={readOnly} onclick={unbind}>
|
|
408
427
|
<Icon icon="heroicons:link-slash" />
|
|
409
428
|
{m().workflowInterface.bindingUnbind}
|
|
410
429
|
</Button>
|
|
@@ -486,6 +505,7 @@
|
|
|
486
505
|
size="sm"
|
|
487
506
|
class="wf-interface__pull"
|
|
488
507
|
title={m().workflowInterface.pullFromPortTitle}
|
|
508
|
+
disabled={readOnly}
|
|
489
509
|
onclick={() => onPatch(pullEntryFieldsFromPort(boundTarget.port))}
|
|
490
510
|
>
|
|
491
511
|
<Icon icon="heroicons:arrow-down-tray" />
|
|
@@ -521,12 +541,18 @@
|
|
|
521
541
|
<option value={option.id}>{option.name}</option>
|
|
522
542
|
{/each}
|
|
523
543
|
</Select>
|
|
544
|
+
{#if isInput && entry.dataType === 'mixed'}
|
|
545
|
+
<span class="wf-interface__inline wf-interface__inline--warning">
|
|
546
|
+
{m().workflowInterface.mixedInputHint}
|
|
547
|
+
</span>
|
|
548
|
+
{/if}
|
|
524
549
|
{#if status?.status === 'type-mismatch' && boundPortType}
|
|
525
550
|
<span class="wf-interface__inline wf-interface__inline--warning">
|
|
526
551
|
{m().workflowInterface.typeMismatchInline({ portType: boundPortType ?? '' })}
|
|
527
552
|
<button
|
|
528
553
|
type="button"
|
|
529
554
|
class="wf-interface__quickfix"
|
|
555
|
+
disabled={readOnly}
|
|
530
556
|
onclick={() => onPatch({ dataType: boundPortType ?? entry.dataType })}
|
|
531
557
|
>
|
|
532
558
|
{m().workflowInterface.useMatchPortType}
|
|
@@ -584,6 +610,7 @@
|
|
|
584
610
|
<IconButton
|
|
585
611
|
size="sm"
|
|
586
612
|
class="wf-interface__example-remove"
|
|
613
|
+
disabled={readOnly}
|
|
587
614
|
onclick={() => removeExample(exampleIndex)}
|
|
588
615
|
ariaLabel={m().workflowInterface.removeExample}
|
|
589
616
|
>
|
|
@@ -591,7 +618,13 @@
|
|
|
591
618
|
</IconButton>
|
|
592
619
|
</div>
|
|
593
620
|
{/each}
|
|
594
|
-
<Button
|
|
621
|
+
<Button
|
|
622
|
+
variant="ghost"
|
|
623
|
+
size="sm"
|
|
624
|
+
class="wf-interface__example-add"
|
|
625
|
+
disabled={readOnly}
|
|
626
|
+
onclick={addExample}
|
|
627
|
+
>
|
|
595
628
|
<Icon icon="heroicons:plus" />
|
|
596
629
|
{m().workflowInterface.addExample}
|
|
597
630
|
</Button>
|
|
@@ -32,6 +32,8 @@ interface Props {
|
|
|
32
32
|
* up. With settings, a stored `turn` shows as a deprecated chip instead.
|
|
33
33
|
*/
|
|
34
34
|
turnSelector?: boolean;
|
|
35
|
+
/** Open the secondary fields from the start (a row the author just added). */
|
|
36
|
+
initiallyOpen?: boolean;
|
|
35
37
|
isFirst: boolean;
|
|
36
38
|
isLast: boolean;
|
|
37
39
|
onPatch: (patch: Partial<WorkflowInterfaceEntry>) => void;
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
<script lang="ts">
|
|
25
25
|
import Icon from '@iconify/svelte';
|
|
26
26
|
import Button from './Button.svelte';
|
|
27
|
+
import { useFormReadOnly } from './form/readOnly.js';
|
|
27
28
|
import Input from './Input.svelte';
|
|
28
29
|
import Select from './primitives/Select.svelte';
|
|
29
30
|
import Checkbox from './primitives/Checkbox.svelte';
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
let { workflow, onChange, onMoveTurns }: Props = $props();
|
|
74
|
+
const readOnly = useFormReadOnly();
|
|
73
75
|
|
|
74
76
|
/** The stored binding, every key present; `null` = not set up. */
|
|
75
77
|
const stored = $derived(
|
|
@@ -257,6 +259,7 @@
|
|
|
257
259
|
<Button
|
|
258
260
|
variant="secondary"
|
|
259
261
|
size="sm"
|
|
262
|
+
disabled={readOnly()}
|
|
260
263
|
onclick={() => turnChat && onMoveTurns?.(turnChat)}
|
|
261
264
|
>
|
|
262
265
|
{m().playgroundSettings.moveTurns}
|
|
@@ -276,7 +279,12 @@
|
|
|
276
279
|
{m().playgroundSettings.leftoverTurns}
|
|
277
280
|
{#snippet actions()}
|
|
278
281
|
{#if onMoveTurns}
|
|
279
|
-
<Button
|
|
282
|
+
<Button
|
|
283
|
+
variant="secondary"
|
|
284
|
+
size="sm"
|
|
285
|
+
disabled={readOnly()}
|
|
286
|
+
onclick={() => stored && onMoveTurns?.(stored)}
|
|
287
|
+
>
|
|
280
288
|
{m().playgroundSettings.removeTurns}
|
|
281
289
|
</Button>
|
|
282
290
|
{/if}
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
import FormPorts from './FormPorts.svelte';
|
|
60
60
|
import FormAutocomplete from './FormAutocomplete.svelte';
|
|
61
61
|
import { humanizeKey } from './humanizeKey.js';
|
|
62
|
+
import { useFormReadOnly } from './readOnly.js';
|
|
62
63
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
63
64
|
import { getResolvedTheme } from '../../stores/settingsStore.svelte.js';
|
|
64
65
|
import type { FormFieldFactoryProps } from './types.js';
|
|
@@ -98,9 +99,14 @@
|
|
|
98
99
|
}: Props = $props();
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
|
-
*
|
|
102
|
+
* Disable all inputs (no editing) when schema.readOnly is true or the form
|
|
103
|
+
* around the field is read-only (for example while the editor is locked).
|
|
102
104
|
*/
|
|
103
|
-
const
|
|
105
|
+
const formReadOnly = useFormReadOnly();
|
|
106
|
+
const isReadOnly = $derived(schema.readOnly === true || formReadOnly());
|
|
107
|
+
// Text, textarea and number fields take a read-only form from the form context
|
|
108
|
+
// themselves (as readonly, so the value stays selectable); they are disabled
|
|
109
|
+
// only by a read-only schema.
|
|
104
110
|
|
|
105
111
|
/**
|
|
106
112
|
* Computed description ID for ARIA association
|
|
@@ -331,7 +337,7 @@
|
|
|
331
337
|
placeholder={schema.placeholder ?? ''}
|
|
332
338
|
{required}
|
|
333
339
|
ariaDescribedBy={descriptionId}
|
|
334
|
-
disabled={
|
|
340
|
+
disabled={schema.readOnly === true}
|
|
335
341
|
onChange={(val) => onChange(val)}
|
|
336
342
|
/>
|
|
337
343
|
{:else if fieldType === 'text'}
|
|
@@ -341,7 +347,7 @@
|
|
|
341
347
|
placeholder={schema.placeholder ?? ''}
|
|
342
348
|
{required}
|
|
343
349
|
ariaDescribedBy={descriptionId}
|
|
344
|
-
disabled={
|
|
350
|
+
disabled={schema.readOnly === true}
|
|
345
351
|
onChange={(val) => onChange(val)}
|
|
346
352
|
/>
|
|
347
353
|
{:else if fieldType === 'number'}
|
|
@@ -354,7 +360,7 @@
|
|
|
354
360
|
step={schema.step}
|
|
355
361
|
{required}
|
|
356
362
|
ariaDescribedBy={descriptionId}
|
|
357
|
-
disabled={
|
|
363
|
+
disabled={schema.readOnly === true}
|
|
358
364
|
onChange={(val) => onChange(val)}
|
|
359
365
|
/>
|
|
360
366
|
{:else if fieldType === 'range'}
|
|
@@ -395,7 +401,8 @@
|
|
|
395
401
|
minItems={schema.minItems}
|
|
396
402
|
maxItems={schema.maxItems}
|
|
397
403
|
addLabel={`Add ${schema.items.title ?? 'Item'}`}
|
|
398
|
-
readOnly={
|
|
404
|
+
readOnly={schema.readOnly === true}
|
|
405
|
+
disabled={isReadOnly}
|
|
399
406
|
{itemRef}
|
|
400
407
|
help={arrayText.help}
|
|
401
408
|
onChange={(val) => onChange(val)}
|