@kekonic/diagrams-core 1.0.0-rc.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kekonic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @kekonic/diagrams-core
2
+
3
+ Language core for KDiagram: parser, compiler, `GraphModel` types, and source formatting.
4
+
5
+ ## Scope
6
+
7
+ This package owns the DSL boundary only:
8
+
9
+ - **parse** — lexer + parser → `KDiagramAst`
10
+ - **compile** — AST → `GraphModel` + layout/routing/render hints
11
+ - **format** — pretty-print KDiagram source
12
+ - **types** — `GraphModel`, geometry helpers (`expandRect`, `manhattan`, `rectsOverlap`), options types
13
+
14
+ Layout, routing, theme, renderers, and the full pipeline live in sibling packages. Use **`@kekonic/diagrams`** for the integrated browser/CLI API.
15
+
16
+ ## Package map
17
+
18
+ | Package | Responsibility |
19
+ | ------------------------------ | ----------------------------------------------------------- |
20
+ | `@kekonic/diagrams-core` | parse, compile, kinds/shapes catalog, types, format |
21
+ | `@kekonic/diagrams-geometry` | ShapeGeometry library, ports, footprints, node-type bridge |
22
+ | `@kekonic/diagrams-layout` | measure, ELK layout + orthogonal edges, topology, direction |
23
+ | `@kekonic/diagrams-routing` | crossing treatment, endpoint trim, perimeter attach |
24
+ | `@kekonic/diagrams-theme` | tokens, styles, CSS |
25
+ | `@kekonic/diagrams-render-svg` | SVG renderer |
26
+ | `@kekonic/diagrams` | pipeline orchestration + `KDiagram` browser API |
27
+ | `@kekonic/diagrams-cli` | CLI |
28
+
29
+ ## Quick start
30
+
31
+ ```ts
32
+ import { parse, compile, formatSource } from "@kekonic/diagrams-core";
33
+
34
+ const ast = parse(`diagram "Demo" {
35
+ direction LR
36
+ a: service "A"
37
+ b: service "B"
38
+ a -> b
39
+ }`);
40
+
41
+ const { graph, layoutHints, routingHints, diagnostics } = compile(ast);
42
+ ```
43
+
44
+ ## Kinds & shapes
45
+
46
+ ```ts
47
+ import {
48
+ getKindDefaults,
49
+ isGeometryKind,
50
+ listGeometryKinds,
51
+ BUILTIN_KIND_CATALOG,
52
+ } from "@kekonic/diagrams-core";
53
+
54
+ getKindDefaults("gateway").defaults.shape; // "hexagon"
55
+ isGeometryKind("diamond"); // true — bare geometry kind
56
+ listGeometryKinds(); // all shape ids usable as kinds
57
+ ```
58
+
59
+ Semantic kinds (`service`, `choice`, …) and geometry kinds (`diamond`, `cylinder`, …) share one
60
+ catalog. Shape math lives in `@kekonic/diagrams-geometry`.
61
+
62
+ For end-to-end rendering:
63
+
64
+ ```ts
65
+ import { KDiagram } from "@kekonic/diagrams";
66
+
67
+ const result = await KDiagram.renderToSvg(source);
68
+ console.log(result.svg);
69
+ ```