@flowdrop/flowdrop 1.15.0 → 2.0.0-beta.10
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 +648 -0
- package/MIGRATION-2.0.md +642 -0
- package/README.md +28 -28
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +18 -13
- package/dist/adapters/agentspec/AgentSpecAdapter.js +10 -10
- package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.d.ts +39 -0
- package/dist/chat/batchFeedback.js +51 -0
- package/dist/commands/executor.js +66 -27
- package/dist/commands/storeIntegration.svelte.d.ts +4 -1
- package/dist/commands/storeIntegration.svelte.js +36 -21
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/types.js +5 -5
- package/dist/components/App.svelte +696 -565
- package/dist/components/App.svelte.d.ts +63 -16
- package/dist/components/Button.stories.svelte +65 -0
- package/dist/components/Button.stories.svelte.d.ts +19 -0
- package/dist/components/Button.svelte +62 -0
- package/dist/components/Button.svelte.d.ts +24 -0
- package/dist/components/CanvasIconButton.svelte +76 -0
- package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
- package/dist/components/ConfigForm.svelte +181 -552
- package/dist/components/ConfigForm.svelte.d.ts +24 -7
- package/dist/components/ConfigModal.svelte +16 -3
- package/dist/components/ConfigPanel.svelte +234 -15
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/ConnectionLine.svelte +4 -2
- package/dist/components/EditorStatusBar.stories.svelte +44 -0
- package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
- package/dist/components/EditorStatusBar.svelte +99 -0
- package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
- package/dist/components/IconButton.svelte +80 -0
- package/dist/components/IconButton.svelte.d.ts +30 -0
- package/dist/components/Input.svelte +74 -0
- package/dist/components/Input.svelte.d.ts +17 -0
- package/dist/components/LogoWordmark.svelte +113 -0
- package/dist/components/LogoWordmark.svelte.d.ts +26 -0
- package/dist/components/Navbar.svelte +78 -64
- package/dist/components/Navbar.svelte.d.ts +3 -0
- package/dist/components/NodeSidebar.svelte +48 -171
- package/dist/components/NodeStatusOverlay.svelte +94 -6
- package/dist/components/NodeSwapPicker.svelte +22 -38
- package/dist/components/PipelineStatus.svelte +22 -68
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortCoordinateTracker.svelte +5 -6
- package/dist/components/PortMappingRow.svelte +0 -2
- package/dist/components/SchemaForm.stories.svelte +1 -3
- package/dist/components/SchemaForm.svelte +22 -39
- package/dist/components/SchemaForm.svelte.d.ts +0 -8
- package/dist/components/Select.svelte +53 -0
- package/dist/components/Select.svelte.d.ts +15 -0
- package/dist/components/SettingsModal.svelte +8 -8
- package/dist/components/SettingsPanel.svelte +44 -10
- package/dist/components/SwapMappingEditor.svelte +67 -49
- package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
- package/dist/components/Textarea.svelte +39 -0
- package/dist/components/Textarea.svelte.d.ts +12 -0
- package/dist/components/ThemeToggle.svelte +15 -94
- package/dist/components/UniversalNode.svelte +45 -11
- package/dist/components/UniversalNode.svelte.d.ts +1 -1
- package/dist/components/WorkflowEditor.svelte +183 -162
- package/dist/components/WorkflowEditor.svelte.d.ts +39 -10
- package/dist/components/chat/AIChatPanel.svelte +99 -90
- package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
- package/dist/components/chat/CommandPreview.svelte +2 -1
- package/dist/components/console/CommandConsole.svelte +7 -5
- package/dist/components/console/ConsoleAutocomplete.svelte +11 -12
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleInput.svelte +18 -9
- package/dist/components/console/ConsoleOutput.svelte +4 -3
- package/dist/components/form/FormArray.svelte +42 -182
- package/dist/components/form/FormArray.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +26 -21
- package/dist/components/form/FormCheckboxGroup.svelte +1 -5
- package/dist/components/form/FormCodeEditor.svelte +9 -7
- package/dist/components/form/FormField.svelte +22 -44
- package/dist/components/form/FormFieldLight.svelte +56 -50
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormFieldset.svelte +45 -11
- package/dist/components/form/FormMarkdownEditor.svelte +17 -9
- package/dist/components/form/FormNumberField.svelte +4 -36
- package/dist/components/form/FormPorts.svelte +262 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +62 -30
- package/dist/components/form/FormSelect.svelte +13 -75
- package/dist/components/form/FormTemplateEditor.svelte +17 -7
- package/dist/components/form/FormTextField.svelte +3 -35
- package/dist/components/form/FormTextarea.svelte +4 -39
- package/dist/components/form/FormToggle.svelte +5 -16
- package/dist/components/form/FormToggle.svelte.d.ts +4 -2
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/form/resolveFieldType.d.ts +24 -0
- package/dist/components/form/resolveFieldType.js +55 -0
- package/dist/components/form/templateAutocomplete.js +1 -5
- package/dist/components/form/types.d.ts +1 -14
- package/dist/components/icons/CloseIcon.svelte +6 -0
- package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CommandLineIcon.svelte +15 -0
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuIcon.svelte +4 -0
- package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuOpenIcon.svelte +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
- package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
- package/dist/components/interrupt/FormPrompt.svelte +3 -2
- package/dist/components/interrupt/InterruptBubble.svelte +25 -27
- package/dist/components/interrupt/ReviewPrompt.svelte +10 -23
- package/dist/components/interrupt/TextInputPrompt.svelte +2 -7
- package/dist/components/layouts/MainLayout.svelte +24 -18
- package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
- package/dist/components/nodes/AtomNode.svelte +70 -72
- package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
- package/dist/components/nodes/GatewayNode.svelte +134 -172
- package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
- package/dist/components/nodes/IdeaNode.svelte +79 -98
- package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
- package/dist/components/nodes/NodeConfigButton.svelte +86 -0
- package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +76 -85
- package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
- package/dist/components/nodes/SimpleNode.svelte +68 -137
- package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
- package/dist/components/nodes/SquareNode.svelte +122 -169
- package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
- package/dist/components/nodes/TerminalNode.svelte +70 -127
- package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
- package/dist/components/nodes/ToolNode.svelte +99 -104
- package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
- package/dist/components/nodes/WorkflowNode.svelte +145 -195
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
- package/dist/components/playground/ChatInput.svelte +11 -15
- package/dist/components/playground/ChatPanel.svelte +6 -49
- package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
- package/dist/components/playground/ControlPanel.svelte +134 -123
- package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -9
- package/dist/components/playground/InputCollector.svelte +22 -57
- package/dist/components/playground/MessageStream.svelte +17 -23
- package/dist/components/playground/PipelineKanbanView.svelte +69 -8
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +31 -8
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +188 -44
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +154 -105
- package/dist/components/playground/Playground.svelte.d.ts +5 -0
- package/dist/components/playground/PlaygroundApp.svelte +12 -2
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundModal.svelte +18 -3
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +40 -37
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
- package/dist/components/playground/SessionManager.svelte +9 -12
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
- package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
- package/dist/components/surfaces/TabbedSurface.svelte +133 -0
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
- package/dist/config/endpoints.d.ts +23 -7
- package/dist/config/endpoints.js +30 -10
- package/dist/core/index.d.ts +6 -7
- package/dist/core/index.js +8 -12
- package/dist/display/index.d.ts +6 -3
- package/dist/display/index.js +7 -5
- package/dist/editor/index.d.ts +20 -21
- package/dist/editor/index.js +26 -36
- package/dist/form/code.d.ts +25 -15
- package/dist/form/code.js +44 -41
- package/dist/form/fieldRegistry.d.ts +17 -13
- package/dist/form/fieldRegistry.js +32 -12
- package/dist/form/full.d.ts +19 -14
- package/dist/form/full.js +26 -28
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +6 -5
- package/dist/form/markdown.d.ts +13 -8
- package/dist/form/markdown.js +22 -23
- package/dist/helpers/proximityConnect.d.ts +3 -2
- package/dist/helpers/proximityConnect.js +2 -5
- package/dist/helpers/workflowEditorHelper.d.ts +14 -5
- package/dist/helpers/workflowEditorHelper.js +32 -30
- package/dist/index.d.ts +28 -24
- package/dist/index.js +27 -50
- package/dist/messages/defaults.d.ts +2 -5
- package/dist/messages/defaults.js +3 -6
- package/dist/messages/index.d.ts +1 -2
- package/dist/messages/index.js +1 -2
- package/dist/mocks/app-forms.d.ts +6 -2
- package/dist/mocks/app-forms.js +11 -4
- package/dist/openapi/v1/openapi.yaml +38 -26
- package/dist/playground/index.d.ts +4 -5
- package/dist/playground/index.js +4 -32
- package/dist/playground/mount.d.ts +34 -5
- package/dist/playground/mount.js +58 -24
- package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
- package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
- package/dist/registry/builtinFormats.d.ts +9 -18
- package/dist/registry/builtinFormats.js +9 -39
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -64
- package/dist/registry/builtinNodes.js +7 -103
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.js +4 -6
- package/dist/registry/nodeComponentRegistry.d.ts +184 -16
- package/dist/registry/nodeComponentRegistry.js +235 -17
- package/dist/registry/workflowFormatRegistry.d.ts +14 -9
- package/dist/registry/workflowFormatRegistry.js +24 -8
- package/dist/{schema → schemas}/index.d.ts +2 -2
- package/dist/{schema → schemas}/index.js +2 -2
- package/dist/schemas/v1/workflow.schema.json +19 -17
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -3
- package/dist/services/apiVariableService.d.ts +2 -1
- package/dist/services/apiVariableService.js +16 -47
- package/dist/services/autoSaveService.d.ts +7 -0
- package/dist/services/autoSaveService.js +6 -4
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +9 -4
- package/dist/services/chatService.js +23 -28
- package/dist/services/draftStorage.d.ts +129 -13
- package/dist/services/draftStorage.js +185 -37
- package/dist/services/dynamicSchemaService.d.ts +33 -5
- package/dist/services/dynamicSchemaService.js +67 -55
- package/dist/services/globalSave.d.ts +13 -12
- package/dist/services/globalSave.js +29 -51
- package/dist/services/historyService.d.ts +39 -11
- package/dist/services/historyService.js +60 -18
- package/dist/services/interruptService.d.ts +15 -9
- package/dist/services/interruptService.js +35 -37
- package/dist/services/nodeExecutionService.d.ts +18 -3
- package/dist/services/nodeExecutionService.js +71 -45
- package/dist/services/playgroundService.d.ts +16 -10
- package/dist/services/playgroundService.js +42 -43
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/services/variableService.d.ts +2 -1
- package/dist/services/variableService.js +2 -2
- package/dist/services/workflowStorage.js +6 -6
- package/dist/skins/drafter.d.ts +30 -0
- package/dist/skins/drafter.js +198 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/stores/apiContext.d.ts +56 -0
- package/dist/stores/apiContext.js +80 -0
- package/dist/stores/categoriesStore.svelte.d.ts +28 -23
- package/dist/stores/categoriesStore.svelte.js +69 -64
- package/dist/stores/getInstance.svelte.d.ts +39 -0
- package/dist/stores/getInstance.svelte.js +65 -0
- package/dist/stores/historyStore.svelte.d.ts +89 -91
- package/dist/stores/historyStore.svelte.js +159 -158
- package/dist/stores/instanceContainer.svelte.d.ts +111 -0
- package/dist/stores/instanceContainer.svelte.js +119 -0
- package/dist/stores/interruptStore.svelte.d.ts +112 -82
- package/dist/stores/interruptStore.svelte.js +253 -226
- package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
- package/dist/stores/pipelinePanelStore.svelte.js +61 -14
- package/dist/stores/playgroundStore.svelte.d.ts +169 -222
- package/dist/stores/playgroundStore.svelte.js +513 -580
- package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
- package/dist/stores/portCoordinateStore.svelte.js +109 -98
- package/dist/stores/settingsStore.svelte.d.ts +17 -1
- package/dist/stores/settingsStore.svelte.js +79 -12
- package/dist/stores/workflowStore.svelte.d.ts +212 -210
- package/dist/stores/workflowStore.svelte.js +527 -502
- package/dist/stories/EdgeDecorator.svelte +5 -2
- package/dist/stories/NodeDecorator.svelte +5 -3
- package/dist/styles/base.css +285 -14
- package/dist/styles/tokens.css +60 -2
- package/dist/svelte-app.d.ts +78 -11
- package/dist/svelte-app.js +210 -141
- package/dist/themes/drafter.d.ts +2 -0
- package/dist/themes/drafter.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +8 -2
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/events.d.ts +24 -3
- package/dist/types/events.js +2 -1
- package/dist/types/index.d.ts +117 -32
- package/dist/types/index.js +0 -1
- package/dist/types/navbar.d.ts +7 -0
- package/dist/types/playground.d.ts +18 -3
- package/dist/types/settings.d.ts +30 -1
- package/dist/types/settings.js +5 -2
- package/dist/types/skin.d.ts +1 -1
- package/dist/types/theme.d.ts +16 -2
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/colors.d.ts +74 -21
- package/dist/utils/colors.js +92 -68
- package/dist/utils/connections.d.ts +9 -15
- package/dist/utils/connections.js +33 -88
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +45 -0
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/icons.d.ts +5 -2
- package/dist/utils/icons.js +6 -5
- package/dist/utils/nodeIds.d.ts +1 -1
- package/dist/utils/nodeIds.js +1 -1
- package/dist/utils/nodeSwap.d.ts +6 -2
- package/dist/utils/nodeSwap.js +62 -129
- package/dist/utils/nodeTypes.d.ts +17 -8
- package/dist/utils/nodeTypes.js +27 -20
- package/dist/utils/performanceUtils.js +7 -0
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/dist/utils/portal.d.ts +18 -0
- package/dist/utils/portal.js +34 -0
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +7 -5
- package/dist/messages/deprecation.d.ts +0 -20
- package/dist/messages/deprecation.js +0 -33
- package/dist/registry/plugin.d.ts +0 -215
- package/dist/registry/plugin.js +0 -249
- package/dist/services/api.d.ts +0 -129
- package/dist/services/api.js +0 -217
package/dist/svelte-app.js
CHANGED
|
@@ -9,19 +9,104 @@
|
|
|
9
9
|
import { mount, unmount } from 'svelte';
|
|
10
10
|
import WorkflowEditor from './components/WorkflowEditor.svelte';
|
|
11
11
|
import App from './components/App.svelte';
|
|
12
|
-
import { workflowFormatRegistry } from './registry/workflowFormatRegistry.js';
|
|
13
|
-
import './registry/builtinFormats.js';
|
|
14
|
-
import { initializePortCompatibility } from './utils/connections.js';
|
|
15
12
|
import { DEFAULT_PORT_CONFIG } from './config/defaultPortConfig.js';
|
|
16
13
|
import { fetchPortConfig } from './services/portConfigApi.js';
|
|
17
14
|
import { fetchCategories } from './services/categoriesApi.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { DraftAutoSaveManager, getDraftStorageKey, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
|
|
15
|
+
import { createFlowDropInstance, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
|
|
16
|
+
import { DraftAutoSaveManager, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
|
|
21
17
|
import { mergeFeatures } from './types/events.js';
|
|
22
|
-
import { initializeSettings } from './stores/settingsStore.svelte.js';
|
|
18
|
+
import { initializeSettings, getBehaviorSettings, onSettingsChange } from './stores/settingsStore.svelte.js';
|
|
23
19
|
import { logger } from './utils/logger.js';
|
|
24
20
|
import { globalSaveWorkflow, globalExportWorkflow } from './services/globalSave.js';
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Instance acquisition
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/** Whether a mount currently owns the page-default instance. */
|
|
25
|
+
let defaultInstanceClaimed = false;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the FlowDrop instance for a new mount.
|
|
28
|
+
*
|
|
29
|
+
* No `instanceId` + default unclaimed → the page-default instance (legacy
|
|
30
|
+
* storage keys, reachable via the module-level store APIs). Everything else
|
|
31
|
+
* gets its own isolated instance.
|
|
32
|
+
*/
|
|
33
|
+
function acquireInstance(instanceId) {
|
|
34
|
+
if (!instanceId && !defaultInstanceClaimed) {
|
|
35
|
+
defaultInstanceClaimed = true;
|
|
36
|
+
return { fd: getDefaultInstance(), isDefault: true };
|
|
37
|
+
}
|
|
38
|
+
return { fd: createFlowDropInstance({ id: instanceId }), isDefault: false };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Release a mount's instance on destroy.
|
|
42
|
+
*
|
|
43
|
+
* Non-default instances are fully destroyed (subscriptions, effect roots,
|
|
44
|
+
* callbacks). The default instance is only *released* — its callbacks are
|
|
45
|
+
* cleared but its reactive wiring stays alive, matching the pre-multi-instance
|
|
46
|
+
* behavior where module stores survived unmount and a later mount reused them.
|
|
47
|
+
*/
|
|
48
|
+
function releaseInstance(fd, isDefault) {
|
|
49
|
+
if (isDefault) {
|
|
50
|
+
fd.workflow.setOnDirtyStateChange(null);
|
|
51
|
+
fd.workflow.setOnWorkflowChange(null);
|
|
52
|
+
defaultInstanceClaimed = false;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
fd.destroy();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve endpoint config, port config and categories from mount options and
|
|
60
|
+
* apply them to the given instance (API context, port-compatibility checker,
|
|
61
|
+
* categories). Shared by `mountFlowDropApp` and `mountWorkflowEditor`.
|
|
62
|
+
*
|
|
63
|
+
* @returns the resolved {@link EndpointConfig} (merged with defaults), which the
|
|
64
|
+
* callers forward to their mounted component.
|
|
65
|
+
*/
|
|
66
|
+
async function configureInstance(fd, options) {
|
|
67
|
+
const { endpointConfig, portConfig, categories, authProvider } = options;
|
|
68
|
+
// Create endpoint configuration, merging with defaults so all required
|
|
69
|
+
// endpoints are present.
|
|
70
|
+
const { defaultEndpointConfig } = await import('./config/endpoints.js');
|
|
71
|
+
const config = endpointConfig
|
|
72
|
+
? {
|
|
73
|
+
...defaultEndpointConfig,
|
|
74
|
+
...endpointConfig,
|
|
75
|
+
endpoints: {
|
|
76
|
+
...defaultEndpointConfig.endpoints,
|
|
77
|
+
...endpointConfig.endpoints
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
: defaultEndpointConfig;
|
|
81
|
+
// Initialize port configuration (fetch from API when not supplied).
|
|
82
|
+
let finalPortConfig = portConfig;
|
|
83
|
+
if (!finalPortConfig) {
|
|
84
|
+
try {
|
|
85
|
+
finalPortConfig = await fetchPortConfig(config, authProvider);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
logger.warn('Failed to fetch port config from API, using default:', error);
|
|
89
|
+
finalPortConfig = DEFAULT_PORT_CONFIG;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Configure this instance's API context and port compatibility checker.
|
|
93
|
+
fd.api.configure(config, authProvider);
|
|
94
|
+
fd.portCompatibility.reinitialize(finalPortConfig);
|
|
95
|
+
// Initialize this instance's categories (fetch from API when not supplied).
|
|
96
|
+
if (categories) {
|
|
97
|
+
fd.categories.initialize(categories);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
try {
|
|
101
|
+
const fetchedCategories = await fetchCategories(config, authProvider);
|
|
102
|
+
fd.categories.initialize(fetchedCategories);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
logger.warn('Failed to fetch categories from API, using defaults:', error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return config;
|
|
109
|
+
}
|
|
25
110
|
/**
|
|
26
111
|
* Mount the full FlowDrop App with navbar, sidebars, and workflow editor
|
|
27
112
|
*
|
|
@@ -47,94 +132,76 @@ import { globalSaveWorkflow, globalExportWorkflow } from './services/globalSave.
|
|
|
47
132
|
* ```
|
|
48
133
|
*/
|
|
49
134
|
export async function mountFlowDropApp(container, options = {}) {
|
|
50
|
-
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar,
|
|
135
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId } = options;
|
|
136
|
+
// Per-instance state container — this is what allows multiple FlowDrop
|
|
137
|
+
// editors to coexist on one page without sharing workflow/history state.
|
|
138
|
+
const { fd, isDefault } = acquireInstance(instanceId);
|
|
51
139
|
// Register custom format adapters before mounting
|
|
52
140
|
if (formatAdapters) {
|
|
53
141
|
for (const adapter of formatAdapters) {
|
|
54
|
-
|
|
142
|
+
fd.formats.register(adapter);
|
|
55
143
|
}
|
|
56
144
|
}
|
|
57
145
|
// Merge features with defaults
|
|
58
146
|
const features = mergeFeatures(userFeatures);
|
|
147
|
+
// Resolve this instance's draft storage backend. The adapter is captured
|
|
148
|
+
// here and threaded into the draft manager and clearAllDrafts, so a later
|
|
149
|
+
// mount with a different backend cannot retarget this instance. The
|
|
150
|
+
// module-level default is also updated for the standalone helpers
|
|
151
|
+
// (last mount wins there — instance paths do not depend on it).
|
|
152
|
+
const draftStorageAdapter = resolveDraftStorage(draftStorage ?? 'local');
|
|
153
|
+
setDraftStorage(draftStorageAdapter);
|
|
59
154
|
// Apply initial settings overrides and initialize theme
|
|
60
155
|
await initializeSettings({
|
|
61
156
|
defaults: initialSettings
|
|
62
157
|
});
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
...defaultEndpointConfig.endpoints,
|
|
73
|
-
...endpointConfig.endpoints
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// Use default configuration if none provided
|
|
79
|
-
const { defaultEndpointConfig } = await import('./config/endpoints.js');
|
|
80
|
-
config = defaultEndpointConfig;
|
|
81
|
-
}
|
|
82
|
-
// Initialize port configuration
|
|
83
|
-
let finalPortConfig = portConfig;
|
|
84
|
-
if (!finalPortConfig && config) {
|
|
85
|
-
// Try to fetch port configuration from API
|
|
86
|
-
try {
|
|
87
|
-
finalPortConfig = await fetchPortConfig(config, authProvider);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
logger.warn('Failed to fetch port config from API, using default:', error);
|
|
91
|
-
finalPortConfig = DEFAULT_PORT_CONFIG;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else if (!finalPortConfig) {
|
|
95
|
-
finalPortConfig = DEFAULT_PORT_CONFIG;
|
|
96
|
-
}
|
|
97
|
-
initializePortCompatibility(finalPortConfig);
|
|
98
|
-
// Initialize categories
|
|
99
|
-
if (categories) {
|
|
100
|
-
initializeCategories(categories);
|
|
101
|
-
}
|
|
102
|
-
else if (config) {
|
|
103
|
-
try {
|
|
104
|
-
const fetchedCategories = await fetchCategories(config, authProvider);
|
|
105
|
-
initializeCategories(fetchedCategories);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
logger.warn('Failed to fetch categories from API, using defaults:', error);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// Set up event handler callbacks in the store
|
|
158
|
+
// Resolve and apply endpoint config, port config and categories to this
|
|
159
|
+
// instance (see configureInstance).
|
|
160
|
+
const config = await configureInstance(fd, {
|
|
161
|
+
endpointConfig,
|
|
162
|
+
portConfig,
|
|
163
|
+
categories,
|
|
164
|
+
authProvider
|
|
165
|
+
});
|
|
166
|
+
// Set up event handler callbacks in this instance's store
|
|
112
167
|
if (eventHandlers?.onDirtyStateChange) {
|
|
113
|
-
setOnDirtyStateChange(eventHandlers.onDirtyStateChange);
|
|
168
|
+
fd.workflow.setOnDirtyStateChange(eventHandlers.onDirtyStateChange);
|
|
114
169
|
}
|
|
115
170
|
if (eventHandlers?.onWorkflowChange) {
|
|
116
|
-
setOnWorkflowChange(eventHandlers.onWorkflowChange);
|
|
171
|
+
fd.workflow.setOnWorkflowChange(eventHandlers.onWorkflowChange);
|
|
117
172
|
}
|
|
118
173
|
// Create the Svelte App component with configuration
|
|
119
174
|
const svelteApp = mount(App, {
|
|
120
175
|
target: container,
|
|
121
176
|
props: {
|
|
177
|
+
instance: fd,
|
|
122
178
|
workflow,
|
|
123
179
|
nodes,
|
|
124
180
|
height,
|
|
125
181
|
width,
|
|
126
182
|
showNavbar,
|
|
127
183
|
disableSidebar,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
184
|
+
configPlacement,
|
|
185
|
+
consolePlacement,
|
|
186
|
+
mode,
|
|
131
187
|
pipelineId,
|
|
132
188
|
navbarTitle,
|
|
133
189
|
navbarActions,
|
|
134
190
|
showSettings,
|
|
191
|
+
showStatus,
|
|
135
192
|
endpointConfig: config,
|
|
136
193
|
authProvider,
|
|
137
|
-
eventHandlers
|
|
194
|
+
// App's event-handler props are flat (the grouped `eventHandlers` option
|
|
195
|
+
// is a mount-API convenience). onDirtyStateChange / onWorkflowChange are
|
|
196
|
+
// wired into the instance store above; onBeforeUnmount is handled in
|
|
197
|
+
// unmount() below; the remaining handlers map 1:1 to App props.
|
|
198
|
+
onBeforeSave: eventHandlers?.onBeforeSave,
|
|
199
|
+
onAfterSave: eventHandlers?.onAfterSave,
|
|
200
|
+
onSaveError: eventHandlers?.onSaveError,
|
|
201
|
+
onApiError: eventHandlers?.onApiError,
|
|
202
|
+
onWorkflowLoad: eventHandlers?.onWorkflowLoad,
|
|
203
|
+
onBeforeSwap: eventHandlers?.onBeforeSwap,
|
|
204
|
+
onAfterSwap: eventHandlers?.onAfterSwap,
|
|
138
205
|
features,
|
|
139
206
|
theme,
|
|
140
207
|
settingsCategories,
|
|
@@ -144,88 +211,119 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
144
211
|
});
|
|
145
212
|
// Set up draft auto-save manager
|
|
146
213
|
let draftManager = null;
|
|
214
|
+
let unsubscribeDraftSettings = null;
|
|
147
215
|
if (features.autoSaveDraft) {
|
|
148
|
-
|
|
216
|
+
// Instance-scoped prefix: every instance (including the default) gets
|
|
217
|
+
// 'flowdrop:draft:<id>' sub-keys.
|
|
218
|
+
const storageKey = getDraftStorageKey(workflow?.id, customDraftKey, fd.storagePrefix);
|
|
219
|
+
// One-time migration: 1.x stored the page-default instance's drafts under
|
|
220
|
+
// the bare 'flowdrop:draft:<workflowId>' key. Move an existing draft to
|
|
221
|
+
// the scoped key so an upgrade mid-edit doesn't lose work.
|
|
222
|
+
if (fd.isDefault && !customDraftKey) {
|
|
223
|
+
migrateLegacyDraftKey(getDraftStorageKey(workflow?.id, undefined, DEFAULT_DRAFT_PREFIX), storageKey, draftStorageAdapter);
|
|
224
|
+
}
|
|
149
225
|
draftManager = new DraftAutoSaveManager({
|
|
150
226
|
storageKey,
|
|
151
227
|
interval: features.autoSaveDraftInterval,
|
|
152
228
|
enabled: features.autoSaveDraft,
|
|
153
|
-
getWorkflow:
|
|
154
|
-
isDirty
|
|
229
|
+
getWorkflow: () => fd.workflow.current,
|
|
230
|
+
isDirty: () => fd.workflow.isDirty,
|
|
231
|
+
// User-facing opt-out: the "Store Drafts in Browser" behavior setting.
|
|
232
|
+
// Checked on every save so toggling it takes effect immediately.
|
|
233
|
+
isPersistenceAllowed: () => getBehaviorSettings().storeDraftsInBrowser,
|
|
234
|
+
storage: draftStorageAdapter
|
|
155
235
|
});
|
|
156
236
|
draftManager.start();
|
|
237
|
+
// When the user opts out, also remove the draft already in storage.
|
|
238
|
+
unsubscribeDraftSettings = onSettingsChange((event) => {
|
|
239
|
+
if (event.category === 'behavior' &&
|
|
240
|
+
event.key === 'storeDraftsInBrowser' &&
|
|
241
|
+
event.newValue === false) {
|
|
242
|
+
draftManager?.clearDraft();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
157
245
|
}
|
|
158
246
|
// Store state for cleanup
|
|
159
247
|
const state = {
|
|
160
248
|
svelteApp,
|
|
161
249
|
draftManager,
|
|
162
|
-
eventHandlers: eventHandlers ?? null
|
|
250
|
+
eventHandlers: eventHandlers ?? null,
|
|
251
|
+
unsubscribeDraftSettings
|
|
163
252
|
};
|
|
164
253
|
// Create the mounted app interface
|
|
165
254
|
const mountedApp = {
|
|
255
|
+
instance: fd,
|
|
166
256
|
destroy: () => {
|
|
167
257
|
// Call onBeforeUnmount if provided
|
|
168
258
|
if (state.eventHandlers?.onBeforeUnmount) {
|
|
169
|
-
const currentWorkflow =
|
|
259
|
+
const currentWorkflow = fd.workflow.current;
|
|
170
260
|
if (currentWorkflow) {
|
|
171
|
-
state.eventHandlers.onBeforeUnmount(currentWorkflow, isDirty
|
|
261
|
+
state.eventHandlers.onBeforeUnmount(currentWorkflow, fd.workflow.isDirty);
|
|
172
262
|
}
|
|
173
263
|
}
|
|
174
264
|
// Stop draft manager
|
|
175
265
|
if (state.draftManager) {
|
|
176
|
-
// Save one final draft if dirty
|
|
177
|
-
if (isDirty
|
|
266
|
+
// Save one final draft if dirty (no-op when the user opted out)
|
|
267
|
+
if (fd.workflow.isDirty) {
|
|
178
268
|
state.draftManager.forceSave();
|
|
179
269
|
}
|
|
180
270
|
state.draftManager.stop();
|
|
181
271
|
}
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
272
|
+
// Stop listening for the draft opt-out setting
|
|
273
|
+
if (state.unsubscribeDraftSettings) {
|
|
274
|
+
state.unsubscribeDraftSettings();
|
|
275
|
+
state.unsubscribeDraftSettings = null;
|
|
276
|
+
}
|
|
277
|
+
// Release this mount's instance: clears its callbacks (and, for
|
|
278
|
+
// non-default instances, all subscriptions/effect roots) without
|
|
279
|
+
// touching sibling instances on the same page.
|
|
280
|
+
releaseInstance(fd, isDefault);
|
|
185
281
|
// Unmount Svelte app
|
|
186
282
|
unmount(state.svelteApp);
|
|
187
283
|
},
|
|
188
|
-
isDirty: () => isDirty
|
|
284
|
+
isDirty: () => fd.workflow.isDirty,
|
|
189
285
|
markAsSaved: () => {
|
|
190
|
-
markAsSaved();
|
|
286
|
+
fd.workflow.markAsSaved();
|
|
191
287
|
if (state.draftManager) {
|
|
192
288
|
// Migrate the draft key when the host confirms a save. New workflows start
|
|
193
|
-
// on '
|
|
289
|
+
// on '<prefix>:new', a key shared across all tabs. If the host has
|
|
194
290
|
// written the server-assigned ID back into the store before calling
|
|
195
291
|
// markAsSaved(), we can move to a unique per-workflow key and stop
|
|
196
292
|
// competing with other tabs that may also have unsaved new workflows.
|
|
197
293
|
// Skip when customDraftKey is set — the host manages that key explicitly.
|
|
198
294
|
if (!customDraftKey) {
|
|
199
|
-
const currentWorkflow =
|
|
295
|
+
const currentWorkflow = fd.workflow.current;
|
|
200
296
|
if (currentWorkflow?.id) {
|
|
201
|
-
state.draftManager.updateStorageKey(getDraftStorageKey(currentWorkflow.id));
|
|
297
|
+
state.draftManager.updateStorageKey(getDraftStorageKey(currentWorkflow.id, undefined, fd.storagePrefix));
|
|
202
298
|
}
|
|
203
299
|
}
|
|
204
300
|
state.draftManager.markAsSaved();
|
|
205
301
|
}
|
|
206
302
|
},
|
|
207
|
-
getWorkflow: () =>
|
|
303
|
+
getWorkflow: () => fd.workflow.current,
|
|
208
304
|
save: async () => {
|
|
209
305
|
await globalSaveWorkflow({
|
|
306
|
+
instance: fd,
|
|
210
307
|
onSaved: (saved) => {
|
|
211
308
|
// globalSaveWorkflow does not write the server-assigned ID back to the
|
|
212
|
-
// workflow store, so we cannot read it from
|
|
309
|
+
// workflow store, so we cannot read it from the store here.
|
|
213
310
|
// Instead we use the savedWorkflow returned by the API directly.
|
|
214
|
-
// This migrates '
|
|
311
|
+
// This migrates '<prefix>:new' to a unique per-workflow key
|
|
215
312
|
// immediately after the first save, preventing cross-tab collisions
|
|
216
313
|
// when multiple new workflows are open simultaneously.
|
|
217
314
|
if (state.draftManager && !customDraftKey && saved.id) {
|
|
218
|
-
state.draftManager.updateStorageKey(getDraftStorageKey(saved.id));
|
|
315
|
+
state.draftManager.updateStorageKey(getDraftStorageKey(saved.id, undefined, fd.storagePrefix));
|
|
219
316
|
}
|
|
220
317
|
}
|
|
221
318
|
});
|
|
222
319
|
},
|
|
223
320
|
export: () => {
|
|
224
|
-
globalExportWorkflow();
|
|
321
|
+
globalExportWorkflow({ instance: fd });
|
|
225
322
|
},
|
|
226
323
|
clearAllDrafts: () => {
|
|
227
324
|
const extras = customDraftKey ? [customDraftKey] : [];
|
|
228
|
-
|
|
325
|
+
// Clear this instance's backend, not whatever the module default is now
|
|
326
|
+
const removed = clearAllDraftsFromStorage(extras, draftStorageAdapter);
|
|
229
327
|
if (state.draftManager) {
|
|
230
328
|
state.draftManager.markAsSaved();
|
|
231
329
|
}
|
|
@@ -244,76 +342,47 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
244
342
|
* @returns Promise resolving to a MountedFlowDropApp instance
|
|
245
343
|
*/
|
|
246
344
|
export async function mountWorkflowEditor(container, options = {}) {
|
|
247
|
-
const {
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
else {
|
|
263
|
-
// Use default configuration if none provided
|
|
264
|
-
const { defaultEndpointConfig } = await import('./config/endpoints.js');
|
|
265
|
-
config = defaultEndpointConfig;
|
|
266
|
-
}
|
|
267
|
-
// Initialize port configuration
|
|
268
|
-
let finalPortConfig = portConfig;
|
|
269
|
-
if (!finalPortConfig && config) {
|
|
270
|
-
// Try to fetch port configuration from API
|
|
271
|
-
try {
|
|
272
|
-
finalPortConfig = await fetchPortConfig(config, authProvider);
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
logger.warn('Failed to fetch port config from API, using default:', error);
|
|
276
|
-
finalPortConfig = DEFAULT_PORT_CONFIG;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
else if (!finalPortConfig) {
|
|
280
|
-
finalPortConfig = DEFAULT_PORT_CONFIG;
|
|
281
|
-
}
|
|
282
|
-
initializePortCompatibility(finalPortConfig);
|
|
283
|
-
// Initialize categories
|
|
284
|
-
if (categories) {
|
|
285
|
-
initializeCategories(categories);
|
|
286
|
-
}
|
|
287
|
-
else if (config) {
|
|
288
|
-
try {
|
|
289
|
-
const fetchedCategories = await fetchCategories(config, authProvider);
|
|
290
|
-
initializeCategories(fetchedCategories);
|
|
291
|
-
}
|
|
292
|
-
catch (error) {
|
|
293
|
-
logger.warn('Failed to fetch categories from API, using defaults:', error);
|
|
294
|
-
}
|
|
345
|
+
const { workflow, endpointConfig, portConfig, categories, authProvider, instanceId, builtinEditors } = options;
|
|
346
|
+
// Per-instance state container (see mountFlowDropApp)
|
|
347
|
+
const { fd, isDefault } = acquireInstance(instanceId);
|
|
348
|
+
// Resolve and apply endpoint config, port config and categories to this
|
|
349
|
+
// instance (see configureInstance).
|
|
350
|
+
const config = await configureInstance(fd, {
|
|
351
|
+
endpointConfig,
|
|
352
|
+
portConfig,
|
|
353
|
+
categories,
|
|
354
|
+
authProvider
|
|
355
|
+
});
|
|
356
|
+
// Seed the instance's workflow before mounting so the editor renders it
|
|
357
|
+
// immediately. (1.x accepted this option but silently ignored it.)
|
|
358
|
+
if (workflow) {
|
|
359
|
+
fd.workflow.initialize(workflow);
|
|
295
360
|
}
|
|
296
361
|
// Create the Svelte component
|
|
297
362
|
const svelteApp = mount(WorkflowEditor, {
|
|
298
363
|
target: container,
|
|
299
364
|
props: {
|
|
300
|
-
|
|
301
|
-
endpointConfig: config
|
|
365
|
+
instance: fd,
|
|
366
|
+
endpointConfig: config,
|
|
367
|
+
authProvider,
|
|
368
|
+
builtinEditors
|
|
302
369
|
}
|
|
303
370
|
});
|
|
304
371
|
// Create the mounted app interface (simpler version)
|
|
305
372
|
const mountedApp = {
|
|
373
|
+
instance: fd,
|
|
306
374
|
destroy: () => {
|
|
375
|
+
releaseInstance(fd, isDefault);
|
|
307
376
|
unmount(svelteApp);
|
|
308
377
|
},
|
|
309
|
-
isDirty: () => isDirty
|
|
310
|
-
markAsSaved: () => markAsSaved(),
|
|
311
|
-
getWorkflow: () =>
|
|
378
|
+
isDirty: () => fd.workflow.isDirty,
|
|
379
|
+
markAsSaved: () => fd.workflow.markAsSaved(),
|
|
380
|
+
getWorkflow: () => fd.workflow.current,
|
|
312
381
|
save: async () => {
|
|
313
|
-
await globalSaveWorkflow();
|
|
382
|
+
await globalSaveWorkflow({ instance: fd });
|
|
314
383
|
},
|
|
315
384
|
export: () => {
|
|
316
|
-
globalExportWorkflow();
|
|
385
|
+
globalExportWorkflow({ instance: fd });
|
|
317
386
|
},
|
|
318
387
|
clearAllDrafts: () => clearAllDraftsFromStorage()
|
|
319
388
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { drafterSkin } from '../skins/drafter.js';
|
|
2
|
+
export const drafterTheme = {
|
|
3
|
+
name: 'drafter',
|
|
4
|
+
skin: drafterSkin,
|
|
5
|
+
config: {
|
|
6
|
+
sidebar: {
|
|
7
|
+
defaultOpen: true,
|
|
8
|
+
categoriesDefaultOpen: false
|
|
9
|
+
},
|
|
10
|
+
// Blueprint square line grid (any theme can opt into a grid variant here)
|
|
11
|
+
canvas: {
|
|
12
|
+
grid: 'lines'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
package/dist/themes/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FlowDropTheme, FlowDropThemeName } from '../types/theme.js';
|
|
2
2
|
import { defaultTheme } from './default.js';
|
|
3
3
|
import { minimalTheme } from './minimal.js';
|
|
4
|
+
import { drafterTheme } from './drafter.js';
|
|
4
5
|
/**
|
|
5
6
|
* Resolve a theme prop to a complete FlowDropTheme object.
|
|
6
7
|
*
|
|
@@ -10,4 +11,4 @@ import { minimalTheme } from './minimal.js';
|
|
|
10
11
|
* → minimal theme + { skin.tokens.primary: '#e11d48' }
|
|
11
12
|
*/
|
|
12
13
|
export declare function resolveTheme(theme: FlowDropTheme | FlowDropThemeName | undefined): FlowDropTheme;
|
|
13
|
-
export { defaultTheme, minimalTheme };
|
|
14
|
+
export { defaultTheme, minimalTheme, drafterTheme };
|
package/dist/themes/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { defaultTheme } from './default.js';
|
|
2
2
|
import { minimalTheme } from './minimal.js';
|
|
3
|
+
import { drafterTheme } from './drafter.js';
|
|
3
4
|
const builtinThemes = {
|
|
4
5
|
default: defaultTheme,
|
|
5
|
-
minimal: minimalTheme
|
|
6
|
+
minimal: minimalTheme,
|
|
7
|
+
drafter: drafterTheme
|
|
6
8
|
};
|
|
7
9
|
/**
|
|
8
10
|
* Resolve a theme prop to a complete FlowDropTheme object.
|
|
@@ -35,10 +37,14 @@ export function resolveTheme(theme) {
|
|
|
35
37
|
sidebar: {
|
|
36
38
|
...base.config?.sidebar,
|
|
37
39
|
...theme.config?.sidebar
|
|
40
|
+
},
|
|
41
|
+
canvas: {
|
|
42
|
+
...base.config?.canvas,
|
|
43
|
+
...theme.config?.canvas
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
};
|
|
41
47
|
}
|
|
42
48
|
return theme;
|
|
43
49
|
}
|
|
44
|
-
export { defaultTheme, minimalTheme };
|
|
50
|
+
export { defaultTheme, minimalTheme, drafterTheme };
|
package/dist/types/auth.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Authentication Provider Types for FlowDrop
|
|
3
3
|
*
|
|
4
4
|
* Provides interfaces and implementations for authentication in FlowDrop.
|
|
5
|
-
* AuthProvider is
|
|
5
|
+
* An AuthProvider is supplied at mount time (or via `fd.api.configure`) and can
|
|
6
|
+
* be swapped at runtime with `fd.api.setAuthProvider(...)` — e.g. on login or
|
|
7
|
+
* logout — without remounting.
|
|
6
8
|
*
|
|
7
9
|
* @module types/auth
|
|
8
10
|
*/
|
|
@@ -15,8 +17,7 @@
|
|
|
15
17
|
* @example
|
|
16
18
|
* ```typescript
|
|
17
19
|
* const authProvider: AuthProvider = {
|
|
18
|
-
* getAuthHeaders: async () => ({ Authorization: "Bearer token123" })
|
|
19
|
-
* isAuthenticated: () => true
|
|
20
|
+
* getAuthHeaders: async () => ({ Authorization: "Bearer token123" })
|
|
20
21
|
* };
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
@@ -30,15 +31,6 @@ export interface AuthProvider {
|
|
|
30
31
|
* @returns Promise resolving to a record of header name-value pairs
|
|
31
32
|
*/
|
|
32
33
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
33
|
-
/**
|
|
34
|
-
* Check if currently authenticated
|
|
35
|
-
*
|
|
36
|
-
* Used to determine if API requests should be attempted.
|
|
37
|
-
* Should return synchronously for performance.
|
|
38
|
-
*
|
|
39
|
-
* @returns true if authenticated, false otherwise
|
|
40
|
-
*/
|
|
41
|
-
isAuthenticated(): boolean;
|
|
42
34
|
/**
|
|
43
35
|
* Called when API returns 401 Unauthorized
|
|
44
36
|
*
|
|
@@ -68,6 +60,11 @@ export interface StaticAuthConfig {
|
|
|
68
60
|
token?: string;
|
|
69
61
|
/** API key (used when type is "api_key") */
|
|
70
62
|
apiKey?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Header name to carry the API key (used when type is "api_key").
|
|
65
|
+
* Defaults to `"X-API-Key"`.
|
|
66
|
+
*/
|
|
67
|
+
apiKeyHeader?: string;
|
|
71
68
|
/** Custom headers (used when type is "custom") */
|
|
72
69
|
headers?: Record<string, string>;
|
|
73
70
|
}
|
|
@@ -119,28 +116,6 @@ export declare class StaticAuthProvider implements AuthProvider {
|
|
|
119
116
|
* @returns Promise resolving to authentication headers
|
|
120
117
|
*/
|
|
121
118
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
122
|
-
/**
|
|
123
|
-
* Check if authenticated
|
|
124
|
-
*
|
|
125
|
-
* Returns true if any auth headers are configured.
|
|
126
|
-
*
|
|
127
|
-
* @returns true if headers are configured
|
|
128
|
-
*/
|
|
129
|
-
isAuthenticated(): boolean;
|
|
130
|
-
/**
|
|
131
|
-
* Handle unauthorized response
|
|
132
|
-
*
|
|
133
|
-
* Static provider cannot refresh tokens, so always returns false.
|
|
134
|
-
*
|
|
135
|
-
* @returns Promise resolving to false (cannot refresh)
|
|
136
|
-
*/
|
|
137
|
-
onUnauthorized(): Promise<boolean>;
|
|
138
|
-
/**
|
|
139
|
-
* Handle forbidden response
|
|
140
|
-
*
|
|
141
|
-
* Static provider has no special handling for 403.
|
|
142
|
-
*/
|
|
143
|
-
onForbidden(): Promise<void>;
|
|
144
119
|
}
|
|
145
120
|
/**
|
|
146
121
|
* Configuration for callback-based authentication
|
|
@@ -213,15 +188,6 @@ export declare class CallbackAuthProvider implements AuthProvider {
|
|
|
213
188
|
* @returns Promise resolving to authentication headers
|
|
214
189
|
*/
|
|
215
190
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
216
|
-
/**
|
|
217
|
-
* Check if authenticated
|
|
218
|
-
*
|
|
219
|
-
* For callback-based auth, we assume authenticated if getToken exists.
|
|
220
|
-
* The actual token validity is checked when making requests.
|
|
221
|
-
*
|
|
222
|
-
* @returns true (assumes authenticated, actual check happens on request)
|
|
223
|
-
*/
|
|
224
|
-
isAuthenticated(): boolean;
|
|
225
191
|
/**
|
|
226
192
|
* Handle unauthorized response
|
|
227
193
|
*
|
|
@@ -252,12 +218,4 @@ export declare class NoAuthProvider implements AuthProvider {
|
|
|
252
218
|
* @returns Promise resolving to empty object
|
|
253
219
|
*/
|
|
254
220
|
getAuthHeaders(): Promise<Record<string, string>>;
|
|
255
|
-
/**
|
|
256
|
-
* Check if authenticated
|
|
257
|
-
*
|
|
258
|
-
* Always returns false (no auth configured).
|
|
259
|
-
*
|
|
260
|
-
* @returns false
|
|
261
|
-
*/
|
|
262
|
-
isAuthenticated(): boolean;
|
|
263
221
|
}
|