@flowdrop/flowdrop 2.15.2 → 2.17.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/README.md +10 -1
  3. package/dist/components/App.svelte +219 -6
  4. package/dist/components/App.svelte.d.ts +8 -0
  5. package/dist/components/CanvasToolbar.svelte +40 -3
  6. package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
  7. package/dist/components/ConnectPortPicker.svelte +8 -4
  8. package/dist/components/DoctorMenu.svelte +208 -126
  9. package/dist/components/ImpactConfirm.svelte +341 -0
  10. package/dist/components/ImpactConfirm.svelte.d.ts +12 -0
  11. package/dist/components/Input.svelte +2 -2
  12. package/dist/components/Navbar.svelte +48 -3
  13. package/dist/components/Navbar.svelte.d.ts +4 -0
  14. package/dist/components/NodeSidebar.svelte +36 -15
  15. package/dist/components/NodeSidebar.svelte.d.ts +2 -0
  16. package/dist/components/NodeSwapPicker.svelte +4 -14
  17. package/dist/components/RunBar.svelte +36 -1
  18. package/dist/components/RunBar.svelte.d.ts +5 -0
  19. package/dist/components/RunInputsDialog.svelte +198 -0
  20. package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
  21. package/dist/components/SchemaForm.svelte +2 -1
  22. package/dist/components/SchemaForm.svelte.d.ts +2 -1
  23. package/dist/components/WorkflowCompareDialog.svelte +177 -0
  24. package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
  25. package/dist/components/WorkflowEditor.svelte +88 -6
  26. package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
  27. package/dist/components/WorkflowInterfaceEditor.svelte +14 -4
  28. package/dist/components/WorkflowInterfaceEntryCard.svelte +19 -3
  29. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
  30. package/dist/components/form/FormAutocomplete.svelte +76 -12
  31. package/dist/components/nodes/NodeCard.svelte +2 -2
  32. package/dist/components/primitives/Button.svelte +1 -1
  33. package/dist/components/primitives/Button.svelte.d.ts +1 -1
  34. package/dist/components/primitives/Card.svelte +1 -1
  35. package/dist/components/primitives/Card.svelte.d.ts +1 -1
  36. package/dist/components/primitives/Checkbox.svelte +1 -1
  37. package/dist/components/primitives/Checkbox.svelte.d.ts +1 -1
  38. package/dist/components/primitives/Chip.svelte +1 -1
  39. package/dist/components/primitives/Chip.svelte.d.ts +1 -1
  40. package/dist/components/primitives/Combobox.svelte +1 -1
  41. package/dist/components/primitives/Combobox.svelte.d.ts +1 -1
  42. package/dist/components/primitives/Composer.svelte +1 -1
  43. package/dist/components/primitives/Composer.svelte.d.ts +1 -1
  44. package/dist/components/primitives/EmptyState.svelte +1 -1
  45. package/dist/components/primitives/EmptyState.svelte.d.ts +1 -1
  46. package/dist/components/primitives/Field.svelte +1 -1
  47. package/dist/components/primitives/Field.svelte.d.ts +1 -1
  48. package/dist/components/primitives/IconButton.svelte +1 -1
  49. package/dist/components/primitives/IconButton.svelte.d.ts +1 -1
  50. package/dist/components/primitives/Menu.svelte +1 -1
  51. package/dist/components/primitives/Menu.svelte.d.ts +1 -1
  52. package/dist/components/primitives/Notice.svelte +1 -1
  53. package/dist/components/primitives/Notice.svelte.d.ts +1 -1
  54. package/dist/components/primitives/PanelHeader.svelte +1 -1
  55. package/dist/components/primitives/PanelHeader.svelte.d.ts +1 -1
  56. package/dist/components/primitives/Segmented.svelte +2 -2
  57. package/dist/components/primitives/Segmented.svelte.d.ts +2 -2
  58. package/dist/components/primitives/Select.svelte +1 -1
  59. package/dist/components/primitives/Select.svelte.d.ts +1 -1
  60. package/dist/components/primitives/StatusPill.svelte +1 -1
  61. package/dist/components/primitives/StatusPill.svelte.d.ts +1 -1
  62. package/dist/components/primitives/Switch.svelte +1 -1
  63. package/dist/components/primitives/Switch.svelte.d.ts +1 -1
  64. package/dist/components/primitives/Tabs.svelte +2 -2
  65. package/dist/components/primitives/Tabs.svelte.d.ts +2 -2
  66. package/dist/components/primitives/Toolbar.svelte +1 -1
  67. package/dist/components/primitives/Toolbar.svelte.d.ts +1 -1
  68. package/dist/components/primitives/ToolbarSeparator.svelte +1 -1
  69. package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +1 -1
  70. package/dist/components/toast/DismissibleToast.svelte +25 -6
  71. package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
  72. package/dist/config/endpoints.d.ts +7 -0
  73. package/dist/config/endpoints.js +2 -1
  74. package/dist/editor/connectCandidates.d.ts +3 -0
  75. package/dist/editor/connectCandidates.js +14 -5
  76. package/dist/editor/index.d.ts +1 -1
  77. package/dist/editor/index.js +1 -1
  78. package/dist/helpers/workflowEditorHelper.d.ts +15 -0
  79. package/dist/helpers/workflowEditorHelper.js +9 -0
  80. package/dist/index.d.ts +1 -0
  81. package/dist/messages/defaults.d.ts +101 -0
  82. package/dist/messages/defaults.js +92 -1
  83. package/dist/openapi/v1/openapi.yaml +10 -2
  84. package/dist/schemas/v1/workflow.schema.json +1 -1
  85. package/dist/services/draftStorage.d.ts +24 -10
  86. package/dist/services/draftStorage.js +60 -35
  87. package/dist/services/globalSave.d.ts +28 -10
  88. package/dist/services/globalSave.js +135 -31
  89. package/dist/services/impactGate.d.ts +34 -0
  90. package/dist/services/impactGate.js +70 -0
  91. package/dist/services/impactService.d.ts +28 -0
  92. package/dist/services/impactService.js +71 -0
  93. package/dist/services/toastQueue.d.ts +9 -0
  94. package/dist/services/toastService.d.ts +4 -0
  95. package/dist/services/toastService.js +9 -3
  96. package/dist/services/workflowLaunchService.js +3 -1
  97. package/dist/settings/index.d.ts +2 -2
  98. package/dist/settings/index.js +1 -1
  99. package/dist/stores/doctorStore.svelte.d.ts +24 -1
  100. package/dist/stores/doctorStore.svelte.js +105 -2
  101. package/dist/stores/instanceContainer.svelte.d.ts +16 -0
  102. package/dist/stores/instanceContainer.svelte.js +22 -2
  103. package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
  104. package/dist/stores/saveConflictStore.svelte.js +169 -0
  105. package/dist/stores/workflowStore.svelte.d.ts +7 -3
  106. package/dist/stores/workflowStore.svelte.js +14 -5
  107. package/dist/styles/toast.css +10 -1
  108. package/dist/svelte-app.d.ts +23 -0
  109. package/dist/svelte-app.js +114 -3
  110. package/dist/themes/scopedSkinCss.d.ts +22 -0
  111. package/dist/themes/scopedSkinCss.js +27 -1
  112. package/dist/types/doctor.d.ts +3 -1
  113. package/dist/types/events.d.ts +20 -0
  114. package/dist/types/events.js +2 -0
  115. package/dist/types/impact.d.ts +25 -0
  116. package/dist/types/impact.js +7 -0
  117. package/dist/types/index.d.ts +11 -1
  118. package/dist/types/settings.d.ts +31 -0
  119. package/dist/types/settings.js +132 -0
  120. package/dist/ui/index.d.ts +76 -0
  121. package/dist/ui/index.js +81 -0
  122. package/dist/utils/apiUrl.d.ts +55 -0
  123. package/dist/utils/apiUrl.js +117 -0
  124. package/dist/utils/draftRestore.d.ts +27 -0
  125. package/dist/utils/draftRestore.js +36 -0
  126. package/dist/utils/interfaceTags.js +4 -1
  127. package/dist/utils/nodeSearch.d.ts +10 -0
  128. package/dist/utils/nodeSearch.js +37 -0
  129. package/dist/utils/portal.js +45 -3
  130. package/dist/utils/runOffer.d.ts +21 -0
  131. package/dist/utils/runOffer.js +13 -0
  132. package/dist/utils/workflowCompare.d.ts +35 -0
  133. package/dist/utils/workflowCompare.js +84 -0
  134. package/dist/utils/workflowInterface.d.ts +26 -1
  135. package/dist/utils/workflowInterface.js +91 -11
  136. package/dist/webmcp/index.d.ts +5 -0
  137. package/dist/webmcp/index.js +5 -0
  138. package/package.json +8 -2
@@ -6,19 +6,21 @@
6
6
  *
7
7
  * @module svelte-app
8
8
  */
9
- import { mount, unmount } from 'svelte';
9
+ import { mount, unmount, createRawSnippet, untrack } from 'svelte';
10
10
  import WorkflowEditor from './components/WorkflowEditor.svelte';
11
11
  import App from './components/App.svelte';
12
12
  import { DEFAULT_PORT_CONFIG } from './config/defaultPortConfig.js';
13
13
  import { fetchPortConfig } from './services/portConfigApi.js';
14
14
  import { fetchCategories } from './services/categoriesApi.js';
15
15
  import { createFlowDropInstance, definedHostHooks, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
16
- import { DraftAutoSaveManager, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
16
+ import { DraftAutoSaveManager, loadDraft, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
17
17
  import { mergeFeatures } from './types/events.js';
18
18
  import { initializeSettings, getHostColorSchemeRegistration, releaseHostColorScheme, getBehaviorSettings, onSettingsChange } from './stores/settingsStore.svelte.js';
19
19
  import { logger } from './utils/logger.js';
20
20
  import { globalSaveWorkflow, globalExportWorkflow } from './services/globalSave.js';
21
21
  import { whenWorkflowLoaded } from './utils/whenWorkflowLoaded.svelte.js';
22
+ import { draftOffer, draftTimeLabel } from './utils/draftRestore.js';
23
+ import { showWarning } from './services/toastService.js';
22
24
  import { parseCommand } from './commands/parser.js';
23
25
  import { executeCommand } from './commands/executor.js';
24
26
  import { isSessionLine } from './commands/session.js';
@@ -279,7 +281,45 @@ function createRunCommand(fd, isDestroyed, registerCancel, onBaseline) {
279
281
  * ```
280
282
  */
281
283
  export async function mountFlowDropApp(container, options = {}) {
282
- const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarActions, branding, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
284
+ const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, editorMode, onEditorModeChange, playground, pipelineId, navbarTitle, navbarTitleLevel, navbarActions, branding, navbarEnd, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, colorScheme, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, workflowSettingsSchema, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host, contextMenu } = options;
285
+ // The host's element callback becomes a snippet: one empty host element, handed
286
+ // to the callback in `setup`, whose return value is the cleanup.
287
+ if (navbarEnd && showNavbar !== true) {
288
+ logger.warn('[FlowDrop] navbarEnd was given but showNavbar is not true: the navbar is hidden, so navbarEnd will not render.');
289
+ }
290
+ const navbarEndSnippet = navbarEnd
291
+ ? createRawSnippet(() => ({
292
+ render: () => '<div class="flowdrop-navbar__host-end"></div>',
293
+ setup: (el) => {
294
+ let cleanup;
295
+ let gone = false;
296
+ const run = () => {
297
+ if (gone)
298
+ return;
299
+ // untrack: state the host reads must not re-run the navbar. A throwing
300
+ // callback is logged and skipped, so it cannot break the editor.
301
+ try {
302
+ const result = untrack(() => navbarEnd(el));
303
+ if (typeof result === 'function')
304
+ cleanup = result;
305
+ }
306
+ catch (error) {
307
+ logger.error('[FlowDrop] navbarEnd callback failed:', error);
308
+ }
309
+ };
310
+ // On the editor's first render the navbar is built before it is
311
+ // attached to the page; the host gets the element once it is in it.
312
+ if (el.isConnected)
313
+ run();
314
+ else
315
+ queueMicrotask(run);
316
+ return () => {
317
+ gone = true;
318
+ cleanup?.();
319
+ };
320
+ }
321
+ }))
322
+ : undefined;
283
323
  // Per-instance state container — this is what allows multiple FlowDrop
284
324
  // editors to coexist on one page without sharing workflow/history state.
285
325
  const { fd, isDefault } = acquireInstance(instanceId);
@@ -344,8 +384,10 @@ export async function mountFlowDropApp(container, options = {}) {
344
384
  playground,
345
385
  pipelineId,
346
386
  navbarTitle,
387
+ navbarTitleLevel,
347
388
  navbarActions,
348
389
  branding,
390
+ navbarEnd: navbarEndSnippet,
349
391
  showSettings,
350
392
  showStatus,
351
393
  endpointConfig: config,
@@ -377,6 +419,7 @@ export async function mountFlowDropApp(container, options = {}) {
377
419
  // Set up draft auto-save manager
378
420
  let draftManager = null;
379
421
  let unsubscribeDraftSettings = null;
422
+ let cancelDraftOffer = null;
380
423
  if (features.autoSaveDraft) {
381
424
  // Instance-scoped prefix: every instance (including the default) gets
382
425
  // 'flowdrop:draft:<id>' sub-keys.
@@ -399,6 +442,54 @@ export async function mountFlowDropApp(container, options = {}) {
399
442
  storage: draftStorageAdapter
400
443
  });
401
444
  draftManager.start();
445
+ // Offer a draft left behind by an earlier session (a reload, a crash).
446
+ // Not for a brand-new workflow: its key is shared by every tab.
447
+ const offerKey = draftManager.getStorageKey();
448
+ if (mode !== 'readonly' && mode !== 'locked' && !offerKey.endsWith(':new')) {
449
+ const manager = draftManager;
450
+ cancelDraftOffer = whenWorkflowLoaded(fd, (loaded) => {
451
+ const draft = loadDraft(offerKey, draftStorageAdapter);
452
+ const offer = draftOffer(draft, loaded);
453
+ if (!draft)
454
+ return;
455
+ if (!offer) {
456
+ manager.clearDraft();
457
+ return;
458
+ }
459
+ const text = fd.messages().drafts;
460
+ // The offer is open until Restore or Discard: keep the draft meanwhile.
461
+ const release = manager.holdDraft();
462
+ showWarning({
463
+ title: text.found({ time: draftTimeLabel(offer.savedAt) }),
464
+ body: offer.savedSince ? text.savedSince : undefined,
465
+ actions: [
466
+ {
467
+ label: text.restore,
468
+ primary: true,
469
+ onClick: () => {
470
+ release();
471
+ fd.workflow.batchUpdate({
472
+ nodes: draft.workflow.nodes,
473
+ edges: draft.workflow.edges,
474
+ name: draft.workflow.name,
475
+ description: draft.workflow.description,
476
+ interface: draft.workflow.interface,
477
+ playground: draft.workflow.playground
478
+ });
479
+ manager.forceSave();
480
+ }
481
+ },
482
+ {
483
+ label: text.discard,
484
+ onClick: () => {
485
+ release();
486
+ manager.clearDraft();
487
+ }
488
+ }
489
+ ]
490
+ }, { id: `flowdrop:draft-offer:${offerKey}` });
491
+ });
492
+ }
402
493
  // When the user opts out, also remove the draft already in storage.
403
494
  unsubscribeDraftSettings = onSettingsChange((event) => {
404
495
  if (event.category === 'behavior' &&
@@ -421,6 +512,21 @@ export async function mountFlowDropApp(container, options = {}) {
421
512
  let destroyed = false;
422
513
  // Calls to runCommand still waiting for the workflow; settled on destroy.
423
514
  const pendingRuns = new Set();
515
+ // Ask the browser to confirm leaving the page while there are unsaved changes.
516
+ let removeLeaveGuard;
517
+ if (features.confirmUnsavedLeave &&
518
+ mode !== 'readonly' &&
519
+ mode !== 'locked' &&
520
+ typeof window !== 'undefined') {
521
+ const onBeforeUnload = (event) => {
522
+ if (!fd.workflow.isDirty)
523
+ return;
524
+ event.preventDefault();
525
+ event.returnValue = '';
526
+ };
527
+ window.addEventListener('beforeunload', onBeforeUnload);
528
+ removeLeaveGuard = () => window.removeEventListener('beforeunload', onBeforeUnload);
529
+ }
424
530
  // Create the mounted app interface
425
531
  const mountedApp = {
426
532
  instance: fd,
@@ -428,6 +534,7 @@ export async function mountFlowDropApp(container, options = {}) {
428
534
  return webmcpHandle;
429
535
  },
430
536
  destroy: () => {
537
+ removeLeaveGuard?.();
431
538
  // Remove the agent-facing tools before anything else goes away.
432
539
  destroyed = true;
433
540
  webmcpHandle?.detach();
@@ -448,6 +555,8 @@ export async function mountFlowDropApp(container, options = {}) {
448
555
  }
449
556
  state.draftManager.stop();
450
557
  }
558
+ // A draft offer still waiting for the workflow is no longer wanted
559
+ cancelDraftOffer?.();
451
560
  // Stop listening for the draft opt-out setting
452
561
  if (state.unsubscribeDraftSettings) {
453
562
  state.unsubscribeDraftSettings();
@@ -502,6 +611,8 @@ export async function mountFlowDropApp(container, options = {}) {
502
611
  if (state.draftManager && !customDraftKey && saved.id) {
503
612
  state.draftManager.updateStorageKey(getDraftStorageKey(saved.id, undefined, fd.storagePrefix));
504
613
  }
614
+ // A saved workflow has no draft
615
+ state.draftManager?.markAsSaved();
505
616
  }
506
617
  });
507
618
  },
@@ -45,3 +45,25 @@ export declare function scopeSelector(scopeId: string): string;
45
45
  * Returns '' when the skin and display set nothing.
46
46
  */
47
47
  export declare function buildScopedSkinCss(scopeId: string, skin: Pick<FlowDropSkin, 'tokens' | 'darkTokens' | 'font'> | undefined, display?: FlowDropDisplayConfig): string;
48
+ /**
49
+ * CSS for a skin on any element a host chooses, e.g. a whole app on `:root`:
50
+ *
51
+ * tokens → {selector}{selector} (light / base)
52
+ * darkTokens → {selector}[data-theme='dark'] (dark)
53
+ *
54
+ * The doubled selector outranks tokens.css's own `:root` block, as the scoped
55
+ * rule does. Dark mode follows `data-theme="dark"` on that element, the same
56
+ * attribute tokens.css keys its dark palette on, so a host sets it there; for
57
+ * `:root` that is `<html data-theme>`, set by the host and still supported.
58
+ * (Only the editor *writing* its theme to `<html>`, the mirror, is deprecated
59
+ * and goes in 3.0.) For the
60
+ * components' base styles use an element that is also `.flowdrop-scope`, e.g.
61
+ * `skinCss(graphiteSkin, '.flowdrop-scope')`.
62
+ * Load tokens.css first; this only overrides it.
63
+ *
64
+ * @param skin - The skin, e.g. `graphiteSkin`
65
+ * @param selector - Where the tokens apply (default `:root`): one trusted, static
66
+ * compound selector such as `:root` or `.app`. It is doubled for specificity, so a
67
+ * selector list (`a, b`) or a descendant selector (`.a .b`) does not work.
68
+ */
69
+ export declare function skinCss(skin: Pick<FlowDropSkin, 'tokens' | 'darkTokens' | 'font'>, selector?: string): string;
@@ -187,13 +187,39 @@ export function scopeSelector(scopeId) {
187
187
  * Returns '' when the skin and display set nothing.
188
188
  */
189
189
  export function buildScopedSkinCss(scopeId, skin, display) {
190
+ return buildSkinCss(scopeSelector(scopeId), skin, display);
191
+ }
192
+ /**
193
+ * CSS for a skin on any element a host chooses, e.g. a whole app on `:root`:
194
+ *
195
+ * tokens → {selector}{selector} (light / base)
196
+ * darkTokens → {selector}[data-theme='dark'] (dark)
197
+ *
198
+ * The doubled selector outranks tokens.css's own `:root` block, as the scoped
199
+ * rule does. Dark mode follows `data-theme="dark"` on that element, the same
200
+ * attribute tokens.css keys its dark palette on, so a host sets it there; for
201
+ * `:root` that is `<html data-theme>`, set by the host and still supported.
202
+ * (Only the editor *writing* its theme to `<html>`, the mirror, is deprecated
203
+ * and goes in 3.0.) For the
204
+ * components' base styles use an element that is also `.flowdrop-scope`, e.g.
205
+ * `skinCss(graphiteSkin, '.flowdrop-scope')`.
206
+ * Load tokens.css first; this only overrides it.
207
+ *
208
+ * @param skin - The skin, e.g. `graphiteSkin`
209
+ * @param selector - Where the tokens apply (default `:root`): one trusted, static
210
+ * compound selector such as `:root` or `.app`. It is doubled for specificity, so a
211
+ * selector list (`a, b`) or a descendant selector (`.a .b`) does not work.
212
+ */
213
+ export function skinCss(skin, selector = ':root') {
214
+ return buildSkinCss(selector, skin);
215
+ }
216
+ function buildSkinCss(scope, skin, display) {
190
217
  const tokens = effectiveSkinTokens(skin, display);
191
218
  const darkTokens = skin?.darkTokens ?? {};
192
219
  const lightKeys = Object.keys(tokens);
193
220
  const darkKeys = Object.keys(darkTokens);
194
221
  if (lightKeys.length === 0 && darkKeys.length === 0)
195
222
  return '';
196
- const scope = scopeSelector(scopeId);
197
223
  // A skin's light tokens also apply in dark mode (as with the old :root rule),
198
224
  // so an alias a skin sets in either palette is never overridden here.
199
225
  const skinSet = new Set([...lightKeys, ...darkKeys]);
@@ -20,10 +20,12 @@ export interface DoctorRemedy {
20
20
  /**
21
21
  * What the remedy needs from the person. Today `choices` (value => label)
22
22
  * for a remedy that must be told which one (`replace_node_type`); the chosen
23
- * value goes back as `params[<name>]`.
23
+ * value goes back as `params[<name>]`. `automatic: true` says the editor
24
+ * may apply this remedy by itself.
24
25
  */
25
26
  params?: {
26
27
  choices?: Record<string, string>;
28
+ automatic?: boolean;
27
29
  } & Record<string, unknown>;
28
30
  }
29
31
  /** One finding on the draft. */
@@ -211,6 +211,17 @@ export interface FlowDropFeatures {
211
211
  * @default true
212
212
  */
213
213
  showToasts?: boolean;
214
+ /**
215
+ * Ask the browser to confirm before leaving the page while the workflow has
216
+ * unsaved changes.
217
+ *
218
+ * Applies to `mountFlowDropApp` only (not `mountWorkflowEditor`, whose host
219
+ * owns the page) and not to `readonly` or `locked` mounts. The browser shows
220
+ * its own wording. The listener is removed again on `destroy()`.
221
+ *
222
+ * @default true
223
+ */
224
+ confirmUnsavedLeave?: boolean;
214
225
  /**
215
226
  * Enable node swap functionality
216
227
  *
@@ -275,6 +286,15 @@ export interface FlowDropFeatures {
275
286
  * @default true
276
287
  */
277
288
  testMode?: boolean;
289
+ /**
290
+ * Offer a Run button in the canvas toolbar in Edit mode. It saves unsaved
291
+ * changes, then starts the workflow through `host.onRun` or the
292
+ * `workflows.run` endpoint and shows the run on the canvas. Drawn only for a
293
+ * saved workflow on an editable canvas whose backend can start a run.
294
+ *
295
+ * @default true
296
+ */
297
+ runButton?: boolean;
278
298
  /**
279
299
  * Offer the Runs list in Test mode: a "Runs" control in the canvas toolbar
280
300
  * listing the workflow's past runs (from `endpoints.pipelines.list`), where
@@ -15,11 +15,13 @@ export const DEFAULT_FEATURES = {
15
15
  autoSaveDraft: true,
16
16
  autoSaveDraftInterval: 30000,
17
17
  showToasts: true,
18
+ confirmUnsavedLeave: true,
18
19
  enableNodeSwap: true,
19
20
  builtinEditors: true,
20
21
  console: true,
21
22
  assistant: true,
22
23
  testMode: true,
24
+ runButton: true,
23
25
  runsList: true,
24
26
  adminLinks: {}
25
27
  };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Impact types: what saving a draft would change for the things that use the
3
+ * workflow, as a backend reports it before the save.
4
+ *
5
+ * @module types/impact
6
+ */
7
+ export type ImpactSeverity = 'breaks' | 'changes' | 'info';
8
+ /** One thing the save touches. */
9
+ export interface ImpactItem {
10
+ kind: string;
11
+ severity: ImpactSeverity;
12
+ label: string;
13
+ message: string;
14
+ /** Where to look at the affected thing, when the backend knows. */
15
+ url: string | null;
16
+ }
17
+ /** The answer of the impact check. */
18
+ export interface ImpactReport {
19
+ /** The editor asks before saving when this is set. */
20
+ confirm: boolean;
21
+ /** The level of the interface change, as the backend names it. */
22
+ interfaceLevel: string;
23
+ interfaceBreaking: boolean;
24
+ items: ImpactItem[];
25
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Impact types: what saving a draft would change for the things that use the
3
+ * workflow, as a backend reports it before the save.
4
+ *
5
+ * @module types/impact
6
+ */
7
+ export {};
@@ -336,7 +336,17 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH';
336
336
  export interface AutocompleteConfig {
337
337
  /**
338
338
  * The callback URL to fetch autocomplete suggestions from.
339
- * Can be relative (resolved against API base URL) or absolute.
339
+ *
340
+ * - `https://host/…` or `//host/…`: used as given.
341
+ * - `/path`: relative to the site, used as given (SchemaForm puts its
342
+ * `baseUrl` prop in front of it).
343
+ * - `path` or `./path` without a leading slash: relative to the API base
344
+ * (`endpointConfig.baseUrl`), so `secrets/options` reaches
345
+ * `{baseUrl}/secrets/options` wherever the editor mounts the API. A
346
+ * SchemaForm given a `baseUrl` prop uses the prop instead; with neither,
347
+ * the URL is used as given.
348
+ * - Malformed URLs are refused and nothing is fetched; the full rule is in
349
+ * docs/config-schema-guide.md ("How `url` is resolved").
340
350
  */
341
351
  url: string;
342
352
  /**
@@ -321,6 +321,37 @@ export declare const DEFAULT_API_SETTINGS: ApiSettings;
321
321
  * Complete default settings object
322
322
  */
323
323
  export declare const DEFAULT_SETTINGS: FlowDropSettings;
324
+ /**
325
+ * Describes one editor setting: its value type, a short label, and the
326
+ * values it allows. Lets a host build a settings form or validate input
327
+ * without reading the TypeScript types.
328
+ */
329
+ export interface SettingsFieldSchema {
330
+ type: 'boolean' | 'number' | 'string' | 'object';
331
+ label: string;
332
+ description?: string;
333
+ /** Allowed values of a string setting */
334
+ enum?: readonly string[];
335
+ /** Lowest allowed value of a number setting */
336
+ minimum?: number;
337
+ /** Highest allowed value of a number setting */
338
+ maximum?: number;
339
+ }
340
+ /**
341
+ * One field schema per setting: the compiler flags a missing or an extra key.
342
+ * An optional setting (`theme.explicit`, an internal marker) has no schema.
343
+ */
344
+ export type SettingsFieldSchemaMap = {
345
+ [C in keyof FlowDropSettings]: {
346
+ [K in keyof FlowDropSettings[C] as undefined extends FlowDropSettings[C][K] ? never : K]: SettingsFieldSchema;
347
+ };
348
+ };
349
+ /**
350
+ * A field schema for every key of {@link DEFAULT_SETTINGS}, by category.
351
+ * The nested width and zoom-tier settings are replaced as a whole, so they are
352
+ * plain `object` fields.
353
+ */
354
+ export declare const SETTINGS_FIELD_SCHEMA: SettingsFieldSchemaMap;
324
355
  /**
325
356
  * Deep partial type for nested settings updates
326
357
  */
@@ -130,6 +130,138 @@ export const DEFAULT_SETTINGS = {
130
130
  behavior: DEFAULT_BEHAVIOR_SETTINGS,
131
131
  api: DEFAULT_API_SETTINGS
132
132
  };
133
+ const SURFACE_PLACEMENTS = [
134
+ 'sidebar',
135
+ 'modal',
136
+ 'below'
137
+ ];
138
+ /**
139
+ * A field schema for every key of {@link DEFAULT_SETTINGS}, by category.
140
+ * The nested width and zoom-tier settings are replaced as a whole, so they are
141
+ * plain `object` fields.
142
+ */
143
+ export const SETTINGS_FIELD_SCHEMA = {
144
+ theme: {
145
+ preference: {
146
+ type: 'string',
147
+ label: 'Colour scheme',
148
+ description: 'Light, dark, follow the system, or follow the embedding page',
149
+ enum: ['light', 'dark', 'auto', 'host']
150
+ }
151
+ },
152
+ editor: {
153
+ showGrid: { type: 'boolean', label: 'Show grid' },
154
+ snapToGrid: { type: 'boolean', label: 'Snap to grid' },
155
+ gridSize: {
156
+ type: 'number',
157
+ label: 'Grid size',
158
+ description: 'In pixels; 10 or 20',
159
+ minimum: 10,
160
+ maximum: 20
161
+ },
162
+ layoutGapX: {
163
+ type: 'number',
164
+ label: 'Layout gap across',
165
+ description: 'Pixels between cards side by side, a multiple of 20',
166
+ minimum: 0
167
+ },
168
+ layoutGapY: {
169
+ type: 'number',
170
+ label: 'Layout gap down',
171
+ description: 'Pixels between stacked cards, a multiple of 20',
172
+ minimum: 0
173
+ },
174
+ showMinimap: { type: 'boolean', label: 'Show minimap' },
175
+ defaultZoom: { type: 'number', label: 'Default zoom', description: '1 is 100%', minimum: 0 },
176
+ fitViewOnLoad: { type: 'boolean', label: 'Fit workflow to view on load' },
177
+ proximityConnect: { type: 'boolean', label: 'Connect nodes by proximity' },
178
+ proximityConnectDistance: {
179
+ type: 'number',
180
+ label: 'Proximity distance',
181
+ description: 'In pixels',
182
+ minimum: 0
183
+ },
184
+ showNodeDescriptions: { type: 'boolean', label: 'Show node descriptions' },
185
+ zoomTiers: {
186
+ type: 'object',
187
+ label: 'Zoom tiers',
188
+ description: 'The zoom at which each tier (full, outline, glyph, map) starts'
189
+ }
190
+ },
191
+ ui: {
192
+ sidebarWidth: {
193
+ type: 'number',
194
+ label: 'Sidebar width',
195
+ description: 'Deprecated; use sidebar widths',
196
+ minimum: 0
197
+ },
198
+ sidebarWidths: {
199
+ type: 'object',
200
+ label: 'Sidebar widths',
201
+ description: 'Width per tab, in pixels'
202
+ },
203
+ sheetWidths: {
204
+ type: 'object',
205
+ label: 'Sheet widths',
206
+ description: 'Width per sheet, in pixels'
207
+ },
208
+ sidebarCollapsed: { type: 'boolean', label: 'Collapse sidebar' },
209
+ compactMode: { type: 'boolean', label: 'Compact mode' },
210
+ theme: {
211
+ type: 'string',
212
+ label: 'Theme',
213
+ enum: ['classic', 'minimal', 'drafter', 'graphite']
214
+ },
215
+ consoleOpen: { type: 'boolean', label: 'Open the console' },
216
+ consoleHeight: {
217
+ type: 'number',
218
+ label: 'Console height',
219
+ description: 'In pixels',
220
+ minimum: 0
221
+ },
222
+ bottomPanelTab: {
223
+ type: 'string',
224
+ label: 'Bottom panel tab',
225
+ enum: ['console', 'chat']
226
+ },
227
+ configPlacement: {
228
+ type: 'string',
229
+ label: 'Configuration panel placement',
230
+ enum: SURFACE_PLACEMENTS
231
+ },
232
+ consolePlacement: { type: 'string', label: 'Console placement', enum: SURFACE_PLACEMENTS }
233
+ },
234
+ behavior: {
235
+ autoSave: { type: 'boolean', label: 'Auto-save' },
236
+ autoSaveInterval: {
237
+ type: 'number',
238
+ label: 'Auto-save interval',
239
+ description: 'In milliseconds',
240
+ minimum: 0
241
+ },
242
+ storeDraftsInBrowser: { type: 'boolean', label: 'Keep drafts in the browser' },
243
+ undoHistoryLimit: { type: 'number', label: 'Undo history limit', minimum: 0 },
244
+ confirmDelete: { type: 'boolean', label: 'Confirm before deleting' },
245
+ chatMode: {
246
+ type: 'string',
247
+ label: 'Assistant mode',
248
+ enum: ['tools', 'dsl']
249
+ },
250
+ chatAutoRetry: { type: 'boolean', label: 'Retry failed assistant changes' },
251
+ chatAllowLayoutChanges: { type: 'boolean', label: 'Let the assistant move nodes' }
252
+ },
253
+ api: {
254
+ timeout: {
255
+ type: 'number',
256
+ label: 'Request timeout',
257
+ description: 'In milliseconds',
258
+ minimum: 0
259
+ },
260
+ retryEnabled: { type: 'boolean', label: 'Retry failed requests' },
261
+ retryAttempts: { type: 'number', label: 'Retry attempts', minimum: 0 },
262
+ cacheEnabled: { type: 'boolean', label: 'Cache responses' }
263
+ }
264
+ };
133
265
  // =========================================================================
134
266
  // Settings Persistence Types
135
267
  // =========================================================================
@@ -0,0 +1,76 @@
1
+ /**
2
+ * FlowDrop UI Module
3
+ *
4
+ * The design-system components the editor is built from: the primitives, the
5
+ * surfaces, and the text controls. They use the `--fd-*` tokens only, so a host
6
+ * that loads the package's styles gets the editor's look in its own pages.
7
+ *
8
+ * @module ui
9
+ *
10
+ * Experimental in 2.x: names and props may still change in a minor release
11
+ * while the design system settles. It becomes semver-stable no later than 3.0;
12
+ * pin a minor version (`~2.16.0`) if you depend on it.
13
+ *
14
+ * @example
15
+ * ```svelte
16
+ * <script>
17
+ * import { Button, Card } from '@flowdrop/flowdrop/ui';
18
+ * import '@flowdrop/flowdrop/styles/base.css';
19
+ * </script>
20
+ *
21
+ * <div class="flowdrop-scope" data-theme="light">
22
+ * <Card><Button variant="primary">Save</Button></Card>
23
+ * </div>
24
+ * ```
25
+ *
26
+ * The base styles (box-sizing, type, `color-scheme`) apply only inside
27
+ * `.flowdrop-root`, `.flowdrop-scope` or `.flowdrop-portal`, so wrap the host
28
+ * content that uses these components in one of them. Set `data-theme`
29
+ * (`light` or `dark`) on that wrapper: an overlay such as `SurfaceOverlay` is
30
+ * moved to `<body>` and takes the scheme from it. Without one, the overlay
31
+ * follows the editor's stored theme setting, which may not match the page.
32
+ *
33
+ * To give that content the editor's Graphite look, load tokens.css and add
34
+ * `skinCss(graphiteSkin, '.flowdrop-scope')` as a stylesheet. Dark mode is
35
+ * `data-theme="dark"` on the element the selector matches (here the
36
+ * `.flowdrop-scope` div); for the default `:root` the host sets it on `<html>`
37
+ * itself, which stays supported. Only the editor writing its theme to `<html>`
38
+ * (the mirror) is deprecated, removed in 3.0. The selector is scoped so the skin
39
+ * stays inside the wrapper; the default `:root` restyles the whole page.
40
+ *
41
+ * Built-in strings (labels, placeholders) are English by default and follow
42
+ * `setMessages` from `@flowdrop/flowdrop/core` when the host calls it in an
43
+ * ancestor component.
44
+ */
45
+ export { default as Button } from '../components/primitives/Button.svelte';
46
+ export { default as Card } from '../components/primitives/Card.svelte';
47
+ export { default as Checkbox } from '../components/primitives/Checkbox.svelte';
48
+ export { default as Chip } from '../components/primitives/Chip.svelte';
49
+ export { default as Combobox } from '../components/primitives/Combobox.svelte';
50
+ export { default as Composer } from '../components/primitives/Composer.svelte';
51
+ export { default as EmptyState } from '../components/primitives/EmptyState.svelte';
52
+ export { default as Field } from '../components/primitives/Field.svelte';
53
+ export { default as IconButton } from '../components/primitives/IconButton.svelte';
54
+ export { default as Menu } from '../components/primitives/Menu.svelte';
55
+ export type { MenuItem, MenuEntry, MenuGroup, MenuSeparator } from '../components/primitives/Menu.svelte';
56
+ export { default as Notice } from '../components/primitives/Notice.svelte';
57
+ export { default as PanelHeader } from '../components/primitives/PanelHeader.svelte';
58
+ export { default as Segmented } from '../components/primitives/Segmented.svelte';
59
+ export type { SegmentedOption } from '../components/primitives/Segmented.svelte';
60
+ export { default as Select } from '../components/primitives/Select.svelte';
61
+ export type { SelectOption } from '../utils/selectOptions.js';
62
+ export { default as StatusPill } from '../components/primitives/StatusPill.svelte';
63
+ export type { StatusPillStatus } from '../components/primitives/StatusPill.svelte';
64
+ export { default as Switch } from '../components/primitives/Switch.svelte';
65
+ export { default as Tabs, tabId, tabPanelId } from '../components/primitives/Tabs.svelte';
66
+ export type { TabItem } from '../components/primitives/Tabs.svelte';
67
+ export { default as Toolbar } from '../components/primitives/Toolbar.svelte';
68
+ export { default as ToolbarSeparator } from '../components/primitives/ToolbarSeparator.svelte';
69
+ export { default as SurfaceOverlay } from '../components/surfaces/SurfaceOverlay.svelte';
70
+ export { default as TabbedSurface } from '../components/surfaces/TabbedSurface.svelte';
71
+ export type { SurfaceTab } from '../components/surfaces/TabbedSurface.svelte';
72
+ export { default as Input } from '../components/Input.svelte';
73
+ export { default as Textarea } from '../components/Textarea.svelte';
74
+ export { graphiteSkin } from '../skins/graphite.js';
75
+ export { skinCss } from '../themes/scopedSkinCss.js';
76
+ export type { FlowDropSkin } from '../types/skin.js';