@emuanalytics/flow-rdf-ui 4.2.0 → 4.3.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/README.md +58 -0
- package/THIRD_PARTY_NOTICES.md +220 -0
- package/dist/components/alert/alert.component.mjs +3 -0
- package/dist/components/animation/animation.component.mjs +1 -0
- package/dist/components/autocomplete/autocomplete.component.mjs +38 -14
- package/dist/components/avatar/avatar.component.mjs +3 -0
- package/dist/components/badge/badge.component.mjs +1 -0
- package/dist/components/base-control/base-control.component.mjs +3 -0
- package/dist/components/breadcrumb/breadcrumb.component.mjs +3 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.component.mjs +1 -0
- package/dist/components/busy-overlay/busy-overlay.component.mjs +3 -0
- package/dist/components/button/button.component.mjs +4 -0
- package/dist/components/button-group/button-group.component.mjs +1 -0
- package/dist/components/calendar/calendar.component.mjs +6 -0
- package/dist/components/card/card.component.mjs +1 -0
- package/dist/components/carousel/carousel.component.mjs +3 -0
- package/dist/components/carousel-item/carousel-item.component.mjs +1 -0
- package/dist/components/chart/chart.component.mjs +1 -0
- package/dist/components/chart/chartjs-plugins/luxon.adapter.mjs +78 -0
- package/dist/components/chart/chartjs-support.mjs +2 -0
- package/dist/components/checkbox/checkbox.component.mjs +3 -0
- package/dist/components/checkbox-group/checkbox-group.component.mjs +3 -0
- package/dist/components/color-mapper/color-mapper.component.mjs +21 -0
- package/dist/components/color-picker/color-picker.component.mjs +8 -0
- package/dist/components/color-stop/color-stop.component.mjs +17 -0
- package/dist/components/date-time-picker/date-time-picker.component.mjs +6 -0
- package/dist/components/details/details.component.mjs +3 -0
- package/dist/components/diagram/diagram-panel.styles.mjs +44 -0
- package/dist/components/diagram/diagram-tokens.styles.mjs +148 -0
- package/dist/components/diagram/diagram.component.mjs +355 -0
- package/dist/components/diagram/diagram.mjs +5 -0
- package/dist/components/diagram/diagram.styles.mjs +95 -0
- package/dist/components/diagram-background/diagram-background.component.mjs +163 -0
- package/dist/components/diagram-background/diagram-background.mjs +5 -0
- package/dist/components/diagram-background/diagram-background.styles.mjs +58 -0
- package/dist/components/diagram-base-edge/diagram-base-edge.component.mjs +326 -0
- package/dist/components/diagram-base-edge/diagram-base-edge.mjs +5 -0
- package/dist/components/diagram-base-edge/diagram-base-edge.styles.mjs +147 -0
- package/dist/components/diagram-base-node/diagram-base-node.component.mjs +84 -0
- package/dist/components/diagram-base-node/diagram-base-node.mjs +5 -0
- package/dist/components/diagram-base-node/diagram-base-node.styles.mjs +37 -0
- package/dist/components/diagram-edge/diagram-edge.component.mjs +56 -0
- package/dist/components/diagram-edge/diagram-edge.mjs +5 -0
- package/dist/components/diagram-edge/diagram-edge.styles.mjs +37 -0
- package/dist/components/diagram-edge-label/diagram-edge-label.component.mjs +202 -0
- package/dist/components/diagram-edge-label/diagram-edge-label.mjs +5 -0
- package/dist/components/diagram-edge-label/diagram-edge-label.styles.mjs +54 -0
- package/dist/components/diagram-marker/diagram-marker.component.mjs +84 -0
- package/dist/components/diagram-marker/diagram-marker.mjs +5 -0
- package/dist/components/diagram-marker/diagram-marker.styles.mjs +9 -0
- package/dist/components/diagram-minimap/diagram-minimap.component.mjs +298 -0
- package/dist/components/diagram-minimap/diagram-minimap.mjs +5 -0
- package/dist/components/diagram-minimap/diagram-minimap.styles.mjs +83 -0
- package/dist/components/diagram-node/diagram-node-template.styles.mjs +36 -0
- package/dist/components/diagram-node/diagram-node.component.mjs +183 -0
- package/dist/components/diagram-node/diagram-node.mjs +6 -0
- package/dist/components/diagram-node/diagram-node.styles.mjs +29 -0
- package/dist/components/diagram-palette-item/diagram-palette-item.component.mjs +168 -0
- package/dist/components/diagram-palette-item/diagram-palette-item.mjs +5 -0
- package/dist/components/diagram-palette-item/diagram-palette-item.styles.mjs +20 -0
- package/dist/components/diagram-palette-item-preview/diagram-palette-item-preview.component.mjs +245 -0
- package/dist/components/diagram-palette-item-preview/diagram-palette-item-preview.mjs +6 -0
- package/dist/components/diagram-palette-item-preview/diagram-palette-item-preview.styles.mjs +41 -0
- package/dist/components/diagram-port/diagram-port.component.mjs +273 -0
- package/dist/components/diagram-port/diagram-port.mjs +5 -0
- package/dist/components/diagram-port/diagram-port.styles.mjs +116 -0
- package/dist/components/diagram-resize-adornment/diagram-resize-adornment.component.mjs +124 -0
- package/dist/components/diagram-resize-adornment/diagram-resize-adornment.mjs +5 -0
- package/dist/components/diagram-resize-adornment/diagram-resize-adornment.styles.mjs +136 -0
- package/dist/components/diagram-rotate-adornment/diagram-rotate-adornment.component.mjs +125 -0
- package/dist/components/diagram-rotate-adornment/diagram-rotate-adornment.mjs +5 -0
- package/dist/components/diagram-rotate-adornment/diagram-rotate-adornment.styles.mjs +65 -0
- package/dist/components/diagram-zoom-controls/diagram-zoom-controls.component.mjs +158 -0
- package/dist/components/diagram-zoom-controls/diagram-zoom-controls.mjs +5 -0
- package/dist/components/diagram-zoom-controls/diagram-zoom-controls.styles.mjs +66 -0
- package/dist/components/dialog/dialog.component.mjs +4 -0
- package/dist/components/divider/divider.component.mjs +1 -0
- package/dist/components/drawer/drawer.component.mjs +3 -0
- package/dist/components/dropdown/dropdown.component.mjs +2 -1
- package/dist/components/form-group/form-group.component.mjs +1 -0
- package/dist/components/gauge/gauge.component.mjs +6 -0
- package/dist/components/icon/icon.component.mjs +1 -0
- package/dist/components/icon/library.system.mjs +2 -0
- package/dist/components/icon-button/icon-button.component.mjs +5 -0
- package/dist/components/input/input.component.mjs +5 -0
- package/dist/components/list/list.component.mjs +1 -0
- package/dist/components/list-item/list-item.component.mjs +17 -0
- package/dist/components/map/map.component.mjs +3 -0
- package/dist/components/map/map.styles.mjs +10 -0
- package/dist/components/menu/menu.component.mjs +1 -0
- package/dist/components/menu-item/menu-item.component.mjs +3 -0
- package/dist/components/menu-label/menu-label.component.mjs +1 -0
- package/dist/components/mutation-observer/mutation-observer.component.mjs +1 -0
- package/dist/components/option/option.component.mjs +2 -1
- package/dist/components/panel/panel.component.mjs +85 -1
- package/dist/components/panel/panel.styles.mjs +29 -0
- package/dist/components/panel-header/panel-header.component.mjs +3 -0
- package/dist/components/popup/popup.component.mjs +1 -0
- package/dist/components/progress-bar/progress-bar.component.mjs +1 -0
- package/dist/components/progress-ring/progress-ring.component.mjs +1 -0
- package/dist/components/query-builder/query-builder.component.mjs +27 -0
- package/dist/components/radio/radio.component.mjs +3 -0
- package/dist/components/radio-group/radio-group.component.mjs +3 -0
- package/dist/components/range/range.component.mjs +9 -0
- package/dist/components/resize-observer/resize-observer.component.mjs +1 -0
- package/dist/components/scroll-view/scroll-view.component.mjs +1 -0
- package/dist/components/select/select.component.mjs +3 -5
- package/dist/components/split-view/split-view-layout-registry.mjs +44 -0
- package/dist/components/split-view/split-view-layout.mjs +607 -0
- package/dist/components/split-view/split-view.component.mjs +502 -468
- package/dist/components/split-view/split-view.styles.mjs +25 -0
- package/dist/components/split-view-divider/split-view-divider.component.mjs +2 -53
- package/dist/components/split-view-divider/split-view-divider.styles.mjs +28 -16
- package/dist/components/split-view-pane/split-view-pane.component.mjs +197 -18
- package/dist/components/split-view-pane/split-view-pane.styles.mjs +52 -0
- package/dist/components/split-view-toggle-button/split-view-toggle-button.component.mjs +5 -0
- package/dist/components/stepper/stepper.component.mjs +1 -0
- package/dist/components/stepper-panel/stepper-panel.component.mjs +1 -0
- package/dist/components/switch/switch.component.mjs +3 -0
- package/dist/components/tab/tab.component.mjs +4 -0
- package/dist/components/tab-group/tab-group.component.mjs +176 -6
- package/dist/components/tab-group/tab-group.styles.mjs +44 -0
- package/dist/components/tab-panel/tab-panel.component.mjs +1 -0
- package/dist/components/tag/tag.component.mjs +2 -1
- package/dist/components/textarea/textarea.component.mjs +1 -0
- package/dist/components/timer/ticker.mjs +7 -0
- package/dist/components/timer/timer.component.mjs +44 -3
- package/dist/components/timer/timer.styles.mjs +6 -2
- package/dist/components/tool-button/tool-button.component.mjs +4 -0
- package/dist/components/tool-button-group/tool-button-group.component.mjs +3 -0
- package/dist/components/tooltip/tooltip.component.mjs +3 -0
- package/dist/components/tree/tree.component.mjs +1 -0
- package/dist/components/tree-item/tree-item.component.mjs +5 -0
- package/dist/components/visually-hidden/visually-hidden.component.mjs +1 -0
- package/dist/custom-elements.json +11803 -5676
- package/dist/diagram/api/diagram-api-base.mjs +16 -0
- package/dist/diagram/api/diagram-api.mjs +399 -0
- package/dist/diagram/api/diagram-clipboard-api.mjs +52 -0
- package/dist/diagram/api/diagram-groups-api.mjs +46 -0
- package/dist/diagram/api/diagram-model-api.mjs +447 -0
- package/dist/diagram/api/diagram-nodes-api.mjs +61 -0
- package/dist/diagram/api/diagram-selection-api.mjs +56 -0
- package/dist/diagram/api/diagram-viewport-api.mjs +169 -0
- package/dist/diagram/api/emit-with-measurement-option.mjs +21 -0
- package/dist/diagram/input/box-selection-controller.mjs +104 -0
- package/dist/diagram/input/context-menu-controller.mjs +196 -0
- package/dist/diagram/input/cursor-position-tracker-controller.mjs +18 -0
- package/dist/diagram/input/input-controller.mjs +31 -0
- package/dist/diagram/input/keyboard-actions/moving-action.mjs +27 -0
- package/dist/diagram/input/keyboard-actions/panning-action.mjs +27 -0
- package/dist/diagram/input/keyboard-actions/paste-action.mjs +17 -0
- package/dist/diagram/input/keyboard-actions/zoom-action.mjs +30 -0
- package/dist/diagram/input/keyboard-inputs-controller.mjs +121 -0
- package/dist/diagram/input/linking-controller.mjs +127 -0
- package/dist/diagram/input/linking-events.mjs +61 -0
- package/dist/diagram/input/manual-linking.mjs +101 -0
- package/dist/diagram/input/mobile-box-selection-controller.mjs +133 -0
- package/dist/diagram/input/mobile-panning-controller.mjs +114 -0
- package/dist/diagram/input/mobile-zooming-controller.mjs +110 -0
- package/dist/diagram/input/object-selection-controller.mjs +152 -0
- package/dist/diagram/input/palette-drop-controller.mjs +92 -0
- package/dist/diagram/input/panning-controller.mjs +147 -0
- package/dist/diagram/input/pointer-move-selection-controller.mjs +191 -0
- package/dist/diagram/input/relinking-gesture.mjs +182 -0
- package/dist/diagram/input/resize-controller.mjs +122 -0
- package/dist/diagram/input/rotate-controller.mjs +126 -0
- package/dist/diagram/input/zooming-wheel-controller.mjs +55 -0
- package/dist/diagram/minimap/minimap-calculations.mjs +83 -0
- package/dist/diagram/minimap/minimap-navigation-controller.mjs +150 -0
- package/dist/diagram/minimap/minimap-node-cache.mjs +19 -0
- package/dist/diagram/minimap/minimap-strategies.mjs +44 -0
- package/dist/diagram/model/diagram-model-adapter.mjs +97 -0
- package/dist/diagram/model/initialize-model.mjs +31 -0
- package/dist/diagram/model/strip-runtime-properties.mjs +30 -0
- package/dist/diagram/runtime/attribute-converters.mjs +11 -0
- package/dist/diagram/runtime/batched-resize-observer.mjs +168 -0
- package/dist/diagram/runtime/box-selection-provider.mjs +9 -0
- package/dist/diagram/runtime/context.mjs +132 -0
- package/dist/diagram/runtime/contexts.mjs +8 -0
- package/dist/diagram/runtime/cursor-position-tracker.mjs +20 -0
- package/dist/diagram/runtime/default-edge-templates.mjs +21 -0
- package/dist/diagram/runtime/default-node-templates.mjs +20 -0
- package/dist/diagram/runtime/diagram-reference.mjs +126 -0
- package/dist/diagram/runtime/diagram-runtime.mjs +214 -0
- package/dist/diagram/runtime/dom-input-events-router.mjs +88 -0
- package/dist/diagram/runtime/environment.mjs +59 -0
- package/dist/diagram/runtime/event-bridge.mjs +31 -0
- package/dist/diagram/runtime/flow-offset.mjs +45 -0
- package/dist/diagram/runtime/group-highlighted.mjs +25 -0
- package/dist/diagram/runtime/hidden.mjs +147 -0
- package/dist/diagram/runtime/lit-renderer.mjs +33 -0
- package/dist/diagram/runtime/marker-registry.mjs +108 -0
- package/dist/diagram/runtime/middlewares.mjs +14 -0
- package/dist/diagram/runtime/model-owner.mjs +11 -0
- package/dist/diagram/runtime/node-selected.mjs +25 -0
- package/dist/diagram/runtime/observable.mjs +205 -0
- package/dist/diagram/runtime/palette-drag.mjs +56 -0
- package/dist/diagram/runtime/port-hover.mjs +27 -0
- package/dist/diagram/runtime/port-registry.mjs +87 -0
- package/dist/diagram/runtime/resize-processor.mjs +207 -0
- package/dist/diagram/runtime/template-resolver.mjs +98 -0
- package/dist/diagram/runtime/touch-events-state.mjs +52 -0
- package/dist/diagram/utilities.mjs +27 -0
- package/dist/diagram-core/action-state-manager/action-state-manager.mjs +238 -0
- package/dist/diagram-core/batch-processor/batch-processor.mjs +144 -0
- package/dist/diagram-core/command-handler/command-handler.mjs +62 -0
- package/dist/diagram-core/command-handler/commands/add-to-group.mjs +32 -0
- package/dist/diagram-core/command-handler/commands/add-update-delete.mjs +196 -0
- package/dist/diagram-core/command-handler/commands/centering.mjs +73 -0
- package/dist/diagram-core/command-handler/commands/copy-paste.mjs +223 -0
- package/dist/diagram-core/command-handler/commands/cut.mjs +9 -0
- package/dist/diagram-core/command-handler/commands/delete-selection.mjs +32 -0
- package/dist/diagram-core/command-handler/commands/detach-on-node-delete.mjs +77 -0
- package/dist/diagram-core/command-handler/commands/highlight-group.mjs +45 -0
- package/dist/diagram-core/command-handler/commands/index.mjs +88 -0
- package/dist/diagram-core/command-handler/commands/init.mjs +11 -0
- package/dist/diagram-core/command-handler/commands/linking/cancel-linking.mjs +26 -0
- package/dist/diagram-core/command-handler/commands/linking/finish-linking-to-position.mjs +33 -0
- package/dist/diagram-core/command-handler/commands/linking/finish-linking.mjs +108 -0
- package/dist/diagram-core/command-handler/commands/linking/finish-relinking.mjs +91 -0
- package/dist/diagram-core/command-handler/commands/linking/linking-gesture.mjs +13 -0
- package/dist/diagram-core/command-handler/commands/linking/move-temporary-edge.mjs +98 -0
- package/dist/diagram-core/command-handler/commands/linking/start-linking-from-position.mjs +23 -0
- package/dist/diagram-core/command-handler/commands/linking/start-linking.mjs +47 -0
- package/dist/diagram-core/command-handler/commands/linking/start-relinking.mjs +51 -0
- package/dist/diagram-core/command-handler/commands/linking/utils.mjs +103 -0
- package/dist/diagram-core/command-handler/commands/move-nodes-lifecycle.mjs +14 -0
- package/dist/diagram-core/command-handler/commands/move-viewport.mjs +48 -0
- package/dist/diagram-core/command-handler/commands/move.mjs +90 -0
- package/dist/diagram-core/command-handler/commands/remove-from-group.mjs +22 -0
- package/dist/diagram-core/command-handler/commands/resize-node-lifecycle.mjs +14 -0
- package/dist/diagram-core/command-handler/commands/resize-node.mjs +214 -0
- package/dist/diagram-core/command-handler/commands/rotate-node-lifecycle.mjs +14 -0
- package/dist/diagram-core/command-handler/commands/rotate-node.mjs +53 -0
- package/dist/diagram-core/command-handler/commands/selection.mjs +69 -0
- package/dist/diagram-core/command-handler/commands/z-order.mjs +125 -0
- package/dist/diagram-core/command-handler/commands/zoom-to-fit.mjs +118 -0
- package/dist/diagram-core/command-handler/commands/zoom.mjs +26 -0
- package/dist/diagram-core/edge-routing-manager/edge-routing-manager.mjs +253 -0
- package/dist/diagram-core/edge-routing-manager/resolve-label-position.mjs +13 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/bezier-routing.mjs +73 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-path.mjs +24 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-point-at-distance.mjs +37 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-point-on-path.mjs +33 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-points.mjs +31 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-path.mjs +56 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-point-at-distance.mjs +12 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-point-on-path.mjs +38 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-points.mjs +26 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/orthogonal-routing.mjs +69 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/get-offset-point.mjs +14 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-bottom.mjs +104 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-left.mjs +91 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-right.mjs +88 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-top.mjs +168 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints.mjs +23 -0
- package/dist/diagram-core/edge-routing-manager/routings/polyline/compute-polyline-point-at-distance.mjs +12 -0
- package/dist/diagram-core/edge-routing-manager/routings/polyline/compute-polyline-point-on-path.mjs +41 -0
- package/dist/diagram-core/edge-routing-manager/routings/polyline/polyline-routing.mjs +81 -0
- package/dist/diagram-core/edge-routing-manager/utils/linear-segment-utils.mjs +27 -0
- package/dist/diagram-core/edge-routing-manager/utils/normalize-distance.mjs +6 -0
- package/dist/diagram-core/event-manager/event-manager.mjs +164 -0
- package/dist/diagram-core/flow-config/default-flow-config.mjs +143 -0
- package/dist/diagram-core/flow-core.mjs +541 -0
- package/dist/diagram-core/input-events/handlers/box-selection/box-selection.handler.mjs +69 -0
- package/dist/diagram-core/input-events/handlers/cancel-interaction/cancel-interaction.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/copy/copy.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/cut/cut.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/delete-selection/delete-selection.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/event-handler.mjs +29 -0
- package/dist/diagram-core/input-events/handlers/keyboard-move-selection/keyboard-move-selection.handler.mjs +130 -0
- package/dist/diagram-core/input-events/handlers/keyboard-panning/keyboard-panning.handler.mjs +31 -0
- package/dist/diagram-core/input-events/handlers/linking/linking.handler.mjs +77 -0
- package/dist/diagram-core/input-events/handlers/movable-selection.mjs +26 -0
- package/dist/diagram-core/input-events/handlers/palette-drop/palette-drop.handler.mjs +20 -0
- package/dist/diagram-core/input-events/handlers/panning/panning-handler-factory.mjs +8 -0
- package/dist/diagram-core/input-events/handlers/panning/panning.handler.mjs +41 -0
- package/dist/diagram-core/input-events/handlers/panning/virtualized-panning.handler.mjs +77 -0
- package/dist/diagram-core/input-events/handlers/paste/paste.handler.mjs +17 -0
- package/dist/diagram-core/input-events/handlers/pointer-move-selection/pointer-move-selection.handler.mjs +220 -0
- package/dist/diagram-core/input-events/handlers/redo/redo.handler.mjs +14 -0
- package/dist/diagram-core/input-events/handlers/relinking/relinking.handler.mjs +62 -0
- package/dist/diagram-core/input-events/handlers/resize/resize.handler.mjs +174 -0
- package/dist/diagram-core/input-events/handlers/rotate/rotate.handler.mjs +107 -0
- package/dist/diagram-core/input-events/handlers/select/select.handler.mjs +42 -0
- package/dist/diagram-core/input-events/handlers/select-all/select-all.handler.mjs +10 -0
- package/dist/diagram-core/input-events/handlers/undo/undo.handler.mjs +14 -0
- package/dist/diagram-core/input-events/handlers/wheel-panning/wheel-panning.handler.mjs +25 -0
- package/dist/diagram-core/input-events/handlers/zooming/zooming.handler.mjs +28 -0
- package/dist/diagram-core/input-events/input-events.router.mjs +75 -0
- package/dist/diagram-core/interaction-coordinator/interaction-coordinator.mjs +75 -0
- package/dist/diagram-core/label-batch-processor/label-batch-processor.mjs +19 -0
- package/dist/diagram-core/math/angle-between-points/angle-between-points.mjs +5 -0
- package/dist/diagram-core/math/angle-to-side/angle-to-side.mjs +27 -0
- package/dist/diagram-core/math/calculate-edge-panning-force/calculate-edge-panning-force.mjs +34 -0
- package/dist/diagram-core/math/clamp/clamp.mjs +5 -0
- package/dist/diagram-core/math/distance-between-points/distance-between-points.mjs +5 -0
- package/dist/diagram-core/math/ng-diagram-math.mjs +25 -0
- package/dist/diagram-core/math/normalize-angle/normalize-angle.mjs +5 -0
- package/dist/diagram-core/math/snap-angle/snap-angle.mjs +43 -0
- package/dist/diagram-core/math/snap-number/snap-number.mjs +3 -0
- package/dist/diagram-core/math/snap-point/snap-point.mjs +8 -0
- package/dist/diagram-core/math/subtract-points/subtract-points.mjs +5 -0
- package/dist/diagram-core/measurement-tracker/measurement-tracker.mjs +182 -0
- package/dist/diagram-core/middleware-manager/middleware-executor.mjs +246 -0
- package/dist/diagram-core/middleware-manager/middleware-manager.mjs +93 -0
- package/dist/diagram-core/middleware-manager/middlewares/edges-routing/edges-routing.mjs +149 -0
- package/dist/diagram-core/middleware-manager/middlewares/edges-routing/get-edge-points.mjs +93 -0
- package/dist/diagram-core/middleware-manager/middlewares/edges-routing/get-source-target-positions.mjs +90 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/clipboard-paste.emitter.mjs +34 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/diagram-init.emitter.mjs +190 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/edge-draw-ended.emitter.mjs +51 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/edge-drawn.emitter.mjs +35 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/edge-relink.emitter.mjs +58 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/group-membership-changed.emitter.mjs +49 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/node-drag-lifecycle.emitter.mjs +54 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/node-resize-lifecycle.emitter.mjs +44 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/node-rotate-lifecycle.emitter.mjs +44 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/palette-item-dropped.emitter.mjs +26 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-changed.emitter.mjs +61 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-gesture-ended.emitter.mjs +32 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-moved.emitter.mjs +57 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-removed.emitter.mjs +40 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-rotated.emitter.mjs +33 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/size-changed.emitter.mjs +33 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/viewport-changed.emitter.mjs +19 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/event-emitter.middleware.mjs +69 -0
- package/dist/diagram-core/middleware-manager/middlewares/hidden-computation/hidden-computation.mjs +66 -0
- package/dist/diagram-core/middleware-manager/middlewares/internal-id-assignment/internal-id-assignment.mjs +24 -0
- package/dist/diagram-core/middleware-manager/middlewares/logger/logger.mjs +18 -0
- package/dist/diagram-core/middleware-manager/middlewares/measured-bounds-assignment/is-node-fully-measured.mjs +20 -0
- package/dist/diagram-core/middleware-manager/middlewares/measured-bounds-assignment/measured-bounds-assignment.mjs +59 -0
- package/dist/diagram-core/middleware-manager/middlewares/measurement-tracking/measurement-tracking.middleware.mjs +55 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/assign-edges-z-index.mjs +12 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/assign-node-z-index.mjs +61 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/create-group-children-map.mjs +14 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/initialize-z-index.mjs +30 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/sort-children.mjs +36 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/z-index-assignment.mjs +240 -0
- package/dist/diagram-core/middleware-manager/pass-settlement.mjs +68 -0
- package/dist/diagram-core/model-lookup/model-lookup.mjs +394 -0
- package/dist/diagram-core/port-batch-processor/port-batch-processor.mjs +20 -0
- package/dist/diagram-core/render-strategy/base-render-strategy.mjs +26 -0
- package/dist/diagram-core/render-strategy/direct/direct-render-strategy.mjs +33 -0
- package/dist/diagram-core/render-strategy/render-performance-logger.mjs +42 -0
- package/dist/diagram-core/render-strategy/virtualized/idle-render-scheduler.mjs +43 -0
- package/dist/diagram-core/render-strategy/virtualized/result-cache.mjs +63 -0
- package/dist/diagram-core/render-strategy/virtualized/viewport-utils.mjs +40 -0
- package/dist/diagram-core/render-strategy/virtualized/virtualized-render-strategy.mjs +91 -0
- package/dist/diagram-core/render-strategy/virtualized/visible-elements-resolver.mjs +120 -0
- package/dist/diagram-core/render-strategy/virtualized/zoom-tracker.mjs +38 -0
- package/dist/diagram-core/set.polyfill.mjs +24 -0
- package/dist/diagram-core/shortcut-manager/default-shortcuts.mjs +99 -0
- package/dist/diagram-core/shortcut-manager/shortcut-manager.mjs +140 -0
- package/dist/diagram-core/spatial-hash/collision-detection.mjs +74 -0
- package/dist/diagram-core/spatial-hash/spatial-hash.mjs +161 -0
- package/dist/diagram-core/spatial-hash/utils.mjs +92 -0
- package/dist/diagram-core/transaction-manager/transaction-context.mjs +40 -0
- package/dist/diagram-core/transaction-manager/transaction-manager.mjs +94 -0
- package/dist/diagram-core/transaction-manager/transaction.mjs +179 -0
- package/dist/diagram-core/types/edge.interface.mjs +3 -0
- package/dist/diagram-core/types/node.interface.mjs +3 -0
- package/dist/diagram-core/types/utils.mjs +3 -0
- package/dist/diagram-core/updater/init-updater/init-state.mjs +356 -0
- package/dist/diagram-core/updater/init-updater/init-updater.mjs +275 -0
- package/dist/diagram-core/updater/init-updater/late-arrival-queue.mjs +71 -0
- package/dist/diagram-core/updater/init-updater/stability-detector.mjs +63 -0
- package/dist/diagram-core/updater/internal-updater/internal-updater.mjs +166 -0
- package/dist/diagram-core/utils/change-generation.mjs +13 -0
- package/dist/diagram-core/utils/compute-floating-edge-side.mjs +35 -0
- package/dist/diagram-core/utils/constants.mjs +3 -0
- package/dist/diagram-core/utils/dangling-edges.mjs +89 -0
- package/dist/diagram-core/utils/deep-merge.mjs +22 -0
- package/dist/diagram-core/utils/dimensions.mjs +52 -0
- package/dist/diagram-core/utils/get-node-border-intersection.mjs +99 -0
- package/dist/diagram-core/utils/get-port-flow-position.mjs +55 -0
- package/dist/diagram-core/utils/group-size.mjs +32 -0
- package/dist/diagram-core/utils/is-group.mjs +5 -0
- package/dist/diagram-core/utils/measurement-validation.mjs +11 -0
- package/dist/diagram-core/utils/object-properties.mjs +22 -0
- package/dist/diagram-core/utils/rects-points-sizes.mjs +148 -0
- package/dist/diagram-core/utils/relinking.mjs +6 -0
- package/dist/diagram-core/utils/semaphore.mjs +43 -0
- package/dist/diagram-core/utils/snap-node-position.mjs +11 -0
- package/dist/diagram-core/utils/sort-nodes-by-z-index.mjs +22 -0
- package/dist/diagram-core/visibility/effective-visibility.mjs +28 -0
- package/dist/diagram-core/visibility/template-visibility-registry.mjs +87 -0
- package/dist/index.d.mts +13416 -3794
- package/dist/index.d.ts +13416 -3794
- package/dist/index.mjs +34 -0
- package/dist/internal/content-size.mjs +14 -0
- package/dist/internal/custom-boolean-converter.mjs +18 -0
- package/dist/internal/flow-ui-rdf-element.mjs +57 -5
- package/dist/package.json.mjs +1 -1
- package/dist/utilities/register-components.mjs +77 -142
- package/dist/vscode.html-custom-data.json +460 -187
- package/package.json +16 -8
- package/themes/dark.css +2 -0
- package/themes/dark.styles.js +2 -0
- package/themes/light.css +2 -0
- package/themes/light.styles.js +2 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { getNodeMeasuredBounds } from '../utils/dimensions.mjs';
|
|
2
|
+
import { isSameRect, doesRectsIntersect } from '../utils/rects-points-sizes.mjs';
|
|
3
|
+
|
|
4
|
+
const SPATIAL_HASH_REMOVE_ERROR = (cell, nodeId) => `[ngDiagram] Spatial hash error: Attempted to remove from non-existent cell "${cell}".
|
|
5
|
+
|
|
6
|
+
Node ID: ${nodeId}
|
|
7
|
+
|
|
8
|
+
This may indicate a state synchronization issue.`;
|
|
9
|
+
const SPATIAL_HASH_UPDATE_ERROR = (cell, nodeId) => `[ngDiagram] Spatial hash error: Attempted to update non-existent cell "${cell}".
|
|
10
|
+
|
|
11
|
+
Node ID: ${nodeId}
|
|
12
|
+
|
|
13
|
+
This may indicate a state synchronization issue.`;
|
|
14
|
+
class SpatialHash {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.cellSize = 100;
|
|
17
|
+
this.grid = /* @__PURE__ */ new Map();
|
|
18
|
+
this.idToCells = /* @__PURE__ */ new Map();
|
|
19
|
+
this.idToRect = /* @__PURE__ */ new Map();
|
|
20
|
+
}
|
|
21
|
+
process(nodes) {
|
|
22
|
+
const previousIds = new Set(this.idToRect.keys());
|
|
23
|
+
const currentIds = /* @__PURE__ */ new Set();
|
|
24
|
+
for (const node of nodes) {
|
|
25
|
+
if (node.computedHidden)
|
|
26
|
+
continue;
|
|
27
|
+
currentIds.add(node.id);
|
|
28
|
+
const prevRect = this.idToRect.get(node.id);
|
|
29
|
+
if (!prevRect) {
|
|
30
|
+
this.addToGrid(this.nodeToRect(node));
|
|
31
|
+
} else {
|
|
32
|
+
const currentRect = this.nodeToRect(node);
|
|
33
|
+
if (!isSameRect(prevRect, currentRect)) {
|
|
34
|
+
this.updateInGrid(currentRect);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const id of previousIds.difference(currentIds)) {
|
|
39
|
+
this.removeFromGrid(id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
query(range) {
|
|
43
|
+
const result = [];
|
|
44
|
+
this._query(range, (rect) => result.push(rect));
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
queryIds(range) {
|
|
48
|
+
const results = [];
|
|
49
|
+
this._query(range, (rect) => results.push(rect.id));
|
|
50
|
+
return results;
|
|
51
|
+
}
|
|
52
|
+
_query(range, addToCollection) {
|
|
53
|
+
const cells = this.getCells(range);
|
|
54
|
+
const checkedRects = /* @__PURE__ */ new Set();
|
|
55
|
+
for (const cell of cells) {
|
|
56
|
+
const objects = this.grid.get(cell);
|
|
57
|
+
if (objects) {
|
|
58
|
+
for (const rect of objects) {
|
|
59
|
+
if (checkedRects.has(rect.id)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
checkedRects.add(rect.id);
|
|
63
|
+
if (doesRectsIntersect(rect, range)) {
|
|
64
|
+
addToCollection(rect);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
nodeToRect(node) {
|
|
71
|
+
const measuredBounds = node.measuredBounds ?? getNodeMeasuredBounds(node);
|
|
72
|
+
return {
|
|
73
|
+
id: node.id,
|
|
74
|
+
...measuredBounds
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
addToCell(cell, rect) {
|
|
78
|
+
if (!this.grid.has(cell)) {
|
|
79
|
+
this.grid.set(cell, []);
|
|
80
|
+
}
|
|
81
|
+
this.grid.get(cell).push(rect);
|
|
82
|
+
}
|
|
83
|
+
removeFromCell(cell, id) {
|
|
84
|
+
const cellData = this.grid.get(cell);
|
|
85
|
+
if (!cellData) {
|
|
86
|
+
console.error(SPATIAL_HASH_REMOVE_ERROR(cell, id));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const newCells = cellData.filter((rect) => rect.id !== id);
|
|
90
|
+
this.grid.set(cell, newCells);
|
|
91
|
+
}
|
|
92
|
+
updateInCell(cell, rect) {
|
|
93
|
+
const cellData = this.grid.get(cell);
|
|
94
|
+
if (!cellData) {
|
|
95
|
+
console.error(SPATIAL_HASH_UPDATE_ERROR(cell, rect.id));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const newCells = cellData.filter(({ id }) => id !== rect.id);
|
|
99
|
+
this.grid.set(cell, [...newCells, rect]);
|
|
100
|
+
}
|
|
101
|
+
addToGrid(rect) {
|
|
102
|
+
const cells = this.getCells(rect);
|
|
103
|
+
for (const cell of cells) {
|
|
104
|
+
this.addToCell(cell, rect);
|
|
105
|
+
}
|
|
106
|
+
this.idToCells.set(rect.id, cells);
|
|
107
|
+
this.idToRect.set(rect.id, rect);
|
|
108
|
+
}
|
|
109
|
+
updateInGrid(rect) {
|
|
110
|
+
const newCells = this.getCells(rect);
|
|
111
|
+
const newCellsSet = new Set(newCells);
|
|
112
|
+
const oldCellsSet = new Set(this.idToCells.get(rect.id) || []);
|
|
113
|
+
const cellsToRemove = oldCellsSet.difference(newCellsSet);
|
|
114
|
+
const cellsToAdd = newCellsSet.difference(oldCellsSet);
|
|
115
|
+
const cellsToUpdate = newCellsSet.intersection(oldCellsSet);
|
|
116
|
+
for (const cell of cellsToRemove) {
|
|
117
|
+
this.removeFromCell(cell, rect.id);
|
|
118
|
+
}
|
|
119
|
+
for (const cell of cellsToAdd) {
|
|
120
|
+
this.addToCell(cell, rect);
|
|
121
|
+
}
|
|
122
|
+
for (const cell of cellsToUpdate) {
|
|
123
|
+
this.updateInCell(cell, rect);
|
|
124
|
+
}
|
|
125
|
+
this.idToRect.set(rect.id, rect);
|
|
126
|
+
this.idToCells.set(rect.id, newCells);
|
|
127
|
+
}
|
|
128
|
+
removeFromGrid(id) {
|
|
129
|
+
const cells = this.idToCells.get(id);
|
|
130
|
+
if (!cells) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
for (const cell of cells) {
|
|
134
|
+
this.removeFromCell(cell, id);
|
|
135
|
+
const cellData = this.grid.get(cell);
|
|
136
|
+
if (cellData && cellData.length === 0) {
|
|
137
|
+
this.grid.delete(cell);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this.idToCells.delete(id);
|
|
141
|
+
this.idToRect.delete(id);
|
|
142
|
+
}
|
|
143
|
+
getCellsRange(startPos, size) {
|
|
144
|
+
const start = Math.floor(startPos / this.cellSize);
|
|
145
|
+
const end = Math.floor((startPos + size) / this.cellSize);
|
|
146
|
+
return [start, end];
|
|
147
|
+
}
|
|
148
|
+
getCells(rect) {
|
|
149
|
+
const [minX, maxX] = this.getCellsRange(rect.x, rect.width);
|
|
150
|
+
const [minY, maxY] = this.getCellsRange(rect.y, rect.height);
|
|
151
|
+
const cells = [];
|
|
152
|
+
for (let x = minX; x <= maxX; x++) {
|
|
153
|
+
for (let y = minY; y <= maxY; y++) {
|
|
154
|
+
cells.push(`${x}-${y}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return cells;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { SpatialHash };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { getNodeMeasuredBounds } from '../utils/dimensions.mjs';
|
|
2
|
+
import { checkCollision } from './collision-detection.mjs';
|
|
3
|
+
import { getPointRangeRect, getDistanceBetweenRects, getRect, doesContainRect } from '../utils/rects-points-sizes.mjs';
|
|
4
|
+
|
|
5
|
+
const getNodesInRange = (flowCore, point, range) => {
|
|
6
|
+
const rangeRect = getPointRangeRect(point, range);
|
|
7
|
+
const candidateIds = flowCore.spatialHash.queryIds(rangeRect);
|
|
8
|
+
const foundNodes = [];
|
|
9
|
+
for (const nodeId of candidateIds) {
|
|
10
|
+
const node = flowCore.modelLookup.getNodeById(nodeId);
|
|
11
|
+
if (node && checkCollision(rangeRect, node)) {
|
|
12
|
+
foundNodes.push(node);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return foundNodes;
|
|
16
|
+
};
|
|
17
|
+
const getNearestNodeInRange = (flowCore, point, range) => {
|
|
18
|
+
return getNodesInRange(flowCore, point, range).sort((a, b) => {
|
|
19
|
+
const aDistance = getDistanceBetweenRects(getRect(a), getPointRangeRect(point, 1));
|
|
20
|
+
const bDistance = getDistanceBetweenRects(getRect(b), getPointRangeRect(point, 1));
|
|
21
|
+
return aDistance - bDistance;
|
|
22
|
+
})[0] || null;
|
|
23
|
+
};
|
|
24
|
+
const getNearestPortInRange = (flowCore, point, range) => {
|
|
25
|
+
const nodeToPortsMap = /* @__PURE__ */ new Map();
|
|
26
|
+
getNodesInRange(flowCore, point, range).forEach((node) => {
|
|
27
|
+
const ports = (node.measuredPorts || []).filter(
|
|
28
|
+
(port) => !flowCore.templateVisibilityRegistry?.isPortHidden(node.id, port.id)
|
|
29
|
+
);
|
|
30
|
+
nodeToPortsMap.set(node, ports);
|
|
31
|
+
});
|
|
32
|
+
let minDistance = Infinity;
|
|
33
|
+
let nearestPort = null;
|
|
34
|
+
for (const [node, ports] of nodeToPortsMap.entries()) {
|
|
35
|
+
for (const port of ports) {
|
|
36
|
+
const { x: px, y: py } = getRect(port);
|
|
37
|
+
const distance = getDistanceBetweenRects(
|
|
38
|
+
getRect({
|
|
39
|
+
size: port.size,
|
|
40
|
+
position: { x: px + node.position.x, y: py + node.position.y }
|
|
41
|
+
}),
|
|
42
|
+
getPointRangeRect(point, 1)
|
|
43
|
+
);
|
|
44
|
+
if (distance <= range) {
|
|
45
|
+
if (distance < minDistance) {
|
|
46
|
+
minDistance = distance;
|
|
47
|
+
nearestPort = port;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return nearestPort;
|
|
53
|
+
};
|
|
54
|
+
const getNodesInRect = (flowCore, rect, partialInclusion = true) => {
|
|
55
|
+
const candidateIds = flowCore.spatialHash.queryIds(rect);
|
|
56
|
+
const foundNodes = [];
|
|
57
|
+
for (const nodeId of candidateIds) {
|
|
58
|
+
const node = flowCore.modelLookup.getNodeById(nodeId);
|
|
59
|
+
if (node && checkCollision(rect, node)) {
|
|
60
|
+
foundNodes.push(node);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (partialInclusion) {
|
|
64
|
+
return foundNodes;
|
|
65
|
+
}
|
|
66
|
+
const fullyContainedNodes = foundNodes.filter((node) => {
|
|
67
|
+
const nodeRect = getRect(node);
|
|
68
|
+
return doesContainRect(rect, nodeRect);
|
|
69
|
+
});
|
|
70
|
+
return fullyContainedNodes;
|
|
71
|
+
};
|
|
72
|
+
function getOverlappingNodes(flowCore, nodeOrId) {
|
|
73
|
+
const isNodeId = typeof nodeOrId === "string";
|
|
74
|
+
const targetNode = isNodeId ? flowCore.modelLookup.getNodeById(nodeOrId) : nodeOrId;
|
|
75
|
+
if (!targetNode) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const measuredBounds = isNodeId ? targetNode.measuredBounds ?? getNodeMeasuredBounds(targetNode) : getNodeMeasuredBounds(targetNode);
|
|
79
|
+
const foundNodesIds = flowCore.spatialHash.queryIds(measuredBounds);
|
|
80
|
+
const foundNodes = [];
|
|
81
|
+
for (const candidateNodeId of foundNodesIds) {
|
|
82
|
+
if (candidateNodeId === targetNode.id)
|
|
83
|
+
continue;
|
|
84
|
+
const candidateNode = flowCore.modelLookup.getNodeById(candidateNodeId);
|
|
85
|
+
if (candidateNode && checkCollision(targetNode, candidateNode)) {
|
|
86
|
+
foundNodes.push(candidateNode);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return foundNodes;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { getNearestNodeInRange, getNearestPortInRange, getNodesInRange, getNodesInRect, getOverlappingNodes };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function createTransactionContext(transaction, flowCore) {
|
|
2
|
+
const context = {
|
|
3
|
+
emit: async (command, ...data) => {
|
|
4
|
+
if (transaction.isAborted()) {
|
|
5
|
+
throw new Error("Cannot emit on rolled back transaction");
|
|
6
|
+
}
|
|
7
|
+
await flowCore.commandHandler.emitInternal(command, true, ...data);
|
|
8
|
+
},
|
|
9
|
+
abort: () => {
|
|
10
|
+
transaction.abort();
|
|
11
|
+
},
|
|
12
|
+
savepoint: (name) => {
|
|
13
|
+
if (transaction.isAborted()) {
|
|
14
|
+
throw new Error("Cannot create savepoint on rolled back transaction");
|
|
15
|
+
}
|
|
16
|
+
transaction.addSavepoint(name);
|
|
17
|
+
},
|
|
18
|
+
rollbackTo: (savepointName) => {
|
|
19
|
+
if (transaction.isAborted()) {
|
|
20
|
+
throw new Error("Cannot rollback to savepoint on already rolled back transaction");
|
|
21
|
+
}
|
|
22
|
+
transaction.rollback(savepointName);
|
|
23
|
+
},
|
|
24
|
+
transaction: (name, callback) => {
|
|
25
|
+
return flowCore.transactionManager.transaction(name, callback);
|
|
26
|
+
},
|
|
27
|
+
hasChanges: () => {
|
|
28
|
+
return transaction.hasChanges();
|
|
29
|
+
},
|
|
30
|
+
isDirty: () => {
|
|
31
|
+
return !transaction.isAborted() && transaction.hasChanges();
|
|
32
|
+
},
|
|
33
|
+
getQueuedUpdates: () => {
|
|
34
|
+
return transaction.getQueue();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return context;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { createTransactionContext };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Transaction } from './transaction.mjs';
|
|
2
|
+
|
|
3
|
+
class TransactionManager {
|
|
4
|
+
constructor(flowCore) {
|
|
5
|
+
this.flowCore = flowCore;
|
|
6
|
+
this.transactionStack = [];
|
|
7
|
+
this.pendingOptions = null;
|
|
8
|
+
}
|
|
9
|
+
async transaction(nameOrCallback, callbackOrOptions, options) {
|
|
10
|
+
const [transactionName, transactionCallback, transactionOptions] = this.parseArgs(
|
|
11
|
+
nameOrCallback,
|
|
12
|
+
callbackOrOptions,
|
|
13
|
+
options
|
|
14
|
+
);
|
|
15
|
+
const parentTransaction = this.getCurrentTransaction();
|
|
16
|
+
const transaction = new Transaction(transactionName, parentTransaction, this.flowCore);
|
|
17
|
+
if (!parentTransaction && transactionOptions) {
|
|
18
|
+
this.pendingOptions = transactionOptions;
|
|
19
|
+
}
|
|
20
|
+
this.transactionStack.push(transaction);
|
|
21
|
+
try {
|
|
22
|
+
await transactionCallback(transaction.context);
|
|
23
|
+
if (!transaction.isAborted()) {
|
|
24
|
+
if (parentTransaction && this.transactionStack.includes(parentTransaction)) {
|
|
25
|
+
transaction.mergeToParent();
|
|
26
|
+
} else {
|
|
27
|
+
if (parentTransaction) {
|
|
28
|
+
console.warn(
|
|
29
|
+
"[ngDiagram] A nested transaction outlived its parent transaction \u2014 committing its updates independently. Await transactions instead of running them fire-and-forget."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const { mergedUpdate, commandsCount, actionTypes } = transaction.getMergedUpdates();
|
|
33
|
+
return {
|
|
34
|
+
results: mergedUpdate,
|
|
35
|
+
commandsCount,
|
|
36
|
+
actionTypes
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
results: {},
|
|
42
|
+
commandsCount: 0,
|
|
43
|
+
actionTypes: []
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
transaction.rollback();
|
|
47
|
+
throw error;
|
|
48
|
+
} finally {
|
|
49
|
+
const index = this.transactionStack.lastIndexOf(transaction);
|
|
50
|
+
if (index !== -1) {
|
|
51
|
+
this.transactionStack.splice(index, 1);
|
|
52
|
+
}
|
|
53
|
+
if (!parentTransaction) {
|
|
54
|
+
this.pendingOptions = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the options for the current root transaction.
|
|
60
|
+
* Returns null if no transaction is active or no options were provided.
|
|
61
|
+
*/
|
|
62
|
+
getCurrentOptions() {
|
|
63
|
+
return this.pendingOptions;
|
|
64
|
+
}
|
|
65
|
+
queueUpdate(update, actionTypes) {
|
|
66
|
+
const currentTransaction = this.getCurrentTransaction();
|
|
67
|
+
if (!currentTransaction) {
|
|
68
|
+
throw new Error("No active transaction. Cannot queue update.");
|
|
69
|
+
}
|
|
70
|
+
currentTransaction.queueUpdate(update, actionTypes);
|
|
71
|
+
}
|
|
72
|
+
isActive() {
|
|
73
|
+
return this.transactionStack.length > 0;
|
|
74
|
+
}
|
|
75
|
+
getTransactionName() {
|
|
76
|
+
const current = this.getCurrentTransaction();
|
|
77
|
+
return current ? current.getState().name : null;
|
|
78
|
+
}
|
|
79
|
+
getCurrentTransaction() {
|
|
80
|
+
return this.transactionStack[this.transactionStack.length - 1] || null;
|
|
81
|
+
}
|
|
82
|
+
parseArgs(nameOrCallback, callbackOrOptions, options) {
|
|
83
|
+
if (typeof nameOrCallback === "function") {
|
|
84
|
+
const transactionOptions = callbackOrOptions;
|
|
85
|
+
return ["transaction", nameOrCallback, transactionOptions];
|
|
86
|
+
}
|
|
87
|
+
if (typeof callbackOrOptions !== "function") {
|
|
88
|
+
throw new Error("Callback is required when transaction name is provided");
|
|
89
|
+
}
|
|
90
|
+
return [nameOrCallback, callbackOrOptions, options];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { TransactionManager };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { createTransactionContext } from './transaction-context.mjs';
|
|
2
|
+
|
|
3
|
+
class Transaction {
|
|
4
|
+
constructor(name, parent, flowCore) {
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.parent = parent;
|
|
7
|
+
this.flowCore = flowCore;
|
|
8
|
+
this.queue = [];
|
|
9
|
+
this.savepoints = /* @__PURE__ */ new Map();
|
|
10
|
+
this._isAborted = false;
|
|
11
|
+
this.children = [];
|
|
12
|
+
this._context = null;
|
|
13
|
+
if (parent) {
|
|
14
|
+
parent.children.push(this);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the transaction context, creating it lazily if needed
|
|
19
|
+
*/
|
|
20
|
+
get context() {
|
|
21
|
+
if (!this._context) {
|
|
22
|
+
this._context = createTransactionContext(this, this.flowCore);
|
|
23
|
+
}
|
|
24
|
+
return this._context;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if the transaction has been completely aborted
|
|
28
|
+
*/
|
|
29
|
+
isAborted() {
|
|
30
|
+
return this._isAborted;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Completely abort the transaction, making it unusable.
|
|
34
|
+
* This also aborts all child transactions.
|
|
35
|
+
*/
|
|
36
|
+
abort() {
|
|
37
|
+
if (this._isAborted)
|
|
38
|
+
return;
|
|
39
|
+
this._isAborted = true;
|
|
40
|
+
this.queue = [];
|
|
41
|
+
this.savepoints.clear();
|
|
42
|
+
this.children.forEach((child) => child.abort());
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a savepoint that can be rolled back to later
|
|
46
|
+
*/
|
|
47
|
+
addSavepoint(name) {
|
|
48
|
+
this.ensureNotAborted();
|
|
49
|
+
this.savepoints.set(name, this.queue.length);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Rollback to a savepoint or to the beginning of the transaction.
|
|
53
|
+
* Unlike abort(), this keeps the transaction active.
|
|
54
|
+
* @param savepointName - If provided, rollback to this savepoint. If not provided, rollback to the beginning.
|
|
55
|
+
*/
|
|
56
|
+
rollback(savepointName) {
|
|
57
|
+
this.ensureNotAborted();
|
|
58
|
+
if (savepointName === void 0) {
|
|
59
|
+
this.queue = [];
|
|
60
|
+
this.savepoints.clear();
|
|
61
|
+
this.children.forEach((child) => child.rollback());
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const index = this.savepoints.get(savepointName);
|
|
65
|
+
if (index === void 0) {
|
|
66
|
+
throw new Error(`Savepoint '${savepointName}' not found`);
|
|
67
|
+
}
|
|
68
|
+
this.queue = this.queue.slice(0, index);
|
|
69
|
+
const savepointsToRemove = [];
|
|
70
|
+
this.savepoints.forEach((savepointIndex, name) => {
|
|
71
|
+
if (savepointIndex > index) {
|
|
72
|
+
savepointsToRemove.push(name);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
savepointsToRemove.forEach((name) => this.savepoints.delete(name));
|
|
76
|
+
this.children.forEach((child) => child.rollback());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Commit the transaction by merging changes to parent or applying them
|
|
80
|
+
*/
|
|
81
|
+
commit() {
|
|
82
|
+
this.ensureNotAborted();
|
|
83
|
+
if (this.parent) {
|
|
84
|
+
this.mergeToParent();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if the transaction can be committed (not aborted and has changes)
|
|
89
|
+
*/
|
|
90
|
+
canCommit() {
|
|
91
|
+
return !this._isAborted && this.hasChanges();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Ensure the transaction is not aborted, throwing an error if it is
|
|
95
|
+
*/
|
|
96
|
+
ensureNotAborted() {
|
|
97
|
+
if (this._isAborted) {
|
|
98
|
+
throw new Error("Cannot perform operation on aborted transaction");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
hasChanges() {
|
|
102
|
+
return this.queue.length > 0 || this.children.some((child) => child.hasChanges());
|
|
103
|
+
}
|
|
104
|
+
getQueue() {
|
|
105
|
+
return [...this.queue];
|
|
106
|
+
}
|
|
107
|
+
queueUpdate(update, actionTypes) {
|
|
108
|
+
this.ensureNotAborted();
|
|
109
|
+
this.queue.push({ update, actionTypes });
|
|
110
|
+
}
|
|
111
|
+
getState() {
|
|
112
|
+
return {
|
|
113
|
+
name: this.name,
|
|
114
|
+
queue: [...this.queue],
|
|
115
|
+
savepoints: new Map(this.savepoints),
|
|
116
|
+
isAborted: this._isAborted,
|
|
117
|
+
parent: this.parent
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
mergeToParent() {
|
|
121
|
+
this.ensureNotAborted();
|
|
122
|
+
if (!this.parent) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.queue.forEach((item) => {
|
|
126
|
+
this.parent.queueUpdate(item.update, item.actionTypes);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
getMergedUpdates() {
|
|
130
|
+
if (this._isAborted) {
|
|
131
|
+
return { mergedUpdate: {}, commandsCount: 0, actionTypes: [] };
|
|
132
|
+
}
|
|
133
|
+
const commandsCount = this.queue.length;
|
|
134
|
+
const actionTypesSet = /* @__PURE__ */ new Set([this.name]);
|
|
135
|
+
const nodesToAddBatches = [];
|
|
136
|
+
const nodesToRemoveBatches = [];
|
|
137
|
+
const nodesToUpdateBatches = [];
|
|
138
|
+
const edgesToAddBatches = [];
|
|
139
|
+
const edgesToRemoveBatches = [];
|
|
140
|
+
const edgesToUpdateBatches = [];
|
|
141
|
+
const metadataUpdates = [];
|
|
142
|
+
for (const { update, actionTypes } of this.queue) {
|
|
143
|
+
actionTypes.forEach((t) => actionTypesSet.add(t));
|
|
144
|
+
if (update.nodesToAdd?.length)
|
|
145
|
+
nodesToAddBatches.push(update.nodesToAdd);
|
|
146
|
+
if (update.nodesToRemove?.length)
|
|
147
|
+
nodesToRemoveBatches.push(update.nodesToRemove);
|
|
148
|
+
if (update.nodesToUpdate?.length)
|
|
149
|
+
nodesToUpdateBatches.push(update.nodesToUpdate);
|
|
150
|
+
if (update.edgesToAdd?.length)
|
|
151
|
+
edgesToAddBatches.push(update.edgesToAdd);
|
|
152
|
+
if (update.edgesToRemove?.length)
|
|
153
|
+
edgesToRemoveBatches.push(update.edgesToRemove);
|
|
154
|
+
if (update.edgesToUpdate?.length)
|
|
155
|
+
edgesToUpdateBatches.push(update.edgesToUpdate);
|
|
156
|
+
if (update.metadataUpdate)
|
|
157
|
+
metadataUpdates.push(update.metadataUpdate);
|
|
158
|
+
}
|
|
159
|
+
const mergedUpdate = {};
|
|
160
|
+
if (nodesToAddBatches.length > 0)
|
|
161
|
+
mergedUpdate.nodesToAdd = nodesToAddBatches.flat();
|
|
162
|
+
if (nodesToRemoveBatches.length > 0)
|
|
163
|
+
mergedUpdate.nodesToRemove = nodesToRemoveBatches.flat();
|
|
164
|
+
if (nodesToUpdateBatches.length > 0)
|
|
165
|
+
mergedUpdate.nodesToUpdate = nodesToUpdateBatches.flat();
|
|
166
|
+
if (edgesToAddBatches.length > 0)
|
|
167
|
+
mergedUpdate.edgesToAdd = edgesToAddBatches.flat();
|
|
168
|
+
if (edgesToRemoveBatches.length > 0)
|
|
169
|
+
mergedUpdate.edgesToRemove = edgesToRemoveBatches.flat();
|
|
170
|
+
if (edgesToUpdateBatches.length > 0)
|
|
171
|
+
mergedUpdate.edgesToUpdate = edgesToUpdateBatches.flat();
|
|
172
|
+
if (metadataUpdates.length > 0) {
|
|
173
|
+
mergedUpdate.metadataUpdate = Object.assign({}, ...metadataUpdates);
|
|
174
|
+
}
|
|
175
|
+
return { mergedUpdate, commandsCount, actionTypes: [...actionTypesSet] };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { Transaction };
|