@flowdrop/flowdrop 2.11.0 → 2.12.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.
- package/CHANGELOG.md +223 -0
- package/dist/adapters/agentspec/autoLayout.d.ts +18 -36
- package/dist/adapters/agentspec/autoLayout.js +75 -93
- package/dist/chat/activity.d.ts +49 -0
- package/dist/chat/activity.js +65 -0
- package/dist/chat/commandClassifier.js +2 -1
- package/dist/commands/executor.js +186 -27
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/parser.js +43 -3
- package/dist/commands/session.d.ts +60 -0
- package/dist/commands/session.js +332 -0
- package/dist/commands/storeIntegration.svelte.js +18 -1
- package/dist/commands/types.d.ts +77 -4
- package/dist/components/App.svelte +966 -226
- package/dist/components/App.svelte.d.ts +26 -2
- package/dist/components/BindablePortListbox.svelte +68 -369
- package/dist/components/Button.svelte +17 -14
- package/dist/components/Button.svelte.d.ts +2 -2
- package/dist/components/CanvasContextMenu.svelte +31 -10
- package/dist/components/CanvasController.svelte +146 -3
- package/dist/components/CanvasController.svelte.d.ts +25 -33
- package/dist/components/CanvasIconButton.svelte +6 -6
- package/dist/components/CanvasToolbar.svelte +103 -0
- package/dist/components/CanvasToolbar.svelte.d.ts +23 -0
- package/dist/components/CanvasZoomControls.svelte +122 -0
- package/dist/components/CanvasZoomControls.svelte.d.ts +15 -0
- package/dist/components/ConfigForm.svelte +159 -121
- package/dist/components/ConfigModal.svelte +11 -54
- package/dist/components/ConfigPanel.svelte +98 -228
- package/dist/components/ConfigPanel.svelte.d.ts +2 -2
- package/dist/components/ConnectPortPicker.svelte +153 -0
- package/dist/components/ConnectPortPicker.svelte.d.ts +22 -0
- package/dist/components/DoctorMenu.svelte +422 -0
- package/dist/components/DoctorMenu.svelte.d.ts +7 -0
- package/dist/components/ExternalLinkRow.svelte +82 -0
- package/dist/components/ExternalLinkRow.svelte.d.ts +14 -0
- package/dist/components/FlowDropEdge.svelte +52 -2
- package/dist/components/FlowDropEdge.svelte.d.ts +5 -1
- package/dist/components/InterfaceNameInput.svelte +103 -0
- package/dist/components/InterfaceNameInput.svelte.d.ts +13 -0
- package/dist/components/InterfaceTag.svelte +215 -0
- package/dist/components/InterfaceTag.svelte.d.ts +20 -0
- package/dist/components/InterfaceTagAnchor.svelte +103 -0
- package/dist/components/InterfaceTagAnchor.svelte.d.ts +12 -0
- package/dist/components/InterfaceTagLayer.svelte +314 -0
- package/dist/components/InterfaceTagLayer.svelte.d.ts +28 -0
- package/dist/components/LogsSidebar.svelte +43 -43
- package/dist/components/LoopbackLanes.svelte +54 -0
- package/dist/components/LoopbackLanes.svelte.d.ts +8 -0
- package/dist/components/Navbar.svelte +539 -169
- package/dist/components/Navbar.svelte.d.ts +20 -1
- package/dist/components/NodeInspector.svelte +153 -0
- package/dist/components/NodeInspector.svelte.d.ts +19 -0
- package/dist/components/NodeLastRun.svelte +212 -0
- package/dist/components/NodeLastRun.svelte.d.ts +13 -0
- package/dist/components/NodeSidebar.svelte +279 -23
- package/dist/components/NodeSidebar.svelte.d.ts +11 -0
- package/dist/components/NodeStatusOverlay.svelte +144 -353
- package/dist/components/NodeStatusOverlay.svelte.d.ts +4 -1
- package/dist/components/PortMappingRow.svelte +28 -44
- package/dist/components/PortPickerListbox.svelte +475 -0
- package/dist/components/PortPickerListbox.svelte.d.ts +73 -0
- package/dist/components/ReadOnlyDetails.svelte +52 -89
- package/dist/components/RunBar.svelte +222 -0
- package/dist/components/RunBar.svelte.d.ts +20 -0
- package/dist/components/RunsMenu.svelte +649 -0
- package/dist/components/RunsMenu.svelte.d.ts +14 -0
- package/dist/components/SettingsModal.svelte +27 -59
- package/dist/components/SettingsPanel.svelte +515 -241
- package/dist/components/StraightGuides.svelte +46 -0
- package/dist/components/StraightGuides.svelte.d.ts +7 -0
- package/dist/components/ThemeToggle.svelte +14 -4
- package/dist/components/UniversalNode.svelte +152 -51
- package/dist/components/WebMCPBridgeMenu.svelte +336 -0
- package/dist/components/WebMCPBridgeMenu.svelte.d.ts +3 -0
- package/dist/components/WorkflowEditor.svelte +789 -136
- package/dist/components/WorkflowEditor.svelte.d.ts +43 -1
- package/dist/components/WorkflowInterfaceEditor.svelte +63 -92
- package/dist/components/WorkflowInterfaceEntryCard.svelte +478 -549
- package/dist/components/WorkflowInterfaceEntryComposer.svelte +23 -67
- package/dist/components/WorkflowPlaygroundSettings.svelte +48 -85
- package/dist/components/WorkflowSettingsPanel.svelte +311 -0
- package/dist/components/WorkflowSettingsPanel.svelte.d.ts +20 -0
- package/dist/components/ZoomTier.svelte +56 -0
- package/dist/components/ZoomTier.svelte.d.ts +4 -0
- package/dist/components/chat/AIChatPanel.svelte +463 -312
- package/dist/components/chat/ActivityList.svelte +130 -0
- package/dist/components/chat/ActivityList.svelte.d.ts +11 -0
- package/dist/components/chat/ActivityRow.svelte +179 -0
- package/dist/components/chat/ActivityRow.svelte.d.ts +16 -0
- package/dist/components/chat/CommandPreview.svelte +42 -64
- package/dist/components/console/CommandConsole.svelte +106 -41
- package/dist/components/console/CommandConsole.svelte.d.ts +2 -0
- package/dist/components/console/ConsoleAutocomplete.svelte +14 -13
- package/dist/components/console/ConsoleInput.svelte +60 -27
- package/dist/components/console/ConsoleOutput.svelte +86 -24
- package/dist/components/console/ConsoleStrip.svelte +80 -0
- package/dist/components/console/ConsoleStrip.svelte.d.ts +13 -0
- package/dist/components/form/FieldFactory.svelte +30 -4
- package/dist/components/form/FormArray.svelte +306 -339
- package/dist/components/form/FormArray.svelte.d.ts +10 -0
- package/dist/components/form/FormArrayRows.svelte +443 -0
- package/dist/components/form/FormArrayRows.svelte.d.ts +18 -0
- package/dist/components/form/FormAutocomplete.svelte +2 -2
- package/dist/components/form/FormCheckboxGroup.svelte +10 -85
- package/dist/components/form/FormCodeEditor.svelte +3 -3
- package/dist/components/form/FormFieldWrapper.svelte +98 -18
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +10 -0
- package/dist/components/form/FormFieldset.svelte +44 -28
- package/dist/components/form/FormMarkdownEditor.svelte +6 -6
- package/dist/components/form/FormPorts.svelte +437 -141
- package/dist/components/form/FormSelect.svelte +1 -1
- package/dist/components/form/FormTemplateEditor.svelte +22 -26
- package/dist/components/form/FormToggle.svelte +15 -106
- package/dist/components/form/FormToggle.svelte.d.ts +3 -2
- package/dist/components/form/FormUISchemaRenderer.svelte +38 -3
- package/dist/components/form/humanizeKey.d.ts +7 -0
- package/dist/components/form/humanizeKey.js +21 -0
- package/dist/components/form/types.d.ts +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte +8 -1
- package/dist/components/interrupt/ChoicePrompt.svelte +51 -152
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +0 -2
- package/dist/components/interrupt/ConfirmationPrompt.svelte +18 -201
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +0 -4
- package/dist/components/interrupt/FormPrompt.svelte +22 -147
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +0 -4
- package/dist/components/interrupt/InterruptBubble.svelte +198 -355
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +0 -2
- package/dist/components/interrupt/ReviewPrompt.svelte +0 -10
- package/dist/components/interrupt/TextInputPrompt.svelte +23 -120
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +0 -2
- package/dist/components/layouts/MainLayout.svelte +110 -75
- package/dist/components/layouts/MainLayout.svelte.d.ts +17 -0
- package/dist/components/nodes/CaptionNode.svelte +7 -0
- package/dist/components/nodes/GatewayNode.svelte +66 -431
- package/dist/components/nodes/IdeaNode.svelte +6 -5
- package/dist/components/nodes/NodeCard.svelte +1051 -0
- package/dist/components/nodes/NodeCard.svelte.d.ts +30 -0
- package/dist/components/nodes/NodeConfigButton.svelte +28 -9
- package/dist/components/nodes/NodeProblemMark.svelte +113 -0
- package/dist/components/nodes/NodeProblemMark.svelte.d.ts +8 -0
- package/dist/components/nodes/NodeTip.svelte +104 -0
- package/dist/components/nodes/NodeTip.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +183 -150
- package/dist/components/nodes/SimpleNode.svelte +176 -44
- package/dist/components/nodes/SquareNode.svelte +127 -34
- package/dist/components/nodes/TerminalNode.svelte +232 -88
- package/dist/components/nodes/ToolNode.svelte +49 -381
- package/dist/components/nodes/WorkflowNode.svelte +40 -399
- package/dist/components/playground/ChatBubble.svelte +248 -62
- package/dist/components/playground/ChatInput.svelte +134 -297
- package/dist/components/playground/ChatInput.svelte.d.ts +17 -0
- package/dist/components/playground/ControlPanel.svelte +290 -190
- package/dist/components/playground/ControlPanel.svelte.d.ts +10 -2
- package/dist/components/playground/DockedPlayground.svelte +75 -0
- package/dist/components/playground/DockedPlayground.svelte.d.ts +24 -0
- package/dist/components/playground/ExecutionConsole.svelte +54 -36
- package/dist/components/playground/ExecutionConsole.svelte.d.ts +12 -0
- package/dist/components/playground/ExecutionLogs.svelte +4 -0
- package/dist/components/playground/HeaderMenu.svelte +170 -0
- package/dist/components/playground/HeaderMenu.svelte.d.ts +22 -0
- package/dist/components/playground/InputCollector.svelte +8 -32
- package/dist/components/playground/InputFields.svelte +246 -0
- package/dist/components/playground/InputFields.svelte.d.ts +16 -0
- package/dist/components/playground/InterfaceInputForm.svelte +285 -30
- package/dist/components/playground/InterfaceInputForm.svelte.d.ts +20 -0
- package/dist/components/playground/InterfaceJsonInput.svelte +92 -0
- package/dist/components/playground/InterfaceJsonInput.svelte.d.ts +10 -0
- package/dist/components/playground/LogRow.svelte +12 -12
- package/dist/components/playground/MessageMarkdown.svelte +11 -11
- package/dist/components/playground/MessageStream.svelte +154 -182
- package/dist/components/playground/Playground.svelte +17 -1139
- package/dist/components/playground/PlaygroundApp.svelte +12 -2
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +2 -1
- package/dist/components/playground/PlaygroundHeader.svelte +309 -0
- package/dist/components/playground/PlaygroundHeader.svelte.d.ts +22 -0
- package/dist/components/playground/PlaygroundModal.svelte +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +30 -32
- package/dist/components/playground/PlaygroundSurface.svelte +648 -0
- package/dist/components/playground/PlaygroundSurface.svelte.d.ts +79 -0
- package/dist/components/playground/StepsSummary.svelte +312 -0
- package/dist/components/playground/StepsSummary.svelte.d.ts +11 -0
- package/dist/components/playground/messageDisplay.d.ts +9 -0
- package/dist/components/playground/messageDisplay.js +24 -2
- package/dist/components/playground/stepSummary.d.ts +71 -0
- package/dist/components/playground/stepSummary.js +152 -0
- package/dist/components/ports/PortTypeBadge.svelte +13 -1
- package/dist/components/primitives/Button.svelte +226 -0
- package/dist/components/primitives/Button.svelte.d.ts +31 -0
- package/dist/components/primitives/Card.svelte +110 -0
- package/dist/components/primitives/Card.svelte.d.ts +20 -0
- package/dist/components/primitives/Checkbox.svelte +126 -0
- package/dist/components/primitives/Checkbox.svelte.d.ts +15 -0
- package/dist/components/primitives/Chip.svelte +143 -0
- package/dist/components/primitives/Chip.svelte.d.ts +22 -0
- package/dist/components/primitives/Combobox.svelte +444 -0
- package/dist/components/primitives/Combobox.svelte.d.ts +22 -0
- package/dist/components/primitives/Composer.svelte +293 -0
- package/dist/components/primitives/Composer.svelte.d.ts +47 -0
- package/dist/components/primitives/EmptyState.svelte +113 -0
- package/dist/components/primitives/EmptyState.svelte.d.ts +18 -0
- package/dist/components/primitives/Field.svelte +178 -0
- package/dist/components/primitives/Field.svelte.d.ts +30 -0
- package/dist/components/primitives/IconButton.svelte +156 -0
- package/dist/components/primitives/IconButton.svelte.d.ts +27 -0
- package/dist/components/primitives/Menu.svelte +435 -0
- package/dist/components/primitives/Menu.svelte.d.ts +61 -0
- package/dist/components/primitives/Notice.svelte +161 -0
- package/dist/components/primitives/Notice.svelte.d.ts +22 -0
- package/dist/components/primitives/PanelHeader.svelte +134 -0
- package/dist/components/primitives/PanelHeader.svelte.d.ts +23 -0
- package/dist/components/primitives/Segmented.svelte +198 -0
- package/dist/components/primitives/Segmented.svelte.d.ts +32 -0
- package/dist/components/primitives/Select.svelte +130 -0
- package/dist/components/primitives/Select.svelte.d.ts +26 -0
- package/dist/components/primitives/StatusPill.svelte +218 -0
- package/dist/components/primitives/StatusPill.svelte.d.ts +24 -0
- package/dist/components/primitives/Switch.svelte +113 -0
- package/dist/components/primitives/Switch.svelte.d.ts +14 -0
- package/dist/components/primitives/Tabs.svelte +209 -0
- package/dist/components/primitives/Tabs.svelte.d.ts +32 -0
- package/dist/components/primitives/Toolbar.svelte +94 -0
- package/dist/components/primitives/Toolbar.svelte.d.ts +14 -0
- package/dist/components/primitives/ToolbarSeparator.svelte +40 -0
- package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +7 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte +10 -40
- package/dist/components/surfaces/TabbedSurface.svelte +49 -39
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +8 -0
- package/dist/components/toast/DismissibleToast.svelte +94 -32
- package/dist/components/toast/DismissibleToast.svelte.d.ts +17 -7
- package/dist/config/endpoints.d.ts +43 -1
- package/dist/config/endpoints.js +21 -3
- package/dist/core/index.d.ts +8 -5
- package/dist/core/index.js +1 -1
- package/dist/editor/connectCandidates.d.ts +56 -0
- package/dist/editor/connectCandidates.js +131 -0
- package/dist/editor/contextMenu.d.ts +31 -2
- package/dist/editor/contextMenu.js +96 -9
- package/dist/editor/index.d.ts +3 -1
- package/dist/editor/index.js +1 -0
- package/dist/editor/interfaceMenu.d.ts +35 -0
- package/dist/editor/interfaceMenu.js +47 -0
- package/dist/editor/portMenu.d.ts +23 -0
- package/dist/editor/portMenu.js +34 -0
- package/dist/editor/tidy.d.ts +30 -0
- package/dist/editor/tidy.js +66 -0
- package/dist/helpers/workflowEditorHelper.d.ts +3 -0
- package/dist/helpers/workflowEditorHelper.js +8 -3
- package/dist/layout/fromWorkflow.d.ts +42 -0
- package/dist/layout/fromWorkflow.js +135 -0
- package/dist/layout/geometry.d.ts +102 -0
- package/dist/layout/geometry.js +317 -0
- package/dist/layout/index.d.ts +21 -0
- package/dist/layout/index.js +14 -0
- package/dist/layout/inspect.d.ts +18 -0
- package/dist/layout/inspect.js +81 -0
- package/dist/layout/lanePath.d.ts +23 -0
- package/dist/layout/lanePath.js +47 -0
- package/dist/layout/measure.d.ts +141 -0
- package/dist/layout/measure.js +477 -0
- package/dist/layout/primitives.d.ts +124 -0
- package/dist/layout/primitives.js +461 -0
- package/dist/layout/sweep.d.ts +59 -0
- package/dist/layout/sweep.js +257 -0
- package/dist/layout/toWorkflow.d.ts +43 -0
- package/dist/layout/toWorkflow.js +131 -0
- package/dist/layout/types.d.ts +93 -0
- package/dist/layout/types.js +35 -0
- package/dist/messages/defaults.d.ts +641 -26
- package/dist/messages/defaults.js +578 -25
- package/dist/messages/types.d.ts +21 -1
- package/dist/openapi/v1/openapi.yaml +109 -0
- package/dist/playground/index.d.ts +28 -1
- package/dist/playground/index.js +29 -0
- package/dist/playground/mount.d.ts +28 -2
- package/dist/playground/mount.js +41 -15
- package/dist/playground/runAction.d.ts +29 -0
- package/dist/playground/runAction.js +38 -0
- package/dist/services/doctorService.d.ts +52 -0
- package/dist/services/doctorService.js +113 -0
- package/dist/services/globalSave.js +12 -29
- package/dist/services/nodeExecutionService.d.ts +12 -1
- package/dist/services/nodeExecutionService.js +58 -58
- package/dist/services/playgroundService.d.ts +17 -2
- package/dist/services/playgroundService.js +48 -5
- package/dist/services/runsService.d.ts +42 -0
- package/dist/services/runsService.js +87 -0
- package/dist/services/toastQueue.d.ts +33 -0
- package/dist/services/toastQueue.js +38 -0
- package/dist/services/toastService.d.ts +30 -9
- package/dist/services/toastService.js +81 -46
- package/dist/settings/index.d.ts +1 -0
- package/dist/skins/graphite.d.ts +26 -0
- package/dist/skins/graphite.js +473 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/skins/slate.js +4 -4
- package/dist/stores/attachedRunStore.svelte.d.ts +35 -0
- package/dist/stores/attachedRunStore.svelte.js +47 -0
- package/dist/stores/connectDragStore.svelte.d.ts +39 -0
- package/dist/stores/connectDragStore.svelte.js +42 -0
- package/dist/stores/doctorStore.svelte.d.ts +79 -0
- package/dist/stores/doctorStore.svelte.js +244 -0
- package/dist/stores/editedNodesStore.svelte.d.ts +42 -0
- package/dist/stores/editedNodesStore.svelte.js +84 -0
- package/dist/stores/editorModeStore.svelte.d.ts +34 -0
- package/dist/stores/editorModeStore.svelte.js +55 -0
- package/dist/stores/instanceContainer.svelte.d.ts +53 -0
- package/dist/stores/instanceContainer.svelte.js +38 -1
- package/dist/stores/loopbackLanesStore.svelte.d.ts +18 -0
- package/dist/stores/loopbackLanesStore.svelte.js +25 -0
- package/dist/stores/nodeHighlightStore.svelte.d.ts +34 -0
- package/dist/stores/nodeHighlightStore.svelte.js +56 -0
- package/dist/stores/playgroundStore.svelte.d.ts +66 -2
- package/dist/stores/playgroundStore.svelte.js +164 -2
- package/dist/stores/runController.svelte.d.ts +382 -0
- package/dist/stores/runController.svelte.js +1217 -0
- package/dist/stores/settingsStore.svelte.d.ts +80 -18
- package/dist/stores/settingsStore.svelte.js +180 -62
- package/dist/stores/workflowStore.svelte.d.ts +14 -0
- package/dist/stores/workflowStore.svelte.js +22 -1
- package/dist/styles/base.css +286 -25
- package/dist/styles/fonts/Inter-LICENSE.txt +93 -0
- package/dist/styles/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/inter.css +19 -0
- package/dist/styles/toast.css +100 -20
- package/dist/styles/tokenAliases.js +118 -1
- package/dist/styles/tokens.css +586 -14
- package/dist/svelte-app.d.ts +38 -5
- package/dist/svelte-app.js +14 -3
- package/dist/themes/graphite.d.ts +2 -0
- package/dist/themes/graphite.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +22 -3
- package/dist/themes/minimal.js +10 -0
- package/dist/themes/scopedSkinCss.d.ts +22 -5
- package/dist/themes/scopedSkinCss.js +136 -11
- package/dist/types/chat.d.ts +6 -0
- package/dist/types/doctor.d.ts +82 -0
- package/dist/types/doctor.js +11 -0
- package/dist/types/events.d.ts +35 -0
- package/dist/types/events.js +4 -1
- package/dist/types/index.d.ts +17 -2
- package/dist/types/navbar.d.ts +36 -0
- package/dist/types/playground.d.ts +66 -0
- package/dist/types/settings.d.ts +120 -7
- package/dist/types/settings.js +35 -3
- package/dist/types/skin.d.ts +21 -8
- package/dist/types/theme.d.ts +40 -2
- package/dist/utils/appearance.d.ts +19 -0
- package/dist/utils/appearance.js +13 -0
- package/dist/utils/canvasFit.d.ts +41 -0
- package/dist/utils/canvasFit.js +44 -0
- package/dist/utils/chipTitles.d.ts +9 -0
- package/dist/utils/chipTitles.js +19 -0
- package/dist/utils/connections.js +8 -0
- package/dist/utils/consoleHighlight.d.ts +28 -0
- package/dist/utils/consoleHighlight.js +269 -0
- package/dist/utils/deprecation.d.ts +17 -0
- package/dist/utils/deprecation.js +29 -0
- package/dist/utils/doctorOperations.d.ts +40 -0
- package/dist/utils/doctorOperations.js +237 -0
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +40 -0
- package/dist/utils/inspectorContext.d.ts +19 -0
- package/dist/utils/inspectorContext.js +12 -0
- package/dist/utils/inspectorSections.d.ts +20 -0
- package/dist/utils/inspectorSections.js +44 -0
- package/dist/utils/inspectorSurface.d.ts +46 -0
- package/dist/utils/inspectorSurface.js +51 -0
- package/dist/utils/interfaceTags.d.ts +102 -0
- package/dist/utils/interfaceTags.js +211 -0
- package/dist/utils/itemRef.d.ts +86 -0
- package/dist/utils/itemRef.js +106 -0
- package/dist/utils/lastRun.d.ts +35 -0
- package/dist/utils/lastRun.js +73 -0
- package/dist/utils/messageNodeLink.d.ts +17 -0
- package/dist/utils/messageNodeLink.js +16 -0
- package/dist/utils/minimapVisibility.d.ts +28 -0
- package/dist/utils/minimapVisibility.js +34 -0
- package/dist/utils/nodeAriaLabel.d.ts +12 -0
- package/dist/utils/nodeAriaLabel.js +17 -0
- package/dist/utils/nodeFingerprint.d.ts +27 -0
- package/dist/utils/nodeFingerprint.js +66 -0
- package/dist/utils/nodeFormSchema.d.ts +10 -0
- package/dist/utils/nodeFormSchema.js +2 -2
- package/dist/utils/nodeGeometry.d.ts +168 -0
- package/dist/utils/nodeGeometry.js +204 -0
- package/dist/utils/nodeProblem.d.ts +19 -0
- package/dist/utils/nodeProblem.js +9 -0
- package/dist/utils/nodeStatus.d.ts +38 -3
- package/dist/utils/nodeStatus.js +67 -39
- package/dist/utils/nodeSwap.js +9 -1
- package/dist/utils/nodeWrapper.d.ts +1 -0
- package/dist/utils/playgroundHistory.d.ts +48 -0
- package/dist/utils/playgroundHistory.js +38 -0
- package/dist/utils/playgroundInputRuns.d.ts +26 -0
- package/dist/utils/playgroundInputRuns.js +50 -0
- package/dist/utils/portExposure.d.ts +49 -0
- package/dist/utils/portExposure.js +122 -0
- package/dist/utils/portUtils.d.ts +16 -0
- package/dist/utils/portUtils.js +37 -0
- package/dist/utils/portal.d.ts +0 -19
- package/dist/utils/portal.js +8 -1
- package/dist/utils/reservedPorts.d.ts +59 -0
- package/dist/utils/reservedPorts.js +60 -0
- package/dist/utils/runEdges.d.ts +24 -0
- package/dist/utils/runEdges.js +35 -0
- package/dist/utils/runsList.d.ts +69 -0
- package/dist/utils/runsList.js +134 -0
- package/dist/utils/selectOptions.d.ts +62 -0
- package/dist/utils/selectOptions.js +137 -0
- package/dist/utils/sessionRuns.d.ts +62 -0
- package/dist/utils/sessionRuns.js +123 -0
- package/dist/utils/sheetWidths.d.ts +29 -0
- package/dist/utils/sheetWidths.js +41 -0
- package/dist/utils/sidebarWidths.d.ts +34 -0
- package/dist/utils/sidebarWidths.js +47 -0
- package/dist/utils/straightWires.d.ts +73 -0
- package/dist/utils/straightWires.js +99 -0
- package/dist/utils/themeScope.svelte.d.ts +10 -0
- package/dist/utils/themeScope.svelte.js +80 -0
- package/dist/utils/wiredHandles.d.ts +10 -0
- package/dist/utils/wiredHandles.js +14 -0
- package/dist/utils/workflowDraft.d.ts +9 -0
- package/dist/utils/workflowDraft.js +39 -0
- package/dist/utils/workflowInterface.d.ts +40 -7
- package/dist/utils/workflowInterface.js +66 -16
- package/dist/utils/zoomTier.d.ts +43 -0
- package/dist/utils/zoomTier.js +107 -0
- package/dist/utils/zoomTierRows.d.ts +41 -0
- package/dist/utils/zoomTierRows.js +103 -0
- package/dist/webmcp/WebMCPConfirm.svelte +1 -1
- package/dist/webmcp/bridge.d.ts +5 -0
- package/dist/webmcp/bridge.js +8 -0
- package/dist/webmcp/bridgeController.svelte.d.ts +84 -0
- package/dist/webmcp/bridgeController.svelte.js +224 -0
- package/dist/webmcp/descriptors.d.ts +1 -1
- package/dist/webmcp/descriptors.js +66 -5
- package/dist/webmcp/fakeWidget.d.ts +34 -0
- package/dist/webmcp/fakeWidget.js +75 -0
- package/dist/webmcp/gate.js +4 -0
- package/dist/webmcp/index.d.ts +2 -0
- package/dist/webmcp/index.js +1 -0
- package/dist/webmcp/runtime.js +4 -1
- package/dist/webmcp/types.d.ts +2 -0
- package/dist/webmcp/validate.js +5 -1
- package/package.json +8 -2
- package/dist/components/Select.svelte +0 -53
- package/dist/components/Select.svelte.d.ts +0 -15
- package/dist/components/icons/CommandLineIcon.svelte +0 -15
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +0 -26
- package/dist/components/toast/WarningIcon.svelte +0 -28
- package/dist/components/toast/WarningIcon.svelte.d.ts +0 -26
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: how good a layout is.
|
|
3
|
+
*
|
|
4
|
+
* `measure` counts what the rules care about; `score` turns that into one
|
|
5
|
+
* tuple compared rank by rank, so a lower rank can never buy back a higher one:
|
|
6
|
+
*
|
|
7
|
+
* 1. overlaps (H2; fewer)
|
|
8
|
+
* 2. spacing breaks (H3; fewer)
|
|
9
|
+
* 3. ports passed (H4; fewer)
|
|
10
|
+
* 4. straight wires (H1; more)
|
|
11
|
+
* 5. backward wires (S5; fewer)
|
|
12
|
+
* 6. crossings (S1; fewer)
|
|
13
|
+
* 7. near misses (H4, graded; fewer)
|
|
14
|
+
* 8. pixels moved (S3; fewer, the tie-break)
|
|
15
|
+
*
|
|
16
|
+
* Overlaps rank above spacing: a card on top of another is worse than two cards too close, so a
|
|
17
|
+
* move can never trade a spacing break for an overlap, whatever it does for the wires. Only an
|
|
18
|
+
* overlap, a spacing break or a passed port can bend a straight wire (decision D1, widened by H4).
|
|
19
|
+
*
|
|
20
|
+
* Ports passed (H4): a wire that runs through a handle other than its own two ends reads as if
|
|
21
|
+
* it started, ended or was relayed there (a level wire running through a card's unused input and
|
|
22
|
+
* output looks like it goes through the card). Every such wire and handle counts once, except a
|
|
23
|
+
* handle wired to the same port as the wire's other end (what it suggests is true), and a wire
|
|
24
|
+
* drawn right to left (counted as backward instead).
|
|
25
|
+
*
|
|
26
|
+
* Near misses (H4, graded): a wire that stays out of a handle but comes within one grid step of it
|
|
27
|
+
* still looks attached (a wire leaving a card's edge just above a port). Same exceptions; ranked
|
|
28
|
+
* last before pixels, so it only breaks ties and never costs a straight wire or a crossing.
|
|
29
|
+
*
|
|
30
|
+
* Spacing (decision D2): cards side by side need `gapX` between them, stacked
|
|
31
|
+
* cards need `gapY`, diagonal neighbours need neither. Annotations count as
|
|
32
|
+
* obstacles for cards; one annotation against another is not checked
|
|
33
|
+
* (decision D8). A return lane needs `gapY` of air below it too.
|
|
34
|
+
*
|
|
35
|
+
* @module layout/measure
|
|
36
|
+
*/
|
|
37
|
+
import { boxOf, loopbackLanes, polylineCrossing, wirePaths } from './geometry.js';
|
|
38
|
+
import { LAYOUT_GRID, cardSpanX } from './types.js';
|
|
39
|
+
/** A wire is level when its ends are less than this apart vertically. */
|
|
40
|
+
const LEVEL_EPSILON = 0.5;
|
|
41
|
+
/**
|
|
42
|
+
* A wire closer than this to a handle centre runs through it: half the grid, so a wire on the
|
|
43
|
+
* next port row (one grid step away) does not count.
|
|
44
|
+
*/
|
|
45
|
+
const PORT_HIT = LAYOUT_GRID / 2;
|
|
46
|
+
/** How far a handle may sit outside its card's box (header pins). */
|
|
47
|
+
const HANDLE_SLACK = 40;
|
|
48
|
+
/** Closer than this (but not a hit) is a near miss: one grid step. */
|
|
49
|
+
const PORT_NEAR = LAYOUT_GRID;
|
|
50
|
+
/** Squared distance from a point to a segment. */
|
|
51
|
+
function segmentDistance2(p, a, b) {
|
|
52
|
+
const vx = b[0] - a[0];
|
|
53
|
+
const vy = b[1] - a[1];
|
|
54
|
+
const len2 = vx * vx + vy * vy;
|
|
55
|
+
const t = len2 ? Math.max(0, Math.min(1, ((p[0] - a[0]) * vx + (p[1] - a[1]) * vy) / len2)) : 0;
|
|
56
|
+
const dx = a[0] + t * vx - p[0];
|
|
57
|
+
const dy = a[1] + t * vy - p[1];
|
|
58
|
+
return dx * dx + dy * dy;
|
|
59
|
+
}
|
|
60
|
+
/** Per wire list: which ports feed which (it never depends on where the cards are). */
|
|
61
|
+
const portLinkCache = new WeakMap();
|
|
62
|
+
function portLinks(wires) {
|
|
63
|
+
let links = portLinkCache.get(wires);
|
|
64
|
+
if (!links) {
|
|
65
|
+
const fedBySource = new Map();
|
|
66
|
+
const feedsTarget = new Map();
|
|
67
|
+
const add = (map, key, value) => {
|
|
68
|
+
let set = map.get(key);
|
|
69
|
+
if (!set)
|
|
70
|
+
map.set(key, (set = new Set()));
|
|
71
|
+
set.add(value);
|
|
72
|
+
};
|
|
73
|
+
for (const w of wires) {
|
|
74
|
+
const source = `${w.source}\0${w.sourcePort}`;
|
|
75
|
+
const target = `${w.target}\0${w.targetPort}`;
|
|
76
|
+
add(fedBySource, target, source);
|
|
77
|
+
add(feedsTarget, source, target);
|
|
78
|
+
}
|
|
79
|
+
links = { fedBySource, feedsTarget };
|
|
80
|
+
portLinkCache.set(wires, links);
|
|
81
|
+
}
|
|
82
|
+
return links;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Every wire that runs through, or close past, a handle other than its own two ends. With `cards`,
|
|
86
|
+
* only the handles on those cards.
|
|
87
|
+
*/
|
|
88
|
+
export function portClearance(graph, wires, cards = graph.cards) {
|
|
89
|
+
const sourceOf = (w) => `${w.source}\0${w.sourcePort}`;
|
|
90
|
+
const targetOf = (w) => `${w.target}\0${w.targetPort}`;
|
|
91
|
+
const { fedBySource, feedsTarget } = portLinks(graph.wires);
|
|
92
|
+
const passes = [];
|
|
93
|
+
const nearMisses = [];
|
|
94
|
+
const hit2 = PORT_HIT * PORT_HIT;
|
|
95
|
+
const near2 = PORT_NEAR * PORT_NEAR;
|
|
96
|
+
for (const path of wires) {
|
|
97
|
+
// A wire drawn right to left loops back past its own cards; the backward rank already
|
|
98
|
+
// counts it, and the sweep's first phase turns it around.
|
|
99
|
+
if (path.tx < path.sx && path.laneY === undefined)
|
|
100
|
+
continue;
|
|
101
|
+
const { wire, points } = path;
|
|
102
|
+
const box = boxOf(points);
|
|
103
|
+
const minX = box[0] - PORT_NEAR;
|
|
104
|
+
const minY = box[1] - PORT_NEAR;
|
|
105
|
+
const maxX = box[2] + PORT_NEAR;
|
|
106
|
+
const maxY = box[3] + PORT_NEAR;
|
|
107
|
+
for (const card of cards) {
|
|
108
|
+
if (card.kind !== 'card')
|
|
109
|
+
continue;
|
|
110
|
+
// A handle sits on its card (a pin may stick out a little): a card far from the wire has
|
|
111
|
+
// none to hit.
|
|
112
|
+
if (card.x - HANDLE_SLACK > maxX ||
|
|
113
|
+
card.x + card.width + HANDLE_SLACK < minX ||
|
|
114
|
+
card.y - HANDLE_SLACK > maxY ||
|
|
115
|
+
card.y + card.height + HANDLE_SLACK < minY)
|
|
116
|
+
continue;
|
|
117
|
+
for (const direction of ['input', 'output']) {
|
|
118
|
+
for (const handle of direction === 'input' ? card.inputs : card.outputs) {
|
|
119
|
+
// Position first: it rules out almost every handle, and the key below costs a string.
|
|
120
|
+
const at = [card.x + handle.dx, card.y + handle.dy];
|
|
121
|
+
if (at[0] < minX || at[0] > maxX || at[1] < minY || at[1] > maxY)
|
|
122
|
+
continue;
|
|
123
|
+
const key = `${card.id}\0${handle.portId}`;
|
|
124
|
+
if (direction === 'output'
|
|
125
|
+
? feedsTarget.get(key)?.has(targetOf(wire))
|
|
126
|
+
: fedBySource.get(key)?.has(sourceOf(wire)))
|
|
127
|
+
continue;
|
|
128
|
+
let closest = Infinity;
|
|
129
|
+
for (let i = 0; i < points.length - 1 && closest >= hit2; i++) {
|
|
130
|
+
closest = Math.min(closest, segmentDistance2(at, points[i], points[i + 1]));
|
|
131
|
+
}
|
|
132
|
+
const pass = { wire: wire.id, card: card.id, port: handle.portId, direction };
|
|
133
|
+
if (closest < hit2)
|
|
134
|
+
passes.push(pass);
|
|
135
|
+
else if (closest < near2)
|
|
136
|
+
nearMisses.push(pass);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return { passes, nearMisses };
|
|
142
|
+
}
|
|
143
|
+
/** Whether a resolved, non-loopback wire is straight: level and left to right. */
|
|
144
|
+
export function isStraight(path) {
|
|
145
|
+
return !path.wire.loopback && path.tx >= path.sx && Math.abs(path.sy - path.ty) < LEVEL_EPSILON;
|
|
146
|
+
}
|
|
147
|
+
/** Whether a resolved, non-loopback wire runs right to left. */
|
|
148
|
+
export function isBackward(path) {
|
|
149
|
+
return !path.wire.loopback && path.tx < path.sx;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The air between two boxes along x and along y; negative when their projections overlap.
|
|
153
|
+
* Along x a card reaches as far as its interface tags.
|
|
154
|
+
*/
|
|
155
|
+
function gaps(a, b) {
|
|
156
|
+
const [aLeft, aRight] = cardSpanX(a);
|
|
157
|
+
const [bLeft, bRight] = cardSpanX(b);
|
|
158
|
+
return {
|
|
159
|
+
gx: Math.max(bLeft - aRight, aLeft - bRight),
|
|
160
|
+
gy: Math.max(b.y - (a.y + a.height), a.y - (b.y + b.height))
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** Whether two cards overlap, or are too close: `null` when neither. */
|
|
164
|
+
function cardConflict(a, b, options) {
|
|
165
|
+
if (a.kind !== 'card' && b.kind !== 'card')
|
|
166
|
+
return null;
|
|
167
|
+
const { gx, gy } = gaps(a, b);
|
|
168
|
+
if (gx < 0 && gy < 0)
|
|
169
|
+
return 'overlap';
|
|
170
|
+
if ((gx < 0 && gy < options.gapY) || (gy < 0 && gx < options.gapX))
|
|
171
|
+
return 'spacing';
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/** The cards too close to a return lane: any card across its span but outside its body. */
|
|
175
|
+
function laneConflicts(path, cards, options) {
|
|
176
|
+
if (path.laneY === undefined)
|
|
177
|
+
return [];
|
|
178
|
+
const lo = Math.min(path.sx, path.tx);
|
|
179
|
+
const hi = Math.max(path.sx, path.tx);
|
|
180
|
+
const conflicts = [];
|
|
181
|
+
for (const card of cards) {
|
|
182
|
+
if (card.kind !== 'card' || path.body?.has(card.id))
|
|
183
|
+
continue;
|
|
184
|
+
const [left, right] = cardSpanX(card);
|
|
185
|
+
if (left >= hi || right <= lo)
|
|
186
|
+
continue;
|
|
187
|
+
if (card.y + card.height > path.laneY - options.gapY + LEVEL_EPSILON &&
|
|
188
|
+
card.y < path.laneY + options.gapY) {
|
|
189
|
+
conflicts.push({ card: card.id, with: path.wire.id, kind: 'lane' });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return conflicts;
|
|
193
|
+
}
|
|
194
|
+
/** Where two wires cross, or null. Wires fanning out of one port, or into one port, meet by design. */
|
|
195
|
+
function wireCrossing(a, b) {
|
|
196
|
+
if (a.wire.source === b.wire.source && a.wire.sourcePort === b.wire.sourcePort)
|
|
197
|
+
return null;
|
|
198
|
+
if (a.wire.target === b.wire.target && a.wire.targetPort === b.wire.targetPort)
|
|
199
|
+
return null;
|
|
200
|
+
return polylineCrossing(a.points, b.points);
|
|
201
|
+
}
|
|
202
|
+
/** Measure a layout. */
|
|
203
|
+
export function measure(graph, options) {
|
|
204
|
+
const wires = wirePaths(graph, options);
|
|
205
|
+
const resolved = new Set(wires.map((path) => path.wire.id));
|
|
206
|
+
const unresolved = graph.wires.filter((wire) => !resolved.has(wire.id)).map((wire) => wire.id);
|
|
207
|
+
let straight = 0;
|
|
208
|
+
let total = 0;
|
|
209
|
+
let backward = 0;
|
|
210
|
+
for (const path of wires) {
|
|
211
|
+
if (path.wire.loopback)
|
|
212
|
+
continue;
|
|
213
|
+
total++;
|
|
214
|
+
if (isBackward(path))
|
|
215
|
+
backward++;
|
|
216
|
+
else if (isStraight(path))
|
|
217
|
+
straight++;
|
|
218
|
+
}
|
|
219
|
+
const conflicts = [];
|
|
220
|
+
let overlaps = 0;
|
|
221
|
+
let spacing = 0;
|
|
222
|
+
const { cards } = graph;
|
|
223
|
+
for (let i = 0; i < cards.length; i++) {
|
|
224
|
+
for (let j = i + 1; j < cards.length; j++) {
|
|
225
|
+
const kind = cardConflict(cards[i], cards[j], options);
|
|
226
|
+
if (!kind)
|
|
227
|
+
continue;
|
|
228
|
+
if (kind === 'overlap')
|
|
229
|
+
overlaps++;
|
|
230
|
+
else
|
|
231
|
+
spacing++;
|
|
232
|
+
conflicts.push({ card: cards[i].id, with: cards[j].id, kind });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// A lane runs under its loop body; any other card across its span keeps gapY clear of it.
|
|
236
|
+
for (const path of wires) {
|
|
237
|
+
const lane = laneConflicts(path, cards, options);
|
|
238
|
+
spacing += lane.length;
|
|
239
|
+
conflicts.push(...lane);
|
|
240
|
+
}
|
|
241
|
+
const crossings = [];
|
|
242
|
+
for (let i = 0; i < wires.length; i++) {
|
|
243
|
+
for (let j = i + 1; j < wires.length; j++) {
|
|
244
|
+
const at = wireCrossing(wires[i], wires[j]);
|
|
245
|
+
if (at)
|
|
246
|
+
crossings.push({ a: wires[i].wire.id, b: wires[j].wire.id, at });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
straight,
|
|
251
|
+
total,
|
|
252
|
+
backward,
|
|
253
|
+
overlaps,
|
|
254
|
+
spacing,
|
|
255
|
+
conflicts,
|
|
256
|
+
crossings,
|
|
257
|
+
...portClearance(graph, wires),
|
|
258
|
+
wires,
|
|
259
|
+
unresolved
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/** The ranked score of a measured layout, given how far the change moved cards (px). */
|
|
263
|
+
export function score(metrics, moved = 0) {
|
|
264
|
+
return [
|
|
265
|
+
metrics.overlaps,
|
|
266
|
+
metrics.spacing,
|
|
267
|
+
metrics.passes.length,
|
|
268
|
+
-metrics.straight,
|
|
269
|
+
metrics.backward,
|
|
270
|
+
metrics.crossings.length,
|
|
271
|
+
metrics.nearMisses.length,
|
|
272
|
+
moved
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
/** Whether two polylines are the same points. */
|
|
276
|
+
function samePoints(a, b) {
|
|
277
|
+
if (a.length !== b.length)
|
|
278
|
+
return false;
|
|
279
|
+
for (let i = 0; i < a.length; i++)
|
|
280
|
+
if (a[i][0] !== b[i][0] || a[i][1] !== b[i][1])
|
|
281
|
+
return false;
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The score of `next`, a layout that differs from the measured `base` only in where `cardId`
|
|
286
|
+
* is. Equal to `score(measure(next, options), moved)`, but counts again only what the move can
|
|
287
|
+
* change: the card's pairs, the wires on the card and (with return lanes) the lanes whose path
|
|
288
|
+
* the move changed, since a lane follows its loop body and the lanes it nests with. A primitive
|
|
289
|
+
* judges its candidates with it and measures the winner.
|
|
290
|
+
*
|
|
291
|
+
* With `bound` (the best score so far) a candidate that is already worse than it on a higher rank
|
|
292
|
+
* is dropped before the dear ranks (ports passed, crossings) are counted: the result is then
|
|
293
|
+
* only guaranteed to rank worse than `bound`, its lower ranks being `Infinity`. Without `bound`
|
|
294
|
+
* it is exact.
|
|
295
|
+
*/
|
|
296
|
+
export function scoreMove(base, next, cardId, options, moved = 0, bound) {
|
|
297
|
+
// `rank` ranks counted so far: worse than the bound on the first difference means stop.
|
|
298
|
+
const beaten = (counted) => {
|
|
299
|
+
if (!bound)
|
|
300
|
+
return false;
|
|
301
|
+
for (let i = 0; i < counted.length; i++) {
|
|
302
|
+
if (counted[i] > bound[i])
|
|
303
|
+
return true;
|
|
304
|
+
if (counted[i] < bound[i])
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
};
|
|
309
|
+
const dropped = (counted) => {
|
|
310
|
+
const rest = Array(8 - counted.length).fill(Infinity);
|
|
311
|
+
return [...counted, ...rest];
|
|
312
|
+
};
|
|
313
|
+
const lanesOn = options.loopbacks === 'lane';
|
|
314
|
+
const basePaths = new Map(base.wires.map((path) => [path.wire.id, path]));
|
|
315
|
+
// Lanes are cheap polylines; the work is what they cross. Work out the new lanes of the whole
|
|
316
|
+
// graph and count again only the loopbacks whose path differs from the measured one.
|
|
317
|
+
let lanes;
|
|
318
|
+
if (lanesOn && next.wires.some((wire) => wire.loopback))
|
|
319
|
+
lanes = loopbackLanes(next);
|
|
320
|
+
const touched = (wire) => {
|
|
321
|
+
if (wire.source === cardId || wire.target === cardId)
|
|
322
|
+
return true;
|
|
323
|
+
if (!lanesOn || !wire.loopback)
|
|
324
|
+
return false;
|
|
325
|
+
const was = basePaths.get(wire.id);
|
|
326
|
+
const now = lanes?.get(wire.id);
|
|
327
|
+
return !was || !now || !samePoints(was.points, now.points);
|
|
328
|
+
};
|
|
329
|
+
const changed = new Set(next.wires.filter(touched).map((wire) => wire.id));
|
|
330
|
+
const fresh = wirePaths(next, options, (wire) => changed.has(wire.id), lanes);
|
|
331
|
+
const kept = base.wires.filter((path) => !changed.has(path.wire.id));
|
|
332
|
+
let straight = base.straight;
|
|
333
|
+
let backward = base.backward;
|
|
334
|
+
for (const path of base.wires) {
|
|
335
|
+
if (!changed.has(path.wire.id))
|
|
336
|
+
continue;
|
|
337
|
+
if (isBackward(path))
|
|
338
|
+
backward--;
|
|
339
|
+
else if (isStraight(path))
|
|
340
|
+
straight--;
|
|
341
|
+
}
|
|
342
|
+
for (const path of fresh) {
|
|
343
|
+
if (isBackward(path))
|
|
344
|
+
backward++;
|
|
345
|
+
else if (isStraight(path))
|
|
346
|
+
straight++;
|
|
347
|
+
}
|
|
348
|
+
// Card pairs without the moved card stand; so do the lane breaks of lanes that did not change
|
|
349
|
+
// (except against the moved card).
|
|
350
|
+
let overlaps = 0;
|
|
351
|
+
let spacing = 0;
|
|
352
|
+
for (const c of base.conflicts) {
|
|
353
|
+
if (c.kind === 'lane') {
|
|
354
|
+
if (c.card !== cardId && !changed.has(c.with))
|
|
355
|
+
spacing++;
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (c.card === cardId || c.with === cardId)
|
|
359
|
+
continue;
|
|
360
|
+
if (c.kind === 'overlap')
|
|
361
|
+
overlaps++;
|
|
362
|
+
else
|
|
363
|
+
spacing++;
|
|
364
|
+
}
|
|
365
|
+
const card = next.cards.find((c) => c.id === cardId);
|
|
366
|
+
if (card) {
|
|
367
|
+
for (const other of next.cards) {
|
|
368
|
+
if (other.id === cardId)
|
|
369
|
+
continue;
|
|
370
|
+
const kind = cardConflict(card, other, options);
|
|
371
|
+
if (kind === 'overlap')
|
|
372
|
+
overlaps++;
|
|
373
|
+
else if (kind)
|
|
374
|
+
spacing++;
|
|
375
|
+
}
|
|
376
|
+
for (const path of kept)
|
|
377
|
+
spacing += laneConflicts(path, [card], options).length;
|
|
378
|
+
}
|
|
379
|
+
for (const path of fresh)
|
|
380
|
+
spacing += laneConflicts(path, next.cards, options).length;
|
|
381
|
+
if (beaten([overlaps, spacing]))
|
|
382
|
+
return dropped([overlaps, spacing]);
|
|
383
|
+
// Changed wires against every handle, unchanged wires against the moved card's handles.
|
|
384
|
+
const stands = (pass) => !changed.has(pass.wire) && pass.card !== cardId;
|
|
385
|
+
const ofFresh = portClearance(next, fresh);
|
|
386
|
+
const ofKept = card ? portClearance(next, kept, [card]) : { passes: [], nearMisses: [] };
|
|
387
|
+
const passes = base.passes.filter(stands).length + ofFresh.passes.length + ofKept.passes.length;
|
|
388
|
+
if (beaten([overlaps, spacing, passes, -straight, backward])) {
|
|
389
|
+
return dropped([overlaps, spacing, passes, -straight, backward]);
|
|
390
|
+
}
|
|
391
|
+
let crossings = base.crossings.filter((c) => !changed.has(c.a) && !changed.has(c.b)).length;
|
|
392
|
+
for (let i = 0; i < fresh.length; i++) {
|
|
393
|
+
for (const other of kept)
|
|
394
|
+
if (wireCrossing(fresh[i], other))
|
|
395
|
+
crossings++;
|
|
396
|
+
for (let j = i + 1; j < fresh.length; j++)
|
|
397
|
+
if (wireCrossing(fresh[i], fresh[j]))
|
|
398
|
+
crossings++;
|
|
399
|
+
}
|
|
400
|
+
const nearMisses = base.nearMisses.filter(stands).length + ofFresh.nearMisses.length + ofKept.nearMisses.length;
|
|
401
|
+
return [overlaps, spacing, passes, -straight, backward, crossings, nearMisses, moved];
|
|
402
|
+
}
|
|
403
|
+
/** True when `a` beats `b` (strictly). */
|
|
404
|
+
export function better(a, b) {
|
|
405
|
+
for (let i = 0; i < a.length; i++) {
|
|
406
|
+
if (a[i] < b[i])
|
|
407
|
+
return true;
|
|
408
|
+
if (a[i] > b[i])
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
/** The cards in a conflict. */
|
|
414
|
+
export function conflictCards(metrics) {
|
|
415
|
+
const ids = new Set();
|
|
416
|
+
for (const c of metrics.conflicts) {
|
|
417
|
+
ids.add(c.card);
|
|
418
|
+
if (c.kind !== 'lane')
|
|
419
|
+
ids.add(c.with);
|
|
420
|
+
}
|
|
421
|
+
return ids;
|
|
422
|
+
}
|
|
423
|
+
/** The cards a passed port is on, and the two ends of each wire that passes one. */
|
|
424
|
+
export function passCards(metrics) {
|
|
425
|
+
const ends = new Map(metrics.wires.map((p) => [p.wire.id, p.wire]));
|
|
426
|
+
const ids = new Set();
|
|
427
|
+
for (const pass of metrics.passes) {
|
|
428
|
+
ids.add(pass.card);
|
|
429
|
+
const wire = ends.get(pass.wire);
|
|
430
|
+
if (wire) {
|
|
431
|
+
ids.add(wire.source);
|
|
432
|
+
ids.add(wire.target);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return ids;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* One line for the console: `straight 3/6 · backward 0 · crossings 0 · overlaps 0 · spacing ok`,
|
|
439
|
+
* with `· ports passed 2` / `· near misses 1` when there are any.
|
|
440
|
+
*/
|
|
441
|
+
export function formatMetrics(metrics) {
|
|
442
|
+
return [
|
|
443
|
+
`straight ${metrics.straight}/${metrics.total}`,
|
|
444
|
+
`backward ${metrics.backward}`,
|
|
445
|
+
`crossings ${metrics.crossings.length}`,
|
|
446
|
+
`overlaps ${metrics.overlaps}`,
|
|
447
|
+
`spacing ${metrics.spacing ? `${metrics.spacing} too close` : 'ok'}`,
|
|
448
|
+
...(metrics.passes.length ? [`ports passed ${metrics.passes.length}`] : []),
|
|
449
|
+
...(metrics.nearMisses.length ? [`near misses ${metrics.nearMisses.length}`] : [])
|
|
450
|
+
].join(' · ');
|
|
451
|
+
}
|
|
452
|
+
/** `before → after`, or the value once when it did not change. */
|
|
453
|
+
function change(before, after) {
|
|
454
|
+
return before === after ? `${before}` : `${before} → ${after}`;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* The score before and after on one line: `straight 0 → 1 · crossings 3 → 2 · overlaps 1 ·
|
|
458
|
+
* spacing ok`. A value that did not change is printed once; `backward` appears only when
|
|
459
|
+
* either side is non-zero; `straight` has no `/total`.
|
|
460
|
+
*/
|
|
461
|
+
export function formatChange(before, after, options = {}) {
|
|
462
|
+
const spacing = (m) => (m.spacing ? `${m.spacing} too close` : 'ok');
|
|
463
|
+
const parts = [
|
|
464
|
+
['straight', before.straight, after.straight]
|
|
465
|
+
];
|
|
466
|
+
if (before.backward || after.backward)
|
|
467
|
+
parts.push(['backward', before.backward, after.backward]);
|
|
468
|
+
parts.push(['crossings', before.crossings.length, after.crossings.length], ['overlaps', before.overlaps, after.overlaps], ['spacing', spacing(before), spacing(after)]);
|
|
469
|
+
if (before.passes.length || after.passes.length)
|
|
470
|
+
parts.push(['ports passed', before.passes.length, after.passes.length]);
|
|
471
|
+
if (before.nearMisses.length || after.nearMisses.length)
|
|
472
|
+
parts.push(['near misses', before.nearMisses.length, after.nearMisses.length]);
|
|
473
|
+
return parts
|
|
474
|
+
.filter(([, b, a]) => !options.onlyChanged || b !== a)
|
|
475
|
+
.map(([name, b, a]) => `${name} ${change(b, a)}`)
|
|
476
|
+
.join(' · ');
|
|
477
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: the primitives.
|
|
3
|
+
*
|
|
4
|
+
* Each primitive looks at one node and proposes one change to the graph: the
|
|
5
|
+
* next graph, what changed, the score before and after, and a one-line message.
|
|
6
|
+
* Nothing is written; the caller reads the proposal and decides. A proposal is
|
|
7
|
+
* accepted only when its score beats the current layout (`better(score(after,
|
|
8
|
+
* moved), score(before, 0))`), so a refusal always carries a reason. Only the
|
|
9
|
+
* given node's pixels count as moved. Inputs are never mutated.
|
|
10
|
+
*
|
|
11
|
+
* - `column`: x to the node's column (longest forward path), then a vertical search for room.
|
|
12
|
+
* - `ports`: connected, non-fixed handles re-sorted by the y of what they connect to, within the
|
|
13
|
+
* slots they already hold. Never moves the node.
|
|
14
|
+
* - `align`: y, one candidate per wire (the shift that levels it). Never changes x.
|
|
15
|
+
* - `clear`: y, only for a card in an overlap or spacing break, or on a wire through a port (H4).
|
|
16
|
+
* Never changes x.
|
|
17
|
+
*
|
|
18
|
+
* `clear` and `column` never move a card above the topmost card of the graph (Q2).
|
|
19
|
+
*
|
|
20
|
+
* Annotations (notes, captions) are never laid out; they stay obstacles (D7, D8).
|
|
21
|
+
* Positions stay on the 20px grid (H0). An unknown node id throws.
|
|
22
|
+
*
|
|
23
|
+
* @module layout/primitives
|
|
24
|
+
*/
|
|
25
|
+
import { type LayoutMetrics } from './measure.js';
|
|
26
|
+
import { type LayoutGraph, type LayoutOptions } from './types.js';
|
|
27
|
+
export type LayoutPrimitive = 'column' | 'ports' | 'align' | 'clear';
|
|
28
|
+
export type LayoutStrategy = LayoutPrimitive | 'all';
|
|
29
|
+
/** The order `all` runs the primitives in. */
|
|
30
|
+
export declare const STRATEGY_ORDER: readonly LayoutPrimitive[];
|
|
31
|
+
export interface PortOrderChange {
|
|
32
|
+
from: string[];
|
|
33
|
+
to: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface LayoutChanges {
|
|
36
|
+
position?: {
|
|
37
|
+
from: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
to: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Handle order of the card, top to bottom, fixed handles included. */
|
|
47
|
+
ports?: {
|
|
48
|
+
inputs?: PortOrderChange;
|
|
49
|
+
outputs?: PortOrderChange;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface LayoutProposal {
|
|
53
|
+
nodeId: string;
|
|
54
|
+
primitive: LayoutPrimitive;
|
|
55
|
+
accepted: boolean;
|
|
56
|
+
/** The next graph when accepted, else the input graph itself. */
|
|
57
|
+
graph: LayoutGraph;
|
|
58
|
+
/** What changed; empty when refused. */
|
|
59
|
+
changes: LayoutChanges;
|
|
60
|
+
before: LayoutMetrics;
|
|
61
|
+
/** The metrics of `graph`: equal to `before` when refused. */
|
|
62
|
+
after: LayoutMetrics;
|
|
63
|
+
/** Pixels the node moved (|dx| + |dy|); 0 for ports and refusals. */
|
|
64
|
+
moved: number;
|
|
65
|
+
/** One line without the node id: the change, or the best candidate when refused. */
|
|
66
|
+
message: string;
|
|
67
|
+
/** Why nothing changed; set exactly when refused. */
|
|
68
|
+
reason?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface BeautifyResult {
|
|
71
|
+
nodeId: string;
|
|
72
|
+
strategy: LayoutStrategy;
|
|
73
|
+
/** One per primitive run. `all` on an annotation gives one refusal (as `column`). */
|
|
74
|
+
steps: LayoutProposal[];
|
|
75
|
+
/** True when any step was accepted. */
|
|
76
|
+
accepted: boolean;
|
|
77
|
+
before: LayoutMetrics;
|
|
78
|
+
after: LayoutMetrics;
|
|
79
|
+
/** The graph after every accepted step. */
|
|
80
|
+
graph: LayoutGraph;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Longest path over non-loopback wires between cards; annotations are ignored. A cycle of
|
|
84
|
+
* non-loopback wires (one that does not run through a loop_back port) has no longest path: the
|
|
85
|
+
* wire that closes it, the one a depth-first walk from the start nodes meets last, is a back
|
|
86
|
+
* edge and counts for nothing, so the rest of the cycle lays out left to right and the back
|
|
87
|
+
* edge runs right to left like any backward wire.
|
|
88
|
+
*/
|
|
89
|
+
export declare function columnRanks(graph: LayoutGraph): Map<string, number>;
|
|
90
|
+
/**
|
|
91
|
+
* Where columns start (x of rank 0) and how far apart they are: the widest card plus the gap.
|
|
92
|
+
* A column whose cards have interface tags moves further right by the room the tags take: the
|
|
93
|
+
* output tags of the column before it and the input tags of its own cards. `columnX` is the x of
|
|
94
|
+
* every rank.
|
|
95
|
+
*/
|
|
96
|
+
export declare function columnGrid(graph: LayoutGraph, options: LayoutOptions): {
|
|
97
|
+
origin: number;
|
|
98
|
+
stride: number;
|
|
99
|
+
columnX: (rank: number) => number;
|
|
100
|
+
};
|
|
101
|
+
export interface ProposeOptions {
|
|
102
|
+
/**
|
|
103
|
+
* `column` only: take the best spot in the column even when it scores worse than where the card
|
|
104
|
+
* is now. The sweep's phase 0 uses it: every card goes into its column first, and a half-done
|
|
105
|
+
* graph (some cards in columns, some not) is no fair judge of a single move.
|
|
106
|
+
*/
|
|
107
|
+
force?: boolean;
|
|
108
|
+
/** `measure(graph, options)`, when the caller has it already (the sweep, `beautify`). */
|
|
109
|
+
before?: LayoutMetrics;
|
|
110
|
+
}
|
|
111
|
+
/** What a primitive would do to one node, judged against the current layout. */
|
|
112
|
+
export declare function propose(graph: LayoutGraph, nodeId: string, primitive: LayoutPrimitive, options: LayoutOptions, { force, before }?: ProposeOptions): LayoutProposal;
|
|
113
|
+
/**
|
|
114
|
+
* Run a primitive, or for `all` column, ports, align, clear in that order, each judged on the
|
|
115
|
+
* graph the previous step left.
|
|
116
|
+
*/
|
|
117
|
+
export declare function beautify(graph: LayoutGraph, nodeId: string, strategy: LayoutStrategy, options: LayoutOptions): BeautifyResult;
|
|
118
|
+
/**
|
|
119
|
+
* Console lines for a proposal: `compose: inputs reordered …` and the score change, or
|
|
120
|
+
* `compose: no change; <reason>`. A dry run says what would happen.
|
|
121
|
+
*/
|
|
122
|
+
export declare function formatProposal(proposal: LayoutProposal, dryRun?: boolean): string[];
|
|
123
|
+
/** Console lines for a beautify run, in the design's format. */
|
|
124
|
+
export declare function formatBeautify(result: BeautifyResult, dryRun?: boolean): string[];
|