@adecore/diagram 0.17.0-beta.1 → 0.17.0-beta.2
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/LICENSE +1 -1
- package/README.md +39 -24
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
# @adecore/diagram
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@adecore/diagram)
|
|
4
|
+
[](https://adecore.dev/diagram/)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Directed graphs that are written rather than drawn. A diagram file names its nodes, groups and edges; the package lays them out, routes the edges and writes the result as SVG or as lines of text. The same file gives the same picture on every machine, and it needs no DOM.
|
|
7
|
+
|
|
8
|
+
**[Documentation with live demos](https://adecore.dev/diagram/)**
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
bun add @adecore/diagram
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Use
|
|
6
17
|
|
|
7
18
|
```ts
|
|
8
19
|
import { layoutOf, readingOrder, toSvg } from '@adecore/diagram';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
nodes: [
|
|
16
|
-
{ id: 'draft', label: 'Draft' },
|
|
17
|
-
{ id: 'review', label: 'Review', shape: 'diamond' }
|
|
18
|
-
],
|
|
19
|
-
groups: [],
|
|
20
|
-
edges: [{ from: 'draft', to: 'review' }]
|
|
21
|
-
});
|
|
22
|
-
const problem = diagramProblemIn(document);
|
|
23
|
-
if (problem !== null) {
|
|
24
|
-
throw new Error(problem);
|
|
20
|
+
import { diagramProblemIn, migrateDiagram } from '@adecore/diagram/protocol';
|
|
21
|
+
|
|
22
|
+
const diagram = migrateDiagram(JSON.parse(file));
|
|
23
|
+
const problem = diagram && diagramProblemIn(diagram);
|
|
24
|
+
if (diagram === null || problem) {
|
|
25
|
+
throw new Error(problem ?? 'Not a diagram');
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
|
|
28
|
+
const layout = layoutOf(diagram);
|
|
29
|
+
const svg = toSvg(diagram, { layout });
|
|
30
|
+
const lines = readingOrder(diagram);
|
|
29
31
|
```
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
## Entry points
|
|
34
|
+
|
|
35
|
+
| Import | What it holds |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `@adecore/diagram` | Layout, SVG export, the shape and text helpers and reading order |
|
|
38
|
+
| `@adecore/diagram/protocol` | The Zod schemas and types of a diagram, and `diagramProblemIn` |
|
|
39
|
+
|
|
40
|
+
## Documentation
|
|
41
|
+
|
|
42
|
+
| Page | What it covers |
|
|
43
|
+
|---|---|
|
|
44
|
+
| [Documents](https://adecore.dev/diagram/documents) | Nodes, groups and edges, and checking a file |
|
|
45
|
+
| [Layout](https://adecore.dev/diagram/layout) | Layers, ordering, sizes, groups, edge routes and dragged nodes |
|
|
46
|
+
| [Painting and reading](https://adecore.dev/diagram/rendering) | `toSvg`, helpers for a painter of your own and `readingOrder` |
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
## License
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
FSL-1.1-MIT, see [LICENSE](./LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/diagram",
|
|
3
|
-
"version": "0.17.0-beta.
|
|
3
|
+
"version": "0.17.0-beta.2",
|
|
4
4
|
"description": "Directed graph schemas, layered layout, SVG export and reading order.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"author": "Bas Milius",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"zod": "^4.6.5",
|
|
48
|
-
"@adecore/drawing": "0.17.0-beta.
|
|
48
|
+
"@adecore/drawing": "0.17.0-beta.2"
|
|
49
49
|
}
|
|
50
50
|
}
|