@redvars/peacock 4.0.0 → 4.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/dist/{BaseField-CAog9TIc.js → BaseField-BMumJpkW.js} +6 -3
- package/dist/BaseField-BMumJpkW.js.map +1 -0
- package/dist/{BaseInput-CcMfg1Y2.js → BaseInput-mWdyYv27.js} +6 -3
- package/dist/BaseInput-mWdyYv27.js.map +1 -0
- package/dist/accordion.js.map +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-button-Do2TUy8M.js → base-button-BJMGMcMv.js} +3 -1
- package/dist/base-button-BJMGMcMv.js.map +1 -0
- package/dist/{base-progress-BiLlZVHJ.js → base-progress-CvLVSjuy.js} +4 -2
- package/dist/base-progress-CvLVSjuy.js.map +1 -0
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/button-group.js +4 -4
- package/dist/button.js +3 -3
- package/dist/calendar.js +2 -2
- package/dist/canvas-base-BTQMEVn_.js +788 -0
- package/dist/canvas-base-BTQMEVn_.js.map +1 -0
- package/dist/canvas-link-CtgsALq4.js +54 -0
- package/dist/canvas-link-CtgsALq4.js.map +1 -0
- package/dist/{cartesian-chart-C-f1frt0.js → cartesian-chart-DM1FC_XT.js} +3 -2
- package/dist/cartesian-chart-DM1FC_XT.js.map +1 -0
- package/dist/{cb-group-base-DeuCVx3a.js → cb-group-base-B6fa4Lll.js} +2 -2
- package/dist/{cb-group-base-DeuCVx3a.js.map → cb-group-base-B6fa4Lll.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +5 -4
- package/dist/chart-area.js.map +1 -1
- package/dist/chart-bar.js +5 -4
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-base-Dhxuw_Mw.js +833 -0
- package/dist/chart-base-Dhxuw_Mw.js.map +1 -0
- package/dist/chart-doughnut.js +4 -3
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-line.js +5 -4
- package/dist/chart-line.js.map +1 -1
- package/dist/chart-pie.js +4 -3
- package/dist/chart-pie.js.map +1 -1
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +4 -4
- package/dist/checkbox.js +4 -4
- package/dist/chip-set.js +3 -3
- package/dist/chip.js +4 -4
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +5 -4
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +5 -5
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +5 -5
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +5 -5
- package/dist/custom-elements-jsdocs.json +2115 -336
- package/dist/custom-elements.json +19483 -615
- package/dist/date-field.js +6 -6
- package/dist/date-picker.js +4 -2
- package/dist/date-picker.js.map +1 -1
- package/dist/date-range-field.js +6 -6
- package/dist/datetime-field.js +6 -6
- package/dist/dependency-map-layout-5KUueabk.js +1390 -0
- package/dist/dependency-map-layout-5KUueabk.js.map +1 -0
- package/dist/dependency-map.js +1605 -0
- package/dist/dependency-map.js.map +1 -0
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/diagram-2r11KySs.js +2029 -0
- package/dist/diagram-2r11KySs.js.map +1 -0
- package/dist/diagram-controls.js +345 -0
- package/dist/diagram-controls.js.map +1 -0
- package/dist/diagram-minimap.js +216 -0
- package/dist/diagram-minimap.js.map +1 -0
- package/dist/diagram.js +20 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +5 -5
- package/dist/{document-editor-BO7QPbO5.js → document-editor-BnEugM3E.js} +2 -2
- package/dist/{document-editor-BO7QPbO5.js.map → document-editor-BnEugM3E.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +2021 -0
- package/dist/erd.js.map +1 -0
- package/dist/fab.js +4 -4
- package/dist/field.js +257 -43
- package/dist/field.js.map +1 -1
- package/dist/file-upload.js +37 -15
- package/dist/file-upload.js.map +1 -1
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +27 -970
- package/dist/flow.js.map +1 -1
- package/dist/focus-ring.js +2 -0
- package/dist/focus-ring.js.map +1 -1
- package/dist/{form-associated-D3Tn33s_.js → form-associated-BHbg72PG.js} +3 -1
- package/dist/{form-associated-D3Tn33s_.js.map → form-associated-BHbg72PG.js.map} +1 -1
- package/dist/{form-submitter-DWwv6K9-.js → form-submitter-beG1CXAn.js} +7 -1
- package/dist/{form-submitter-DWwv6K9-.js.map → form-submitter-beG1CXAn.js.map} +1 -1
- package/dist/form.js +2 -2
- package/dist/{generative-view-DmtpDobn.js → generative-view-BgOcLRXr.js} +13 -13
- package/dist/generative-view-BgOcLRXr.js.map +1 -0
- package/dist/generative-view.js +3 -3
- package/dist/geometry-INg82Lxq.js +305 -0
- package/dist/geometry-INg82Lxq.js.map +1 -0
- package/dist/history-YbTSQZHj.js +45 -0
- package/dist/history-YbTSQZHj.js.map +1 -0
- package/dist/host-CZK7xhzh.js +40 -0
- package/dist/host-CZK7xhzh.js.map +1 -0
- package/dist/html-editor.js +5 -5
- package/dist/{hyperlink-DhE9RlVS.js → hyperlink-DycWPKwU.js} +10 -1
- package/dist/hyperlink-DycWPKwU.js.map +1 -0
- package/dist/{i18n-controller-urcQKYGe.js → i18n-controller-Cp43HjJl.js} +2 -2
- package/dist/{i18n-controller-urcQKYGe.js.map → i18n-controller-Cp43HjJl.js.map} +1 -1
- package/dist/icon-button.js +4 -4
- package/dist/image.js +2 -2
- package/dist/index.js +37 -18
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +4 -4
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/link-button.js +2 -2
- package/dist/list-item.js +2 -2
- package/dist/list.js +2 -2
- package/dist/listbox.js +3 -3
- package/dist/loader-full.js +13 -13
- package/dist/loader.js +44 -15
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +5 -5
- package/dist/markers-BFmh1OCz.js +46 -0
- package/dist/markers-BFmh1OCz.js.map +1 -0
- package/dist/measure-controller-Dmc5hZKg.js +89 -0
- package/dist/measure-controller-Dmc5hZKg.js.map +1 -0
- package/dist/mention-input.js +6 -5
- package/dist/mention-input.js.map +1 -1
- package/dist/menu-item.js +3 -2
- package/dist/menu-item.js.map +1 -1
- package/dist/menu.js +2 -2
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +6 -5
- package/dist/number-field.js.map +1 -1
- package/dist/option.js +2 -2
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +5 -5
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +5 -5
- package/dist/{picker-field-B4DtcJfL.js → picker-field-dTlIMAQn.js} +3 -3
- package/dist/{picker-field-B4DtcJfL.js.map → picker-field-dTlIMAQn.js.map} +1 -1
- package/dist/pin-input.js +5 -5
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +5 -5
- package/dist/radio-group.js +1 -0
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.js +5 -5
- package/dist/radio.js.map +1 -1
- package/dist/rating.js +5 -4
- package/dist/rating.js.map +1 -1
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-DLICqof1.js → rich-text-input-DM_BOzgk.js} +3 -3
- package/dist/{rich-text-input-DLICqof1.js.map → rich-text-input-DM_BOzgk.js.map} +1 -1
- package/dist/ripple.js +2 -0
- package/dist/ripple.js.map +1 -1
- package/dist/{schema-hMt-NRLk.js → schema-B8g30A_n.js} +2 -2
- package/dist/{schema-hMt-NRLk.js.map → schema-B8g30A_n.js.map} +1 -1
- package/dist/search.js +4 -4
- package/dist/segmented-button-group.js +1 -1
- package/dist/select.js +7 -7
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +5 -4
- package/dist/signature-pad.js.map +1 -1
- package/dist/slider.js +5 -4
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/diagram/canvas-base.d.ts +105 -0
- package/dist/src/__internal/diagram/canvas-link.d.ts +21 -0
- package/dist/src/__internal/diagram/geometry.d.ts +49 -0
- package/dist/src/__internal/diagram/history.d.ts +17 -0
- package/dist/src/__internal/diagram/host.d.ts +45 -0
- package/dist/src/__internal/diagram/markers.d.ts +16 -0
- package/dist/src/__internal/diagram/measure-controller.d.ts +32 -0
- package/dist/src/__internal/diagram/motion.d.ts +22 -0
- package/dist/src/__internal/diagram/selection.d.ts +20 -0
- package/dist/src/__internal/diagram/types.d.ts +39 -0
- package/dist/src/__internal/diagram/viewport-controller.d.ts +89 -0
- package/dist/src/__internal/i18n/strings.d.ts +149 -0
- package/dist/src/__internal/toggle-base.d.ts +8 -0
- package/dist/src/__internal/utils/deprecate.d.ts +3 -3
- package/dist/src/accordion/accordion.d.ts +1 -0
- package/dist/src/code-editor/code-editor.d.ts +1 -0
- package/dist/src/date-picker/date-picker.d.ts +2 -0
- package/dist/src/dependency-map/dependency-map-layout.d.ts +48 -0
- package/dist/src/dependency-map/dependency-map.d.ts +241 -0
- package/dist/src/dependency-map/index.d.ts +2 -0
- package/dist/src/diagram/diagram.d.ts +300 -0
- package/dist/src/diagram/flow.d.ts +53 -0
- package/dist/src/diagram/index.d.ts +4 -0
- package/dist/src/diagram-controls/diagram-controls.d.ts +46 -0
- package/dist/src/diagram-controls/index.d.ts +1 -0
- package/dist/src/diagram-minimap/diagram-minimap.d.ts +39 -0
- package/dist/src/diagram-minimap/index.d.ts +1 -0
- package/dist/src/erd/erd-layout.d.ts +27 -0
- package/dist/src/erd/erd.d.ts +266 -0
- package/dist/src/erd/index.d.ts +2 -0
- package/dist/src/field/field.d.ts +38 -1
- package/dist/src/file-upload/file-upload.d.ts +3 -1
- package/dist/src/focus-ring/focus-ring.d.ts +2 -0
- package/dist/src/index.d.ts +15 -2
- package/dist/src/input/BaseField.d.ts +3 -0
- package/dist/src/input/BaseInput.d.ts +3 -0
- package/dist/src/menu/menu-item/menu-item.d.ts +1 -0
- package/dist/src/number-field/number-field.d.ts +4 -0
- package/dist/src/progress/base-progress.d.ts +3 -0
- package/dist/src/radio/radio-group.d.ts +1 -0
- package/dist/src/rating/rating.d.ts +1 -0
- package/dist/src/ripple/ripple.d.ts +2 -0
- package/dist/src/signature-pad/signature-pad.d.ts +1 -0
- package/dist/src/slider/slider.d.ts +1 -0
- package/dist/src/switch/switch.d.ts +1 -0
- package/dist/src/tabs/tab.d.ts +2 -0
- package/dist/src/tabs/tabs.d.ts +1 -0
- package/dist/src/textarea/textarea.d.ts +1 -0
- package/dist/src/time-picker/time-picker.d.ts +2 -0
- package/dist/src/transfer-list/transfer-list.d.ts +1 -0
- package/dist/src/tree-chart/index.d.ts +2 -0
- package/dist/src/tree-chart/tree-chart-layout.d.ts +49 -0
- package/dist/src/tree-chart/tree-chart.d.ts +221 -0
- package/dist/src/workflow/index.d.ts +2 -0
- package/dist/src/workflow/workflow-format.d.ts +5 -0
- package/dist/src/workflow/workflow-model.d.ts +194 -0
- package/dist/src/workflow/workflow.d.ts +313 -0
- package/dist/src/workflow-timeline/index.d.ts +1 -0
- package/dist/src/workflow-timeline/workflow-timeline.d.ts +41 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-DmbqMTfs.js → strings-BJPuhKJk.js} +163 -1
- package/dist/{strings-DmbqMTfs.js.map → strings-BJPuhKJk.js.map} +1 -1
- package/dist/sub-menu.js +2 -2
- package/dist/svg.js +2 -2
- package/dist/switch.js +5 -4
- package/dist/switch.js.map +1 -1
- package/dist/tab.js +1 -0
- package/dist/tab.js.map +1 -1
- package/dist/table.js +2 -2
- package/dist/tabs.js +1 -0
- package/dist/tabs.js.map +1 -1
- package/dist/test/diagram-controls.test.d.ts +1 -0
- package/dist/test/diagram-geometry.test.d.ts +1 -0
- package/dist/test/diagram.test.d.ts +1 -0
- package/dist/test/erd.test.d.ts +1 -0
- package/dist/test/toggle-label.test.d.ts +1 -0
- package/dist/test/tree-chart.test.d.ts +1 -0
- package/dist/test/workflow-debug.test.d.ts +1 -0
- package/dist/test/workflow.test.d.ts +1 -0
- package/dist/textarea.js +7 -5
- package/dist/textarea.js.map +1 -1
- package/dist/time-field.js +6 -6
- package/dist/time-picker.js +4 -2
- package/dist/time-picker.js.map +1 -1
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BQO5pjrU.js → toggle-base-BlaHalfS.js} +19 -3
- package/dist/toggle-base-BlaHalfS.js.map +1 -0
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +5 -4
- package/dist/transfer-list.js.map +1 -1
- package/dist/{chart-base-B-gOg2Di.js → transform-CxeQFXXB.js} +9 -839
- package/dist/transform-CxeQFXXB.js.map +1 -0
- package/dist/tree-chart.js +1986 -0
- package/dist/tree-chart.js.map +1 -0
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +5 -5
- package/dist/user-menu.js +2 -2
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-format-BsyveyeC.js +34 -0
- package/dist/workflow-format-BsyveyeC.js.map +1 -0
- package/dist/workflow-model-CauduOG2.js +330 -0
- package/dist/workflow-model-CauduOG2.js.map +1 -0
- package/dist/workflow-timeline.js +354 -0
- package/dist/workflow-timeline.js.map +1 -0
- package/dist/workflow.js +3337 -0
- package/dist/workflow.js.map +1 -0
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +44 -2
- package/src/LoaderUtils.ts +9 -2
- package/src/__internal/diagram/canvas-base.ts +410 -0
- package/src/__internal/diagram/canvas-link.ts +66 -0
- package/src/__internal/diagram/geometry.ts +372 -0
- package/src/__internal/diagram/history.ts +49 -0
- package/src/__internal/diagram/host.ts +76 -0
- package/src/__internal/diagram/markers.ts +56 -0
- package/src/__internal/diagram/measure-controller.ts +104 -0
- package/src/__internal/diagram/motion.ts +89 -0
- package/src/__internal/diagram/selection.ts +69 -0
- package/src/__internal/diagram/types.ts +56 -0
- package/src/__internal/diagram/viewport-controller.ts +494 -0
- package/src/__internal/i18n/strings.ts +201 -0
- package/src/__internal/mixins/field.ts +3 -0
- package/src/__internal/mixins/form-associated.ts +2 -0
- package/src/__internal/mixins/form-submitter.ts +6 -0
- package/src/__internal/mixins/hyperlink.ts +10 -0
- package/src/__internal/toggle-base.ts +16 -0
- package/src/__internal/utils/deprecate.ts +5 -4
- package/src/accordion/accordion.ts +1 -0
- package/src/button/base-button/base-button.ts +2 -0
- package/src/code-editor/code-editor.ts +1 -0
- package/src/date-picker/date-picker.ts +2 -0
- package/src/dependency-map/dependency-map-layout.ts +505 -0
- package/src/dependency-map/dependency-map.scss +626 -0
- package/src/dependency-map/dependency-map.ts +1280 -0
- package/src/dependency-map/index.ts +16 -0
- package/src/diagram/diagram.scss +513 -0
- package/src/diagram/diagram.ts +1852 -0
- package/src/diagram/flow.ts +81 -0
- package/src/diagram/index.ts +44 -0
- package/src/diagram-controls/diagram-controls.scss +68 -0
- package/src/diagram-controls/diagram-controls.ts +255 -0
- package/src/diagram-controls/index.ts +1 -0
- package/src/diagram-minimap/diagram-minimap.scss +41 -0
- package/src/diagram-minimap/diagram-minimap.ts +149 -0
- package/src/diagram-minimap/index.ts +1 -0
- package/src/erd/erd-layout.ts +92 -0
- package/src/erd/erd.scss +636 -0
- package/src/erd/erd.ts +1728 -0
- package/src/erd/index.ts +17 -0
- package/src/field/field.scss +197 -23
- package/src/field/field.ts +109 -16
- package/src/file-upload/file-upload.scss +37 -10
- package/src/file-upload/file-upload.ts +3 -1
- package/src/focus-ring/focus-ring.ts +2 -0
- package/src/generative-view/catalog.generated.ts +12 -11
- package/src/index.ts +121 -2
- package/src/input/BaseField.ts +3 -0
- package/src/input/BaseInput.ts +3 -0
- package/src/loader.ts +25 -0
- package/src/mention-input/mention-input.scss +2 -0
- package/src/menu/menu-item/menu-item.ts +1 -0
- package/src/number-field/number-field.ts +4 -0
- package/src/progress/base-progress.ts +3 -0
- package/src/radio/radio-group.ts +1 -0
- package/src/radio/radio.ts +1 -1
- package/src/rating/rating.ts +1 -0
- package/src/ripple/ripple.ts +2 -0
- package/src/signature-pad/signature-pad.ts +1 -0
- package/src/slider/slider.ts +1 -0
- package/src/switch/switch.ts +1 -0
- package/src/tabs/tab.ts +2 -0
- package/src/tabs/tabs.ts +1 -0
- package/src/textarea/textarea.scss +2 -0
- package/src/textarea/textarea.ts +1 -0
- package/src/time-picker/time-picker.ts +2 -0
- package/src/transfer-list/transfer-list.ts +1 -0
- package/src/tree-chart/index.ts +13 -0
- package/src/tree-chart/tree-chart-layout.ts +185 -0
- package/src/tree-chart/tree-chart.scss +377 -0
- package/src/tree-chart/tree-chart.ts +1170 -0
- package/src/workflow/index.ts +35 -0
- package/src/workflow/workflow-format.ts +29 -0
- package/src/workflow/workflow-model.ts +583 -0
- package/src/workflow/workflow.scss +1164 -0
- package/src/workflow/workflow.ts +2674 -0
- package/src/workflow-timeline/index.ts +1 -0
- package/src/workflow-timeline/workflow-timeline.scss +128 -0
- package/src/workflow-timeline/workflow-timeline.ts +238 -0
- package/dist/BaseField-CAog9TIc.js.map +0 -1
- package/dist/BaseInput-CcMfg1Y2.js.map +0 -1
- package/dist/base-button-Do2TUy8M.js.map +0 -1
- package/dist/base-progress-BiLlZVHJ.js.map +0 -1
- package/dist/cartesian-chart-C-f1frt0.js.map +0 -1
- package/dist/chart-base-B-gOg2Di.js.map +0 -1
- package/dist/generative-view-DmtpDobn.js.map +0 -1
- package/dist/hyperlink-DhE9RlVS.js.map +0 -1
- package/dist/src/flow/flow.d.ts +0 -178
- package/dist/src/flow/index.d.ts +0 -2
- package/dist/toggle-base-BQO5pjrU.js.map +0 -1
- package/src/button/button-group/readme.md +0 -23
- package/src/flow/flow.scss +0 -215
- package/src/flow/flow.ts +0 -958
- package/src/flow/index.ts +0 -10
- /package/dist/test/{flow.test.d.ts → dependency-map.test.d.ts} +0 -0
|
@@ -0,0 +1,1280 @@
|
|
|
1
|
+
import { html, nothing, svg, type PropertyValues } from 'lit';
|
|
2
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
5
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
6
|
+
import { DiagramCanvasElement } from '@/__internal/diagram/canvas-base.js';
|
|
7
|
+
import { MeasureController } from '@/__internal/diagram/measure-controller.js';
|
|
8
|
+
import { boundsOf } from '@/__internal/diagram/geometry.js';
|
|
9
|
+
import {
|
|
10
|
+
easeInOutCubic,
|
|
11
|
+
prefersReducedMotion,
|
|
12
|
+
tween,
|
|
13
|
+
} from '@/__internal/diagram/motion.js';
|
|
14
|
+
import type { DiagramOverview } from '@/__internal/diagram/host.js';
|
|
15
|
+
import type {
|
|
16
|
+
DiagramPoint,
|
|
17
|
+
DiagramRect,
|
|
18
|
+
DiagramViewportDetail,
|
|
19
|
+
} from '@/__internal/diagram/types.js';
|
|
20
|
+
import { formatDuration } from '@/workflow/workflow-format.js';
|
|
21
|
+
import {
|
|
22
|
+
forceLayout,
|
|
23
|
+
layeredLayout,
|
|
24
|
+
radialLayout,
|
|
25
|
+
reachable,
|
|
26
|
+
withinHops,
|
|
27
|
+
type MapLayoutEdge,
|
|
28
|
+
type MapLayoutNode,
|
|
29
|
+
} from './dependency-map-layout.js';
|
|
30
|
+
import styles from './dependency-map.scss';
|
|
31
|
+
|
|
32
|
+
export type DependencyMapStatus = 'healthy' | 'degraded' | 'down' | 'unknown';
|
|
33
|
+
|
|
34
|
+
export type DependencyMapLayout = 'force' | 'layered' | 'radial';
|
|
35
|
+
|
|
36
|
+
export type DependencyMapImpact = 'none' | 'upstream' | 'downstream';
|
|
37
|
+
|
|
38
|
+
/** A service, database, queue, host or any other asset. */
|
|
39
|
+
export interface DependencyMapNode {
|
|
40
|
+
id: string;
|
|
41
|
+
/** What it is, for example "Service", "Database" or "Queue". Drives the legend and filters. */
|
|
42
|
+
type?: string;
|
|
43
|
+
headline: string;
|
|
44
|
+
supportingText?: string;
|
|
45
|
+
/** Material Symbols name. */
|
|
46
|
+
icon?: string;
|
|
47
|
+
status?: DependencyMapStatus;
|
|
48
|
+
/** Id of the group (cluster, namespace, business service) it belongs to. */
|
|
49
|
+
group?: string;
|
|
50
|
+
tags?: string[];
|
|
51
|
+
/** Shown on the card when zoomed in, for example `{ rps: '1.2k', p95: '38 ms' }`. */
|
|
52
|
+
metrics?: Record<string, string | number>;
|
|
53
|
+
/** A fixed position, in canvas pixels. */
|
|
54
|
+
position?: DiagramPoint;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A relationship: `source` calls, depends on, runs on or is hosted in `target`. */
|
|
58
|
+
export interface DependencyMapEdge {
|
|
59
|
+
id: string;
|
|
60
|
+
source: string;
|
|
61
|
+
target: string;
|
|
62
|
+
/** What the relationship is, for example "calls" or "runs on". */
|
|
63
|
+
type?: string;
|
|
64
|
+
label?: string;
|
|
65
|
+
status?: DependencyMapStatus;
|
|
66
|
+
metrics?: {
|
|
67
|
+
/** Requests per second: drives the line width. */
|
|
68
|
+
rps?: number;
|
|
69
|
+
/** 95th percentile latency in milliseconds. */
|
|
70
|
+
latencyMs?: number;
|
|
71
|
+
/** Share of failed requests, 0 to 1: drives the line colour. */
|
|
72
|
+
errorRate?: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A box around nodes, such as a cluster, namespace or business service. */
|
|
77
|
+
export interface DependencyMapGroup {
|
|
78
|
+
id: string;
|
|
79
|
+
label: string;
|
|
80
|
+
icon?: string;
|
|
81
|
+
/** Starts collapsed into a single node. */
|
|
82
|
+
collapsed?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Which nodes to show. Leave a field out to show everything for it. */
|
|
86
|
+
export interface DependencyMapFilter {
|
|
87
|
+
types?: string[];
|
|
88
|
+
statuses?: DependencyMapStatus[];
|
|
89
|
+
/** Shows nodes with at least one of these tags. */
|
|
90
|
+
tags?: string[];
|
|
91
|
+
/** Matches the headline and supporting text. */
|
|
92
|
+
text?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Detail of `select`. */
|
|
96
|
+
export interface DependencyMapSelectDetail {
|
|
97
|
+
id: string;
|
|
98
|
+
node?: DependencyMapNode;
|
|
99
|
+
group?: DependencyMapGroup;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Detail of `focus-change`. */
|
|
103
|
+
export interface DependencyMapFocusDetail {
|
|
104
|
+
id: string | null;
|
|
105
|
+
hops: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Detail of `filter-change`. */
|
|
109
|
+
export interface DependencyMapFilterDetail {
|
|
110
|
+
filter: DependencyMapFilter;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Detail of `node-drag-end`. */
|
|
114
|
+
export interface DependencyMapMoveDetail {
|
|
115
|
+
id: string;
|
|
116
|
+
position: DiagramPoint;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Detail of `group-toggle`. */
|
|
120
|
+
export interface DependencyMapGroupDetail {
|
|
121
|
+
id: string;
|
|
122
|
+
collapsed: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Detail of `viewport-change`. */
|
|
126
|
+
export type DependencyMapViewportDetail = DiagramViewportDetail;
|
|
127
|
+
|
|
128
|
+
interface VisibleNode {
|
|
129
|
+
id: string;
|
|
130
|
+
kind: 'node' | 'group';
|
|
131
|
+
node?: DependencyMapNode;
|
|
132
|
+
group?: DependencyMapGroup;
|
|
133
|
+
members: DependencyMapNode[];
|
|
134
|
+
status: DependencyMapStatus;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface VisibleEdge {
|
|
138
|
+
id: string;
|
|
139
|
+
source: string;
|
|
140
|
+
target: string;
|
|
141
|
+
edges: DependencyMapEdge[];
|
|
142
|
+
rps: number;
|
|
143
|
+
latencyMs?: number;
|
|
144
|
+
errorRate: number;
|
|
145
|
+
status?: DependencyMapStatus;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const NODE_SIZE = { width: 200, height: 52 };
|
|
149
|
+
|
|
150
|
+
const STATUS_RANK: Record<DependencyMapStatus, number> = {
|
|
151
|
+
healthy: 0,
|
|
152
|
+
unknown: 1,
|
|
153
|
+
degraded: 2,
|
|
154
|
+
down: 3,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const DRAG_THRESHOLD = 4;
|
|
158
|
+
|
|
159
|
+
const INTERACTIVE = 'button, a, input, wc-icon-button';
|
|
160
|
+
|
|
161
|
+
/** Below this zoom, nodes are drawn as status dots. */
|
|
162
|
+
const DOT_ZOOM = 0.45;
|
|
163
|
+
|
|
164
|
+
/** From this zoom, nodes show their metrics. */
|
|
165
|
+
const DETAIL_ZOOM = 1.2;
|
|
166
|
+
|
|
167
|
+
function worst(
|
|
168
|
+
statuses: (DependencyMapStatus | undefined)[],
|
|
169
|
+
): DependencyMapStatus {
|
|
170
|
+
return statuses.reduce<DependencyMapStatus>(
|
|
171
|
+
(w, s) => (s && STATUS_RANK[s] > STATUS_RANK[w] ? s : w),
|
|
172
|
+
'healthy',
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @label Dependency map
|
|
178
|
+
* @tag wc-dependency-map
|
|
179
|
+
* @rawTag dependency-map
|
|
180
|
+
* @summary An explorable map of connected services and assets: service meshes, CMDB relationships, infrastructure.
|
|
181
|
+
*
|
|
182
|
+
* @overview
|
|
183
|
+
* <p>Set <code>nodes</code>, <code>edges</code> and optionally <code>groups</code>. Each node has a
|
|
184
|
+
* <code>type</code>, a <code>status</code> (healthy, degraded, down) shown as a ring, and an optional
|
|
185
|
+
* <code>group</code> (a cluster, namespace or business service) drawn as a box. Edges get thicker with
|
|
186
|
+
* traffic (<code>metrics.rps</code>) and warmer with errors (<code>metrics.errorRate</code>); hover one
|
|
187
|
+
* for its metrics. A collapsed group becomes one node with combined status and edges.</p>
|
|
188
|
+
* <p><code>layout</code> is <code>force</code> (organic, groups drift together), <code>layered</code>
|
|
189
|
+
* (callers on the left, dependencies on the right) or <code>radial</code> (rings of hops around the
|
|
190
|
+
* focused or selected node). Live updates move as little as possible, and changing layout glides.
|
|
191
|
+
* Drag a node to pin it.</p>
|
|
192
|
+
* <p>Select a node and set <code>impact</code> to <code>upstream</code> to light up everything that
|
|
193
|
+
* depends on it (what breaks if it goes down), or <code>downstream</code> for everything it depends on;
|
|
194
|
+
* the rest dims. <code>focused-node</code> shows only the nodes within <code>hops</code> of one node (press F
|
|
195
|
+
* on a node). <code>filter</code> limits nodes by type, status, tag or text, and the legend's types toggle
|
|
196
|
+
* it. Zoomed out, nodes become status dots; zoomed in, they show their metrics.</p>
|
|
197
|
+
* <p>Nodes are buttons with one tab stop. Down moves to a node it depends on, Up to one that depends
|
|
198
|
+
* on it, Left and Right to the other nodes along that step, Enter selects, F focuses and Escape
|
|
199
|
+
* clears. The canvas is infinite like <code>wc-diagram</code>, with the <code>controls</code> and
|
|
200
|
+
* <code>minimap</code> slots.</p>
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```html
|
|
204
|
+
* <wc-dependency-map id="mesh" style="height: 500px"></wc-dependency-map>
|
|
205
|
+
* <script>
|
|
206
|
+
* const map = document.getElementById('mesh');
|
|
207
|
+
* map.nodes = [
|
|
208
|
+
* { id: 'web', type: 'Service', headline: 'checkout-web', status: 'healthy' },
|
|
209
|
+
* { id: 'api', type: 'Service', headline: 'payments-api', status: 'degraded' },
|
|
210
|
+
* { id: 'db', type: 'Database', headline: 'payments-db', status: 'degraded', icon: 'database' }
|
|
211
|
+
* ];
|
|
212
|
+
* map.edges = [
|
|
213
|
+
* { id: 'e1', source: 'web', target: 'api', metrics: { rps: 420 } },
|
|
214
|
+
* { id: 'e2', source: 'api', target: 'db', metrics: { rps: 1200, errorRate: 0.008 } }
|
|
215
|
+
* ];
|
|
216
|
+
* </script>
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @slot controls - A `wc-diagram-controls`, shown at the bottom start corner.
|
|
220
|
+
* @slot minimap - A `wc-diagram-minimap`, shown at the bottom end corner.
|
|
221
|
+
*
|
|
222
|
+
* @fires {CustomEvent<DependencyMapSelectDetail>} select - A node or collapsed group was chosen. Detail contains `{ id, node, group }`.
|
|
223
|
+
* @fires {CustomEvent<DependencyMapFocusDetail>} focus-change - Focus mode was turned on or off with the keyboard. Detail contains `{ id, hops }`.
|
|
224
|
+
* @fires {CustomEvent<DependencyMapFilterDetail>} filter-change - The legend changed the filter. Detail contains `{ filter }`.
|
|
225
|
+
* @fires {CustomEvent<DependencyMapMoveDetail>} node-drag-end - A dragged node was dropped and pinned there. Detail contains `{ id, position }`.
|
|
226
|
+
* @fires {CustomEvent<DependencyMapGroupDetail>} group-toggle - A group was collapsed or expanded. Detail contains `{ id, collapsed }`.
|
|
227
|
+
* @fires {CustomEvent<DependencyMapViewportDetail>} viewport-change - Once per frame while the camera moves and once when it settles. Detail contains `{ x, y, zoom, settled }`.
|
|
228
|
+
*
|
|
229
|
+
* @cssprop --dependency-map-edge-color - Colour of edges. Defaults to outline.
|
|
230
|
+
* @cssprop --dependency-map-impact-color - Colour of the impact path. Defaults to the orange palette.
|
|
231
|
+
* @cssprop --dependency-map-background - Canvas background. Defaults to surface-container-lowest.
|
|
232
|
+
* @tags data
|
|
233
|
+
*/
|
|
234
|
+
@IndividualComponent
|
|
235
|
+
export class DependencyMap extends DiagramCanvasElement {
|
|
236
|
+
// ── Static
|
|
237
|
+
|
|
238
|
+
static styles = [styles];
|
|
239
|
+
|
|
240
|
+
// ── Properties
|
|
241
|
+
|
|
242
|
+
@property({ attribute: false })
|
|
243
|
+
nodes: DependencyMapNode[] = [];
|
|
244
|
+
|
|
245
|
+
@property({ attribute: false })
|
|
246
|
+
edges: DependencyMapEdge[] = [];
|
|
247
|
+
|
|
248
|
+
@property({ attribute: false })
|
|
249
|
+
groups: DependencyMapGroup[] = [];
|
|
250
|
+
|
|
251
|
+
/** How nodes are arranged. */
|
|
252
|
+
@property({ type: String, reflect: true })
|
|
253
|
+
layout: DependencyMapLayout = 'force';
|
|
254
|
+
|
|
255
|
+
/** Highlights what depends on the selected node (`upstream`) or what it depends on (`downstream`). */
|
|
256
|
+
@property({ type: String, reflect: true })
|
|
257
|
+
impact: DependencyMapImpact = 'none';
|
|
258
|
+
|
|
259
|
+
/** Shows only the nodes within `hops` of this node. */
|
|
260
|
+
@property({ type: String, reflect: true, attribute: 'focused-node' })
|
|
261
|
+
focusedNode = '';
|
|
262
|
+
|
|
263
|
+
/** How far focus mode reaches. */
|
|
264
|
+
@property({ type: Number, reflect: true })
|
|
265
|
+
hops = 2;
|
|
266
|
+
|
|
267
|
+
/** Which nodes to show. */
|
|
268
|
+
@property({ attribute: false })
|
|
269
|
+
filter: DependencyMapFilter = {};
|
|
270
|
+
|
|
271
|
+
/** Id of the selected node or collapsed group. */
|
|
272
|
+
@property({ type: String, reflect: true })
|
|
273
|
+
selected = '';
|
|
274
|
+
|
|
275
|
+
/** Leaves out the legend. */
|
|
276
|
+
@property({ type: Boolean, attribute: 'hide-legend' })
|
|
277
|
+
hideLegend = false;
|
|
278
|
+
|
|
279
|
+
// ── State
|
|
280
|
+
|
|
281
|
+
@state()
|
|
282
|
+
private _collapsedGroups = new Set<string>();
|
|
283
|
+
|
|
284
|
+
@state()
|
|
285
|
+
private _focusId = '';
|
|
286
|
+
|
|
287
|
+
@state()
|
|
288
|
+
private _tooltip?: { x: number; y: number; edge: VisibleEdge };
|
|
289
|
+
|
|
290
|
+
@state()
|
|
291
|
+
private _announcement = '';
|
|
292
|
+
|
|
293
|
+
// ── Private fields
|
|
294
|
+
|
|
295
|
+
@query('.dm-viewport')
|
|
296
|
+
private readonly _viewportEl?: HTMLElement;
|
|
297
|
+
|
|
298
|
+
private readonly measure = new MeasureController(this, {
|
|
299
|
+
elements: () => this.nodeElements(),
|
|
300
|
+
fallback: NODE_SIZE,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
private visibleNodes: VisibleNode[] = [];
|
|
304
|
+
|
|
305
|
+
private visibleById = new Map<string, VisibleNode>();
|
|
306
|
+
|
|
307
|
+
private visibleEdges: VisibleEdge[] = [];
|
|
308
|
+
|
|
309
|
+
private positions = new Map<string, DiagramPoint>();
|
|
310
|
+
|
|
311
|
+
private overrides = new Map<string, DiagramPoint>();
|
|
312
|
+
|
|
313
|
+
private pinned = new Map<string, DiagramPoint>();
|
|
314
|
+
|
|
315
|
+
private layoutKey = '';
|
|
316
|
+
|
|
317
|
+
private stopGlide?: () => void;
|
|
318
|
+
|
|
319
|
+
private seenGroups = new Set<string>();
|
|
320
|
+
|
|
321
|
+
/** The step keyboard navigation last took, for Left and Right. */
|
|
322
|
+
private navStep?: { from: string; direction: 'up' | 'down' };
|
|
323
|
+
|
|
324
|
+
private nodeDrag?: {
|
|
325
|
+
pointerId: number;
|
|
326
|
+
startX: number;
|
|
327
|
+
startY: number;
|
|
328
|
+
id: string;
|
|
329
|
+
origin: DiagramPoint;
|
|
330
|
+
element: HTMLElement;
|
|
331
|
+
moved: boolean;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// ── Lifecycle
|
|
335
|
+
|
|
336
|
+
disconnectedCallback() {
|
|
337
|
+
super.disconnectedCallback();
|
|
338
|
+
this.stopGlide?.();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
protected willUpdate(changed: PropertyValues<this>) {
|
|
342
|
+
super.willUpdate(changed);
|
|
343
|
+
if (changed.has('groups')) {
|
|
344
|
+
let next: Set<string> | undefined;
|
|
345
|
+
for (const g of this.groups) {
|
|
346
|
+
if (g.collapsed && !this.seenGroups.has(g.id)) {
|
|
347
|
+
this.seenGroups.add(g.id);
|
|
348
|
+
next = next ?? new Set(this._collapsedGroups);
|
|
349
|
+
next.add(g.id);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (next) this._collapsedGroups = next;
|
|
353
|
+
}
|
|
354
|
+
if (changed.has('nodes')) {
|
|
355
|
+
for (const n of this.nodes)
|
|
356
|
+
if (n.position) this.pinned.set(n.id, n.position);
|
|
357
|
+
}
|
|
358
|
+
if (
|
|
359
|
+
[
|
|
360
|
+
'nodes',
|
|
361
|
+
'edges',
|
|
362
|
+
'groups',
|
|
363
|
+
'filter',
|
|
364
|
+
'focusedNode',
|
|
365
|
+
'hops',
|
|
366
|
+
'layout',
|
|
367
|
+
'_collapsedGroups',
|
|
368
|
+
].some(k => changed.has(k as keyof DependencyMap)) ||
|
|
369
|
+
(this.layout === 'radial' && changed.has('selected'))
|
|
370
|
+
) {
|
|
371
|
+
this.buildGraph();
|
|
372
|
+
this.runLayout();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// ── Public API
|
|
377
|
+
|
|
378
|
+
/** The map has no undo; these keep the canvas contract. */
|
|
379
|
+
get canUndo(): boolean {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
get canRedo(): boolean {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// eslint-disable-next-line class-methods-use-this
|
|
388
|
+
undo() {
|
|
389
|
+
// Nothing to undo.
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// eslint-disable-next-line class-methods-use-this
|
|
393
|
+
redo() {
|
|
394
|
+
// Nothing to redo.
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/** Lays the map out again from scratch, keeping pinned nodes. */
|
|
398
|
+
relayout() {
|
|
399
|
+
this.layoutKey = '';
|
|
400
|
+
const previous = this.positions;
|
|
401
|
+
this.positions = new Map();
|
|
402
|
+
this.runLayout(previous);
|
|
403
|
+
this.requestUpdate();
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/** Forgets every pinned position and lays the map out again. */
|
|
407
|
+
unpinAll() {
|
|
408
|
+
this.pinned.clear();
|
|
409
|
+
this.relayout();
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** Shows only the nodes within `hops` of a node. */
|
|
413
|
+
focusOn(id: string, hops = this.hops) {
|
|
414
|
+
this.hops = hops;
|
|
415
|
+
this.focusedNode = id;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
clearFocus() {
|
|
419
|
+
this.focusedNode = '';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Selects a node as a click would and brings it into view. */
|
|
423
|
+
selectNode(id: string) {
|
|
424
|
+
const v = this.visibleById.get(id);
|
|
425
|
+
if (!v) return;
|
|
426
|
+
this.select(v);
|
|
427
|
+
this.moveFocusTo(id);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
collapseGroup(id: string) {
|
|
431
|
+
this.toggleGroup(id, true);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
expandGroup(id: string) {
|
|
435
|
+
this.toggleGroup(id, false);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// ── Canvas hooks
|
|
439
|
+
|
|
440
|
+
protected viewportElement() {
|
|
441
|
+
return this._viewportEl;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
protected contentBounds(): DiagramRect | undefined {
|
|
445
|
+
return boundsOf(this.visibleNodes.map(v => this.rectOf(v.id)));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
protected selectionRects(): DiagramRect[] {
|
|
449
|
+
return this.visibleById.has(this.selected)
|
|
450
|
+
? [this.rectOf(this.selected)]
|
|
451
|
+
: [];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
protected itemRect(id: string): DiagramRect | undefined {
|
|
455
|
+
return this.visibleById.has(id) ? this.rectOf(id) : undefined;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
protected firstItemRect(): DiagramRect | undefined {
|
|
459
|
+
const first = this.visibleNodes[0];
|
|
460
|
+
return first ? this.rectOf(first.id) : undefined;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
protected overviewItems(): DiagramOverview['items'] {
|
|
464
|
+
return this.visibleNodes.map(v => ({
|
|
465
|
+
...this.rectOf(v.id),
|
|
466
|
+
selected: v.id === this.selected,
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
protected isBackground(target: EventTarget | null): boolean {
|
|
471
|
+
const el = target as Element | null;
|
|
472
|
+
if (!el) return false;
|
|
473
|
+
return (
|
|
474
|
+
el === this._viewportEl ||
|
|
475
|
+
['dm-world', 'dm-edges', 'dm-nodes', 'dm-groups', 'dm-group'].some(c =>
|
|
476
|
+
el.classList?.contains(c),
|
|
477
|
+
)
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
protected onBackgroundClick() {
|
|
482
|
+
this.selected = '';
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// ── Private methods: graph
|
|
486
|
+
|
|
487
|
+
/** Applies filter, focus and collapsed groups to get what is drawn. */
|
|
488
|
+
private buildGraph() {
|
|
489
|
+
const f = this.filter ?? {};
|
|
490
|
+
const text = f.text?.trim().toLowerCase();
|
|
491
|
+
const pass = (n: DependencyMapNode) =>
|
|
492
|
+
(!f.types || !n.type || f.types.includes(n.type)) &&
|
|
493
|
+
(!f.statuses || f.statuses.includes(n.status ?? 'unknown')) &&
|
|
494
|
+
(!f.tags || f.tags.some(t => n.tags?.includes(t))) &&
|
|
495
|
+
(!text ||
|
|
496
|
+
n.headline.toLowerCase().includes(text) ||
|
|
497
|
+
(n.supportingText ?? '').toLowerCase().includes(text));
|
|
498
|
+
let shown = this.nodes.filter(pass);
|
|
499
|
+
let ids = new Set(shown.map(n => n.id));
|
|
500
|
+
let edges = this.edges.filter(e => ids.has(e.source) && ids.has(e.target));
|
|
501
|
+
if (this.focusedNode && ids.has(this.focusedNode)) {
|
|
502
|
+
const near = withinHops(this.focusedNode, edges, this.hops);
|
|
503
|
+
shown = shown.filter(n => near.has(n.id));
|
|
504
|
+
ids = near;
|
|
505
|
+
edges = edges.filter(e => near.has(e.source) && near.has(e.target));
|
|
506
|
+
}
|
|
507
|
+
const groupsById = new Map(this.groups.map(g => [g.id, g]));
|
|
508
|
+
const repr = (n: DependencyMapNode) =>
|
|
509
|
+
n.group && this._collapsedGroups.has(n.group) && groupsById.has(n.group)
|
|
510
|
+
? `group:${n.group}`
|
|
511
|
+
: n.id;
|
|
512
|
+
const visible = new Map<string, VisibleNode>();
|
|
513
|
+
for (const n of shown) {
|
|
514
|
+
const id = repr(n);
|
|
515
|
+
const existing = visible.get(id);
|
|
516
|
+
if (id === n.id) {
|
|
517
|
+
visible.set(id, {
|
|
518
|
+
id,
|
|
519
|
+
kind: 'node',
|
|
520
|
+
node: n,
|
|
521
|
+
members: [n],
|
|
522
|
+
status: n.status ?? 'unknown',
|
|
523
|
+
});
|
|
524
|
+
} else if (existing) {
|
|
525
|
+
existing.members.push(n);
|
|
526
|
+
existing.status = worst(existing.members.map(m => m.status));
|
|
527
|
+
} else {
|
|
528
|
+
visible.set(id, {
|
|
529
|
+
id,
|
|
530
|
+
kind: 'group',
|
|
531
|
+
group: groupsById.get(n.group ?? ''),
|
|
532
|
+
members: [n],
|
|
533
|
+
status: n.status ?? 'unknown',
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const byNode = new Map(shown.map(n => [n.id, repr(n)]));
|
|
538
|
+
const merged = new Map<string, VisibleEdge>();
|
|
539
|
+
for (const e of edges) {
|
|
540
|
+
const source = byNode.get(e.source);
|
|
541
|
+
const target = byNode.get(e.target);
|
|
542
|
+
if (source && target && source !== target) {
|
|
543
|
+
const key = `${source}\u0000${target}`;
|
|
544
|
+
const m = merged.get(key);
|
|
545
|
+
if (m) {
|
|
546
|
+
m.edges.push(e);
|
|
547
|
+
m.rps += e.metrics?.rps ?? 0;
|
|
548
|
+
m.errorRate = Math.max(m.errorRate, e.metrics?.errorRate ?? 0);
|
|
549
|
+
m.latencyMs =
|
|
550
|
+
Math.max(m.latencyMs ?? 0, e.metrics?.latencyMs ?? 0) || undefined;
|
|
551
|
+
m.status = worst([m.status, e.status]);
|
|
552
|
+
} else {
|
|
553
|
+
merged.set(key, {
|
|
554
|
+
id:
|
|
555
|
+
source === e.source && target === e.target ? e.id : `agg:${key}`,
|
|
556
|
+
source,
|
|
557
|
+
target,
|
|
558
|
+
edges: [e],
|
|
559
|
+
rps: e.metrics?.rps ?? 0,
|
|
560
|
+
latencyMs: e.metrics?.latencyMs,
|
|
561
|
+
errorRate: e.metrics?.errorRate ?? 0,
|
|
562
|
+
status: e.status,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
this.visibleNodes = [...visible.values()];
|
|
568
|
+
this.visibleById = visible;
|
|
569
|
+
this.visibleEdges = [...merged.values()];
|
|
570
|
+
if (this.selected && !visible.has(this.selected)) this.selected = '';
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** Lays the visible graph out when its shape changed, gliding from the old positions. */
|
|
574
|
+
private runLayout(previous = this.positions) {
|
|
575
|
+
const center =
|
|
576
|
+
this.layout === 'radial'
|
|
577
|
+
? (this.visibleById.has(this.focusedNode) && this.focusedNode) ||
|
|
578
|
+
(this.visibleById.has(this.selected) && this.selected) ||
|
|
579
|
+
undefined
|
|
580
|
+
: undefined;
|
|
581
|
+
const key = [
|
|
582
|
+
this.layout,
|
|
583
|
+
center,
|
|
584
|
+
this.visibleNodes.map(v => v.id).join(','),
|
|
585
|
+
this.visibleEdges.map(e => `${e.source}>${e.target}`).join(','),
|
|
586
|
+
].join('|');
|
|
587
|
+
if (key === this.layoutKey) return;
|
|
588
|
+
this.layoutKey = key;
|
|
589
|
+
this._tooltip = undefined;
|
|
590
|
+
const nodes: MapLayoutNode[] = this.visibleNodes.map(v => ({
|
|
591
|
+
id: v.id,
|
|
592
|
+
group: v.kind === 'node' ? v.node?.group : undefined,
|
|
593
|
+
pinned: this.pinned.get(v.id),
|
|
594
|
+
}));
|
|
595
|
+
const edges: MapLayoutEdge[] = this.visibleEdges.map(e => ({
|
|
596
|
+
source: e.source,
|
|
597
|
+
target: e.target,
|
|
598
|
+
}));
|
|
599
|
+
const options = {
|
|
600
|
+
nodeWidth: NODE_SIZE.width,
|
|
601
|
+
nodeHeight: NODE_SIZE.height,
|
|
602
|
+
previous,
|
|
603
|
+
center,
|
|
604
|
+
};
|
|
605
|
+
let next: Map<string, DiagramPoint>;
|
|
606
|
+
if (this.layout === 'layered') next = layeredLayout(nodes, edges, options);
|
|
607
|
+
else if (this.layout === 'radial')
|
|
608
|
+
next = radialLayout(nodes, edges, options);
|
|
609
|
+
else next = forceLayout(nodes, edges, options);
|
|
610
|
+
this.glide(previous, next);
|
|
611
|
+
this.positions = next;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
private glide(
|
|
615
|
+
from: Map<string, DiagramPoint>,
|
|
616
|
+
to: Map<string, DiagramPoint>,
|
|
617
|
+
) {
|
|
618
|
+
this.stopGlide?.();
|
|
619
|
+
this.overrides.clear();
|
|
620
|
+
if (!from.size || prefersReducedMotion() || !this.startApplied) return;
|
|
621
|
+
const moving = [...to].filter(([id, p]) => {
|
|
622
|
+
const f = from.get(id);
|
|
623
|
+
return f && (f.x !== p.x || f.y !== p.y);
|
|
624
|
+
});
|
|
625
|
+
if (!moving.length) return;
|
|
626
|
+
this.stopGlide = tween({
|
|
627
|
+
duration: 450,
|
|
628
|
+
easing: easeInOutCubic,
|
|
629
|
+
onUpdate: t => {
|
|
630
|
+
for (const [id, p] of moving) {
|
|
631
|
+
const f = from.get(id) ?? p;
|
|
632
|
+
this.overrides.set(id, {
|
|
633
|
+
x: f.x + (p.x - f.x) * t,
|
|
634
|
+
y: f.y + (p.y - f.y) * t,
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
this.requestUpdate();
|
|
638
|
+
},
|
|
639
|
+
onDone: () => {
|
|
640
|
+
this.overrides.clear();
|
|
641
|
+
this.stopGlide = undefined;
|
|
642
|
+
this.requestUpdate();
|
|
643
|
+
},
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
private centerOf(id: string): DiagramPoint {
|
|
648
|
+
return this.overrides.get(id) ?? this.positions.get(id) ?? { x: 0, y: 0 };
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
private rectOf(id: string): DiagramRect {
|
|
652
|
+
const c = this.centerOf(id);
|
|
653
|
+
const s = this.measure.size(id);
|
|
654
|
+
return {
|
|
655
|
+
x: c.x - s.width / 2,
|
|
656
|
+
y: c.y - s.height / 2,
|
|
657
|
+
width: s.width,
|
|
658
|
+
height: s.height,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
private neighbours(id: string, direction: 'up' | 'down'): string[] {
|
|
663
|
+
const ids = this.visibleEdges
|
|
664
|
+
.filter(e => (direction === 'down' ? e.source === id : e.target === id))
|
|
665
|
+
.map(e => (direction === 'down' ? e.target : e.source));
|
|
666
|
+
const vertical = this.layout !== 'layered';
|
|
667
|
+
return ids.sort((a, b) =>
|
|
668
|
+
vertical
|
|
669
|
+
? this.centerOf(a).x - this.centerOf(b).x
|
|
670
|
+
: this.centerOf(a).y - this.centerOf(b).y,
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
private impactSet(): Set<string> | undefined {
|
|
675
|
+
if (this.impact === 'none' || !this.visibleById.has(this.selected))
|
|
676
|
+
return undefined;
|
|
677
|
+
return reachable(this.selected, this.visibleEdges, this.impact);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// ── Private methods: interaction
|
|
681
|
+
|
|
682
|
+
private announce(message: string) {
|
|
683
|
+
this._announcement = '';
|
|
684
|
+
requestAnimationFrame(() => {
|
|
685
|
+
this._announcement = message;
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
private select(v: VisibleNode) {
|
|
690
|
+
this.selected = v.id;
|
|
691
|
+
this.emit<DependencyMapSelectDetail>('select', {
|
|
692
|
+
id: v.id,
|
|
693
|
+
node: v.node,
|
|
694
|
+
group: v.group,
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
private moveFocusTo(id: string) {
|
|
699
|
+
this._focusId = id;
|
|
700
|
+
this.updateComplete.then(() => {
|
|
701
|
+
this.nodeElement(id)?.focus({ preventScroll: true });
|
|
702
|
+
const r = this.itemRect(id);
|
|
703
|
+
const view = this.viewport.visibleRect();
|
|
704
|
+
if (
|
|
705
|
+
r &&
|
|
706
|
+
(r.x < view.x ||
|
|
707
|
+
r.y < view.y ||
|
|
708
|
+
r.x + r.width > view.x + view.width ||
|
|
709
|
+
r.y + r.height > view.y + view.height)
|
|
710
|
+
) {
|
|
711
|
+
this.centerOn(r.x + r.width / 2, r.y + r.height / 2);
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
private toggleGroup(id: string, collapsed: boolean) {
|
|
717
|
+
const next = new Set(this._collapsedGroups);
|
|
718
|
+
if (collapsed) next.add(id);
|
|
719
|
+
else next.delete(id);
|
|
720
|
+
this._collapsedGroups = next;
|
|
721
|
+
this.emit<DependencyMapGroupDetail>('group-toggle', { id, collapsed });
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
private toggleType(type: string, allTypes: string[]) {
|
|
725
|
+
const current = this.filter.types ?? allTypes;
|
|
726
|
+
const types = current.includes(type)
|
|
727
|
+
? current.filter(t => t !== type)
|
|
728
|
+
: [...current, type];
|
|
729
|
+
this.filter = {
|
|
730
|
+
...this.filter,
|
|
731
|
+
types: types.length === allTypes.length ? undefined : types,
|
|
732
|
+
};
|
|
733
|
+
this.emit<DependencyMapFilterDetail>('filter-change', {
|
|
734
|
+
filter: this.filter,
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
private onNodeKeyDown(event: KeyboardEvent, v: VisibleNode) {
|
|
739
|
+
if (event.target !== event.currentTarget) return;
|
|
740
|
+
const done = (fn: () => void) => {
|
|
741
|
+
event.preventDefault();
|
|
742
|
+
event.stopPropagation();
|
|
743
|
+
fn();
|
|
744
|
+
};
|
|
745
|
+
const { key } = event;
|
|
746
|
+
if (key === 'Enter' || key === ' ') {
|
|
747
|
+
done(() => {
|
|
748
|
+
if (
|
|
749
|
+
v.kind === 'group' &&
|
|
750
|
+
v.group &&
|
|
751
|
+
key === 'Enter' &&
|
|
752
|
+
event.shiftKey
|
|
753
|
+
) {
|
|
754
|
+
this.expandGroup(v.group.id);
|
|
755
|
+
} else this.select(v);
|
|
756
|
+
});
|
|
757
|
+
} else if (key === 'ArrowDown' || key === 'ArrowUp') {
|
|
758
|
+
const direction = key === 'ArrowDown' ? 'down' : 'up';
|
|
759
|
+
const next = this.neighbours(v.id, direction)[0];
|
|
760
|
+
if (next) {
|
|
761
|
+
done(() => {
|
|
762
|
+
this.navStep = { from: v.id, direction };
|
|
763
|
+
this.moveFocusTo(next);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
} else if (key === 'ArrowLeft' || key === 'ArrowRight') {
|
|
767
|
+
const step = this.navStep;
|
|
768
|
+
const row = step ? this.neighbours(step.from, step.direction) : [];
|
|
769
|
+
const at = row.indexOf(v.id);
|
|
770
|
+
const rtl = getComputedStyle(this).direction === 'rtl';
|
|
771
|
+
const delta = (key === 'ArrowRight') !== rtl ? 1 : -1;
|
|
772
|
+
const next = at >= 0 ? row[at + delta] : undefined;
|
|
773
|
+
if (next) done(() => this.moveFocusTo(next));
|
|
774
|
+
} else if (key === 'f' || key === 'F') {
|
|
775
|
+
done(() => {
|
|
776
|
+
const id = this.focusedNode === v.id ? '' : v.id;
|
|
777
|
+
this.focusedNode = id;
|
|
778
|
+
this.emit<DependencyMapFocusDetail>('focus-change', {
|
|
779
|
+
id: id || null,
|
|
780
|
+
hops: this.hops,
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
} else if (key === 'Home' && this.visibleNodes[0]) {
|
|
784
|
+
done(() => this.moveFocusTo(this.visibleNodes[0].id));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
private onViewportKeyDown = (event: KeyboardEvent) => {
|
|
789
|
+
if (event.defaultPrevented) return;
|
|
790
|
+
if (event.key === 'Escape') {
|
|
791
|
+
event.preventDefault();
|
|
792
|
+
if (this.focusedNode) {
|
|
793
|
+
this.focusedNode = '';
|
|
794
|
+
this.emit<DependencyMapFocusDetail>('focus-change', {
|
|
795
|
+
id: null,
|
|
796
|
+
hops: this.hops,
|
|
797
|
+
});
|
|
798
|
+
} else this.selected = '';
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
this.handleCanvasKey(event);
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
private onNodePointerDown(event: PointerEvent, v: VisibleNode) {
|
|
805
|
+
if (event.button !== 0 || this.viewport.spaceHeld) return;
|
|
806
|
+
const origin = event.composedPath()[0];
|
|
807
|
+
if (origin instanceof Element && origin.closest(INTERACTIVE)) return;
|
|
808
|
+
event.stopPropagation();
|
|
809
|
+
const element = event.currentTarget as HTMLElement;
|
|
810
|
+
element.focus({ preventScroll: true });
|
|
811
|
+
this._focusId = v.id;
|
|
812
|
+
this.nodeDrag = {
|
|
813
|
+
pointerId: event.pointerId,
|
|
814
|
+
startX: event.clientX,
|
|
815
|
+
startY: event.clientY,
|
|
816
|
+
id: v.id,
|
|
817
|
+
origin: this.centerOf(v.id),
|
|
818
|
+
element,
|
|
819
|
+
moved: false,
|
|
820
|
+
};
|
|
821
|
+
try {
|
|
822
|
+
element.setPointerCapture(event.pointerId);
|
|
823
|
+
} catch {
|
|
824
|
+
// Synthetic pointers cannot be captured.
|
|
825
|
+
}
|
|
826
|
+
element.addEventListener('pointermove', this.onDragMove);
|
|
827
|
+
element.addEventListener('pointerup', this.onDragUp);
|
|
828
|
+
element.addEventListener('pointercancel', this.onDragUp);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
private onDragMove = (event: PointerEvent) => {
|
|
832
|
+
const drag = this.nodeDrag;
|
|
833
|
+
if (!drag || event.pointerId !== drag.pointerId || this.readonly) return;
|
|
834
|
+
const { zoom } = this.viewport.view;
|
|
835
|
+
const dx = (event.clientX - drag.startX) / zoom;
|
|
836
|
+
const dy = (event.clientY - drag.startY) / zoom;
|
|
837
|
+
if (!drag.moved && Math.hypot(dx * zoom, dy * zoom) < DRAG_THRESHOLD)
|
|
838
|
+
return;
|
|
839
|
+
drag.moved = true;
|
|
840
|
+
const position = { x: drag.origin.x + dx, y: drag.origin.y + dy };
|
|
841
|
+
this.positions.set(drag.id, position);
|
|
842
|
+
this.pinned.set(drag.id, position);
|
|
843
|
+
this.requestUpdate();
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
private onDragUp = (event: PointerEvent) => {
|
|
847
|
+
const drag = this.nodeDrag;
|
|
848
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
849
|
+
this.nodeDrag = undefined;
|
|
850
|
+
drag.element.removeEventListener('pointermove', this.onDragMove);
|
|
851
|
+
drag.element.removeEventListener('pointerup', this.onDragUp);
|
|
852
|
+
drag.element.removeEventListener('pointercancel', this.onDragUp);
|
|
853
|
+
try {
|
|
854
|
+
if (drag.element.hasPointerCapture(drag.pointerId)) {
|
|
855
|
+
drag.element.releasePointerCapture(drag.pointerId);
|
|
856
|
+
}
|
|
857
|
+
} catch {
|
|
858
|
+
// The pointer is already gone.
|
|
859
|
+
}
|
|
860
|
+
const v = this.visibleById.get(drag.id);
|
|
861
|
+
if (!v) return;
|
|
862
|
+
if (drag.moved) {
|
|
863
|
+
this.emit<DependencyMapMoveDetail>('node-drag-end', {
|
|
864
|
+
id: drag.id,
|
|
865
|
+
position: this.centerOf(drag.id),
|
|
866
|
+
});
|
|
867
|
+
} else this.select(v);
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
private nodeElements(): [string, HTMLElement][] {
|
|
871
|
+
const out: [string, HTMLElement][] = [];
|
|
872
|
+
this.renderRoot.querySelectorAll<HTMLElement>('.dm-node').forEach(el => {
|
|
873
|
+
if (el.dataset.id) out.push([el.dataset.id, el]);
|
|
874
|
+
});
|
|
875
|
+
return out;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
private nodeElement(id: string): HTMLElement | null {
|
|
879
|
+
return this.renderRoot.querySelector<HTMLElement>(
|
|
880
|
+
`.dm-node[data-id="${CSS.escape(id)}"]`,
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// ── Render helpers
|
|
885
|
+
|
|
886
|
+
private statusLabel(status: DependencyMapStatus): string {
|
|
887
|
+
return this.i18n.t(
|
|
888
|
+
(
|
|
889
|
+
{
|
|
890
|
+
healthy: 'dependencyMapHealthy',
|
|
891
|
+
degraded: 'dependencyMapDegraded',
|
|
892
|
+
down: 'dependencyMapDown',
|
|
893
|
+
unknown: 'dependencyMapUnknown',
|
|
894
|
+
} as const
|
|
895
|
+
)[status],
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
private formatRps(rps: number): string {
|
|
900
|
+
return new Intl.NumberFormat(this.i18n.locale, {
|
|
901
|
+
notation: 'compact',
|
|
902
|
+
maximumFractionDigits: 1,
|
|
903
|
+
}).format(rps);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/** The point where the line from `center` toward `toward` leaves the node's box. */
|
|
907
|
+
private exitPoint(id: string, toward: DiagramPoint): DiagramPoint {
|
|
908
|
+
const c = this.centerOf(id);
|
|
909
|
+
const s = this.measure.size(id);
|
|
910
|
+
const dx = toward.x - c.x;
|
|
911
|
+
const dy = toward.y - c.y;
|
|
912
|
+
if (!dx && !dy) return c;
|
|
913
|
+
const scale = Math.min(
|
|
914
|
+
dx ? (s.width / 2 + 4) / Math.abs(dx) : Infinity,
|
|
915
|
+
dy ? (s.height / 2 + 4) / Math.abs(dy) : Infinity,
|
|
916
|
+
);
|
|
917
|
+
return { x: c.x + dx * scale, y: c.y + dy * scale };
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
private renderEdges(impact: Set<string> | undefined, shown: Set<string>) {
|
|
921
|
+
const maxRps = Math.max(1, ...this.visibleEdges.map(e => e.rps));
|
|
922
|
+
return this.visibleEdges
|
|
923
|
+
.filter(e => shown.has(e.source) || shown.has(e.target))
|
|
924
|
+
.map(e => {
|
|
925
|
+
const a = this.centerOf(e.source);
|
|
926
|
+
const b = this.centerOf(e.target);
|
|
927
|
+
const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;
|
|
928
|
+
// A gentle bend, always to the same side of the direction of travel.
|
|
929
|
+
const ctrl = {
|
|
930
|
+
x: (a.x + b.x) / 2 - ((b.y - a.y) / len) * len * 0.08,
|
|
931
|
+
y: (a.y + b.y) / 2 + ((b.x - a.x) / len) * len * 0.08,
|
|
932
|
+
};
|
|
933
|
+
const start = this.exitPoint(e.source, ctrl);
|
|
934
|
+
const end = this.exitPoint(e.target, ctrl);
|
|
935
|
+
const width =
|
|
936
|
+
1.5 + 4 * (Math.log10(1 + e.rps) / Math.log10(1 + maxRps));
|
|
937
|
+
const angle = Math.atan2(end.y - ctrl.y, end.x - ctrl.x);
|
|
938
|
+
const size = 6 + width;
|
|
939
|
+
const tip = `M ${end.x} ${end.y} L ${end.x - size * Math.cos(angle - 0.45)} ${end.y - size * Math.sin(angle - 0.45)} L ${end.x - size * Math.cos(angle + 0.45)} ${end.y - size * Math.sin(angle + 0.45)} Z`;
|
|
940
|
+
const onImpact =
|
|
941
|
+
!!impact &&
|
|
942
|
+
impact.has(e.source) &&
|
|
943
|
+
impact.has(e.target) &&
|
|
944
|
+
(this.impact === 'upstream' ? impact.has(e.source) : true);
|
|
945
|
+
let tone = '';
|
|
946
|
+
if (e.status === 'down' || e.errorRate >= 0.05) tone = 'is-error';
|
|
947
|
+
else if (e.status === 'degraded' || e.errorRate >= 0.01)
|
|
948
|
+
tone = 'is-warning';
|
|
949
|
+
const d = `M ${start.x} ${start.y} Q ${ctrl.x} ${ctrl.y} ${end.x} ${end.y}`;
|
|
950
|
+
const mid = {
|
|
951
|
+
x: (start.x + 2 * ctrl.x + end.x) / 4,
|
|
952
|
+
y: (start.y + 2 * ctrl.y + end.y) / 4,
|
|
953
|
+
};
|
|
954
|
+
const showCount = e.edges.length > 1;
|
|
955
|
+
return svg`<g class=${classMap({
|
|
956
|
+
'dm-edge': true,
|
|
957
|
+
[tone]: !!tone,
|
|
958
|
+
'is-impact': onImpact,
|
|
959
|
+
'is-dim': !!impact && !onImpact,
|
|
960
|
+
'is-down': e.status === 'down',
|
|
961
|
+
})}>
|
|
962
|
+
<path class="dm-edge-line" d=${d} style="stroke-width: ${width}"></path>
|
|
963
|
+
<path class="dm-edge-tip" d=${tip}></path>
|
|
964
|
+
<path
|
|
965
|
+
class="dm-edge-hit"
|
|
966
|
+
d=${d}
|
|
967
|
+
@pointerenter=${(ev: PointerEvent) => this.showTooltip(ev, e)}
|
|
968
|
+
@pointermove=${(ev: PointerEvent) => this.showTooltip(ev, e)}
|
|
969
|
+
@pointerleave=${() => {
|
|
970
|
+
this._tooltip = undefined;
|
|
971
|
+
}}
|
|
972
|
+
></path>
|
|
973
|
+
${
|
|
974
|
+
showCount
|
|
975
|
+
? svg`<text class="dm-edge-count" x=${mid.x} y=${mid.y - 6}>${this.i18n.t('dependencyMapEdgeCount')(e.edges.length)}</text>`
|
|
976
|
+
: nothing
|
|
977
|
+
}
|
|
978
|
+
</g>`;
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
private showTooltip(event: PointerEvent, edge: VisibleEdge) {
|
|
983
|
+
const vr = this._viewportEl?.getBoundingClientRect();
|
|
984
|
+
this._tooltip = {
|
|
985
|
+
x: event.clientX - (vr?.left ?? 0),
|
|
986
|
+
y: event.clientY - (vr?.top ?? 0),
|
|
987
|
+
edge,
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
private renderTooltip() {
|
|
992
|
+
const t = this._tooltip;
|
|
993
|
+
if (!t) return nothing;
|
|
994
|
+
const { edge } = t;
|
|
995
|
+
const name = (id: string) => {
|
|
996
|
+
const v = this.visibleById.get(id);
|
|
997
|
+
return v?.node?.headline ?? v?.group?.label ?? id;
|
|
998
|
+
};
|
|
999
|
+
const parts = [
|
|
1000
|
+
edge.edges[0]?.type ?? edge.edges[0]?.label,
|
|
1001
|
+
edge.rps ? this.i18n.t('dependencyMapRps')(this.formatRps(edge.rps)) : '',
|
|
1002
|
+
edge.latencyMs
|
|
1003
|
+
? this.i18n.t('dependencyMapLatency')(
|
|
1004
|
+
formatDuration(edge.latencyMs, this.i18n.locale),
|
|
1005
|
+
)
|
|
1006
|
+
: '',
|
|
1007
|
+
edge.errorRate
|
|
1008
|
+
? this.i18n.t('dependencyMapErrors')(
|
|
1009
|
+
new Intl.NumberFormat(this.i18n.locale, {
|
|
1010
|
+
style: 'percent',
|
|
1011
|
+
maximumFractionDigits: 1,
|
|
1012
|
+
}).format(edge.errorRate),
|
|
1013
|
+
)
|
|
1014
|
+
: '',
|
|
1015
|
+
].filter(Boolean);
|
|
1016
|
+
return html`<div
|
|
1017
|
+
class="dm-tooltip"
|
|
1018
|
+
aria-hidden="true"
|
|
1019
|
+
style="left: ${t.x + 14}px; top: ${t.y + 14}px;"
|
|
1020
|
+
>
|
|
1021
|
+
<strong>${name(edge.source)} → ${name(edge.target)}</strong>
|
|
1022
|
+
${parts.length ? html`<span>${parts.join(' · ')}</span>` : nothing}
|
|
1023
|
+
</div>`;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
private renderGroups() {
|
|
1027
|
+
// Rings of hops cut across groups, so a radial map draws no group boxes.
|
|
1028
|
+
if (this.layout === 'radial') return [];
|
|
1029
|
+
const out = [];
|
|
1030
|
+
for (const g of this.groups) {
|
|
1031
|
+
const members = this.visibleNodes.filter(
|
|
1032
|
+
v => v.kind === 'node' && v.node?.group === g.id,
|
|
1033
|
+
);
|
|
1034
|
+
if (members.length && !this._collapsedGroups.has(g.id)) {
|
|
1035
|
+
const b = boundsOf(members.map(m => this.rectOf(m.id)));
|
|
1036
|
+
if (b) {
|
|
1037
|
+
const status = worst(members.map(m => m.status));
|
|
1038
|
+
out.push(
|
|
1039
|
+
html`<div
|
|
1040
|
+
class=${classMap({ 'dm-group': true, [`st-${status}`]: true })}
|
|
1041
|
+
style="left: ${b.x - 28}px; top: ${b.y - 44}px; width: ${b.width +
|
|
1042
|
+
56}px; height: ${b.height + 72}px;"
|
|
1043
|
+
>
|
|
1044
|
+
<span class="dm-group-label">
|
|
1045
|
+
<wc-icon name=${g.icon ?? 'lan'}></wc-icon>${g.label}
|
|
1046
|
+
<button
|
|
1047
|
+
type="button"
|
|
1048
|
+
class="dm-group-toggle"
|
|
1049
|
+
aria-label=${this.i18n.t('dependencyMapCollapseGroup')(
|
|
1050
|
+
g.label,
|
|
1051
|
+
)}
|
|
1052
|
+
@click=${() => this.collapseGroup(g.id)}
|
|
1053
|
+
>
|
|
1054
|
+
<wc-icon name="unfold_less"></wc-icon>
|
|
1055
|
+
</button>
|
|
1056
|
+
</span>
|
|
1057
|
+
</div>`,
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
return out;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
private renderNode(
|
|
1066
|
+
v: VisibleNode,
|
|
1067
|
+
focusId: string,
|
|
1068
|
+
impact: Set<string> | undefined,
|
|
1069
|
+
lod: string,
|
|
1070
|
+
) {
|
|
1071
|
+
const c = this.centerOf(v.id);
|
|
1072
|
+
const name = v.node?.headline ?? v.group?.label ?? v.id;
|
|
1073
|
+
const type =
|
|
1074
|
+
v.kind === 'group'
|
|
1075
|
+
? this.i18n.t('dependencyMapGroupCount')(v.members.length)
|
|
1076
|
+
: (v.node?.type ?? '');
|
|
1077
|
+
const icon =
|
|
1078
|
+
v.kind === 'group'
|
|
1079
|
+
? (v.group?.icon ?? 'folder')
|
|
1080
|
+
: (v.node?.icon ?? 'deployed_code');
|
|
1081
|
+
const upstream = this.visibleEdges.filter(e => e.target === v.id).length;
|
|
1082
|
+
const downstream = this.visibleEdges.filter(e => e.source === v.id).length;
|
|
1083
|
+
const selected = this.selected === v.id;
|
|
1084
|
+
const metrics =
|
|
1085
|
+
lod === 'detail' && v.node?.metrics
|
|
1086
|
+
? Object.entries(v.node.metrics).slice(0, 3)
|
|
1087
|
+
: [];
|
|
1088
|
+
return html`<div
|
|
1089
|
+
class=${classMap({
|
|
1090
|
+
'dm-node': true,
|
|
1091
|
+
[`st-${v.status}`]: true,
|
|
1092
|
+
'is-group': v.kind === 'group',
|
|
1093
|
+
'is-selected': selected,
|
|
1094
|
+
'is-impact': !!impact && impact.has(v.id) && !selected,
|
|
1095
|
+
'is-dim': !!impact && !impact.has(v.id),
|
|
1096
|
+
'is-focus': this.focusedNode === v.id,
|
|
1097
|
+
})}
|
|
1098
|
+
data-id=${v.id}
|
|
1099
|
+
role="button"
|
|
1100
|
+
aria-pressed=${selected ? 'true' : 'false'}
|
|
1101
|
+
aria-label=${this.i18n.t('dependencyMapNode')(
|
|
1102
|
+
name,
|
|
1103
|
+
type,
|
|
1104
|
+
this.statusLabel(v.status),
|
|
1105
|
+
upstream,
|
|
1106
|
+
downstream,
|
|
1107
|
+
)}
|
|
1108
|
+
tabindex=${focusId === v.id ? '0' : '-1'}
|
|
1109
|
+
style="left: ${c.x}px; top: ${c.y}px;"
|
|
1110
|
+
@pointerdown=${(e: PointerEvent) => this.onNodePointerDown(e, v)}
|
|
1111
|
+
@keydown=${(e: KeyboardEvent) => this.onNodeKeyDown(e, v)}
|
|
1112
|
+
@dblclick=${() => {
|
|
1113
|
+
if (v.kind === 'group' && v.group) this.expandGroup(v.group.id);
|
|
1114
|
+
}}
|
|
1115
|
+
@focus=${() => {
|
|
1116
|
+
this._focusId = v.id;
|
|
1117
|
+
}}
|
|
1118
|
+
>
|
|
1119
|
+
<span class="dm-ring"><wc-icon name=${icon}></wc-icon></span>
|
|
1120
|
+
<span class="dm-text">
|
|
1121
|
+
<span class="dm-name">${name}</span>
|
|
1122
|
+
${type ? html`<span class="dm-type">${type}</span>` : nothing}
|
|
1123
|
+
${metrics.length
|
|
1124
|
+
? html`<span class="dm-metrics"
|
|
1125
|
+
>${metrics.map(
|
|
1126
|
+
([k, val]) => html`<span>${k} <b>${val}</b></span>`,
|
|
1127
|
+
)}</span
|
|
1128
|
+
>`
|
|
1129
|
+
: nothing}
|
|
1130
|
+
</span>
|
|
1131
|
+
${v.kind === 'group' && v.group
|
|
1132
|
+
? html`<button
|
|
1133
|
+
type="button"
|
|
1134
|
+
class="dm-group-toggle"
|
|
1135
|
+
tabindex="-1"
|
|
1136
|
+
aria-label=${this.i18n.t('dependencyMapExpandGroup')(v.group.label)}
|
|
1137
|
+
@click=${() => v.group && this.expandGroup(v.group.id)}
|
|
1138
|
+
>
|
|
1139
|
+
<wc-icon name="unfold_more"></wc-icon>
|
|
1140
|
+
</button>`
|
|
1141
|
+
: nothing}
|
|
1142
|
+
</div>`;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
private renderLegend() {
|
|
1146
|
+
if (this.hideLegend) return nothing;
|
|
1147
|
+
const types = new Map<string, { icon?: string; count: number }>();
|
|
1148
|
+
for (const n of this.nodes) {
|
|
1149
|
+
if (n.type) {
|
|
1150
|
+
const t = types.get(n.type) ?? { icon: n.icon, count: 0 };
|
|
1151
|
+
t.count += 1;
|
|
1152
|
+
types.set(n.type, t);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
const all = [...types.keys()];
|
|
1156
|
+
const active = this.filter.types ?? all;
|
|
1157
|
+
return html`<div
|
|
1158
|
+
class="dm-legend"
|
|
1159
|
+
role="group"
|
|
1160
|
+
aria-label=${this.i18n.t('dependencyMapLegend')}
|
|
1161
|
+
>
|
|
1162
|
+
${all.length
|
|
1163
|
+
? html`<div class="dm-legend-types">
|
|
1164
|
+
${all.map(type => {
|
|
1165
|
+
const t = types.get(type);
|
|
1166
|
+
const on = active.includes(type);
|
|
1167
|
+
return html`<button
|
|
1168
|
+
type="button"
|
|
1169
|
+
class=${classMap({ 'dm-type-toggle': true, 'is-off': !on })}
|
|
1170
|
+
aria-pressed=${on ? 'true' : 'false'}
|
|
1171
|
+
title=${this.i18n.t('dependencyMapShowType')(type)}
|
|
1172
|
+
@click=${() => this.toggleType(type, all)}
|
|
1173
|
+
>
|
|
1174
|
+
<wc-icon name=${t?.icon ?? 'deployed_code'}></wc-icon
|
|
1175
|
+
>${type}<span class="dm-count">${t?.count}</span>
|
|
1176
|
+
</button>`;
|
|
1177
|
+
})}
|
|
1178
|
+
</div>`
|
|
1179
|
+
: nothing}
|
|
1180
|
+
<div class="dm-legend-keys">
|
|
1181
|
+
<span
|
|
1182
|
+
><i class="dm-dot st-healthy"></i>${this.i18n.t(
|
|
1183
|
+
'dependencyMapHealthy',
|
|
1184
|
+
)}</span
|
|
1185
|
+
>
|
|
1186
|
+
<span
|
|
1187
|
+
><i class="dm-dot st-degraded"></i>${this.i18n.t(
|
|
1188
|
+
'dependencyMapDegraded',
|
|
1189
|
+
)}</span
|
|
1190
|
+
>
|
|
1191
|
+
<span
|
|
1192
|
+
><i class="dm-dot st-down"></i>${this.i18n.t(
|
|
1193
|
+
'dependencyMapDown',
|
|
1194
|
+
)}</span
|
|
1195
|
+
>
|
|
1196
|
+
${this.impact !== 'none'
|
|
1197
|
+
? html`<span
|
|
1198
|
+
><i class="dm-bar is-impact"></i>${this.i18n.t(
|
|
1199
|
+
'dependencyMapImpact',
|
|
1200
|
+
)}</span
|
|
1201
|
+
>`
|
|
1202
|
+
: nothing}
|
|
1203
|
+
<span
|
|
1204
|
+
><i class="dm-bar"></i>${this.i18n.t('dependencyMapTraffic')}</span
|
|
1205
|
+
>
|
|
1206
|
+
</div>
|
|
1207
|
+
</div>`;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// ── Render
|
|
1211
|
+
|
|
1212
|
+
protected render() {
|
|
1213
|
+
const { x, y, zoom } = this.viewport.view;
|
|
1214
|
+
let lod = 'card';
|
|
1215
|
+
if (zoom < DOT_ZOOM) lod = 'dot';
|
|
1216
|
+
else if (zoom >= DETAIL_ZOOM) lod = 'detail';
|
|
1217
|
+
const impact = this.impactSet();
|
|
1218
|
+
const focusId = this.visibleById.has(this._focusId)
|
|
1219
|
+
? this._focusId
|
|
1220
|
+
: (this.visibleNodes[0]?.id ?? '');
|
|
1221
|
+
const shown = new Set(
|
|
1222
|
+
this.visibleNodes
|
|
1223
|
+
.filter(
|
|
1224
|
+
v =>
|
|
1225
|
+
this.nearView(this.rectOf(v.id)) ||
|
|
1226
|
+
v.id === focusId ||
|
|
1227
|
+
v.id === this.selected,
|
|
1228
|
+
)
|
|
1229
|
+
.map(v => v.id),
|
|
1230
|
+
);
|
|
1231
|
+
return html`
|
|
1232
|
+
<div
|
|
1233
|
+
class=${classMap({
|
|
1234
|
+
'dm-viewport': true,
|
|
1235
|
+
[`lod-${lod}`]: true,
|
|
1236
|
+
'is-panning': this.viewport.panning,
|
|
1237
|
+
'is-space': this.viewport.spaceHeld,
|
|
1238
|
+
})}
|
|
1239
|
+
tabindex="0"
|
|
1240
|
+
role="region"
|
|
1241
|
+
aria-label=${this.label || this.i18n.t('dependencyMapLabel')}
|
|
1242
|
+
aria-describedby="instructions"
|
|
1243
|
+
style=${this.gridStyle()}
|
|
1244
|
+
@keydown=${this.onViewportKeyDown}
|
|
1245
|
+
>
|
|
1246
|
+
<div
|
|
1247
|
+
class="dm-world"
|
|
1248
|
+
style="transform: translate(${x}px, ${y}px) scale(${zoom}); --_zoom: ${zoom};"
|
|
1249
|
+
>
|
|
1250
|
+
<div class="dm-groups">${this.renderGroups()}</div>
|
|
1251
|
+
<svg class="dm-edges" width="1" height="1" aria-hidden="true">
|
|
1252
|
+
${this.renderEdges(impact, shown)}
|
|
1253
|
+
</svg>
|
|
1254
|
+
<div
|
|
1255
|
+
class="dm-nodes"
|
|
1256
|
+
role="group"
|
|
1257
|
+
aria-label=${this.label || this.i18n.t('dependencyMapLabel')}
|
|
1258
|
+
>
|
|
1259
|
+
${repeat(
|
|
1260
|
+
this.visibleNodes.filter(v => shown.has(v.id)),
|
|
1261
|
+
v => v.id,
|
|
1262
|
+
v => this.renderNode(v, focusId, impact, lod),
|
|
1263
|
+
)}
|
|
1264
|
+
</div>
|
|
1265
|
+
</div>
|
|
1266
|
+
${this.renderLegend()} ${this.renderTooltip()}
|
|
1267
|
+
${this.renderBackToContent()}
|
|
1268
|
+
<div class="slot-controls"><slot name="controls"></slot></div>
|
|
1269
|
+
<div class="slot-minimap"><slot name="minimap"></slot></div>
|
|
1270
|
+
<div id="instructions" hidden>
|
|
1271
|
+
${this.i18n.t('diagramInstructions')}
|
|
1272
|
+
</div>
|
|
1273
|
+
<div class="sr-only" aria-live="polite">${this._announcement}</div>
|
|
1274
|
+
</div>
|
|
1275
|
+
`;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// Nodes are measured after they render, so a second update is expected.
|
|
1280
|
+
DependencyMap.disableWarning?.('change-in-update');
|