@flowdrop/flowdrop 2.0.0-beta.5 → 2.0.0-beta.6
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 +24 -2
- package/dist/components/App.svelte +1 -10
- package/dist/components/ConfigForm.svelte +6 -505
- package/dist/components/ConfigForm.svelte.d.ts +4 -6
- package/dist/components/ConfigModal.svelte +0 -1
- package/dist/components/form/FormField.svelte +15 -0
- package/dist/components/form/FormFieldLight.svelte +14 -0
- package/dist/components/form/FormPorts.svelte +262 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/nodes/AtomNode.svelte +13 -39
- package/dist/components/nodes/GatewayNode.svelte +20 -56
- package/dist/components/nodes/SimpleNode.svelte +23 -49
- package/dist/components/nodes/SquareNode.svelte +23 -49
- package/dist/components/nodes/TerminalNode.svelte +25 -31
- package/dist/components/nodes/WorkflowNode.svelte +37 -84
- package/dist/core/index.d.ts +1 -1
- package/dist/openapi/v1/openapi.yaml +33 -21
- package/dist/schemas/v1/workflow.schema.json +16 -14
- package/dist/stores/workflowStore.svelte.d.ts +1 -1
- package/dist/stores/workflowStore.svelte.js +1 -1
- package/dist/types/index.d.ts +45 -20
- package/dist/utils/colors.d.ts +27 -0
- package/dist/utils/colors.js +23 -0
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfigSchema, WorkflowNode, WorkflowEdge,
|
|
1
|
+
import type { ConfigSchema, WorkflowNode, WorkflowEdge, AuthProvider } from '../types/index.js';
|
|
2
2
|
import type { UISchemaElement } from '../types/uischema.js';
|
|
3
3
|
interface Props {
|
|
4
4
|
/** Optional workflow node (if provided, schema and values are derived from it) */
|
|
@@ -14,8 +14,6 @@ interface Props {
|
|
|
14
14
|
uiSchema?: UISchemaElement;
|
|
15
15
|
/** Direct config values (used when node is not provided) */
|
|
16
16
|
values?: Record<string, unknown>;
|
|
17
|
-
/** Whether to show UI extension settings section */
|
|
18
|
-
showUIExtensions?: boolean;
|
|
19
17
|
/** Optional workflow ID for context in external links */
|
|
20
18
|
workflowId?: string;
|
|
21
19
|
/** Whether to also save the workflow when saving config */
|
|
@@ -33,9 +31,9 @@ interface Props {
|
|
|
33
31
|
/** Auth provider for API requests (used for template variable API mode) */
|
|
34
32
|
authProvider?: AuthProvider;
|
|
35
33
|
/** Callback when any field value changes (fired on blur for immediate sync) */
|
|
36
|
-
onChange?: (config: Record<string, unknown
|
|
37
|
-
/** Callback when form is saved
|
|
38
|
-
onSave?: (config: Record<string, unknown
|
|
34
|
+
onChange?: (config: Record<string, unknown>) => void;
|
|
35
|
+
/** Callback when form is saved */
|
|
36
|
+
onSave?: (config: Record<string, unknown>) => void;
|
|
39
37
|
/** Callback when form is cancelled */
|
|
40
38
|
onCancel?: () => void;
|
|
41
39
|
}
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
import FormSelect from './FormSelect.svelte';
|
|
38
38
|
import FormCheckboxGroup from './FormCheckboxGroup.svelte';
|
|
39
39
|
import FormArray from './FormArray.svelte';
|
|
40
|
+
import FormPorts from './FormPorts.svelte';
|
|
40
41
|
import FormCodeEditor from './FormCodeEditor.svelte';
|
|
41
42
|
import FormMarkdownEditor from './FormMarkdownEditor.svelte';
|
|
42
43
|
import FormTemplateEditor from './FormTemplateEditor.svelte';
|
|
@@ -140,6 +141,11 @@
|
|
|
140
141
|
return 'template-editor';
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
// Injected port order + exposure widget (the `ports` reserved config prop).
|
|
145
|
+
if (schema.format === 'ports') {
|
|
146
|
+
return 'ports';
|
|
147
|
+
}
|
|
148
|
+
|
|
143
149
|
// Shared basic field resolution (enum/oneOf/primitive types).
|
|
144
150
|
const base = resolveBaseFieldType(schema);
|
|
145
151
|
if (base) {
|
|
@@ -307,6 +313,15 @@
|
|
|
307
313
|
disabled={isReadOnly}
|
|
308
314
|
onChange={(val) => onChange(val)}
|
|
309
315
|
/>
|
|
316
|
+
{:else if fieldType === 'ports'}
|
|
317
|
+
<FormPorts
|
|
318
|
+
id={fieldKey}
|
|
319
|
+
{value}
|
|
320
|
+
ariaDescribedBy={descriptionId}
|
|
321
|
+
disabled={isReadOnly}
|
|
322
|
+
{node}
|
|
323
|
+
onChange={(val) => onChange(val)}
|
|
324
|
+
/>
|
|
310
325
|
{:else if fieldType === 'code-editor'}
|
|
311
326
|
<FormCodeEditor
|
|
312
327
|
id={fieldKey}
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
import FormSelect from './FormSelect.svelte';
|
|
43
43
|
import FormCheckboxGroup from './FormCheckboxGroup.svelte';
|
|
44
44
|
import FormArray from './FormArray.svelte';
|
|
45
|
+
import FormPorts from './FormPorts.svelte';
|
|
45
46
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
46
47
|
import { getResolvedTheme } from '../../stores/settingsStore.svelte.js';
|
|
47
48
|
|
|
@@ -140,6 +141,11 @@
|
|
|
140
141
|
return 'template-editor-fallback';
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
// Injected port order + exposure widget (the `ports` reserved config prop).
|
|
145
|
+
if (schema.format === 'ports') {
|
|
146
|
+
return 'ports';
|
|
147
|
+
}
|
|
148
|
+
|
|
143
149
|
// Object type without specific format would use code editor
|
|
144
150
|
if (schema.type === 'object' && !schema.format) {
|
|
145
151
|
return 'code-editor-fallback';
|
|
@@ -321,6 +327,14 @@
|
|
|
321
327
|
addLabel={`Add ${schema.items.title ?? 'Item'}`}
|
|
322
328
|
onChange={(val) => onChange(val)}
|
|
323
329
|
/>
|
|
330
|
+
{:else if fieldType === 'ports'}
|
|
331
|
+
<FormPorts
|
|
332
|
+
id={fieldKey}
|
|
333
|
+
{value}
|
|
334
|
+
ariaDescribedBy={descriptionId}
|
|
335
|
+
{node}
|
|
336
|
+
onChange={(val) => onChange(val)}
|
|
337
|
+
/>
|
|
324
338
|
{:else if fieldType.endsWith('-fallback')}
|
|
325
339
|
<!-- Fallback for unregistered heavy editors -->
|
|
326
340
|
<div class="form-field-fallback">
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Unified port widget — order + exposure
|
|
3
|
+
|
|
4
|
+
Renders one row per port of the node being configured, each carrying a
|
|
5
|
+
reorder control (up/down) and an expose/hide toggle. Binds to the injected
|
|
6
|
+
`ports` reserved config property (a PortsConfig: a per-direction ordered list
|
|
7
|
+
of {id, exposed?} entries).
|
|
8
|
+
|
|
9
|
+
Order is cosmetic — the engine ignores it. Exposure is semantic in v2: a
|
|
10
|
+
not-exposed port is hidden on the canvas, not wireable, and not
|
|
11
|
+
runtime-overridable.
|
|
12
|
+
|
|
13
|
+
The stored value is materialized as the FULL ordered list on the first edit
|
|
14
|
+
(so order + exposure stay independent inside one positional array), and reset
|
|
15
|
+
to `undefined` when it lands back on the metadata default order with no
|
|
16
|
+
exposure override.
|
|
17
|
+
|
|
18
|
+
@see .claude/plans/exposed-ports.md
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import type {
|
|
23
|
+
DynamicPort,
|
|
24
|
+
NodePort,
|
|
25
|
+
PortConfigEntry,
|
|
26
|
+
PortsConfig,
|
|
27
|
+
WorkflowNode
|
|
28
|
+
} from '../../types/index.js';
|
|
29
|
+
import { dynamicPortToNodePort } from '../../types/index.js';
|
|
30
|
+
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
31
|
+
import { getPortColorToken, getPortBackgroundColorForPort } from '../../utils/colors.js';
|
|
32
|
+
import { byDefaultOrder, isPortExposed, orderPortsFor } from '../../utils/portUtils.js';
|
|
33
|
+
import FormToggle from './FormToggle.svelte';
|
|
34
|
+
import Icon from '@iconify/svelte';
|
|
35
|
+
|
|
36
|
+
interface Props {
|
|
37
|
+
id: string;
|
|
38
|
+
value: unknown;
|
|
39
|
+
ariaDescribedBy?: string;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
onChange: (value: unknown) => void;
|
|
42
|
+
/** The node being configured, source of the port list + metadata defaults. */
|
|
43
|
+
node?: WorkflowNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let { id, value, ariaDescribedBy, disabled = false, onChange, node }: Props = $props();
|
|
47
|
+
|
|
48
|
+
const fd = getInstance();
|
|
49
|
+
const checker = fd.portCompatibility;
|
|
50
|
+
|
|
51
|
+
const portsConfig = $derived((value as PortsConfig | undefined) ?? {});
|
|
52
|
+
|
|
53
|
+
// Mirror the canvas: static metadata ports plus user-defined dynamic ports.
|
|
54
|
+
const inputPorts = $derived<NodePort[]>([
|
|
55
|
+
...(node?.data.metadata?.inputs ?? []),
|
|
56
|
+
...((node?.data.config?.dynamicInputs as DynamicPort[]) ?? []).map((p) =>
|
|
57
|
+
dynamicPortToNodePort(p, 'input')
|
|
58
|
+
)
|
|
59
|
+
]);
|
|
60
|
+
const outputPorts = $derived<NodePort[]>([
|
|
61
|
+
...(node?.data.metadata?.outputs ?? []),
|
|
62
|
+
...((node?.data.config?.dynamicOutputs as DynamicPort[]) ?? []).map((p) =>
|
|
63
|
+
dynamicPortToNodePort(p, 'output')
|
|
64
|
+
)
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
type Direction = 'inputs' | 'outputs';
|
|
68
|
+
|
|
69
|
+
function portsFor(direction: Direction): NodePort[] {
|
|
70
|
+
return direction === 'inputs' ? inputPorts : outputPorts;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Ports in the order the widget renders them (default order, then override). */
|
|
74
|
+
function orderedPorts(direction: Direction): NodePort[] {
|
|
75
|
+
return orderPortsFor(portsFor(direction), portsConfig[direction]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Write a direction's desired ordered list (each port carrying its effective
|
|
80
|
+
* exposure) back to the bound value, keeping it minimal: an entry's `exposed`
|
|
81
|
+
* flag is dropped when it equals the port's default, the whole direction is
|
|
82
|
+
* dropped when it carries neither a reorder nor an exposure override, and the
|
|
83
|
+
* value collapses to `undefined` when empty — so an untouched node stores
|
|
84
|
+
* nothing.
|
|
85
|
+
*/
|
|
86
|
+
function commit(
|
|
87
|
+
direction: Direction,
|
|
88
|
+
ordered: NodePort[],
|
|
89
|
+
exposureOf: (port: NodePort) => boolean
|
|
90
|
+
): void {
|
|
91
|
+
const entries: PortConfigEntry[] = ordered.map((port) => {
|
|
92
|
+
const entry: PortConfigEntry = { id: port.id };
|
|
93
|
+
const exposed = exposureOf(port);
|
|
94
|
+
if (exposed !== (port.exposedByDefault ?? true)) entry.exposed = exposed;
|
|
95
|
+
return entry;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const defaultOrder = byDefaultOrder(portsFor(direction)).map((p) => p.id);
|
|
99
|
+
const orderChanged = entries.some((e, i) => e.id !== defaultOrder[i]);
|
|
100
|
+
const hasExposureOverride = entries.some((e) => e.exposed !== undefined);
|
|
101
|
+
|
|
102
|
+
const next: PortsConfig = { ...portsConfig };
|
|
103
|
+
if (orderChanged || hasExposureOverride) next[direction] = entries;
|
|
104
|
+
else delete next[direction];
|
|
105
|
+
|
|
106
|
+
// We carry the untouched direction over verbatim from `portsConfig`, but an
|
|
107
|
+
// earlier edit there may have left an empty array; prune it so an all-default
|
|
108
|
+
// node collapses to `undefined` below rather than persisting `{inputs: []}`.
|
|
109
|
+
const other: Direction = direction === 'inputs' ? 'outputs' : 'inputs';
|
|
110
|
+
if (!next[other] || next[other]?.length === 0) delete next[other];
|
|
111
|
+
onChange(Object.keys(next).length === 0 ? undefined : next);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function setExposed(direction: Direction, portId: string, exposed: boolean): void {
|
|
115
|
+
commit(direction, orderedPorts(direction), (port) =>
|
|
116
|
+
port.id === portId ? exposed : isPortExposed(port, portsConfig[direction])
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function move(direction: Direction, index: number, delta: -1 | 1): void {
|
|
121
|
+
const ordered = orderedPorts(direction);
|
|
122
|
+
const target = index + delta;
|
|
123
|
+
if (target < 0 || target >= ordered.length) return;
|
|
124
|
+
[ordered[index], ordered[target]] = [ordered[target], ordered[index]];
|
|
125
|
+
commit(direction, ordered, (port) => isPortExposed(port, portsConfig[direction]));
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<div class="fd-ports" {id} aria-describedby={ariaDescribedBy}>
|
|
130
|
+
{#each [{ key: 'inputs', label: 'Inputs' }, { key: 'outputs', label: 'Outputs' }] as group (group.key)}
|
|
131
|
+
{@const direction = group.key as Direction}
|
|
132
|
+
{@const ordered = orderedPorts(direction)}
|
|
133
|
+
{#if ordered.length > 0}
|
|
134
|
+
<div class="fd-ports__group">
|
|
135
|
+
<span class="fd-ports__group-label">{group.label}</span>
|
|
136
|
+
<ul class="fd-ports__list">
|
|
137
|
+
{#each ordered as port, i (port.id)}
|
|
138
|
+
<li class="fd-ports__item">
|
|
139
|
+
<div class="fd-ports__reorder">
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
142
|
+
disabled={disabled || i === 0}
|
|
143
|
+
onclick={() => move(direction, i, -1)}
|
|
144
|
+
title="Move up"
|
|
145
|
+
aria-label={`Move ${port.name} up`}
|
|
146
|
+
>
|
|
147
|
+
<Icon icon="heroicons:chevron-up" />
|
|
148
|
+
</button>
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
disabled={disabled || i === ordered.length - 1}
|
|
152
|
+
onclick={() => move(direction, i, 1)}
|
|
153
|
+
title="Move down"
|
|
154
|
+
aria-label={`Move ${port.name} down`}
|
|
155
|
+
>
|
|
156
|
+
<Icon icon="heroicons:chevron-down" />
|
|
157
|
+
</button>
|
|
158
|
+
</div>
|
|
159
|
+
<span class="fd-ports__name">{port.name}</span>
|
|
160
|
+
<span
|
|
161
|
+
class="fd-ports__badge"
|
|
162
|
+
style="background-color:{getPortBackgroundColorForPort(
|
|
163
|
+
checker,
|
|
164
|
+
port,
|
|
165
|
+
15
|
|
166
|
+
)};color:{getPortColorToken(
|
|
167
|
+
checker,
|
|
168
|
+
port
|
|
169
|
+
)};border:1px solid {getPortBackgroundColorForPort(checker, port, 30)}"
|
|
170
|
+
>
|
|
171
|
+
{port.dataType}
|
|
172
|
+
</span>
|
|
173
|
+
<FormToggle
|
|
174
|
+
id={`${id}-${direction}-${port.id}`}
|
|
175
|
+
value={isPortExposed(port, portsConfig[direction])}
|
|
176
|
+
onLabel="Exposed"
|
|
177
|
+
offLabel="Hidden"
|
|
178
|
+
{disabled}
|
|
179
|
+
onChange={(exposed) => setExposed(direction, port.id, exposed)}
|
|
180
|
+
/>
|
|
181
|
+
</li>
|
|
182
|
+
{/each}
|
|
183
|
+
</ul>
|
|
184
|
+
</div>
|
|
185
|
+
{/if}
|
|
186
|
+
{/each}
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<style>
|
|
190
|
+
.fd-ports {
|
|
191
|
+
display: flex;
|
|
192
|
+
flex-direction: column;
|
|
193
|
+
gap: var(--fd-space-3, 0.75rem);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.fd-ports__group {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-direction: column;
|
|
199
|
+
gap: var(--fd-space-1, 0.25rem);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.fd-ports__group-label {
|
|
203
|
+
font-size: var(--fd-text-xs);
|
|
204
|
+
font-weight: 600;
|
|
205
|
+
color: var(--fd-text-muted);
|
|
206
|
+
text-transform: uppercase;
|
|
207
|
+
letter-spacing: 0.04em;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.fd-ports__list {
|
|
211
|
+
list-style: none;
|
|
212
|
+
margin: 0;
|
|
213
|
+
padding: 0;
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
gap: var(--fd-space-1, 0.25rem);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.fd-ports__item {
|
|
220
|
+
display: flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
gap: var(--fd-space-2, 0.5rem);
|
|
223
|
+
padding: var(--fd-space-1, 0.25rem) var(--fd-space-2, 0.5rem);
|
|
224
|
+
border-radius: var(--fd-radius-md, 6px);
|
|
225
|
+
border: 1px solid var(--fd-border-muted);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.fd-ports__reorder {
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-direction: column;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.fd-ports__reorder button {
|
|
234
|
+
display: flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
justify-content: center;
|
|
237
|
+
padding: 0;
|
|
238
|
+
border: none;
|
|
239
|
+
background: none;
|
|
240
|
+
color: var(--fd-text-muted);
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
line-height: 1;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.fd-ports__reorder button:disabled {
|
|
246
|
+
opacity: 0.3;
|
|
247
|
+
cursor: default;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.fd-ports__name {
|
|
251
|
+
flex: 1;
|
|
252
|
+
font-size: var(--fd-text-xs);
|
|
253
|
+
font-weight: 500;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.fd-ports__badge {
|
|
257
|
+
font-size: var(--fd-text-2xs, 0.625rem);
|
|
258
|
+
padding: 0 var(--fd-space-1, 0.25rem);
|
|
259
|
+
border-radius: var(--fd-radius-sm, 4px);
|
|
260
|
+
white-space: nowrap;
|
|
261
|
+
}
|
|
262
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WorkflowNode } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
id: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
ariaDescribedBy?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
onChange: (value: unknown) => void;
|
|
8
|
+
/** The node being configured, source of the port list + metadata defaults. */
|
|
9
|
+
node?: WorkflowNode;
|
|
10
|
+
}
|
|
11
|
+
declare const FormPorts: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type FormPorts = ReturnType<typeof FormPorts>;
|
|
13
|
+
export default FormPorts;
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
NodeExtensions,
|
|
18
18
|
NodePort,
|
|
19
19
|
AtomUIConfig,
|
|
20
|
+
PortsConfig,
|
|
20
21
|
WorkflowNode as WorkflowNodeType
|
|
21
22
|
} from '../../types/index.js';
|
|
22
|
-
import {
|
|
23
|
+
import { getPortColorToken } from '../../utils/colors.js';
|
|
23
24
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
24
|
-
import {
|
|
25
|
+
import { orderPortsFor, isPortVisible } from '../../utils/portUtils.js';
|
|
25
26
|
import { ProximityConnectHelper } from '../../helpers/proximityConnect.js';
|
|
26
27
|
|
|
27
28
|
interface AtomNodeData {
|
|
@@ -56,17 +57,7 @@
|
|
|
56
57
|
const atomCfg = $derived<AtomUIConfig>(
|
|
57
58
|
data.extensions?.ui?.atom ?? data.metadata?.extensions?.ui?.atom ?? {}
|
|
58
59
|
);
|
|
59
|
-
const
|
|
60
|
-
data.extensions?.ui?.hideUnconnectedHandles ??
|
|
61
|
-
data.metadata?.extensions?.ui?.hideUnconnectedHandles ??
|
|
62
|
-
false
|
|
63
|
-
);
|
|
64
|
-
const hiddenPorts = $derived(
|
|
65
|
-
data.extensions?.ui?.hiddenPorts ?? data.metadata?.extensions?.ui?.hiddenPorts ?? {}
|
|
66
|
-
);
|
|
67
|
-
const portOrder = $derived(
|
|
68
|
-
data.extensions?.ui?.portOrder ?? data.metadata?.extensions?.ui?.portOrder ?? {}
|
|
69
|
-
);
|
|
60
|
+
const portsConfig = $derived((data.config?.ports as PortsConfig | undefined) ?? {});
|
|
70
61
|
|
|
71
62
|
// Optional, server-driven accent. When unset the inline custom property is
|
|
72
63
|
// omitted, so CSS falls back to the neutral border — uncolored atoms are
|
|
@@ -90,32 +81,15 @@
|
|
|
90
81
|
const nodeLike = $derived<Pick<WorkflowNodeType, 'type' | 'data'>>({ type: nodeType, data });
|
|
91
82
|
|
|
92
83
|
const inPorts = $derived(
|
|
93
|
-
|
|
94
|
-
(p: NodePort) =>
|
|
95
|
-
isPortVisible(
|
|
96
|
-
p,
|
|
97
|
-
'input',
|
|
98
|
-
hiddenPorts,
|
|
99
|
-
hideUnconnectedHandles,
|
|
100
|
-
fd.workflow.connectedHandles,
|
|
101
|
-
nodeId
|
|
102
|
-
)
|
|
84
|
+
orderPortsFor(ProximityConnectHelper.getAllPorts(nodeLike, 'input'), portsConfig.inputs).filter(
|
|
85
|
+
(p: NodePort) => isPortVisible(p, 'input', portsConfig)
|
|
103
86
|
)
|
|
104
87
|
);
|
|
105
88
|
const outPorts = $derived(
|
|
106
|
-
|
|
89
|
+
orderPortsFor(
|
|
107
90
|
ProximityConnectHelper.getAllPorts(nodeLike, 'output'),
|
|
108
|
-
|
|
109
|
-
).filter((p: NodePort) =>
|
|
110
|
-
isPortVisible(
|
|
111
|
-
p,
|
|
112
|
-
'output',
|
|
113
|
-
hiddenPorts,
|
|
114
|
-
hideUnconnectedHandles,
|
|
115
|
-
fd.workflow.connectedHandles,
|
|
116
|
-
nodeId
|
|
117
|
-
)
|
|
118
|
-
)
|
|
91
|
+
portsConfig.outputs
|
|
92
|
+
).filter((p: NodePort) => isPortVisible(p, 'output', portsConfig))
|
|
119
93
|
);
|
|
120
94
|
|
|
121
95
|
/** Friendly label for a value, using the field's oneOf titles when present. */
|
|
@@ -157,9 +131,9 @@
|
|
|
157
131
|
type="target"
|
|
158
132
|
position={Position.Left}
|
|
159
133
|
id={`${nodeId}-input-${port.id}`}
|
|
160
|
-
style="--fd-handle-fill: var(--fd-port-skin-color, {
|
|
134
|
+
style="--fd-handle-fill: var(--fd-port-skin-color, {getPortColorToken(
|
|
161
135
|
checker,
|
|
162
|
-
port
|
|
136
|
+
port
|
|
163
137
|
)}); top: {portTopPct(index, inPorts.length)}%;"
|
|
164
138
|
/>
|
|
165
139
|
{/each}
|
|
@@ -192,9 +166,9 @@
|
|
|
192
166
|
type="source"
|
|
193
167
|
position={Position.Right}
|
|
194
168
|
id={`${nodeId}-output-${port.id}`}
|
|
195
|
-
style="--fd-handle-fill: var(--fd-port-skin-color, {
|
|
169
|
+
style="--fd-handle-fill: var(--fd-port-skin-color, {getPortColorToken(
|
|
196
170
|
checker,
|
|
197
|
-
port
|
|
171
|
+
port
|
|
198
172
|
)}); top: {portTopPct(index, outPorts.length)}%;"
|
|
199
173
|
/>
|
|
200
174
|
{/each}
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
Visual representation of gateway/branch nodes with branching flow indicators
|
|
4
4
|
Shows active branches and execution paths
|
|
5
5
|
Styled with BEM syntax following WorkflowNode pattern
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
6
|
+
|
|
7
|
+
Port rendering:
|
|
8
|
+
- Input-port exposure (data.config.ports, falling back to each port's
|
|
9
|
+
exposedByDefault) decides which input ports render, in effective order.
|
|
10
|
+
Branches are authored output paths and always render.
|
|
9
11
|
-->
|
|
10
12
|
|
|
11
13
|
<script lang="ts">
|
|
12
14
|
import { Position, Handle } from '@xyflow/svelte';
|
|
13
|
-
import type { WorkflowNode,
|
|
15
|
+
import type { WorkflowNode, Branch, PortsConfig } from '../../types/index.js';
|
|
14
16
|
import Icon from '@iconify/svelte';
|
|
15
17
|
import NodeConfigButton from './NodeConfigButton.svelte';
|
|
16
18
|
import { getNodeIcon } from '../../utils/icons.js';
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
getPortBackgroundColor
|
|
21
23
|
} from '../../utils/colors.js';
|
|
22
24
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
25
|
+
import { orderPortsFor, isPortVisible } from '../../utils/portUtils.js';
|
|
23
26
|
import { m } from '../../messages/index.js';
|
|
24
27
|
|
|
25
28
|
interface Props {
|
|
@@ -56,60 +59,21 @@
|
|
|
56
59
|
);
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
const hideUnconnectedHandles = $derived(
|
|
63
|
-
props.data.extensions?.ui?.hideUnconnectedHandles ??
|
|
64
|
-
props.data.metadata?.extensions?.ui?.hideUnconnectedHandles ??
|
|
65
|
-
false
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Check if a port should be visible based on connection state and settings
|
|
70
|
-
* @param port - The port to check
|
|
71
|
-
* @param type - Whether this is an 'input' or 'output' port
|
|
72
|
-
* @returns true if the port should be visible
|
|
62
|
+
* Per-instance port order + exposure, in config. Order overrides the metadata
|
|
63
|
+
* default; exposure is semantic (a not-exposed port is hidden, not wireable,
|
|
64
|
+
* not runtime-overridable).
|
|
73
65
|
*/
|
|
74
|
-
|
|
75
|
-
// Always show if hideUnconnectedHandles is disabled
|
|
76
|
-
if (!hideUnconnectedHandles) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Always show required ports
|
|
81
|
-
if (port.required) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Check if port is connected
|
|
86
|
-
const handleId = `${props.id}-${type}-${port.id}`;
|
|
87
|
-
return fd.workflow.connectedHandles.has(handleId);
|
|
88
|
-
}
|
|
66
|
+
const portsConfig = $derived((props.data.config?.ports as PortsConfig | undefined) ?? {});
|
|
89
67
|
|
|
90
68
|
/**
|
|
91
|
-
* Derived list of
|
|
69
|
+
* Derived list of exposed input ports, in effective order.
|
|
92
70
|
*/
|
|
93
71
|
const visibleInputPorts = $derived(
|
|
94
|
-
props.data.metadata.inputs.filter((port) =>
|
|
72
|
+
orderPortsFor(props.data.metadata.inputs, portsConfig.inputs).filter((port) =>
|
|
73
|
+
isPortVisible(port, 'input', portsConfig)
|
|
74
|
+
)
|
|
95
75
|
);
|
|
96
76
|
|
|
97
|
-
/**
|
|
98
|
-
* Check if a branch output should be visible based on connection state
|
|
99
|
-
* @param branchName - The branch name to check
|
|
100
|
-
* @returns true if the branch should be visible
|
|
101
|
-
*/
|
|
102
|
-
function isBranchVisible(branchName: string): boolean {
|
|
103
|
-
// Always show if hideUnconnectedHandles is disabled
|
|
104
|
-
if (!hideUnconnectedHandles) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Check if branch output is connected
|
|
109
|
-
const handleId = `${props.id}-output-${branchName}`;
|
|
110
|
-
return fd.workflow.connectedHandles.has(handleId);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
77
|
// Gateway-specific data - branches are calculated at runtime from config
|
|
114
78
|
let branches = $derived((props.data.config?.branches as Branch[]) || []);
|
|
115
79
|
let activeBranches = $derived(
|
|
@@ -117,9 +81,9 @@
|
|
|
117
81
|
);
|
|
118
82
|
|
|
119
83
|
/**
|
|
120
|
-
*
|
|
84
|
+
* Branches are authored output paths, so they always render.
|
|
121
85
|
*/
|
|
122
|
-
const visibleBranches = $derived(branches
|
|
86
|
+
const visibleBranches = $derived(branches);
|
|
123
87
|
|
|
124
88
|
/**
|
|
125
89
|
* Handle double-click to open config
|
|
@@ -178,7 +142,7 @@
|
|
|
178
142
|
</p>
|
|
179
143
|
</div>
|
|
180
144
|
|
|
181
|
-
<!-- Input Ports Container (
|
|
145
|
+
<!-- Input Ports Container (exposed input ports) -->
|
|
182
146
|
{#if visibleInputPorts.length > 0}
|
|
183
147
|
<div class="flowdrop-workflow-node__ports">
|
|
184
148
|
<div class="flowdrop-workflow-node__ports-list">
|
|
@@ -232,7 +196,7 @@
|
|
|
232
196
|
</div>
|
|
233
197
|
{/if}
|
|
234
198
|
|
|
235
|
-
<!-- Branches Section (Output Ports)
|
|
199
|
+
<!-- Branches Section (Output Ports) -->
|
|
236
200
|
{#if visibleBranches.length > 0}
|
|
237
201
|
<div class="flowdrop-workflow-node__ports">
|
|
238
202
|
<div class="flowdrop-workflow-node__ports-list">
|
|
@@ -300,7 +264,7 @@
|
|
|
300
264
|
</div>
|
|
301
265
|
</div>
|
|
302
266
|
{/if}
|
|
303
|
-
<!-- Note: When
|
|
267
|
+
<!-- Note: When there are no branches, we don't show anything -->
|
|
304
268
|
|
|
305
269
|
<!-- Config button -->
|
|
306
270
|
<NodeConfigButton onclick={handleNodeDoubleClick} title="Configure node" />
|