reladraw 0.26.1 → 0.28.0

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 (50) hide show
  1. package/.claude/skills/reladraw/SKILL.md +7 -5
  2. package/.claude/skills/reladraw/reference/syntax.md +55 -7
  3. package/README.md +2 -2
  4. package/SYNTAX.md +55 -7
  5. package/dist/cli.js +15 -1
  6. package/dist/examples.d.ts +26 -0
  7. package/dist/examples.js +56 -0
  8. package/dist/page-data.d.ts +130 -0
  9. package/dist/page-data.js +226 -0
  10. package/dist/page.d.ts +46 -2
  11. package/dist/page.js +1992 -252
  12. package/dist/serve.d.ts +18 -0
  13. package/dist/serve.js +544 -0
  14. package/dist/viewer.js +1 -1
  15. package/examples/arch.reladraw +95 -0
  16. package/examples/around.reladraw +101 -0
  17. package/examples/borders.reladraw +28 -0
  18. package/examples/bundles.reladraw +49 -0
  19. package/examples/circles.reladraw +37 -0
  20. package/examples/coincident.reladraw +66 -0
  21. package/examples/contents.reladraw +52 -0
  22. package/examples/corridors.reladraw +48 -0
  23. package/examples/deck.reladraw +26 -0
  24. package/examples/flowchart.reladraw +23 -0
  25. package/examples/frames.reladraw +79 -0
  26. package/examples/gap.reladraw +21 -0
  27. package/examples/gaps.reladraw +25 -0
  28. package/examples/icons.reladraw +35 -0
  29. package/examples/lanes.reladraw +54 -0
  30. package/examples/lines.reladraw +73 -0
  31. package/examples/linetexts.reladraw +48 -0
  32. package/examples/marks.reladraw +39 -0
  33. package/examples/names.reladraw +23 -0
  34. package/examples/outlines.reladraw +56 -0
  35. package/examples/overhang.reladraw +24 -0
  36. package/examples/overlays.reladraw +75 -0
  37. package/examples/parts.reladraw +31 -0
  38. package/examples/passes.reladraw +56 -0
  39. package/examples/points.reladraw +28 -0
  40. package/examples/regions.reladraw +14 -0
  41. package/examples/routing.reladraw +88 -0
  42. package/examples/shapes.reladraw +38 -0
  43. package/examples/snug.reladraw +8 -0
  44. package/examples/text.reladraw +69 -0
  45. package/examples/themes.reladraw +16 -0
  46. package/examples/urls.reladraw +35 -0
  47. package/examples/venn.reladraw +15 -0
  48. package/package.json +2 -1
  49. package/dist/search.d.ts +0 -104
  50. package/dist/search.js +0 -490
@@ -11,11 +11,11 @@ Every other diagram language hands the arrangement to a layout engine, so where
11
11
 
12
12
  That matters here specifically. You can't see the SVG you produced. With auto-layout that leaves you guessing; with reladraw the arrangement is in the sentences you just wrote, and where the picture may not read as meant, the tool tells you in words.
13
13
 
14
- **Show every diagram as its page.** Whenever the user is to see a diagram, whether one you drew, one you changed, or an existing file they asked to look at, render it with `--page` and open it in the default browser, as step 7 of the loop says. The bare SVG is for putting into something else, such as a README or a document, not for showing.
14
+ **Show every diagram on its served page.** Whenever the user is to see a diagram, whether one you drew, one you changed, or an existing file they asked to look at, serve it with `reladraw serve`, as step 7 of the loop says. The page redraws whenever the file changes, and the user can edit and save the file from it, so you and the user work on the one file. `render --page` writes a page to send to someone else, and the bare SVG is for putting into something else, such as a README; neither is for showing.
15
15
 
16
16
  ## Check it is installed, and the same version as this skill
17
17
 
18
- This skill teaches reladraw 0.26.1. Once per session, before the first render, run:
18
+ This skill teaches reladraw 0.28.0. Once per session, before the first render, run:
19
19
 
20
20
  ```
21
21
  reladraw --version
@@ -29,7 +29,7 @@ If `reladraw` isn't installed, `npx reladraw` works without installing, and `npm
29
29
 
30
30
  ## The loop
31
31
 
32
- 1. Write a `.reladraw` file. Where it goes depends on what it is for. A diagram that belongs to the project, one the user asked to keep or that a README or document will show, goes where they say, or beside what it describes. A diagram drawn only to show the user something, such as an explanation or a sketch of a change, goes in a folder of its own outside the project, such as `~/.cache/reladraw/` or the system's temporary folder, named after what it shows, so the project isn't littered. Nothing is lost if that folder is cleared: the page in step 7 carries its source and saves it.
32
+ 1. Write a `.reladraw` file. Where it goes depends on what it is for. A diagram that belongs to the project, one the user asked to keep or that a README or document will show, goes where they say, or beside what it describes. A diagram drawn only to show the user something, such as an explanation or a sketch of a change, goes in a folder of its own outside the project, such as `~/.cache/reladraw/` or the system's temporary folder, named after what it shows, so the project isn't littered. Tell the user where it is, so they can move it somewhere lasting if they want to keep it.
33
33
  2. `reladraw check diagram.reladraw`. It prints errors and findings and writes nothing.
34
34
  3. If it fails, the **error** names the line and what to write instead. Fix and re-run.
35
35
  4. If it succeeds, read the **findings** it printed. Each is one line saying what may not read as meant, where, and how much:
@@ -41,7 +41,9 @@ diagram.reladraw:9: warning(edge-node-overlap): line api -> db crosses node cach
41
41
 
42
42
  5. Fix each finding in the source, by placing something differently or saying where a line goes, and re-run until there are none.
43
43
  6. `reladraw format diagram.reladraw` before handing the file over. It lines statements up in columns and evens out spacing, by the project's `.reladraw-format` if there is one, and changes nothing about what the file draws. A file you wrote then reads like one the user's project already has.
44
- 7. Finish by showing the user the picture. Give the diagram a title with `diagram title: "…"`, which heads the page, then run `reladraw render diagram.reladraw --page`. It writes `diagram.html` beside the source, a page in the diagram's own colors that pans, zooms, goes full screen, and saves itself, its source, an SVG or a PNG. For a diagram kept in the project, put the page in the outside folder of step 1 instead, with `-o ~/.cache/reladraw/diagram.html`, so it isn't committed by mistake. Write an SVG only when something will use it, such as a README picture: `reladraw render diagram.reladraw` writes `diagram.svg` beside the source. Open the page in the default browser: `xdg-open diagram.html` on Linux, `open diagram.html` on macOS, `start diagram.html` on Windows. Show the page rather than the bare SVG, and don't build a page of your own around it. Open it once per diagram; after later edits, render the page again and tell the user to reload it. Don't open it when there is no display to open it on, as in a remote or headless session, or when the user has said not to; give them the page's path instead.
44
+ 7. Finish by showing the user the picture. Give the diagram a title with `diagram title: "…"`, which heads the page, then run `reladraw serve diagram.reladraw` from the folder that holds the file (`cd` there first for a diagram in the outside folder of step 1), in the background, since it runs until stopped. It opens the page in the default browser: the diagram in its own colors, panning, zooming and going full screen, with an editor (Edit, or `e`) whose Save writes the file. Serve each diagram once: the page redraws by itself when you change the file, so there is nothing to tell the user to reload. Serving a second file from the same folder opens its page on the server already running and returns at once. Don't build a page of your own around it. When there is no display to open it on, as in a remote or headless session, or when the user has said not to open it, add `--no-open` and give them the address it prints. When the user wants a page to send to someone, `reladraw render diagram.reladraw --page` writes `diagram.html`, one file that needs nothing running; put it in the outside folder of step 1 with `-o` for a diagram kept in the project, so it isn't committed by mistake. Write an SVG only when something will use it, such as a README picture: `reladraw render diagram.reladraw` writes `diagram.svg` beside the source.
45
+
46
+ **The user edits the file too.** On the served page the user can change the diagram and save it, so read the file again before every change you make to it, even one you wrote a minute ago; what you remember may no longer be what is there. After each change, describe it in a few words, which the page's Versions menu shows as yours: `reladraw note diagram.reladraw "moved the cache under the API"`, run from the folder you served. With no server running it notes nothing and says so, which is fine.
45
47
 
46
48
  A file with no errors and no findings has nothing on top of anything. That is still not the same as a good picture: re-read your source to confirm the arrangement says what you meant, and for a large diagram tell the user you have checked the findings but not seen the render.
47
49
 
@@ -193,7 +195,7 @@ Owns the order records. See [the docs](https://example.com/orders).
193
195
  """
194
196
  ```
195
197
 
196
- **Notes about a thing go in its description, not in a box beside it.** A description is shown when the thing is selected on the `--page` page, and as hover text in an SVG; it is never drawn, so it can run to paragraphs and lists in Markdown. Write a short one on the statement, and a long one with `description for`, after the diagram's statements, so it doesn't crowd them. When several things share one text, name them all after `for`.
198
+ **Notes about a thing go in its description, not in a box beside it.** A description is shown when the thing is selected on the diagram's page, and as hover text in an SVG; it is never drawn, so it can run to paragraphs and lists in Markdown. Write a short one on the statement, and a long one with `description for`, after the diagram's statements, so it doesn't crowd them. When several things share one text, name them all after `for`.
197
199
 
198
200
  **Offer links; don't add them unasked.** When the things in a diagram have real web addresses, such as the files of a pull request on GitHub, end your reply with one line offering to link each node to its file. Never guess an address, and don't link to files on the local machine.
199
201
 
@@ -1,4 +1,4 @@
1
- # Syntax reference — 0.26.1
1
+ # Syntax reference — 0.28.0
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
 
@@ -1021,7 +1021,7 @@ guide node column "" below a width: 10 height: 20
1021
1021
 
1022
1022
  **A guide does everything its kind does except draw.** It places things, holds children, is placed against, and shapes the lines through it. A `guide node` container's children are drawn; only its box and title aren't. That gives a reserved empty space, a column to align against, or a group with no outline.
1023
1023
 
1024
- Guides are shown by whoever renders the file, not by the file: `--guides` on the command line, the Guides box in the playground. A file that explains its own construction, such as a tutorial, may say `diagram guides: show`. Shown guides are dashed, in the theme's secondary color, and unfilled. Their look changes per kind with `default guide node`, `default guide edge`, `default guide point` and `default guide region`; a bare `default guide` is refused, listing the four.
1024
+ Guides are shown by whoever renders the file, not by the file: `--guides` on the command line, the Guides switch in View on the page and in the playground. A file that explains its own construction, such as a tutorial, may say `diagram guides: show`. Shown guides are dashed, in the theme's secondary color, and unfilled. Their look changes per kind with `default guide node`, `default guide edge`, `default guide point` and `default guide region`; a bare `default guide` is refused, listing the four.
1025
1025
 
1026
1026
  A container styled with no border is different: the same picture with guides hidden, but showing guides never reveals it. A guide box draws nothing, so it is left out of the overlap and overflow findings.
1027
1027
 
@@ -1257,7 +1257,7 @@ The file and line of the statement at fault, `warning` in a fixed spot, the kind
1257
1257
 
1258
1258
  Kinds are turned on or off by name, in the file or on the command line: `diagram checks: (edge-crossings: on, crowded-edge-ends: off)`, or `--checks "edge-crossings: on"`. A kind not mentioned keeps its default. A deliberate overlap is stated on the thing itself (`overlap: allow`), not turned off for the whole file.
1259
1259
 
1260
- In the playground, where you are looking at the picture, checks run only when you press Check. The findings are listed under the diagram, apart from errors, and clicking one selects its line.
1260
+ On the page and in the playground, the findings are listed in the side panel and redone as you type; an error that stops the diagram drawing heads the list. Clicking a finding lights what its statement drew, and, with the source shown, selects its line.
1261
1261
 
1262
1262
  ## The command line
1263
1263
 
@@ -1278,6 +1278,8 @@ reladraw check diagram.reladraw
1278
1278
  | `--no-checks` | print no findings; errors still print |
1279
1279
  | `-v`, `--version` | print the version |
1280
1280
 
1281
+ `reladraw serve diagram.reladraw` opens a page for the diagram that redraws whenever the file changes and can edit and save it, `reladraw serve` with no file opens the playground on this machine, and `reladraw note` describes a change made to a served file; see [A page that follows its file](#a-page-that-follows-its-file).
1282
+
1281
1283
  `reladraw install-skill` installs the agent skill that came with this version of reladraw, for every project, by running `npx skills add` on it with `--copy`. `--claude` installs it in `~/.claude/skills`, `--agents` in `~/.agents/skills` (Codex and others), and both may be given; with neither, it asks, or, with no terminal to ask in, refuses and names them. For any other agent it prints the `skills` command to run.
1282
1284
 
1283
1285
  The output is a standalone SVG: every picture is drawn into it as path data, never from a font or a linked file. A web page can draw a diagram in place with `<reladraw-diagram>`; see "In a web page" in the README.
@@ -1288,13 +1290,47 @@ The output is a standalone SVG: every picture is drawn into it as path data, nev
1288
1290
  reladraw render arch.reladraw --page
1289
1291
  ```
1290
1292
 
1291
- `--page` writes `arch.html`: one self-contained file, for opening in a browser, attaching or committing, that needs nothing running and fetches nothing. The page is in the diagram's own colors, so a dark diagram doesn't sit on a white page, and it is headed with `diagram title:`, or the file's name when there is none. Under the title it says which file it was drawn from and when, such as "drawn from arch.reladraw, 2026-11-05 14:32": the page is a snapshot of the file, and is behind it once the file is edited, until it is rendered again. Drag to pan, or press `g` to grab the diagram and pan it with the arrow keys or `h` `j` `k` `l` (Shift for bigger steps, `g` or Escape to let go); scroll, pinch or double-click to zoom; Fit shows the whole diagram and 100% returns it to its own scale. The zoom is always shown, with "Fit" beside it while the whole diagram is in view. There is a full-screen button. The Save menu saves the page itself, as it was written rather than at its current zoom; the `.reladraw` source it was drawn from; or the picture as an SVG or a PNG, as `render` would draw it; or copies the SVG. Each is named after the source file: `arch.html`, `arch.reladraw`, `arch.svg`, `arch.png`. In Chrome and Edge it asks where to save; other browsers put the file with their downloads. The findings are listed beside it in a panel that folds away, and clicking one lights up what its line drew. A box's or a line's name shows under the pointer. The theme picker draws the diagram in another theme, as `--theme` would, keeping the view and the selection; a page or text color the file states holds in every theme, and Save SVG, PNG and Copy SVG take the theme shown. It starts on "Diagram's theme", the one the file names (or dark), which follows the file when it is rendered again. A theme picked by name is the reader's: it holds on every reladraw page in that browser, whatever the file says, until "Diagram's theme" is picked again.
1293
+ `--page` writes `arch.html`: one self-contained file, for opening in a browser, attaching or committing, that needs nothing running and fetches nothing. The page is in the diagram's own colors, so a dark diagram doesn't sit on a white page, and it is headed with `diagram title:`, or the file's name when there is none. Under the title it says which file it was drawn from and when, such as "drawn from arch.reladraw, 2026-11-05 14:32": the page is a snapshot of the file, and is behind it once the file is edited, until it is rendered again. Drag to pan, or press `g` to grab the diagram and pan it with the arrow keys or `h` `j` `k` `l` (Shift for bigger steps, `g` or Escape to let go); scroll, pinch or double-click to zoom; Fit shows the whole diagram and 100% returns it to its own scale. The zoom is always shown, with "Fit" beside it while the whole diagram is in view. There is a full-screen button. The Export menu saves the page itself, as it was written rather than at its current zoom; the `.reladraw` source it was drawn from; or the picture as an SVG or a PNG, as `render` would draw it; or copies the SVG. Each is named after the source file: `arch.html`, `arch.reladraw`, `arch.svg`, `arch.png`. In Chrome and Edge it asks where to save; other browsers put the file with their downloads. The findings are listed beside it, and clicking one lights up what its line drew. A box's or a line's name shows under the pointer.
1294
+
1295
+ **The View menu** holds the page's settings, each row a switch that says on or off. **Theme** opens a list of themes, and draws the diagram in the one picked, as `--theme` would, keeping the view and the selection; a page or text color the file states holds in every theme. It starts on "Diagram's theme", the one the file names (or dark), which follows the file when it is rendered again. A theme picked by name is the reader's: it holds on every reladraw page in that browser, whatever the file says, until "Diagram's theme" is picked again. **Side panel** shows or hides the panel beside the drawing, which then stays hidden whatever is selected. **Auto-hide panel** shows it only while something is selected or the findings are open, and the findings start folded. Both are remembered by the browser for every page. **Findings**, with their count, open or fold the findings in the panel. **Guides**, with their count, draws the [guides](#guides) as `--guides` does; it starts as the file or `--guides` says, and a change lasts for that page only. Save SVG, PNG and Copy SVG take the theme and the guides as shown.
1296
+
1297
+ **From the keyboard**, `m` reaches the bar: it is ringed, each control shows its letter, and a strip under it names where the keys are and which keys work there. `v` opens View, `x` opens Export, and `f` goes full screen. In a menu a row's letter does what the row does, and the menu stays open, so several can be changed in turn: in View, `t` theme, `p` side panel, `a` auto-hide, `f` findings and `g` guides; in Export, `p` this page, `r` the source, `s` SVG, `n` PNG and `c` Copy SVG. The arrow keys and Enter work too. In the theme list the arrows draw the diagram in each theme as they reach it, and Enter keeps the one reached. Backspace steps back one level at a time: from the theme list to View, from a menu to the bar, from the bar to the diagram, and then lets go of a grab, a lit finding and the selection in turn. Escape goes straight back to the plain diagram from anywhere: every menu closes, a theme tried and not kept is dropped, and a grab, a lit finding and the selection are all cleared. With the menus closed, `p` shows or hides the side panel and `f` goes full screen; `+` `-` `0` `1` zoom at every level.
1298
+
1299
+ **A click on a box or a line selects it**, and never follows a link. The selection is amber; what feeds it is green and what it feeds is red, the lines dashed and moving the way they run; the rest dims. A line runs from the end without an arrowhead when only one end has one, and otherwise from the end written first. The panel beside the drawing names the selection and lists its links, each with its badge, and the boxes it comes from and goes to; a link opens in a new tab, and a box selects it. One line out lights by default, and the panel's button lights everything upstream and downstream. Its description, if it has one, comes last ([Descriptions](#descriptions)). A box with links underlines its text under the pointer. A click on the background, Escape or Backspace clears the selection.
1300
+
1301
+ **Selecting from the keyboard**: `s` puts a letter on every box and line, and typing a letter selects that thing. Things in view get the one-letter labels; past 26, the rest take two letters. `/` starts a filter that narrows what gets a letter, live as it is typed: a plain word matches a box's or a line's text, `is:node`, `is:edge` and `is:container` match a kind, and `style:synced` matches what wears that style. Words combine, so `/is:edge rclone` letters only the lines whose text says rclone. Enter ends the filter and the letters pick again, or selects the match at once when there is only one. With something selected, `n` letters what is one line away (from a box, its lines and the boxes at their other ends; from a line, its two ends), `i` letters the boxes inside the selected box and the box it sits in, and `l` letters its links, which a letter opens in a new tab: on the side panel's rows when the panel is shown, and in a small list beside the selection when it is hidden. Backspace steps back a letter, then out of the filter, then out; Escape clears everything. A picked thing out of view is brought into it.
1302
+
1303
+ Keys: `+` and `-` zoom, `0` fits, `1` is actual size, `f` is full screen, `p` shows or hides the side panel, `s` and `/` select, `n` `i` `l` step from the selection, Escape clears the selection.
1304
+
1305
+ ### A page that follows its file
1306
+
1307
+ ```
1308
+ reladraw serve arch.reladraw
1309
+ ```
1310
+
1311
+ `serve` opens the same page in the browser, served from this machine and tied to the file: whenever the file changes on disk, whoever changed it, the page draws it again, keeping the view, the theme and the selection. Under the title it says the page is live, and when the file was last read or changed. A file that stops drawing keeps the last picture that drew, with the error at the head of the findings, and draws again as soon as the file does.
1312
+
1313
+ **Edit** (or `e`) shows the source beside the picture, colored as in the playground, with the cheatsheet under it, and the picture redraws as you type. The divider between them can be dragged. **Save** (or ⌘S, Ctrl+S) writes the file, and nothing else does; a dot beside the file's name means there is text the file doesn't have. **Format** lays the source out as `reladraw format` would, with the nearest `.reladraw-format`.
1314
+
1315
+ If the file changes on disk while the editor holds unsaved text, the text stays, and a strip says the file changed, by whom when that is known, with **Load it** to replace the text with the file's and **Keep mine** to carry on. Saving over a change made since you started editing asks first.
1292
1316
 
1293
- The side panel can be hidden with the Panel button or `p`, and then stays hidden whatever is selected. With Auto-hide ticked it shows only while something is selected or the findings are open, and the findings start folded. Both choices are remembered by the browser for every page.
1317
+ **Versions** (or `o` from the bar) lists the file's versions since the server started, newest first: each one saved from the page, each change on disk, and each change an agent described with `reladraw note`, with its note. Picking one puts it in the editor as unsaved text, to save if you want it back. They are kept only while the server runs.
1294
1318
 
1295
- **A click on a box or a line selects it**, and never follows a link. The selection is amber; what feeds it is green and what it feeds is red, the lines dashed and moving the way they run; the rest dims. A line runs from the end without an arrowhead when only one end has one, and otherwise from the end written first. The panel beside the drawing names the selection and lists its links, each with its badge, and the boxes it comes from and goes to; a link opens in a new tab, and a box selects it. One line out lights by default, and the panel's button lights everything upstream and downstream. Its description, if it has one, comes last ([Descriptions](#descriptions)). A box with links underlines its text under the pointer. A click on the background or Escape clears the selection.
1319
+ One server serves the folder it was started in, and only `.reladraw` files inside it, to this machine only. Serving another file from that folder opens its page on the server already running and returns at once. Ctrl-C stops the server, and an open page then says so; it follows the file again when a server is started in the same folder. `--no-open` prints the page's address instead of opening it.
1296
1320
 
1297
- Keys: `+` and `-` zoom, `0` fits, `1` is actual size, `f` is full screen, `p` shows or hides the side panel, Escape clears the selection.
1321
+ **Export ▾ ▸ This page** saves the diagram as `reladraw render --page` would write it: a page to send, not one tied to the file.
1322
+
1323
+ ```
1324
+ reladraw serve
1325
+ ```
1326
+
1327
+ With no file, `serve` opens the playground, served from this machine: the source shown, the examples, Open…, and the format settings, with your text kept in the browser. Its first **Save** asks for a path inside the folder, such as `docs/flow.reladraw`, and asks before replacing a file already there. From then on the page is tied to that file, as if `serve` had been given it.
1328
+
1329
+ ```
1330
+ reladraw note arch.reladraw "moved the cache under the API"
1331
+ ```
1332
+
1333
+ `note` describes the change just made to a served file, for its Versions list, which shows it as an agent's. With no server serving the folder, it notes nothing, says so, and succeeds.
1298
1334
 
1299
1335
  ### Formatting
1300
1336
 
@@ -1416,6 +1452,18 @@ Designed and absent from the code.
1416
1452
 
1417
1453
  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.
1418
1454
 
1455
+ **0.28.0**
1456
+
1457
+ - **`reladraw serve` opens a page that follows its file.** The page redraws whenever the file changes on disk, edits it beside the picture, and writes it on Save or ⌘S. Unsaved text is never replaced by a change on disk without asking, and a Versions menu keeps the file's recent versions, saved from the page, changed on disk, or described by an agent with **`reladraw note`**. One server serves a folder. See [A page that follows its file](#a-page-that-follows-its-file).
1458
+ - **`reladraw serve` with no file opens the playground** on this machine; its first Save names a file in the folder, and the page then follows that file.
1459
+ - **The playground is the page.** It gains selection, the side panel, View and the keys. The Guides box and the theme picker are now in View, and the theme picked there no longer writes a `diagram theme:` line into the source. Check is gone: the findings are in the side panel and redone as you type. Examples, Open…, Save…, Format settings, the cheatsheet and the text kept in your browser are as they were.
1460
+ - **The page's Save menu is now Export**, opened by `x` from the bar, so that Save can mean writing the file on a served page. On a page with an editor, Export's This page saves a snapshot, as `render --page` writes it.
1461
+
1462
+ **0.27.0**
1463
+
1464
+ - **The `--page` page selects from the keyboard.** `s` puts a letter on every box and line and a letter selects it; `/` filters what gets a letter by text, `is:node`, `is:edge`, `is:container` or `style:`; with something selected, `n` letters what is one line away, `i` what is inside it and the box it sits in, and `l` its links. See [A page for looking at a diagram](#a-page-for-looking-at-a-diagram).
1465
+ - **The `--page` page has a View menu**, and its bar keeps only the zoom, Full screen, Save and View. The theme, the side panel, auto-hide and the findings moved into View, each a switch that says on or off, and View gained **Guides**, which draws the diagram's guides as `--guides` does. **`m` reaches the menus from the keyboard**: each control shows its letter, a strip names where the keys are, Backspace steps back one level and Escape goes straight back to the plain diagram, clearing the selection too. In the theme list the arrow keys try each theme on the diagram, and Enter keeps one. See [A page for looking at a diagram](#a-page-for-looking-at-a-diagram).
1466
+
1419
1467
  **0.26.1**
1420
1468
 
1421
1469
  - `h` `j` `k` `l` now pan only while the diagram is grabbed with `g`, as the arrow keys do, on the `--page` page and in the playground. In 0.26.0 they panned without a grab.
package/README.md CHANGED
@@ -47,7 +47,7 @@ npm install -g reladraw
47
47
  reladraw render diagram.reladraw -o diagram.svg
48
48
  ```
49
49
 
50
- `reladraw check diagram.reladraw` prints the warnings without writing a picture, and `reladraw format diagram.reladraw` lines its statements up in columns. `reladraw render diagram.reladraw --page` writes a page for looking at it in a browser, with pan, zoom, full screen and the warnings beside it.
50
+ `reladraw check diagram.reladraw` prints the warnings without writing a picture, and `reladraw format diagram.reladraw` lines its statements up in columns. `reladraw serve diagram.reladraw` opens it in a browser on a page with pan, zoom, full screen and the warnings beside it, which redraws whenever the file changes and can edit and save it, so you and an agent can work on the one file. `reladraw serve` with no file opens the playground on your machine, and its first Save makes the file. `reladraw render diagram.reladraw --page` writes the same page as one file to send to someone.
51
51
 
52
52
  Or from a clone, which also gets you the examples:
53
53
 
@@ -94,7 +94,7 @@ To install the skill from the main branch instead, which can run ahead of the re
94
94
 
95
95
  ## Status
96
96
 
97
- Version 0.26.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.
97
+ Version 0.28.0. 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.
98
98
 
99
99
  ## License
100
100
 
package/SYNTAX.md CHANGED
@@ -1,4 +1,4 @@
1
- # Syntax reference — 0.26.1
1
+ # Syntax reference — 0.28.0
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
 
@@ -1021,7 +1021,7 @@ guide node column "" below a width: 10 height: 20
1021
1021
 
1022
1022
  **A guide does everything its kind does except draw.** It places things, holds children, is placed against, and shapes the lines through it. A `guide node` container's children are drawn; only its box and title aren't. That gives a reserved empty space, a column to align against, or a group with no outline.
1023
1023
 
1024
- Guides are shown by whoever renders the file, not by the file: `--guides` on the command line, the Guides box in the playground. A file that explains its own construction, such as a tutorial, may say `diagram guides: show`. Shown guides are dashed, in the theme's secondary color, and unfilled. Their look changes per kind with `default guide node`, `default guide edge`, `default guide point` and `default guide region`; a bare `default guide` is refused, listing the four.
1024
+ Guides are shown by whoever renders the file, not by the file: `--guides` on the command line, the Guides switch in View on the page and in the playground. A file that explains its own construction, such as a tutorial, may say `diagram guides: show`. Shown guides are dashed, in the theme's secondary color, and unfilled. Their look changes per kind with `default guide node`, `default guide edge`, `default guide point` and `default guide region`; a bare `default guide` is refused, listing the four.
1025
1025
 
1026
1026
  A container styled with no border is different: the same picture with guides hidden, but showing guides never reveals it. A guide box draws nothing, so it is left out of the overlap and overflow findings.
1027
1027
 
@@ -1257,7 +1257,7 @@ The file and line of the statement at fault, `warning` in a fixed spot, the kind
1257
1257
 
1258
1258
  Kinds are turned on or off by name, in the file or on the command line: `diagram checks: (edge-crossings: on, crowded-edge-ends: off)`, or `--checks "edge-crossings: on"`. A kind not mentioned keeps its default. A deliberate overlap is stated on the thing itself (`overlap: allow`), not turned off for the whole file.
1259
1259
 
1260
- In the playground, where you are looking at the picture, checks run only when you press Check. The findings are listed under the diagram, apart from errors, and clicking one selects its line.
1260
+ On the page and in the playground, the findings are listed in the side panel and redone as you type; an error that stops the diagram drawing heads the list. Clicking a finding lights what its statement drew, and, with the source shown, selects its line.
1261
1261
 
1262
1262
  ## The command line
1263
1263
 
@@ -1278,6 +1278,8 @@ reladraw check diagram.reladraw
1278
1278
  | `--no-checks` | print no findings; errors still print |
1279
1279
  | `-v`, `--version` | print the version |
1280
1280
 
1281
+ `reladraw serve diagram.reladraw` opens a page for the diagram that redraws whenever the file changes and can edit and save it, `reladraw serve` with no file opens the playground on this machine, and `reladraw note` describes a change made to a served file; see [A page that follows its file](#a-page-that-follows-its-file).
1282
+
1281
1283
  `reladraw install-skill` installs the agent skill that came with this version of reladraw, for every project, by running `npx skills add` on it with `--copy`. `--claude` installs it in `~/.claude/skills`, `--agents` in `~/.agents/skills` (Codex and others), and both may be given; with neither, it asks, or, with no terminal to ask in, refuses and names them. For any other agent it prints the `skills` command to run.
1282
1284
 
1283
1285
  The output is a standalone SVG: every picture is drawn into it as path data, never from a font or a linked file. A web page can draw a diagram in place with `<reladraw-diagram>`; see "In a web page" in the README.
@@ -1288,13 +1290,47 @@ The output is a standalone SVG: every picture is drawn into it as path data, nev
1288
1290
  reladraw render arch.reladraw --page
1289
1291
  ```
1290
1292
 
1291
- `--page` writes `arch.html`: one self-contained file, for opening in a browser, attaching or committing, that needs nothing running and fetches nothing. The page is in the diagram's own colors, so a dark diagram doesn't sit on a white page, and it is headed with `diagram title:`, or the file's name when there is none. Under the title it says which file it was drawn from and when, such as "drawn from arch.reladraw, 2026-11-05 14:32": the page is a snapshot of the file, and is behind it once the file is edited, until it is rendered again. Drag to pan, or press `g` to grab the diagram and pan it with the arrow keys or `h` `j` `k` `l` (Shift for bigger steps, `g` or Escape to let go); scroll, pinch or double-click to zoom; Fit shows the whole diagram and 100% returns it to its own scale. The zoom is always shown, with "Fit" beside it while the whole diagram is in view. There is a full-screen button. The Save menu saves the page itself, as it was written rather than at its current zoom; the `.reladraw` source it was drawn from; or the picture as an SVG or a PNG, as `render` would draw it; or copies the SVG. Each is named after the source file: `arch.html`, `arch.reladraw`, `arch.svg`, `arch.png`. In Chrome and Edge it asks where to save; other browsers put the file with their downloads. The findings are listed beside it in a panel that folds away, and clicking one lights up what its line drew. A box's or a line's name shows under the pointer. The theme picker draws the diagram in another theme, as `--theme` would, keeping the view and the selection; a page or text color the file states holds in every theme, and Save SVG, PNG and Copy SVG take the theme shown. It starts on "Diagram's theme", the one the file names (or dark), which follows the file when it is rendered again. A theme picked by name is the reader's: it holds on every reladraw page in that browser, whatever the file says, until "Diagram's theme" is picked again.
1293
+ `--page` writes `arch.html`: one self-contained file, for opening in a browser, attaching or committing, that needs nothing running and fetches nothing. The page is in the diagram's own colors, so a dark diagram doesn't sit on a white page, and it is headed with `diagram title:`, or the file's name when there is none. Under the title it says which file it was drawn from and when, such as "drawn from arch.reladraw, 2026-11-05 14:32": the page is a snapshot of the file, and is behind it once the file is edited, until it is rendered again. Drag to pan, or press `g` to grab the diagram and pan it with the arrow keys or `h` `j` `k` `l` (Shift for bigger steps, `g` or Escape to let go); scroll, pinch or double-click to zoom; Fit shows the whole diagram and 100% returns it to its own scale. The zoom is always shown, with "Fit" beside it while the whole diagram is in view. There is a full-screen button. The Export menu saves the page itself, as it was written rather than at its current zoom; the `.reladraw` source it was drawn from; or the picture as an SVG or a PNG, as `render` would draw it; or copies the SVG. Each is named after the source file: `arch.html`, `arch.reladraw`, `arch.svg`, `arch.png`. In Chrome and Edge it asks where to save; other browsers put the file with their downloads. The findings are listed beside it, and clicking one lights up what its line drew. A box's or a line's name shows under the pointer.
1294
+
1295
+ **The View menu** holds the page's settings, each row a switch that says on or off. **Theme** opens a list of themes, and draws the diagram in the one picked, as `--theme` would, keeping the view and the selection; a page or text color the file states holds in every theme. It starts on "Diagram's theme", the one the file names (or dark), which follows the file when it is rendered again. A theme picked by name is the reader's: it holds on every reladraw page in that browser, whatever the file says, until "Diagram's theme" is picked again. **Side panel** shows or hides the panel beside the drawing, which then stays hidden whatever is selected. **Auto-hide panel** shows it only while something is selected or the findings are open, and the findings start folded. Both are remembered by the browser for every page. **Findings**, with their count, open or fold the findings in the panel. **Guides**, with their count, draws the [guides](#guides) as `--guides` does; it starts as the file or `--guides` says, and a change lasts for that page only. Save SVG, PNG and Copy SVG take the theme and the guides as shown.
1296
+
1297
+ **From the keyboard**, `m` reaches the bar: it is ringed, each control shows its letter, and a strip under it names where the keys are and which keys work there. `v` opens View, `x` opens Export, and `f` goes full screen. In a menu a row's letter does what the row does, and the menu stays open, so several can be changed in turn: in View, `t` theme, `p` side panel, `a` auto-hide, `f` findings and `g` guides; in Export, `p` this page, `r` the source, `s` SVG, `n` PNG and `c` Copy SVG. The arrow keys and Enter work too. In the theme list the arrows draw the diagram in each theme as they reach it, and Enter keeps the one reached. Backspace steps back one level at a time: from the theme list to View, from a menu to the bar, from the bar to the diagram, and then lets go of a grab, a lit finding and the selection in turn. Escape goes straight back to the plain diagram from anywhere: every menu closes, a theme tried and not kept is dropped, and a grab, a lit finding and the selection are all cleared. With the menus closed, `p` shows or hides the side panel and `f` goes full screen; `+` `-` `0` `1` zoom at every level.
1298
+
1299
+ **A click on a box or a line selects it**, and never follows a link. The selection is amber; what feeds it is green and what it feeds is red, the lines dashed and moving the way they run; the rest dims. A line runs from the end without an arrowhead when only one end has one, and otherwise from the end written first. The panel beside the drawing names the selection and lists its links, each with its badge, and the boxes it comes from and goes to; a link opens in a new tab, and a box selects it. One line out lights by default, and the panel's button lights everything upstream and downstream. Its description, if it has one, comes last ([Descriptions](#descriptions)). A box with links underlines its text under the pointer. A click on the background, Escape or Backspace clears the selection.
1300
+
1301
+ **Selecting from the keyboard**: `s` puts a letter on every box and line, and typing a letter selects that thing. Things in view get the one-letter labels; past 26, the rest take two letters. `/` starts a filter that narrows what gets a letter, live as it is typed: a plain word matches a box's or a line's text, `is:node`, `is:edge` and `is:container` match a kind, and `style:synced` matches what wears that style. Words combine, so `/is:edge rclone` letters only the lines whose text says rclone. Enter ends the filter and the letters pick again, or selects the match at once when there is only one. With something selected, `n` letters what is one line away (from a box, its lines and the boxes at their other ends; from a line, its two ends), `i` letters the boxes inside the selected box and the box it sits in, and `l` letters its links, which a letter opens in a new tab: on the side panel's rows when the panel is shown, and in a small list beside the selection when it is hidden. Backspace steps back a letter, then out of the filter, then out; Escape clears everything. A picked thing out of view is brought into it.
1302
+
1303
+ Keys: `+` and `-` zoom, `0` fits, `1` is actual size, `f` is full screen, `p` shows or hides the side panel, `s` and `/` select, `n` `i` `l` step from the selection, Escape clears the selection.
1304
+
1305
+ ### A page that follows its file
1306
+
1307
+ ```
1308
+ reladraw serve arch.reladraw
1309
+ ```
1310
+
1311
+ `serve` opens the same page in the browser, served from this machine and tied to the file: whenever the file changes on disk, whoever changed it, the page draws it again, keeping the view, the theme and the selection. Under the title it says the page is live, and when the file was last read or changed. A file that stops drawing keeps the last picture that drew, with the error at the head of the findings, and draws again as soon as the file does.
1312
+
1313
+ **Edit** (or `e`) shows the source beside the picture, colored as in the playground, with the cheatsheet under it, and the picture redraws as you type. The divider between them can be dragged. **Save** (or ⌘S, Ctrl+S) writes the file, and nothing else does; a dot beside the file's name means there is text the file doesn't have. **Format** lays the source out as `reladraw format` would, with the nearest `.reladraw-format`.
1314
+
1315
+ If the file changes on disk while the editor holds unsaved text, the text stays, and a strip says the file changed, by whom when that is known, with **Load it** to replace the text with the file's and **Keep mine** to carry on. Saving over a change made since you started editing asks first.
1292
1316
 
1293
- The side panel can be hidden with the Panel button or `p`, and then stays hidden whatever is selected. With Auto-hide ticked it shows only while something is selected or the findings are open, and the findings start folded. Both choices are remembered by the browser for every page.
1317
+ **Versions** (or `o` from the bar) lists the file's versions since the server started, newest first: each one saved from the page, each change on disk, and each change an agent described with `reladraw note`, with its note. Picking one puts it in the editor as unsaved text, to save if you want it back. They are kept only while the server runs.
1294
1318
 
1295
- **A click on a box or a line selects it**, and never follows a link. The selection is amber; what feeds it is green and what it feeds is red, the lines dashed and moving the way they run; the rest dims. A line runs from the end without an arrowhead when only one end has one, and otherwise from the end written first. The panel beside the drawing names the selection and lists its links, each with its badge, and the boxes it comes from and goes to; a link opens in a new tab, and a box selects it. One line out lights by default, and the panel's button lights everything upstream and downstream. Its description, if it has one, comes last ([Descriptions](#descriptions)). A box with links underlines its text under the pointer. A click on the background or Escape clears the selection.
1319
+ One server serves the folder it was started in, and only `.reladraw` files inside it, to this machine only. Serving another file from that folder opens its page on the server already running and returns at once. Ctrl-C stops the server, and an open page then says so; it follows the file again when a server is started in the same folder. `--no-open` prints the page's address instead of opening it.
1296
1320
 
1297
- Keys: `+` and `-` zoom, `0` fits, `1` is actual size, `f` is full screen, `p` shows or hides the side panel, Escape clears the selection.
1321
+ **Export ▾ ▸ This page** saves the diagram as `reladraw render --page` would write it: a page to send, not one tied to the file.
1322
+
1323
+ ```
1324
+ reladraw serve
1325
+ ```
1326
+
1327
+ With no file, `serve` opens the playground, served from this machine: the source shown, the examples, Open…, and the format settings, with your text kept in the browser. Its first **Save** asks for a path inside the folder, such as `docs/flow.reladraw`, and asks before replacing a file already there. From then on the page is tied to that file, as if `serve` had been given it.
1328
+
1329
+ ```
1330
+ reladraw note arch.reladraw "moved the cache under the API"
1331
+ ```
1332
+
1333
+ `note` describes the change just made to a served file, for its Versions list, which shows it as an agent's. With no server serving the folder, it notes nothing, says so, and succeeds.
1298
1334
 
1299
1335
  ### Formatting
1300
1336
 
@@ -1416,6 +1452,18 @@ Designed and absent from the code.
1416
1452
 
1417
1453
  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.
1418
1454
 
1455
+ **0.28.0**
1456
+
1457
+ - **`reladraw serve` opens a page that follows its file.** The page redraws whenever the file changes on disk, edits it beside the picture, and writes it on Save or ⌘S. Unsaved text is never replaced by a change on disk without asking, and a Versions menu keeps the file's recent versions, saved from the page, changed on disk, or described by an agent with **`reladraw note`**. One server serves a folder. See [A page that follows its file](#a-page-that-follows-its-file).
1458
+ - **`reladraw serve` with no file opens the playground** on this machine; its first Save names a file in the folder, and the page then follows that file.
1459
+ - **The playground is the page.** It gains selection, the side panel, View and the keys. The Guides box and the theme picker are now in View, and the theme picked there no longer writes a `diagram theme:` line into the source. Check is gone: the findings are in the side panel and redone as you type. Examples, Open…, Save…, Format settings, the cheatsheet and the text kept in your browser are as they were.
1460
+ - **The page's Save menu is now Export**, opened by `x` from the bar, so that Save can mean writing the file on a served page. On a page with an editor, Export's This page saves a snapshot, as `render --page` writes it.
1461
+
1462
+ **0.27.0**
1463
+
1464
+ - **The `--page` page selects from the keyboard.** `s` puts a letter on every box and line and a letter selects it; `/` filters what gets a letter by text, `is:node`, `is:edge`, `is:container` or `style:`; with something selected, `n` letters what is one line away, `i` what is inside it and the box it sits in, and `l` its links. See [A page for looking at a diagram](#a-page-for-looking-at-a-diagram).
1465
+ - **The `--page` page has a View menu**, and its bar keeps only the zoom, Full screen, Save and View. The theme, the side panel, auto-hide and the findings moved into View, each a switch that says on or off, and View gained **Guides**, which draws the diagram's guides as `--guides` does. **`m` reaches the menus from the keyboard**: each control shows its letter, a strip names where the keys are, Backspace steps back one level and Escape goes straight back to the plain diagram, clearing the selection too. In the theme list the arrow keys try each theme on the diagram, and Enter keeps one. See [A page for looking at a diagram](#a-page-for-looking-at-a-diagram).
1466
+
1419
1467
  **0.26.1**
1420
1468
 
1421
1469
  - `h` `j` `k` `l` now pan only while the diagram is grabbed with `g`, as the arrow keys do, on the `--page` page and in the playground. In 0.26.0 they panned without a grab.
package/dist/cli.js CHANGED
@@ -10,6 +10,7 @@ import { format } from './format.js';
10
10
  import { DEFAULT_FORMAT, readFormatSettings, SETTINGS_FILE, settingsFileText } from './format-settings.js';
11
11
  import { draw } from './index.js';
12
12
  import { drawPage } from './page.js';
13
+ import { noteCommand, serve } from './serve.js';
13
14
  import { THEME_NAMES, THEMES } from './themes.js';
14
15
  const USAGE = `reladraw — draw a diagram from stated placement
15
16
 
@@ -19,6 +20,8 @@ const USAGE = `reladraw — draw a diagram from stated placement
19
20
  reladraw format <input.reladraw>... [--check]
20
21
  reladraw format - [--check]
21
22
  reladraw format --init
23
+ reladraw serve [<input.reladraw>] [--no-open]
24
+ reladraw note <input.reladraw> "<what changed>"
22
25
  reladraw install-skill [--claude] [--agents]
23
26
 
24
27
  render draw the diagram to an SVG, and print any findings: places
@@ -35,6 +38,13 @@ const USAGE = `reladraw — draw a diagram from stated placement
35
38
  folder up.
36
39
  --init writes a .reladraw-format here, every setting at its
37
40
  default with what it does.
41
+ serve open a page for the diagram, served on this machine, that
42
+ redraws whenever the file changes, and edits and saves it. One
43
+ server serves the folder it was started in, until Ctrl-C;
44
+ serving another file there opens a page on it. --no-open
45
+ prints the address.
46
+ note describe the change just made to a served file; the page's
47
+ Versions menu shows it as the agent's, with the note.
38
48
  install-skill
39
49
  install the agent skill that came with this version of
40
50
  reladraw, so it teaches what this tool accepts, for every
@@ -60,7 +70,7 @@ const USAGE = `reladraw — draw a diagram from stated placement
60
70
  print the version.
61
71
  -h, --help print this.
62
72
  `;
63
- const COMMANDS = ['render', 'check', 'format', 'install-skill'];
73
+ const COMMANDS = ['render', 'check', 'format', 'serve', 'note', 'install-skill'];
64
74
  // The version of skills this was tried with, so a change there can't break it.
65
75
  const SKILLS_PACKAGE = 'skills@1.7.6';
66
76
  // The two places the skill is installed, each picked by its flag. skills
@@ -185,6 +195,10 @@ async function main(argv) {
185
195
  // install-skill reads its own flags, -h included.
186
196
  if (argv[0] === 'install-skill')
187
197
  return installSkill(argv.slice(1));
198
+ if (argv[0] === 'serve')
199
+ return serve(argv.slice(1));
200
+ if (argv[0] === 'note')
201
+ return noteCommand(argv.slice(1));
188
202
  if (argv.length === 0 || argv.includes('-h') || argv.includes('--help')) {
189
203
  process.stdout.write(USAGE);
190
204
  return argv.length === 0 ? 1 : 0;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The examples a page with no file offers, in the order its picker lists
3
+ * them: the hosted playground, and `reladraw serve` with no file. Every
4
+ * construct in the language is demonstrated by one of these files, so leaving
5
+ * them out makes the playground a five-line demo. The list is stated rather
6
+ * than globbed: the order is the point (the benchmark first, then placement,
7
+ * appearance, edges), and a new file under examples/ is not automatically
8
+ * something a stranger should be handed.
9
+ *
10
+ * Each file is listed under the name a stranger sees, with one short sentence
11
+ * shown above its preview. The file names are coverage and are referred to
12
+ * elsewhere; these are for someone who has not read the syntax yet, and say
13
+ * what the picture shows. Keep the sentence to one line: the file's own
14
+ * opening comment is there for anyone who wants more.
15
+ */
16
+ export declare const OFFERED: readonly (readonly [file: string, name: string, about: string])[];
17
+ /**
18
+ * The first thing a new visitor sees. No comments in it: every statement says
19
+ * where a node goes, which is the whole point, and a paragraph explaining that
20
+ * in advance only gets in the way.
21
+ */
22
+ export declare const START: {
23
+ name: string;
24
+ about: string;
25
+ source: string;
26
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The examples a page with no file offers, in the order its picker lists
3
+ * them: the hosted playground, and `reladraw serve` with no file. Every
4
+ * construct in the language is demonstrated by one of these files, so leaving
5
+ * them out makes the playground a five-line demo. The list is stated rather
6
+ * than globbed: the order is the point (the benchmark first, then placement,
7
+ * appearance, edges), and a new file under examples/ is not automatically
8
+ * something a stranger should be handed.
9
+ *
10
+ * Each file is listed under the name a stranger sees, with one short sentence
11
+ * shown above its preview. The file names are coverage and are referred to
12
+ * elsewhere; these are for someone who has not read the syntax yet, and say
13
+ * what the picture shows. Keep the sentence to one line: the file's own
14
+ * opening comment is there for anyone who wants more.
15
+ */
16
+ export const OFFERED = [
17
+ ['arch', 'architecture', "A home network's file sync and backups, redrawn from a draw.io diagram."],
18
+ ['regions', 'beside a group', 'A node placed against several others at once.'],
19
+ ['points', 'points and regions', 'Places said in words and worked out from named things; turn on Guides in View to see how.'],
20
+ ['gaps', 'gap sizes', 'Tight, wide and no gap, each on its own placement; a node has none of its own.'],
21
+ ['snug', 'exactly as far', 'A gap is the distance asked for, not a minimum.'],
22
+ ['contents', 'inside a container', 'How children line up in a container wider than they are.'],
23
+ ['shapes', 'shapes', 'The outlines a node can be drawn with, and the pictures it can be drawn as.'],
24
+ ['icons', 'icons', 'The seven icons, and the ways to use one.'],
25
+ ['overlays', 'sides and corners', 'Nodes placed against part of another node: a side, a corner, or its text.'],
26
+ ['frames', "on the parent's edge", "A child placed on its own container's side or corner."],
27
+ ['text', 'room for labels', "A line's text takes no room of its own; the gap it sits in is stated."],
28
+ ['lanes', 'side by side', 'Lines between the same two sides fan out as copies, and copies never cross.'],
29
+ ['coincident', 'parallel edges', 'Several lines between the same two nodes: copies, or a bundle that bows them apart.'],
30
+ ['bundles', 'bundles', 'Lines that travel together, each in its own lane, in one order across.'],
31
+ ['corridors', 'through a gap', 'Lines sent through the point between two named nodes with via:.'],
32
+ ['passes', 'saying where a line goes', 'Sides and points a line passes, named with via:.'],
33
+ ['overhang', 'outside the nodes', 'Lines that run past the nodes, and the page grows to hold them.'],
34
+ ['routing', 'going round boxes', 'Every routing bug reported so far, each line now stating its course.'],
35
+ ['lines', 'line styles', 'Straight, square and curved lines, dashes, and how crossings are drawn.'],
36
+ ['linetexts', 'texts on lines', "Where a line's text sits: the middle, a fraction along, beside, or a gap from an end."],
37
+ ['marks', 'line ends', 'Arrowheads, dots, diamonds and bars at either end of a line, or none.'],
38
+ ];
39
+ /**
40
+ * The first thing a new visitor sees. No comments in it: every statement says
41
+ * where a node goes, which is the whole point, and a paragraph explaining that
42
+ * in advance only gets in the way.
43
+ */
44
+ export const START = {
45
+ name: 'start',
46
+ about: 'Three boxes in a row, each a stated distance from the last.',
47
+ source: [
48
+ 'node parser "Parser"',
49
+ 'node resolver "Resolver" right of parser (gap: 12)',
50
+ 'node renderer "Renderer" right of resolver (gap: 12)',
51
+ '',
52
+ 'edge parser -> resolver "statements"',
53
+ 'edge resolver -> renderer "layout"',
54
+ '',
55
+ ].join('\n'),
56
+ };
@@ -0,0 +1,130 @@
1
+ import { type Finding } from './checks.js';
2
+ import type { DrawOptions } from './index.js';
3
+ import { type Theme } from './themes.js';
4
+ /**
5
+ * What a page shows of one diagram: its drawing in every theme, what can be
6
+ * selected in it, and its findings. `page.ts` writes these into a page; a page
7
+ * that redraws as it is edited makes them in the browser, so this module is
8
+ * kept apart from the page's own markup and script, which it has no need of.
9
+ */
10
+ /**
11
+ * The page's data for `source`, as a served page takes it when its file
12
+ * changes or its editor is typed in: the same parse, layout, drawings and
13
+ * findings `drawPage` puts in the page it writes. Runs in the browser too.
14
+ */
15
+ export declare function pageData(source: string, file: string, options?: DrawOptions, at?: Date): {
16
+ title: string;
17
+ drawn: string;
18
+ data: PageData;
19
+ };
20
+ export declare function partsOf(source: string, file: string, options: DrawOptions, at: Date): PageParts;
21
+ export interface PageParts {
22
+ title: string;
23
+ /** What a saved file is called, before its extension. */
24
+ name: string;
25
+ /** The line under the title saying which file the page was drawn from, and when. */
26
+ drawn: string;
27
+ /** The `.reladraw` text the page was drawn from, which Save gives back. */
28
+ source: string;
29
+ findings: Finding[];
30
+ /** The diagram in each theme the picker offers, by name, with guides as the page opens. */
31
+ themes: Record<string, ThemeView>;
32
+ /** The same with guides the other way, or null when the diagram has none. */
33
+ flipped: Record<string, ThemeView> | null;
34
+ /** Whether the page opens with guides shown. */
35
+ guidesShown: boolean;
36
+ /** How many guides the diagram has, which the View menu shows. */
37
+ guideCount: number;
38
+ /** The theme the page opens in. */
39
+ current: string;
40
+ graph: Graph;
41
+ }
42
+ /** The diagram drawn in one theme, and the page's colors to go with it. */
43
+ interface ThemeView {
44
+ /** The SVG as `render` writes it, which is what Save SVG and Save PNG save. */
45
+ svg: string;
46
+ /** The same drawing with each thing grouped and named, which is what is shown. */
47
+ tagged: string;
48
+ theme: Theme;
49
+ /** The page's own colors, as CSS custom properties. */
50
+ colors: Record<string, string>;
51
+ /** The browser's controls: `dark`, `light`, or `light dark` when it can't be told. */
52
+ scheme: string;
53
+ }
54
+ /** A link as the panel shows it: where it goes, what it is called, and its badge drawn in each theme. */
55
+ interface LinkView {
56
+ href: string;
57
+ label: string;
58
+ badges: Record<string, string>;
59
+ }
60
+ /**
61
+ * What a click on the page selects, and what the panel says about it: every
62
+ * node with its text and links, and every line with its two ends, upstream
63
+ * first. A line's index is its place in the layout, which `data-edge` names.
64
+ */
65
+ interface Graph {
66
+ nodes: Record<string, GraphNode>;
67
+ edges: {
68
+ up: string;
69
+ down: string;
70
+ label: string;
71
+ links: LinkView[];
72
+ description?: string;
73
+ /** The styles it wears, by name, which a filter's `style:` matches. */
74
+ styles: string[];
75
+ guide?: true;
76
+ }[];
77
+ }
78
+ interface GraphNode {
79
+ label: string;
80
+ links: LinkView[];
81
+ description?: string;
82
+ /** Where it is in the drawing's own units, `[x, y, width, height]`: where its letter goes, even when it draws nothing. */
83
+ box: number[];
84
+ /** The box it sits in, if any. */
85
+ parent?: string;
86
+ /** The boxes inside it, in the order written, leaving out a picture `badge:` puts beside its text. */
87
+ children: string[];
88
+ styles: string[];
89
+ guide?: true;
90
+ /** The picture a `badge:` writes out: part of its box's heading, never picked on its own. */
91
+ badge?: true;
92
+ /** Text with no outline and nothing inside, whose letter goes beside it rather than over its first words. */
93
+ bare?: true;
94
+ }
95
+ export type PageData = ReturnType<typeof dataOf>;
96
+ export declare function dataOf({ name, source, findings, themes, flipped, guidesShown, guideCount, current, graph }: PageParts): {
97
+ name: string;
98
+ source: string;
99
+ current: string;
100
+ varies: string;
101
+ themeGroups: {
102
+ dark: string[];
103
+ light: string[];
104
+ };
105
+ themes: {
106
+ [k: string]: {
107
+ svg: string | string[];
108
+ tagged: string | string[];
109
+ colors: Record<string, string>;
110
+ scheme: string;
111
+ };
112
+ };
113
+ flipped: {
114
+ [k: string]: {
115
+ svg: string | string[];
116
+ tagged: string | string[];
117
+ colors: Record<string, string>;
118
+ scheme: string;
119
+ };
120
+ } | null;
121
+ guidesShown: boolean;
122
+ guideCount: number;
123
+ findings: {
124
+ kind: "text-overlap" | "text-overflow" | "edge-node-overlap" | "edge-overlap" | "crowded-edge-ends" | "node-overlap" | "node-overflow" | "edge-no-length" | "edge-crossings";
125
+ message: string;
126
+ line: number;
127
+ }[];
128
+ graph: Graph;
129
+ };
130
+ export {};