@xyflow/system 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +338 -139
- package/dist/esm/index.mjs +338 -139
- package/dist/esm/types/general.d.ts +6 -3
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/types/nodes.d.ts +3 -4
- package/dist/esm/types/nodes.d.ts.map +1 -1
- package/dist/esm/utils/connections.d.ts +3 -3
- package/dist/esm/utils/connections.d.ts.map +1 -1
- package/dist/esm/utils/dom.d.ts.map +1 -1
- package/dist/esm/utils/general.d.ts +1 -0
- package/dist/esm/utils/general.d.ts.map +1 -1
- package/dist/esm/utils/graph.d.ts +25 -6
- package/dist/esm/utils/graph.d.ts.map +1 -1
- package/dist/esm/utils/marker.d.ts +3 -1
- package/dist/esm/utils/marker.d.ts.map +1 -1
- package/dist/esm/xydrag/XYDrag.d.ts +5 -5
- package/dist/esm/xydrag/XYDrag.d.ts.map +1 -1
- package/dist/esm/xyhandle/XYHandle.d.ts.map +1 -1
- package/dist/esm/xyresizer/XYResizer.d.ts +7 -2
- package/dist/esm/xyresizer/XYResizer.d.ts.map +1 -1
- package/dist/esm/xyresizer/utils.d.ts +12 -13
- package/dist/esm/xyresizer/utils.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/types/general.d.ts +6 -3
- package/dist/umd/types/general.d.ts.map +1 -1
- package/dist/umd/types/nodes.d.ts +3 -4
- package/dist/umd/types/nodes.d.ts.map +1 -1
- package/dist/umd/utils/connections.d.ts +3 -3
- package/dist/umd/utils/connections.d.ts.map +1 -1
- package/dist/umd/utils/dom.d.ts.map +1 -1
- package/dist/umd/utils/general.d.ts +1 -0
- package/dist/umd/utils/general.d.ts.map +1 -1
- package/dist/umd/utils/graph.d.ts +25 -6
- package/dist/umd/utils/graph.d.ts.map +1 -1
- package/dist/umd/utils/marker.d.ts +3 -1
- package/dist/umd/utils/marker.d.ts.map +1 -1
- package/dist/umd/xydrag/XYDrag.d.ts +5 -5
- package/dist/umd/xydrag/XYDrag.d.ts.map +1 -1
- package/dist/umd/xyhandle/XYHandle.d.ts.map +1 -1
- package/dist/umd/xyresizer/XYResizer.d.ts +7 -2
- package/dist/umd/xyresizer/XYResizer.d.ts.map +1 -1
- package/dist/umd/xyresizer/utils.d.ts +12 -13
- package/dist/umd/xyresizer/utils.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Transform, type XYPosition, type Rect, type NodeOrigin, type NodeBase, type EdgeBase, type FitViewParamsBase, type FitViewOptionsBase,
|
|
1
|
+
import { type Transform, type XYPosition, type Rect, type NodeOrigin, type NodeBase, type EdgeBase, type FitViewParamsBase, type FitViewOptionsBase, CoordinateExtent, OnError, OnBeforeDeleteBase, NodeLookup } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Test whether an object is useable as an Edge
|
|
4
4
|
* @public
|
|
@@ -37,18 +37,24 @@ export declare const getOutgoers: <NodeType extends NodeBase<any, string | undef
|
|
|
37
37
|
export declare const getIncomers: <NodeType extends NodeBase<any, string | undefined> = NodeBase<any, string | undefined>, EdgeType extends EdgeBase<any> = EdgeBase<any>>(node: NodeType | {
|
|
38
38
|
id: string;
|
|
39
39
|
}, nodes: NodeType[], edges: EdgeType[]) => NodeType[];
|
|
40
|
-
export declare const getNodePositionWithOrigin: (node: NodeBase | undefined, nodeOrigin?: NodeOrigin) =>
|
|
40
|
+
export declare const getNodePositionWithOrigin: (node: NodeBase | undefined, nodeOrigin?: NodeOrigin) => {
|
|
41
|
+
position: XYPosition;
|
|
41
42
|
positionAbsolute: XYPosition;
|
|
42
43
|
};
|
|
44
|
+
export type GetNodesBoundsParams = {
|
|
45
|
+
nodeOrigin?: NodeOrigin;
|
|
46
|
+
useRelativePosition?: boolean;
|
|
47
|
+
};
|
|
43
48
|
/**
|
|
44
49
|
* Determines a bounding box that contains all given nodes in an array
|
|
45
50
|
* @public
|
|
46
51
|
* @remarks Useful when combined with {@link getViewportForBounds} to calculate the correct transform to fit the given nodes in a viewport.
|
|
47
52
|
* @param nodes - Nodes to calculate the bounds for
|
|
48
|
-
* @param nodeOrigin - Origin of the nodes: [0, 0] - top left, [0.5, 0.5] - center
|
|
53
|
+
* @param params.nodeOrigin - Origin of the nodes: [0, 0] - top left, [0.5, 0.5] - center
|
|
54
|
+
* @param params.useRelativePosition - Whether to use the relative or absolute node positions
|
|
49
55
|
* @returns Bounding box enclosing all nodes
|
|
50
56
|
*/
|
|
51
|
-
export declare const getNodesBounds: (nodes: NodeBase[],
|
|
57
|
+
export declare const getNodesBounds: (nodes: NodeBase[], params?: GetNodesBoundsParams) => Rect;
|
|
52
58
|
export declare const getNodesInside: <NodeType extends NodeBase<any, string | undefined>>(nodes: NodeType[], rect: Rect, [tx, ty, tScale]?: Transform, partially?: boolean, excludeNonSelectableNodes?: boolean, nodeOrigin?: NodeOrigin) => NodeType[];
|
|
53
59
|
/**
|
|
54
60
|
* Get all connecting edges for a given set of nodes
|
|
@@ -58,7 +64,20 @@ export declare const getNodesInside: <NodeType extends NodeBase<any, string | un
|
|
|
58
64
|
*/
|
|
59
65
|
export declare const getConnectedEdges: <NodeType extends NodeBase<any, string | undefined> = NodeBase<any, string | undefined>, EdgeType extends EdgeBase<any> = EdgeBase<any>>(nodes: NodeType[], edges: EdgeType[]) => EdgeType[];
|
|
60
66
|
export declare function fitView<Params extends FitViewParamsBase<NodeBase>, Options extends FitViewOptionsBase<NodeBase>>({ nodes, width, height, panZoom, minZoom, maxZoom, nodeOrigin }: Params, options?: Options): boolean;
|
|
61
|
-
|
|
67
|
+
/**
|
|
68
|
+
* This function calculates the next position of a node, taking into account the node's extent, parent node, and origin.
|
|
69
|
+
*
|
|
70
|
+
* @internal
|
|
71
|
+
* @returns position, positionAbsolute
|
|
72
|
+
*/
|
|
73
|
+
export declare function calculateNodePosition<NodeType extends NodeBase>({ nodeId, nextPosition, nodeLookup, nodeOrigin, nodeExtent, onError, }: {
|
|
74
|
+
nodeId: string;
|
|
75
|
+
nextPosition: XYPosition;
|
|
76
|
+
nodeLookup: NodeLookup<NodeType>;
|
|
77
|
+
nodeOrigin?: NodeOrigin;
|
|
78
|
+
nodeExtent?: CoordinateExtent;
|
|
79
|
+
onError?: OnError;
|
|
80
|
+
}): {
|
|
62
81
|
position: XYPosition;
|
|
63
82
|
positionAbsolute: XYPosition;
|
|
64
83
|
};
|
|
@@ -77,7 +96,7 @@ export declare function getElementsToRemove<NodeType extends NodeBase = NodeBase
|
|
|
77
96
|
edgesToRemove: Partial<EdgeType>[];
|
|
78
97
|
nodes: NodeType[];
|
|
79
98
|
edges: EdgeType[];
|
|
80
|
-
onBeforeDelete?:
|
|
99
|
+
onBeforeDelete?: OnBeforeDeleteBase<NodeType, EdgeType>;
|
|
81
100
|
}): Promise<{
|
|
82
101
|
nodes: NodeType[];
|
|
83
102
|
edges: EdgeType[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/utils/graph.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/utils/graph.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,4DAAmD,GAAG,wBACd,CAAC;AAEhE;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C,EAAE,OAAO,CAAC;CACnB,GAAG;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,gBAAgB,EAAE,UAAU,CAAA;CAAE,CA8CzD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,EACpH,aAAkB,EAClB,aAAkB,EAClB,KAAK,EACL,KAAK,EACL,cAAc,GACf,EAAE;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CACzD,GAAG,OAAO,CAAC;IACV,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC,CA+CD"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { EdgeBase, EdgeMarkerType, MarkerProps } from '../types';
|
|
2
2
|
export declare function getMarkerId(marker: EdgeMarkerType | undefined, id?: string | null): string;
|
|
3
|
-
export declare function createMarkerIds(edges: EdgeBase[], { id, defaultColor }: {
|
|
3
|
+
export declare function createMarkerIds(edges: EdgeBase[], { id, defaultColor, defaultMarkerStart, defaultMarkerEnd, }: {
|
|
4
4
|
id?: string | null;
|
|
5
5
|
defaultColor?: string;
|
|
6
|
+
defaultMarkerStart?: EdgeMarkerType;
|
|
7
|
+
defaultMarkerEnd?: EdgeMarkerType;
|
|
6
8
|
}): MarkerProps[];
|
|
7
9
|
//# sourceMappingURL=marker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../../src/utils/marker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAc,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElF,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAe1F;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,
|
|
1
|
+
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../../src/utils/marker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAc,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElF,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAe1F;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,EACE,EAAE,EACF,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,GACjB,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,cAAc,CAAC;IACpC,gBAAgB,CAAC,EAAE,cAAc,CAAC;CACnC,iBAmBF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { NodeBase, NodeDragItem, EdgeBase, CoordinateExtent, NodeOrigin, OnError, SnapGrid, Transform, PanBy,
|
|
1
|
+
import type { NodeBase, NodeDragItem, EdgeBase, CoordinateExtent, NodeOrigin, OnError, SnapGrid, Transform, PanBy, OnSelectionDrag, UpdateNodePositions } from '../types';
|
|
2
2
|
export type OnDrag = (event: MouseEvent, dragItems: NodeDragItem[], node: NodeBase, nodes: NodeBase[]) => void;
|
|
3
|
-
type StoreItems = {
|
|
3
|
+
type StoreItems<OnNodeDrag> = {
|
|
4
4
|
nodes: NodeBase[];
|
|
5
5
|
nodeLookup: Map<string, NodeBase>;
|
|
6
6
|
edges: EdgeBase[];
|
|
@@ -29,9 +29,9 @@ type StoreItems = {
|
|
|
29
29
|
onSelectionDragStop?: OnSelectionDrag;
|
|
30
30
|
updateNodePositions: UpdateNodePositions;
|
|
31
31
|
};
|
|
32
|
-
export type XYDragParams = {
|
|
32
|
+
export type XYDragParams<OnNodeDrag> = {
|
|
33
33
|
domNode: Element;
|
|
34
|
-
getStoreItems: () => StoreItems
|
|
34
|
+
getStoreItems: () => StoreItems<OnNodeDrag>;
|
|
35
35
|
onDragStart?: OnDrag;
|
|
36
36
|
onDrag?: OnDrag;
|
|
37
37
|
onDragStop?: OnDrag;
|
|
@@ -48,6 +48,6 @@ export type DragUpdateParams = {
|
|
|
48
48
|
nodeId?: string;
|
|
49
49
|
domNode: Element;
|
|
50
50
|
};
|
|
51
|
-
export declare function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragStop, }: XYDragParams): XYDragInstance;
|
|
51
|
+
export declare function XYDrag<OnNodeDrag extends (e: any, nodes: any, node: any) => void | undefined>({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragStop, }: XYDragParams<OnNodeDrag>): XYDragInstance;
|
|
52
52
|
export {};
|
|
53
53
|
//# sourceMappingURL=XYDrag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XYDrag.d.ts","sourceRoot":"","sources":["../../src/xydrag/XYDrag.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAGZ,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"XYDrag.d.ts","sourceRoot":"","sources":["../../src/xydrag/XYDrag.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EAGZ,QAAQ,EACR,gBAAgB,EAChB,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;IACZ,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACpC,CAAC;AAiQF,eAAO,MAAM,QAAQ,EAAE,gBAGtB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodeLookup, Transform } from '../types';
|
|
1
|
+
import type { CoordinateExtent, NodeLookup, Transform, XYPosition } from '../types';
|
|
2
2
|
import type { OnResize, OnResizeEnd, OnResizeStart, ShouldResize, ControlPosition } from './types';
|
|
3
3
|
declare const initChange: {
|
|
4
4
|
x: number;
|
|
@@ -11,6 +11,11 @@ declare const initChange: {
|
|
|
11
11
|
isHeightChange: boolean;
|
|
12
12
|
};
|
|
13
13
|
export type XYResizerChange = typeof initChange;
|
|
14
|
+
export type XYResizerChildChange = {
|
|
15
|
+
id: string;
|
|
16
|
+
position: XYPosition;
|
|
17
|
+
extent?: 'parent' | CoordinateExtent;
|
|
18
|
+
};
|
|
14
19
|
type XYResizerParams = {
|
|
15
20
|
domNode: HTMLDivElement;
|
|
16
21
|
nodeId: string;
|
|
@@ -20,7 +25,7 @@ type XYResizerParams = {
|
|
|
20
25
|
snapGrid?: [number, number];
|
|
21
26
|
snapToGrid: boolean;
|
|
22
27
|
};
|
|
23
|
-
onChange: (changes: XYResizerChange) => void;
|
|
28
|
+
onChange: (changes: XYResizerChange, childChanges: XYResizerChildChange[]) => void;
|
|
24
29
|
onEnd?: () => void;
|
|
25
30
|
};
|
|
26
31
|
type XYResizerUpdateParams = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XYResizer.d.ts","sourceRoot":"","sources":["../../src/xyresizer/XYResizer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"XYRes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AAQ,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAmBF,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,iBAAiB,CAkM1G"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CoordinateExtent } from '../types';
|
|
1
2
|
import { getPointerPosition } from '../utils';
|
|
2
3
|
import { ControlPosition } from './types';
|
|
3
4
|
type GetResizeDirectionParams = {
|
|
@@ -42,32 +43,30 @@ type StartValues = PrevValues & {
|
|
|
42
43
|
aspectRatio: number;
|
|
43
44
|
};
|
|
44
45
|
/**
|
|
45
|
-
* Calculates new width & height of node after resize based on pointer position
|
|
46
|
+
* Calculates new width & height and x & y of node after resize based on pointer position
|
|
47
|
+
* @description - Buckle up, this is a chunky one! If you want to determine the new dimensions of a node after a resize,
|
|
48
|
+
* you have to account for all possible restrictions: min/max width/height of the node, the maximum extent the node is allowed
|
|
49
|
+
* to move in (in this case: resize into) determined by the parent node, the minimal extent determined by child nodes
|
|
50
|
+
* with expandParent or extent: 'parent' set and oh yeah, these things also have to work with keepAspectRatio!
|
|
51
|
+
* The way this is done is by determining how much each of these restricting actually restricts the resize and then applying the
|
|
52
|
+
* strongest restriction. Because the resize affects x, y and width, height and width, height of a opposing side with keepAspectRatio,
|
|
53
|
+
* the resize amount is always kept in distX & distY amount (the distance in mouse movement)
|
|
54
|
+
* Instead of clamping each value, we first calculate the biggest 'clamp' (for the lack of a better name) and then apply it to all values.
|
|
46
55
|
* @param startValues - starting values of resize
|
|
47
56
|
* @param controlDirection - dimensions affected by the resize
|
|
48
57
|
* @param pointerPosition - the current pointer position corrected for snapping
|
|
49
58
|
* @param boundaries - minimum and maximum dimensions of the node
|
|
50
59
|
* @param keepAspectRatio - prevent changes of asprect ratio
|
|
51
|
-
* @returns
|
|
60
|
+
* @returns x, y, width and height of the node after resize
|
|
52
61
|
*/
|
|
53
62
|
export declare function getDimensionsAfterResize(startValues: StartValues, controlDirection: ReturnType<typeof getControlDirection>, pointerPosition: ReturnType<typeof getPointerPosition>, boundaries: {
|
|
54
63
|
minWidth: number;
|
|
55
64
|
maxWidth: number;
|
|
56
65
|
minHeight: number;
|
|
57
66
|
maxHeight: number;
|
|
58
|
-
}, keepAspectRatio: boolean): {
|
|
67
|
+
}, keepAspectRatio: boolean, extent?: CoordinateExtent, childExtent?: CoordinateExtent): {
|
|
59
68
|
width: number;
|
|
60
69
|
height: number;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Determines new x & y position of node after resize based on new width & height
|
|
64
|
-
* @param startValues - starting values of resize
|
|
65
|
-
* @param controlDirection - dimensions affected by the resize
|
|
66
|
-
* @param width - new width of node
|
|
67
|
-
* @param height - new height of node
|
|
68
|
-
* @returns x: new x position of node, y: new y position of node
|
|
69
|
-
*/
|
|
70
|
-
export declare function getPositionAfterResize(startValues: StartValues, controlDirection: ReturnType<typeof getControlDirection>, width: number, height: number): {
|
|
71
70
|
x: number;
|
|
72
71
|
y: number;
|
|
73
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xyresizer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/xyresizer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,S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|
2
2
|
"name": "@xyflow/system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "xyflow core system that powers React Flow and Svelte Flow.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-based UI",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^18.7.16",
|
|
49
49
|
"typescript": "5.1.3",
|
|
50
|
-
"@xyflow/tsconfig": "0.0.0",
|
|
51
50
|
"@xyflow/eslint-config": "0.0.0",
|
|
52
|
-
"@xyflow/rollup-config": "0.0.0"
|
|
51
|
+
"@xyflow/rollup-config": "0.0.0",
|
|
52
|
+
"@xyflow/tsconfig": "0.0.0"
|
|
53
53
|
},
|
|
54
54
|
"rollup": {
|
|
55
55
|
"globals": {
|