@zukhruf/diagram 0.3.33 → 0.3.34
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/README.md +98 -52
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/compiler/diagram-compile.d.ts +3 -4
- package/dist/lib/compiler/diagram-compile.d.ts.map +1 -1
- package/dist/lib/compiler/diagram-compile.js +85 -370
- package/dist/lib/compiler/diagram-compile.js.map +1 -1
- package/dist/lib/layouts/graph/attach.d.ts.map +1 -1
- package/dist/lib/layouts/graph/attach.js +64 -8
- package/dist/lib/layouts/graph/attach.js.map +1 -1
- package/dist/lib/layouts/graph/connections.d.ts +11 -4
- package/dist/lib/layouts/graph/connections.d.ts.map +1 -1
- package/dist/lib/layouts/graph/connections.js +43 -17
- package/dist/lib/layouts/graph/connections.js.map +1 -1
- package/dist/lib/layouts/graph/graph-layout-result.d.ts +4 -2
- package/dist/lib/layouts/graph/graph-layout-result.d.ts.map +1 -1
- package/dist/lib/layouts/graph/graph-layout-result.js.map +1 -1
- package/dist/lib/layouts/graph/gutters.js +40 -21
- package/dist/lib/layouts/graph/gutters.js.map +1 -1
- package/dist/lib/layouts/graph/labels.d.ts +16 -9
- package/dist/lib/layouts/graph/labels.d.ts.map +1 -1
- package/dist/lib/layouts/graph/labels.js +62 -18
- package/dist/lib/layouts/graph/labels.js.map +1 -1
- package/dist/lib/layouts/graph/layout.d.ts +1 -1
- package/dist/lib/layouts/graph/layout.d.ts.map +1 -1
- package/dist/lib/layouts/graph/layout.js +6 -3
- package/dist/lib/layouts/graph/layout.js.map +1 -1
- package/dist/lib/layouts/graph/measure.d.ts +8 -5
- package/dist/lib/layouts/graph/measure.d.ts.map +1 -1
- package/dist/lib/layouts/graph/measure.js +47 -9
- package/dist/lib/layouts/graph/measure.js.map +1 -1
- package/dist/lib/layouts/graph/min-heap.d.ts +1 -5
- package/dist/lib/layouts/graph/min-heap.d.ts.map +1 -1
- package/dist/lib/layouts/graph/min-heap.js +1 -5
- package/dist/lib/layouts/graph/min-heap.js.map +1 -1
- package/dist/lib/layouts/graph/node-content.d.ts +1 -1
- package/dist/lib/layouts/graph/node-content.d.ts.map +1 -1
- package/dist/lib/layouts/graph/node-content.js +26 -7
- package/dist/lib/layouts/graph/node-content.js.map +1 -1
- package/dist/lib/layouts/graph/path.d.ts +2 -10
- package/dist/lib/layouts/graph/path.d.ts.map +1 -1
- package/dist/lib/layouts/graph/path.js +11 -13
- package/dist/lib/layouts/graph/path.js.map +1 -1
- package/dist/lib/layouts/graph/round.d.ts +11 -0
- package/dist/lib/layouts/graph/round.d.ts.map +1 -0
- package/dist/lib/layouts/graph/round.js +181 -0
- package/dist/lib/layouts/graph/round.js.map +1 -0
- package/dist/lib/layouts/graph/route.d.ts +10 -6
- package/dist/lib/layouts/graph/route.d.ts.map +1 -1
- package/dist/lib/layouts/graph/route.js +68 -33
- package/dist/lib/layouts/graph/route.js.map +1 -1
- package/dist/lib/layouts/graph/sides.d.ts +10 -5
- package/dist/lib/layouts/graph/sides.d.ts.map +1 -1
- package/dist/lib/layouts/graph/sides.js +14 -7
- package/dist/lib/layouts/graph/sides.js.map +1 -1
- package/dist/lib/layouts/timeline/timeline-layout.d.ts +2 -1
- package/dist/lib/layouts/timeline/timeline-layout.d.ts.map +1 -1
- package/dist/lib/layouts/timeline/timeline-layout.js +9 -4
- package/dist/lib/layouts/timeline/timeline-layout.js.map +1 -1
- package/dist/lib/model/diagram-ir.d.ts +19 -156
- package/dist/lib/model/diagram-ir.d.ts.map +1 -1
- package/dist/lib/model/diagram-ir.js.map +1 -1
- package/dist/lib/model/validate-graph.d.ts +7 -0
- package/dist/lib/model/validate-graph.d.ts.map +1 -0
- package/dist/lib/model/validate-graph.js +54 -0
- package/dist/lib/model/validate-graph.js.map +1 -0
- package/dist/lib/react/Diagram.d.ts +3 -9
- package/dist/lib/react/Diagram.d.ts.map +1 -1
- package/dist/lib/react/Diagram.js +1 -13
- package/dist/lib/react/Diagram.js.map +1 -1
- package/dist/lib/react/diagram-types.d.ts +17 -46
- package/dist/lib/react/diagram-types.d.ts.map +1 -1
- package/dist/lib/react/diagram-types.js.map +1 -1
- package/dist/lib/renderers/canvas/graph-canvas.d.ts +2 -5
- package/dist/lib/renderers/canvas/graph-canvas.d.ts.map +1 -1
- package/dist/lib/renderers/canvas/graph-canvas.js +68 -43
- package/dist/lib/renderers/canvas/graph-canvas.js.map +1 -1
- package/dist/lib/renderers/html/graph-html.d.ts +2 -3
- package/dist/lib/renderers/html/graph-html.d.ts.map +1 -1
- package/dist/lib/renderers/html/graph-html.js +298 -289
- package/dist/lib/renderers/html/graph-html.js.map +1 -1
- package/dist/lib/renderers/shared/graph-parts.d.ts +3 -1
- package/dist/lib/renderers/shared/graph-parts.d.ts.map +1 -1
- package/dist/lib/renderers/shared/graph-parts.js +350 -418
- package/dist/lib/renderers/shared/graph-parts.js.map +1 -1
- package/dist/lib/renderers/shared/node-parts.d.ts +5 -6
- package/dist/lib/renderers/shared/node-parts.d.ts.map +1 -1
- package/dist/lib/renderers/shared/node-parts.js +112 -190
- package/dist/lib/renderers/shared/node-parts.js.map +1 -1
- package/dist/lib/renderers/shared/run-spans.js +2 -2
- package/dist/lib/renderers/shared/run-spans.js.map +1 -1
- package/dist/lib/renderers/shared/text-runs.d.ts +0 -6
- package/dist/lib/renderers/shared/text-runs.d.ts.map +1 -1
- package/dist/lib/renderers/shared/text-runs.js +0 -12
- package/dist/lib/renderers/shared/text-runs.js.map +1 -1
- package/dist/lib/renderers/svg/graph-svg.d.ts +1 -3
- package/dist/lib/renderers/svg/graph-svg.d.ts.map +1 -1
- package/dist/lib/renderers/svg/graph-svg.js +66 -80
- package/dist/lib/renderers/svg/graph-svg.js.map +1 -1
- package/dist/lib/renderers/svg/timeline-svg.d.ts.map +1 -1
- package/dist/lib/renderers/svg/timeline-svg.js +7 -5
- package/dist/lib/renderers/svg/timeline-svg.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/layouts/graph/graph-layout.d.ts +0 -154
- package/dist/lib/layouts/graph/graph-layout.d.ts.map +0 -1
- package/dist/lib/layouts/graph/graph-layout.js +0 -2340
- package/dist/lib/layouts/graph/graph-layout.js.map +0 -1
- package/dist/lib/layouts/graph/legacy-graph-layout.d.ts +0 -6
- package/dist/lib/layouts/graph/legacy-graph-layout.d.ts.map +0 -1
- package/dist/lib/layouts/graph/legacy-graph-layout.js +0 -542
- package/dist/lib/layouts/graph/legacy-graph-layout.js.map +0 -1
- package/dist/lib/layouts/text-metrics.d.ts +0 -7
- package/dist/lib/layouts/text-metrics.d.ts.map +0 -1
- package/dist/lib/layouts/text-metrics.js +0 -40
- package/dist/lib/layouts/text-metrics.js.map +0 -1
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ Two props also change the look:
|
|
|
125
125
|
- `accent`: the highlight color. It is `green` (the default), `primary`, `neutral`, or a CSS color.
|
|
126
126
|
- `stylePreset`: `default`, or `sketch`. The `sketch` preset draws black ink on white, and makes each tone the same gray.
|
|
127
127
|
|
|
128
|
-
The
|
|
128
|
+
The text uses the fonts Geist Sans and Geist Mono. The stylesheet loads them from `@fontsource/geist-sans` and `@fontsource/geist-mono`, which install with the package. The graph layout measures each text with a table of the glyph widths of these fonts. Thus the text fits its box on each operating system and in server rendering. See [ADR 0003](./docs/adr/0003-the-graph-layout-is-a-content-sized-grid.md).
|
|
129
129
|
|
|
130
130
|
## Effects
|
|
131
131
|
|
|
@@ -154,10 +154,10 @@ The source of truth is `src/lib/react/Diagram.tsx`, `src/lib/react/diagram-types
|
|
|
154
154
|
|
|
155
155
|
The renderer sets the layout. `SvgGraphDiagram`, `CanvasGraphDiagram` and `HtmlGraphDiagram` draw a **graph**. `SvgTimelineDiagram` draws a **timeline**.
|
|
156
156
|
|
|
157
|
-
- **Graph primitives:** `Node`, `Box`, `Card`, `Port`, `Label`, `Float`, `
|
|
157
|
+
- **Graph primitives:** `Node`, `Box`, `Card`, `Port`, `Label`, `Float`, `Marker`, `Appliance`, `Connector`, `Junction`, `Note`, `Edge`, `Arrow`, `Wire`, `Group`, `Content`.
|
|
158
158
|
- **Timeline primitives:** `Lane`, `Signal`, `Frame`.
|
|
159
159
|
|
|
160
|
-
`Line` makes a label with more than one line, in both layouts. `Content` goes into a `Box`, a `Card` or a `Node`, one time.
|
|
160
|
+
`Line` makes a label with more than one line, in both layouts. `Content` goes into a `Box`, a `Card` or a `Node`, one time.
|
|
161
161
|
|
|
162
162
|
### Timeline primitives
|
|
163
163
|
|
|
@@ -182,28 +182,44 @@ The layout splits the line into two stubs. The stub at the source has no arrowhe
|
|
|
182
182
|
|
|
183
183
|
### Graph primitives
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
| Primitive | What it is | Default frame |
|
|
188
|
-
| ------------------- | ----------------------------------------------------------- | ------------- |
|
|
189
|
-
| `Diagram.Node` | The general node | `solid` | Prefer `Box` or `Card`.
|
|
190
|
-
| `Diagram.Box` | A node with a solid border and centered text | `solid` | The usual node.
|
|
191
|
-
| `Diagram.Card` | A node with a solid border and text that starts at the left | `solid` |
|
|
192
|
-
| `Diagram.Port` | A node with no header | `transparent` |
|
|
193
|
-
| `Diagram.Label` | Text at a grid position | `none` |
|
|
194
|
-
| `Diagram.Float` | A flat node
|
|
195
|
-
| `Diagram.
|
|
196
|
-
| `Diagram.
|
|
197
|
-
| `Diagram.
|
|
198
|
-
| `Diagram.
|
|
199
|
-
| `Diagram.
|
|
185
|
+
A graph is a grid of cells. Give each node an `id`, and a `row` and a `col`: integers from 0. `rowSpan` and `colSpan` let a node cover more cells. One node at most is in a cell. You do not give sizes in pixels. The layout measures the content of each node, and gives each row and each column the size of its largest content.
|
|
186
|
+
|
|
187
|
+
| Primitive | What it is | Default frame | Size |
|
|
188
|
+
| ------------------- | ----------------------------------------------------------- | ------------- | --------------------------------------- |
|
|
189
|
+
| `Diagram.Node` | The general node | `solid` | Fills its area. Prefer `Box` or `Card`. |
|
|
190
|
+
| `Diagram.Box` | A node with a solid border and centered text | `solid` | Fills its area. The usual node. |
|
|
191
|
+
| `Diagram.Card` | A node with a solid border and text that starts at the left | `solid` | Fills its area. |
|
|
192
|
+
| `Diagram.Port` | A node with no header | `transparent` | Fills its area. |
|
|
193
|
+
| `Diagram.Label` | Text at a grid position | `none` | Fills its area. |
|
|
194
|
+
| `Diagram.Float` | A flat node. An edge cannot attach to it. | `flat` | Fills its area. |
|
|
195
|
+
| `Diagram.Marker` | A node with an `icon`, for example `server` or `user` | `none` | Its own size. The icon is required. |
|
|
196
|
+
| `Diagram.Appliance` | A hardware device | `none` | Its own size. |
|
|
197
|
+
| `Diagram.Connector` | A small node with round corners and an optional `icon` | `solid` | Its own size. |
|
|
198
|
+
| `Diagram.Junction` | A small circle where edges meet | `none` | Its own size. |
|
|
199
|
+
| `Diagram.Note` | Text with no frame, with an optional leader to a `target` | `none` | Its own size. |
|
|
200
|
+
|
|
201
|
+
A node that keeps its own size goes at the center of its area.
|
|
200
202
|
|
|
201
203
|
Other props of a node:
|
|
202
204
|
|
|
203
|
-
- `tone`, `texture` and `accent` set its colors.
|
|
205
|
+
- `tone`, `texture` and `accent` set its colors. `frame` sets its border.
|
|
206
|
+
- `description` and `items` add text under the title of a card.
|
|
204
207
|
- `caption` puts text next to the node, on the side that `captionSide` sets.
|
|
205
|
-
- `ports` gives node ports: named points on a side, where an edge can attach.
|
|
206
|
-
- `stack` draws copies of the frame behind the node, for a set of equal items.
|
|
208
|
+
- `ports` gives node ports: named points on a side, where an edge can attach. When a side has ports, each edge to that side must name a port.
|
|
209
|
+
- `stack` draws copies of the frame behind the node, for a set of equal items. `stackDirection` sets where the copies go.
|
|
210
|
+
- `appliancePorts` and `antenna` change the drawing of an appliance.
|
|
211
|
+
|
|
212
|
+
A note explains a node or a group. With a `target`, the layout draws a leader from the note to it:
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
<Diagram.Box id="cert-manager" row={2} col={5}>
|
|
216
|
+
cert-manager
|
|
217
|
+
</Diagram.Box>
|
|
218
|
+
<Diagram.Note id="cert-note" row={2} col={7} target="cert-manager">
|
|
219
|
+
<Diagram.Line>Manages</Diagram.Line>
|
|
220
|
+
<Diagram.Line>certificates</Diagram.Line>
|
|
221
|
+
</Diagram.Note>
|
|
222
|
+
```
|
|
207
223
|
|
|
208
224
|
### Edges
|
|
209
225
|
|
|
@@ -213,45 +229,72 @@ Other props of a node:
|
|
|
213
229
|
| `Diagram.Wire` | An edge with no arrowhead | No | When the direction is clear or the same both ways. |
|
|
214
230
|
| `Diagram.Edge` | The general edge; set `headless` yourself | You select it | Prefer `Arrow` or `Wire`. |
|
|
215
231
|
|
|
216
|
-
The required props are `from` and `to`.
|
|
232
|
+
The required props are `from` and `to`. Each is the id of a node or a group, or `id:port` for a node port. The other props are:
|
|
217
233
|
|
|
218
|
-
|
|
234
|
+
- `lineStyle` (`solid`, `dashed`, `dotted`), `direction` (`forward`, `both`, `none`), `weight` (`regular`, `bold`), `dim`, `accent`, and `headless`.
|
|
235
|
+
- `exitSide` and `entrySide` (`top`, `right`, `bottom`, `left`): the side of the source where the edge goes out, and the side of the target where it goes in.
|
|
236
|
+
- `layer` (`background`, `foreground`): whether the edge draws below or above the nodes.
|
|
237
|
+
- `labelFrame`: a box around the label.
|
|
238
|
+
- `badgeIcon` and `badgeLabel`: an icon on the edge.
|
|
239
|
+
- `channel`: a name that the layout copies to the `data-diagram-edge-channel` attribute.
|
|
219
240
|
|
|
220
|
-
|
|
241
|
+
The text children and the `Diagram.Line` children of an edge are its label.
|
|
221
242
|
|
|
222
|
-
|
|
243
|
+
The router in `src/lib/layouts/graph/route.ts` selects each path:
|
|
223
244
|
|
|
224
|
-
|
|
245
|
+
- Each path is orthogonal. The router finds it with A\*, and it goes around the nodes, the captions, the group labels, and the labels of the edges that routed before it.
|
|
246
|
+
- The router routes the nearest edges first.
|
|
247
|
+
- When you do not give `exitSide` and `entrySide`, the router selects the sides from the cells of the two ends.
|
|
248
|
+
- The edges on one side of a node divide that side into equal slots, in the order of their other ends, so they do not cross.
|
|
249
|
+
- The router puts each label beside the longest segment of its edge, at the first free position.
|
|
225
250
|
|
|
226
|
-
|
|
251
|
+
The layout throws when an edge has no route, or when a label has no free position. Each error names the edge. Then give `exitSide` or `entrySide`, move a node to a different cell, or split the diagram. When the problem is general, fix the router. See [the internals](./docs/internals.md).
|
|
252
|
+
|
|
253
|
+
### Groups
|
|
227
254
|
|
|
228
|
-
|
|
229
|
-
| ------------------ | --------------------------------------------------------------------------------------- |
|
|
230
|
-
| `Diagram.Entry` | Sets the side of the target where the edge goes in: `top`, `right`, `bottom` or `left`. |
|
|
231
|
-
| `Diagram.Exit` | Sets the side of the source where the edge goes out. |
|
|
232
|
-
| `Diagram.Waypoint` | Gives a point that the edge goes through: `{ x, y }`, a grid cell, a guide, or a node. |
|
|
255
|
+
`Diagram.Group` draws a rectangle around a set of nodes. Put the nodes in it as children. A group can be in a group.
|
|
233
256
|
|
|
234
|
-
|
|
257
|
+
The required prop is `id`. The optional props are `label`, `labelAlign`, `labelSide` (`top`, `bottom`), `titleBand` (a band behind the label), `accent`, `tone`, `texture`, `fill`, `frame` (`solid`, `dashed`, `none`), `ports`, and `dividers` (a line through each gutter in the group).
|
|
235
258
|
|
|
236
|
-
The
|
|
259
|
+
The area of a group is the smallest area that holds its members. To give a larger area, set `row`, `col`, `rowSpan` and `colSpan`:
|
|
237
260
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
261
|
+
```tsx
|
|
262
|
+
<Diagram.Group id="bug" row={0} col={3} colSpan={5} label="BUG">
|
|
263
|
+
<Diagram.Box id="reproduce" row={0} col={3}>
|
|
264
|
+
Reproduce
|
|
265
|
+
</Diagram.Box>
|
|
266
|
+
<Diagram.Box id="review-fix" row={0} col={6}>
|
|
267
|
+
Review fix
|
|
268
|
+
</Diagram.Box>
|
|
269
|
+
</Diagram.Group>
|
|
270
|
+
```
|
|
243
271
|
|
|
244
|
-
|
|
272
|
+
The border, the padding and the title band of a group go in the gutters between the rows and the columns. Thus a group never covers a node. The layout throws when two sibling groups overlap, when a node is in the area of a group that it is not a member of, and when an explicit area does not hold all of the members.
|
|
245
273
|
|
|
246
274
|
### Primitives for both layouts
|
|
247
275
|
|
|
248
|
-
| Primitive
|
|
249
|
-
|
|
|
250
|
-
| `Diagram.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
276
|
+
| Primitive | What it is |
|
|
277
|
+
| -------------- | ---------------------------------------------------------------------------------------------- |
|
|
278
|
+
| `Diagram.Line` | One line of a label with more than one line. It goes into a lane, a signal, a node or an edge. |
|
|
279
|
+
|
|
280
|
+
### Content
|
|
281
|
+
|
|
282
|
+
`Diagram.Content` holds real React content in a `Box`, a `Card` or a `Node`. Only `HtmlGraphDiagram` draws it. The layout cannot measure React content, so give its size in pixels with `size`. The layout keeps a space of that size under the label:
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
<HtmlGraphDiagram title="Query">
|
|
286
|
+
<Diagram.Box id="database" row={0} col={0}>
|
|
287
|
+
Database
|
|
288
|
+
<Diagram.Content size={{ w: 96, h: 56 }}>
|
|
289
|
+
<button type="button">Run query</button>
|
|
290
|
+
</Diagram.Content>
|
|
291
|
+
</Diagram.Box>
|
|
292
|
+
</HtmlGraphDiagram>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### The layout without React
|
|
296
|
+
|
|
297
|
+
`layoutGraph(ir)` calculates the layout of a graph and returns a `GraphLayout`: the boxes of the nodes, the rectangles of the groups, the paths of the edges and the leaders, the positions of each text, and the `viewBox`. It is a pure, synchronous function. The renderers call it, and only copy its values. The package exports it and its types.
|
|
255
298
|
|
|
256
299
|
### Labels
|
|
257
300
|
|
|
@@ -269,8 +312,8 @@ The compiler checks the children, and it throws with a clear message:
|
|
|
269
312
|
- A renderer accepts only primitives as children.
|
|
270
313
|
- A React fragment (`<>…</>`) throws. Write the primitives directly, or give an array of primitives.
|
|
271
314
|
- A different component, for example `<MyHelper />`, throws with the name of the component.
|
|
272
|
-
- A lane, a signal, an edge and a frame accept only their own children: text
|
|
273
|
-
- A duplicate `id` of a node, a group
|
|
315
|
+
- A lane, a signal, an edge and a frame accept only their own children: text and `Line`, and `Signal` in a frame.
|
|
316
|
+
- A duplicate `id` of a node, a group or a lane throws, with the id in the message.
|
|
274
317
|
- An edge to a missing `from` or `to` throws, with both ends in the message.
|
|
275
318
|
|
|
276
319
|
### Renderer props
|
|
@@ -291,7 +334,7 @@ Each renderer takes these props:
|
|
|
291
334
|
| `viewport` | `{ fit?, zoom? }` | `fit: 'width'` | How the drawing fits its container: `width`, `contain` or `natural`. `zoom` scales it. |
|
|
292
335
|
| `paper` | `boolean \| { fill?, stroke?, rx? }` | | A rectangle behind the drawing. `fill` is `background` or `surface`. |
|
|
293
336
|
|
|
294
|
-
|
|
337
|
+
`HtmlGraphDiagram` takes `viewport.zoom`, but not `viewport.fit`. Only `SvgGraphDiagram` takes `effects`.
|
|
295
338
|
|
|
296
339
|
The package does not set the width of a diagram on a page. Give the classes of your page layout with `className`.
|
|
297
340
|
|
|
@@ -300,6 +343,8 @@ The package does not set the width of a diagram on a page. Give the classes of y
|
|
|
300
343
|
- **Internals**: [docs/internals.md](./docs/internals.md) tells how the compiler, the layouts and the renderers divide the work, and which mistakes the code had before.
|
|
301
344
|
- **Decisions**: the [architecture decision records](./docs/adr) tell why the design is as it is.
|
|
302
345
|
1. [The diagram is a zukhruf package](./docs/adr/0001-the-diagram-is-a-zukhruf-package.md)
|
|
346
|
+
2. [The examples are a playground app in zukhruf](./docs/adr/0002-the-examples-are-a-playground-app-in-zukhruf.md)
|
|
347
|
+
3. [The graph layout is a content-sized grid](./docs/adr/0003-the-graph-layout-is-a-content-sized-grid.md)
|
|
303
348
|
|
|
304
349
|
## Development
|
|
305
350
|
|
|
@@ -317,9 +362,10 @@ npx nx run diagram:lint # lints the code
|
|
|
317
362
|
src/
|
|
318
363
|
lib/model/ the IR types, and parseEndpointRef, which reads the from and to of an edge
|
|
319
364
|
lib/compiler/ reads the primitives, and makes the IR
|
|
320
|
-
lib/layouts/ the pure geometry of the graph and the timeline
|
|
365
|
+
lib/layouts/ the pure geometry of the graph and the timeline; text/ measures text with the glyph table
|
|
321
366
|
lib/renderers/ svg/, canvas/, html/ and webgpu/ draw the layouts; shared/ holds the parts that they share
|
|
322
367
|
lib/react/ the Diagram primitives and the chrome
|
|
368
|
+
testing/ the oracle (assertSoundLayout), and the script that writes the glyph table; the build does not ship them
|
|
323
369
|
index.ts the entry
|
|
324
|
-
styles.css registers dist with @source
|
|
370
|
+
styles.css loads the Geist fonts, and registers dist with @source
|
|
325
371
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export { Diagram, type DiagramAccent, type DiagramApplianceProps, type DiagramConnectorProps, type DiagramContentProps, type DiagramEdgeProps, type DiagramEffects, type
|
|
1
|
+
export { Diagram, type DiagramAccent, type DiagramApplianceProps, type DiagramConnectorProps, type DiagramContentProps, type DiagramEdgeProps, type DiagramEffects, type DiagramFrameProps, type DiagramGroupProps, type DiagramJunctionProps, type DiagramLaneProps, type DiagramLineProps, type DiagramMarkerProps, type DiagramMode, type DiagramNodeProps, type DiagramNoteProps, type DiagramPaper, type DiagramProps, type DiagramSignalProps, type DiagramStackDirection, type DiagramStylePreset, type DiagramViewport, } from './lib/react/Diagram.tsx';
|
|
2
2
|
export { SvgGraphDiagram, type SvgGraphDiagramProps, } from './lib/renderers/svg/graph-svg.tsx';
|
|
3
3
|
export { SvgTimelineDiagram, type SvgTimelineDiagramProps, } from './lib/renderers/svg/timeline-svg.tsx';
|
|
4
4
|
export { CanvasGraphDiagram, type CanvasGraphDiagramProps, } from './lib/renderers/canvas/graph-canvas.tsx';
|
|
5
5
|
export { HtmlGraphDiagram, type HtmlGraphDiagramProps, } from './lib/renderers/html/graph-html.tsx';
|
|
6
|
-
export
|
|
7
|
-
export type {
|
|
6
|
+
export { layoutGraph } from './lib/layouts/graph/layout.ts';
|
|
7
|
+
export type { EdgeLabelLayout, EdgeLayout, GraphLayout, GroupLayout, LeaderLayout, NodeLayout, PortLayout, TextAnchor, TextRun, } from './lib/layouts/graph/graph-layout-result.ts';
|
|
8
|
+
export type { Font, FontFace, FontWeight } from './lib/layouts/text/font.ts';
|
|
9
|
+
export type { Box, DiagramEdge, DiagramEdgeDirection, DiagramEdgeLineStyle, DiagramEdgeWeight, DiagramFrameElement, DiagramGraphIR, DiagramGroup, DiagramLabelLine, DiagramLane, DiagramMarker, DiagramNode, DiagramNodeContent, DiagramNodeIcon, DiagramNodePort, DiagramSide, DiagramSignal, DiagramTextColor, DiagramTexture, DiagramTimelineSpec, DiagramTone, DiagramViewportFit, Point, } from './lib/model/diagram-ir.ts';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,YAAY,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,GACR,MAAM,4CAA4C,CAAC;AACpD,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7E,YAAY,EACV,GAAG,EACH,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,KAAK,GACN,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { SvgGraphDiagram } from "./lib/renderers/svg/graph-svg.js";
|
|
|
3
3
|
export { SvgTimelineDiagram } from "./lib/renderers/svg/timeline-svg.js";
|
|
4
4
|
export { CanvasGraphDiagram } from "./lib/renderers/canvas/graph-canvas.js";
|
|
5
5
|
export { HtmlGraphDiagram } from "./lib/renderers/html/graph-html.js";
|
|
6
|
+
export { layoutGraph } from "./lib/layouts/graph/layout.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Diagram","SvgGraphDiagram","SvgTimelineDiagram","CanvasGraphDiagram","HtmlGraphDiagram"],"sources":["../src/index.ts"],"sourcesContent":["export {\n Diagram,\n type DiagramAccent,\n type DiagramApplianceProps,\n type DiagramConnectorProps,\n type DiagramContentProps,\n type DiagramEdgeProps,\n type DiagramEffects,\n type
|
|
1
|
+
{"version":3,"file":"index.js","names":["Diagram","SvgGraphDiagram","SvgTimelineDiagram","CanvasGraphDiagram","HtmlGraphDiagram","layoutGraph"],"sources":["../src/index.ts"],"sourcesContent":["export {\n Diagram,\n type DiagramAccent,\n type DiagramApplianceProps,\n type DiagramConnectorProps,\n type DiagramContentProps,\n type DiagramEdgeProps,\n type DiagramEffects,\n type DiagramFrameProps,\n type DiagramGroupProps,\n type DiagramJunctionProps,\n type DiagramLaneProps,\n type DiagramLineProps,\n type DiagramMarkerProps,\n type DiagramMode,\n type DiagramNodeProps,\n type DiagramNoteProps,\n type DiagramPaper,\n type DiagramProps,\n type DiagramSignalProps,\n type DiagramStackDirection,\n type DiagramStylePreset,\n type DiagramViewport,\n} from './lib/react/Diagram.tsx';\nexport {\n SvgGraphDiagram,\n type SvgGraphDiagramProps,\n} from './lib/renderers/svg/graph-svg.tsx';\nexport {\n SvgTimelineDiagram,\n type SvgTimelineDiagramProps,\n} from './lib/renderers/svg/timeline-svg.tsx';\nexport {\n CanvasGraphDiagram,\n type CanvasGraphDiagramProps,\n} from './lib/renderers/canvas/graph-canvas.tsx';\nexport {\n HtmlGraphDiagram,\n type HtmlGraphDiagramProps,\n} from './lib/renderers/html/graph-html.tsx';\nexport { layoutGraph } from './lib/layouts/graph/layout.ts';\nexport type {\n EdgeLabelLayout,\n EdgeLayout,\n GraphLayout,\n GroupLayout,\n LeaderLayout,\n NodeLayout,\n PortLayout,\n TextAnchor,\n TextRun,\n} from './lib/layouts/graph/graph-layout-result.ts';\nexport type { Font, FontFace, FontWeight } from './lib/layouts/text/font.ts';\nexport type {\n Box,\n DiagramEdge,\n DiagramEdgeDirection,\n DiagramEdgeLineStyle,\n DiagramEdgeWeight,\n DiagramFrameElement,\n DiagramGraphIR,\n DiagramGroup,\n DiagramLabelLine,\n DiagramLane,\n DiagramMarker,\n DiagramNode,\n DiagramNodeContent,\n DiagramNodeIcon,\n DiagramNodePort,\n DiagramSide,\n DiagramSignal,\n DiagramTextColor,\n DiagramTexture,\n DiagramTimelineSpec,\n DiagramTone,\n DiagramViewportFit,\n Point,\n} from './lib/model/diagram-ir.ts';\n"],"mappings":"AAAA,SACEA,OAAO,QAsBF,wBAAyB;AAChC,SACEC,eAAe,QAEV,kCAAmC;AAC1C,SACEC,kBAAkB,QAEb,qCAAsC;AAC7C,SACEC,kBAAkB,QAEb,wCAAyC;AAChD,SACEC,gBAAgB,QAEX,oCAAqC;AAC5C,SAASC,WAAW,QAAQ,+BAA+B","ignoreList":[]}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { DiagramGraphIR,
|
|
2
|
+
import type { DiagramGraphIR, DiagramTimelineSpec } from '../model/diagram-ir.ts';
|
|
3
3
|
export declare const DIAGRAM_PRIMITIVE: unique symbol;
|
|
4
|
-
declare const PRIMITIVE_KINDS: readonly ["node", "box", "card", "port", "label", "float", "
|
|
4
|
+
declare const PRIMITIVE_KINDS: readonly ["node", "box", "card", "port", "label", "float", "appliance", "connector", "junction", "edge", "arrow", "wire", "group", "note", "line", "lane", "signal", "frame", "marker", "content"];
|
|
5
5
|
export type PrimitiveKind = (typeof PRIMITIVE_KINDS)[number];
|
|
6
6
|
export type PrimitiveComponent<P> = ((props: P) => null) & {
|
|
7
7
|
[DIAGRAM_PRIMITIVE]: PrimitiveKind;
|
|
8
8
|
};
|
|
9
9
|
export declare function primitive<P>(kind: PrimitiveKind): PrimitiveComponent<P>;
|
|
10
10
|
export declare function primitiveKind(node: ReactNode): PrimitiveKind | null;
|
|
11
|
-
export declare function compileGraph(children: ReactNode
|
|
11
|
+
export declare function compileGraph(children: ReactNode): DiagramGraphIR;
|
|
12
12
|
export declare function compileTimeline(children: ReactNode): DiagramTimelineSpec;
|
|
13
|
-
export declare function validateGraph(ir: DiagramGraphIR): void;
|
|
14
13
|
export declare function validateTimeline(ir: DiagramTimelineSpec): void;
|
|
15
14
|
export {};
|
|
16
15
|
//# sourceMappingURL=diagram-compile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram-compile.d.ts","sourceRoot":"","sources":["../../../src/lib/compiler/diagram-compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"diagram-compile.d.ts","sourceRoot":"","sources":["../../../src/lib/compiler/diagram-compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAGV,cAAc,EAOd,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAiBhC,eAAO,MAAM,iBAAiB,eAA2C,CAAC;AAE1E,QAAA,MAAM,eAAe,oMAqBX,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG;IACzD,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;CACpC,CAAC;AAEF,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAEvE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,IAAI,CAMnE;AAuCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,cAAc,CAgBhE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,GAAG,mBAAmB,CAgBxE;AAqYD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,mBAAmB,QAoBvD"}
|