/** * Svelte App Wrapper for Framework Integration * * Provides mount/unmount functions for integrating FlowDrop into any web application. * Particularly useful for integration with vanilla JS, Drupal, WordPress, or other frameworks. * * @module svelte-app */ import type { Workflow, NodeMetadata, PortConfig, CategoryDefinition } from './types/index.js'; import type { EndpointConfig } from './config/endpoints.js'; import type { AuthProvider } from './types/auth.js'; import type { FlowDropEventHandlers, FlowDropFeatures } from './types/events.js'; import type { FlowDropTheme, FlowDropThemeName } from './types/theme.js'; import type { WorkflowFormatAdapter } from './registry/workflowFormatRegistry.js'; import './registry/builtinFormats.js'; import type { PartialSettings, SettingsCategory } from './types/settings.js'; import type { NavbarAction } from './types/navbar.js'; export type { NavbarAction }; /** * Mount options for FlowDrop App */ export interface FlowDropMountOptions { /** Initial workflow to load */ workflow?: Workflow; /** Available node types */ nodes?: NodeMetadata[]; /** API endpoint configuration */ endpointConfig?: EndpointConfig; /** Port configuration for connections */ portConfig?: PortConfig; /** Category definitions for node categories */ categories?: CategoryDefinition[]; /** Editor height */ height?: string | number; /** Editor width */ width?: string | number; /** Show the navbar */ showNavbar?: boolean; /** Disable the node sidebar */ disableSidebar?: boolean; /** Lock the workflow (prevent changes) */ lockWorkflow?: boolean; /** Read-only mode */ readOnly?: boolean; /** Pipeline ID for status display */ pipelineId?: string; /** Node execution statuses */ nodeStatuses?: Record; /** Custom navbar title */ navbarTitle?: string; /** Custom navbar actions */ navbarActions?: NavbarAction[]; /** Show settings gear icon in navbar */ showSettings?: boolean; /** Authentication provider for API requests */ authProvider?: AuthProvider; /** Event handlers for workflow lifecycle */ eventHandlers?: FlowDropEventHandlers; /** Feature configuration */ features?: FlowDropFeatures; /** Initial settings overrides (theme, behavior, editor, ui, api) */ settings?: PartialSettings; /** Custom storage key for localStorage drafts */ draftStorageKey?: string; /** Custom workflow format adapters to register */ formatAdapters?: WorkflowFormatAdapter[]; /** Visual theme — named built-in ('default' | 'minimal') or custom theme object */ theme?: FlowDropTheme | FlowDropThemeName; /** Which settings tabs to show in the modal (defaults to all) */ settingsCategories?: SettingsCategory[]; /** Show the "Sync to Cloud" button in the settings modal */ showSettingsSyncButton?: boolean; /** Show the reset buttons in the settings modal */ showSettingsResetButton?: boolean; } /** * Return type for mounted FlowDrop app */ export interface MountedFlowDropApp { /** * Destroy the app and clean up resources */ destroy: () => void; /** * Check if there are unsaved changes */ isDirty: () => boolean; /** * Mark the workflow as saved (clears dirty state) */ markAsSaved: () => void; /** * Get the current workflow data */ getWorkflow: () => Workflow | null; /** * Trigger save operation */ save: () => Promise; /** * Trigger export operation (downloads JSON) */ export: () => void; /** * Clear all FlowDrop workflow drafts from `localStorage`. * * Removes every key beginning with `flowdrop:draft:` plus the custom * `draftStorageKey` configured at mount time (if any). Call this from * the host application's logout handler so drafts do not persist across * user sessions on shared devices. * * @returns The number of entries removed. */ clearAllDrafts: () => number; } /** * Mount the full FlowDrop App with navbar, sidebars, and workflow editor * * Use this for a complete workflow editing experience with all UI components. * * @param container - DOM element to mount the app into * @param options - Configuration options for the app * @returns Promise resolving to a MountedFlowDropApp instance * * @example * ```typescript * const app = await mountFlowDropApp(document.getElementById("editor"), { * workflow: myWorkflow, * endpointConfig: createEndpointConfig("/api/flowdrop"), * authProvider: new CallbackAuthProvider({ * getToken: () => authService.getAccessToken() * }), * eventHandlers: { * onDirtyStateChange: (isDirty) => updateSaveButton(isDirty), * onAfterSave: () => showSuccess("Saved!") * } * }); * ``` */ export declare function mountFlowDropApp(container: HTMLElement, options?: FlowDropMountOptions): Promise; /** * Mount the WorkflowEditor component in a container * * Simpler alternative to mountFlowDropApp - only mounts the editor without navbar. * * @param container - DOM element to mount the editor into * @param options - Configuration options * @returns Promise resolving to a MountedFlowDropApp instance */ export declare function mountWorkflowEditor(container: HTMLElement, options?: { workflow?: Workflow; nodes?: NodeMetadata[]; endpointConfig?: EndpointConfig; portConfig?: PortConfig; categories?: CategoryDefinition[]; authProvider?: AuthProvider; }): Promise; /** * Unmount a FlowDrop app * * @param app - The mounted app to unmount */ export declare function unmountFlowDropApp(app: MountedFlowDropApp): void;