@graphty/layout 1.1.1 → 1.2.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.
Files changed (100) hide show
  1. package/.env.example +11 -0
  2. package/.github/workflows/ci.yml +3 -7
  3. package/CHANGELOG.md +14 -0
  4. package/DEPLOYMENT.md +59 -0
  5. package/README.md +54 -1
  6. package/dist/vitest.config.js +2 -2
  7. package/dist/vitest.config.js.map +1 -1
  8. package/examples/3d-force-directed.html +611 -0
  9. package/examples/3d-kamada-kawai.html +379 -0
  10. package/examples/3d-layout-comparison.html +448 -0
  11. package/examples/3d-spherical-layout.html +319 -0
  12. package/examples/arf-layout.html +13 -1
  13. package/examples/bfs-layout.html +38 -32
  14. package/examples/bipartite-layout.html +16 -4
  15. package/examples/circular-layout.html +14 -2
  16. package/examples/forceatlas2-layout.html +118 -151
  17. package/examples/index.html +75 -0
  18. package/examples/kamada-kawai-layout.html +13 -1
  19. package/{dist → examples}/layout-helpers.js +58 -29
  20. package/examples/multipartite-layout.html +44 -54
  21. package/examples/planar-layout.html +13 -1
  22. package/examples/random-layout.html +13 -1
  23. package/examples/shell-layout.html +16 -2
  24. package/examples/spectral-layout.html +13 -1
  25. package/examples/spiral-layout.html +13 -1
  26. package/examples/spring-layout.html +15 -13
  27. package/package.json +6 -3
  28. package/src/algorithms/index.ts +6 -0
  29. package/src/algorithms/optimization/index.ts +12 -0
  30. package/src/algorithms/optimization/kamada-kawai-solver.ts +231 -0
  31. package/src/algorithms/optimization/lbfgs.ts +68 -0
  32. package/src/algorithms/optimization/line-search.ts +50 -0
  33. package/src/algorithms/optimization/types.ts +8 -0
  34. package/src/algorithms/planarity/check.ts +38 -0
  35. package/src/algorithms/planarity/embedding.ts +216 -0
  36. package/src/algorithms/planarity/index.ts +12 -0
  37. package/src/algorithms/planarity/lr-test.ts +70 -0
  38. package/src/algorithms/planarity/special-graphs.ts +126 -0
  39. package/src/generators/basic.ts +93 -0
  40. package/src/generators/bipartite.ts +45 -0
  41. package/src/generators/grid.ts +42 -0
  42. package/src/generators/index.ts +15 -0
  43. package/src/generators/random.ts +39 -0
  44. package/src/generators/scale-free.ts +72 -0
  45. package/src/index.ts +18 -0
  46. package/src/layouts/basic/index.ts +5 -0
  47. package/src/layouts/basic/random.ts +32 -0
  48. package/src/layouts/force-directed/arf.ts +130 -0
  49. package/src/layouts/force-directed/forceatlas2.ts +407 -0
  50. package/src/layouts/force-directed/fruchterman-reingold.ts +164 -0
  51. package/src/layouts/force-directed/index.ts +9 -0
  52. package/src/layouts/force-directed/kamada-kawai.ts +112 -0
  53. package/src/layouts/force-directed/spring.ts +35 -0
  54. package/src/layouts/geometric/circular.ts +77 -0
  55. package/src/layouts/geometric/index.ts +7 -0
  56. package/src/layouts/geometric/shell.ts +80 -0
  57. package/src/layouts/geometric/spiral.ts +93 -0
  58. package/src/layouts/hierarchical/bfs.ts +81 -0
  59. package/src/layouts/hierarchical/bipartite.ts +94 -0
  60. package/src/layouts/hierarchical/index.ts +7 -0
  61. package/src/layouts/hierarchical/multipartite.ts +88 -0
  62. package/src/layouts/index.ts +9 -0
  63. package/src/layouts/specialized/index.ts +6 -0
  64. package/src/layouts/specialized/planar.ts +65 -0
  65. package/src/layouts/specialized/spectral.ts +128 -0
  66. package/src/types/embedding.ts +11 -0
  67. package/src/types/graph.ts +13 -0
  68. package/src/types/index.ts +7 -0
  69. package/src/types/layout.ts +9 -0
  70. package/src/utils/graph.ts +77 -0
  71. package/src/utils/index.ts +9 -0
  72. package/src/utils/numpy.ts +108 -0
  73. package/src/utils/params.ts +26 -0
  74. package/src/utils/random.ts +53 -0
  75. package/src/utils/rescale.ts +137 -0
  76. package/test/arf-layout.test.ts +1 -1
  77. package/test/bfs-layout.test.ts +1 -1
  78. package/test/bipartite-layout.test.ts +1 -1
  79. package/test/circular-layout.test.ts +145 -3
  80. package/test/forceatlas2-layout.test.ts +1 -1
  81. package/test/fruchterman-reingold-layout.test.ts +1 -1
  82. package/test/graph-generators.test.ts +1 -1
  83. package/test/kamada-kawai-layout.test.ts +273 -1
  84. package/test/multipartite-layout.test.ts +1 -1
  85. package/test/planar-layout.test.ts +1 -1
  86. package/test/random-layout.test.ts +1 -1
  87. package/test/rescale-layout.test.ts +1 -1
  88. package/test/shell-layout.test.ts +1 -1
  89. package/test/spectral-layout.test.ts +1 -1
  90. package/test/spiral-layout.test.ts +1 -1
  91. package/test/spring-layout.test.ts +1 -1
  92. package/vite.config.js +36 -0
  93. package/vitest.config.ts +2 -2
  94. package/dist/layout-helpers.d.ts +0 -123
  95. package/dist/layout-helpers.js.map +0 -1
  96. package/dist/layout.d.ts +0 -275
  97. package/dist/layout.js +0 -2280
  98. package/dist/layout.js.map +0 -1
  99. package/layout-helpers.ts +0 -559
  100. package/layout.ts +0 -2867
package/.env.example ADDED
@@ -0,0 +1,11 @@
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
@@ -38,16 +38,12 @@ jobs:
38
38
  run: npm run test:coverage
39
39
  if: matrix.node-version == '20.x'
40
40
 
41
- - name: Upload coverage reports to Codecov
42
- uses: codecov/codecov-action@v4
41
+ - name: Upload coverage reports to Coveralls
42
+ uses: coverallsapp/github-action@v2
43
43
  if: matrix.node-version == '20.x'
44
44
  with:
45
+ github-token: ${{ secrets.GITHUB_TOKEN }}
45
46
  file: ./coverage/lcov.info
46
- flags: unittests
47
- name: codecov-umbrella
48
- fail_ci_if_error: false
49
- env:
50
- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
51
47
 
52
48
  lint:
53
49
  name: Lint
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.2.1](https://github.com/graphty-org/layout/compare/v1.2.0...v1.2.1) (2025-07-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * resolve import errors and browser hang in shell layout example ([d65e436](https://github.com/graphty-org/layout/commit/d65e4360d9c42c885731ec952ea52978da61c7d5))
7
+
8
+ # [1.2.0](https://github.com/graphty-org/layout/compare/v1.1.1...v1.2.0) (2025-07-12)
9
+
10
+
11
+ ### Features
12
+
13
+ * add 3D examples and enhance development setup ([dbcb911](https://github.com/graphty-org/layout/commit/dbcb9117f77243c0c105c3bcf29252f0cf5d5484))
14
+
1
15
  ## [1.1.1](https://github.com/graphty-org/layout/compare/v1.1.0...v1.1.1) (2025-07-12)
2
16
 
3
17
 
package/DEPLOYMENT.md ADDED
@@ -0,0 +1,59 @@
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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Layout
2
2
 
3
3
  [![CI](https://github.com/graphty-org/layout/actions/workflows/ci.yml/badge.svg)](https://github.com/graphty-org/layout/actions/workflows/ci.yml)
4
- [![codecov](https://codecov.io/gh/graphty-org/layout/branch/main/graph/badge.svg)](https://codecov.io/gh/graphty-org/layout)
4
+ [![Coverage Status](https://coveralls.io/repos/github/graphty-org/layout/badge.svg?branch=main)](https://coveralls.io/github/graphty-org/layout?branch=main)
5
5
  [![npm version](https://badge.fury.io/js/%40graphty%2Flayout.svg)](https://badge.fury.io/js/%40graphty%2Flayout)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
@@ -857,6 +857,59 @@ If you want to build the TypeScript module from source:
857
857
 
858
858
  This will watch for changes and automatically recompile the TypeScript files.
859
859
 
860
+ ## Development Server
861
+
862
+ The project includes a Vite development server for testing and viewing examples.
863
+
864
+ ### Starting the Development Server
865
+
866
+ ```bash
867
+ npm run serve
868
+ ```
869
+
870
+ This will:
871
+ - Start a development server on port 3000
872
+ - Automatically open your browser to `/examples/`
873
+ - Provide hot module reloading for development
874
+
875
+ ### Configuring the Development Server
876
+
877
+ You can customize the server configuration using environment variables:
878
+
879
+ 1. **Create a `.env` file** (copy from `.env.example`):
880
+ ```bash
881
+ cp .env.example .env
882
+ ```
883
+
884
+ 2. **Configure server options in `.env`:**
885
+ ```bash
886
+ # Server host (defaults to true for network exposure)
887
+ HOST=localhost # For local-only access
888
+ HOST=0.0.0.0 # For network access
889
+ HOST=my.server.com # For custom domain
890
+
891
+ # Server port (defaults to 3000)
892
+ PORT=3000
893
+ PORT=8080 # Custom port
894
+ ```
895
+
896
+ 3. **Start the server with your configuration:**
897
+ ```bash
898
+ npm run serve
899
+ ```
900
+
901
+ ### Alternative: Build and Serve
902
+
903
+ To build the project and then serve the examples:
904
+
905
+ ```bash
906
+ npm run examples
907
+ ```
908
+
909
+ This command:
910
+ 1. Builds the TypeScript files to JavaScript
911
+ 2. Starts the Vite development server
912
+
860
913
  **Note:** The compiled JavaScript files will be available in the `dist/` directory. You can import from the compiled JavaScript files or directly use the TypeScript source files in a TypeScript project.
861
914
 
862
915
  ## Implementation
@@ -7,8 +7,8 @@ export default defineConfig({
7
7
  testTimeout: 30000,
8
8
  coverage: {
9
9
  provider: 'v8',
10
- reporter: ['text', 'json', 'html'],
11
- include: ['layout.ts'],
10
+ reporter: ['text', 'json', 'html', 'lcov'],
11
+ include: ['src/**/*.ts'],
12
12
  exclude: ['**/*.d.ts', '**/*.test.ts'],
13
13
  all: true,
14
14
  thresholds: {
@@ -1 +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;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,CAAC;YAClC,OAAO,EAAE,CAAC,WAAW,CAAC;YACtB,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,EAA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