aontu 0.54.0 → 0.55.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.
package/dist/aontu.d.ts CHANGED
@@ -17,7 +17,7 @@ import { agentsMd } from './agentsmd';
17
17
  import { graphOf } from './graph';
18
18
  import { relationCheck } from './relation';
19
19
  import { view, viewSet, viewTree } from './view';
20
- declare const VERSION = "0.54.0";
20
+ declare const VERSION = "0.55.0";
21
21
  declare class Aontu {
22
22
  opts: AontuOptions;
23
23
  lang: Lang;
package/dist/aontu.js CHANGED
@@ -54,7 +54,7 @@ Object.defineProperty(exports, "viewTree", { enumerable: true, get: function ()
54
54
  // Kept in step with package.json by the `version` npm lifecycle script,
55
55
  // which runs on `npm version` / `npm run repo-bump`. version.test.ts
56
56
  // fails if the two ever drift.
57
- const VERSION = '0.54.0';
57
+ const VERSION = '0.55.0';
58
58
  exports.VERSION = VERSION;
59
59
  // A module file's VALUE, as far as it goes. COLLECTED, not raised: a
60
60
  // module file that does not stand up has no `mod.main` to read, and
package/dist/cli.js CHANGED
@@ -183,13 +183,14 @@ kind and out file, nothing is written unless every figure rendered,
183
183
  and --check gates the committed set.
184
184
 
185
185
  View options:
186
- --as <profile> text | mermaid | dot | er | svg, per kind: tree,
187
- matrix, sets and layers draw text (default) or
188
- svg; graph draws mermaid (default), dot or er;
186
+ --as <profile> text | mermaid | dot | er | svg, per kind: doc,
187
+ tree, matrix, sets and layers draw text (default)
188
+ or svg; graph draws mermaid (default), dot or er;
189
189
  layer draws text (default), mermaid or svg; ladder
190
190
  and poset draw mermaid (default) or dot
191
191
  --at <path> Restrict the figure to nodes under this path; the
192
- path the ladder draws; where the poset compares
192
+ subtree doc draws; the path the ladder draws;
193
+ where the poset compares
193
194
  --views <path> Draw every figure the document declares at this
194
195
  path, one evaluation, all or nothing; each
195
196
  declaration names its own kind and out file
@@ -198,7 +199,20 @@ View options:
198
199
  nothing is written
199
200
  --strict Exit 1 when the loss report holds anything beyond
200
201
  edges_deduped, inverse_suppressed and crossings
202
+ --depth <n> doc: how many levels of key to draw (default 3)
201
203
  --max-rows <n> Refuse a figure above this many rows (default 60)
204
+ --style <s> auto (default), none, ansi or css. A figure's
205
+ marks carry their meaning -- a direct cell, a
206
+ closure cell, an upward edge -- and each profile
207
+ has one way to show it: SGR escapes for text, CSS
208
+ classes for svg. auto picks that mechanism where
209
+ the destination can carry it: escapes only on a
210
+ terminal (NO_COLOR is honoured), and an svg keeps
211
+ the stylesheet that makes it standalone. none
212
+ drops both; on svg the classes stay and only the
213
+ stylesheet goes, for a host page that has already
214
+ bound --av-ink and its kin. Escapes are never
215
+ written to a file
202
216
  --format <f> text (default) or json, the whole report
203
217
  --relation <n> tree, matrix, layer: draw over this relation only;
204
218
  graph: keep this predicate (repeatable)
@@ -1476,9 +1490,40 @@ const REACHES_EXIT = {
1476
1490
  error: 4,
1477
1491
  };
1478
1492
  const VIEW_HELP = 'aontu view <kind> [options] <file>... (try --help)';
1479
- const VIEW_KINDS = ['tree', 'matrix', 'graph', 'layer', 'sets', 'layers', 'ladder', 'poset'];
1493
+ const VIEW_KINDS = ['doc', 'tree', 'matrix', 'graph', 'layer', 'sets', 'layers', 'ladder',
1494
+ 'poset'];
1480
1495
  const VIEW_PROFILES = ['text', 'mermaid', 'dot', 'er', 'svg'];
1481
1496
  const VIEW_EDGES = ['upward', 'all', 'none'];
1497
+ // The styles the CLI accepts (VIEWS.0.md, "7. Styling"). `auto` is
1498
+ // here and NOT in ViewStyle: resolving it means knowing whether stdout
1499
+ // is a terminal, which is the CLI's to know and the library's never --
1500
+ // the same division err.ts already draws for the error frames.
1501
+ const VIEW_STYLES = ['auto', 'none', 'ansi', 'css'];
1502
+ // `--style auto` resolved, which only the CLI can do. The mechanism is
1503
+ // the PROFILE's and the library knows it -- an SVG carries its
1504
+ // stylesheet unless told not to, which is what makes a figure stand
1505
+ // alone. What the library cannot know is whether the DESTINATION is a
1506
+ // terminal, so that is the only thing decided here: escapes on the
1507
+ // text profile when stdout is a terminal and NO_COLOR is unset, the
1508
+ // same two conditions the error frames use. `undefined` leaves the
1509
+ // profile's own default in place.
1510
+ function viewStyleOf(asked, as) {
1511
+ if (undefined !== asked && 'auto' !== asked) {
1512
+ return asked;
1513
+ }
1514
+ // STDOUT'S OWN TERMINAL-NESS, and NO_COLOR read here rather than
1515
+ // through colorActive(). The figure goes to STDOUT and the error
1516
+ // frames go to STDERR, and they are not the same destination: main()
1517
+ // has already called setColor for stderr, so asking colorActive()
1518
+ // would answer the wrong question twice --- no escapes for
1519
+ // `aontu view tree m.aon 2>/dev/null` at a terminal, and escapes
1520
+ // into the pipe for `aontu view tree m.aon | less`. The NO_COLOR
1521
+ // rule is the one no-color.org states and err.ts implements:
1522
+ // set, to anything but empty, means no colour.
1523
+ const no = process.env.NO_COLOR;
1524
+ return 'text' === as && true === process.stdout.isTTY
1525
+ && (null == no || '' === no) ? 'ansi' : undefined;
1526
+ }
1482
1527
  // The figure was drawn (0, `lossy` included: the loss report says
1483
1528
  // what it could not draw, and --strict is the gate on that), or the
1484
1529
  // document could not be drawn (4). An EMPTY figure is a drawing, not
@@ -1493,7 +1538,7 @@ const VIEW_EXIT = {
1493
1538
  const VIEW_USAGE_CODES = [
1494
1539
  'view_kind_unknown', 'view_profile_unknown', 'view_rows_exceeded',
1495
1540
  'view_at_required', 'view_sets_required', 'view_group_required',
1496
- 'view_document_shape',
1541
+ 'view_document_shape', 'view_style_profile', 'view_style_unknown',
1497
1542
  ];
1498
1543
  const MOD_HELP = 'aontu mod tidy|verify|vendor|manifest [dir] (try --help)';
1499
1544
  // The module tooling (G6 phase 3, ts/src/mod-tool.ts). All LOCAL:
@@ -1552,7 +1597,8 @@ function runMod(argv) {
1552
1597
  const dir = rest[1] ?? '.';
1553
1598
  if ('get' === sub || 'publish' === sub) {
1554
1599
  process.stderr.write('aontu: mod ' + sub + ' needs a registry client, which this build ' +
1555
- 'does not ship (docs/capability-review/g6-distribution.md)\n');
1600
+ 'does not ship; vendor the module by hand and run ' +
1601
+ "'aontu mod tidy'\n");
1556
1602
  return 2;
1557
1603
  }
1558
1604
  if (!MOD_SUBS.includes(sub) || 2 < rest.length) {
@@ -1826,6 +1872,9 @@ function runView(argv) {
1826
1872
  const relations = [];
1827
1873
  const roots = [];
1828
1874
  const opts = {};
1875
+ // The style ASKED FOR, which may be `auto` -- a word ViewStyle does
1876
+ // not have, because resolving it is the CLI's job.
1877
+ let style = undefined;
1829
1878
  // A flag that takes a value, read into `opts` by name.
1830
1879
  const valued = {
1831
1880
  '--as': 'as', '--at': 'at', '--order': 'order', '--group-by': 'groupBy',
@@ -1836,6 +1885,7 @@ function runView(argv) {
1836
1885
  const counted = {
1837
1886
  '--max-rows': 'maxRows', '--max-cols': 'maxCols',
1838
1887
  '--min-degree': 'minDegree', '--min-size': 'minSize',
1888
+ '--depth': 'depth',
1839
1889
  };
1840
1890
  for (let i = 0; i < argv.length; i++) {
1841
1891
  const arg = argv[i];
@@ -1874,6 +1924,13 @@ function runView(argv) {
1874
1924
  return 2;
1875
1925
  }
1876
1926
  }
1927
+ else if ('--style' === arg) {
1928
+ style = argv[++i];
1929
+ if (null == style || !VIEW_STYLES.includes(style)) {
1930
+ process.stderr.write(`aontu: --style needs one of ${VIEW_STYLES.join(', ')}\n`);
1931
+ return 2;
1932
+ }
1933
+ }
1877
1934
  else if ('--check' === arg) {
1878
1935
  check = true;
1879
1936
  }
@@ -1915,9 +1972,24 @@ function runView(argv) {
1915
1972
  rest.push(arg);
1916
1973
  }
1917
1974
  }
1975
+ // ESCAPES NEVER GO INTO A FILE. A pinned golden holding terminal
1976
+ // control codes is not a golden anybody can read, and a byte
1977
+ // comparison against one would fail on the reader's terminal
1978
+ // settings. `auto` resolves to `none` there on its own; asking for
1979
+ // `ansi` explicitly is a usage error rather than a silent downgrade,
1980
+ // so a script that wanted colour is told where it went.
1981
+ if ('ansi' === style && (undefined !== out || undefined !== opts.views)) {
1982
+ process.stderr.write('aontu: --style ansi writes to a terminal, not to a file\n');
1983
+ return 2;
1984
+ }
1918
1985
  // THE VIEW DOCUMENT draws every figure a document declares, so it
1919
1986
  // names no kind: the declarations do, one each.
1920
1987
  if (undefined !== opts.views) {
1988
+ // A declaration names its own profile, so the style is left to
1989
+ // each figure's own default; `--style none` still reaches every
1990
+ // one of them, which is how a host page that binds the CSS
1991
+ // variables asks for eight figures without eight stylesheets.
1992
+ opts.style = viewStyleOf(style, undefined);
1921
1993
  return runViewSet(rest, opts, trust, { format, check, strict, out });
1922
1994
  }
1923
1995
  if (2 > rest.length) {
@@ -1976,6 +2048,7 @@ function runView(argv) {
1976
2048
  }
1977
2049
  const report = (0, view_1.view)(srcs[0], {
1978
2050
  ...opts,
2051
+ style: viewStyleOf(style, opts.as ?? (0, view_1.viewDefaultProfile)(kind)),
1979
2052
  kind,
1980
2053
  path: files[0],
1981
2054
  roots,