@eightkk/vue-weave 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +517 -0
  2. package/CONTRIBUTING.md +123 -0
  3. package/LICENSE +21 -0
  4. package/README.ja.md +275 -0
  5. package/README.md +272 -2
  6. package/THIRD_PARTY_NOTICES.md +25 -0
  7. package/dist/core-BH5rTsKp.js +13606 -0
  8. package/dist/core.js +1 -0
  9. package/dist/index.js +8022 -0
  10. package/dist/style.css +2 -0
  11. package/dist/types/components/GanttChart.vue.d.ts +339 -0
  12. package/dist/types/components/NetworkGraph.vue.d.ts +252 -0
  13. package/dist/types/components/types.d.ts +27 -0
  14. package/dist/types/composables/useAsyncGraphLayout.d.ts +163 -0
  15. package/dist/types/composables/useEditHistory.d.ts +13 -0
  16. package/dist/types/composables/useEditTransaction.d.ts +46 -0
  17. package/dist/types/composables/useLinkedSelection.d.ts +118 -0
  18. package/dist/types/composables/useTimelineView.d.ts +24 -0
  19. package/dist/types/composables/useWindowedData.d.ts +83 -0
  20. package/dist/types/core/actuals.d.ts +170 -0
  21. package/dist/types/core/calendarFormat.d.ts +65 -0
  22. package/dist/types/core/editTransaction.d.ts +96 -0
  23. package/dist/types/core/exportSvg.d.ts +236 -0
  24. package/dist/types/core/fieldEditing.d.ts +114 -0
  25. package/dist/types/core/graph.d.ts +196 -0
  26. package/dist/types/core/graphAlgorithms.d.ts +51 -0
  27. package/dist/types/core/graphAnalysis.d.ts +96 -0
  28. package/dist/types/core/graphCollapse.d.ts +62 -0
  29. package/dist/types/core/graphCrossings.d.ts +25 -0
  30. package/dist/types/core/graphEditing.d.ts +52 -0
  31. package/dist/types/core/graphExpansion.d.ts +71 -0
  32. package/dist/types/core/graphFlow.d.ts +184 -0
  33. package/dist/types/core/graphForce.d.ts +29 -0
  34. package/dist/types/core/graphGeometry.d.ts +31 -0
  35. package/dist/types/core/graphIncremental.d.ts +93 -0
  36. package/dist/types/core/graphLasso.d.ts +15 -0
  37. package/dist/types/core/graphLayoutRequests.d.ts +218 -0
  38. package/dist/types/core/graphLayouts.d.ts +81 -0
  39. package/dist/types/core/graphObstacleRouting.d.ts +68 -0
  40. package/dist/types/core/graphPortRules.d.ts +111 -0
  41. package/dist/types/core/graphRouting.d.ts +84 -0
  42. package/dist/types/core/graphSnapping.d.ts +34 -0
  43. package/dist/types/core/graphSpatial.d.ts +49 -0
  44. package/dist/types/core/graphSwimlanes.d.ts +77 -0
  45. package/dist/types/core/graphTraversal.d.ts +51 -0
  46. package/dist/types/core/graphView.d.ts +73 -0
  47. package/dist/types/core/index.d.ts +75 -0
  48. package/dist/types/core/interchange.d.ts +6 -0
  49. package/dist/types/core/interchangeCsv.d.ts +75 -0
  50. package/dist/types/core/interchangeICalendar.d.ts +111 -0
  51. package/dist/types/core/interchangeMsProject.d.ts +339 -0
  52. package/dist/types/core/leveling.d.ts +57 -0
  53. package/dist/types/core/pert.d.ts +62 -0
  54. package/dist/types/core/placement.d.ts +100 -0
  55. package/dist/types/core/planComparison.d.ts +275 -0
  56. package/dist/types/core/resourceLoad.d.ts +65 -0
  57. package/dist/types/core/resourceTimeline.d.ts +179 -0
  58. package/dist/types/core/rowHierarchy.d.ts +25 -0
  59. package/dist/types/core/scheduleDiagnostics.d.ts +37 -0
  60. package/dist/types/core/scheduleModel.d.ts +187 -0
  61. package/dist/types/core/scheduleTrace.d.ts +118 -0
  62. package/dist/types/core/scheduling.d.ts +194 -0
  63. package/dist/types/core/snapshot.d.ts +388 -0
  64. package/dist/types/core/statusDate.d.ts +36 -0
  65. package/dist/types/core/timeRangeTargets.d.ts +67 -0
  66. package/dist/types/core/timeline.d.ts +194 -0
  67. package/dist/types/core/timelineView.d.ts +101 -0
  68. package/dist/types/core/types.d.ts +783 -0
  69. package/dist/types/core/viewBindings.d.ts +112 -0
  70. package/dist/types/core/windowedData.d.ts +255 -0
  71. package/dist/types/core/workCalendar.d.ts +41 -0
  72. package/dist/types/core/workingTimeScale.d.ts +33 -0
  73. package/dist/types/index.d.ts +52 -0
  74. package/docs/api.md +1989 -0
  75. package/docs/architecture.md +112 -0
  76. package/docs/code-of-conduct.md +24 -0
  77. package/docs/integration.md +931 -0
  78. package/docs/scheduling.md +586 -0
  79. package/docs/security.md +26 -0
  80. package/docs/third-party-licenses.md +33 -0
  81. package/package.json +79 -4
@@ -0,0 +1,96 @@
1
+ import type { GraphEdge, GraphGroup, IdentifiedNode } from './graph.js';
2
+ /**
3
+ * Weakly connected components (edge direction ignored). Each component lists its node IDs in input order and
4
+ * components are ordered by their first node's input position. Isolated nodes are single-node components.
5
+ */
6
+ export declare function graphComponents(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[]): string[][];
7
+ export interface GraphDegreeCentralityOptions {
8
+ /** Which edges count: incoming, outgoing or both. Default `'both'`. */
9
+ direction?: 'in' | 'out' | 'both';
10
+ /** Divide each count by n − 1 (0 when the graph has fewer than two nodes). Default false: raw counts. */
11
+ normalized?: boolean;
12
+ }
13
+ /**
14
+ * Degree per node ID, in input order. Every edge counts once, so parallel edges add up. A self-loop is one
15
+ * incoming and one outgoing edge: it adds 1 to `'in'`, 1 to `'out'` and 2 to `'both'`. Normalized values can
16
+ * exceed 1 when parallel edges or self-loops are present.
17
+ */
18
+ export declare function graphDegreeCentrality(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[], options?: GraphDegreeCentralityOptions): Map<string, number>;
19
+ export interface GraphBetweennessOptions {
20
+ /** Default true follows edge direction only; false lets edges be walked both ways. */
21
+ directed?: boolean;
22
+ /** Scale scores to [0, 1]. Default true. */
23
+ normalized?: boolean;
24
+ /** Edge length; must be finite and greater than 0. Without it every edge has length 1. */
25
+ weight?: (edge: GraphEdge) => number;
26
+ }
27
+ /**
28
+ * Betweenness centrality by Brandes' algorithm: for every node, the share of shortest paths between other node
29
+ * pairs that pass through it. Cost is O(V·E) without `weight` and O(V·(E + V) log V) with it, so it suits graphs of
30
+ * a few thousand nodes. Parallel edges count as distinct shortest paths; self-loops never lie on shortest paths.
31
+ * Lengths that differ by less than a relative 1e-12 are treated as equal.
32
+ *
33
+ * Normalization divides by (n − 1)(n − 2), the number of ordered node pairs excluding the node itself. For undirected
34
+ * graphs the raw score counts each unordered pair once (the ordered sum halved) and the divisor is (n − 1)(n − 2) / 2,
35
+ * which gives the same result as dividing the ordered sum by (n − 1)(n − 2). With fewer than three nodes, normalized scores are 0.
36
+ */
37
+ export declare function graphBetweennessCentrality(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[], options?: GraphBetweennessOptions): Map<string, number>;
38
+ export interface GraphPageRankOptions {
39
+ /** Probability of following a link rather than jumping to a random node; in [0, 1). Default 0.85. */
40
+ damping?: number;
41
+ /** Stop when the L1 change between iterations drops below this; finite and greater than 0. Default 1e-6. */
42
+ tolerance?: number;
43
+ /** Iteration cap; a positive integer. Default 100. */
44
+ maxIterations?: number;
45
+ /** Edge weight; finite and nonnegative. Without it every edge counts 1. */
46
+ weight?: (edge: GraphEdge) => number;
47
+ }
48
+ export interface GraphPageRankResult {
49
+ /** Score per node ID in input order; the scores sum to 1 (the map is empty for an empty graph). */
50
+ scores: Map<string, number>;
51
+ /** Iterations performed. */
52
+ iterations: number;
53
+ /** False when `maxIterations` was reached before the change fell below `tolerance`. */
54
+ converged: boolean;
55
+ }
56
+ /**
57
+ * PageRank by power iteration. Edges point from the linking node to the linked one; parallel edges add their
58
+ * weights and a self-loop is an ordinary link. Nodes without outgoing weight (dangling) spread their score uniformly
59
+ * over all nodes. Returns `{ scores, iterations, converged }` rather than a bare map so callers can detect a run
60
+ * that hit the iteration cap.
61
+ */
62
+ export declare function graphPageRank(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[], options?: GraphPageRankOptions): GraphPageRankResult;
63
+ export interface GraphCommunityOptions {
64
+ /** Modularity resolution γ; larger values give smaller communities. Finite and greater than 0. Default 1. */
65
+ resolution?: number;
66
+ /** Edge weight; finite and greater than 0. Without it every edge counts 1. */
67
+ weight?: (edge: GraphEdge) => number;
68
+ }
69
+ export interface GraphCommunityResult {
70
+ /** Node IDs per community: members in input order, communities ordered by their first member's input position. */
71
+ communities: string[][];
72
+ /** Modularity of the partition at the given resolution (0 for a graph without edges). */
73
+ modularity: number;
74
+ }
75
+ /**
76
+ * Louvain community detection: local moving of nodes to the neighbouring community with the best modularity gain,
77
+ * then aggregation of communities into super-nodes, repeated until no node moves. Edge direction is ignored, parallel
78
+ * edges and self-loops add their weights. Deterministic: nodes are visited in input order and ties keep the current
79
+ * community. Modularity is Q = Σ_c [ in_c / 2m − γ (tot_c / 2m)² ]. Expect roughly O(E log V) time on typical graphs.
80
+ */
81
+ export declare function detectGraphCommunities(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[], options?: GraphCommunityOptions): GraphCommunityResult;
82
+ export interface GraphCommunityGroupsOptions {
83
+ /** Prefix of generated group IDs (`idPrefix + (index + 1)`). Default `'community-'`. */
84
+ idPrefix?: string;
85
+ /** Group label from its members and its zero-based index in `communities`. Default `Community N`. */
86
+ label?: (members: readonly string[], index: number) => string;
87
+ /** Communities with fewer members produce no group. A positive integer; default 2. */
88
+ minSize?: number;
89
+ }
90
+ /**
91
+ * Turn communities into `NetworkGraph` `groups`. Numbering follows the position in `communities`, so skipped small
92
+ * communities leave gaps and the IDs of the others stay stable. Group IDs must not collide with node IDs, because
93
+ * collapsing a group uses the group ID for its proxy node; choose `idPrefix` accordingly. A node listed in two
94
+ * communities throws an Error.
95
+ */
96
+ export declare function graphCommunityGroups(communities: readonly (readonly string[])[], options?: GraphCommunityGroupsOptions): GraphGroup[];
@@ -0,0 +1,62 @@
1
+ import type { GraphEdge } from './graph.js';
2
+ import type { NetworkGroup, NetworkNode } from './types.js';
3
+ /** A collapsed group as `collapseGraphGroups` reports it. */
4
+ export interface GraphCollapsedGroup {
5
+ /** The group ID, which is also the ID of its proxy node. */
6
+ id: string;
7
+ label: string;
8
+ /** Every hidden node of the group and its descendant groups, in input order. */
9
+ nodeIds: string[];
10
+ }
11
+ /** Data of a proxy node made by `collapseGraphGroups`. */
12
+ export interface GraphCollapsedNodeData {
13
+ collapsedGroup: string;
14
+ nodeIds: string[];
15
+ }
16
+ /** A proxy node made by `collapseGraphGroups`: it stands for a collapsed group and has its ID and label. */
17
+ export type GraphCollapsedNode = NetworkNode<GraphCollapsedNodeData>;
18
+ /**
19
+ * A node that NetworkGraph draws and hands to its `node` and `tooltip` slots, its `layout` function and its export
20
+ * callbacks: an input node of type `N`, or, when the graph has groups (`G` is not `never`), a `GraphCollapsedNode`
21
+ * proxy of a collapsed group.
22
+ */
23
+ export type GraphShownNode<N extends NetworkNode = NetworkNode, G extends NetworkGroup = NetworkGroup> = N | ([G] extends [never] ? never : GraphCollapsedNode);
24
+ /**
25
+ * An edge that NetworkGraph draws and hands to its `edge` and `tooltip` slots, its `layout` function and its export
26
+ * callbacks: an input edge of type `E`, or, when the graph has groups (`G` is not `never`), an edge that merges several
27
+ * edges re-attached to a collapsed group, which has no `data`.
28
+ */
29
+ export type GraphShownEdge<E extends GraphEdge = GraphEdge, G extends NetworkGroup = NetworkGroup> = E | ([G] extends [never] ? never : GraphEdge<never>);
30
+ export interface GraphCollapseOptions {
31
+ /** Detail text of a proxy node. Default "1 node" or "N nodes". Return undefined for no detail. */
32
+ detail?: (group: GraphCollapsedGroup) => string | undefined;
33
+ }
34
+ export interface GraphCollapseResult<N extends NetworkNode = NetworkNode, E extends GraphEdge = GraphEdge> {
35
+ /** Visible nodes in input order; each proxy takes the place of its group's first member. */
36
+ nodes: (N | NetworkNode)[];
37
+ /**
38
+ * Visible edges in input order. An edge between two visible nodes is kept as it is. Edges re-attached to a proxy are
39
+ * merged into one edge per source, source port, target and target port; it keeps the ID of the first original edge.
40
+ */
41
+ edges: (E | GraphEdge)[];
42
+ /** The groups that stay drawn, with each collapsed child group replaced by its proxy among the parent's nodeIds. */
43
+ groups: NetworkGroup[];
44
+ /** The outermost collapsed groups by proxy ID, in group input order. */
45
+ proxies: Map<string, GraphCollapsedGroup>;
46
+ /** Every hidden node ID mapped to the proxy that stands for it. */
47
+ owners: Map<string, string>;
48
+ /** Each re-attached edge ID mapped to the original edge IDs merged into it, in input order. */
49
+ mergedEdges: Map<string, string[]>;
50
+ /** Original IDs of the edges dropped because both ends are inside the same collapsed group. */
51
+ hiddenEdgeIds: string[];
52
+ }
53
+ /**
54
+ * Replaces each outermost collapsed group with one proxy node. The proxy has the group's ID and label, a detail with the
55
+ * member count, the rounded shape and `data` of type GraphCollapsedNodeData. Member nodes are removed, edges are
56
+ * re-attached to the proxy (dropping the port on that end), edges inside one collapsed group are dropped, and parallel
57
+ * re-attached edges are merged; a merged edge keeps its label, edgeStyle, markers and animated flag only when every merged
58
+ * edge has the same value. Throws Error for a duplicate or empty group ID, an unknown parent, a parent cycle, an
59
+ * unknown or repeated member, an unknown collapsed ID, or a collapsed group ID that is also a visible node ID. The
60
+ * inputs are not modified.
61
+ */
62
+ export declare function collapseGraphGroups<N extends NetworkNode, E extends GraphEdge>(nodes: readonly N[], edges: readonly E[], groups: readonly NetworkGroup[], collapsedIds: Iterable<string>, options?: GraphCollapseOptions): GraphCollapseResult<N, E>;
@@ -0,0 +1,25 @@
1
+ import type { GraphEdge, GraphLayout, GraphLayoutDirection } from './graph.js';
2
+ export interface CrossingItem {
3
+ rank: number;
4
+ a: number;
5
+ b: number;
6
+ }
7
+ /** Count pairs of edges between the same two adjacent ranks whose endpoints strictly swap order. */
8
+ export declare function countAdjacentCrossings(items: CrossingItem[]): number;
9
+ /**
10
+ * Count crossings between edges that connect adjacent ranks, measured on the node centres of a layout.
11
+ * Long edges, same-rank edges and self-loops use their own routes and are not counted.
12
+ */
13
+ export declare function countGraphCrossings(layout: GraphLayout, edges: readonly GraphEdge[], direction?: GraphLayoutDirection): number;
14
+ /**
15
+ * The neighbours of each node in lower (`above`) and higher (`below`) ranks, in edge order, and the edges between
16
+ * adjacent ranks as [lower, higher] pairs. Same-rank edges and self-loops are left out. Shared by the crossing reduction
17
+ * of the layered and the swimlane layouts.
18
+ */
19
+ export declare function rankNeighbours(edges: readonly GraphEdge[], ranks: ReadonlyMap<string, number>): {
20
+ above: Map<string, string[]>;
21
+ below: Map<string, string[]>;
22
+ adjacent: [string, string][];
23
+ };
24
+ /** Reorder nodes inside each column (in place) with alternating barycenter/median sweeps; never worse than the input order. */
25
+ export declare function reduceCrossings(columns: string[][], edges: readonly GraphEdge[], ranks: ReadonlyMap<string, number>, method: 'barycenter' | 'median', sweeps: number): void;
@@ -0,0 +1,52 @@
1
+ import type { GraphEdge, GraphPoint, IdentifiedNode } from './graph.js';
2
+ /**
3
+ * A deletion proposal. `nodeIds` follows the order of the node array and `edgeIds` the order of the edge array.
4
+ * `edgeIds` lists every edge that touches a deleted node, so applying the proposal leaves a consistent graph.
5
+ */
6
+ export interface GraphDeletion {
7
+ nodeIds: string[];
8
+ edgeIds: string[];
9
+ }
10
+ /**
11
+ * Normalizes a deletion: validates the graph and the requested IDs, adds every edge incident to a deleted node,
12
+ * removes duplicates and sorts both lists into input order. Unknown node or edge IDs throw an Error.
13
+ */
14
+ export declare function graphDeletion(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[], nodeIds: Iterable<string>, edgeIds?: Iterable<string>): GraphDeletion;
15
+ /**
16
+ * Returns new node and edge arrays without the elements of `deletion`. Edges incident to a removed node are removed
17
+ * too, even when `deletion.edgeIds` omits them. Unknown IDs throw an Error. The input arrays are not modified.
18
+ */
19
+ export declare function removeGraphElements<N extends IdentifiedNode, E extends GraphEdge>(nodes: readonly N[], edges: readonly E[], deletion: GraphDeletion): {
20
+ nodes: N[];
21
+ edges: E[];
22
+ };
23
+ /** Options of `cloneGraphElements`. */
24
+ export interface GraphCloneOptions {
25
+ /** Returns the ID of the copy of a node or an edge. IDs must be nonempty, unique and unused in the input arrays. */
26
+ createId: (id: string, kind: 'node' | 'edge') => string;
27
+ /** Saved positions of the source nodes. Copies of the nodes that have one receive it, moved by `offset`. */
28
+ positions?: ReadonlyMap<string, GraphPoint>;
29
+ /** Added to every copied position. Default `{ x: 0, y: 0 }`. */
30
+ offset?: GraphPoint;
31
+ }
32
+ /** The copies made by `cloneGraphElements`, and the IDs of the copies keyed by the source IDs. */
33
+ export interface GraphCloneResult<N extends IdentifiedNode = IdentifiedNode, E extends GraphEdge = GraphEdge> {
34
+ nodes: N[];
35
+ edges: E[];
36
+ /** Positions of the copied nodes, keyed by the new node IDs. */
37
+ positions: Map<string, GraphPoint>;
38
+ idMap: {
39
+ nodes: Map<string, string>;
40
+ edges: Map<string, string>;
41
+ };
42
+ }
43
+ /**
44
+ * Copies the nodes listed in `nodeIds` and every edge whose source and target are both among them, in input order.
45
+ * Copies are shallow: they keep every field (ports, data, labels) and only receive new IDs from `options.createId`,
46
+ * and copied edges point at the copied nodes. Saved positions of the source nodes are moved by `options.offset` and
47
+ * returned under the new IDs, and the waypoints (`points`) of copied edges are moved by the same offset so routes keep
48
+ * their shape. Duplicate IDs in `nodeIds` are ignored. Throws an Error for an invalid graph, an unknown node ID, or a
49
+ * new ID that is empty, repeated or already used by a node (or edge) of the input, and a RangeError for a non-finite
50
+ * offset, copied position or copied waypoint. The input arrays, maps and waypoints are not modified.
51
+ */
52
+ export declare function cloneGraphElements<N extends IdentifiedNode, E extends GraphEdge>(nodes: readonly N[], edges: readonly E[], nodeIds: Iterable<string>, options: GraphCloneOptions): GraphCloneResult<N, E>;
@@ -0,0 +1,71 @@
1
+ import type { GraphEdge } from './graph.js';
2
+ import { type DanglingLink } from './windowedData.js';
3
+ /**
4
+ * Incremental neighbourhood expansion of a partially loaded graph. The application loads pages of nodes and edges (for
5
+ * example the direct neighbours of one node at a time) and merges them here: nodes and edges are deduplicated by ID,
6
+ * expanded nodes are remembered, and edges to nodes that are not loaded yet are kept apart from the component input.
7
+ * Pure and immutable: every function returns a new state. Layout stability on expansion is not handled here.
8
+ */
9
+ export interface GraphExpansionState<N extends {
10
+ id: string;
11
+ } = {
12
+ id: string;
13
+ }, E extends GraphEdge = GraphEdge> {
14
+ /** Loaded nodes by ID, in first-arrival order; a later page replaces a node with the same ID. */
15
+ readonly nodes: ReadonlyMap<string, N>;
16
+ /** Loaded edges by ID, in first-arrival order, including dangling ones. */
17
+ readonly edges: ReadonlyMap<string, E>;
18
+ /** Nodes whose neighbours have been loaded. */
19
+ readonly expandedIds: ReadonlySet<string>;
20
+ /** Nodes whose expansion is in flight (`beginGraphExpansion`). */
21
+ readonly pendingIds: ReadonlySet<string>;
22
+ }
23
+ /** A page of a graph source: the nodes and edges it returned. */
24
+ export interface GraphExpansionPage<N extends {
25
+ id: string;
26
+ } = {
27
+ id: string;
28
+ }, E extends GraphEdge = GraphEdge> {
29
+ nodes?: readonly N[];
30
+ edges?: readonly E[];
31
+ }
32
+ /** What to pass to NetworkGraph, and what to keep aside. */
33
+ export interface GraphExpansionView<N extends {
34
+ id: string;
35
+ } = {
36
+ id: string;
37
+ }, E extends GraphEdge = GraphEdge> {
38
+ /** Every loaded node. */
39
+ nodes: N[];
40
+ /** Edges whose both ends are loaded: safe for NetworkGraph `edges`. */
41
+ edges: E[];
42
+ /** Edges with an end that is not loaded yet; they move to `edges` once that node arrives. */
43
+ dangling: DanglingLink<E>[];
44
+ /** Loaded nodes that are neither expanded nor being expanded, in load order. */
45
+ frontierIds: string[];
46
+ }
47
+ /** A state holding an optional first page (for example the selected nodes), with nothing expanded. */
48
+ export declare function createGraphExpansion<N extends {
49
+ id: string;
50
+ }, E extends GraphEdge = GraphEdge>(seed?: GraphExpansionPage<N, E>): GraphExpansionState<N, E>;
51
+ /** Marks nodes as being expanded, so they leave the frontier until their page is merged or the expansion is cancelled. */
52
+ export declare function beginGraphExpansion<N extends {
53
+ id: string;
54
+ }, E extends GraphEdge>(state: GraphExpansionState<N, E>, ids: Iterable<string>): GraphExpansionState<N, E>;
55
+ /** Forgets that nodes are being expanded (after a failed or aborted load); they return to the frontier. */
56
+ export declare function cancelGraphExpansion<N extends {
57
+ id: string;
58
+ }, E extends GraphEdge>(state: GraphExpansionState<N, E>, ids: Iterable<string>): GraphExpansionState<N, E>;
59
+ /**
60
+ * Merges a page into the state: nodes and edges are added or replaced by ID, so overlapping pages (a cycle reached from
61
+ * two sides, a neighbour shared by two expanded nodes) never duplicate anything, and `expandedIds` (the nodes whose
62
+ * neighbours the page holds) are marked expanded and no longer pending. Throws Error for an item without a non-empty
63
+ * string ID, an ID twice in the page or an edge without string ends. The inputs are not modified.
64
+ */
65
+ export declare function mergeGraphExpansionPage<N extends {
66
+ id: string;
67
+ }, E extends GraphEdge>(state: GraphExpansionState<N, E>, page: GraphExpansionPage<N, E>, expandedIds?: Iterable<string>): GraphExpansionState<N, E>;
68
+ /** The component input of a state: the loaded nodes, the edges between them, the dangling edges and the frontier. */
69
+ export declare function graphExpansionView<N extends {
70
+ id: string;
71
+ }, E extends GraphEdge>(state: GraphExpansionState<N, E>): GraphExpansionView<N, E>;
@@ -0,0 +1,184 @@
1
+ import { type GraphBox, type GraphEdge, type GraphLayout, type GraphLayoutDirection, type GraphPort, type IdentifiedNode } from './graph.js';
2
+ /**
3
+ * How `layoutFlowGraph` turns quantities into pixels. `pixelsPerUnit` fixes the scale; `fitExtent` picks the largest
4
+ * scale at which the fullest rank (its node sizes plus the gaps between them) fits into that cross-flow extent. Boxes with
5
+ * a small nonzero value raised to `minNodeSize` are not part of that fit, so a rank holding them can exceed it slightly.
6
+ */
7
+ export type GraphFlowScale = {
8
+ pixelsPerUnit: number;
9
+ } | {
10
+ fitExtent: number;
11
+ };
12
+ /** Options of `layoutFlowGraph`. `N` and `E` type the nodes and edges that the accessors receive. */
13
+ export interface GraphFlowOptions<N extends IdentifiedNode = IdentifiedNode, E extends GraphEdge = GraphEdge> {
14
+ /** The quantity that flows along an edge, in the edge's unit. Must be a finite number of at least 0. Required. */
15
+ quantity: (edge: E) => number;
16
+ /**
17
+ * The unit of every quantity (`'pcs'`), or the unit of each edge (`edge => edge.data.unit`). Required. Quantities in
18
+ * different units are never added: edges whose unit is not `displayUnit` are left out of the picture and listed in
19
+ * `excluded`.
20
+ */
21
+ unit: string | ((edge: E) => string);
22
+ /** The unit the projection draws and sums. Required when `unit` is a function; defaults to `unit` when it is a string. */
23
+ displayUnit?: string;
24
+ /** Direction of the flow. Default `'LR'`. */
25
+ direction?: GraphLayoutDirection;
26
+ /** Size of every node box along the flow. Positive. Default 24. */
27
+ nodeThickness?: number;
28
+ /** Cross-flow gap between neighbouring nodes of one rank. Default 16. */
29
+ nodeGap?: number;
30
+ /** Gap between ranks along the flow, where the bands run. Default 120. */
31
+ rankGap?: number;
32
+ /** Margin around the picture. Default 20. */
33
+ padding?: number;
34
+ /** Default `{ fitExtent: 360 }`. */
35
+ scale?: GraphFlowScale;
36
+ /** Smallest cross-flow size of a node box, so a node without flow stays visible. Positive. Default 2. */
37
+ minNodeSize?: number;
38
+ /** Smallest drawn stroke width of a band, so a zero quantity stays a selectable hairline. Default 1. */
39
+ minBandWidth?: number;
40
+ /** Gap between the picture and the reference lanes, and between two reference lanes. Default 12. */
41
+ referenceGap?: number;
42
+ /** Number of barycenter sweeps of the layered layout that order the nodes of each rank. Positive integer. Default 4. */
43
+ crossingSweeps?: number;
44
+ /** Node name used in band labels. Defaults to the node's `label` when it is a string, else its ID. */
45
+ nodeLabel?: (node: N) => string;
46
+ /** Quantity text used in band labels. Default `` `${quantity} ${unit}` ``. */
47
+ formatQuantity?: (quantity: number, unit: string) => string;
48
+ }
49
+ /** One node of a flow projection. All totals are in the projection's `unit`. */
50
+ export interface GraphFlowNode {
51
+ /** The original node ID. */
52
+ id: string;
53
+ /** The node box in chart coordinates; `rank` counts ranks along the flow. */
54
+ box: GraphBox;
55
+ rank: number;
56
+ /** Position of the node within its rank, from the top (LR, RL) or the left (TB, BT). */
57
+ order: number;
58
+ /** Sum of the forward bands that end here. */
59
+ inflow: number;
60
+ /** Sum of the forward bands that start here. */
61
+ outflow: number;
62
+ /** `outflow - inflow`, as given: negative where less leaves than arrives (scrap, stock, rounding — the caller decides). */
63
+ difference: number;
64
+ /**
65
+ * `max(inflow, outflow)`. The cross-flow size of the box is `max(inflow + referenceInflow, outflow + referenceOutflow)
66
+ * × scale` (at least `minNodeSize`), so it equals `value × scale` for a node without reference bands and also holds the
67
+ * reference stacks of one that has them.
68
+ */
69
+ value: number;
70
+ /** Sum of the reference (loop) bands that end here. Not part of `inflow` or `value`. */
71
+ referenceInflow: number;
72
+ /** Sum of the reference (loop) bands that start here. Not part of `outflow` or `value`. */
73
+ referenceOutflow: number;
74
+ }
75
+ /** The band of one edge of a flow projection. */
76
+ export interface GraphFlowBand {
77
+ /** The original edge ID. */
78
+ edgeId: string;
79
+ from: string;
80
+ to: string;
81
+ quantity: number;
82
+ unit: string;
83
+ /** `quantity × scale`, exactly. */
84
+ thickness: number;
85
+ /** The drawn stroke width: `thickness`, at least `minBandWidth`. */
86
+ width: number;
87
+ /**
88
+ * True for an edge that closes a cycle (a rework loop) or is a self-loop. It is stacked below the forward bands of
89
+ * both ends, routed back through a lane beside the ranks, drawn dashed by the renderers, and counted in
90
+ * `referenceInflow` and `referenceOutflow` instead of `inflow`, `outflow` and `value`.
91
+ */
92
+ reference: boolean;
93
+ selfLoop: boolean;
94
+ /** The source box side the band leaves through: the downstream side (right for LR, left for RL, bottom for TB, top for BT). */
95
+ sourceSide: GraphPort['side'];
96
+ /** The target box side the band enters through: the upstream side. */
97
+ targetSide: GraphPort['side'];
98
+ /** Where the band starts along its source side, from the top end (left, right) or left end (top, bottom) of that side; it covers `[sourceOffset, sourceOffset + thickness]`. */
99
+ sourceOffset: number;
100
+ /** Where the band starts along its target side, measured like `sourceOffset`. */
101
+ targetOffset: number;
102
+ /** The centre line of the band in chart coordinates; stroke it with `width`. */
103
+ path: string;
104
+ /** Accessible text such as `Cut → Inspect: 60 pcs`. */
105
+ label: string;
106
+ }
107
+ /** An edge whose unit is not the displayed unit; it is not drawn and not added to any total. */
108
+ export interface GraphFlowExcludedEdge {
109
+ edgeId: string;
110
+ from: string;
111
+ to: string;
112
+ unit: string;
113
+ quantity: number;
114
+ }
115
+ /**
116
+ * The result of `layoutFlowGraph`. It is a `GraphLayout` (boxes for every node, a path for every band, no edge label
117
+ * anchors), so it can be the NetworkGraph `layout` and the layout of `renderGraphSvg`, for the edges that have a band.
118
+ */
119
+ export interface GraphFlowLayout extends GraphLayout {
120
+ /** The displayed unit. */
121
+ unit: string;
122
+ /** Pixels per unit, the same across the whole picture. */
123
+ scale: number;
124
+ direction: GraphLayoutDirection;
125
+ /** One entry per node, in input order. */
126
+ nodes: GraphFlowNode[];
127
+ /** One band per edge in the displayed unit, in input order. */
128
+ bands: GraphFlowBand[];
129
+ /** Edges in another unit, in input order. */
130
+ excluded: GraphFlowExcludedEdge[];
131
+ }
132
+ /**
133
+ * Drawing of one edge as a band with real width: the NetworkGraph `edgeBands` prop and the `renderGraphSvg` option of
134
+ * the same name take these by edge ID. `graphFlowBands` builds them from a flow projection.
135
+ */
136
+ export interface GraphEdgeBand {
137
+ /** Stroke width of the band in chart units. Finite and at least 0. */
138
+ width: number;
139
+ /** Draws the band as a dashed reference band (a loop that is not part of the node totals). */
140
+ reference?: boolean;
141
+ /** Accessible name of the band; replaces the edge label in the name of its hit area. */
142
+ label?: string;
143
+ }
144
+ /**
145
+ * Projects quantities on the edges of a graph into a Sankey-style picture: node boxes ordered in ranks along the flow
146
+ * and, for each edge, a band whose width is `quantity × scale` on one scale for the whole picture.
147
+ *
148
+ * Ranks come from the layered layout (`layoutLayeredGraph` with barycenter crossing reduction) of the forward edges.
149
+ * Each node box is `nodeThickness` long along the flow and `max(inflow, outflow) × scale` across it (at least
150
+ * `minNodeSize`; see `GraphFlowNode.value` for nodes with reference bands). Bands are stacked along a node side from
151
+ * its top (LR, RL) or left (TB, BT), sorted by the position of their other end, so they cross as little as possible.
152
+ * The totals are reported as given and never balanced: where inflow and outflow differ, the shorter stack leaves the
153
+ * rest of the box empty and `difference` says by how much.
154
+ *
155
+ * Units are never mixed: only edges whose unit is `displayUnit` are drawn and summed; the others are returned in
156
+ * `excluded`. A quantity of 0 keeps its band, with `thickness` 0, drawn as a `minBandWidth` hairline.
157
+ *
158
+ * Cycles terminate: an iterative depth-first search in input order marks the edges that close a cycle, and self-loops,
159
+ * as reference bands. They are routed back through lanes beside the ranks (below for LR and RL, to the right for TB and
160
+ * BT), drawn dashed by the renderers, and counted in `referenceInflow` and `referenceOutflow`, not in the node totals.
161
+ * Loops are not unrolled; to show rework as forward flow across periods, give each period its own node copies first.
162
+ *
163
+ * Throws Error for unknown endpoints, duplicate IDs and a missing or empty unit, and RangeError for a quantity that is
164
+ * not a finite number of at least 0, an unknown direction and invalid sizes. The inputs are not modified.
165
+ */
166
+ export declare function layoutFlowGraph<N extends IdentifiedNode, E extends GraphEdge>(nodes: readonly N[], edges: readonly E[], options: GraphFlowOptions<N, E>): GraphFlowLayout;
167
+ /**
168
+ * The bands of a flow projection as the NetworkGraph `edgeBands` prop and the `renderGraphSvg` option expect them:
169
+ * the drawn width, the reference flag and the accessible label, by edge ID.
170
+ */
171
+ export declare function graphFlowBands(flow: Pick<GraphFlowLayout, 'bands'>): Map<string, GraphEdgeBand>;
172
+ /**
173
+ * The default dash pattern of a reference band of the given drawn width: `10 6` for thin bands, lengthened with the
174
+ * width (dash twice, gap at least three quarters of it) so a wide band reads as a dashed band rather than a comb of
175
+ * stripes. For a straight-segment path (`M`/`L` commands, as `layoutFlowGraph` routes loops) the gaps are evened out so
176
+ * the band starts and ends with a dash at its nodes.
177
+ */
178
+ export declare function graphReferenceDash(width: number, path?: string): string;
179
+ /** Validates an `edgeBands` map: every width finite and at least 0. Throws RangeError naming the edge. */
180
+ export declare function assertGraphEdgeBands(bands: ReadonlyMap<string, GraphEdgeBand>, owner: string): void;
181
+ /** Edges in drawing order for bands: wider bands first so thinner ones stay on top, then the other edges, each stably. */
182
+ export declare function graphBandOrder<E extends {
183
+ id: string;
184
+ }>(edges: readonly E[], bands: ReadonlyMap<string, GraphEdgeBand>): E[];
@@ -0,0 +1,29 @@
1
+ import type { GraphEdge, GraphLayout, GraphPoint, IdentifiedNode } from './graph.js';
2
+ export interface GraphForceLayoutOptions {
3
+ nodeWidth?: number;
4
+ nodeHeight?: number;
5
+ padding?: number;
6
+ /** Simulation steps. Positive integer, default 300. */
7
+ iterations?: number;
8
+ /** Preferred distance between the centres of linked nodes. Default 180. */
9
+ linkDistance?: number;
10
+ /** Strength of the repulsion between every pair of nodes (Barnes–Hut approximated). Default 600. */
11
+ repulsion?: number;
12
+ /** Pull of every node toward the centre of its group, in [0, 1]. Default 0.05. */
13
+ gravity?: number;
14
+ /** Minimum free space kept between node boxes by the final overlap passes. Default 16. */
15
+ nodeGap?: number;
16
+ /** Integer seed of the pseudo-random initial placement. Default 1. */
17
+ seed?: number;
18
+ /** Start positions (box top-left corners). Nodes without one start next to a placed neighbour or at a seeded random point. Unknown IDs are ignored. */
19
+ initialPositions?: ReadonlyMap<string, GraphPoint>;
20
+ /** Node IDs pinned to their initial position. Unknown IDs are ignored. */
21
+ fixed?: ReadonlySet<string>;
22
+ }
23
+ /**
24
+ * Deterministic force-directed layout: link springs, Barnes–Hut repulsion and gravity, followed by box-overlap passes.
25
+ * Connected components without pinned nodes are laid out separately and packed in rows; components containing a
26
+ * pinned node share the caller's coordinate frame. Box `rank` is the breadth-first depth (ignoring edge direction)
27
+ * from the first node of its component in input order.
28
+ */
29
+ export declare function layoutForceGraph(nodes: readonly IdentifiedNode[], edges: readonly GraphEdge[], options?: GraphForceLayoutOptions): GraphLayout;
@@ -0,0 +1,31 @@
1
+ import type { GraphBox, GraphEdge, GraphLayout, GraphPoint, GraphPort, IdentifiedNode } from './graph.js';
2
+ /**
3
+ * How the core routing functions and NetworkGraph treat the edge paths of a layout. 'builtin' (the default) redraws
4
+ * every edge with a named port and, in the orthogonal and straight edge styles, every edge. 'preserve' keeps each path
5
+ * the layout drew while it still fits its nodes and ports, and redraws only the others.
6
+ */
7
+ export type GraphRoutingPolicy = 'builtin' | 'preserve';
8
+ /** Internal: the edges of a layout whose paths the core drew, as recorded by the functions that produced it. */
9
+ export declare function builtinRoutedEdges(layout: GraphLayout): ReadonlySet<string>;
10
+ /**
11
+ * Internal: records on `result` the built-in routes of `source` plus `added`, and returns `result`. Only a newly
12
+ * created layout object is passed as `result`.
13
+ */
14
+ export declare function markBuiltinRoutes<L extends GraphLayout>(result: L, source: GraphLayout, added: Iterable<string>): L;
15
+ /** Internal: whether a value is a point with finite coordinates. */
16
+ export declare function isFiniteGraphPoint(point: GraphPoint | undefined): point is GraphPoint;
17
+ /**
18
+ * Internal: whether a point lies on one side of a box, or on any side when `side` is undefined, within half a chart
19
+ * unit.
20
+ */
21
+ export declare function isOnGraphBoxSide(box: GraphBox, point: GraphPoint, side?: GraphPort['side']): boolean;
22
+ /**
23
+ * Whether the routing policy 'preserve' keeps the path of an edge in a layout. The path must exist and must have been
24
+ * drawn by the layout, not rerouted by the core because a node moved or was resized; the edge must have no `points`
25
+ * (explicit waypoints always win); and both ends must fit the current boxes: at the anchor of a named port, otherwise on
26
+ * the box border. When the layout has route metadata for the edge (`layout.routes`), its ports must equal the edge's,
27
+ * its sides must match the ports or the borders its ends lie on, its points must be finite, and the path must start and
28
+ * end at its `start` and `end`. Without metadata the ends are read from the path. Never throws; a path it cannot read
29
+ * is not kept.
30
+ */
31
+ export declare function isGraphRouteValid(layout: GraphLayout, nodes: ReadonlyMap<string, IdentifiedNode>, edge: GraphEdge): boolean;