@graphty/layout 1.5.0 → 1.5.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.
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAEA,wBA2BG"}
@@ -0,0 +1,30 @@
1
+ import { defineConfig } from "vitest/config";
2
+ export default defineConfig({
3
+ test: {
4
+ globals: true,
5
+ environment: "happy-dom",
6
+ pool: "forks",
7
+ testTimeout: 30000,
8
+ coverage: {
9
+ provider: "v8",
10
+ reporter: ["text", "json", "html", "lcov"],
11
+ include: ["src/**/*.ts"],
12
+ exclude: ["**/*.d.ts", "**/*.test.ts"],
13
+ all: true,
14
+ thresholds: {
15
+ lines: 65,
16
+ functions: 60,
17
+ branches: 85,
18
+ statements: 65,
19
+ },
20
+ },
21
+ include: ["test/**/*.test.ts", "test/**/*.test.js"],
22
+ reporters: ["verbose"],
23
+ },
24
+ resolve: {
25
+ alias: {
26
+ "@": "/src",
27
+ },
28
+ },
29
+ });
30
+ //# sourceMappingURL=vitest.config.js.map
@@ -0,0 +1 @@
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;IACxB,IAAI,EAAE;QACF,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE;YACN,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;gBACR,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,EAAE;gBACb,QAAQ,EAAE,EAAE;gBACZ,UAAU,EAAE,EAAE;aACjB;SACJ;QACD,OAAO,EAAE,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;QACnD,SAAS,EAAE,CAAC,SAAS,CAAC;KACzB;IACD,OAAO,EAAE;QACL,KAAK,EAAE;YACH,GAAG,EAAE,MAAM;SACd;KACJ;CACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphty/layout",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "graph layout algorithms based on networkx",
5
5
  "author": "Adam Powers <apowers@ato.ms>",
6
6
  "main": "dist/layout.js",
@@ -46,7 +46,29 @@
46
46
  "path": "./node_modules/cz-conventional-changelog"
47
47
  }
48
48
  },
49
- "devDependencies": {},
49
+ "devDependencies": {
50
+ "@chromatic-com/storybook": "^4.0.0",
51
+ "@semantic-release/changelog": "^6.0.3",
52
+ "@semantic-release/git": "^10.0.1",
53
+ "@storybook/addon-docs": "^9.0.11",
54
+ "@storybook/html-vite": "^9.0.11",
55
+ "@storybook/test": "^8.6.14",
56
+ "@types/three": "^0.182.0",
57
+ "@vitest/coverage-v8": "^3.2.4",
58
+ "@vitest/ui": "^3.2.4",
59
+ "chromatic": "^11.0.0",
60
+ "happy-dom": "^18.0.1",
61
+ "semantic-release": "^24.2.7",
62
+ "storybook": "^9.0.11",
63
+ "three": "^0.182.0",
64
+ "typedoc": "^0.28.15",
65
+ "typedoc-plugin-markdown": "^4.9.0",
66
+ "typedoc-vitepress-theme": "^1.1.2",
67
+ "typescript": "^5.3.3",
68
+ "vite": "^7.0.5",
69
+ "vitepress": "^1.6.3",
70
+ "vitest": "^3.2.4"
71
+ },
50
72
  "scripts": {
51
73
  "test": "vitest",
52
74
  "test:ui": "vitest --ui",
@@ -71,6 +93,8 @@
71
93
  "docs:dev": "vitepress dev docs",
72
94
  "docs:watch": "npm run docs:api && (npm run docs:api:watch & npm run docs:dev & wait)",
73
95
  "docs:build": "npm run docs:api && vitepress build docs",
74
- "docs:preview": "vitepress preview docs"
96
+ "docs:preview": "vitepress preview docs",
97
+ "storybook": ". ../.env 2>/dev/null; storybook dev -p ${PORT:-6006} --host ${HOST:-localhost} ${HTTPS_CERT_PATH:+--https --ssl-cert $HTTPS_CERT_PATH --ssl-key $HTTPS_KEY_PATH} --no-open",
98
+ "build-storybook": "storybook build"
75
99
  }
76
100
  }
@@ -5,6 +5,7 @@
5
5
  import type { Graph, Node, PositionMap } from "../../types";
6
6
  import { getEdgesFromGraph,getNodesFromGraph } from "../../utils/graph";
7
7
  import { _processParams } from "../../utils/params";
8
+ import { RandomNumberGenerator } from "../../utils/random";
8
9
  import { rescaleLayout } from "../../utils/rescale";
9
10
 
10
11
  /**
@@ -13,6 +14,7 @@ import { rescaleLayout } from "../../utils/rescale";
13
14
  * @param scale - Scale factor for positions
14
15
  * @param center - Coordinate pair around which to center the layout
15
16
  * @param dim - Dimension of layout
17
+ * @param seed - Random seed for reproducible layouts
16
18
  * @returns Positions dictionary keyed by node
17
19
  */
18
20
  export function spectralLayout(
@@ -20,6 +22,7 @@ export function spectralLayout(
20
22
  scale: number = 1,
21
23
  center: number[] | null = null,
22
24
  dim: number = 2,
25
+ seed: number | null = null,
23
26
  ): PositionMap {
24
27
  const processed = _processParams(G, center, dim);
25
28
  const graph = processed.G;
@@ -74,12 +77,13 @@ export function spectralLayout(
74
77
  // Compute eigenvectors using power iteration method
75
78
  // We need the smallest non-zero eigenvectors of L
76
79
  const eigenvectors: number[][] = [];
80
+ const rng = new RandomNumberGenerator(seed ?? undefined);
77
81
 
78
82
  // For each dimension, find an eigenvector
79
83
  for (let d = 0; d < dim; d++) {
80
84
  let vector = Array(N)
81
85
  .fill(0)
82
- .map(() => Math.random() - 0.5);
86
+ .map(() => (rng.rand(null) as number) - 0.5);
83
87
 
84
88
  // Orthogonalize against previous eigenvectors
85
89
  for (const ev of eigenvectors) {