@graphty/layout 1.2.3 → 1.2.4
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/src/algorithms/index.d.ts +5 -0
- package/dist/src/algorithms/index.js +6 -0
- package/dist/src/algorithms/index.js.map +1 -0
- package/dist/src/algorithms/optimization/index.d.ts +7 -0
- package/dist/src/algorithms/optimization/index.js +7 -0
- package/dist/src/algorithms/optimization/index.js.map +1 -0
- package/dist/src/algorithms/optimization/kamada-kawai-solver.d.ts +32 -0
- package/dist/src/algorithms/optimization/kamada-kawai-solver.js +176 -0
- package/dist/src/algorithms/optimization/kamada-kawai-solver.js.map +1 -0
- package/dist/src/algorithms/optimization/lbfgs.d.ts +13 -0
- package/dist/src/algorithms/optimization/lbfgs.js +56 -0
- package/dist/src/algorithms/optimization/lbfgs.js.map +1 -0
- package/dist/src/algorithms/optimization/line-search.d.ts +15 -0
- package/dist/src/algorithms/optimization/line-search.js +37 -0
- package/dist/src/algorithms/optimization/line-search.js.map +1 -0
- package/dist/src/algorithms/optimization/types.d.ts +5 -0
- package/dist/src/algorithms/optimization/types.js +5 -0
- package/dist/src/algorithms/optimization/types.js.map +1 -0
- package/dist/src/algorithms/planarity/check.d.ts +17 -0
- package/dist/src/algorithms/planarity/check.js +30 -0
- package/dist/src/algorithms/planarity/check.js.map +1 -0
- package/dist/src/algorithms/planarity/embedding.d.ts +29 -0
- package/dist/src/algorithms/planarity/embedding.js +179 -0
- package/dist/src/algorithms/planarity/embedding.js.map +1 -0
- package/dist/src/algorithms/planarity/index.d.ts +7 -0
- package/dist/src/algorithms/planarity/index.js +8 -0
- package/dist/src/algorithms/planarity/index.js.map +1 -0
- package/dist/src/algorithms/planarity/lr-test.d.ts +15 -0
- package/dist/src/algorithms/planarity/lr-test.js +54 -0
- package/dist/src/algorithms/planarity/lr-test.js.map +1 -0
- package/dist/src/algorithms/planarity/special-graphs.d.ts +28 -0
- package/dist/src/algorithms/planarity/special-graphs.js +108 -0
- package/dist/src/algorithms/planarity/special-graphs.js.map +1 -0
- package/dist/src/generators/basic.d.ts +28 -0
- package/dist/src/generators/basic.js +79 -0
- package/dist/src/generators/basic.js.map +1 -0
- package/dist/src/generators/bipartite.d.ts +16 -0
- package/dist/src/generators/bipartite.js +40 -0
- package/dist/src/generators/bipartite.js.map +1 -0
- package/dist/src/generators/grid.d.ts +11 -0
- package/dist/src/generators/grid.js +37 -0
- package/dist/src/generators/grid.js.map +1 -0
- package/dist/src/generators/index.d.ts +8 -0
- package/dist/src/generators/index.js +9 -0
- package/dist/src/generators/index.js.map +1 -0
- package/dist/src/generators/random.d.ts +12 -0
- package/dist/src/generators/random.js +34 -0
- package/dist/src/generators/random.js.map +1 -0
- package/dist/src/generators/scale-free.d.ts +12 -0
- package/dist/src/generators/scale-free.js +62 -0
- package/dist/src/generators/scale-free.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/layouts/basic/index.d.ts +4 -0
- package/dist/src/layouts/basic/index.js +5 -0
- package/dist/src/layouts/basic/index.js.map +1 -0
- package/dist/src/layouts/basic/random.d.ts +14 -0
- package/dist/src/layouts/basic/random.js +27 -0
- package/dist/src/layouts/basic/random.js.map +1 -0
- package/dist/src/layouts/force-directed/arf.d.ts +13 -0
- package/dist/src/layouts/force-directed/arf.js +103 -0
- package/dist/src/layouts/force-directed/arf.js.map +1 -0
- package/dist/src/layouts/force-directed/forceatlas2.d.ts +22 -0
- package/dist/src/layouts/force-directed/forceatlas2.js +322 -0
- package/dist/src/layouts/force-directed/forceatlas2.js.map +1 -0
- package/dist/src/layouts/force-directed/fruchterman-reingold.d.ts +19 -0
- package/dist/src/layouts/force-directed/fruchterman-reingold.js +131 -0
- package/dist/src/layouts/force-directed/fruchterman-reingold.js.map +1 -0
- package/dist/src/layouts/force-directed/index.d.ts +8 -0
- package/dist/src/layouts/force-directed/index.js +9 -0
- package/dist/src/layouts/force-directed/index.js.map +1 -0
- package/dist/src/layouts/force-directed/kamada-kawai.d.ts +15 -0
- package/dist/src/layouts/force-directed/kamada-kawai.js +87 -0
- package/dist/src/layouts/force-directed/kamada-kawai.js.map +1 -0
- package/dist/src/layouts/force-directed/spring.d.ts +19 -0
- package/dist/src/layouts/force-directed/spring.js +23 -0
- package/dist/src/layouts/force-directed/spring.js.map +1 -0
- package/dist/src/layouts/geometric/circular.d.ts +14 -0
- package/dist/src/layouts/geometric/circular.js +67 -0
- package/dist/src/layouts/geometric/circular.js.map +1 -0
- package/dist/src/layouts/geometric/index.d.ts +6 -0
- package/dist/src/layouts/geometric/index.js +7 -0
- package/dist/src/layouts/geometric/index.js.map +1 -0
- package/dist/src/layouts/geometric/shell.d.ts +15 -0
- package/dist/src/layouts/geometric/shell.js +67 -0
- package/dist/src/layouts/geometric/shell.js.map +1 -0
- package/dist/src/layouts/geometric/spiral.d.ts +16 -0
- package/dist/src/layouts/geometric/spiral.js +73 -0
- package/dist/src/layouts/geometric/spiral.js.map +1 -0
- package/dist/src/layouts/hierarchical/bfs.d.ts +12 -0
- package/dist/src/layouts/hierarchical/bfs.js +62 -0
- package/dist/src/layouts/hierarchical/bfs.js.map +1 -0
- package/dist/src/layouts/hierarchical/bipartite.d.ts +16 -0
- package/dist/src/layouts/hierarchical/bipartite.js +72 -0
- package/dist/src/layouts/hierarchical/bipartite.js.map +1 -0
- package/dist/src/layouts/hierarchical/index.d.ts +6 -0
- package/dist/src/layouts/hierarchical/index.js +7 -0
- package/dist/src/layouts/hierarchical/index.js.map +1 -0
- package/dist/src/layouts/hierarchical/multipartite.d.ts +12 -0
- package/dist/src/layouts/hierarchical/multipartite.js +73 -0
- package/dist/src/layouts/hierarchical/multipartite.js.map +1 -0
- package/dist/src/layouts/index.d.ts +8 -0
- package/dist/src/layouts/index.js +9 -0
- package/dist/src/layouts/index.js.map +1 -0
- package/dist/src/layouts/specialized/index.d.ts +5 -0
- package/dist/src/layouts/specialized/index.js +6 -0
- package/dist/src/layouts/specialized/index.js.map +1 -0
- package/dist/src/layouts/specialized/planar.d.ts +14 -0
- package/dist/src/layouts/specialized/planar.js +47 -0
- package/dist/src/layouts/specialized/planar.js.map +1 -0
- package/dist/src/layouts/specialized/spectral.d.ts +14 -0
- package/dist/src/layouts/specialized/spectral.js +106 -0
- package/dist/src/layouts/specialized/spectral.js.map +1 -0
- package/dist/src/types/embedding.d.ts +9 -0
- package/dist/src/types/embedding.js +5 -0
- package/dist/src/types/embedding.js.map +1 -0
- package/dist/src/types/graph.d.ts +10 -0
- package/dist/src/types/graph.js +5 -0
- package/dist/src/types/graph.js.map +1 -0
- package/dist/src/types/index.d.ts +6 -0
- package/dist/src/types/index.js +7 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/layout.d.ts +6 -0
- package/dist/src/types/layout.js +5 -0
- package/dist/src/types/layout.js.map +1 -0
- package/dist/src/utils/graph.d.ts +34 -0
- package/dist/src/utils/graph.js +69 -0
- package/dist/src/utils/graph.js.map +1 -0
- package/dist/src/utils/index.d.ts +8 -0
- package/dist/src/utils/index.js +9 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/numpy.d.ts +17 -0
- package/dist/src/utils/numpy.js +101 -0
- package/dist/src/utils/numpy.js.map +1 -0
- package/dist/src/utils/params.d.ts +17 -0
- package/dist/src/utils/params.js +22 -0
- package/dist/src/utils/params.js.map +1 -0
- package/dist/src/utils/random.d.ts +14 -0
- package/dist/src/utils/random.js +42 -0
- package/dist/src/utils/random.js.map +1 -0
- package/dist/src/utils/rescale.d.ts +21 -0
- package/dist/src/utils/rescale.js +119 -0
- package/dist/src/utils/rescale.js.map +1 -0
- package/dist/vitest.config.js +1 -1
- package/dist/vitest.config.js.map +1 -1
- package/package.json +14 -1
- package/.env.example +0 -11
- package/.github/workflows/ci.yml +0 -101
- package/.releaserc.json +0 -22
- package/CHANGELOG.md +0 -52
- package/CLAUDE.md +0 -104
- package/CONTRIBUTING.md +0 -1
- package/DEPLOYMENT.md +0 -59
- package/build-examples-script.js +0 -26
- package/commitlint.config.js +0 -37
- package/examples/3d-force-directed.html +0 -611
- package/examples/3d-kamada-kawai.html +0 -379
- package/examples/3d-layout-comparison.html +0 -448
- package/examples/3d-spherical-layout.html +0 -319
- package/examples/arf-layout.html +0 -524
- package/examples/bfs-layout.html +0 -487
- package/examples/bipartite-layout.html +0 -382
- package/examples/circular-layout.html +0 -292
- package/examples/forceatlas2-layout.html +0 -588
- package/examples/index.html +0 -241
- package/examples/kamada-kawai-layout.html +0 -425
- package/examples/layout-helpers.js +0 -23
- package/examples/layout.js +0 -2304
- package/examples/multipartite-layout.html +0 -410
- package/examples/planar-layout.html +0 -388
- package/examples/random-layout.html +0 -328
- package/examples/shell-layout.html +0 -323
- package/examples/spectral-layout.html +0 -335
- package/examples/spiral-layout.html +0 -447
- package/examples/spring-layout.html +0 -313
- package/test/arf-layout.test.ts +0 -443
- package/test/bfs-layout.test.ts +0 -427
- package/test/bipartite-layout.test.ts +0 -344
- package/test/circular-layout.test.ts +0 -442
- package/test/forceatlas2-layout.test.ts +0 -405
- package/test/fruchterman-reingold-layout.test.ts +0 -477
- package/test/graph-generators.test.ts +0 -450
- package/test/kamada-kawai-layout.test.ts +0 -623
- package/test/multipartite-layout.test.ts +0 -404
- package/test/planar-layout.test.ts +0 -266
- package/test/random-layout.test.ts +0 -254
- package/test/rescale-layout.test.ts +0 -373
- package/test/shell-layout.test.ts +0 -347
- package/test/spectral-layout.test.ts +0 -378
- package/test/spiral-layout.test.ts +0 -338
- package/test/spring-layout.test.ts +0 -241
- package/test/test-utils.ts +0 -34
- package/test/utils-graph.test.ts +0 -155
- package/test/utils-index.test.ts +0 -77
- package/test/utils-numpy.test.ts +0 -272
- package/test/utils-params.test.ts +0 -99
- package/test/utils-random.test.ts +0 -229
- package/tsconfig.json +0 -16
- package/vite.config.js +0 -36
- package/vitest.config.ts +0 -30
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Random number generator for seed-based randomization
|
|
3
|
+
* Maintains exact same functionality as original implementation
|
|
4
|
+
*/
|
|
5
|
+
export class RandomNumberGenerator {
|
|
6
|
+
constructor(seed) {
|
|
7
|
+
this.seed = seed || Math.floor(Math.random() * 1000000);
|
|
8
|
+
this.m = 2 ** 35 - 31;
|
|
9
|
+
this.a = 185852;
|
|
10
|
+
this.c = 1;
|
|
11
|
+
this._state = this.seed % this.m;
|
|
12
|
+
}
|
|
13
|
+
_next() {
|
|
14
|
+
this._state = (this.a * this._state + this.c) % this.m;
|
|
15
|
+
return this._state / this.m;
|
|
16
|
+
}
|
|
17
|
+
rand(shape = null) {
|
|
18
|
+
if (shape === null) {
|
|
19
|
+
return this._next();
|
|
20
|
+
}
|
|
21
|
+
if (typeof shape === 'number') {
|
|
22
|
+
const result = [];
|
|
23
|
+
for (let i = 0; i < shape; i++) {
|
|
24
|
+
result.push(this._next());
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
if (shape.length === 1) {
|
|
29
|
+
const result = [];
|
|
30
|
+
for (let i = 0; i < shape[0]; i++) {
|
|
31
|
+
result.push(this._next());
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
const result = [];
|
|
36
|
+
for (let i = 0; i < shape[0]; i++) {
|
|
37
|
+
result.push(this.rand(shape.slice(1)));
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/utils/random.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAOhC,YAAY,IAAa;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC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AAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout rescaling utilities
|
|
3
|
+
*/
|
|
4
|
+
import { PositionMap } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Returns scaled position array/dict to (-scale, scale) in all axes.
|
|
7
|
+
*
|
|
8
|
+
* @param pos - Position dictionary or array
|
|
9
|
+
* @param scale - Scale factor for positions
|
|
10
|
+
* @param center - Coordinate pair around which to center the layout
|
|
11
|
+
* @returns Rescaled positions dictionary
|
|
12
|
+
*/
|
|
13
|
+
export declare function rescaleLayout(pos: PositionMap | number[][], scale?: number, center?: number[]): PositionMap | number[][];
|
|
14
|
+
/**
|
|
15
|
+
* Return a dictionary of scaled positions centered at (0, 0).
|
|
16
|
+
*
|
|
17
|
+
* @param pos - Dictionary of positions
|
|
18
|
+
* @param scale - Scale factor for positions
|
|
19
|
+
* @returns Dictionary of scaled positions
|
|
20
|
+
*/
|
|
21
|
+
export declare function rescaleLayoutDict(pos: PositionMap, scale?: number): PositionMap;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout rescaling utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Returns scaled position array/dict to (-scale, scale) in all axes.
|
|
6
|
+
*
|
|
7
|
+
* @param pos - Position dictionary or array
|
|
8
|
+
* @param scale - Scale factor for positions
|
|
9
|
+
* @param center - Coordinate pair around which to center the layout
|
|
10
|
+
* @returns Rescaled positions dictionary
|
|
11
|
+
*/
|
|
12
|
+
export function rescaleLayout(pos, scale = 1, center = [0, 0]) {
|
|
13
|
+
// Check if pos is empty
|
|
14
|
+
if (Array.isArray(pos)) {
|
|
15
|
+
if (pos.length === 0)
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
if (Object.keys(pos).length === 0)
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
// Extract position values
|
|
23
|
+
const posValues = Array.isArray(pos) ? pos : Object.values(pos);
|
|
24
|
+
const dim = posValues[0].length;
|
|
25
|
+
// Calculate center of positions
|
|
26
|
+
const posCenter = Array(dim).fill(0);
|
|
27
|
+
for (const p of posValues) {
|
|
28
|
+
for (let i = 0; i < dim; i++) {
|
|
29
|
+
posCenter[i] += p[i] / posValues.length;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Center positions
|
|
33
|
+
let centeredPos = {};
|
|
34
|
+
if (Array.isArray(pos)) {
|
|
35
|
+
centeredPos = pos.map(p => p.map((val, i) => val - posCenter[i]));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
for (const [node, p] of Object.entries(pos)) {
|
|
39
|
+
centeredPos[node] = p.map((val, i) => val - posCenter[i]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Find maximum distance from center
|
|
43
|
+
let maxDistance = 0;
|
|
44
|
+
const centeredValues = Array.isArray(centeredPos) ? centeredPos : Object.values(centeredPos);
|
|
45
|
+
for (const p of centeredValues) {
|
|
46
|
+
const distance = Math.sqrt(p.reduce((sum, val) => sum + val * val, 0));
|
|
47
|
+
maxDistance = Math.max(maxDistance, distance);
|
|
48
|
+
}
|
|
49
|
+
// Rescale
|
|
50
|
+
let scaledPos = Array.isArray(pos) ? [] : {};
|
|
51
|
+
if (maxDistance > 0) {
|
|
52
|
+
const scaleFactor = scale / maxDistance;
|
|
53
|
+
if (Array.isArray(pos)) {
|
|
54
|
+
scaledPos = centeredPos.map(p => p.map((val, i) => val * scaleFactor + center[i]));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
for (const [node, p] of Object.entries(centeredPos)) {
|
|
58
|
+
scaledPos[node] = p.map((val, i) => val * scaleFactor + center[i]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// All nodes at the same position
|
|
64
|
+
if (Array.isArray(pos)) {
|
|
65
|
+
scaledPos = Array(pos.length).fill(0).map(() => [...center]);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
for (const node of Object.keys(pos)) {
|
|
69
|
+
scaledPos[node] = [...center];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return scaledPos;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Return a dictionary of scaled positions centered at (0, 0).
|
|
77
|
+
*
|
|
78
|
+
* @param pos - Dictionary of positions
|
|
79
|
+
* @param scale - Scale factor for positions
|
|
80
|
+
* @returns Dictionary of scaled positions
|
|
81
|
+
*/
|
|
82
|
+
export function rescaleLayoutDict(pos, scale = 1) {
|
|
83
|
+
if (Object.keys(pos).length === 0) {
|
|
84
|
+
return {};
|
|
85
|
+
}
|
|
86
|
+
// Extract positions as array
|
|
87
|
+
const posArray = Object.values(pos);
|
|
88
|
+
// Find center of positions
|
|
89
|
+
const center = [];
|
|
90
|
+
for (let d = 0; d < posArray[0].length; d++) {
|
|
91
|
+
center[d] = posArray.reduce((sum, p) => sum + p[d], 0) / posArray.length;
|
|
92
|
+
}
|
|
93
|
+
// Center positions
|
|
94
|
+
const centeredPos = {};
|
|
95
|
+
for (const [node, p] of Object.entries(pos)) {
|
|
96
|
+
centeredPos[node] = p.map((val, d) => val - center[d]);
|
|
97
|
+
}
|
|
98
|
+
// Find maximum distance from center
|
|
99
|
+
let maxDist = 0;
|
|
100
|
+
for (const p of Object.values(centeredPos)) {
|
|
101
|
+
const dist = Math.sqrt(p.reduce((sum, val) => sum + val * val, 0));
|
|
102
|
+
maxDist = Math.max(maxDist, dist);
|
|
103
|
+
}
|
|
104
|
+
// Scale positions
|
|
105
|
+
const scaledPos = {};
|
|
106
|
+
if (maxDist > 0) {
|
|
107
|
+
for (const [node, p] of Object.entries(centeredPos)) {
|
|
108
|
+
scaledPos[node] = p.map(val => val * scale / maxDist);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// All points at the center
|
|
113
|
+
for (const node of Object.keys(centeredPos)) {
|
|
114
|
+
scaledPos[node] = Array(centeredPos[node].length).fill(0);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return scaledPos;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=rescale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rescale.js","sourceRoot":"","sources":["../../../src/utils/rescale.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,GAA6B,EAC7B,QAAgB,CAAC,EACjB,SAAmB,CAAC,CAAC,EAAE,CAAC,CAAC;IAEzB,wBAAwB;IACxB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;IAC/C,CAAC;IAED,0BAA0B;IAC1B,MAAM,SAAS,GAAe,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAEhC,gCAAgC;IAChC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAA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AAE,OAAO;QACb,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE;YACR,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC1C,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,OAAO,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;YACtC,GAAG,EAAE,IAAI;YACT,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,EAAE;gBACb,QAAQ,EAAE,EAAE;gBACZ,UAAU,EAAE,EAAE;aACf;SACF;QACD,OAAO,EAAE,CAAC,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE;YACR,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC1C,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,OAAO,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;YACtC,GAAG,EAAE,IAAI;YACT,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,EAAE;gBACb,QAAQ,EAAE,EAAE;gBACZ,UAAU,EAAE,EAAE;aACf;SACF;QACD,OAAO,EAAE,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;QACnD,SAAS,EAAE,CAAC,SAAS,CAAC;KACvB;IACD,OAAO,EAAE;QACP,KAAK,EAAE;YACL,GAAG,EAAE,MAAM;SACZ;KACF;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphty/layout",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "graph layout algorithms based on networkx",
|
|
5
5
|
"author": "Adam Powers <apowers@ato.ms>",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/src/index.js",
|
|
11
|
+
"types": "./dist/src/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"types": "dist/src/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/",
|
|
17
|
+
"src/",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
8
21
|
"directories": {
|
|
9
22
|
"example": "examples"
|
|
10
23
|
},
|
package/.env.example
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Development Server Configuration
|
|
2
|
-
# Copy this file to .env and adjust values as needed
|
|
3
|
-
|
|
4
|
-
# Server host (defaults to true for network exposure)
|
|
5
|
-
# HOST=localhost
|
|
6
|
-
# HOST=0.0.0.0
|
|
7
|
-
# HOST=my.server.com
|
|
8
|
-
|
|
9
|
-
# Server port (defaults to 3000)
|
|
10
|
-
# PORT=3000
|
|
11
|
-
# PORT=8080
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main, develop ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ main ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
name: Test
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
strategy:
|
|
15
|
-
matrix:
|
|
16
|
-
node-version: [18.x, 20.x, 22.x]
|
|
17
|
-
|
|
18
|
-
steps:
|
|
19
|
-
- name: Checkout code
|
|
20
|
-
uses: actions/checkout@v4
|
|
21
|
-
|
|
22
|
-
- name: Setup Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
cache: 'npm'
|
|
27
|
-
|
|
28
|
-
- name: Install dependencies
|
|
29
|
-
run: npm ci
|
|
30
|
-
|
|
31
|
-
- name: Run TypeScript compiler
|
|
32
|
-
run: npm run build
|
|
33
|
-
|
|
34
|
-
- name: Run tests
|
|
35
|
-
run: npm run test:run
|
|
36
|
-
|
|
37
|
-
- name: Run tests with coverage
|
|
38
|
-
run: npm run test:coverage
|
|
39
|
-
if: matrix.node-version == '20.x'
|
|
40
|
-
|
|
41
|
-
- name: Upload coverage reports to Coveralls
|
|
42
|
-
uses: coverallsapp/github-action@v2
|
|
43
|
-
if: matrix.node-version == '20.x'
|
|
44
|
-
with:
|
|
45
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
-
file: ./coverage/lcov.info
|
|
47
|
-
|
|
48
|
-
lint:
|
|
49
|
-
name: Lint
|
|
50
|
-
runs-on: ubuntu-latest
|
|
51
|
-
|
|
52
|
-
steps:
|
|
53
|
-
- name: Checkout code
|
|
54
|
-
uses: actions/checkout@v4
|
|
55
|
-
|
|
56
|
-
- name: Setup Node.js
|
|
57
|
-
uses: actions/setup-node@v4
|
|
58
|
-
with:
|
|
59
|
-
node-version: '20.x'
|
|
60
|
-
cache: 'npm'
|
|
61
|
-
|
|
62
|
-
- name: Install dependencies
|
|
63
|
-
run: npm ci
|
|
64
|
-
|
|
65
|
-
- name: Check TypeScript types
|
|
66
|
-
run: npx tsc --noEmit
|
|
67
|
-
|
|
68
|
-
- name: Run commitlint on PR title
|
|
69
|
-
if: github.event_name == 'pull_request'
|
|
70
|
-
run: echo "${{ github.event.pull_request.title }}" | npx commitlint
|
|
71
|
-
|
|
72
|
-
release:
|
|
73
|
-
name: Release
|
|
74
|
-
runs-on: ubuntu-latest
|
|
75
|
-
needs: [test, lint]
|
|
76
|
-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
77
|
-
|
|
78
|
-
steps:
|
|
79
|
-
- name: Checkout code
|
|
80
|
-
uses: actions/checkout@v4
|
|
81
|
-
with:
|
|
82
|
-
fetch-depth: 0
|
|
83
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
|
84
|
-
|
|
85
|
-
- name: Setup Node.js
|
|
86
|
-
uses: actions/setup-node@v4
|
|
87
|
-
with:
|
|
88
|
-
node-version: '20.x'
|
|
89
|
-
cache: 'npm'
|
|
90
|
-
|
|
91
|
-
- name: Install dependencies
|
|
92
|
-
run: npm ci
|
|
93
|
-
|
|
94
|
-
- name: Build package
|
|
95
|
-
run: npm run build
|
|
96
|
-
|
|
97
|
-
- name: Release
|
|
98
|
-
env:
|
|
99
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
100
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
101
|
-
run: npx semantic-release
|
package/.releaserc.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": ["main"],
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@semantic-release/commit-analyzer",
|
|
5
|
-
"@semantic-release/release-notes-generator",
|
|
6
|
-
"@semantic-release/changelog",
|
|
7
|
-
[
|
|
8
|
-
"@semantic-release/npm",
|
|
9
|
-
{
|
|
10
|
-
"npmPublish": true
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
[
|
|
14
|
-
"@semantic-release/git",
|
|
15
|
-
{
|
|
16
|
-
"assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
|
|
17
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"@semantic-release/github"
|
|
21
|
-
]
|
|
22
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
## [1.2.3](https://github.com/graphty-org/layout/compare/v1.2.2...v1.2.3) (2025-07-17)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* github pages ([da26028](https://github.com/graphty-org/layout/commit/da26028da1f7638322f2a6e199f0bbdf70baec91))
|
|
7
|
-
|
|
8
|
-
## [1.2.2](https://github.com/graphty-org/layout/compare/v1.2.1...v1.2.2) (2025-07-13)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* numpy linspace error. improve test coverage ([2e820f1](https://github.com/graphty-org/layout/commit/2e820f181bd7242ef251c1833b10533699485209))
|
|
14
|
-
|
|
15
|
-
## [1.2.1](https://github.com/graphty-org/layout/compare/v1.2.0...v1.2.1) (2025-07-13)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* resolve import errors and browser hang in shell layout example ([d65e436](https://github.com/graphty-org/layout/commit/d65e4360d9c42c885731ec952ea52978da61c7d5))
|
|
21
|
-
|
|
22
|
-
# [1.2.0](https://github.com/graphty-org/layout/compare/v1.1.1...v1.2.0) (2025-07-12)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* add 3D examples and enhance development setup ([dbcb911](https://github.com/graphty-org/layout/commit/dbcb9117f77243c0c105c3bcf29252f0cf5d5484))
|
|
28
|
-
|
|
29
|
-
## [1.1.1](https://github.com/graphty-org/layout/compare/v1.1.0...v1.1.1) (2025-07-12)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* correct main entry point to dist/layout.js ([4e9f95b](https://github.com/graphty-org/layout/commit/4e9f95bfae3d2974808fa4a306b677e95d9706b9))
|
|
35
|
-
|
|
36
|
-
# 1.0.0 (2025-07-12)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Bug Fixes
|
|
40
|
-
|
|
41
|
-
* flakey test ([8de0d14](https://github.com/graphty-org/layout/commit/8de0d147f7267b5715c4529db64014578ee06c97))
|
|
42
|
-
* improve performance test reliability for CI ([0a41ee2](https://github.com/graphty-org/layout/commit/0a41ee238bdbaa1f4d68d864998b24bd4c59ff3d))
|
|
43
|
-
* increase test timeout for CI environments ([36b20a8](https://github.com/graphty-org/layout/commit/36b20a8ea0811cdac7d97975ab0490f2cf29b6ae))
|
|
44
|
-
* make ForceAtlas2 balanced layout test more tolerant ([78fb975](https://github.com/graphty-org/layout/commit/78fb975053dd25d26e351626170fe73d2b68b677))
|
|
45
|
-
* remove conflicting .releaserc file ([1fffa82](https://github.com/graphty-org/layout/commit/1fffa821219774efab8203fc2ea7943493ad1825))
|
|
46
|
-
* resolve CI pipeline and test coverage issues ([9c60656](https://github.com/graphty-org/layout/commit/9c606562074bafc234499f4f2637a55730195af3))
|
|
47
|
-
* update tests to import from TypeScript source instead of dist ([d000b23](https://github.com/graphty-org/layout/commit/d000b23c301fe84807958e54f29ba4ca682818fd))
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### Features
|
|
51
|
-
|
|
52
|
-
* add layout helpers ([d43562c](https://github.com/graphty-org/layout/commit/d43562c02a68720f96905ad4c969e12c0a0e5db4))
|
package/CLAUDE.md
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
@graphty/layout is a TypeScript graph layout library that ports NetworkX Python algorithms to JavaScript. All layout algorithms are implemented in a single file: `layout.ts`.
|
|
8
|
-
|
|
9
|
-
## Key Commands
|
|
10
|
-
|
|
11
|
-
### Development
|
|
12
|
-
```bash
|
|
13
|
-
# Build TypeScript to JavaScript
|
|
14
|
-
npm run build
|
|
15
|
-
|
|
16
|
-
# Watch mode for development
|
|
17
|
-
npm run watch
|
|
18
|
-
# or
|
|
19
|
-
npm run dev
|
|
20
|
-
|
|
21
|
-
# Currently no test framework is configured
|
|
22
|
-
# npm test exits with error code 1
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Git Commits
|
|
26
|
-
This project uses conventional commits with commitizen:
|
|
27
|
-
```bash
|
|
28
|
-
# Use commitizen for formatted commits
|
|
29
|
-
npm run commit
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Commit types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test
|
|
33
|
-
|
|
34
|
-
## Architecture
|
|
35
|
-
|
|
36
|
-
The entire library is contained in `layout.ts` with the following structure:
|
|
37
|
-
|
|
38
|
-
1. **Type System** (lines 1-50):
|
|
39
|
-
- `Node`: string | number
|
|
40
|
-
- `Edge`: [Node, Node]
|
|
41
|
-
- `Graph`: Interface with adjacency(), nodes(), edges() methods
|
|
42
|
-
- `PositionMap`: Map<Node, Position> for storing layouts
|
|
43
|
-
|
|
44
|
-
2. **NumPy-like Utilities** (lines 50-500):
|
|
45
|
-
- Array manipulation functions under `np` object
|
|
46
|
-
- Used for mathematical operations in layout algorithms
|
|
47
|
-
|
|
48
|
-
3. **Layout Algorithms** (lines 500-2591):
|
|
49
|
-
- Force-directed: springLayout, forceatlas2Layout, arfLayout, kamadaKawaiLayout
|
|
50
|
-
- Geometric: randomLayout, circularLayout, shellLayout, spiralLayout
|
|
51
|
-
- Specialized: spectralLayout, bipartiteLayout, multipartiteLayout, bfsLayout, planarLayout
|
|
52
|
-
- Utilities: rescaleLayout, rescaleLayoutDict
|
|
53
|
-
|
|
54
|
-
Each algorithm returns a `PositionMap` with node positions.
|
|
55
|
-
|
|
56
|
-
## Module System
|
|
57
|
-
|
|
58
|
-
This is an ES module project (`"type": "module"` in package.json). When importing:
|
|
59
|
-
```typescript
|
|
60
|
-
import { springLayout, circularLayout } from '@graphty/layout';
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Common Tasks
|
|
64
|
-
|
|
65
|
-
### Adding a New Layout Algorithm
|
|
66
|
-
1. Add the function to `layout.ts` following the existing pattern
|
|
67
|
-
2. Export it at the bottom of the file
|
|
68
|
-
3. Update README.md with documentation and example
|
|
69
|
-
4. Add an example HTML file in `examples/`
|
|
70
|
-
|
|
71
|
-
### Modifying Build Output
|
|
72
|
-
Edit `tsconfig.json`. Current settings:
|
|
73
|
-
- Target: ES2020
|
|
74
|
-
- Module: ES2020
|
|
75
|
-
- Output: `dist/` directory
|
|
76
|
-
- Generates declaration files and source maps
|
|
77
|
-
|
|
78
|
-
## Testing
|
|
79
|
-
|
|
80
|
-
### Running Tests
|
|
81
|
-
```bash
|
|
82
|
-
npm test # Run tests in watch mode
|
|
83
|
-
npm run test:run # Run tests once
|
|
84
|
-
npm run test:coverage # Run with coverage report
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Testing Preferences
|
|
88
|
-
- Use `assert` instead of `expect` for test assertions
|
|
89
|
-
- Tests are organized by layout algorithm in `test/` directory
|
|
90
|
-
- Each test file covers: basic functionality, parameter variations, edge cases, and algorithm-specific behaviors
|
|
91
|
-
- Graph generation utilities are available for creating test graphs
|
|
92
|
-
|
|
93
|
-
## Important Notes
|
|
94
|
-
|
|
95
|
-
- All algorithms should match NetworkX Python library behavior where possible
|
|
96
|
-
- Graph interface is minimal - algorithms work with any object providing nodes() and edges() methods
|
|
97
|
-
- Examples in `examples/` directory demonstrate usage patterns
|
|
98
|
-
- Tests serve as additional documentation for expected behavior
|
|
99
|
-
|
|
100
|
-
## Claude Preferences
|
|
101
|
-
|
|
102
|
-
- NEVER automatically stage files with git add or create commits
|
|
103
|
-
- NEVER create commits unless explicitly requested by the user
|
|
104
|
-
- User prefers to handle git operations manually
|
package/CONTRIBUTING.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Graphty Layout Algorithms
|
package/DEPLOYMENT.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Deployment Guide
|
|
2
|
-
|
|
3
|
-
## GitHub Pages Setup
|
|
4
|
-
|
|
5
|
-
This project uses a dual-build system to support both local development and GitHub Pages deployment.
|
|
6
|
-
|
|
7
|
-
### For GitHub Pages Deployment:
|
|
8
|
-
|
|
9
|
-
1. **Build the examples**:
|
|
10
|
-
```bash
|
|
11
|
-
npm run build:examples
|
|
12
|
-
```
|
|
13
|
-
This compiles TypeScript and copies `layout.js` to the `examples/` folder.
|
|
14
|
-
|
|
15
|
-
2. **Commit the built files**:
|
|
16
|
-
```bash
|
|
17
|
-
git add examples/layout.js
|
|
18
|
-
git commit -m "Update examples with latest layout.js"
|
|
19
|
-
git push
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
3. **GitHub Pages will serve** the examples directly from the `examples/` folder.
|
|
23
|
-
|
|
24
|
-
### Local Development:
|
|
25
|
-
|
|
26
|
-
- **For development**: `npm run serve` or `npm run examples`
|
|
27
|
-
- **For testing**: Use any of the individual npm scripts
|
|
28
|
-
- **File watching**: `npm run dev` or `npm run watch`
|
|
29
|
-
|
|
30
|
-
### File Structure:
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
layout/
|
|
34
|
-
├── layout.ts # Source TypeScript
|
|
35
|
-
├── dist/
|
|
36
|
-
│ └── layout.js # Compiled for npm package
|
|
37
|
-
├── examples/
|
|
38
|
-
│ ├── layout.js # Copy for GitHub Pages
|
|
39
|
-
│ ├── index.html # Example index
|
|
40
|
-
│ ├── 3d-force-directed.html
|
|
41
|
-
│ └── ...other examples
|
|
42
|
-
└── package.json
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Notes:
|
|
46
|
-
|
|
47
|
-
- `examples/layout.js` is auto-generated and should not be edited directly
|
|
48
|
-
- The file is ignored in `.gitignore` for local development
|
|
49
|
-
- For GitHub Pages, you must commit this file manually before deployment
|
|
50
|
-
- All examples use `import ... from './layout.js'` for maximum compatibility
|
|
51
|
-
|
|
52
|
-
### GitHub Actions (Optional):
|
|
53
|
-
|
|
54
|
-
For automated deployment, you could add a GitHub Action that:
|
|
55
|
-
1. Runs `npm run build:examples`
|
|
56
|
-
2. Commits the updated `examples/layout.js`
|
|
57
|
-
3. Deploys to GitHub Pages
|
|
58
|
-
|
|
59
|
-
This ensures the examples are always in sync with the latest TypeScript source.
|
package/build-examples-script.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
|
|
8
|
-
// Read the compiled JavaScript from dist
|
|
9
|
-
const distLayoutPath = path.join(__dirname, 'dist', 'layout.js');
|
|
10
|
-
const examplesLayoutPath = path.join(__dirname, 'examples', 'layout.js');
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
// Check if dist file exists
|
|
14
|
-
if (!fs.existsSync(distLayoutPath)) {
|
|
15
|
-
console.error('Error: dist/layout.js not found. Please run "npm run build" first.');
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Copy the bundled layout.js to examples directory
|
|
20
|
-
fs.copyFileSync(distLayoutPath, examplesLayoutPath);
|
|
21
|
-
console.log('Successfully copied dist/layout.js to examples/layout.js');
|
|
22
|
-
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error('Error building examples:', error);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
package/commitlint.config.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parserPreset: "conventional-changelog-conventionalcommits",
|
|
3
|
-
rules: {
|
|
4
|
-
"body-leading-blank": [1, "always"],
|
|
5
|
-
"body-max-line-length": [2, "always", 100],
|
|
6
|
-
"footer-leading-blank": [1, "always"],
|
|
7
|
-
"footer-max-line-length": [2, "always", 100],
|
|
8
|
-
"header-max-length": [2, "always", 100],
|
|
9
|
-
"scope-case": [2, "always", "lower-case"],
|
|
10
|
-
"subject-case": [
|
|
11
|
-
2,
|
|
12
|
-
"never",
|
|
13
|
-
["sentence-case", "start-case", "pascal-case", "upper-case"],
|
|
14
|
-
],
|
|
15
|
-
"subject-empty": [2, "never"],
|
|
16
|
-
"subject-full-stop": [2, "never", "."],
|
|
17
|
-
"type-case": [2, "always", "lower-case"],
|
|
18
|
-
"type-empty": [2, "never"],
|
|
19
|
-
"type-enum": [
|
|
20
|
-
2,
|
|
21
|
-
"always",
|
|
22
|
-
[
|
|
23
|
-
"build",
|
|
24
|
-
"chore",
|
|
25
|
-
"ci",
|
|
26
|
-
"docs",
|
|
27
|
-
"feat",
|
|
28
|
-
"fix",
|
|
29
|
-
"perf",
|
|
30
|
-
"refactor",
|
|
31
|
-
"revert",
|
|
32
|
-
"style",
|
|
33
|
-
"test",
|
|
34
|
-
],
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
};
|