@likec4/diagram 1.45.0 → 1.46.2
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/bundle/index.js +2488 -1959
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +8 -7
- package/dist/LikeC4Diagram.props.d.ts +4 -12
- package/dist/LikeC4ProjectsProvider.js +8 -4
- package/dist/LikeC4View.js +1 -5
- package/dist/ReactLikeC4.d.ts +1 -4
- package/dist/StaticLikeC4Diagram.js +0 -2
- package/dist/base-primitives/NodeHandles.d.ts +2 -1
- package/dist/base-primitives/NodeHandles.js +22 -18
- package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +2 -3
- package/dist/base-primitives/edge/EdgeLabel.js +16 -16
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.js +5 -4
- package/dist/base-primitives/edge/EdgePath.js +13 -18
- package/dist/base-primitives/element/ElementActionButtons.js +1 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +1 -1
- package/dist/base-primitives/memoNode.js +1 -1
- package/dist/components/ErrorFallback.js +1 -1
- package/dist/components/Link.js +2 -2
- package/dist/context/DiagramEventHandlers.js +0 -1
- package/dist/context/DiagramFeatures.d.ts +1 -1
- package/dist/context/DiagramFeatures.js +1 -0
- package/dist/context/EnsureMantine.js +2 -1
- package/dist/context/IconRenderer.js +6 -6
- package/dist/editor/LikeC4EditorProvider.d.ts +22 -0
- package/dist/editor/LikeC4EditorProvider.js +12 -0
- package/dist/editor/__tests__/fixture.d.ts +205 -0
- package/dist/editor/applyChangesToManualLayout.d.ts +8 -0
- package/dist/editor/applyChangesToManualLayout.js +182 -0
- package/dist/editor/editorActor.actions.d.ts +201 -0
- package/dist/editor/editorActor.actions.js +149 -0
- package/dist/editor/editorActor.d.ts +653 -0
- package/dist/editor/editorActor.js +324 -0
- package/dist/editor/hotkeyActor.d.ts +7 -0
- package/dist/editor/hotkeyActor.js +19 -0
- package/dist/editor/index.d.ts +3 -2
- package/dist/editor/useEditorActorLogic.d.ts +565 -0
- package/dist/editor/useEditorActorLogic.js +54 -0
- package/dist/hooks/safeContext.d.ts +3 -2
- package/dist/hooks/safeContext.js +7 -4
- package/dist/hooks/useDiagram.d.ts +4 -2
- package/dist/hooks/useDiagram.js +19 -8
- package/dist/hooks/useDiagramCompareLayout.d.ts +8 -0
- package/dist/hooks/useDiagramCompareLayout.js +22 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/likec4diagram/DiagramXYFlow.js +1 -2
- package/dist/likec4diagram/custom/edges/EdgeDrifts.js +1 -5
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +74 -48
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +0 -1
- package/dist/likec4diagram/custom/edges/edges.css.js +30 -24
- package/dist/likec4diagram/custom/edges/useControlPoints.js +2 -2
- package/dist/likec4diagram/custom/nodes/ElementActions.js +2 -2
- package/dist/likec4diagram/custom/nodes/NodeDrifts.js +4 -9
- package/dist/likec4diagram/custom/nodes/nodes.js +3 -6
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +2 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +127 -14
- package/dist/likec4diagram/state/DiagramActorProvider.js +63 -71
- package/dist/likec4diagram/state/assign.d.ts +4 -1
- package/dist/likec4diagram/state/assign.js +11 -8
- package/dist/likec4diagram/state/createViewChange.js +13 -9
- package/dist/likec4diagram/state/diagram-api.d.ts +20 -2
- package/dist/likec4diagram/state/diagram-api.js +58 -44
- package/dist/likec4diagram/state/hotkeyActor.d.ts +1 -1
- package/dist/likec4diagram/state/hotkeyActor.js +12 -0
- package/dist/likec4diagram/state/machine.actions.d.ts +774 -195
- package/dist/likec4diagram/state/machine.actions.js +185 -74
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +93 -31
- package/dist/likec4diagram/state/machine.actions.layout.js +16 -4
- package/dist/likec4diagram/state/machine.d.ts +5 -4
- package/dist/likec4diagram/state/machine.js +11 -6
- package/dist/likec4diagram/state/machine.setup.d.ts +20 -9
- package/dist/likec4diagram/state/machine.setup.js +18 -3
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +34 -18
- package/dist/likec4diagram/state/machine.state.initializing.js +10 -10
- package/dist/likec4diagram/state/machine.state.navigating.js +28 -9
- package/dist/likec4diagram/state/machine.state.ready.d.ts +1368 -434
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +363 -39
- package/dist/likec4diagram/state/machine.state.ready.focused.js +17 -4
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +104 -38
- package/dist/likec4diagram/state/machine.state.ready.idle.js +14 -5
- package/dist/likec4diagram/state/machine.state.ready.js +13 -90
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +18 -6
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +204 -31
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +14 -1
- package/dist/likec4diagram/state/types.d.ts +6 -2
- package/dist/likec4diagram/state/utils.d.ts +33 -7
- package/dist/likec4diagram/state/utils.js +23 -7
- package/dist/likec4diagram/ui/notation/NotationPanel.js +3 -3
- package/dist/likec4diagram/useLayoutConstraints.js +5 -9
- package/dist/navigationpanel/NavigationPanel.js +6 -9
- package/dist/navigationpanel/NavigationPanelDropdown.js +7 -7
- package/dist/navigationpanel/_common.js +1 -1
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -1
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +40 -14
- package/dist/navigationpanel/comparepanel/ComparePanelControls.js +6 -4
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +2 -2
- package/dist/navigationpanel/controls/DetailsControls.js +2 -2
- package/dist/navigationpanel/controls/LayoutWarning.js +2 -1
- package/dist/navigationpanel/controls/NavigationButtons.js +2 -2
- package/dist/navigationpanel/controls/OpenSource.js +1 -1
- package/dist/navigationpanel/controls/SearchControl.js +2 -2
- package/dist/navigationpanel/controls/ToggleReadonly.js +25 -17
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
- package/dist/navigationpanel/editorpanel/CenterCamera.js +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +1 -1
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +9 -9
- package/dist/navigationpanel/editorpanel/ToggleReadonly.js +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +3 -3
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +1 -1
- package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.2.0 → @tabler_icons-react@3.36.0_react@19.2.3}/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +1 -1
- package/dist/overlays/Overlays.js +23 -11
- package/dist/overlays/element-details/ElementDetailsCard.css.js +8 -11
- package/dist/overlays/element-details/ElementDetailsCard.js +4 -4
- package/dist/overlays/element-details/MetadataValue.js +4 -6
- package/dist/overlays/element-details/TabPanelDeployments.js +3 -3
- package/dist/overlays/element-details/TabPanelRelationships.js +12 -7
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/overlaysActor.js +6 -5
- package/dist/overlays/relationship-details/RelationshipDetails.js +3 -3
- package/dist/overlays/relationship-details/SelectEdge.js +2 -2
- package/dist/overlays/relationship-details/custom/ElementActions.js +3 -3
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +3 -3
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/custom/ElementActions.js +3 -3
- package/dist/search/components/ElementsColumn.js +16 -11
- package/dist/search/components/PickView.js +3 -1
- package/dist/search/components/SearchByTags.js +1 -1
- package/dist/search/components/SearchInput.js +1 -1
- package/dist/search/components/ViewsColum.d.ts +3 -1
- package/dist/search/components/ViewsColum.js +14 -9
- package/dist/search/components/utils.d.ts +6 -0
- package/dist/search/components/utils.js +4 -1
- package/dist/shadowroot/styles.css.js +6 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/xyflow.d.ts +2 -3
- package/dist/utils/xyflow.js +9 -8
- package/package.json +22 -22
- package/panda.buildinfo.json +61 -80
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/dist/base-primitives/edge/edge.css.d.ts +0 -4
- package/dist/base-primitives/edge/edge.css.js +0 -71
- package/dist/editor/LikeC4EditorContext.d.ts +0 -21
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +0 -46
- package/dist/likec4diagram/state/syncManualLayoutActor.js +0 -309
- package/dist/utils/vector.d.ts +0 -86
- package/dist/utils/vector.js +0 -127
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { css } from '@likec4/styles/css';
|
|
2
|
-
|
|
3
|
-
const isSelected = ".react-flow__edge.selected";
|
|
4
|
-
const edgeContainer = css({
|
|
5
|
-
_reduceGraphics: {
|
|
6
|
-
transition: "none"
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
const edgePathBg = css({
|
|
10
|
-
pointerEvents: "none",
|
|
11
|
-
fill: "none",
|
|
12
|
-
strokeWidth: "calc(var(--xy-edge-stroke-width) + 2)",
|
|
13
|
-
strokeOpacity: 0.08,
|
|
14
|
-
_noReduceGraphics: {
|
|
15
|
-
transitionProperty: "stroke-width, stroke-opacity",
|
|
16
|
-
transitionDuration: "fast",
|
|
17
|
-
transitionTimingFunction: "inOut"
|
|
18
|
-
},
|
|
19
|
-
_whenHovered: {
|
|
20
|
-
transitionTimingFunction: "out",
|
|
21
|
-
strokeWidth: "calc(var(--xy-edge-stroke-width) + 4)",
|
|
22
|
-
strokeOpacity: 0.2
|
|
23
|
-
},
|
|
24
|
-
_whenSelected: {
|
|
25
|
-
strokeWidth: "calc(var(--xy-edge-stroke-width) + 6)",
|
|
26
|
-
strokeOpacity: 0.25,
|
|
27
|
-
_whenHovered: {
|
|
28
|
-
strokeOpacity: 0.4
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const markerContext = css({
|
|
33
|
-
fill: "[var(--xy-edge-stroke)]",
|
|
34
|
-
stroke: "[var(--xy-edge-stroke)]"
|
|
35
|
-
});
|
|
36
|
-
const cssEdgePath = css({
|
|
37
|
-
fill: "none",
|
|
38
|
-
strokeDashoffset: 0,
|
|
39
|
-
_noReduceGraphics: {
|
|
40
|
-
animationStyle: "xyedgeAnimated",
|
|
41
|
-
animationPlayState: "paused",
|
|
42
|
-
transition: "stroke 130ms ease-out,stroke-width 130ms ease-out"
|
|
43
|
-
},
|
|
44
|
-
[`:where([data-edge-dir='back']) &`]: {
|
|
45
|
-
animationDirection: "reverse"
|
|
46
|
-
},
|
|
47
|
-
_whenHovered: {
|
|
48
|
-
_noReduceGraphics: {
|
|
49
|
-
animationPlayState: "running",
|
|
50
|
-
animationDelay: "450ms"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
[`:where(${isSelected}, [data-edge-active='true'], [data-edge-animated='true']) &`]: {
|
|
54
|
-
_noReduceGraphics: {
|
|
55
|
-
animationPlayState: "running",
|
|
56
|
-
animationDelay: "0ms"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
_whenDimmed: {
|
|
60
|
-
animationPlayState: "paused"
|
|
61
|
-
},
|
|
62
|
-
_smallZoom: {
|
|
63
|
-
animationName: "none"
|
|
64
|
-
},
|
|
65
|
-
_whenPanning: {
|
|
66
|
-
strokeDasharray: "none !important",
|
|
67
|
-
animationPlayState: "paused"
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
export { cssEdgePath, edgeContainer, edgePathBg, markerContext };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { OnChange } from '../LikeC4Diagram.props';
|
|
3
|
-
import type * as t from '@likec4/core/types';
|
|
4
|
-
export type LikeC4EditorContextType = {
|
|
5
|
-
/**
|
|
6
|
-
* Fetch a view by its ID and layout type.
|
|
7
|
-
*
|
|
8
|
-
* @param viewId - The ID of the view to fetch.
|
|
9
|
-
* @param layout - The layout type to use when fetching the view.
|
|
10
|
-
*/
|
|
11
|
-
fetchView(viewId: t.ViewId, layout?: t.LayoutType): Promise<t.LayoutedView>;
|
|
12
|
-
syncManualLayout(viewId: t.ViewId): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Callback invoked when the view changes.
|
|
15
|
-
*/
|
|
16
|
-
onChange: OnChange;
|
|
17
|
-
};
|
|
18
|
-
export declare function LikeC4EditorContext({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export declare function EnsureEditorContext({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
-
export declare function useOptionalLikeC4Editor(): LikeC4EditorContextType | null;
|
|
21
|
-
export declare function useLikeC4Editor(): LikeC4EditorContextType;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { LayoutedView, ViewChange, ViewId } from '@likec4/core/types';
|
|
2
|
-
import { ActorRef, MachineSnapshot, StateMachine } from 'xstate';
|
|
3
|
-
import { Types } from '../types';
|
|
4
|
-
export type Input = {
|
|
5
|
-
viewId: ViewId;
|
|
6
|
-
};
|
|
7
|
-
type HistorySnapshot = {
|
|
8
|
-
view: LayoutedView;
|
|
9
|
-
change: ViewChange.SaveViewSnapshot;
|
|
10
|
-
xynodes: Types.Node[];
|
|
11
|
-
xyedges: Types.Edge[];
|
|
12
|
-
synched: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type Context = Readonly<Input & {
|
|
15
|
-
history: ReadonlyArray<HistorySnapshot>;
|
|
16
|
-
beforeEditing: HistorySnapshot | null;
|
|
17
|
-
editing: 'node' | 'edge' | null;
|
|
18
|
-
}>;
|
|
19
|
-
export type Events = {
|
|
20
|
-
type: 'sync';
|
|
21
|
-
} | {
|
|
22
|
-
type: 'synced';
|
|
23
|
-
} | {
|
|
24
|
-
type: 'editing.start';
|
|
25
|
-
subject: 'node' | 'edge';
|
|
26
|
-
} | {
|
|
27
|
-
type: 'editing.stop';
|
|
28
|
-
wasChanged?: boolean;
|
|
29
|
-
} | {
|
|
30
|
-
type: 'cancel';
|
|
31
|
-
} | {
|
|
32
|
-
type: 'undo';
|
|
33
|
-
} | {
|
|
34
|
-
type: 'stop';
|
|
35
|
-
};
|
|
36
|
-
type Tags = 'pending' | 'ready';
|
|
37
|
-
/**
|
|
38
|
-
* Here is a trick to reduce inference types
|
|
39
|
-
*/
|
|
40
|
-
export interface SyncLayoutActorLogic extends StateMachine<Context, Events, {}, any, any, any, any, any, Tags, Input, any, any, any, any> {
|
|
41
|
-
}
|
|
42
|
-
export type SyncLayoutActorSnapshot = MachineSnapshot<Context, Events, {}, never, Tags, never, {}, {}>;
|
|
43
|
-
export interface SyncLayoutActorRef extends ActorRef<SyncLayoutActorSnapshot, Events> {
|
|
44
|
-
}
|
|
45
|
-
export declare const syncManualLayoutActorLogic: SyncLayoutActorLogic;
|
|
46
|
-
export {};
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { getHotkeyHandler } from '@mantine/hooks';
|
|
2
|
-
import { last, omit } from 'remeda';
|
|
3
|
-
import { setup, assign, stopChild, fromCallback, assertEvent } from 'xstate';
|
|
4
|
-
import { createViewChange } from './createViewChange.js';
|
|
5
|
-
|
|
6
|
-
const undoHotKeyActorLogic = fromCallback(({ sendBack }) => {
|
|
7
|
-
const ctrlZHandler = getHotkeyHandler([
|
|
8
|
-
["mod + z", (event) => {
|
|
9
|
-
event.stopPropagation();
|
|
10
|
-
sendBack({ type: "undo" });
|
|
11
|
-
}, {
|
|
12
|
-
preventDefault: true
|
|
13
|
-
}]
|
|
14
|
-
]);
|
|
15
|
-
document.body.addEventListener("keydown", ctrlZHandler, { capture: true });
|
|
16
|
-
return () => {
|
|
17
|
-
document.body.removeEventListener("keydown", ctrlZHandler, { capture: true });
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
const diagramActorRef = function(system) {
|
|
21
|
-
return system.get("diagram");
|
|
22
|
-
};
|
|
23
|
-
const syncManualLayout = setup({
|
|
24
|
-
types: {
|
|
25
|
-
context: {},
|
|
26
|
-
input: {},
|
|
27
|
-
events: {},
|
|
28
|
-
tags: "",
|
|
29
|
-
children: {}
|
|
30
|
-
},
|
|
31
|
-
delays: {
|
|
32
|
-
"timeout": 2e3
|
|
33
|
-
},
|
|
34
|
-
guards: {
|
|
35
|
-
"can undo": ({ context }) => context.history.length > 0
|
|
36
|
-
},
|
|
37
|
-
actors: {
|
|
38
|
-
undoHotKeyActorLogic
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const raiseSync = syncManualLayout.raise({ type: "sync" }, { delay: 300, id: "sync" });
|
|
42
|
-
const cancelSync = syncManualLayout.cancel("sync");
|
|
43
|
-
const startEditing = syncManualLayout.enqueueActions(({ check, enqueue, system, event, self, context }) => {
|
|
44
|
-
assertEvent(event, "editing.start");
|
|
45
|
-
const parentContext = diagramActorRef(system).getSnapshot().context;
|
|
46
|
-
enqueue.assign({
|
|
47
|
-
editing: event.subject,
|
|
48
|
-
beforeEditing: {
|
|
49
|
-
xynodes: parentContext.xynodes.map(
|
|
50
|
-
({ measured, style, ...n }) => ({
|
|
51
|
-
...omit(n, ["selected", "dragging", "resizing"]),
|
|
52
|
-
data: omit(n.data, ["dimmed", "hovered"]),
|
|
53
|
-
initialWidth: measured?.width ?? n.width ?? n.initialWidth,
|
|
54
|
-
initialHeight: measured?.height ?? n.height ?? n.initialHeight
|
|
55
|
-
})
|
|
56
|
-
),
|
|
57
|
-
xyedges: parentContext.xyedges.map(
|
|
58
|
-
(e) => ({
|
|
59
|
-
...omit(e, ["selected"]),
|
|
60
|
-
data: omit(e.data, ["active", "dimmed", "hovered"])
|
|
61
|
-
})
|
|
62
|
-
),
|
|
63
|
-
change: createViewChange(parentContext),
|
|
64
|
-
view: parentContext.view,
|
|
65
|
-
synched: false
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
const ensureHotKey = syncManualLayout.enqueueActions(({ check, context, enqueue, self }) => {
|
|
70
|
-
const hasUndo = context.history.length > 0;
|
|
71
|
-
const undoHotKey = self.getSnapshot().children["undoHotKey"];
|
|
72
|
-
if (undoHotKey && !hasUndo) {
|
|
73
|
-
enqueue.stopChild(undoHotKey);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (!undoHotKey && hasUndo) {
|
|
77
|
-
enqueue.spawnChild("undoHotKeyActorLogic", {
|
|
78
|
-
id: "undoHotKey"
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
const pushHistory = syncManualLayout.assign(({ context }) => {
|
|
83
|
-
const snapshot = context.beforeEditing;
|
|
84
|
-
if (!snapshot) {
|
|
85
|
-
return {
|
|
86
|
-
editing: null
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
beforeEditing: null,
|
|
91
|
-
editing: null,
|
|
92
|
-
history: [
|
|
93
|
-
...context.history,
|
|
94
|
-
snapshot
|
|
95
|
-
]
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
const stopEditing = syncManualLayout.enqueueActions(({ event, enqueue }) => {
|
|
99
|
-
assertEvent(event, ["editing.stop", "cancel", "undo"]);
|
|
100
|
-
if (event.type === "editing.stop" && event.wasChanged) {
|
|
101
|
-
enqueue(pushHistory);
|
|
102
|
-
enqueue(ensureHotKey);
|
|
103
|
-
enqueue(raiseSync);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
enqueue.assign({
|
|
107
|
-
beforeEditing: null,
|
|
108
|
-
editing: null
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
const markHistoryAsSynched = syncManualLayout.assign(({ context, event }) => {
|
|
112
|
-
assertEvent(event, "synced");
|
|
113
|
-
return {
|
|
114
|
-
history: context.history.map((i) => ({
|
|
115
|
-
...i,
|
|
116
|
-
synched: true
|
|
117
|
-
}))
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
const popHistory = syncManualLayout.assign(({ context }) => {
|
|
121
|
-
if (context.history.length === 0 || context.history.length === 1) {
|
|
122
|
-
return {
|
|
123
|
-
history: []
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
history: context.history.slice(0, context.history.length - 1)
|
|
128
|
-
};
|
|
129
|
-
});
|
|
130
|
-
const undo = syncManualLayout.enqueueActions(({ context, enqueue, system }) => {
|
|
131
|
-
enqueue(cancelSync);
|
|
132
|
-
const lastHistoryItem = last(context.history);
|
|
133
|
-
if (!lastHistoryItem) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
enqueue(popHistory);
|
|
137
|
-
enqueue(ensureHotKey);
|
|
138
|
-
const diagramActor = diagramActorRef(system);
|
|
139
|
-
enqueue.sendTo(diagramActor, {
|
|
140
|
-
type: "update.view",
|
|
141
|
-
view: lastHistoryItem.view,
|
|
142
|
-
xyedges: lastHistoryItem.xyedges,
|
|
143
|
-
xynodes: lastHistoryItem.xynodes,
|
|
144
|
-
source: "internal"
|
|
145
|
-
});
|
|
146
|
-
if (lastHistoryItem.synched) {
|
|
147
|
-
enqueue.sendTo(
|
|
148
|
-
diagramActor,
|
|
149
|
-
{
|
|
150
|
-
type: "emit.onChange",
|
|
151
|
-
change: lastHistoryItem.change
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
} else {
|
|
155
|
-
enqueue(raiseSync);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
const emitOnChange = syncManualLayout.enqueueActions(({ context, enqueue, system }) => {
|
|
159
|
-
enqueue(cancelSync);
|
|
160
|
-
const diagramActor = diagramActorRef(system);
|
|
161
|
-
const parentContext = diagramActor.getSnapshot().context;
|
|
162
|
-
const change = createViewChange(parentContext);
|
|
163
|
-
enqueue.sendTo(diagramActor, {
|
|
164
|
-
type: "update.view-bounds",
|
|
165
|
-
bounds: change.layout.bounds
|
|
166
|
-
});
|
|
167
|
-
enqueue.sendTo(diagramActor, {
|
|
168
|
-
type: "emit.onChange",
|
|
169
|
-
change
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
const idle = syncManualLayout.createStateConfig({
|
|
173
|
-
tags: "ready",
|
|
174
|
-
on: {
|
|
175
|
-
sync: {
|
|
176
|
-
target: "pending"
|
|
177
|
-
},
|
|
178
|
-
"editing.start": {
|
|
179
|
-
actions: startEditing,
|
|
180
|
-
target: "editing"
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
const editing = syncManualLayout.createStateConfig({
|
|
185
|
-
entry: [
|
|
186
|
-
cancelSync
|
|
187
|
-
],
|
|
188
|
-
on: {
|
|
189
|
-
cancel: {
|
|
190
|
-
actions: stopEditing,
|
|
191
|
-
target: "idle"
|
|
192
|
-
},
|
|
193
|
-
"editing.stop": {
|
|
194
|
-
actions: stopEditing,
|
|
195
|
-
target: "idle"
|
|
196
|
-
},
|
|
197
|
-
undo: {
|
|
198
|
-
actions: stopEditing,
|
|
199
|
-
target: "idle"
|
|
200
|
-
},
|
|
201
|
-
synced: {
|
|
202
|
-
actions: [
|
|
203
|
-
markHistoryAsSynched
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
const pending = syncManualLayout.createStateConfig({
|
|
209
|
-
tags: "pending",
|
|
210
|
-
on: {
|
|
211
|
-
cancel: {
|
|
212
|
-
actions: cancelSync,
|
|
213
|
-
target: "idle"
|
|
214
|
-
},
|
|
215
|
-
sync: {
|
|
216
|
-
target: "pending",
|
|
217
|
-
reenter: true
|
|
218
|
-
},
|
|
219
|
-
"editing.start": {
|
|
220
|
-
target: "paused",
|
|
221
|
-
actions: startEditing
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
after: {
|
|
225
|
-
"timeout": {
|
|
226
|
-
target: "idle",
|
|
227
|
-
actions: emitOnChange
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
const paused = syncManualLayout.createStateConfig({
|
|
232
|
-
tags: "pending",
|
|
233
|
-
entry: [
|
|
234
|
-
cancelSync
|
|
235
|
-
],
|
|
236
|
-
on: {
|
|
237
|
-
cancel: {
|
|
238
|
-
actions: stopEditing,
|
|
239
|
-
target: "idle"
|
|
240
|
-
},
|
|
241
|
-
"editing.stop": {
|
|
242
|
-
actions: stopEditing,
|
|
243
|
-
target: "pending"
|
|
244
|
-
},
|
|
245
|
-
undo: {
|
|
246
|
-
actions: stopEditing,
|
|
247
|
-
target: "idle"
|
|
248
|
-
},
|
|
249
|
-
// When external sync is done while editing, we just mark history as synced
|
|
250
|
-
// but go to editing state (that does not return to pending)
|
|
251
|
-
synced: {
|
|
252
|
-
actions: [
|
|
253
|
-
markHistoryAsSynched
|
|
254
|
-
],
|
|
255
|
-
target: "editing"
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
const _syncManualLayoutActorLogic = syncManualLayout.createMachine({
|
|
260
|
-
initial: "idle",
|
|
261
|
-
context: ({ input }) => ({
|
|
262
|
-
...input,
|
|
263
|
-
history: [],
|
|
264
|
-
beforeEditing: null,
|
|
265
|
-
editing: null
|
|
266
|
-
}),
|
|
267
|
-
states: {
|
|
268
|
-
idle,
|
|
269
|
-
editing,
|
|
270
|
-
pending,
|
|
271
|
-
paused,
|
|
272
|
-
stopped: {
|
|
273
|
-
entry: [
|
|
274
|
-
assign({
|
|
275
|
-
beforeEditing: null,
|
|
276
|
-
history: []
|
|
277
|
-
}),
|
|
278
|
-
stopChild("undoHotKey")
|
|
279
|
-
],
|
|
280
|
-
type: "final"
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
on: {
|
|
284
|
-
cancel: {
|
|
285
|
-
actions: [
|
|
286
|
-
cancelSync
|
|
287
|
-
],
|
|
288
|
-
target: ".idle"
|
|
289
|
-
},
|
|
290
|
-
synced: {
|
|
291
|
-
actions: [
|
|
292
|
-
markHistoryAsSynched,
|
|
293
|
-
cancelSync
|
|
294
|
-
],
|
|
295
|
-
target: ".idle"
|
|
296
|
-
},
|
|
297
|
-
undo: {
|
|
298
|
-
guard: "can undo",
|
|
299
|
-
actions: undo,
|
|
300
|
-
target: ".idle"
|
|
301
|
-
},
|
|
302
|
-
stop: {
|
|
303
|
-
target: ".stopped"
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
const syncManualLayoutActorLogic = _syncManualLayoutActorLogic;
|
|
308
|
-
|
|
309
|
-
export { syncManualLayoutActorLogic };
|
package/dist/utils/vector.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
export interface VectorValue {
|
|
2
|
-
readonly x: number;
|
|
3
|
-
readonly y: number;
|
|
4
|
-
}
|
|
5
|
-
export declare class Vector implements VectorValue {
|
|
6
|
-
readonly x: number;
|
|
7
|
-
readonly y: number;
|
|
8
|
-
constructor(x: number, y: number);
|
|
9
|
-
static create(position: VectorValue): Vector;
|
|
10
|
-
static create(x: number, y: number): Vector;
|
|
11
|
-
/**
|
|
12
|
-
* Adds two vectors.
|
|
13
|
-
* @param a The first vector.
|
|
14
|
-
* @param b The second vector.
|
|
15
|
-
* @returns The sum of the two vectors.
|
|
16
|
-
*/
|
|
17
|
-
static add(a: VectorValue, b: VectorValue): VectorValue;
|
|
18
|
-
/**
|
|
19
|
-
* Subtracts two vectors.
|
|
20
|
-
* @param a The first vector.
|
|
21
|
-
* @param b The second vector.
|
|
22
|
-
* @returns The difference of the two vectors.
|
|
23
|
-
*/
|
|
24
|
-
static subtract(a: VectorValue, b: VectorValue): VectorValue;
|
|
25
|
-
/**
|
|
26
|
-
* Multiplies a vector by a scalar.
|
|
27
|
-
* @param a The vector.
|
|
28
|
-
* @param b The scalar.
|
|
29
|
-
* @returns The scaled vector.
|
|
30
|
-
*/
|
|
31
|
-
static multiply(a: VectorValue, b: number): VectorValue;
|
|
32
|
-
/**
|
|
33
|
-
* Calculates the dot product of the vectors.
|
|
34
|
-
* @param a The first vector.
|
|
35
|
-
* @param b The second vector.
|
|
36
|
-
* @returns The dot product.
|
|
37
|
-
*/
|
|
38
|
-
static dot(a: VectorValue, b: VectorValue): number;
|
|
39
|
-
/**
|
|
40
|
-
* Adds the given vector to this vector.
|
|
41
|
-
* @param b The vector to add.
|
|
42
|
-
* @returns A new vector that is the sum of this vector and the given vector.
|
|
43
|
-
*/
|
|
44
|
-
add(b: VectorValue): Vector;
|
|
45
|
-
/**
|
|
46
|
-
* Subtracts the given vector from this vector.
|
|
47
|
-
* @param b The vector to subtract.
|
|
48
|
-
* @returns A new vector that is the difference of this vector and the given vector.
|
|
49
|
-
*/
|
|
50
|
-
subtract(b: VectorValue): Vector;
|
|
51
|
-
/**
|
|
52
|
-
* Multiplies this vector by a scalar.
|
|
53
|
-
* @param b The scalar to multiply by.
|
|
54
|
-
* @returns A new vector that is the product of this vector and the given scalar.
|
|
55
|
-
*/
|
|
56
|
-
multiply(b: number): Vector;
|
|
57
|
-
/**
|
|
58
|
-
* Calculates the dot product of this vector and another vector.
|
|
59
|
-
* @param b The other vector.
|
|
60
|
-
* @returns The dot product.
|
|
61
|
-
*/
|
|
62
|
-
dot(b: VectorValue): number;
|
|
63
|
-
/**
|
|
64
|
-
* Calculates the cross product of this vector and another vector.
|
|
65
|
-
* @param b The other vector.
|
|
66
|
-
* @returns The cross product as a new vector.
|
|
67
|
-
*/
|
|
68
|
-
cross(b: VectorValue): Vector;
|
|
69
|
-
/**
|
|
70
|
-
* Calculates the length (magnitude) of this vector.
|
|
71
|
-
* @returns The length of the vector.
|
|
72
|
-
*/
|
|
73
|
-
length(): number;
|
|
74
|
-
/**
|
|
75
|
-
* Normalizes the vector (makes it unit length, i.e., has a length of 1).
|
|
76
|
-
* @returns A new vector that is the normalized version of this vector.
|
|
77
|
-
*/
|
|
78
|
-
normalize(): Vector;
|
|
79
|
-
/**
|
|
80
|
-
* Rounds the components of the vector to the nearest integers.
|
|
81
|
-
* @returns A new vector with rounded components.
|
|
82
|
-
*/
|
|
83
|
-
round(): Vector;
|
|
84
|
-
}
|
|
85
|
-
export declare function vector(source: VectorValue | Vector): Vector;
|
|
86
|
-
export declare function vector(x: number, y: number): Vector;
|
package/dist/utils/vector.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
class Vector {
|
|
2
|
-
constructor(x, y) {
|
|
3
|
-
this.x = x;
|
|
4
|
-
this.y = y;
|
|
5
|
-
}
|
|
6
|
-
static create(...args) {
|
|
7
|
-
if (args.length === 2) {
|
|
8
|
-
return new Vector(args[0], args[1]);
|
|
9
|
-
}
|
|
10
|
-
return new Vector(args[0].x, args[0].y);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Adds two vectors.
|
|
14
|
-
* @param a The first vector.
|
|
15
|
-
* @param b The second vector.
|
|
16
|
-
* @returns The sum of the two vectors.
|
|
17
|
-
*/
|
|
18
|
-
static add(a, b) {
|
|
19
|
-
return { x: a.x + b.x, y: a.y + b.y };
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Subtracts two vectors.
|
|
23
|
-
* @param a The first vector.
|
|
24
|
-
* @param b The second vector.
|
|
25
|
-
* @returns The difference of the two vectors.
|
|
26
|
-
*/
|
|
27
|
-
static subtract(a, b) {
|
|
28
|
-
return { x: a.x - b.x, y: a.y - b.y };
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Multiplies a vector by a scalar.
|
|
32
|
-
* @param a The vector.
|
|
33
|
-
* @param b The scalar.
|
|
34
|
-
* @returns The scaled vector.
|
|
35
|
-
*/
|
|
36
|
-
static multiply(a, b) {
|
|
37
|
-
return { x: a.x * b, y: a.y * b };
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Calculates the dot product of the vectors.
|
|
41
|
-
* @param a The first vector.
|
|
42
|
-
* @param b The second vector.
|
|
43
|
-
* @returns The dot product.
|
|
44
|
-
*/
|
|
45
|
-
static dot(a, b) {
|
|
46
|
-
return a.x * b.x + a.y * b.y;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Adds the given vector to this vector.
|
|
50
|
-
* @param b The vector to add.
|
|
51
|
-
* @returns A new vector that is the sum of this vector and the given vector.
|
|
52
|
-
*/
|
|
53
|
-
add(b) {
|
|
54
|
-
return new Vector(this.x + b.x, this.y + b.y);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Subtracts the given vector from this vector.
|
|
58
|
-
* @param b The vector to subtract.
|
|
59
|
-
* @returns A new vector that is the difference of this vector and the given vector.
|
|
60
|
-
*/
|
|
61
|
-
subtract(b) {
|
|
62
|
-
return new Vector(this.x - b.x, this.y - b.y);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Multiplies this vector by a scalar.
|
|
66
|
-
* @param b The scalar to multiply by.
|
|
67
|
-
* @returns A new vector that is the product of this vector and the given scalar.
|
|
68
|
-
*/
|
|
69
|
-
multiply(b) {
|
|
70
|
-
return new Vector(this.x * b, this.y * b);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Calculates the dot product of this vector and another vector.
|
|
74
|
-
* @param b The other vector.
|
|
75
|
-
* @returns The dot product.
|
|
76
|
-
*/
|
|
77
|
-
dot(b) {
|
|
78
|
-
return this.x * b.x + this.y * b.y;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Calculates the cross product of this vector and another vector.
|
|
82
|
-
* @param b The other vector.
|
|
83
|
-
* @returns The cross product as a new vector.
|
|
84
|
-
*/
|
|
85
|
-
cross(b) {
|
|
86
|
-
return new Vector(this.y * b.x - this.x * b.y, this.x * b.y - this.y * b.x);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Calculates the length (magnitude) of this vector.
|
|
90
|
-
* @returns The length of the vector.
|
|
91
|
-
*/
|
|
92
|
-
length() {
|
|
93
|
-
if (this.x === 0 && this.y === 0) {
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
return Math.sqrt(this.x ** 2 + this.y ** 2);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Normalizes the vector (makes it unit length, i.e., has a length of 1).
|
|
100
|
-
* @returns A new vector that is the normalized version of this vector.
|
|
101
|
-
*/
|
|
102
|
-
normalize() {
|
|
103
|
-
const len = this.length();
|
|
104
|
-
if (len === 0) {
|
|
105
|
-
return new Vector(0, 0);
|
|
106
|
-
}
|
|
107
|
-
return new Vector(this.x / len, this.y / len);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Rounds the components of the vector to the nearest integers.
|
|
111
|
-
* @returns A new vector with rounded components.
|
|
112
|
-
*/
|
|
113
|
-
round() {
|
|
114
|
-
return new Vector(Math.round(this.x), Math.round(this.y));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function vector(...args) {
|
|
118
|
-
if (args.length === 1 && args[0] instanceof Vector) {
|
|
119
|
-
return args[0];
|
|
120
|
-
}
|
|
121
|
-
if (args.length === 2) {
|
|
122
|
-
return new Vector(args[0], args[1]);
|
|
123
|
-
}
|
|
124
|
-
return new Vector(args[0].x, args[0].y);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { Vector, vector };
|