reladraw 0.19.0 → 0.19.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.
- package/README.md +4 -4
- package/SYNTAX.md +7 -2
- package/dist/lines.d.ts +1 -0
- package/dist/lines.js +10 -4
- package/dist/model.d.ts +2 -0
- package/dist/resolve.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
reladraw is a text language for diagrams where you say where things go.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> The language is changing frequently. The playground always runs the newest syntax, so a diagram that draws there today may need a small edit later. An installed copy from npm changes only when you upgrade it.
|
|
6
|
+
|
|
7
|
+
**[Try it in your browser in the reladraw playground →](https://reladraw.github.io/reladraw/)**
|
|
6
8
|
|
|
7
9
|
I wanted to be able to create custom, expressive diagrams where I decided how to arrange the diagram, but without the inefficiency of manually drawing in draw.io. For example, this is a diagram drawn in draw.io:
|
|
8
10
|
|
|
@@ -86,9 +88,7 @@ That gets you a copy of the skill at the time you run it, so you'll need to re-r
|
|
|
86
88
|
|
|
87
89
|
## Status
|
|
88
90
|
|
|
89
|
-
Version 0.19.
|
|
90
|
-
|
|
91
|
-
The language isn't stable yet, so expect the syntax to change.
|
|
91
|
+
Version 0.19.1. Early stage, but works. The parser, layout engine, and SVG renderer are written in TypeScript, with zero runtime dependencies. There is a command-line tool that turns a .reladraw text file into an SVG, and an element that does the same inside a web page.
|
|
92
92
|
|
|
93
93
|
## License
|
|
94
94
|
|
package/SYNTAX.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Syntax reference — 0.19.
|
|
1
|
+
# Syntax reference — 0.19.1
|
|
2
2
|
|
|
3
3
|
What the language accepts. The changelog at the end lists what changed in each published version; 0.17.0's changes are large, and its entry has a table of every old spelling and what to write instead.
|
|
4
4
|
|
|
@@ -842,7 +842,7 @@ A line named `req` has parts. `req start` and `req end` are where it was written
|
|
|
842
842
|
|
|
843
843
|
### Copies fan out
|
|
844
844
|
|
|
845
|
-
Copies are lines with the same two boxes on the same sides, in either direction, with nothing stated about their path. Texts and colors don't count, so a request and its response are copies. Copies are drawn as one shape, each shifted sideways from it by a fixed step like lanes on a road, so they never cross. Straight copies with no side named run parallel, a `tight` gap apart, each end landing where its lane meets the border. A line
|
|
845
|
+
Copies are lines with the same two boxes on the same sides, in either direction, with nothing stated about their path. Texts and colors don't count, so a request and its response are copies. Copies are drawn as one shape, each shifted sideways from it by a fixed step like lanes on a road, so they never cross. Straight copies with no side named run parallel, a `tight` gap apart, each end landing where its lane meets the border. A line that says anything about where it goes is no longer a copy, and is drawn as written: a stated landing (`to: top, right of z`), a place in a side's `right-edge-order:` list, or a `step-out:` or `turn:` in its own bracket. That is how to override the fan. A `step-out:` or `turn:` from `default edge` or a style says the same for every line, so copies sharing it still fan, each taking it from the first.
|
|
846
846
|
|
|
847
847
|
```
|
|
848
848
|
node client
|
|
@@ -1281,6 +1281,11 @@ Designed and absent from the code.
|
|
|
1281
1281
|
|
|
1282
1282
|
Pre-1.0, so the minor number is where a breaking change goes. Every removal is refused by name with the replacement quoted, rather than dropped in silence: an older file stops with an error saying what to write instead.
|
|
1283
1283
|
|
|
1284
|
+
**0.19.1**
|
|
1285
|
+
|
|
1286
|
+
- **A copy that states its own `step-out:` or `turn:` keeps it.** Lines between the same two sides of the same two boxes fan into lanes, and each used to be drawn as the first one's shape shifted over, so a `step-out:` or `turn:` written on any later line was ignored. A line naming either is now drawn as written and leaves the fan, and so does a line named in its side's `right-edge-order:` list. Where that puts two lines on one run, it is reported as `edge-overlap`. Prompted by #19.
|
|
1287
|
+
- **Errors and findings name a named line by its name**, as written: `line e2 b.1 -- b.2 runs on line e1 b.1 -- b.2`. Two lines between the same boxes used to read identically.
|
|
1288
|
+
|
|
1284
1289
|
**0.19.0**
|
|
1285
1290
|
|
|
1286
1291
|
- **`reladraw format`** lays a file out again: each statement on one line, neighboring statements with the same keyword lined up in columns, comments kept beside what they are about. No word is respelled, and the result is checked to draw what the original did. `--check` fails on a file that would change, and `.reladraw-format` holds a project's settings; `reladraw format --init` writes one with every setting explained. `reladraw format -` reads standard input and prints the result, for editors. A long statement can wrap past a width (`wrap-at`) or go one clause to a line (`clause-per-line-at`), and `clause-order` puts placements and keys in a chosen order. The playground has a Format button (Shift+Alt+F, undone with Ctrl+Z) and a panel for its settings, which can copy them as a `.reladraw-format`. Spacing inside a clause is evened out too: `gap:tight` becomes `gap: tight`, `( gap: tight )` becomes `(gap: tight)`. Prompted by #14, where a long statement was hard to read in a plain editor.
|
package/dist/lines.d.ts
CHANGED
|
@@ -101,4 +101,5 @@ export declare function crossingPoints(a: Point[], b: Point[], clear: number): {
|
|
|
101
101
|
along: Point;
|
|
102
102
|
other: Point;
|
|
103
103
|
}[];
|
|
104
|
+
/** An edge as written, its name first where it has one: `e2 b.1 -- b.2`, so two lines between the same boxes can be told apart. */
|
|
104
105
|
export declare function describeEdge(edge: LayoutEdge): string;
|
package/dist/lines.js
CHANGED
|
@@ -145,16 +145,20 @@ export function planSides(layout) {
|
|
|
145
145
|
/**
|
|
146
146
|
* Copies are lines with the same two boxes on the same sides, in either
|
|
147
147
|
* direction, with nothing stated about their path (6.5): no waypoints, no
|
|
148
|
-
* landing point, no place among a side's ends
|
|
149
|
-
*
|
|
148
|
+
* landing point, no place among a side's ends, and no `step-out:` or `turn:`
|
|
149
|
+
* written on the line itself. Found by filing each line under its boxes and
|
|
150
|
+
* sides, in one pass.
|
|
150
151
|
*/
|
|
151
152
|
function copySets(edges, ends) {
|
|
152
153
|
const filed = new Map();
|
|
153
|
-
const
|
|
154
|
+
const listed = (end) => end.edge.name !== undefined && (end.node.attrs[`${end.spec.side}-edge-order`]?.split(', ').includes(end.edge.name) ?? false);
|
|
155
|
+
const plain = (end) => end.spec.kind === 'side' && end.spec.after === undefined && !listed(end) && !end.onLine && end.edge.onMark?.[end.which] !== 'point';
|
|
154
156
|
const keyOf = (end) => `${end.node.name}\n${end.spec.side}`;
|
|
155
157
|
for (const edge of edges) {
|
|
156
158
|
if (edge.via !== undefined || edge.straight !== undefined)
|
|
157
159
|
continue;
|
|
160
|
+
if (edge.look.stepOutWritten !== undefined || edge.look.turnWritten !== undefined)
|
|
161
|
+
continue;
|
|
158
162
|
const [start, end] = ends.get(edge);
|
|
159
163
|
if (!plain(start) || !plain(end))
|
|
160
164
|
continue;
|
|
@@ -2007,8 +2011,10 @@ function intersect(a, b, c, d) {
|
|
|
2007
2011
|
return undefined;
|
|
2008
2012
|
return { x: a.x + r.x * t, y: a.y + r.y * t };
|
|
2009
2013
|
}
|
|
2014
|
+
/** An edge as written, its name first where it has one: `e2 b.1 -- b.2`, so two lines between the same boxes can be told apart. */
|
|
2010
2015
|
export function describeEdge(edge) {
|
|
2011
2016
|
if (edge.bundle)
|
|
2012
2017
|
return `bundle ${edge.name}`;
|
|
2013
|
-
|
|
2018
|
+
const ends = `${edge.from.name} ${edge.arrow} ${edge.to.name}`;
|
|
2019
|
+
return edge.name === undefined ? ends : `${edge.name} ${ends}`;
|
|
2014
2020
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -287,6 +287,8 @@ export interface LineLook {
|
|
|
287
287
|
turnWritten: string | undefined;
|
|
288
288
|
/** The short first and last leg of a square or curved line, in pixels. */
|
|
289
289
|
stepOut: number;
|
|
290
|
+
/** `step-out:` as written on the edge itself; from a style or a default it is undefined. */
|
|
291
|
+
stepOutWritten: string | undefined;
|
|
290
292
|
}
|
|
291
293
|
export interface Layout {
|
|
292
294
|
/** Every node, containers and children alike, in declaration order. */
|
package/dist/resolve.js
CHANGED
|
@@ -1700,6 +1700,7 @@ function lineLook(written, appearance, what, line) {
|
|
|
1700
1700
|
turn,
|
|
1701
1701
|
turnWritten: written['line.turn'],
|
|
1702
1702
|
stepOut,
|
|
1703
|
+
stepOutWritten: written['line.step-out'],
|
|
1703
1704
|
};
|
|
1704
1705
|
// Said on the edge itself, a property its path doesn't have is refused; from
|
|
1705
1706
|
// a style or a default it lands on the lines that have it.
|