@statelyai/layout 0.0.0 → 0.0.1

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.
@@ -1,4 +1,4 @@
1
- import { a as getPolylineMidpoint, c as placePorts } from "./layered-ByNCZQgJ.mjs";
1
+ import { F as placePorts, O as getPolylineMidpoint, z as JavaRandom } from "./layered-Dd868WZY.mjs";
2
2
  import { getNodeSize } from "@statelyai/graph/layout";
3
3
 
4
4
  //#region src/fixed.ts
@@ -262,36 +262,6 @@ const rectanglePackingAlgorithm = {
262
262
 
263
263
  //#endregion
264
264
  //#region src/random.ts
265
- var JavaRandom = class JavaRandom {
266
- static #multiplier = 25214903917n;
267
- static #addend = 11n;
268
- static #mask = (1n << 48n) - 1n;
269
- #seed;
270
- constructor(seed) {
271
- this.#seed = (BigInt(seed) ^ JavaRandom.#multiplier) & JavaRandom.#mask;
272
- }
273
- #next(bits) {
274
- this.#seed = this.#seed * JavaRandom.#multiplier + JavaRandom.#addend & JavaRandom.#mask;
275
- return Number(this.#seed >> BigInt(48 - bits));
276
- }
277
- nextDouble() {
278
- return (this.#next(26) * 2 ** 27 + this.#next(27)) / 2 ** 53;
279
- }
280
- nextFloat() {
281
- return this.#next(24) / 2 ** 24;
282
- }
283
- nextInt(bound) {
284
- if (bound <= 0) throw new RangeError("bound must be positive");
285
- if ((bound & -bound) === bound) return Math.floor(bound * this.#next(31) / 2 ** 31);
286
- let bits;
287
- let value;
288
- do {
289
- bits = this.#next(31);
290
- value = bits % bound;
291
- } while (bits - value + (bound - 1) >= 2 ** 31);
292
- return value;
293
- }
294
- };
295
265
  function getPadding$1(value) {
296
266
  if (typeof value === "number") return {
297
267
  top: value,
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@statelyai/layout",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Extensible, graph-native layout algorithms for @statelyai/graph",
5
5
  "license": "EPL-2.0 OR GPL-3.0-or-later",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/statelyai/layout.git"
9
+ },
6
10
  "files": [
7
11
  "dist",
8
12
  "LICENSE.md",
@@ -19,35 +23,31 @@
19
23
  "./layered": "./dist/layered/index.mjs",
20
24
  "./package.json": "./package.json"
21
25
  },
22
- "scripts": {
23
- "build": "tsdown",
24
- "bench": "vitest bench --run",
25
- "demo": "vite --config demo/vite.config.ts",
26
- "demo:build": "vite build --config demo/vite.config.ts",
27
- "demo:check": "tsx scripts/generate-demo-corpus.ts --check",
28
- "demo:generate": "tsx scripts/generate-demo-corpus.ts",
29
- "demo:typecheck": "tsc --project demo/tsconfig.json",
30
- "dev": "tsdown --watch",
31
- "format": "oxfmt .",
32
- "format:check": "oxfmt --check .",
33
- "lint": "oxlint",
34
- "lint:fix": "oxlint --fix",
35
- "test": "vitest",
36
- "typecheck": "tsc --noEmit",
37
- "typecheck:repo": "tsc --project tsconfig.repo.json",
38
- "verify": "oxfmt --check . && oxlint && tsc --noEmit && tsc --project tsconfig.repo.json && tsc --project demo/tsconfig.json && tsx scripts/generate-demo-corpus.ts --check && vitest --run && tsdown && vite build --config demo/vite.config.ts && publint --pack npm && tsx scripts/smoke-package.ts",
39
- "validate:package": "publint --pack npm && tsx scripts/smoke-package.ts"
26
+ "publishConfig": {
27
+ "access": "public"
40
28
  },
41
29
  "dependencies": {
42
30
  "@statelyai/graph": "^2.1.0"
43
31
  },
44
32
  "devDependencies": {
45
- "@statelyai/sdk": "^0.20.1",
33
+ "@changesets/cli": "3.0.1",
34
+ "@codemirror/lang-javascript": "^6.2.5",
35
+ "@codemirror/lint": "^6.9.7",
46
36
  "@types/node": "^25.0.3",
37
+ "@types/react": "^19.2.18",
38
+ "@types/react-dom": "^19.2.4",
39
+ "@vitejs/plugin-react": "^6.0.5",
40
+ "codemirror": "^6.0.2",
47
41
  "elkjs": "^0.11.1",
42
+ "json5": "^2.2.3",
43
+ "lucide-react": "^1.31.0",
48
44
  "oxfmt": "0.62.0",
49
45
  "oxlint": "1.77.0",
46
+ "portless": "^0.15.5",
50
47
  "publint": "^0.3.15",
48
+ "react": "^19.2.8",
49
+ "react-dom": "^19.2.8",
50
+ "react-resizable-panels": "^4.12.2",
51
51
  "tsdown": "^0.18.1",
52
52
  "tsx": "^4.22.4",
53
53
  "typescript": "^5.9.3",
@@ -57,5 +57,28 @@
57
57
  "peerDependencies": {
58
58
  "@statelyai/graph": "^2.1.0"
59
59
  },
60
- "packageManager": "pnpm@10.28.2"
61
- }
60
+ "scripts": {
61
+ "build": "tsdown",
62
+ "bench": "vitest bench --run",
63
+ "demo": "portless --name layout vite --config demo/vite.config.ts",
64
+ "demo:build": "vite build --config demo/vite.config.ts",
65
+ "demo:check": "tsx scripts/generate-demo-corpus.ts --check",
66
+ "demo:generate": "tsx scripts/generate-demo-corpus.ts",
67
+ "demo:sync": "tsx scripts/sync-elk-live-examples.ts && pnpm demo:generate",
68
+ "demo:typecheck": "tsc --project demo/tsconfig.json",
69
+ "generate:elk-layered-options": "tsx scripts/generate-elk-layered-options.ts",
70
+ "generate:elk-layered-options:check": "tsx scripts/generate-elk-layered-options.ts --check",
71
+ "dev": "tsdown --watch",
72
+ "changeset": "changeset",
73
+ "release": "pnpm build && pnpm changeset publish",
74
+ "format": "oxfmt .",
75
+ "format:check": "oxfmt --check .",
76
+ "lint": "oxlint",
77
+ "lint:fix": "oxlint --fix",
78
+ "test": "vitest",
79
+ "typecheck": "tsc --noEmit",
80
+ "typecheck:repo": "tsc --project tsconfig.repo.json",
81
+ "verify": "oxfmt --check . && oxlint && tsc --noEmit && tsc --project tsconfig.repo.json && tsc --project demo/tsconfig.json && tsx scripts/generate-elk-layered-options.ts --check && tsx scripts/generate-demo-corpus.ts --check && vitest --run && tsdown && vite build --config demo/vite.config.ts && publint --pack npm && tsx scripts/smoke-package.ts",
82
+ "validate:package": "publint --pack npm && tsx scripts/smoke-package.ts"
83
+ }
84
+ }
@@ -1,149 +0,0 @@
1
- import { LayoutConstraints } from "@statelyai/graph/layout";
2
- import { EntityRect, Graph, GraphNode, GraphPatch, Point, VisualGraph } from "@statelyai/graph";
3
-
4
- //#region src/types.d.ts
5
- type AnyGraph = Graph<unknown, unknown, unknown, unknown>;
6
- type LayoutDirection = "up" | "down" | "left" | "right";
7
- type LayoutScope = {
8
- mode: "full";
9
- } | {
10
- mode: "incremental";
11
- previous: VisualGraph;
12
- } | {
13
- mode: "partial";
14
- previous: VisualGraph;
15
- nodeIds: readonly string[];
16
- } | {
17
- mode: "route-only";
18
- previous: VisualGraph;
19
- edgeIds?: readonly string[];
20
- };
21
- interface LayoutDiagnostic {
22
- severity: "info" | "warning" | "error";
23
- code: string;
24
- message: string;
25
- entityIds?: readonly string[];
26
- phase?: string;
27
- }
28
- interface LayoutPhaseMetrics {
29
- id: string;
30
- durationMs: number;
31
- }
32
- interface LayoutMetrics {
33
- durationMs: number;
34
- nodeCount: number;
35
- edgeCount: number;
36
- phases: readonly LayoutPhaseMetrics[];
37
- }
38
- interface LayoutCapabilities {
39
- full: boolean;
40
- incremental: boolean;
41
- partial: boolean;
42
- routeOnly: boolean;
43
- hierarchy: boolean;
44
- ports: boolean;
45
- }
46
- interface LayoutAlgorithm<Options = unknown> {
47
- readonly id: string;
48
- readonly capabilities: LayoutCapabilities;
49
- layout<N, E, G, P>(graph: Graph<N, E, G, P> | VisualGraph<N, E, G, P>, options: Options, context: LayoutExecutionContext): VisualGraph<N, E, G, P> | Promise<VisualGraph<N, E, G, P>>;
50
- }
51
- interface LayoutExecutionContext {
52
- readonly scope: LayoutScope;
53
- readonly signal?: AbortSignal;
54
- readonly diagnostics: LayoutDiagnostic[];
55
- measurePhase<T>(id: string, run: () => T): T;
56
- throwIfAborted(): void;
57
- }
58
- interface LayoutRequest<N = unknown, E = unknown, G = unknown, P = unknown, O = unknown> {
59
- graph: Graph<N, E, G, P> | VisualGraph<N, E, G, P>;
60
- algorithm?: string | LayoutAlgorithm<O>;
61
- options?: O;
62
- scope?: LayoutScope;
63
- signal?: AbortSignal;
64
- }
65
- interface LayoutResult<N = unknown, E = unknown, G = unknown, P = unknown> {
66
- graph: VisualGraph<N, E, G, P>;
67
- patches: readonly GraphPatch<N, E>[];
68
- diagnostics: readonly LayoutDiagnostic[];
69
- metrics: LayoutMetrics;
70
- }
71
- //#endregion
72
- //#region src/layered/types.d.ts
73
- interface NodeSize {
74
- width: number;
75
- height: number;
76
- }
77
- interface LayeredSpacing {
78
- node: number;
79
- layer: number;
80
- }
81
- interface LayoutPadding {
82
- top: number;
83
- right: number;
84
- bottom: number;
85
- left: number;
86
- }
87
- interface LayeredPhaseInput {
88
- graph: Graph<unknown, unknown, unknown, unknown>;
89
- sizes: ReadonlyMap<string, NodeSize>;
90
- direction: LayoutDirection;
91
- spacing: LayeredSpacing;
92
- padding: LayoutPadding;
93
- constrainedLayerByNodeId: ReadonlyMap<string, number>;
94
- }
95
- interface AcyclicOrientation {
96
- reversedEdgeIds: ReadonlySet<string>;
97
- }
98
- interface LayerAssignment {
99
- layerByNodeId: ReadonlyMap<string, number>;
100
- }
101
- interface LayerOrder {
102
- layers: readonly (readonly string[])[];
103
- }
104
- interface NodePlacement {
105
- rectByNodeId: ReadonlyMap<string, EntityRect>;
106
- }
107
- interface EdgeRoutes {
108
- pointsByEdgeId: ReadonlyMap<string, readonly Point[]>;
109
- }
110
- type CycleBreaker = (input: LayeredPhaseInput) => AcyclicOrientation;
111
- type LayerAssigner = (input: LayeredPhaseInput, orientation: AcyclicOrientation) => LayerAssignment;
112
- type CrossingMinimizer = (input: LayeredPhaseInput, orientation: AcyclicOrientation, assignment: LayerAssignment) => LayerOrder;
113
- type NodePlacer = (input: LayeredPhaseInput, order: LayerOrder) => NodePlacement;
114
- type EdgeRouter = (input: LayeredPhaseInput, orientation: AcyclicOrientation, placement: NodePlacement) => EdgeRoutes;
115
- interface LayeredStrategies {
116
- breakCycles?: CycleBreaker;
117
- assignLayers?: LayerAssigner;
118
- minimizeCrossings?: CrossingMinimizer;
119
- placeNodes?: NodePlacer;
120
- routeEdges?: EdgeRouter;
121
- }
122
- interface LayeredLayoutOptions {
123
- direction?: LayoutDirection;
124
- spacing?: Partial<LayeredSpacing>;
125
- padding?: number | Partial<LayoutPadding>;
126
- constraints?: LayoutConstraints;
127
- measure?: (node: GraphNode) => NodeSize;
128
- crossingSweeps?: number;
129
- strategies?: LayeredStrategies;
130
- }
131
- //#endregion
132
- //#region src/layered/strategies.d.ts
133
- declare const breakCyclesWithDepthFirstSearch: CycleBreaker;
134
- declare const assignLayersByLongestPath: LayerAssigner;
135
- declare function minimizeCrossingsWithBarycenter(sweeps?: number): CrossingMinimizer;
136
- declare const placeNodesInLayers: NodePlacer;
137
- declare const routeEdgesOrthogonally: EdgeRouter;
138
- //#endregion
139
- //#region src/layered/index.d.ts
140
- /**
141
- * Deterministic native layered layout for an `@statelyai/graph` graph.
142
- *
143
- * This initial vertical slice supports flat graphs, cycles, ports, self-loops,
144
- * four directions, custom phase strategies, and orthogonal routes.
145
- */
146
- declare function getLayeredLayout<N, E, G, P>(graph: Graph<N, E, G, P> | VisualGraph<N, E, G, P>, options?: LayeredLayoutOptions): VisualGraph<N, E, G, P>;
147
- declare const layeredAlgorithm: LayoutAlgorithm<LayeredLayoutOptions>;
148
- //#endregion
149
- export { LayoutMetrics as A, NodeSize as C, LayoutDiagnostic as D, LayoutCapabilities as E, LayoutRequest as M, LayoutResult as N, LayoutDirection as O, LayoutScope as P, NodePlacer as S, LayoutAlgorithm as T, LayeredPhaseInput as _, minimizeCrossingsWithBarycenter as a, LayoutPadding as b, AcyclicOrientation as c, EdgeRouter as d, EdgeRoutes as f, LayeredLayoutOptions as g, LayerOrder as h, breakCyclesWithDepthFirstSearch as i, LayoutPhaseMetrics as j, LayoutExecutionContext as k, CrossingMinimizer as l, LayerAssignment as m, layeredAlgorithm as n, placeNodesInLayers as o, LayerAssigner as p, assignLayersByLongestPath as r, routeEdgesOrthogonally as s, getLayeredLayout as t, CycleBreaker as u, LayeredSpacing as v, AnyGraph as w, NodePlacement as x, LayeredStrategies as y };