@flowdrop/flowdrop 2.0.0-beta.9 → 2.0.1

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/chat/batchFeedback.js +1 -1
  3. package/dist/chat/commandClassifier.d.ts +11 -0
  4. package/dist/chat/commandClassifier.js +20 -0
  5. package/dist/chat/historyBuilder.d.ts +39 -0
  6. package/dist/chat/historyBuilder.js +82 -0
  7. package/dist/chat/index.d.ts +2 -1
  8. package/dist/chat/index.js +2 -1
  9. package/dist/chat/responseParser.js +16 -12
  10. package/dist/commands/parser.d.ts +12 -0
  11. package/dist/commands/parser.js +33 -6
  12. package/dist/commands/storeIntegration.svelte.js +11 -1
  13. package/dist/components/App.svelte +56 -17
  14. package/dist/components/ConfigForm.svelte +98 -23
  15. package/dist/components/ConfigForm.svelte.d.ts +21 -2
  16. package/dist/components/ConfigModal.svelte +9 -0
  17. package/dist/components/ConfigPanel.svelte +0 -1
  18. package/dist/components/SettingsPanel.svelte +9 -0
  19. package/dist/components/WorkflowEditor.svelte +5 -2
  20. package/dist/components/chat/AIChatPanel.svelte +42 -6
  21. package/dist/components/chat/CommandPreview.svelte +10 -1
  22. package/dist/components/form/FormPorts.svelte +21 -3
  23. package/dist/components/form/FormRangeField.svelte +5 -3
  24. package/dist/components/form/FormToggle.svelte +27 -2
  25. package/dist/components/form/FormToggle.svelte.d.ts +5 -0
  26. package/dist/components/playground/ChatInput.svelte +316 -26
  27. package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
  28. package/dist/components/playground/ControlPanel.svelte +22 -0
  29. package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
  30. package/dist/components/playground/Playground.svelte +217 -4
  31. package/dist/components/surfaces/SurfaceOverlay.svelte +0 -1
  32. package/dist/config/endpoints.d.ts +48 -1
  33. package/dist/config/endpoints.js +18 -5
  34. package/dist/messages/defaults.d.ts +98 -0
  35. package/dist/messages/defaults.js +58 -1
  36. package/dist/playground/commands/args.d.ts +32 -0
  37. package/dist/playground/commands/args.js +50 -0
  38. package/dist/playground/commands/dispatch.d.ts +143 -0
  39. package/dist/playground/commands/dispatch.js +162 -0
  40. package/dist/playground/commands/index.d.ts +14 -0
  41. package/dist/playground/commands/index.js +10 -0
  42. package/dist/playground/commands/parser.d.ts +38 -0
  43. package/dist/playground/commands/parser.js +163 -0
  44. package/dist/playground/commands/registry.d.ts +42 -0
  45. package/dist/playground/commands/registry.js +122 -0
  46. package/dist/playground/commands/suggest.d.ts +37 -0
  47. package/dist/playground/commands/suggest.js +46 -0
  48. package/dist/playground/commands/types.d.ts +111 -0
  49. package/dist/playground/commands/types.js +15 -0
  50. package/dist/playground/index.d.ts +19 -0
  51. package/dist/playground/index.js +25 -0
  52. package/dist/playground/runAction.d.ts +48 -0
  53. package/dist/playground/runAction.js +31 -0
  54. package/dist/services/historyService.d.ts +30 -8
  55. package/dist/services/historyService.js +51 -15
  56. package/dist/services/pipelineSignalService.d.ts +97 -0
  57. package/dist/services/pipelineSignalService.js +94 -0
  58. package/dist/services/playgroundService.d.ts +12 -0
  59. package/dist/services/playgroundService.js +22 -0
  60. package/dist/services/workflowLaunchService.d.ts +74 -0
  61. package/dist/services/workflowLaunchService.js +74 -0
  62. package/dist/stores/historyStore.svelte.d.ts +17 -3
  63. package/dist/stores/historyStore.svelte.js +30 -3
  64. package/dist/stores/instanceContainer.svelte.js +5 -0
  65. package/dist/stores/workflowStore.svelte.d.ts +41 -4
  66. package/dist/stores/workflowStore.svelte.js +103 -13
  67. package/dist/types/chat.d.ts +5 -1
  68. package/dist/types/index.d.ts +2 -2
  69. package/dist/types/index.js +1 -1
  70. package/dist/types/settings.d.ts +11 -0
  71. package/dist/types/settings.js +2 -1
  72. package/dist/utils/canvasSelection.d.ts +25 -0
  73. package/dist/utils/canvasSelection.js +37 -0
  74. package/dist/utils/nodeFormSchema.d.ts +51 -0
  75. package/dist/utils/nodeFormSchema.js +87 -0
  76. package/package.json +1 -1
@@ -55,6 +55,10 @@ export interface WorkflowStoreActions {
55
55
  addEdge: (edge: WorkflowEdge) => void;
56
56
  removeEdge: (edgeId: string) => void;
57
57
  updateNode: (nodeId: string, updates: Partial<WorkflowNode>) => void;
58
+ updateNodeConfig: (nodeId: string, updates: Partial<WorkflowNode>, opts?: {
59
+ fieldKey?: string;
60
+ }) => void;
61
+ finalizeNodeConfig: (changeType?: WorkflowChangeType) => void;
58
62
  clear: () => void;
59
63
  updateMetadata: (metadata: Partial<Workflow['metadata']>) => void;
60
64
  batchUpdate: (updates: {
@@ -208,6 +212,38 @@ export declare class WorkflowStore {
208
212
  * Used for config changes. Pushes to history for undo support.
209
213
  */
210
214
  updateNode(nodeId: string, updates: Partial<WorkflowNode>): void;
215
+ /**
216
+ * Apply a live config edit to a node.
217
+ *
218
+ * Unlike {@link updateNode}, this is cheap enough to call on every keystroke:
219
+ * it does NOT snapshot the workflow to history and does NOT fire the external
220
+ * change event per call. Instead it opens (lazily) a single history
221
+ * transaction for the field-editing session and defers the change event to
222
+ * {@link finalizeNodeConfig}. Editing a different node or field first
223
+ * finalizes the previous session, so undo granularity is one step per field.
224
+ *
225
+ * The store always reflects the latest value immediately (the mutation and
226
+ * version bump happen here), so a save mid-session persists the current
227
+ * value even if the session hasn't been finalized yet.
228
+ *
229
+ * @param nodeId - Node whose config is being edited
230
+ * @param updates - Partial node updates (typically `{ data }`)
231
+ * @param opts.fieldKey - The config field being edited; drives per-field
232
+ * session boundaries. Omit to treat the whole node as one session.
233
+ */
234
+ updateNodeConfig(nodeId: string, updates: Partial<WorkflowNode>, opts?: {
235
+ fieldKey?: string;
236
+ }): void;
237
+ /**
238
+ * Finalize the in-progress config-edit session, if any.
239
+ *
240
+ * Commits the session's history transaction (one undo step for the whole
241
+ * session) and fires the external change event once. Idempotent: a no-op
242
+ * when no session is open. Call on blur, panel close, node switch, and before
243
+ * save. Undo/redo call this first (via the history facade / command dispatch)
244
+ * so a session becomes a committed step before it is undone.
245
+ */
246
+ finalizeNodeConfig(changeType?: WorkflowChangeType): void;
211
247
  /**
212
248
  * Clear the workflow.
213
249
  *
@@ -242,12 +278,13 @@ export declare class WorkflowStore {
242
278
  description?: string;
243
279
  }): void;
244
280
  /**
245
- * Push current state to history manually.
281
+ * Push the current (post-change) state to history manually.
246
282
  *
247
- * Use this before operations that modify the workflow through other means
248
- * (e.g., drag operations handled by SvelteFlow directly).
283
+ * Use this AFTER operations that modify the workflow through other means
284
+ * (e.g., drag operations handled by SvelteFlow directly), passing the
285
+ * resulting state so undo returns to the state before the operation.
249
286
  *
250
- * @param description - Description of the upcoming change
287
+ * @param description - Description of the change that was just made
251
288
  * @param workflow - Optional workflow to push (uses store state if not provided)
252
289
  */
253
290
  pushHistory(description?: string, workflow?: Workflow): void;
@@ -133,6 +133,19 @@ export class WorkflowStore {
133
133
  #restoringFromHistory = false;
134
134
  /** Whether history recording is enabled (disable for bulk operations). */
135
135
  #historyEnabled = true;
136
+ /**
137
+ * Identifies the config-edit session currently in progress, as
138
+ * `${nodeId}::${fieldKey}`, or null when no field is being edited.
139
+ *
140
+ * Config fields commit live on every change (see {@link updateNodeConfig}),
141
+ * but a whole field-editing session — however many keystrokes — should be a
142
+ * single undo step and fire the external change event only once. The session
143
+ * is a history transaction: opened lazily on the first change, coalescing all
144
+ * live edits, and closed by {@link finalizeNodeConfig}. A change to a
145
+ * different node/field auto-finalizes the previous session first, giving
146
+ * one-undo-step-per-field granularity.
147
+ */
148
+ #configEditKey = null;
136
149
  /** Undo/redo engine for this instance (constructor-injected). */
137
150
  #history;
138
151
  /** Bound mutation facade — see {@link WorkflowStoreActions}. */
@@ -151,6 +164,8 @@ export class WorkflowStore {
151
164
  addEdge: this.addEdge.bind(this),
152
165
  removeEdge: this.removeEdge.bind(this),
153
166
  updateNode: this.updateNode.bind(this),
167
+ updateNodeConfig: this.updateNodeConfig.bind(this),
168
+ finalizeNodeConfig: this.finalizeNodeConfig.bind(this),
154
169
  clear: this.clear.bind(this),
155
170
  updateMetadata: this.updateMetadata.bind(this),
156
171
  batchUpdate: this.batchUpdate.bind(this),
@@ -332,9 +347,14 @@ export class WorkflowStore {
332
347
  }
333
348
  }
334
349
  /**
335
- * Push current state to history before making changes.
350
+ * Record the current (post-change) state to history.
336
351
  *
337
- * @param description - Description of the change about to be made
352
+ * Call this AFTER mutating `#workflow` so the entry captures the new committed
353
+ * state — the history stack's top is the live state, making one undo == one
354
+ * change (see issue #39). Passing the pre-change state instead makes a single
355
+ * undo skip a step once there are two or more sequential edits.
356
+ *
357
+ * @param description - Description of the change that was just made
338
358
  * @param workflow - Optional workflow to push (uses store state if not provided)
339
359
  */
340
360
  #pushToHistory(description, workflow) {
@@ -355,6 +375,7 @@ export class WorkflowStore {
355
375
  * This sets the initial saved snapshot, clears dirty state, and initializes history.
356
376
  */
357
377
  initialize(workflow) {
378
+ this.#configEditKey = null;
358
379
  workflow = normalizeWorkflowMetadata(workflow);
359
380
  this.#workflow = workflow;
360
381
  // Reset version counters — workflow is "clean" after initialization
@@ -383,6 +404,9 @@ export class WorkflowStore {
383
404
  * This bypasses history recording to prevent recursive loops.
384
405
  */
385
406
  restoreFromHistory(workflow) {
407
+ // Undo/redo supersedes any in-progress config edit; drop the session marker
408
+ // (the history service already closed the transaction).
409
+ this.#configEditKey = null;
386
410
  this.#restoringFromHistory = true;
387
411
  workflow = normalizeWorkflowMetadata(workflow);
388
412
  this.#workflow = workflow;
@@ -446,7 +470,6 @@ export class WorkflowStore {
446
470
  }
447
471
  /** Add a node. */
448
472
  addNode(node) {
449
- this.#pushToHistory('Add node');
450
473
  if (!this.#workflow)
451
474
  return;
452
475
  this.#workflow = {
@@ -454,6 +477,7 @@ export class WorkflowStore {
454
477
  nodes: [...this.#workflow.nodes, node],
455
478
  metadata: buildMetadata(this.#workflow.metadata)
456
479
  };
480
+ this.#pushToHistory('Add node');
457
481
  this.#bumpVersion();
458
482
  this.#notifyWorkflowChange('node_add');
459
483
  }
@@ -464,7 +488,6 @@ export class WorkflowStore {
464
488
  * A single undo will restore both the node and its edges.
465
489
  */
466
490
  removeNode(nodeId) {
467
- this.#pushToHistory('Delete node');
468
491
  if (!this.#workflow)
469
492
  return;
470
493
  this.#workflow = {
@@ -473,6 +496,7 @@ export class WorkflowStore {
473
496
  edges: this.#workflow.edges.filter((edge) => edge.source !== nodeId && edge.target !== nodeId),
474
497
  metadata: buildMetadata(this.#workflow.metadata)
475
498
  };
499
+ this.#pushToHistory('Delete node');
476
500
  this.#bumpVersion();
477
501
  this.#notifyWorkflowChange('node_remove');
478
502
  }
@@ -485,18 +509,17 @@ export class WorkflowStore {
485
509
  // before touching history so a no-op stays a no-op.
486
510
  if (this.#workflow.edges.some((e) => e.id === edge.id))
487
511
  return;
488
- this.#pushToHistory('Add connection');
489
512
  this.#workflow = {
490
513
  ...this.#workflow,
491
514
  edges: [...this.#workflow.edges, edge],
492
515
  metadata: buildMetadata(this.#workflow.metadata)
493
516
  };
517
+ this.#pushToHistory('Add connection');
494
518
  this.#bumpVersion();
495
519
  this.#notifyWorkflowChange('edge_add');
496
520
  }
497
521
  /** Remove an edge. */
498
522
  removeEdge(edgeId) {
499
- this.#pushToHistory('Delete connection');
500
523
  if (!this.#workflow)
501
524
  return;
502
525
  this.#workflow = {
@@ -504,6 +527,7 @@ export class WorkflowStore {
504
527
  edges: this.#workflow.edges.filter((edge) => edge.id !== edgeId),
505
528
  metadata: buildMetadata(this.#workflow.metadata)
506
529
  };
530
+ this.#pushToHistory('Delete connection');
507
531
  this.#bumpVersion();
508
532
  this.#notifyWorkflowChange('edge_remove');
509
533
  }
@@ -513,7 +537,6 @@ export class WorkflowStore {
513
537
  * Used for config changes. Pushes to history for undo support.
514
538
  */
515
539
  updateNode(nodeId, updates) {
516
- this.#pushToHistory('Update node config');
517
540
  if (!this.#workflow)
518
541
  return;
519
542
  this.#workflow = {
@@ -521,15 +544,81 @@ export class WorkflowStore {
521
544
  nodes: this.#workflow.nodes.map((node) => node.id === nodeId ? { ...node, ...updates } : node),
522
545
  metadata: buildMetadata(this.#workflow.metadata)
523
546
  };
547
+ this.#pushToHistory('Update node config');
524
548
  this.#bumpVersion();
525
549
  this.#notifyWorkflowChange('node_config');
526
550
  }
551
+ /**
552
+ * Apply a live config edit to a node.
553
+ *
554
+ * Unlike {@link updateNode}, this is cheap enough to call on every keystroke:
555
+ * it does NOT snapshot the workflow to history and does NOT fire the external
556
+ * change event per call. Instead it opens (lazily) a single history
557
+ * transaction for the field-editing session and defers the change event to
558
+ * {@link finalizeNodeConfig}. Editing a different node or field first
559
+ * finalizes the previous session, so undo granularity is one step per field.
560
+ *
561
+ * The store always reflects the latest value immediately (the mutation and
562
+ * version bump happen here), so a save mid-session persists the current
563
+ * value even if the session hasn't been finalized yet.
564
+ *
565
+ * @param nodeId - Node whose config is being edited
566
+ * @param updates - Partial node updates (typically `{ data }`)
567
+ * @param opts.fieldKey - The config field being edited; drives per-field
568
+ * session boundaries. Omit to treat the whole node as one session.
569
+ */
570
+ updateNodeConfig(nodeId, updates, opts) {
571
+ if (!this.#workflow)
572
+ return;
573
+ const sessionKey = `${nodeId}::${opts?.fieldKey ?? ''}`;
574
+ // Moving to a different field/node closes the previous field's session.
575
+ if (this.#configEditKey !== null && this.#configEditKey !== sessionKey) {
576
+ this.finalizeNodeConfig();
577
+ }
578
+ // Open a transaction for this session on first touch. `push()` calls are
579
+ // no-ops until it commits, so the per-keystroke edits below never clone.
580
+ if (this.#configEditKey === null) {
581
+ if (this.#historyEnabled && !this.#restoringFromHistory) {
582
+ this.#history.startTransaction(this.#workflow, 'Update node config');
583
+ }
584
+ this.#configEditKey = sessionKey;
585
+ }
586
+ this.#workflow = {
587
+ ...this.#workflow,
588
+ nodes: this.#workflow.nodes.map((node) => node.id === nodeId ? { ...node, ...updates } : node),
589
+ metadata: buildMetadata(this.#workflow.metadata)
590
+ };
591
+ this.#bumpVersion();
592
+ // Deliberately no #pushToHistory (coalesced into the transaction) and no
593
+ // #notifyWorkflowChange (deferred to finalize) — that is the whole point.
594
+ }
595
+ /**
596
+ * Finalize the in-progress config-edit session, if any.
597
+ *
598
+ * Commits the session's history transaction (one undo step for the whole
599
+ * session) and fires the external change event once. Idempotent: a no-op
600
+ * when no session is open. Call on blur, panel close, node switch, and before
601
+ * save. Undo/redo call this first (via the history facade / command dispatch)
602
+ * so a session becomes a committed step before it is undone.
603
+ */
604
+ finalizeNodeConfig(changeType = 'node_config') {
605
+ if (this.#configEditKey === null)
606
+ return;
607
+ this.#configEditKey = null;
608
+ // A session can only be open when a workflow is loaded, so #workflow is
609
+ // non-null here; commit its final (post-change) state as one undo step.
610
+ if (this.#historyEnabled && this.#workflow) {
611
+ this.#history.commitTransaction(this.#workflow);
612
+ }
613
+ this.#notifyWorkflowChange(changeType);
614
+ }
527
615
  /**
528
616
  * Clear the workflow.
529
617
  *
530
618
  * Resets the workflow and clears history.
531
619
  */
532
620
  clear() {
621
+ this.#configEditKey = null;
533
622
  this.#workflow = null;
534
623
  this.#editVersion = 0;
535
624
  this.#savedVersion = 0;
@@ -556,7 +645,6 @@ export class WorkflowStore {
556
645
  * Creates a single history entry for the entire batch.
557
646
  */
558
647
  batchUpdate(updates) {
559
- this.#pushToHistory('Batch update');
560
648
  if (!this.#workflow)
561
649
  return;
562
650
  this.#workflow = {
@@ -570,6 +658,7 @@ export class WorkflowStore {
570
658
  ...(updates.config !== undefined && { config: updates.config }),
571
659
  metadata: buildMetadata(this.#workflow.metadata, updates.metadata ?? undefined)
572
660
  };
661
+ this.#pushToHistory('Batch update');
573
662
  this.#bumpVersion();
574
663
  this.#notifyWorkflowChange('metadata');
575
664
  }
@@ -580,7 +669,6 @@ export class WorkflowStore {
580
669
  * records a meaningful description for the undo history.
581
670
  */
582
671
  swapNode(updates) {
583
- this.#pushToHistory(updates.description ?? 'Swap node');
584
672
  if (!this.#workflow)
585
673
  return;
586
674
  this.#workflow = {
@@ -589,16 +677,18 @@ export class WorkflowStore {
589
677
  edges: updates.edges,
590
678
  metadata: buildMetadata(this.#workflow.metadata)
591
679
  };
680
+ this.#pushToHistory(updates.description ?? 'Swap node');
592
681
  this.#bumpVersion();
593
682
  this.#notifyWorkflowChange('node_swap');
594
683
  }
595
684
  /**
596
- * Push current state to history manually.
685
+ * Push the current (post-change) state to history manually.
597
686
  *
598
- * Use this before operations that modify the workflow through other means
599
- * (e.g., drag operations handled by SvelteFlow directly).
687
+ * Use this AFTER operations that modify the workflow through other means
688
+ * (e.g., drag operations handled by SvelteFlow directly), passing the
689
+ * resulting state so undo returns to the state before the operation.
600
690
  *
601
- * @param description - Description of the upcoming change
691
+ * @param description - Description of the change that was just made
602
692
  * @param workflow - Optional workflow to push (uses store state if not provided)
603
693
  */
604
694
  pushHistory(description, workflow) {
@@ -48,8 +48,12 @@ export interface ExtractedCommands {
48
48
  }
49
49
  /**
50
50
  * Status of a single command in the preview
51
+ *
52
+ * `skipped` means the command was intentionally not run (e.g. a layout command
53
+ * while `chatAllowLayoutChanges` is off) — it is not a failure and does not
54
+ * trigger retry feedback.
51
55
  */
52
- export type CommandExecutionStatus = 'pending' | 'executing' | 'success' | 'error';
56
+ export type CommandExecutionStatus = 'pending' | 'executing' | 'success' | 'error' | 'skipped';
53
57
  /**
54
58
  * A single command shown in the command preview UI
55
59
  */
@@ -196,8 +196,8 @@ export type PortCoordinateMap = Map<string, PortCoordinate>;
196
196
  export interface DynamicPort {
197
197
  /** Unique identifier for the port (used for handle IDs and connections) */
198
198
  name: string;
199
- /** Display label shown in the UI */
200
- label: string;
199
+ /** Display label shown in the UI (optional, defaults to name) */
200
+ label?: string;
201
201
  /** Description of what this port accepts/provides */
202
202
  description?: string;
203
203
  /** Data type for the port (affects color and connection validation) */
@@ -14,7 +14,7 @@ export const DEFAULT_WORKFLOW_FORMAT = 'flowdrop';
14
14
  export function dynamicPortToNodePort(port, portType) {
15
15
  return {
16
16
  id: port.name,
17
- name: port.label,
17
+ name: port.label ?? port.name,
18
18
  type: portType,
19
19
  dataType: port.dataType,
20
20
  required: port.required ?? false,
@@ -107,6 +107,17 @@ export interface BehaviorSettings {
107
107
  confirmDelete: boolean;
108
108
  /** Automatically re-submit batch failures to the AI for self-correction */
109
109
  chatAutoRetry: boolean;
110
+ /**
111
+ * Allow the AI assistant's commands to reposition nodes
112
+ * (`layout auto`, `layout beautify`).
113
+ *
114
+ * Turn off to protect a hand-crafted layout: those commands are then skipped
115
+ * (not failed) when a batch is applied, so the rest of the change set still
116
+ * lands. Positioning nodes explicitly via `add ... at <x>,<y>` and viewport
117
+ * commands (`canvas fitview`) are unaffected — they don't overwrite the
118
+ * arrangement of existing nodes.
119
+ */
120
+ chatAllowLayoutChanges: boolean;
110
121
  }
111
122
  /**
112
123
  * API connection and request settings
@@ -75,7 +75,8 @@ export const DEFAULT_BEHAVIOR_SETTINGS = {
75
75
  storeDraftsInBrowser: true,
76
76
  undoHistoryLimit: 50,
77
77
  confirmDelete: false,
78
- chatAutoRetry: true
78
+ chatAutoRetry: true,
79
+ chatAllowLayoutChanges: true
79
80
  };
80
81
  /**
81
82
  * Default API settings
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Canvas Selection Utilities
3
+ *
4
+ * Keeps canvas pointer gestures from turning into browser text-selection drags.
5
+ */
6
+ /**
7
+ * Suppress the text-selection drag a port handle mousedown would otherwise start.
8
+ *
9
+ * All canvas chrome is `user-select: none` (xyflow sets it on the node, pane and
10
+ * viewport), but WebKit still begins a selection drag from a mousedown on
11
+ * unselectable content: it anchors at the nearest selectable text *outside* the
12
+ * canvas — sidebar, toolbar, status bar or the surrounding host page — and
13
+ * extends it as the pointer moves, so drawing a connection paints a selection
14
+ * across the app (#37). Chromium and Firefox never start the gesture.
15
+ *
16
+ * Only handles need this: xyflow already suppresses the default for node drags
17
+ * (d3-drag) and pane drags. Handles are the one canvas drag started from a plain
18
+ * mousedown handler, so we suppress the default here — nothing in the connect
19
+ * flow depends on it, since xyflow tracks the drag on its own pointer listeners.
20
+ * The default action also moves focus, so re-apply it to keep the focus ring
21
+ * (`.svelte-flow__handle:focus` in base.css) behaving as before.
22
+ *
23
+ * Bind in the capture phase so xyflow's handle handler still receives the event.
24
+ */
25
+ export declare function suppressPortDragSelection(event: MouseEvent): void;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Canvas Selection Utilities
3
+ *
4
+ * Keeps canvas pointer gestures from turning into browser text-selection drags.
5
+ */
6
+ /**
7
+ * Suppress the text-selection drag a port handle mousedown would otherwise start.
8
+ *
9
+ * All canvas chrome is `user-select: none` (xyflow sets it on the node, pane and
10
+ * viewport), but WebKit still begins a selection drag from a mousedown on
11
+ * unselectable content: it anchors at the nearest selectable text *outside* the
12
+ * canvas — sidebar, toolbar, status bar or the surrounding host page — and
13
+ * extends it as the pointer moves, so drawing a connection paints a selection
14
+ * across the app (#37). Chromium and Firefox never start the gesture.
15
+ *
16
+ * Only handles need this: xyflow already suppresses the default for node drags
17
+ * (d3-drag) and pane drags. Handles are the one canvas drag started from a plain
18
+ * mousedown handler, so we suppress the default here — nothing in the connect
19
+ * flow depends on it, since xyflow tracks the drag on its own pointer listeners.
20
+ * The default action also moves focus, so re-apply it to keep the focus ring
21
+ * (`.svelte-flow__handle:focus` in base.css) behaving as before.
22
+ *
23
+ * Bind in the capture phase so xyflow's handle handler still receives the event.
24
+ */
25
+ export function suppressPortDragSelection(event) {
26
+ // Primary button only — other buttons never start a selection.
27
+ if (event.button !== 0)
28
+ return;
29
+ const target = event.target;
30
+ if (typeof target?.closest !== 'function')
31
+ return;
32
+ const handle = target.closest('.svelte-flow__handle');
33
+ if (!handle)
34
+ return;
35
+ event.preventDefault();
36
+ handle.focus();
37
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Node-level form contributions — the config fields the *editor* owns for every
3
+ * node, independent of what the node type's own `configSchema` declares.
4
+ *
5
+ * Today that is the port order + exposure widget bound to the reserved
6
+ * `config.ports` key (see {@link PORTS_CONFIG_KEY}). It is a library feature —
7
+ * `PortsConfig` is read by the canvas, not by the engine — so the library
8
+ * injects it rather than expecting every backend to serve it.
9
+ *
10
+ * Why this matters beyond convenience: `ConfigForm` renders its whole form only
11
+ * when it has a schema, so a node type contributing no `configSchema` used to
12
+ * fall straight through to "No configuration options available" and lose the
13
+ * node-level settings with it (#34). Injecting here gives such a node a schema,
14
+ * and the panel something to render.
15
+ *
16
+ * Kept as pure functions so they can be unit-tested directly against the same
17
+ * code `ConfigForm` runs, rather than through the component.
18
+ */
19
+ import type { ConfigSchema, WorkflowNode } from '../types/index.js';
20
+ import type { UISchemaElement } from '../types/uischema.js';
21
+ /**
22
+ * Reserved config key holding the instance's `PortsConfig` (per-direction
23
+ * ordered port list with optional exposure overrides).
24
+ */
25
+ export declare const PORTS_CONFIG_KEY = "ports";
26
+ /**
27
+ * Append the reserved `ports` property to a node's effective config schema.
28
+ *
29
+ * A no-op when there is no node (the standalone `schema`/`values` mode), when
30
+ * the schema already declares `ports` (a backend that serves the field itself
31
+ * stays authoritative), or when the node has no ports to configure — in which
32
+ * case a schema-less node keeps falling through to the empty state, as it
33
+ * should.
34
+ *
35
+ * @returns The schema to render — `base` untouched, or a copy with the field
36
+ * appended (last, so it renders below the node type's own fields).
37
+ */
38
+ export declare function withPortsField(base: ConfigSchema | undefined, node: WorkflowNode | undefined): ConfigSchema | undefined;
39
+ /**
40
+ * Mirror {@link withPortsField} in the UI schema.
41
+ *
42
+ * The UISchema renderer draws only the controls the tree lists, so an injected
43
+ * property is invisible unless a control is added for it. Wraps the authored
44
+ * tree and the new control in a `VerticalLayout`, keeping the author's layout
45
+ * intact and putting the ports control in its own collapsible group below it.
46
+ *
47
+ * @param uiSchema - The authored UI schema, if any. When absent, nothing to do:
48
+ * `ConfigForm` renders the schema's properties flat and picks the field up.
49
+ * @param injected - Whether {@link withPortsField} actually added the property.
50
+ */
51
+ export declare function withPortsControl(uiSchema: UISchemaElement | undefined, injected: boolean): UISchemaElement | undefined;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Reserved config key holding the instance's `PortsConfig` (per-direction
3
+ * ordered port list with optional exposure overrides).
4
+ */
5
+ export const PORTS_CONFIG_KEY = 'ports';
6
+ /** Config properties whose presence means the node can grow ports at runtime. */
7
+ const DYNAMIC_PORT_KEYS = ['dynamicInputs', 'dynamicOutputs'];
8
+ /**
9
+ * Whether the node has anything for the ports widget to show: a static
10
+ * metadata port, or a config field through which the author adds dynamic ones.
11
+ *
12
+ * Deliberately reads only `metadata` and the schema — never `data.config`.
13
+ * `ConfigForm` drops its in-flight `edits` buffer whenever the effective schema
14
+ * changes identity, so a decision that moved with config values would discard a
15
+ * user's half-typed edit the moment it flipped.
16
+ */
17
+ function hasConfigurablePorts(node, schema) {
18
+ const meta = node.data.metadata;
19
+ if ((meta?.inputs?.length ?? 0) > 0 || (meta?.outputs?.length ?? 0) > 0)
20
+ return true;
21
+ const properties = schema?.properties;
22
+ if (!properties)
23
+ return false;
24
+ return DYNAMIC_PORT_KEYS.some((key) => key in properties);
25
+ }
26
+ /**
27
+ * Append the reserved `ports` property to a node's effective config schema.
28
+ *
29
+ * A no-op when there is no node (the standalone `schema`/`values` mode), when
30
+ * the schema already declares `ports` (a backend that serves the field itself
31
+ * stays authoritative), or when the node has no ports to configure — in which
32
+ * case a schema-less node keeps falling through to the empty state, as it
33
+ * should.
34
+ *
35
+ * @returns The schema to render — `base` untouched, or a copy with the field
36
+ * appended (last, so it renders below the node type's own fields).
37
+ */
38
+ export function withPortsField(base, node) {
39
+ if (!node)
40
+ return base;
41
+ if (base?.properties && PORTS_CONFIG_KEY in base.properties)
42
+ return base;
43
+ if (!hasConfigurablePorts(node, base))
44
+ return base;
45
+ return {
46
+ ...(base ?? { type: 'object', properties: {} }),
47
+ properties: {
48
+ ...(base?.properties ?? {}),
49
+ [PORTS_CONFIG_KEY]: {
50
+ type: 'object',
51
+ // The signal FormField/FormFieldLight match to render <FormPorts>.
52
+ format: 'ports',
53
+ title: 'Ports',
54
+ description: 'Order the node’s ports and choose which ones are exposed.'
55
+ }
56
+ }
57
+ };
58
+ }
59
+ /**
60
+ * Mirror {@link withPortsField} in the UI schema.
61
+ *
62
+ * The UISchema renderer draws only the controls the tree lists, so an injected
63
+ * property is invisible unless a control is added for it. Wraps the authored
64
+ * tree and the new control in a `VerticalLayout`, keeping the author's layout
65
+ * intact and putting the ports control in its own collapsible group below it.
66
+ *
67
+ * @param uiSchema - The authored UI schema, if any. When absent, nothing to do:
68
+ * `ConfigForm` renders the schema's properties flat and picks the field up.
69
+ * @param injected - Whether {@link withPortsField} actually added the property.
70
+ */
71
+ export function withPortsControl(uiSchema, injected) {
72
+ if (!uiSchema || !injected)
73
+ return uiSchema;
74
+ return {
75
+ type: 'VerticalLayout',
76
+ elements: [
77
+ uiSchema,
78
+ {
79
+ type: 'Group',
80
+ label: 'Ports',
81
+ collapsible: true,
82
+ defaultOpen: false,
83
+ elements: [{ type: 'Control', scope: `#/properties/${PORTS_CONFIG_KEY}` }]
84
+ }
85
+ ]
86
+ };
87
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.0.0-beta.9",
6
+ "version": "2.0.1",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"