react-html-graph 1.2.1 → 1.2.3
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/behaviour/move-behaviour.d.ts +50 -0
- package/dist/behaviour/move-behaviour.d.ts.map +1 -0
- package/dist/behaviour/move-behaviour.js +71 -0
- package/dist/behaviour/move-behaviour.js.map +1 -0
- package/dist/calculations/index.d.ts +15 -1
- package/dist/calculations/index.d.ts.map +1 -1
- package/dist/calculations/index.js +1026 -0
- package/dist/calculations/index.js.map +1 -1
- package/dist/calculations/types.d.ts +70 -0
- package/dist/calculations/types.d.ts.map +1 -1
- package/dist/context/connection-context.d.ts.map +1 -1
- package/dist/context/connection-context.js.map +1 -1
- package/dist/context/error-context.d.ts.map +1 -1
- package/dist/context/error-context.js.map +1 -1
- package/dist/context/graph-context.d.ts.map +1 -1
- package/dist/context/graph-context.js.map +1 -1
- package/dist/context/graph-event-bus-context.d.ts +4 -0
- package/dist/context/graph-event-bus-context.d.ts.map +1 -0
- package/dist/context/graph-event-bus-context.js +8 -0
- package/dist/context/graph-event-bus-context.js.map +1 -0
- package/dist/context/graph-root-context.d.ts.map +1 -1
- package/dist/context/graph-root-context.js.map +1 -1
- package/dist/context/link-info-context.d.ts +4 -0
- package/dist/context/link-info-context.d.ts.map +1 -0
- package/dist/context/link-info-context.js +15 -0
- package/dist/context/link-info-context.js.map +1 -0
- package/dist/context/node-event-context.d.ts +4 -0
- package/dist/context/node-event-context.d.ts.map +1 -0
- package/dist/context/node-event-context.js +10 -0
- package/dist/context/node-event-context.js.map +1 -0
- package/dist/context/node-registry-context.d.ts +4 -0
- package/dist/context/node-registry-context.d.ts.map +1 -0
- package/dist/context/node-registry-context.js +13 -0
- package/dist/context/node-registry-context.js.map +1 -0
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +446 -36
- package/dist/graph/index.js.map +1 -1
- package/dist/hooks/connection.d.ts +1 -1
- package/dist/hooks/connection.d.ts.map +1 -1
- package/dist/hooks/connection.js +5 -2
- package/dist/hooks/connection.js.map +1 -1
- package/dist/hooks/get-viewbox.d.ts +9 -0
- package/dist/hooks/get-viewbox.d.ts.map +1 -0
- package/dist/hooks/get-viewbox.js +20 -0
- package/dist/hooks/get-viewbox.js.map +1 -0
- package/dist/hooks/graph-event-bus.d.ts +3 -0
- package/dist/hooks/graph-event-bus.d.ts.map +1 -0
- package/dist/hooks/graph-event-bus.js +7 -0
- package/dist/hooks/graph-event-bus.js.map +1 -0
- package/dist/hooks/link-info.d.ts +4 -0
- package/dist/hooks/link-info.d.ts.map +1 -0
- package/dist/hooks/link-info.js +7 -0
- package/dist/hooks/link-info.js.map +1 -0
- package/dist/hooks/node-registry.d.ts +3 -0
- package/dist/hooks/node-registry.d.ts.map +1 -0
- package/dist/hooks/node-registry.js +7 -0
- package/dist/hooks/node-registry.js.map +1 -0
- package/dist/hooks/nodeEvent.d.ts +7 -0
- package/dist/hooks/nodeEvent.d.ts.map +1 -0
- package/dist/hooks/nodeEvent.js +17 -0
- package/dist/hooks/nodeEvent.js.map +1 -0
- package/dist/hooks/use-graph-api.d.ts +50 -0
- package/dist/hooks/use-graph-api.d.ts.map +1 -0
- package/dist/hooks/use-graph-api.js +97 -0
- package/dist/hooks/use-graph-api.js.map +1 -0
- package/dist/layouts/centralizar.d.ts +1 -0
- package/dist/layouts/centralizar.d.ts.map +1 -0
- package/dist/layouts/centralizar.js +2 -0
- package/dist/layouts/centralizar.js.map +1 -0
- package/dist/layouts/force-direction-layout.d.ts +9 -0
- package/dist/layouts/force-direction-layout.d.ts.map +1 -0
- package/dist/layouts/force-direction-layout.js +11 -0
- package/dist/layouts/force-direction-layout.js.map +1 -0
- package/dist/layouts/index.d.ts +13 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/layouts/index.js +17 -0
- package/dist/layouts/index.js.map +1 -0
- package/dist/layouts/organic-layout.d.ts +9 -0
- package/dist/layouts/organic-layout.d.ts.map +1 -0
- package/dist/layouts/organic-layout.js +11 -0
- package/dist/layouts/organic-layout.js.map +1 -0
- package/dist/layouts/radial-layout.d.ts +9 -0
- package/dist/layouts/radial-layout.d.ts.map +1 -0
- package/dist/layouts/radial-layout.js +11 -0
- package/dist/layouts/radial-layout.js.map +1 -0
- package/dist/layouts/sequential-layout.d.ts +9 -0
- package/dist/layouts/sequential-layout.d.ts.map +1 -0
- package/dist/layouts/sequential-layout.js +11 -0
- package/dist/layouts/sequential-layout.js.map +1 -0
- package/dist/layouts/shared.d.ts +10 -0
- package/dist/layouts/shared.d.ts.map +1 -0
- package/dist/layouts/shared.js +39 -0
- package/dist/layouts/shared.js.map +1 -0
- package/dist/layouts/structural-layout.d.ts +9 -0
- package/dist/layouts/structural-layout.d.ts.map +1 -0
- package/dist/layouts/structural-layout.js +11 -0
- package/dist/layouts/structural-layout.js.map +1 -0
- package/dist/layouts/tree-layout.d.ts +9 -0
- package/dist/layouts/tree-layout.d.ts.map +1 -0
- package/dist/layouts/tree-layout.js +11 -0
- package/dist/layouts/tree-layout.js.map +1 -0
- package/dist/link/base.d.ts +10 -20
- package/dist/link/base.d.ts.map +1 -1
- package/dist/link/base.js +17 -197
- package/dist/link/base.js.map +1 -1
- package/dist/link/temp-link.d.ts.map +1 -1
- package/dist/link/temp-link.js +24 -7
- package/dist/link/temp-link.js.map +1 -1
- package/dist/module.d.ts +11 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +11 -1
- package/dist/module.js.map +1 -1
- package/dist/nodes/base.d.ts +2 -1
- package/dist/nodes/base.d.ts.map +1 -1
- package/dist/nodes/base.js +75 -66
- package/dist/nodes/base.js.map +1 -1
- package/dist/paths/bidirectional-path.d.ts +16 -0
- package/dist/paths/bidirectional-path.d.ts.map +1 -0
- package/dist/paths/bidirectional-path.js +260 -0
- package/dist/paths/bidirectional-path.js.map +1 -0
- package/dist/ports/base.d.ts.map +1 -1
- package/dist/ports/base.js +26 -13
- package/dist/ports/base.js.map +1 -1
- package/dist/providers/connection-provider.d.ts +1 -1
- package/dist/providers/connection-provider.d.ts.map +1 -1
- package/dist/providers/connection-provider.js +30 -16
- package/dist/providers/connection-provider.js.map +1 -1
- package/dist/providers/graph-event-bus-provider.d.ts +11 -0
- package/dist/providers/graph-event-bus-provider.d.ts.map +1 -0
- package/dist/providers/graph-event-bus-provider.js +46 -0
- package/dist/providers/graph-event-bus-provider.js.map +1 -0
- package/dist/providers/link-info-provider.d.ts +23 -0
- package/dist/providers/link-info-provider.d.ts.map +1 -0
- package/dist/providers/link-info-provider.js +31 -0
- package/dist/providers/link-info-provider.js.map +1 -0
- package/dist/providers/node-event-context.d.ts +3 -0
- package/dist/providers/node-event-context.d.ts.map +1 -0
- package/dist/providers/node-event-context.js +81 -0
- package/dist/providers/node-event-context.js.map +1 -0
- package/dist/providers/node-registry-provider.d.ts +11 -0
- package/dist/providers/node-registry-provider.d.ts.map +1 -0
- package/dist/providers/node-registry-provider.js +54 -0
- package/dist/providers/node-registry-provider.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +359 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/proxy.d.ts +2 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +18 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/symbols.d.ts +2 -0
- package/dist/utils/symbols.d.ts.map +1 -0
- package/dist/utils/symbols.js +2 -0
- package/dist/utils/symbols.js.map +1 -0
- package/package.json +1 -1
package/dist/hooks/connection.js
CHANGED
|
@@ -2,6 +2,7 @@ import { useContext, useCallback } from "react";
|
|
|
2
2
|
import { ConnectionContext } from "../context/connection-context";
|
|
3
3
|
import { GraphContext } from "../context/graph-context";
|
|
4
4
|
import useGraphRoot from "./graph-root";
|
|
5
|
+
import useGetViewbox from "./get-viewbox";
|
|
5
6
|
/**
|
|
6
7
|
* Hook que expõe o estado de conexões e operações básicas (connect/disconnect)
|
|
7
8
|
* a partir do ConnectionContext.
|
|
@@ -53,8 +54,9 @@ export function usePortDrag(nodeId, portName, connectionType) {
|
|
|
53
54
|
*/
|
|
54
55
|
export function usePortDrop(nodeId, portName, connectionType) {
|
|
55
56
|
const { dragState, endDrag } = useContext(ConnectionContext);
|
|
56
|
-
const { mode
|
|
57
|
+
const { mode } = useContext(GraphContext);
|
|
57
58
|
const graphRoot = useGraphRoot();
|
|
59
|
+
const getViewbox = useGetViewbox();
|
|
58
60
|
const canDrop = dragState.active &&
|
|
59
61
|
dragState.connectionType === connectionType &&
|
|
60
62
|
dragState.sourceNodeId !== nodeId;
|
|
@@ -66,13 +68,14 @@ export function usePortDrop(nodeId, portName, connectionType) {
|
|
|
66
68
|
let cursorPos = { x: 0, y: 0 };
|
|
67
69
|
if (graph) {
|
|
68
70
|
const rect = graph.getBoundingClientRect();
|
|
71
|
+
const viewbox = getViewbox();
|
|
69
72
|
cursorPos = {
|
|
70
73
|
x: (e.clientX - rect.left) / viewbox.zoom + viewbox.x,
|
|
71
74
|
y: (e.clientY - rect.top) / viewbox.zoom + viewbox.y,
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
77
|
endDrag(nodeId, portName, cursorPos);
|
|
75
|
-
}, [mode, dragState.active, nodeId, portName, endDrag,
|
|
78
|
+
}, [mode, dragState.active, nodeId, portName, endDrag, getViewbox, graphRoot]);
|
|
76
79
|
return {
|
|
77
80
|
dropHandlers: { onMouseUp: handleMouseUp },
|
|
78
81
|
canDrop,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/hooks/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,YAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.js","source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,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC,EACD,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAC7E,CAAC;IAEF,OAAO;QACH,YAAY,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE;QAC1C,OAAO;KACV,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Viewbox } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook que retorna um getter estável para o viewbox atual, sem causar
|
|
4
|
+
* re-render quando o viewbox muda. Mesma abordagem de `useGetZoom`.
|
|
5
|
+
*
|
|
6
|
+
* @returns Função que retorna o Viewbox mais recente.
|
|
7
|
+
*/
|
|
8
|
+
export default function useGetViewbox(): () => Viewbox;
|
|
9
|
+
//# sourceMappingURL=get-viewbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-viewbox.d.ts","sourceRoot":"","sources":["../../src/hooks/get-viewbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,kBAapC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import useViewbox from "./viewbox";
|
|
3
|
+
/**
|
|
4
|
+
* Hook que retorna um getter estável para o viewbox atual, sem causar
|
|
5
|
+
* re-render quando o viewbox muda. Mesma abordagem de `useGetZoom`.
|
|
6
|
+
*
|
|
7
|
+
* @returns Função que retorna o Viewbox mais recente.
|
|
8
|
+
*/
|
|
9
|
+
export default function useGetViewbox() {
|
|
10
|
+
const viewbox = useViewbox();
|
|
11
|
+
const ref = useRef(viewbox);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
ref.current = viewbox;
|
|
14
|
+
}, [viewbox]);
|
|
15
|
+
const getViewbox = useCallback(() => {
|
|
16
|
+
return ref.current;
|
|
17
|
+
}, []);
|
|
18
|
+
return getViewbox;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=get-viewbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-viewbox.js","sourceRoot":"","sources":["../../src/hooks/get-viewbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,UAAU,MAAM,WAAW,CAAC;AAInC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa;IACjC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,MAAM,CAAU,OAAO,CAAC,CAAC;IAErC,SAAS,CAAC,GAAG,EAAE;QACX,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1B,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,OAAO,GAAG,CAAC,OAAO,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,UAAU,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-event-bus.d.ts","sourceRoot":"","sources":["../../src/hooks/graph-event-bus.ts"],"names":[],"mappings":"AAGA,+DAA+D;AAC/D,MAAM,CAAC,OAAO,UAAU,gBAAgB,iDAEvC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { GraphEventBusContext } from "../context/graph-event-bus-context";
|
|
3
|
+
/** Hook que retorna o bus centralizado de eventos do grafo. */
|
|
4
|
+
export default function useGraphEventBus() {
|
|
5
|
+
return useContext(GraphEventBusContext);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=graph-event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-event-bus.js","sourceRoot":"","sources":["../../src/hooks/graph-event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,+DAA+D;AAC/D,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACpC,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-info.d.ts","sourceRoot":"","sources":["../../src/hooks/link-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,kFAAkF;AAClF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,KACD,oBAAoB,CAAC,CAAC,CAAC,CAChE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { LinkInfoContext } from "../context/link-info-context";
|
|
3
|
+
/** Hook que retorna as informações do link no qual o componente está inserido. */
|
|
4
|
+
export default function useLinkInfo() {
|
|
5
|
+
return useContext(LinkInfoContext);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=link-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-info.js","sourceRoot":"","sources":["../../src/hooks/link-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,kFAAkF;AAClF,MAAM,CAAC,OAAO,UAAU,WAAW;IAC/B,OAAO,UAAU,CAAC,eAAe,CAA4B,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-registry.d.ts","sourceRoot":"","sources":["../../src/hooks/node-registry.ts"],"names":[],"mappings":"AAGA,gEAAgE;AAChE,MAAM,CAAC,OAAO,UAAU,eAAe,gDAEtC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { NodeRegistryContext } from "../context/node-registry-context";
|
|
3
|
+
/** Hook que retorna o registro centralizado de nós e portas. */
|
|
4
|
+
export default function useNodeRegistry() {
|
|
5
|
+
return useContext(NodeRegistryContext);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=node-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-registry.js","sourceRoot":"","sources":["../../src/hooks/node-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,gEAAgE;AAChE,MAAM,CAAC,OAAO,UAAU,eAAe;IACnC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/nodeEvent.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,6CAWnC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { NodeEventContext } from "../context/node-event-context";
|
|
3
|
+
import { NoProviderSymbol } from "../utils/symbols";
|
|
4
|
+
/**
|
|
5
|
+
* Hook que retorna o estado do viewbox (posição e zoom) do GraphContext.
|
|
6
|
+
*
|
|
7
|
+
* @returns Viewbox
|
|
8
|
+
*/
|
|
9
|
+
export default function useNodeEvent() {
|
|
10
|
+
const nodeEvent = useContext(NodeEventContext);
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
if (nodeEvent[NoProviderSymbol]) {
|
|
13
|
+
throw new Error("It's not possible to use useNodeEvent outside of a NodeEventProvider...");
|
|
14
|
+
}
|
|
15
|
+
return nodeEvent;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=nodeEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeEvent.js","sourceRoot":"","sources":["../../src/hooks/nodeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAInD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY;IAChC,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAE9C,8DAA8D;IAC9D,IAAK,SAAiB,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACX,yEAAyE,CAC5E,CAAA;IACL,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { GraphApi, NodeTypeDefinition, NodeDefinition, LinkDefinition, PortConnection, GraphNodeRuntimeState, GraphLinkRuntimeState, GraphCentralizeOptions, GraphApplyLayoutInput, GraphLayoutResult, Viewbox, NodeObjectTemplateProps, LinkInfoContextValue, GraphSerializedState } from "../types";
|
|
2
|
+
/** Implementação interna que estende GraphApi com campos de controle. */
|
|
3
|
+
export interface GraphApiInternal extends GraphApi {
|
|
4
|
+
/** Registro de tipos de nó (nodeType → definição). */
|
|
5
|
+
_nodeTypeRegistry: Map<string, NodeTypeDefinition>;
|
|
6
|
+
/** Registro de templates de link (connectionType → template). */
|
|
7
|
+
_linkTemplateRegistry: Map<string, (props: LinkInfoContextValue) => React.ReactNode>;
|
|
8
|
+
/** Template padrão para nós sem tipo registrado. */
|
|
9
|
+
_defaultNodeTemplate: ((props: NodeObjectTemplateProps) => React.ReactNode) | null;
|
|
10
|
+
/** Template padrão para links sem tipo registrado. */
|
|
11
|
+
_defaultLinkTemplate: ((props: LinkInfoContextValue) => React.ReactNode) | null;
|
|
12
|
+
/** Indica se o Graph já se conectou. */
|
|
13
|
+
_connected: boolean;
|
|
14
|
+
/** Callback chamado quando o Graph conecta. */
|
|
15
|
+
_onReady: ((api: GraphApi) => void) | null;
|
|
16
|
+
/** Vincula implementações reais vindas do Graph. */
|
|
17
|
+
_bind(impl: GraphApiBindings): void;
|
|
18
|
+
/** Desvincula implementações ao desmontar o Graph. */
|
|
19
|
+
_unbind(): void;
|
|
20
|
+
}
|
|
21
|
+
/** Métodos injetados pelo Graph via _bind. */
|
|
22
|
+
export interface GraphApiBindings {
|
|
23
|
+
addNode(node: NodeDefinition): void;
|
|
24
|
+
removeNode(id: string): void;
|
|
25
|
+
addLink(link: LinkDefinition): void;
|
|
26
|
+
removeLink(id: string): void;
|
|
27
|
+
connect(connection: PortConnection): void;
|
|
28
|
+
disconnect(connection: PortConnection): void;
|
|
29
|
+
getConnections(): PortConnection[];
|
|
30
|
+
getNodeStates(): GraphNodeRuntimeState[];
|
|
31
|
+
getLinkStates(): GraphLinkRuntimeState[];
|
|
32
|
+
centralize(options?: GraphCentralizeOptions): Promise<Viewbox>;
|
|
33
|
+
applyLayout(input: GraphApplyLayoutInput): Promise<GraphLayoutResult>;
|
|
34
|
+
serialize(): GraphSerializedState;
|
|
35
|
+
load(input: GraphSerializedState | string): void;
|
|
36
|
+
}
|
|
37
|
+
export interface UseGraphApiOptions {
|
|
38
|
+
/** Chamado uma vez quando o Graph monta e conecta a API. */
|
|
39
|
+
onReady?: (api: GraphApi) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hook que cria um objeto de API estável para o grafo.
|
|
43
|
+
* O objeto retornado nunca muda de identidade — métodos de manipulação
|
|
44
|
+
* são no-ops até que o componente <Graph> monte e chame _bind internamente.
|
|
45
|
+
*
|
|
46
|
+
* @param options Opções de configuração (onReady callback).
|
|
47
|
+
* @returns Instância estável de GraphApi.
|
|
48
|
+
*/
|
|
49
|
+
export default function useGraphApi(options?: UseGraphApiOptions): GraphApi;
|
|
50
|
+
//# sourceMappingURL=use-graph-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-graph-api.d.ts","sourceRoot":"","sources":["../../src/hooks/use-graph-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,OAAO,EACP,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,UAAU,CAAC;AAGlB,yEAAyE;AACzE,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAC9C,sDAAsD;IACtD,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACnD,iEAAiE;IACjE,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IACrF,oDAAoD;IACpD,oBAAoB,EAAE,CAAC,CAAC,KAAK,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACnF,sDAAsD;IACtD,oBAAoB,EAAE,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAChF,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3C,oDAAoD;IACpD,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,sDAAsD;IACtD,OAAO,IAAI,IAAI,CAAC;CACnB;AAED,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC7B,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAC7C,cAAc,IAAI,cAAc,EAAE,CAAC;IACnC,aAAa,IAAI,qBAAqB,EAAE,CAAC;IACzC,aAAa,IAAI,qBAAqB,EAAE,CAAC;IACzC,UAAU,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACtE,SAAS,IAAI,oBAAoB,CAAC;IAClC,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,kBAAkB;IAC/B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;CACrC;AA2FD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAM1E"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
/** No-op para métodos ainda não conectados. */
|
|
3
|
+
const NOOP = () => { };
|
|
4
|
+
const NOOP_ARRAY = () => [];
|
|
5
|
+
const NOOP_PROMISE = () => Promise.resolve({});
|
|
6
|
+
const NOOP_SERIALIZE = () => ({ nodes: [], links: [] });
|
|
7
|
+
function createGraphApiInternal(onReady) {
|
|
8
|
+
const nodeTypeRegistry = new Map();
|
|
9
|
+
const linkTemplateRegistry = new Map();
|
|
10
|
+
const api = {
|
|
11
|
+
// Registros — funcionam imediatamente
|
|
12
|
+
_nodeTypeRegistry: nodeTypeRegistry,
|
|
13
|
+
_linkTemplateRegistry: linkTemplateRegistry,
|
|
14
|
+
_defaultNodeTemplate: null,
|
|
15
|
+
_defaultLinkTemplate: null,
|
|
16
|
+
_connected: false,
|
|
17
|
+
_onReady: onReady,
|
|
18
|
+
registerNodeType(name, definition) {
|
|
19
|
+
nodeTypeRegistry.set(name, definition);
|
|
20
|
+
},
|
|
21
|
+
setDefaultNodeTemplate(template) {
|
|
22
|
+
api._defaultNodeTemplate = template;
|
|
23
|
+
},
|
|
24
|
+
registerLinkTemplate(connectionType, template) {
|
|
25
|
+
linkTemplateRegistry.set(connectionType, template);
|
|
26
|
+
},
|
|
27
|
+
setDefaultLinkTemplate(template) {
|
|
28
|
+
api._defaultLinkTemplate = template;
|
|
29
|
+
},
|
|
30
|
+
// Métodos de manipulação — no-ops até _bind
|
|
31
|
+
addNode: NOOP,
|
|
32
|
+
removeNode: NOOP,
|
|
33
|
+
addLink: NOOP,
|
|
34
|
+
removeLink: NOOP,
|
|
35
|
+
connect: NOOP,
|
|
36
|
+
disconnect: NOOP,
|
|
37
|
+
getConnections: NOOP_ARRAY,
|
|
38
|
+
getNodeStates: NOOP_ARRAY,
|
|
39
|
+
getLinkStates: NOOP_ARRAY,
|
|
40
|
+
centralize: NOOP_PROMISE,
|
|
41
|
+
applyLayout: NOOP_PROMISE,
|
|
42
|
+
serialize: NOOP_SERIALIZE,
|
|
43
|
+
load: NOOP,
|
|
44
|
+
_bind(impl) {
|
|
45
|
+
api.addNode = impl.addNode;
|
|
46
|
+
api.removeNode = impl.removeNode;
|
|
47
|
+
api.addLink = impl.addLink;
|
|
48
|
+
api.removeLink = impl.removeLink;
|
|
49
|
+
api.connect = impl.connect;
|
|
50
|
+
api.disconnect = impl.disconnect;
|
|
51
|
+
api.getConnections = impl.getConnections;
|
|
52
|
+
api.getNodeStates = impl.getNodeStates;
|
|
53
|
+
api.getLinkStates = impl.getLinkStates;
|
|
54
|
+
api.centralize = impl.centralize;
|
|
55
|
+
api.applyLayout = impl.applyLayout;
|
|
56
|
+
api.serialize = impl.serialize;
|
|
57
|
+
api.load = impl.load;
|
|
58
|
+
if (!api._connected) {
|
|
59
|
+
api._connected = true;
|
|
60
|
+
api._onReady?.(api);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
_unbind() {
|
|
64
|
+
api._connected = false;
|
|
65
|
+
api.addNode = NOOP;
|
|
66
|
+
api.removeNode = NOOP;
|
|
67
|
+
api.addLink = NOOP;
|
|
68
|
+
api.removeLink = NOOP;
|
|
69
|
+
api.connect = NOOP;
|
|
70
|
+
api.disconnect = NOOP;
|
|
71
|
+
api.getConnections = NOOP_ARRAY;
|
|
72
|
+
api.getNodeStates = NOOP_ARRAY;
|
|
73
|
+
api.getLinkStates = NOOP_ARRAY;
|
|
74
|
+
api.centralize = NOOP_PROMISE;
|
|
75
|
+
api.applyLayout = NOOP_PROMISE;
|
|
76
|
+
api.serialize = NOOP_SERIALIZE;
|
|
77
|
+
api.load = NOOP;
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
return api;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Hook que cria um objeto de API estável para o grafo.
|
|
84
|
+
* O objeto retornado nunca muda de identidade — métodos de manipulação
|
|
85
|
+
* são no-ops até que o componente <Graph> monte e chame _bind internamente.
|
|
86
|
+
*
|
|
87
|
+
* @param options Opções de configuração (onReady callback).
|
|
88
|
+
* @returns Instância estável de GraphApi.
|
|
89
|
+
*/
|
|
90
|
+
export default function useGraphApi(options) {
|
|
91
|
+
const apiRef = useRef(null);
|
|
92
|
+
if (!apiRef.current) {
|
|
93
|
+
apiRef.current = createGraphApiInternal(options?.onReady ?? null);
|
|
94
|
+
}
|
|
95
|
+
return apiRef.current;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=use-graph-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-graph-api.js","sourceRoot":"","sources":["../../src/hooks/use-graph-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AA6D/B,+CAA+C;AAC/C,MAAM,IAAI,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;AACvB,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,EAAW,CAAC;AACrC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAS,CAAC,CAAC;AACtD,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAA2B,CAAA,CAAC;AAEhF,SAAS,sBAAsB,CAAC,OAAyC;IACrE,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;IAC/D,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAA4D,CAAC;IAEjG,MAAM,GAAG,GAAqB;QAC1B,sCAAsC;QACtC,iBAAiB,EAAE,gBAAgB;QACnC,qBAAqB,EAAE,oBAAoB;QAC3C,oBAAoB,EAAE,IAAI;QAC1B,oBAAoB,EAAE,IAAI;QAC1B,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,OAAO;QAEjB,gBAAgB,CAAC,IAAY,EAAE,UAA8B;YACzD,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC3C,CAAC;QACD,sBAAsB,CAAC,QAA6D;YAChF,GAAG,CAAC,oBAAoB,GAAG,QAAQ,CAAC;QACxC,CAAC;QACD,oBAAoB,CAAC,cAAsB,EAAE,QAA0D;YACnG,oBAAoB,CAAC,GAAG,CAAC,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ts","sourceRoot":"","sources":["../../src/layouts/centralizar.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"centralizar.js","sourceRoot":"","sources":["../../src/layouts/centralizar.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout por forças com viés direcional entre origem e destino.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default function forceDirectionLayout(input: GraphLayoutInput): Promise<GraphLayoutResult>;
|
|
9
|
+
//# sourceMappingURL=force-direction-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"force-direction-layout.d.ts","sourceRoot":"","sources":["../../src/layouts/force-direction-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI/D;;;;;GAKG;AACH,wBAA8B,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAEtG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runLayoutAlgorithm } from "./shared";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout por forças com viés direcional entre origem e destino.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default async function forceDirectionLayout(input) {
|
|
9
|
+
return runLayoutAlgorithm("force-direction", input);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=force-direction-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"force-direction-layout.js","sourceRoot":"","sources":["../../src/layouts/force-direction-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAuB;IACtE,OAAO,kBAAkB,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraphLayoutAlgorithm, GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
import forceDirectionLayout from "./force-direction-layout";
|
|
3
|
+
import organicLayout from "./organic-layout";
|
|
4
|
+
import radialLayout from "./radial-layout";
|
|
5
|
+
import sequentialLayout from "./sequential-layout";
|
|
6
|
+
import structuralLayout from "./structural-layout";
|
|
7
|
+
import treeLayout from "./tree-layout";
|
|
8
|
+
/** Assinatura compartilhada por todos os executores de layout. */
|
|
9
|
+
export type GraphLayoutExecutor = (input: GraphLayoutInput) => Promise<GraphLayoutResult>;
|
|
10
|
+
/** Mapa estável dos algoritmos de layout disponíveis. */
|
|
11
|
+
export declare const GRAPH_LAYOUT_EXECUTORS: Record<GraphLayoutAlgorithm, GraphLayoutExecutor>;
|
|
12
|
+
export { forceDirectionLayout, organicLayout, radialLayout, sequentialLayout, structuralLayout, treeLayout };
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layouts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACrF,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAC5D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,UAAU,MAAM,eAAe,CAAC;AAGvC,kEAAkE;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE1F,yDAAyD;AACzD,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAOpF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import forceDirectionLayout from "./force-direction-layout";
|
|
2
|
+
import organicLayout from "./organic-layout";
|
|
3
|
+
import radialLayout from "./radial-layout";
|
|
4
|
+
import sequentialLayout from "./sequential-layout";
|
|
5
|
+
import structuralLayout from "./structural-layout";
|
|
6
|
+
import treeLayout from "./tree-layout";
|
|
7
|
+
/** Mapa estável dos algoritmos de layout disponíveis. */
|
|
8
|
+
export const GRAPH_LAYOUT_EXECUTORS = {
|
|
9
|
+
"force-direction": forceDirectionLayout,
|
|
10
|
+
organic: organicLayout,
|
|
11
|
+
radial: radialLayout,
|
|
12
|
+
sequential: sequentialLayout,
|
|
13
|
+
structural: structuralLayout,
|
|
14
|
+
tree: treeLayout,
|
|
15
|
+
};
|
|
16
|
+
export { forceDirectionLayout, organicLayout, radialLayout, sequentialLayout, structuralLayout, treeLayout };
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layouts/index.ts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAC5D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,UAAU,MAAM,eAAe,CAAC;AAMvC,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAsD;IACrF,iBAAiB,EAAE,oBAAoB;IACvC,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,IAAI,EAAE,UAAU;CACnB,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout orgânico baseado em relaxamento por forças.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default function organicLayout(input: GraphLayoutInput): Promise<GraphLayoutResult>;
|
|
9
|
+
//# sourceMappingURL=organic-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organic-layout.d.ts","sourceRoot":"","sources":["../../src/layouts/organic-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI/D;;;;;GAKG;AACH,wBAA8B,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE/F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runLayoutAlgorithm } from "./shared";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout orgânico baseado em relaxamento por forças.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default async function organicLayout(input) {
|
|
9
|
+
return runLayoutAlgorithm("organic", input);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=organic-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organic-layout.js","sourceRoot":"","sources":["../../src/layouts/organic-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CAAC,KAAuB;IAC/D,OAAO,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout radial distribuindo camadas ao redor de uma raiz.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default function radialLayout(input: GraphLayoutInput): Promise<GraphLayoutResult>;
|
|
9
|
+
//# sourceMappingURL=radial-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-layout.d.ts","sourceRoot":"","sources":["../../src/layouts/radial-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI/D;;;;;GAKG;AACH,wBAA8B,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE9F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runLayoutAlgorithm } from "./shared";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout radial distribuindo camadas ao redor de uma raiz.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default async function radialLayout(input) {
|
|
9
|
+
return runLayoutAlgorithm("radial", input);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=radial-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-layout.js","sourceRoot":"","sources":["../../src/layouts/radial-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,KAAuB;IAC9D,OAAO,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout sequencial em linhas/colunas a partir da ordem do grafo.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default function sequentialLayout(input: GraphLayoutInput): Promise<GraphLayoutResult>;
|
|
9
|
+
//# sourceMappingURL=sequential-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequential-layout.d.ts","sourceRoot":"","sources":["../../src/layouts/sequential-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI/D;;;;;GAKG;AACH,wBAA8B,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAElG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runLayoutAlgorithm } from "./shared";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout sequencial em linhas/colunas a partir da ordem do grafo.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default async function sequentialLayout(input) {
|
|
9
|
+
return runLayoutAlgorithm("sequential", input);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sequential-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequential-layout.js","sourceRoot":"","sources":["../../src/layouts/sequential-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAuB;IAClE,OAAO,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GraphLayoutAlgorithm, GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um algoritmo de layout no worker pool a partir do snapshot público.
|
|
4
|
+
*
|
|
5
|
+
* @param algorithm Nome do algoritmo desejado
|
|
6
|
+
* @param input Snapshot de nós/links e opções compartilhadas
|
|
7
|
+
* @returns Resultado com posições e bounds calculados
|
|
8
|
+
*/
|
|
9
|
+
export declare function runLayoutAlgorithm(algorithm: GraphLayoutAlgorithm, input: GraphLayoutInput): Promise<GraphLayoutResult>;
|
|
10
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/layouts/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGrF;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACpC,SAAS,EAAE,oBAAoB,EAC/B,KAAK,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CA8B5B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { calculateLayout } from "../calculations";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um algoritmo de layout no worker pool a partir do snapshot público.
|
|
4
|
+
*
|
|
5
|
+
* @param algorithm Nome do algoritmo desejado
|
|
6
|
+
* @param input Snapshot de nós/links e opções compartilhadas
|
|
7
|
+
* @returns Resultado com posições e bounds calculados
|
|
8
|
+
*/
|
|
9
|
+
export async function runLayoutAlgorithm(algorithm, input) {
|
|
10
|
+
const result = await calculateLayout({
|
|
11
|
+
algorithm,
|
|
12
|
+
nodes: input.nodes.map(node => ({
|
|
13
|
+
id: node.id,
|
|
14
|
+
width: node.width,
|
|
15
|
+
height: node.height,
|
|
16
|
+
x: node.position.x,
|
|
17
|
+
y: node.position.y,
|
|
18
|
+
z: node.position.z,
|
|
19
|
+
})),
|
|
20
|
+
links: input.links.map(link => ({
|
|
21
|
+
id: link.id,
|
|
22
|
+
from: link.from,
|
|
23
|
+
to: link.to,
|
|
24
|
+
})),
|
|
25
|
+
options: input.options,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
positions: result.positions.map(position => ({
|
|
29
|
+
id: position.id,
|
|
30
|
+
position: {
|
|
31
|
+
x: position.x,
|
|
32
|
+
y: position.y,
|
|
33
|
+
z: position.z,
|
|
34
|
+
},
|
|
35
|
+
})),
|
|
36
|
+
bounds: result.bounds,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/layouts/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACpC,SAA+B,EAC/B,KAAuB;IAEvB,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;QACjC,SAAS;QACT,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SACrB,CAAC,CAAC;QACH,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;SACd,CAAC,CAAC;QACH,OAAO,EAAE,KAAK,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,OAAO;QACH,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACzC,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,QAAQ,EAAE;gBACN,CAAC,EAAE,QAAQ,CAAC,CAAC;gBACb,CAAC,EAAE,QAAQ,CAAC,CAAC;gBACb,CAAC,EAAE,QAAQ,CAAC,CAAC;aAChB;SACJ,CAAC,CAAC;QACH,MAAM,EAAE,MAAM,CAAC,MAAM;KACxB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphLayoutInput, GraphLayoutResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Executa um layout estrutural hierárquico com base na conectividade.
|
|
4
|
+
*
|
|
5
|
+
* @param input Snapshot do grafo e opções compartilhadas
|
|
6
|
+
* @returns Resultado com novas posições para os nós
|
|
7
|
+
*/
|
|
8
|
+
export default function structuralLayout(input: GraphLayoutInput): Promise<GraphLayoutResult>;
|
|
9
|
+
//# sourceMappingURL=structural-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structural-layout.d.ts","sourceRoot":"","sources":["../../src/layouts/structural-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI/D;;;;;GAKG;AACH,wBAA8B,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAElG"}
|