@link-foundation/ui-components 0.0.0-stage → 0.0.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/CONFIGURATIONS.md +74 -0
- package/ICONS.md +76 -0
- package/LICENSE +24 -0
- package/README.md +1499 -2
- package/bin/lino-network.mjs +71 -0
- package/dist/icons/ATTRIBUTION.md +602 -0
- package/dist/icons/NOTICE.lino +1261 -0
- package/dist/icons/brand.js +31 -0
- package/dist/icons/brand.svg +3 -0
- package/dist/icons/licenses/brand/DISCLAIMER.md +51 -0
- package/dist/icons/licenses/brand/LICENSE.md +30 -0
- package/dist/icons/licenses/lucide/LICENSE +43 -0
- package/dist/icons/licenses/material-symbols/LICENSE +202 -0
- package/dist/icons/licenses/material-symbols/NOTICE +12 -0
- package/dist/icons/licenses/tabler/LICENSE +21 -0
- package/dist/icons/lucide.js +681 -0
- package/dist/icons/lucide.svg +34 -0
- package/dist/icons/material-symbols.js +681 -0
- package/dist/icons/material-symbols.svg +34 -0
- package/dist/icons/own.js +521 -0
- package/dist/icons/own.svg +34 -0
- package/dist/icons/tabler.js +681 -0
- package/dist/icons/tabler.svg +34 -0
- package/dist/network-layout-NOTICE.md +6 -0
- package/dist/network-layout-d3-dispatch-LICENSE.txt +13 -0
- package/dist/network-layout-d3-force-LICENSE.txt +13 -0
- package/dist/network-layout-d3-quadtree-LICENSE.txt +13 -0
- package/dist/network-layout-d3-timer-LICENSE.txt +13 -0
- package/dist/network-layout-dagre-LICENSE.txt +19 -0
- package/dist/network-layout.worker.mjs +2 -0
- package/package.json +246 -4
- package/src/a11y/announce.js +88 -0
- package/src/a11y/bind-machine.js +181 -0
- package/src/a11y/focus.js +169 -0
- package/src/a11y/index.d.ts +89 -0
- package/src/a11y/index.js +19 -0
- package/src/a11y/keys.js +182 -0
- package/src/a11y/roving.js +167 -0
- package/src/a11y/typeahead.js +82 -0
- package/src/behavior/actions.js +235 -0
- package/src/behavior/diagnostics.js +73 -0
- package/src/behavior/dom.d.ts +38 -0
- package/src/behavior/dom.js +420 -0
- package/src/behavior/index.d.ts +211 -0
- package/src/behavior/index.js +29 -0
- package/src/behavior/interpret.js +454 -0
- package/src/behavior/machines/disclosure.lino +46 -0
- package/src/behavior/machines/index.js +91 -0
- package/src/behavior/machines/toggle.lino +25 -0
- package/src/behavior/parse-machine.js +367 -0
- package/src/charts/README.md +78 -0
- package/src/charts/activity-layout.js +350 -0
- package/src/charts/activity-model.js +130 -0
- package/src/charts/activity-validation.js +31 -0
- package/src/charts/chart-model.js +667 -0
- package/src/charts/chart.js +518 -0
- package/src/charts/echarts-adapter.d.ts +23 -0
- package/src/charts/echarts-adapter.js +240 -0
- package/src/charts/element.js +330 -0
- package/src/charts/errors.js +62 -0
- package/src/charts/gauge.js +27 -0
- package/src/charts/index.d.ts +344 -0
- package/src/charts/index.js +59 -0
- package/src/charts/layout.js +542 -0
- package/src/charts/lino.js +158 -0
- package/src/charts/mark-options.js +78 -0
- package/src/charts/read.js +101 -0
- package/src/charts/renderer-features.js +8 -0
- package/src/charts/scales.js +223 -0
- package/src/charts/small-model.js +223 -0
- package/src/charts/small-svg.js +269 -0
- package/src/charts/sparkline.js +27 -0
- package/src/charts/stat-tile.js +37 -0
- package/src/charts/summary.js +193 -0
- package/src/charts/svg-renderer.js +226 -0
- package/src/charts/svg.js +69 -0
- package/src/charts/tag-cloud.js +129 -0
- package/src/charts/tokens.js +171 -0
- package/src/charts/tooltip.js +47 -0
- package/src/charts/values.js +146 -0
- package/src/chat/README.md +142 -0
- package/src/chat/actions.js +75 -0
- package/src/chat/chat-contract.js +95 -0
- package/src/chat/chat-list.js +42 -0
- package/src/chat/chat-model.js +125 -0
- package/src/chat/chat.css +228 -0
- package/src/chat/composer.js +131 -0
- package/src/chat/day-separator.js +12 -0
- package/src/chat/dom.js +33 -0
- package/src/chat/follow.js +49 -0
- package/src/chat/index.d.ts +142 -0
- package/src/chat/index.js +13 -0
- package/src/chat/message-bubble.js +191 -0
- package/src/chat/message-stream.js +331 -0
- package/src/chat/reasoning-trace.js +70 -0
- package/src/chat/selection.js +39 -0
- package/src/chat/skins/bubbles.lino +2 -0
- package/src/chat/skins/cards.lino +4 -0
- package/src/chat/skins/compact.lino +4 -0
- package/src/chat/skins/signal.lino +25 -0
- package/src/chat/skins/t3.lino +25 -0
- package/src/chat/skins/telegram.lino +31 -0
- package/src/chat/skins/whatsapp.lino +25 -0
- package/src/chat/stream-keys.js +57 -0
- package/src/chat/stream-window.js +159 -0
- package/src/chat/vocabulary.js +19 -0
- package/src/controls/accordion.js +160 -0
- package/src/controls/avatar.js +80 -0
- package/src/controls/badge.js +48 -0
- package/src/controls/button-template.js +32 -0
- package/src/controls/button.js +97 -0
- package/src/controls/catalog.lino +84 -0
- package/src/controls/checkbox.js +112 -0
- package/src/controls/chip.js +140 -0
- package/src/controls/choices.js +45 -0
- package/src/controls/color-field.js +217 -0
- package/src/controls/color-popover.js +135 -0
- package/src/controls/color-rgb.js +80 -0
- package/src/controls/color.js +67 -0
- package/src/controls/combobox.js +192 -0
- package/src/controls/dom.js +261 -0
- package/src/controls/icon-button.js +33 -0
- package/src/controls/index.d.ts +163 -0
- package/src/controls/index.js +182 -0
- package/src/controls/kinds-text.js +358 -0
- package/src/controls/kinds.lino +350 -0
- package/src/controls/label.js +52 -0
- package/src/controls/link.js +101 -0
- package/src/controls/listbox.js +144 -0
- package/src/controls/machines/button.lino +20 -0
- package/src/controls/machines/checkbox.lino +17 -0
- package/src/controls/machines/chip.lino +20 -0
- package/src/controls/machines/color-field.lino +23 -0
- package/src/controls/machines/combobox.lino +82 -0
- package/src/controls/machines/icon-button.lino +20 -0
- package/src/controls/machines/index.js +586 -0
- package/src/controls/machines/number-field.lino +71 -0
- package/src/controls/machines/radio-group.lino +17 -0
- package/src/controls/machines/select.lino +122 -0
- package/src/controls/machines/slider.lino +99 -0
- package/src/controls/machines/switch.lino +19 -0
- package/src/controls/machines/text-area.lino +26 -0
- package/src/controls/machines/text-field.lino +26 -0
- package/src/controls/number-field.js +239 -0
- package/src/controls/numeric-keys.js +125 -0
- package/src/controls/option.js +54 -0
- package/src/controls/progress.js +76 -0
- package/src/controls/radio-group.js +234 -0
- package/src/controls/select.js +229 -0
- package/src/controls/slider.js +234 -0
- package/src/controls/stories.js +172 -0
- package/src/controls/styles.css +1060 -0
- package/src/controls/switch.js +95 -0
- package/src/controls/text-area.js +39 -0
- package/src/controls/text-field.js +131 -0
- package/src/controls/vocabulary.js +164 -0
- package/src/data/data.css +95 -0
- package/src/data/index.d.ts +83 -0
- package/src/data/index.js +10 -0
- package/src/data/keyboard.js +189 -0
- package/src/data/list.js +215 -0
- package/src/data/render-data.js +116 -0
- package/src/data/selection-dom.js +39 -0
- package/src/data/selection-model.js +43 -0
- package/src/data/sort-model.js +42 -0
- package/src/data/source.js +45 -0
- package/src/data/table.js +160 -0
- package/src/data/tree-model.js +41 -0
- package/src/data/tree.js +55 -0
- package/src/data/viewport.js +216 -0
- package/src/data/virtual-range.js +92 -0
- package/src/data/vocabulary.js +67 -0
- package/src/diagrams/diagram-model.js +511 -0
- package/src/diagrams/diagram.js +204 -0
- package/src/diagrams/index.d.ts +225 -0
- package/src/diagrams/index.js +48 -0
- package/src/diagrams/layout-dagre.js +164 -0
- package/src/diagrams/layout-plugins.js +131 -0
- package/src/diagrams/mermaid-export.js +232 -0
- package/src/diagrams/mermaid-view.js +229 -0
- package/src/diagrams/svg-diagram.js +215 -0
- package/src/editor/code-editor.js +206 -0
- package/src/editor/documents-model.js +170 -0
- package/src/editor/documents-persistence.js +85 -0
- package/src/editor/editor-engine.js +22 -0
- package/src/editor/editor-ui.js +203 -0
- package/src/editor/editor.css +106 -0
- package/src/editor/engines/codemirror.js +227 -0
- package/src/editor/engines/monaco.js +219 -0
- package/src/editor/index.d.ts +111 -0
- package/src/editor/index.js +14 -0
- package/src/editor/lino-highlight.js +106 -0
- package/src/editor/lino-structure.js +85 -0
- package/src/editor/validate-lino.js +43 -0
- package/src/embed/README.md +161 -0
- package/src/embed/controller.js +223 -0
- package/src/embed/element.js +141 -0
- package/src/embed/index.d.ts +75 -0
- package/src/embed/index.js +9 -0
- package/src/embed/providers/telegram.d.ts +3 -0
- package/src/embed/providers/telegram.js +38 -0
- package/src/embed/providers/vk.d.ts +3 -0
- package/src/embed/providers/vk.js +42 -0
- package/src/embed/providers/x.d.ts +3 -0
- package/src/embed/providers/x.js +31 -0
- package/src/embed/registry.js +35 -0
- package/src/embed/script.js +73 -0
- package/src/embed/view.js +122 -0
- package/src/icons/adapters/lucide.d.ts +15 -0
- package/src/icons/adapters/lucide.js +142 -0
- package/src/icons/adapters/material-symbols.d.ts +13 -0
- package/src/icons/adapters/material-symbols.js +113 -0
- package/src/icons/adapters/shared.d.ts +38 -0
- package/src/icons/adapters/shared.js +157 -0
- package/src/icons/adapters/simple-icons.d.ts +9 -0
- package/src/icons/adapters/simple-icons.js +38 -0
- package/src/icons/adapters/tabler.d.ts +9 -0
- package/src/icons/adapters/tabler.js +86 -0
- package/src/icons/icon-registry.js +215 -0
- package/src/icons/icon.js +356 -0
- package/src/icons/index.d.ts +123 -0
- package/src/icons/index.js +30 -0
- package/src/icons/names.js +51 -0
- package/src/icons/own-icons.js +521 -0
- package/src/icons/presentation.js +55 -0
- package/src/icons/svg.js +136 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +40 -0
- package/src/layout/README.md +102 -0
- package/src/layout/app-shell.js +150 -0
- package/src/layout/catalog.lino +27 -0
- package/src/layout/dock-model.js +576 -0
- package/src/layout/dock-view.js +312 -0
- package/src/layout/dock.js +352 -0
- package/src/layout/dom.js +312 -0
- package/src/layout/grid.js +192 -0
- package/src/layout/index.d.ts +267 -0
- package/src/layout/index.js +60 -0
- package/src/layout/layer-manager.js +120 -0
- package/src/layout/layout.css +760 -0
- package/src/layout/menu.js +141 -0
- package/src/layout/nav-strip.js +174 -0
- package/src/layout/page-links.js +166 -0
- package/src/layout/panel.js +26 -0
- package/src/layout/pref-switches.js +209 -0
- package/src/layout/split-model.js +270 -0
- package/src/layout/split.js +430 -0
- package/src/layout/stack.js +86 -0
- package/src/layout/surfaces.js +119 -0
- package/src/layout/tab-group.js +151 -0
- package/src/layout/tab-strip.js +277 -0
- package/src/layout/vocabulary.js +229 -0
- package/src/layout/window-frame.js +222 -0
- package/src/layout/window.js +146 -0
- package/src/links-view/animator.js +144 -0
- package/src/links-view/configuration-classes.js +150 -0
- package/src/links-view/configuration-model.js +191 -0
- package/src/links-view/configuration-notations.js +230 -0
- package/src/links-view/configurations.d.ts +73 -0
- package/src/links-view/configurations.js +33 -0
- package/src/links-view/create-layout-runner.js +79 -0
- package/src/links-view/doublet-curves.js +239 -0
- package/src/links-view/doublet-layout.js +148 -0
- package/src/links-view/doublet-markers.js +109 -0
- package/src/links-view/doublet-options.js +369 -0
- package/src/links-view/doublet-svg.js +156 -0
- package/src/links-view/doublet.js +230 -0
- package/src/links-view/export.js +146 -0
- package/src/links-view/geometry.js +409 -0
- package/src/links-view/index.d.ts +1029 -0
- package/src/links-view/index.js +140 -0
- package/src/links-view/labels.js +28 -0
- package/src/links-view/layout-worker-entry.mjs +2 -0
- package/src/links-view/layout-worker.js +28 -0
- package/src/links-view/layouts/circle.js +7 -0
- package/src/links-view/layouts/force.js +76 -0
- package/src/links-view/layouts/grid.js +7 -0
- package/src/links-view/layouts/hex.js +8 -0
- package/src/links-view/layouts/index.js +15 -0
- package/src/links-view/layouts/layered.js +29 -0
- package/src/links-view/layouts/regular.js +27 -0
- package/src/links-view/layouts/spiral.js +10 -0
- package/src/links-view/link-view.js +494 -0
- package/src/links-view/links-gallery.js +306 -0
- package/src/links-view/links-network.js +496 -0
- package/src/links-view/lino-network-source.js +122 -0
- package/src/links-view/lino-network.js +233 -0
- package/src/links-view/lino-to-network.js +252 -0
- package/src/links-view/markers.js +192 -0
- package/src/links-view/model.js +233 -0
- package/src/links-view/network-editor/dom.js +36 -0
- package/src/links-view/network-editor/editor.js +202 -0
- package/src/links-view/network-editor/model.js +163 -0
- package/src/links-view/network-editor/options.js +265 -0
- package/src/links-view/network-editor/panels.js +423 -0
- package/src/links-view/network-editor/presets.js +76 -0
- package/src/links-view/network-editor/provider.js +93 -0
- package/src/links-view/network-editor/remap.js +45 -0
- package/src/links-view/network-editor/schema.js +224 -0
- package/src/links-view/network-editor/share.js +232 -0
- package/src/links-view/network-editor/styles.js +19 -0
- package/src/links-view/network-editor/url-sync.js +131 -0
- package/src/links-view/network-interaction.js +228 -0
- package/src/links-view/network-model.js +85 -0
- package/src/links-view/network-renderer.js +259 -0
- package/src/links-view/network-scene.js +245 -0
- package/src/links-view/network-source.js +82 -0
- package/src/links-view/network-vocabulary.js +18 -0
- package/src/links-view/presentation.js +199 -0
- package/src/links-view/render-canvas.js +102 -0
- package/src/links-view/render-svg.js +118 -0
- package/src/links-view/scene.js +233 -0
- package/src/links-view/solver-job.js +106 -0
- package/src/links-view/tokens.js +114 -0
- package/src/links-view/zoom-pan.js +203 -0
- package/src/overlays/catalog.lino +89 -0
- package/src/overlays/context-menu.js +110 -0
- package/src/overlays/dialog.js +117 -0
- package/src/overlays/dom.js +168 -0
- package/src/overlays/drawer.js +8 -0
- package/src/overlays/index.d.ts +80 -0
- package/src/overlays/index.js +25 -0
- package/src/overlays/kinds.lino +137 -0
- package/src/overlays/list-popover.js +129 -0
- package/src/overlays/machines/index.js +71 -0
- package/src/overlays/machines/surface.lino +11 -0
- package/src/overlays/machines/tabs.lino +7 -0
- package/src/overlays/machines/toast.lino +16 -0
- package/src/overlays/machines/tooltip.lino +29 -0
- package/src/overlays/menu.js +240 -0
- package/src/overlays/popover.js +194 -0
- package/src/overlays/position.js +84 -0
- package/src/overlays/radial-geometry.js +38 -0
- package/src/overlays/radial-menu.js +50 -0
- package/src/overlays/styles.css +155 -0
- package/src/overlays/tabs.js +125 -0
- package/src/overlays/toast-queue.js +105 -0
- package/src/overlays/toast.js +163 -0
- package/src/overlays/tooltip.js +110 -0
- package/src/overlays/vocabulary.js +3 -0
- package/src/settings/conditions.js +44 -0
- package/src/settings/control-for.js +62 -0
- package/src/settings/field-control.js +201 -0
- package/src/settings/index.d.ts +201 -0
- package/src/settings/index.js +3 -0
- package/src/settings/messages.js +112 -0
- package/src/settings/miniature.js +26 -0
- package/src/settings/panel-actions.js +234 -0
- package/src/settings/panel-model.js +49 -0
- package/src/settings/panel-refresh.js +56 -0
- package/src/settings/panel-rows.js +200 -0
- package/src/settings/preset-cards.js +43 -0
- package/src/settings/saved-looks.js +227 -0
- package/src/settings/section-layout.js +95 -0
- package/src/settings/section-tabs.js +175 -0
- package/src/settings/settings-panel.js +192 -0
- package/src/settings/settings.css +178 -0
- package/stories/accordion.lino +14 -0
- package/stories/alert-dialog.lino +4 -0
- package/stories/app-bar.lino +10 -0
- package/stories/avatar.lino +7 -0
- package/stories/badge.lino +12 -0
- package/stories/button.lino +17 -0
- package/stories/card.lino +10 -0
- package/stories/checkbox.lino +14 -0
- package/stories/chip.lino +19 -0
- package/stories/color-field.lino +9 -0
- package/stories/combobox.lino +10 -0
- package/stories/container.lino +11 -0
- package/stories/context-menu.lino +15 -0
- package/stories/dialog.lino +16 -0
- package/stories/drawer.lino +12 -0
- package/stories/icon-button.lino +13 -0
- package/stories/label.lino +7 -0
- package/stories/link-cards.lino +9 -0
- package/stories/link.lino +9 -0
- package/stories/menu-item.lino +6 -0
- package/stories/menu-separator.lino +7 -0
- package/stories/menu.lino +30 -0
- package/stories/nav-strip.lino +11 -0
- package/stories/number-field.lino +16 -0
- package/stories/option.lino +10 -0
- package/stories/paper.lino +11 -0
- package/stories/popover.lino +4 -0
- package/stories/pref-switches.lino +4 -0
- package/stories/progress.lino +14 -0
- package/stories/radial-menu.lino +19 -0
- package/stories/radio-group.lino +22 -0
- package/stories/radio.lino +10 -0
- package/stories/section-nav.lino +9 -0
- package/stories/select.lino +16 -0
- package/stories/slider.lino +14 -0
- package/stories/switch.lino +10 -0
- package/stories/tab-panel.lino +7 -0
- package/stories/tab.lino +7 -0
- package/stories/tabs.lino +25 -0
- package/stories/text-area.lino +12 -0
- package/stories/text-field.lino +23 -0
- package/stories/titled-section.lino +7 -0
- package/stories/toast.lino +3 -0
- package/stories/toaster.lino +2 -0
- package/stories/tooltip.lino +3 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
|
|
3
|
+
import type { Link } from 'links-notation';
|
|
4
|
+
|
|
5
|
+
export type DiagramKind = 'flowchart' | 'sequence' | 'state' | 'class';
|
|
6
|
+
export type DiagramDirection = 'down' | 'up' | 'right' | 'left';
|
|
7
|
+
export type NodeShape =
|
|
8
|
+
| 'box'
|
|
9
|
+
| 'round'
|
|
10
|
+
| 'stadium'
|
|
11
|
+
| 'circle'
|
|
12
|
+
| 'diamond'
|
|
13
|
+
| 'start'
|
|
14
|
+
| 'end';
|
|
15
|
+
export type DiagramRenderer = 'svg' | 'mermaid';
|
|
16
|
+
|
|
17
|
+
export interface DiagramNode {
|
|
18
|
+
id: string;
|
|
19
|
+
/** The text shown (defaults to the id). */
|
|
20
|
+
label: string;
|
|
21
|
+
shape: NodeShape;
|
|
22
|
+
/** The id of the group the node is in. */
|
|
23
|
+
group: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DiagramEdge {
|
|
27
|
+
/** Given, or `edge-N` (N counts the edges from 1). */
|
|
28
|
+
id: string;
|
|
29
|
+
from: string;
|
|
30
|
+
to: string;
|
|
31
|
+
label: string | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface DiagramGroup {
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
/** The id of the enclosing group. */
|
|
38
|
+
group: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface DiagramModel {
|
|
42
|
+
id: string;
|
|
43
|
+
kind: DiagramKind;
|
|
44
|
+
direction: DiagramDirection;
|
|
45
|
+
/** An accessible title (optional). */
|
|
46
|
+
label: string | null;
|
|
47
|
+
/** `null`: the default renderer of the kind. */
|
|
48
|
+
renderer: DiagramRenderer | null;
|
|
49
|
+
/** A registered layout name (`null`: dagre). */
|
|
50
|
+
layout: string | null;
|
|
51
|
+
nodes: DiagramNode[];
|
|
52
|
+
edges: DiagramEdge[];
|
|
53
|
+
groups: DiagramGroup[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const DIAGRAM_KINDS: readonly DiagramKind[];
|
|
57
|
+
export const DIAGRAM_DIRECTIONS: readonly DiagramDirection[];
|
|
58
|
+
export const NODE_SHAPES: readonly NodeShape[];
|
|
59
|
+
export const DIAGRAM_RENDERERS: readonly DiagramRenderer[];
|
|
60
|
+
|
|
61
|
+
export type DiagramErrorCode =
|
|
62
|
+
| 'no-diagram'
|
|
63
|
+
| 'unknown-node'
|
|
64
|
+
| 'unknown-group'
|
|
65
|
+
| 'duplicate-id'
|
|
66
|
+
| 'invalid-value'
|
|
67
|
+
| 'unknown-property'
|
|
68
|
+
| 'missing-value';
|
|
69
|
+
|
|
70
|
+
/** Where an error is: the diagram, the index path of the link, its text. */
|
|
71
|
+
export interface DiagramErrorPosition {
|
|
72
|
+
diagram: string | null;
|
|
73
|
+
/** `[index of the diagram link in the document, index of the child]`. */
|
|
74
|
+
path: number[];
|
|
75
|
+
link: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class DiagramError extends Error {
|
|
79
|
+
constructor(
|
|
80
|
+
code: DiagramErrorCode,
|
|
81
|
+
message: string,
|
|
82
|
+
at: DiagramErrorPosition
|
|
83
|
+
);
|
|
84
|
+
readonly code: DiagramErrorCode;
|
|
85
|
+
readonly at: DiagramErrorPosition;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function foldLink(link: Link): Link;
|
|
89
|
+
export function diagramsFromLinks(links: Link[]): DiagramModel[];
|
|
90
|
+
export function diagramFromLinks(links: Link[]): DiagramModel;
|
|
91
|
+
export function parseDiagram(text: string): DiagramModel;
|
|
92
|
+
export function diagramToLino(model: DiagramModel): string;
|
|
93
|
+
export function describeDiagram(model: DiagramModel): {
|
|
94
|
+
nodes: string[];
|
|
95
|
+
edges: string[];
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export interface Size {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** `x`, `y`: the centre of the box. */
|
|
104
|
+
export interface Box extends Size {
|
|
105
|
+
id: string;
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface Point {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface EdgeLayout {
|
|
116
|
+
id: string;
|
|
117
|
+
/** From the source border to the target border. */
|
|
118
|
+
points: Point[];
|
|
119
|
+
/** The centre of the label. */
|
|
120
|
+
labelAt: Point | null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface Layout {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
nodes: Box[];
|
|
127
|
+
edges: EdgeLayout[];
|
|
128
|
+
groups: Box[];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface LayoutOptions {
|
|
132
|
+
nodeSize?: Size | ((node: DiagramNode) => Size);
|
|
133
|
+
rankSep?: number;
|
|
134
|
+
nodeSep?: number;
|
|
135
|
+
margin?: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type LayoutEngine = (
|
|
139
|
+
model: DiagramModel,
|
|
140
|
+
options: Record<string, unknown>
|
|
141
|
+
) => Layout | Promise<Layout>;
|
|
142
|
+
|
|
143
|
+
export function estimateNodeSize(
|
|
144
|
+
node: Pick<DiagramNode, 'label' | 'shape'>
|
|
145
|
+
): Size;
|
|
146
|
+
export function edgeLabelSize(label: string | null): Size;
|
|
147
|
+
export function layoutDiagram(
|
|
148
|
+
model: DiagramModel,
|
|
149
|
+
options?: LayoutOptions
|
|
150
|
+
): Layout;
|
|
151
|
+
|
|
152
|
+
export const DEFAULT_LAYOUT: 'dagre';
|
|
153
|
+
export function registerLayout(name: string, engine: LayoutEngine): void;
|
|
154
|
+
export function unregisterLayout(name: string): boolean;
|
|
155
|
+
export function registeredLayouts(): string[];
|
|
156
|
+
export function runLayout(
|
|
157
|
+
model: DiagramModel,
|
|
158
|
+
options?: Record<string, unknown>,
|
|
159
|
+
name?: string
|
|
160
|
+
): Promise<Layout>;
|
|
161
|
+
|
|
162
|
+
export interface DiagramTokens {
|
|
163
|
+
surface?: string;
|
|
164
|
+
onSurface?: string;
|
|
165
|
+
edge?: string;
|
|
166
|
+
group?: string;
|
|
167
|
+
groupOutline?: string;
|
|
168
|
+
accent?: string;
|
|
169
|
+
fontFamily?: string;
|
|
170
|
+
/** In px. */
|
|
171
|
+
fontSize?: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const DEFAULT_DIAGRAM_TOKENS: Readonly<Required<DiagramTokens>>;
|
|
175
|
+
export const SVG_KINDS: readonly DiagramKind[];
|
|
176
|
+
export function escapeXml(text: string): string;
|
|
177
|
+
export function diagramSummary(model: DiagramModel): string;
|
|
178
|
+
export function renderDiagramSvg(
|
|
179
|
+
model: DiagramModel,
|
|
180
|
+
layout: Layout,
|
|
181
|
+
tokens?: DiagramTokens & { idPrefix?: string }
|
|
182
|
+
): string;
|
|
183
|
+
|
|
184
|
+
export function escapeMermaidLabel(text: string): string;
|
|
185
|
+
export function toMermaid(model: DiagramModel): string;
|
|
186
|
+
|
|
187
|
+
export interface MermaidApi {
|
|
188
|
+
initialize(config: object): void;
|
|
189
|
+
render(id: string, text: string): Promise<{ svg: string }>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const MERMAID_CONFIG: Readonly<{
|
|
193
|
+
startOnLoad: false;
|
|
194
|
+
securityLevel: 'strict';
|
|
195
|
+
}>;
|
|
196
|
+
export function setMermaidImporter(
|
|
197
|
+
importer: (() => Promise<unknown>) | null
|
|
198
|
+
): void;
|
|
199
|
+
export function loadMermaid(): Promise<MermaidApi>;
|
|
200
|
+
export function renderMermaid(source: string): Promise<string>;
|
|
201
|
+
|
|
202
|
+
export type DiagramState = 'loading' | 'ready' | 'error';
|
|
203
|
+
|
|
204
|
+
/** `<ui-mermaid-view>`: Mermaid text drawn by the lazily loaded Mermaid. */
|
|
205
|
+
export interface MermaidViewElement extends HTMLElement {
|
|
206
|
+
source: string;
|
|
207
|
+
readonly label: string;
|
|
208
|
+
refresh(): Promise<DiagramState>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** `<ui-diagram>`: a diagram written in Links Notation. */
|
|
212
|
+
export interface DiagramElement extends HTMLElement {
|
|
213
|
+
source: string;
|
|
214
|
+
layoutOptions: LayoutOptions & Record<string, unknown>;
|
|
215
|
+
tokens: DiagramTokens;
|
|
216
|
+
readonly model: DiagramModel | null;
|
|
217
|
+
refresh(): Promise<DiagramState>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function defineMermaidView(win?: Window): CustomElementConstructor;
|
|
221
|
+
export function defineDiagram(win?: Window): CustomElementConstructor;
|
|
222
|
+
export function pickRenderer(
|
|
223
|
+
model: DiagramModel,
|
|
224
|
+
override?: string | null
|
|
225
|
+
): DiagramRenderer;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagrams written in Links Notation: the pure model (`diagramFromLinks`,
|
|
3
|
+
* `diagramToLino`), the Dagre layout and layout plugins, our SVG renderer,
|
|
4
|
+
* Mermaid export, and the `<ui-diagram>` and `<ui-mermaid-view>` elements.
|
|
5
|
+
* See README.md.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
DIAGRAM_DIRECTIONS,
|
|
10
|
+
DIAGRAM_KINDS,
|
|
11
|
+
DIAGRAM_RENDERERS,
|
|
12
|
+
DiagramError,
|
|
13
|
+
NODE_SHAPES,
|
|
14
|
+
describeDiagram,
|
|
15
|
+
diagramFromLinks,
|
|
16
|
+
diagramToLino,
|
|
17
|
+
diagramsFromLinks,
|
|
18
|
+
foldLink,
|
|
19
|
+
parseDiagram,
|
|
20
|
+
} from './diagram-model.js';
|
|
21
|
+
export {
|
|
22
|
+
edgeLabelSize,
|
|
23
|
+
estimateNodeSize,
|
|
24
|
+
layoutDiagram,
|
|
25
|
+
} from './layout-dagre.js';
|
|
26
|
+
export {
|
|
27
|
+
DEFAULT_LAYOUT,
|
|
28
|
+
registerLayout,
|
|
29
|
+
registeredLayouts,
|
|
30
|
+
runLayout,
|
|
31
|
+
unregisterLayout,
|
|
32
|
+
} from './layout-plugins.js';
|
|
33
|
+
export {
|
|
34
|
+
DEFAULT_DIAGRAM_TOKENS,
|
|
35
|
+
SVG_KINDS,
|
|
36
|
+
diagramSummary,
|
|
37
|
+
escapeXml,
|
|
38
|
+
renderDiagramSvg,
|
|
39
|
+
} from './svg-diagram.js';
|
|
40
|
+
export { escapeMermaidLabel, toMermaid } from './mermaid-export.js';
|
|
41
|
+
export {
|
|
42
|
+
MERMAID_CONFIG,
|
|
43
|
+
defineMermaidView,
|
|
44
|
+
loadMermaid,
|
|
45
|
+
renderMermaid,
|
|
46
|
+
setMermaidImporter,
|
|
47
|
+
} from './mermaid-view.js';
|
|
48
|
+
export { defineDiagram, pickRenderer } from './diagram.js';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default layered layout of a diagram, computed by Dagre
|
|
3
|
+
* (`@dagrejs/dagre`, MIT). Deterministic: the same model and options give the
|
|
4
|
+
* same coordinates, rounded to 1/100 px.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import dagre from '@dagrejs/dagre';
|
|
8
|
+
|
|
9
|
+
/** @typedef {import('./diagram-model.js').DiagramModel} DiagramModel */
|
|
10
|
+
/** @typedef {import('./diagram-model.js').DiagramNode} DiagramNode */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} Size
|
|
14
|
+
* @property {number} width
|
|
15
|
+
* @property {number} height
|
|
16
|
+
*
|
|
17
|
+
* @typedef {object} Box `x`, `y`: the centre of the box
|
|
18
|
+
* @property {string} id
|
|
19
|
+
* @property {number} x
|
|
20
|
+
* @property {number} y
|
|
21
|
+
* @property {number} width
|
|
22
|
+
* @property {number} height
|
|
23
|
+
*
|
|
24
|
+
* @typedef {object} EdgeLayout
|
|
25
|
+
* @property {string} id
|
|
26
|
+
* @property {{x: number, y: number}[]} points from the source border to the
|
|
27
|
+
* target border
|
|
28
|
+
* @property {{x: number, y: number}|null} labelAt the centre of the label
|
|
29
|
+
*
|
|
30
|
+
* @typedef {object} Layout the result of every layout engine
|
|
31
|
+
* @property {number} width of the whole drawing
|
|
32
|
+
* @property {number} height
|
|
33
|
+
* @property {Box[]} nodes in the order of `model.nodes`
|
|
34
|
+
* @property {EdgeLayout[]} edges in the order of `model.edges`
|
|
35
|
+
* @property {Box[]} groups in the order of `model.groups`
|
|
36
|
+
*
|
|
37
|
+
* @typedef {object} LayoutOptions
|
|
38
|
+
* @property {Size|((node: DiagramNode) => Size)} [nodeSize] default: from
|
|
39
|
+
* the label length (`estimateNodeSize`)
|
|
40
|
+
* @property {number} [rankSep] space between ranks (default 56)
|
|
41
|
+
* @property {number} [nodeSep] space between nodes of a rank (default 40)
|
|
42
|
+
* @property {number} [margin] around the drawing (default 16)
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const RANKDIR = Object.freeze({
|
|
46
|
+
down: 'TB',
|
|
47
|
+
up: 'BT',
|
|
48
|
+
right: 'LR',
|
|
49
|
+
left: 'RL',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/** Average glyph width of the default 14 px sans-serif font. */
|
|
53
|
+
export const CHAR_WIDTH = 8;
|
|
54
|
+
export const LINE_HEIGHT = 20;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The default size of a node: wide enough for its label in a 14 px font.
|
|
58
|
+
* @param {DiagramNode} node
|
|
59
|
+
* @returns {Size}
|
|
60
|
+
*/
|
|
61
|
+
export function estimateNodeSize(node) {
|
|
62
|
+
if (node.shape === 'start' || node.shape === 'end') {
|
|
63
|
+
return { width: 24, height: 24 };
|
|
64
|
+
}
|
|
65
|
+
const text = node.label.length * CHAR_WIDTH;
|
|
66
|
+
const width = Math.max(72, text + 32);
|
|
67
|
+
if (node.shape === 'diamond') {
|
|
68
|
+
return { width: Math.round(width * 1.5), height: 72 };
|
|
69
|
+
}
|
|
70
|
+
if (node.shape === 'circle') {
|
|
71
|
+
const side = Math.max(width, 56);
|
|
72
|
+
return { width: side, height: side };
|
|
73
|
+
}
|
|
74
|
+
return { width, height: 40 };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The size of an edge label, as given to Dagre so labels get room.
|
|
79
|
+
* @param {string|null} label
|
|
80
|
+
* @returns {Size}
|
|
81
|
+
*/
|
|
82
|
+
export function edgeLabelSize(label) {
|
|
83
|
+
return label === null
|
|
84
|
+
? { width: 0, height: 0 }
|
|
85
|
+
: { width: label.length * 7 + 8, height: LINE_HEIGHT };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
89
|
+
const box = (id, value) => ({
|
|
90
|
+
id,
|
|
91
|
+
x: round(value.x),
|
|
92
|
+
y: round(value.y),
|
|
93
|
+
width: round(value.width),
|
|
94
|
+
height: round(value.height),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function sizeOf(node, nodeSize) {
|
|
98
|
+
if (typeof nodeSize === 'function') {
|
|
99
|
+
return nodeSize(node);
|
|
100
|
+
}
|
|
101
|
+
return nodeSize ?? estimateNodeSize(node);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Lay a diagram out with Dagre.
|
|
106
|
+
* @param {DiagramModel} model
|
|
107
|
+
* @param {LayoutOptions} [options]
|
|
108
|
+
* @returns {Layout}
|
|
109
|
+
*/
|
|
110
|
+
export function layoutDiagram(model, options = {}) {
|
|
111
|
+
const margin = options.margin ?? 16;
|
|
112
|
+
const graph = new dagre.graphlib.Graph({ compound: true, multigraph: true });
|
|
113
|
+
graph.setGraph({
|
|
114
|
+
rankdir: RANKDIR[model.direction] ?? 'TB',
|
|
115
|
+
ranksep: options.rankSep ?? 56,
|
|
116
|
+
nodesep: options.nodeSep ?? 40,
|
|
117
|
+
edgesep: 16,
|
|
118
|
+
marginx: margin,
|
|
119
|
+
marginy: margin,
|
|
120
|
+
});
|
|
121
|
+
graph.setDefaultEdgeLabel(() => ({}));
|
|
122
|
+
for (const group of model.groups) {
|
|
123
|
+
graph.setNode(group.id, {
|
|
124
|
+
label: group.label,
|
|
125
|
+
paddingTop: LINE_HEIGHT + 8,
|
|
126
|
+
width: group.label.length * CHAR_WIDTH + 24,
|
|
127
|
+
height: LINE_HEIGHT + 16,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
for (const node of model.nodes) {
|
|
131
|
+
const { width, height } = sizeOf(node, options.nodeSize);
|
|
132
|
+
graph.setNode(node.id, { width, height });
|
|
133
|
+
}
|
|
134
|
+
for (const item of [...model.groups, ...model.nodes]) {
|
|
135
|
+
if (item.group !== null) {
|
|
136
|
+
graph.setParent(item.id, item.group);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const edge of model.edges) {
|
|
140
|
+
graph.setEdge(
|
|
141
|
+
edge.from,
|
|
142
|
+
edge.to,
|
|
143
|
+
{ ...edgeLabelSize(edge.label), labelpos: 'c' },
|
|
144
|
+
edge.id
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
dagre.layout(graph);
|
|
148
|
+
const size = graph.graph();
|
|
149
|
+
return {
|
|
150
|
+
width: round(size.width),
|
|
151
|
+
height: round(size.height),
|
|
152
|
+
nodes: model.nodes.map((node) => box(node.id, graph.node(node.id))),
|
|
153
|
+
edges: model.edges.map((edge) => {
|
|
154
|
+
const value = graph.edge(edge.from, edge.to, edge.id);
|
|
155
|
+
return {
|
|
156
|
+
id: edge.id,
|
|
157
|
+
points: value.points.map((p) => ({ x: round(p.x), y: round(p.y) })),
|
|
158
|
+
labelAt:
|
|
159
|
+
edge.label === null ? null : { x: round(value.x), y: round(value.y) },
|
|
160
|
+
};
|
|
161
|
+
}),
|
|
162
|
+
groups: model.groups.map((group) => box(group.id, graph.node(group.id))),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout plugins: an app registers another layout engine (ELK.js, Graphviz
|
|
3
|
+
* through `@hpcc-js/wasm-graphviz`, …) under a name and a diagram picks it
|
|
4
|
+
* with `(layout NAME)`. This package ships only `dagre`; EPL-licensed
|
|
5
|
+
* engines stay in the app. A plugin wrapping ELK.js in the app:
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* import ELK from 'elkjs/lib/elk.bundled.js'; // EPL-2.0: the app's choice
|
|
9
|
+
* import { registerLayout, estimateNodeSize } from '@link-foundation/ui-components/diagrams';
|
|
10
|
+
*
|
|
11
|
+
* const elk = new ELK();
|
|
12
|
+
* registerLayout('elk', async (model) => {
|
|
13
|
+
* const sizes = new Map(model.nodes.map((n) => [n.id, estimateNodeSize(n)]));
|
|
14
|
+
* const graph = await elk.layout({
|
|
15
|
+
* id: model.id,
|
|
16
|
+
* layoutOptions: { 'elk.algorithm': 'layered', 'elk.direction': 'DOWN' },
|
|
17
|
+
* children: model.nodes.map((n) => ({ id: n.id, ...sizes.get(n.id) })),
|
|
18
|
+
* edges: model.edges.map((e) => ({ id: e.id, sources: [e.from], targets: [e.to] })),
|
|
19
|
+
* });
|
|
20
|
+
* const at = new Map(graph.children.map((c) => [c.id, c]));
|
|
21
|
+
* return {
|
|
22
|
+
* width: graph.width,
|
|
23
|
+
* height: graph.height,
|
|
24
|
+
* // Layout boxes use the centre, ELK the top-left corner.
|
|
25
|
+
* nodes: model.nodes.map((n) => {
|
|
26
|
+
* const c = at.get(n.id);
|
|
27
|
+
* return { id: n.id, x: c.x + c.width / 2, y: c.y + c.height / 2, width: c.width, height: c.height };
|
|
28
|
+
* }),
|
|
29
|
+
* edges: graph.edges.map((e) => {
|
|
30
|
+
* const s = e.sections[0];
|
|
31
|
+
* return { id: e.id, points: [s.startPoint, ...(s.bendPoints ?? []), s.endPoint], labelAt: null };
|
|
32
|
+
* }),
|
|
33
|
+
* groups: [],
|
|
34
|
+
* };
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
import { layoutDiagram } from './layout-dagre.js';
|
|
40
|
+
|
|
41
|
+
/** @typedef {import('./diagram-model.js').DiagramModel} DiagramModel */
|
|
42
|
+
/** @typedef {import('./layout-dagre.js').Layout} Layout */
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {(model: DiagramModel, options: object) => Layout|Promise<Layout>}
|
|
45
|
+
* LayoutEngine
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
export const DEFAULT_LAYOUT = 'dagre';
|
|
49
|
+
|
|
50
|
+
/** @type {Map<string, LayoutEngine>} */
|
|
51
|
+
const engines = new Map([[DEFAULT_LAYOUT, layoutDiagram]]);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Register (or replace) a layout engine.
|
|
55
|
+
* @param {string} name
|
|
56
|
+
* @param {LayoutEngine} engine
|
|
57
|
+
*/
|
|
58
|
+
export function registerLayout(name, engine) {
|
|
59
|
+
if (typeof name !== 'string' || name === '') {
|
|
60
|
+
throw new TypeError('registerLayout: the name must be a non-empty string');
|
|
61
|
+
}
|
|
62
|
+
if (typeof engine !== 'function') {
|
|
63
|
+
throw new TypeError(
|
|
64
|
+
`registerLayout(${name}): the engine must be a function`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
engines.set(name, engine);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Remove a registered engine (`dagre` cannot be removed).
|
|
72
|
+
* @param {string} name
|
|
73
|
+
* @returns {boolean} whether an engine was removed
|
|
74
|
+
*/
|
|
75
|
+
export function unregisterLayout(name) {
|
|
76
|
+
return name !== DEFAULT_LAYOUT && engines.delete(name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @returns {string[]} the registered engine names, sorted */
|
|
80
|
+
export function registeredLayouts() {
|
|
81
|
+
return [...engines.keys()].sort();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const isNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
85
|
+
|
|
86
|
+
/** Throw a TypeError when a plugin returns a malformed layout. */
|
|
87
|
+
function checkLayout(name, model, layout) {
|
|
88
|
+
const fail = (what) => {
|
|
89
|
+
throw new TypeError(`layout "${name}" returned ${what}`);
|
|
90
|
+
};
|
|
91
|
+
if (!layout || !isNumber(layout.width) || !isNumber(layout.height)) {
|
|
92
|
+
fail('no width and height');
|
|
93
|
+
}
|
|
94
|
+
const boxes = new Map((layout.nodes ?? []).map((b) => [b.id, b]));
|
|
95
|
+
for (const node of model.nodes) {
|
|
96
|
+
const b = boxes.get(node.id);
|
|
97
|
+
if (!b || ![b.x, b.y, b.width, b.height].every(isNumber)) {
|
|
98
|
+
fail(`no box for node "${node.id}"`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const edge of layout.edges ?? []) {
|
|
102
|
+
if (!Array.isArray(edge.points) || edge.points.length < 2) {
|
|
103
|
+
fail(`fewer than two points for edge "${edge.id}"`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return layout;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Lay a diagram out with a registered engine (`model.layout`, else `name`,
|
|
111
|
+
* else `dagre`). The result is checked and has an entry per node.
|
|
112
|
+
* @param {DiagramModel} model
|
|
113
|
+
* @param {object} [options] passed to the engine
|
|
114
|
+
* @param {string} [name]
|
|
115
|
+
* @returns {Promise<Layout>}
|
|
116
|
+
*/
|
|
117
|
+
export async function runLayout(model, options = {}, name = undefined) {
|
|
118
|
+
const engineName = name ?? model.layout ?? DEFAULT_LAYOUT;
|
|
119
|
+
const engine = engines.get(engineName);
|
|
120
|
+
if (!engine) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`unknown layout "${engineName}" (registered: ${registeredLayouts().join(', ')})`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const layout = await engine(model, options);
|
|
126
|
+
return checkLayout(engineName, model, {
|
|
127
|
+
edges: [],
|
|
128
|
+
groups: [],
|
|
129
|
+
...layout,
|
|
130
|
+
});
|
|
131
|
+
}
|