@link-foundation/ui-components 0.0.0-stage → 0.1.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,1029 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
|
|
3
|
+
import type { RawValue } from '@link-foundation/ui-core';
|
|
4
|
+
import type { KindSpec } from '@link-foundation/ui-dom';
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------- geometry
|
|
7
|
+
|
|
8
|
+
export interface LinkPoint {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** One cubic Bézier segment of a link path. */
|
|
14
|
+
export interface CubicSegment {
|
|
15
|
+
p0: LinkPoint;
|
|
16
|
+
c1: LinkPoint;
|
|
17
|
+
c2: LinkPoint;
|
|
18
|
+
p3: LinkPoint;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Bounds {
|
|
22
|
+
minX: number;
|
|
23
|
+
minY: number;
|
|
24
|
+
maxX: number;
|
|
25
|
+
maxY: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface LinkGeometry {
|
|
29
|
+
/** The link from the source to the target. */
|
|
30
|
+
path: CubicSegment[];
|
|
31
|
+
/** The point at half the arc length (the anchor). */
|
|
32
|
+
center: LinkPoint;
|
|
33
|
+
/** The arc length of the path. */
|
|
34
|
+
length: number;
|
|
35
|
+
/** The control points the spline passes through. */
|
|
36
|
+
points: LinkPoint[];
|
|
37
|
+
source: LinkPoint;
|
|
38
|
+
target: LinkPoint;
|
|
39
|
+
selfLoop: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface LinkGeometryOptions {
|
|
43
|
+
source: LinkPoint;
|
|
44
|
+
/** Without a target the link is a self-loop at the source. */
|
|
45
|
+
target?: LinkPoint;
|
|
46
|
+
/** How far the middle bends off the line, as a fraction of its length. */
|
|
47
|
+
bend?: number;
|
|
48
|
+
selfLoop?: boolean;
|
|
49
|
+
loopRadius?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The number of control points of a link (links-visuals). */
|
|
53
|
+
export const POINT_COUNT: 9;
|
|
54
|
+
export const DEFAULT_LOOP_RADIUS: number;
|
|
55
|
+
|
|
56
|
+
export function linkGeometry(options: LinkGeometryOptions): LinkGeometry;
|
|
57
|
+
/** The point at a fraction `t` (0…1) of the arc length. */
|
|
58
|
+
export function pointAtLength(
|
|
59
|
+
path: readonly CubicSegment[],
|
|
60
|
+
t: number
|
|
61
|
+
): LinkPoint;
|
|
62
|
+
/** The direction (radians) at a fraction `t` of the arc length. */
|
|
63
|
+
export function angleAtLength(path: readonly CubicSegment[], t: number): number;
|
|
64
|
+
/** The direction of travel at the start and at the end (radians). */
|
|
65
|
+
export function endAngles(path: readonly CubicSegment[]): {
|
|
66
|
+
start: number;
|
|
67
|
+
end: number;
|
|
68
|
+
};
|
|
69
|
+
export function cubicPoint(s: CubicSegment, t: number): LinkPoint;
|
|
70
|
+
export function cubicDerivative(s: CubicSegment, t: number): LinkPoint;
|
|
71
|
+
export function segmentLength(s: CubicSegment, t?: number): number;
|
|
72
|
+
export function pathLength(path: readonly CubicSegment[]): number;
|
|
73
|
+
export function catmullRomTangents(points: readonly LinkPoint[]): LinkPoint[];
|
|
74
|
+
export function catmullRomToCubics(
|
|
75
|
+
points: readonly LinkPoint[]
|
|
76
|
+
): CubicSegment[];
|
|
77
|
+
export function controlPoints(
|
|
78
|
+
source: LinkPoint,
|
|
79
|
+
target: LinkPoint,
|
|
80
|
+
bend?: number
|
|
81
|
+
): LinkPoint[];
|
|
82
|
+
export function selfLoopPoints(anchor: LinkPoint, radius?: number): LinkPoint[];
|
|
83
|
+
export function pathBounds(path: readonly CubicSegment[]): Bounds;
|
|
84
|
+
export function pathToSvgD(path: readonly CubicSegment[]): string;
|
|
85
|
+
|
|
86
|
+
// ----------------------------------------------------------------- markers
|
|
87
|
+
|
|
88
|
+
export type MarkerShape = 'bar' | 'arrow' | 'cross' | 'dot' | 'none';
|
|
89
|
+
export type LinkEnd = 'source' | 'target';
|
|
90
|
+
|
|
91
|
+
/** A marker shape as data, shared by the SVG and the Canvas renderer. */
|
|
92
|
+
export interface Marker {
|
|
93
|
+
readonly id: MarkerShape;
|
|
94
|
+
/** Always `0 0 100 100`. */
|
|
95
|
+
readonly viewBox: string;
|
|
96
|
+
/** SVG path data in the box (empty for `none`). */
|
|
97
|
+
readonly path: string;
|
|
98
|
+
readonly refX: number;
|
|
99
|
+
readonly refY: number;
|
|
100
|
+
readonly paint: 'stroke' | 'fill';
|
|
101
|
+
/** In box units (one line width). */
|
|
102
|
+
readonly strokeWidth: number;
|
|
103
|
+
/** How the end is announced. */
|
|
104
|
+
readonly label: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const MARKERS: Readonly<Record<MarkerShape, Readonly<Marker>>>;
|
|
108
|
+
export const MARKER_IDS: readonly MarkerShape[];
|
|
109
|
+
export const MARKER_BOX: 100;
|
|
110
|
+
export const DEFAULT_ENDS: Readonly<{ source: 'bar'; target: 'arrow' }>;
|
|
111
|
+
|
|
112
|
+
export function getMarker(id: string): Readonly<Marker> | undefined;
|
|
113
|
+
export function markerElementId(
|
|
114
|
+
prefix: string,
|
|
115
|
+
end: LinkEnd,
|
|
116
|
+
shape: string
|
|
117
|
+
): string;
|
|
118
|
+
/** `<marker>` elements for the two ends (no `<defs>` around them). */
|
|
119
|
+
export function svgMarkerDefs(
|
|
120
|
+
ends: Partial<Record<LinkEnd, string>>,
|
|
121
|
+
colors: Readonly<Record<string, string>>,
|
|
122
|
+
options?: { idPrefix?: string }
|
|
123
|
+
): string;
|
|
124
|
+
/** Draw a marker on a canvas; whether anything was drawn. */
|
|
125
|
+
export function drawMarker(
|
|
126
|
+
ctx: CanvasRenderingContext2D,
|
|
127
|
+
marker: Readonly<Marker>,
|
|
128
|
+
at: LinkPoint,
|
|
129
|
+
angle: number,
|
|
130
|
+
scale: number,
|
|
131
|
+
options?: { color?: string; Path2D?: typeof Path2D }
|
|
132
|
+
): boolean;
|
|
133
|
+
|
|
134
|
+
// ------------------------------------------------------------------ tokens
|
|
135
|
+
|
|
136
|
+
export type ColorRole =
|
|
137
|
+
| 'background'
|
|
138
|
+
| 'line'
|
|
139
|
+
| 'source'
|
|
140
|
+
| 'target'
|
|
141
|
+
| 'gridMinor'
|
|
142
|
+
| 'gridMajor'
|
|
143
|
+
| 'blueprintStart'
|
|
144
|
+
| 'blueprintEnd'
|
|
145
|
+
| 'blueprintCenter'
|
|
146
|
+
| 'blueprintPoint'
|
|
147
|
+
| 'blueprintGuide'
|
|
148
|
+
| 'focus';
|
|
149
|
+
|
|
150
|
+
export type LinkColors = Readonly<Record<ColorRole, string>>;
|
|
151
|
+
|
|
152
|
+
/** The ui-tokens Links Notation of the `link-view` theme (light and dark). */
|
|
153
|
+
export const LINK_TOKENS: string;
|
|
154
|
+
export const COLOR_TOKENS: Readonly<Record<ColorRole, string>>;
|
|
155
|
+
export function linkColors(options?: {
|
|
156
|
+
mode?: 'light' | 'dark' | null;
|
|
157
|
+
tokens?: string;
|
|
158
|
+
}): LinkColors;
|
|
159
|
+
export function colorVariables(
|
|
160
|
+
prefix?: string
|
|
161
|
+
): Readonly<Record<ColorRole, string>>;
|
|
162
|
+
|
|
163
|
+
// ------------------------------------------------------------------- scene
|
|
164
|
+
|
|
165
|
+
/** `screen = world · k + (x, y)`. */
|
|
166
|
+
export interface View {
|
|
167
|
+
x: number;
|
|
168
|
+
y: number;
|
|
169
|
+
k: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface Segment {
|
|
173
|
+
x1: number;
|
|
174
|
+
y1: number;
|
|
175
|
+
x2: number;
|
|
176
|
+
y2: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface LinkStyle {
|
|
180
|
+
/** In CSS pixels. */
|
|
181
|
+
width: number;
|
|
182
|
+
height: number;
|
|
183
|
+
view?: View;
|
|
184
|
+
colors: LinkColors | Readonly<Record<string, string>>;
|
|
185
|
+
ends?: Partial<Record<LinkEnd, string>>;
|
|
186
|
+
blueprint?: boolean;
|
|
187
|
+
grid?: boolean;
|
|
188
|
+
gridSpacing?: number;
|
|
189
|
+
/** World units (default from the grid step). */
|
|
190
|
+
lineWidth?: number;
|
|
191
|
+
/** Makes the SVG marker ids unique on a page. */
|
|
192
|
+
idPrefix?: string;
|
|
193
|
+
/** Canvas pixels per CSS pixel. */
|
|
194
|
+
pixelRatio?: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface SceneEnd {
|
|
198
|
+
end: LinkEnd;
|
|
199
|
+
shape: string;
|
|
200
|
+
at: LinkPoint;
|
|
201
|
+
angle: number;
|
|
202
|
+
color: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface Scene {
|
|
206
|
+
width: number;
|
|
207
|
+
height: number;
|
|
208
|
+
view: View;
|
|
209
|
+
background: string;
|
|
210
|
+
grid: {
|
|
211
|
+
minor: Segment[];
|
|
212
|
+
major: Segment[];
|
|
213
|
+
minorColor: string;
|
|
214
|
+
majorColor: string;
|
|
215
|
+
minorWidth: number;
|
|
216
|
+
majorWidth: number;
|
|
217
|
+
} | null;
|
|
218
|
+
line: { path: CubicSegment[]; width: number; color: string };
|
|
219
|
+
ends: [SceneEnd, SceneEnd];
|
|
220
|
+
blueprint: {
|
|
221
|
+
radius: number;
|
|
222
|
+
strokeWidth: number;
|
|
223
|
+
dash: readonly number[];
|
|
224
|
+
guide: { points: LinkPoint[]; color: string; width: number };
|
|
225
|
+
points: {
|
|
226
|
+
at: LinkPoint;
|
|
227
|
+
role: 'start' | 'end' | 'center' | 'point';
|
|
228
|
+
color: string;
|
|
229
|
+
}[];
|
|
230
|
+
} | null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export const GRID_SPACING: number;
|
|
234
|
+
export const STROKE_FRACTION: number;
|
|
235
|
+
export const RADIUS_FRACTION: number;
|
|
236
|
+
export const BLUEPRINT_DASH: readonly [4, 2];
|
|
237
|
+
|
|
238
|
+
export function buildScene(geometry: LinkGeometry, style: LinkStyle): Scene;
|
|
239
|
+
export function gridLines(
|
|
240
|
+
area: Bounds,
|
|
241
|
+
spacing: number,
|
|
242
|
+
k: number
|
|
243
|
+
): { minor: Segment[]; major: Segment[] };
|
|
244
|
+
export function visibleArea(view: View, width: number, height: number): Bounds;
|
|
245
|
+
export function sceneBounds(
|
|
246
|
+
geometry: LinkGeometry,
|
|
247
|
+
options?: { gridSpacing?: number }
|
|
248
|
+
): Bounds;
|
|
249
|
+
export function fitView(
|
|
250
|
+
bounds: Bounds,
|
|
251
|
+
width: number,
|
|
252
|
+
height: number,
|
|
253
|
+
limits?: { min?: number; max?: number }
|
|
254
|
+
): View;
|
|
255
|
+
|
|
256
|
+
// --------------------------------------------------------------- renderers
|
|
257
|
+
|
|
258
|
+
/** The SVG of one link; the same input always gives the same text. */
|
|
259
|
+
export function renderLinkSvg(geometry: LinkGeometry, style: LinkStyle): string;
|
|
260
|
+
/** The marker shapes a scene draws (source, target). */
|
|
261
|
+
export function drawnMarkers(scene: Scene): string[];
|
|
262
|
+
export function drawLinkCanvas(
|
|
263
|
+
ctx: CanvasRenderingContext2D,
|
|
264
|
+
geometry: LinkGeometry,
|
|
265
|
+
style: LinkStyle & { Path2D?: typeof Path2D }
|
|
266
|
+
): { markers: string[] };
|
|
267
|
+
|
|
268
|
+
// --------------------------------------------------------------- zoom-pan
|
|
269
|
+
|
|
270
|
+
export interface ZoomPanOptions {
|
|
271
|
+
/** The smallest zoom (default 0.1). */
|
|
272
|
+
min?: number;
|
|
273
|
+
/** The largest zoom (default 20). */
|
|
274
|
+
max?: number;
|
|
275
|
+
/** Default `{x: 0, y: 0, k: 1}`. */
|
|
276
|
+
initial?: Partial<View>;
|
|
277
|
+
onChange?: (view: View, cause: string) => void;
|
|
278
|
+
/** Zoom with the wheel (default true). */
|
|
279
|
+
wheel?: boolean;
|
|
280
|
+
/** Traces every event (off by default). */
|
|
281
|
+
debug?: (message: string, data?: object) => void;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface ZoomPan {
|
|
285
|
+
get(): View;
|
|
286
|
+
/** The zoom is clamped. */
|
|
287
|
+
set(view: Partial<View>): View;
|
|
288
|
+
reset(): View;
|
|
289
|
+
/** The pivot stays in place (default: the middle of the element). */
|
|
290
|
+
zoomBy(factor: number, pivot?: LinkPoint): View;
|
|
291
|
+
panBy(dx: number, dy: number): View;
|
|
292
|
+
/** Removes every listener. */
|
|
293
|
+
destroy(): void;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function createZoomPan(
|
|
297
|
+
element: HTMLElement,
|
|
298
|
+
options?: ZoomPanOptions
|
|
299
|
+
): ZoomPan;
|
|
300
|
+
/** `0.999 ** delta`. */
|
|
301
|
+
export function wheelFactor(delta: number): number;
|
|
302
|
+
export function wheelDelta(event: {
|
|
303
|
+
deltaY: number;
|
|
304
|
+
deltaMode?: number;
|
|
305
|
+
}): number;
|
|
306
|
+
|
|
307
|
+
// ---------------------------------------------------------------- animator
|
|
308
|
+
|
|
309
|
+
export interface Frame {
|
|
310
|
+
/** `now()` of this frame. */
|
|
311
|
+
time: number;
|
|
312
|
+
/** Since the animation started. */
|
|
313
|
+
elapsed: number;
|
|
314
|
+
/** Reduced motion: the only call, go to the end. */
|
|
315
|
+
reduced: boolean;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Return `true` to be called again on the next frame. */
|
|
319
|
+
export type Step = (frame: Frame) => boolean | void;
|
|
320
|
+
|
|
321
|
+
export interface AnimatorOptions {
|
|
322
|
+
now?: () => number;
|
|
323
|
+
raf?: (callback: (time: number) => void) => unknown;
|
|
324
|
+
caf?: (handle: unknown) => void;
|
|
325
|
+
reducedMotion?: () => boolean;
|
|
326
|
+
onError?: (error: unknown, id: string) => void;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface Animator {
|
|
330
|
+
/** Replaces a running animation of the same id. */
|
|
331
|
+
start(id: string, step: Step): void;
|
|
332
|
+
stop(id: string): boolean;
|
|
333
|
+
isRunning(id?: string): boolean;
|
|
334
|
+
destroy(): void;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function createAnimator(options?: AnimatorOptions): Animator;
|
|
338
|
+
export function prefersReducedMotion(win?: {
|
|
339
|
+
matchMedia?: (query: string) => { matches: boolean };
|
|
340
|
+
}): boolean;
|
|
341
|
+
|
|
342
|
+
// ------------------------------------------------------------------- model
|
|
343
|
+
|
|
344
|
+
export interface LinkViewModel {
|
|
345
|
+
/** The id of the `link-view` element. */
|
|
346
|
+
readonly name: string | null;
|
|
347
|
+
/** The link id. */
|
|
348
|
+
readonly id: string | null;
|
|
349
|
+
/** `null` is a free end. */
|
|
350
|
+
readonly source: string | null;
|
|
351
|
+
readonly target: string | null;
|
|
352
|
+
readonly ends: Readonly<Record<LinkEnd, string>>;
|
|
353
|
+
readonly blueprint: boolean;
|
|
354
|
+
readonly grid: boolean;
|
|
355
|
+
readonly bend: number;
|
|
356
|
+
/** An explicit accessible name. */
|
|
357
|
+
readonly label: string | null;
|
|
358
|
+
readonly selfLoop: boolean;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface ModelDiagnostic {
|
|
362
|
+
code: string;
|
|
363
|
+
severity: 'error' | 'warning';
|
|
364
|
+
message: string;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export const FREE_END_MARKER: 'cross';
|
|
368
|
+
export function readLinkView(
|
|
369
|
+
raw: readonly RawValue[],
|
|
370
|
+
options?: { name?: string | null }
|
|
371
|
+
): { model: LinkViewModel; diagnostics: ModelDiagnostic[] };
|
|
372
|
+
export function parseLinkView(text: string): {
|
|
373
|
+
model: LinkViewModel;
|
|
374
|
+
diagnostics: ModelDiagnostic[];
|
|
375
|
+
};
|
|
376
|
+
/** `Link 1 from 1 to 2`, or the label. */
|
|
377
|
+
export function accessibleName(model: LinkViewModel): string;
|
|
378
|
+
|
|
379
|
+
// ---------------------------------------------------------------- element
|
|
380
|
+
|
|
381
|
+
export interface LinkViewOptions {
|
|
382
|
+
tag?: string;
|
|
383
|
+
/** Clock and frame scheduler of every element of the tag. */
|
|
384
|
+
animator?: AnimatorOptions;
|
|
385
|
+
zoom?: { min?: number; max?: number };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface LinkViewDrawn {
|
|
389
|
+
readonly renderer: 'svg' | 'canvas';
|
|
390
|
+
readonly markers: readonly string[];
|
|
391
|
+
readonly view: View;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** The `<link-view>` element. */
|
|
395
|
+
export interface LinkViewElement extends HTMLElement {
|
|
396
|
+
readonly model: LinkViewModel;
|
|
397
|
+
readonly diagnostics: ModelDiagnostic[];
|
|
398
|
+
lino: string | null;
|
|
399
|
+
links: { raw: readonly RawValue[]; name?: string | null } | null;
|
|
400
|
+
/** The zoom and pan of this element, relative to the fitted view. */
|
|
401
|
+
view: View;
|
|
402
|
+
readonly drawn: LinkViewDrawn | null;
|
|
403
|
+
zoomBy(factor: number, pivot?: LinkPoint): View | undefined;
|
|
404
|
+
resetView(): View | undefined;
|
|
405
|
+
/** Draw on the next frame (several requests draw once). */
|
|
406
|
+
requestDraw(): void;
|
|
407
|
+
draw(): void;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export const LINK_VIEW_TAG: 'link-view';
|
|
411
|
+
export const LINK_VIEW_ATTRIBUTES: readonly string[];
|
|
412
|
+
export const KEY_ZOOM_STEP: number;
|
|
413
|
+
export const KEY_PAN_STEP: number;
|
|
414
|
+
export const FALLBACK_SIZE: Readonly<{ width: number; height: number }>;
|
|
415
|
+
|
|
416
|
+
export function linkViewGeometry(
|
|
417
|
+
model: LinkViewModel,
|
|
418
|
+
options?: { gridSpacing?: number }
|
|
419
|
+
): LinkGeometry;
|
|
420
|
+
export function defineLinkView(
|
|
421
|
+
win?: Window & typeof globalThis,
|
|
422
|
+
options?: LinkViewOptions
|
|
423
|
+
): { new (): LinkViewElement; prototype: LinkViewElement };
|
|
424
|
+
export function linkViewKind(options?: { tag?: string }): KindSpec;
|
|
425
|
+
export function registerLinkViewKind(
|
|
426
|
+
win?: Window & typeof globalThis,
|
|
427
|
+
options?: LinkViewOptions
|
|
428
|
+
): Readonly<KindSpec>;
|
|
429
|
+
|
|
430
|
+
// --------------------------------------------------------- links network
|
|
431
|
+
export type NetworkId = string | number;
|
|
432
|
+
export interface NetworkLink {
|
|
433
|
+
lino?: LinoNetworkMetadata;
|
|
434
|
+
id: NetworkId;
|
|
435
|
+
source: NetworkId | 0;
|
|
436
|
+
target: NetworkId | 0;
|
|
437
|
+
label?: string;
|
|
438
|
+
}
|
|
439
|
+
export interface Network {
|
|
440
|
+
points: Map<
|
|
441
|
+
NetworkId,
|
|
442
|
+
{
|
|
443
|
+
id: NetworkId;
|
|
444
|
+
label?: string;
|
|
445
|
+
kind?: 'point' | 'value';
|
|
446
|
+
lino?: LinoNetworkMetadata;
|
|
447
|
+
}
|
|
448
|
+
>;
|
|
449
|
+
links: Map<NetworkId, NetworkLink>;
|
|
450
|
+
}
|
|
451
|
+
export type NetworkPositions = Map<NetworkId, LinkPoint>;
|
|
452
|
+
export interface NetworkLayoutOptions {
|
|
453
|
+
width?: number;
|
|
454
|
+
height?: number;
|
|
455
|
+
alphaMin?: number;
|
|
456
|
+
maxTicks?: number;
|
|
457
|
+
pins?: [NetworkId, LinkPoint][];
|
|
458
|
+
}
|
|
459
|
+
export type NetworkLayoutName =
|
|
460
|
+
| 'circle'
|
|
461
|
+
| 'grid'
|
|
462
|
+
| 'hex'
|
|
463
|
+
| 'spiral'
|
|
464
|
+
| 'force'
|
|
465
|
+
| 'layered';
|
|
466
|
+
export type NetworkLayout = (
|
|
467
|
+
network: Network,
|
|
468
|
+
options?: NetworkLayoutOptions
|
|
469
|
+
) => NetworkPositions;
|
|
470
|
+
export function buildNetwork(links: Iterable<NetworkLinkInput>): Network;
|
|
471
|
+
export function networkIds(network: Network): NetworkId[];
|
|
472
|
+
export function networkEdges(
|
|
473
|
+
network: Network
|
|
474
|
+
): { source: NetworkId; target: NetworkId }[];
|
|
475
|
+
export function networkNeighbours(network: Network, id: NetworkId): NetworkId[];
|
|
476
|
+
export const NETWORK_LAYOUTS: Readonly<
|
|
477
|
+
Record<NetworkLayoutName, NetworkLayout>
|
|
478
|
+
>;
|
|
479
|
+
export const circle: NetworkLayout;
|
|
480
|
+
export const grid: NetworkLayout;
|
|
481
|
+
export const hex: NetworkLayout;
|
|
482
|
+
export const spiral: NetworkLayout;
|
|
483
|
+
export const force: NetworkLayout;
|
|
484
|
+
export const layered: NetworkLayout;
|
|
485
|
+
export function createForceSimulation(
|
|
486
|
+
network: Network,
|
|
487
|
+
options?: NetworkLayoutOptions
|
|
488
|
+
): {
|
|
489
|
+
readonly ticks: number;
|
|
490
|
+
tick(): boolean;
|
|
491
|
+
positions(): NetworkPositions;
|
|
492
|
+
};
|
|
493
|
+
export interface NetworkLabel {
|
|
494
|
+
id: NetworkId;
|
|
495
|
+
x: number;
|
|
496
|
+
y: number;
|
|
497
|
+
width: number;
|
|
498
|
+
height: number;
|
|
499
|
+
priority?: number;
|
|
500
|
+
}
|
|
501
|
+
export function visibleLabels(
|
|
502
|
+
labels: NetworkLabel[],
|
|
503
|
+
zoom: number,
|
|
504
|
+
options?: { minZoom?: number; padding?: number }
|
|
505
|
+
): NetworkId[];
|
|
506
|
+
export interface LayoutJob {
|
|
507
|
+
layout: NetworkLayoutName;
|
|
508
|
+
links: NetworkLinkInput[];
|
|
509
|
+
options?: NetworkLayoutOptions;
|
|
510
|
+
}
|
|
511
|
+
export interface LayoutResult {
|
|
512
|
+
positions: NetworkPositions;
|
|
513
|
+
ticks?: number;
|
|
514
|
+
}
|
|
515
|
+
export interface LayoutRunner {
|
|
516
|
+
run(key: string, job: LayoutJob): Promise<LayoutResult>;
|
|
517
|
+
cancel(key: string): void;
|
|
518
|
+
dispose(): void;
|
|
519
|
+
}
|
|
520
|
+
export function createLayoutRunner(options?: {
|
|
521
|
+
createWorker?: () => Worker;
|
|
522
|
+
}): LayoutRunner;
|
|
523
|
+
export interface NetworkStyle {
|
|
524
|
+
width?: number;
|
|
525
|
+
height?: number;
|
|
526
|
+
view?: View;
|
|
527
|
+
colors?: LinkColors;
|
|
528
|
+
style?: 'glyph' | 'node-edge';
|
|
529
|
+
selected?: NetworkId[];
|
|
530
|
+
hovered?: NetworkId | null;
|
|
531
|
+
labels?: { minZoom?: number; padding?: number };
|
|
532
|
+
}
|
|
533
|
+
export function networkToSvg(
|
|
534
|
+
network: Network,
|
|
535
|
+
positions: NetworkPositions,
|
|
536
|
+
style?: NetworkStyle
|
|
537
|
+
): string;
|
|
538
|
+
export function networkToPng(svg: string, scale?: number): Promise<Blob>;
|
|
539
|
+
export interface NetworkStore {
|
|
540
|
+
get(id: string):
|
|
541
|
+
| {
|
|
542
|
+
id: string;
|
|
543
|
+
kind: string | null;
|
|
544
|
+
positional: readonly RawValue[];
|
|
545
|
+
properties: readonly { name: string; values: readonly RawValue[] }[];
|
|
546
|
+
}
|
|
547
|
+
| undefined;
|
|
548
|
+
roots(): readonly string[];
|
|
549
|
+
children(id: string): readonly string[];
|
|
550
|
+
subscribe(
|
|
551
|
+
listener: (
|
|
552
|
+
events: readonly { id: string; type: string; before: unknown }[]
|
|
553
|
+
) => void
|
|
554
|
+
): () => void;
|
|
555
|
+
}
|
|
556
|
+
export interface LinksNetworkElement extends HTMLElement {
|
|
557
|
+
presentation: NetworkPresentation | null;
|
|
558
|
+
items: NetworkLinkInput[];
|
|
559
|
+
store: NetworkStore | null;
|
|
560
|
+
links: { raw: readonly RawValue[] };
|
|
561
|
+
readonly network: Network;
|
|
562
|
+
positions: NetworkPositions;
|
|
563
|
+
readonly pins: NetworkPositions;
|
|
564
|
+
readonly selection: NetworkId[];
|
|
565
|
+
select(id: NetworkId | null, additive?: boolean): void;
|
|
566
|
+
readonly ready: Promise<void | boolean>;
|
|
567
|
+
readonly diagnostics: { severity: string; message: string }[];
|
|
568
|
+
view: View;
|
|
569
|
+
readonly drawn: {
|
|
570
|
+
renderer: 'svg' | 'canvas';
|
|
571
|
+
links: number;
|
|
572
|
+
view: View;
|
|
573
|
+
} | null;
|
|
574
|
+
layout(): Promise<void | boolean>;
|
|
575
|
+
requestDraw(): void;
|
|
576
|
+
toSvg(): string;
|
|
577
|
+
toPng(scale?: number): Promise<Blob>;
|
|
578
|
+
}
|
|
579
|
+
export interface LinksNetworkOptions {
|
|
580
|
+
/** Disable worker allocation for bounded, synchronous thumbnail layouts. */
|
|
581
|
+
worker?: boolean;
|
|
582
|
+
tag?: string;
|
|
583
|
+
animator?: AnimatorOptions;
|
|
584
|
+
createWorker?: () => Worker;
|
|
585
|
+
}
|
|
586
|
+
export const LINKS_NETWORK_TAG: 'links-network';
|
|
587
|
+
export function defineLinksNetwork(
|
|
588
|
+
win?: Window & typeof globalThis,
|
|
589
|
+
options?: LinksNetworkOptions
|
|
590
|
+
): { new (): LinksNetworkElement; prototype: LinksNetworkElement };
|
|
591
|
+
export function linksNetworkKind(options?: { tag?: string }): KindSpec;
|
|
592
|
+
export function registerLinksNetworkKind(
|
|
593
|
+
win?: Window & typeof globalThis,
|
|
594
|
+
options?: LinksNetworkOptions
|
|
595
|
+
): Readonly<KindSpec>;
|
|
596
|
+
|
|
597
|
+
export function networkVocabulary(): import('@link-foundation/ui-core').Vocabulary;
|
|
598
|
+
|
|
599
|
+
// ----------------------------------------------------- LiNo network converter
|
|
600
|
+
export interface LinoSourcePosition {
|
|
601
|
+
line: number;
|
|
602
|
+
column: number;
|
|
603
|
+
}
|
|
604
|
+
export interface LinoNetworkDiagnostic extends LinoSourcePosition {
|
|
605
|
+
code: string;
|
|
606
|
+
severity: 'error' | 'warning';
|
|
607
|
+
message: string;
|
|
608
|
+
}
|
|
609
|
+
export interface LinoNetworkSource {
|
|
610
|
+
id: string | null;
|
|
611
|
+
values: LinoNetworkSource[];
|
|
612
|
+
definition?: boolean;
|
|
613
|
+
quote?: string;
|
|
614
|
+
}
|
|
615
|
+
export interface LinoNetworkMetadata {
|
|
616
|
+
roots: LinoNetworkSource[];
|
|
617
|
+
}
|
|
618
|
+
export interface NetworkPointInput {
|
|
619
|
+
id: NetworkId;
|
|
620
|
+
kind: 'point' | 'value';
|
|
621
|
+
label: string;
|
|
622
|
+
lino?: LinoNetworkMetadata;
|
|
623
|
+
}
|
|
624
|
+
export type NetworkLinkInput = NetworkLink | NetworkPointInput;
|
|
625
|
+
export type LinoNetworkInput = NetworkLinkInput;
|
|
626
|
+
export interface LinoNetworkResult {
|
|
627
|
+
links: LinoNetworkInput[];
|
|
628
|
+
diagnostics: LinoNetworkDiagnostic[];
|
|
629
|
+
sourceMap: Map<string, LinoSourcePosition>;
|
|
630
|
+
}
|
|
631
|
+
export interface LinoNetworkOptions {
|
|
632
|
+
maxInputSize?: number;
|
|
633
|
+
maxDepth?: number;
|
|
634
|
+
}
|
|
635
|
+
export function linoToNetwork(
|
|
636
|
+
text: string,
|
|
637
|
+
options?: LinoNetworkOptions
|
|
638
|
+
): LinoNetworkResult;
|
|
639
|
+
export function networkToLino(
|
|
640
|
+
network: Network | LinoNetworkResult | LinoNetworkInput[]
|
|
641
|
+
): string;
|
|
642
|
+
export function networkInput(network: Network): NetworkLinkInput[];
|
|
643
|
+
export interface LinoNetworkElement extends HTMLElement {
|
|
644
|
+
lino: string;
|
|
645
|
+
readonly ready: Promise<void>;
|
|
646
|
+
readonly diagnostics: LinoNetworkDiagnostic[];
|
|
647
|
+
readonly sourceMap: Map<string, LinoSourcePosition>;
|
|
648
|
+
readonly network: Network;
|
|
649
|
+
readonly networkView: LinksNetworkElement;
|
|
650
|
+
select(id: NetworkId | null): void;
|
|
651
|
+
toSvg(): string;
|
|
652
|
+
toPng(scale?: number): Promise<Blob>;
|
|
653
|
+
}
|
|
654
|
+
export interface LinoNetworkElementOptions extends LinoNetworkOptions {
|
|
655
|
+
tag?: string;
|
|
656
|
+
createWorker?: () => Worker;
|
|
657
|
+
fetch?: typeof fetch;
|
|
658
|
+
/** Optional source-load tracing; silent by default. */
|
|
659
|
+
debug?: (message: string, data?: object) => void;
|
|
660
|
+
}
|
|
661
|
+
export const LINO_NETWORK_TAG: 'lino-network';
|
|
662
|
+
export function defineLinoNetwork(
|
|
663
|
+
win?: Window & typeof globalThis,
|
|
664
|
+
options?: LinoNetworkElementOptions
|
|
665
|
+
): { new (): LinoNetworkElement; prototype: LinoNetworkElement };
|
|
666
|
+
|
|
667
|
+
// --------------------------------------- host geometry/solver/export providers
|
|
668
|
+
export interface NetworkPresentationInput {
|
|
669
|
+
items: NetworkLinkInput[] | DoubletPair[];
|
|
670
|
+
/** Decimal text preserves indexes beyond the safe Number range. */
|
|
671
|
+
index: string;
|
|
672
|
+
/** Opaque LiNo geometry, marker, solver, caption and export configuration. */
|
|
673
|
+
options: string;
|
|
674
|
+
}
|
|
675
|
+
export interface NetworkPresentationFrame {
|
|
676
|
+
positions: NetworkPositions;
|
|
677
|
+
pins: NetworkPositions;
|
|
678
|
+
bounds: { x: number; y: number; width: number; height: number };
|
|
679
|
+
[key: string]: unknown;
|
|
680
|
+
}
|
|
681
|
+
export interface NetworkPresentationSnapshot {
|
|
682
|
+
input: NetworkPresentationInput;
|
|
683
|
+
frame?: NetworkPresentationFrame;
|
|
684
|
+
revision: number;
|
|
685
|
+
}
|
|
686
|
+
export interface NetworkPresentationRequest extends NetworkPresentationSnapshot {
|
|
687
|
+
signal: AbortSignal;
|
|
688
|
+
}
|
|
689
|
+
export type NetworkRasterType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
690
|
+
export interface NetworkRasterOptions {
|
|
691
|
+
type?: NetworkRasterType;
|
|
692
|
+
scale?: number;
|
|
693
|
+
quality?: number;
|
|
694
|
+
background?: string;
|
|
695
|
+
maxPixels?: number;
|
|
696
|
+
document?: Document;
|
|
697
|
+
URL?: typeof URL;
|
|
698
|
+
Image?: typeof Image;
|
|
699
|
+
}
|
|
700
|
+
export interface NetworkPresentationProvider {
|
|
701
|
+
geometry(
|
|
702
|
+
request: NetworkPresentationRequest
|
|
703
|
+
): NetworkPresentationFrame | Promise<NetworkPresentationFrame>;
|
|
704
|
+
solve?(
|
|
705
|
+
request: NetworkPresentationRequest
|
|
706
|
+
): NetworkPresentationFrame | Promise<NetworkPresentationFrame>;
|
|
707
|
+
svg(snapshot: NetworkPresentationSnapshot): string;
|
|
708
|
+
raster?(
|
|
709
|
+
request: NetworkPresentationSnapshot & {
|
|
710
|
+
svg: string;
|
|
711
|
+
type: NetworkRasterType;
|
|
712
|
+
options: NetworkRasterOptions;
|
|
713
|
+
}
|
|
714
|
+
): Promise<Blob>;
|
|
715
|
+
}
|
|
716
|
+
export interface NetworkPresentation {
|
|
717
|
+
update(patch: Partial<NetworkPresentationInput>): Promise<boolean>;
|
|
718
|
+
solve(): Promise<boolean>;
|
|
719
|
+
snapshot(): NetworkPresentationSnapshot;
|
|
720
|
+
toSvg(): string;
|
|
721
|
+
toRaster(
|
|
722
|
+
type?: NetworkRasterType,
|
|
723
|
+
options?: NetworkRasterOptions
|
|
724
|
+
): Promise<Blob>;
|
|
725
|
+
toLino(): string;
|
|
726
|
+
subscribe(
|
|
727
|
+
listener: (snapshot: NetworkPresentationSnapshot) => void
|
|
728
|
+
): () => void;
|
|
729
|
+
dispose(): void;
|
|
730
|
+
}
|
|
731
|
+
export function createNetworkPresentation(
|
|
732
|
+
provider: NetworkPresentationProvider,
|
|
733
|
+
options?: { debug?: (message: string, data: object) => void }
|
|
734
|
+
): NetworkPresentation;
|
|
735
|
+
export function networkToRaster(
|
|
736
|
+
svg: string,
|
|
737
|
+
options?: NetworkRasterOptions
|
|
738
|
+
): Promise<Blob>;
|
|
739
|
+
|
|
740
|
+
import type { Configuration } from './configurations.d.ts';
|
|
741
|
+
|
|
742
|
+
export interface NetworkEditorValues {
|
|
743
|
+
[key: string]: unknown;
|
|
744
|
+
turns: [number, number][];
|
|
745
|
+
linkGaps: [number | null, number | null, number | null, number | null][];
|
|
746
|
+
linkColors: (string | null)[];
|
|
747
|
+
frame: [number, number, number] | null;
|
|
748
|
+
order: number[] | null;
|
|
749
|
+
}
|
|
750
|
+
export interface NetworkOptionDefinition {
|
|
751
|
+
readonly key: string;
|
|
752
|
+
readonly type: string;
|
|
753
|
+
readonly default: string | number | boolean;
|
|
754
|
+
readonly section: string;
|
|
755
|
+
readonly availability: string;
|
|
756
|
+
readonly min?: number | string;
|
|
757
|
+
readonly max?: number | string;
|
|
758
|
+
readonly step?: number;
|
|
759
|
+
readonly choices?: readonly string[];
|
|
760
|
+
}
|
|
761
|
+
export interface NetworkEditorSnapshot {
|
|
762
|
+
links: Configuration;
|
|
763
|
+
options: NetworkEditorValues;
|
|
764
|
+
code: string;
|
|
765
|
+
}
|
|
766
|
+
export interface NetworkSolverResult {
|
|
767
|
+
turns: NetworkEditorValues['turns'];
|
|
768
|
+
linkGaps: NetworkEditorValues['linkGaps'];
|
|
769
|
+
frame: NetworkEditorValues['frame'];
|
|
770
|
+
before: number;
|
|
771
|
+
after: number;
|
|
772
|
+
delta?: unknown;
|
|
773
|
+
}
|
|
774
|
+
export interface NetworkEditorSettings {
|
|
775
|
+
presentation: NetworkPresentation;
|
|
776
|
+
configurations?: typeof import('./configurations.d.ts');
|
|
777
|
+
solve?: (
|
|
778
|
+
links: Configuration,
|
|
779
|
+
options: NetworkEditorValues,
|
|
780
|
+
context: { signal: AbortSignal }
|
|
781
|
+
) => Promise<NetworkSolverResult>;
|
|
782
|
+
locale?: 'en' | 'ru';
|
|
783
|
+
serializeOptions?: (options: NetworkEditorValues) => string;
|
|
784
|
+
readOptions?: (text: string) => Partial<NetworkEditorValues>;
|
|
785
|
+
syncUrl?: boolean;
|
|
786
|
+
debug?: (message: string, data?: object) => void;
|
|
787
|
+
}
|
|
788
|
+
export interface NetworkEditor {
|
|
789
|
+
readonly ready: Promise<unknown>;
|
|
790
|
+
snapshot(): NetworkEditorSnapshot;
|
|
791
|
+
updateOptions(patch: Partial<NetworkEditorValues>): Promise<boolean>;
|
|
792
|
+
updateLinks(links: Configuration): Promise<boolean>;
|
|
793
|
+
restoreUrl(): Promise<unknown>;
|
|
794
|
+
dispose(): void;
|
|
795
|
+
}
|
|
796
|
+
export function createNetworkEditor(
|
|
797
|
+
root: HTMLElement,
|
|
798
|
+
settings: NetworkEditorSettings
|
|
799
|
+
): NetworkEditor;
|
|
800
|
+
export const networkOptionSchema: readonly NetworkOptionDefinition[];
|
|
801
|
+
export const networkOverrideSchema: readonly NetworkOptionDefinition[];
|
|
802
|
+
export function normalizeNetworkOptions(
|
|
803
|
+
input?: Record<string, unknown>
|
|
804
|
+
): NetworkEditorValues;
|
|
805
|
+
export function networkOptionsToParams(
|
|
806
|
+
options: Record<string, unknown>
|
|
807
|
+
): URLSearchParams;
|
|
808
|
+
export function networkOptionsFromParams(
|
|
809
|
+
params: string | URLSearchParams
|
|
810
|
+
): NetworkEditorValues;
|
|
811
|
+
export function networkOptionsToLino(options: Record<string, unknown>): string;
|
|
812
|
+
export function networkOptionsFromLino(text?: string): NetworkEditorValues;
|
|
813
|
+
export function networkOptionAvailable(
|
|
814
|
+
field: NetworkOptionDefinition,
|
|
815
|
+
links: Configuration,
|
|
816
|
+
options: NetworkEditorValues
|
|
817
|
+
): boolean;
|
|
818
|
+
export const networkLooks: Readonly<
|
|
819
|
+
Record<string, Readonly<Record<string, unknown>>>
|
|
820
|
+
>;
|
|
821
|
+
export const networkSizePresets: readonly (readonly [number, number])[];
|
|
822
|
+
export function networkFilename(code: string, extension: string): string;
|
|
823
|
+
export function networkShareTargets(
|
|
824
|
+
url: string,
|
|
825
|
+
title?: string
|
|
826
|
+
): Record<string, string>;
|
|
827
|
+
export interface NetworkUrlSyncSettings {
|
|
828
|
+
window?: Window;
|
|
829
|
+
root?: EventTarget;
|
|
830
|
+
urlFor(
|
|
831
|
+
snapshot: NetworkPresentationSnapshot,
|
|
832
|
+
currentHref: string
|
|
833
|
+
): string | URL;
|
|
834
|
+
delay?: number;
|
|
835
|
+
setTimer?: (fn: () => void, delay: number) => unknown;
|
|
836
|
+
clearTimer?: (id: unknown) => void;
|
|
837
|
+
debug?: (message: string, data?: object) => void;
|
|
838
|
+
}
|
|
839
|
+
export function syncNetworkUrl(
|
|
840
|
+
presentation: NetworkPresentation,
|
|
841
|
+
settings: NetworkUrlSyncSettings
|
|
842
|
+
): { flush(): void; dispose(): void };
|
|
843
|
+
|
|
844
|
+
export function createNetworkEditorProvider(configuration?: {
|
|
845
|
+
debug?: (message: string, data?: object) => void;
|
|
846
|
+
}): NetworkPresentationProvider;
|
|
847
|
+
|
|
848
|
+
/** Job execution only; this does not provide a collision search algorithm. */
|
|
849
|
+
export type NetworkSolver<Result> = (
|
|
850
|
+
links: number[][],
|
|
851
|
+
options: Record<string, unknown>,
|
|
852
|
+
context: { signal: AbortSignal }
|
|
853
|
+
) => Result | Promise<Result>;
|
|
854
|
+
export function createSolverJob<Result>(
|
|
855
|
+
solve: NetworkSolver<Result>,
|
|
856
|
+
configuration?: { workerUrl?: string | URL; Worker?: typeof Worker }
|
|
857
|
+
): (
|
|
858
|
+
links: number[][],
|
|
859
|
+
options?: Record<string, unknown>,
|
|
860
|
+
context?: { signal?: AbortSignal }
|
|
861
|
+
) => Promise<Result>;
|
|
862
|
+
export function installSolverWorker<Result>(
|
|
863
|
+
scope: {
|
|
864
|
+
addEventListener(
|
|
865
|
+
type: 'message',
|
|
866
|
+
listener: (event: MessageEvent) => void
|
|
867
|
+
): void;
|
|
868
|
+
postMessage(value: unknown): void;
|
|
869
|
+
},
|
|
870
|
+
solve: NetworkSolver<Result>
|
|
871
|
+
): void;
|
|
872
|
+
export interface LinksGalleryElement extends HTMLElement {
|
|
873
|
+
size: number;
|
|
874
|
+
readonly count: bigint;
|
|
875
|
+
urlFor:
|
|
876
|
+
| ((input: {
|
|
877
|
+
code: string;
|
|
878
|
+
links: [number, number][];
|
|
879
|
+
index: string;
|
|
880
|
+
size: number;
|
|
881
|
+
real: boolean;
|
|
882
|
+
theme: string | null;
|
|
883
|
+
}) => string | URL)
|
|
884
|
+
| null;
|
|
885
|
+
}
|
|
886
|
+
export const LINKS_GALLERY_TAG: 'links-gallery';
|
|
887
|
+
export const GALLERY_PAGE_SIZE: 243;
|
|
888
|
+
export function defineLinksGallery(
|
|
889
|
+
win?: Window,
|
|
890
|
+
options?: { tag?: string }
|
|
891
|
+
): CustomElementConstructor;
|
|
892
|
+
|
|
893
|
+
// --------------------------------------- built-in doublet provider
|
|
894
|
+
export type DoubletPair = readonly [number, number];
|
|
895
|
+
export type DoubletInput = readonly DoubletPair[] | readonly NetworkLinkInput[];
|
|
896
|
+
export type DoubletMarkerShape =
|
|
897
|
+
| 'bar'
|
|
898
|
+
| 'arrow'
|
|
899
|
+
| 'triangle'
|
|
900
|
+
| 'tail'
|
|
901
|
+
| 'dot'
|
|
902
|
+
| 'circle'
|
|
903
|
+
| 'square'
|
|
904
|
+
| 'diamond'
|
|
905
|
+
| 'none';
|
|
906
|
+
export interface DoubletMarker {
|
|
907
|
+
shape: DoubletMarkerShape;
|
|
908
|
+
size: number;
|
|
909
|
+
angle: number;
|
|
910
|
+
offset: number;
|
|
911
|
+
across: number;
|
|
912
|
+
rotation: number;
|
|
913
|
+
explicit: string[];
|
|
914
|
+
}
|
|
915
|
+
export interface DoubletOptions {
|
|
916
|
+
layout:
|
|
917
|
+
| 'auto'
|
|
918
|
+
| 'circle'
|
|
919
|
+
| 'grid'
|
|
920
|
+
| 'hex'
|
|
921
|
+
| 'spiral'
|
|
922
|
+
| 'dice'
|
|
923
|
+
| 'cards'
|
|
924
|
+
| 'force'
|
|
925
|
+
| 'layered';
|
|
926
|
+
layoutAspect: number;
|
|
927
|
+
columns: number;
|
|
928
|
+
spread: number;
|
|
929
|
+
rotation: number;
|
|
930
|
+
free: number;
|
|
931
|
+
loop: number;
|
|
932
|
+
bulge: number;
|
|
933
|
+
loopBend: number;
|
|
934
|
+
angles: 'fixed' | 'mirror';
|
|
935
|
+
sourceAngle: number;
|
|
936
|
+
targetAngle: number;
|
|
937
|
+
tension: number;
|
|
938
|
+
gaps: number[];
|
|
939
|
+
links: Record<number, { turns: number[]; gaps: (number | null)[] }>;
|
|
940
|
+
order: number[] | null;
|
|
941
|
+
frame: [number, number, number] | null;
|
|
942
|
+
padding: number;
|
|
943
|
+
start: DoubletMarker;
|
|
944
|
+
end: DoubletMarker;
|
|
945
|
+
middle: DoubletMarker;
|
|
946
|
+
strokeWidth: number;
|
|
947
|
+
color: string;
|
|
948
|
+
dash: 'solid' | 'dashed' | 'dotted' | 'dashdot' | 'long';
|
|
949
|
+
linecap: 'butt' | 'round' | 'square';
|
|
950
|
+
opacity: number;
|
|
951
|
+
glow: number;
|
|
952
|
+
arrowJoin: 'miter' | 'round' | 'bevel';
|
|
953
|
+
balanceArrows: boolean;
|
|
954
|
+
background: {
|
|
955
|
+
type: 'transparent' | 'solid' | 'linear' | 'radial';
|
|
956
|
+
color: string;
|
|
957
|
+
color2: string;
|
|
958
|
+
angle: number;
|
|
959
|
+
};
|
|
960
|
+
card: {
|
|
961
|
+
color: string;
|
|
962
|
+
opacity: number;
|
|
963
|
+
border: 'solid' | 'dashed' | 'dotted' | 'double' | 'none';
|
|
964
|
+
borderColor: string;
|
|
965
|
+
width: number;
|
|
966
|
+
radius: number;
|
|
967
|
+
inset: number;
|
|
968
|
+
};
|
|
969
|
+
caption: {
|
|
970
|
+
mode: 'none' | 'theory' | 'pairs' | 'number' | 'links' | 'custom';
|
|
971
|
+
text: string;
|
|
972
|
+
font: 'mono' | 'sans' | 'serif';
|
|
973
|
+
size: number;
|
|
974
|
+
color: string;
|
|
975
|
+
};
|
|
976
|
+
width: number;
|
|
977
|
+
height: number;
|
|
978
|
+
}
|
|
979
|
+
export interface DoubletMarkerPlacement {
|
|
980
|
+
end: 'start' | 'end' | 'middle';
|
|
981
|
+
marker: DoubletMarker;
|
|
982
|
+
point: LinkPoint;
|
|
983
|
+
anchor: LinkPoint;
|
|
984
|
+
direction: LinkPoint;
|
|
985
|
+
angle: number;
|
|
986
|
+
compensated: boolean;
|
|
987
|
+
extension: number;
|
|
988
|
+
length: number;
|
|
989
|
+
}
|
|
990
|
+
export interface DoubletCurve {
|
|
991
|
+
id: number;
|
|
992
|
+
middle: LinkPoint;
|
|
993
|
+
direction: LinkPoint;
|
|
994
|
+
path: [CubicSegment, CubicSegment];
|
|
995
|
+
}
|
|
996
|
+
export interface FittedDoubletCurve extends DoubletCurve {
|
|
997
|
+
visible: [CubicSegment | null, CubicSegment | null];
|
|
998
|
+
gaps: number[];
|
|
999
|
+
markers: DoubletMarkerPlacement[];
|
|
1000
|
+
lengths: number[];
|
|
1001
|
+
}
|
|
1002
|
+
export interface DoubletFrame extends NetworkPresentationFrame {
|
|
1003
|
+
places: Map<number, LinkPoint>;
|
|
1004
|
+
layoutCurves: DoubletCurve[];
|
|
1005
|
+
curves: FittedDoubletCurve[];
|
|
1006
|
+
pairs: DoubletPair[];
|
|
1007
|
+
options: DoubletOptions;
|
|
1008
|
+
index: string;
|
|
1009
|
+
transform: [number, number, number];
|
|
1010
|
+
margin: number;
|
|
1011
|
+
captionRoom: number;
|
|
1012
|
+
}
|
|
1013
|
+
export const DOUBLET_MARKERS: readonly DoubletMarkerShape[];
|
|
1014
|
+
export function readDoubletOptions(
|
|
1015
|
+
text?: string,
|
|
1016
|
+
count?: number
|
|
1017
|
+
): DoubletOptions;
|
|
1018
|
+
export function doubletGeometry(
|
|
1019
|
+
items: DoubletInput,
|
|
1020
|
+
options?: string,
|
|
1021
|
+
index?: string
|
|
1022
|
+
): DoubletFrame;
|
|
1023
|
+
export function createDoubletProvider(options?: {
|
|
1024
|
+
debug?: (message: string, data: object) => void;
|
|
1025
|
+
}): NetworkPresentationProvider;
|
|
1026
|
+
export function doubletOptionAvailability(
|
|
1027
|
+
items: DoubletInput,
|
|
1028
|
+
options?: string
|
|
1029
|
+
): Record<string, boolean>;
|