@loadmap/cli 0.8.0 → 0.10.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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as main } from "./src-KVw61wOu.js";
2
+ import { n as main } from "./src-0Gq92LO7.js";
3
3
  // src/bin.ts
4
4
  main(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
5
5
  console.error(err instanceof Error ? err.message : err);
package/dist/index.d.ts CHANGED
@@ -40,7 +40,7 @@ interface FmtOptions {
40
40
  * file has a syntax error, cannot be read, or (with --check) needs formatting; 2 for a usage mistake.
41
41
  */
42
42
  export declare function fmt(argv: string[], o?: FmtOptions): Promise<number>;
43
- export declare const USAGE = "loadmap check <file.loadmap>… [--format text|github]\nloadmap fmt <file.loadmap>… [--check] | loadmap fmt -\nloadmap record <url | file.loadmap> --out <file.gif|.webm|.mp4|.png|.svg> [options]\n\ncheck compiles each definition and tests its expect lines on the pessimistic edge (every capacity at its low\nbound). It exits 1 when a definition has an error or an expectation fails, 0 when everything holds.\n\n --format <f> text, or github to add annotations on the lines (the default under GitHub Actions)\n\nfmt lays each definition out the one way, in place: two spaces a block, a statement a line, one space around\noperators; numbers, texts and formulas stay as written. A file with a syntax error is left alone (exit 1).\n\n --check change nothing; exit 1 when a file is not laid out so (for CI)\n - read standard input, write standard output\n\nrecord opens the page in headless Chromium, finds the loadmap it exposes (expose() from @loadmap/export) and\nrecords it on a fixed clock, so the same options give the same file. A .loadmap file is drawn by the viewer that\ncomes with the command. It needs Playwright next to the command: npm i -D playwright, then npx playwright install\nchromium (check and fmt run without it).\n\n --out <file> the extension picks the format: gif, webm, mp4, png or svg\n --script <file.json> [{ \"at\": 0, \"set\": { \"load\": 5 } }, { \"at\": 3, \"scenario\": \"Proposed\" }, …]\n or { \"seconds\", \"fps\", \"script\": […] }\n --scenario <label> start from a scenario's values (--set goes on top)\n --set <key=value> a value before recording starts; repeatable (--set load=30 --set pods=6)\n --caption the title, scenario and load above the board, the verdict below it\n --story play the definition's story, a step at a time (with --caption, its text below the board)\n --poster with .png: the board, the verdict, the limits and the scenarios compared\n --seconds <n> length of a video or GIF (default 8, or the script's)\n --fps <n> frames per second (default 30; GIF 15, at most 50)\n --scale <n> pixels per diagram unit (default 1, PNG 2)\n --seed <n> the sim's seed (default 1)\n --name <name> which exposed loadmap, when the page has several (default \"default\")\n --width <px> the browser window (default 1280; below 640 the diagram runs top to bottom)\n --color-scheme <s> light or dark, for a page that follows the system theme (default light)";
43
+ export declare const USAGE = "loadmap check <file.loadmap>… [--format text|github]\nloadmap fmt <file.loadmap>… [--check] | loadmap fmt -\nloadmap record <url | file.loadmap> --out <file.gif|.webm|.mp4|.png|.svg> [options]\n\ncheck compiles each definition and tests its expect lines on the pessimistic edge (every capacity at its low\nbound). It exits 1 when a definition has an error or an expectation fails, 0 when everything holds.\n\n --format <f> text, or github to add annotations on the lines (the default under GitHub Actions)\n\nfmt lays each definition out the one way, in place: two spaces a block, a statement a line, one space around\noperators; numbers, texts and formulas stay as written. A file with a syntax error is left alone (exit 1).\n\n --check change nothing; exit 1 when a file is not laid out so (for CI)\n - read standard input, write standard output\n\nrecord opens the page in headless Chromium, finds the loadmap it exposes (expose() from @loadmap/export) and\nrecords it on a fixed clock, so the same options give the same file. A .loadmap file is drawn by the viewer that\ncomes with the command. It needs Playwright next to the command: npm i -D playwright, then npx playwright install\nchromium (check and fmt run without it).\n\n --out <file> the extension picks the format: gif, webm, mp4, png or svg\n --script <file.json> [{ \"at\": 0, \"set\": { \"load\": 5 } }, { \"at\": 3, \"scenario\": \"Proposed\" }, …]\n or { \"seconds\", \"fps\", \"script\": […] }\n --scenario <label> start from a scenario's values (--set goes on top)\n --set <key=value> a value before recording starts; repeatable (--set load=30 --set pods=6)\n --caption the title, scenario and load above the board, the verdict below it\n --story play the definition's story as the page's Play does: close on each change, then the whole\n diagram (with --caption, each step's text below the board)\n --poster with .png: the board, the verdict, the limits and the scenarios compared\n --seconds <n> length of a video or GIF (default 8, or the script's)\n --fps <n> frames per second (default 30; GIF 15, at most 50)\n --scale <n> pixels per diagram unit (default 1, PNG 2)\n --seed <n> the sim's seed (default 1)\n --name <name> which exposed loadmap, when the page has several (default \"default\")\n --width <px> the browser window (default 1280; below 640 the diagram runs top to bottom)\n --color-scheme <s> light or dark, for a page that follows the system theme (default light)";
44
44
  export interface RecordArgs {
45
45
  /** A page that calls expose(); empty with `file`. */
46
46
  url: string;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as USAGE, o as check, a as fmt, s as github, n as main, r as parseRecord, i as record } from "./src-KVw61wOu.js";
1
+ export { t as USAGE, o as check, a as fmt, s as github, n as main, r as parseRecord, i as record } from "./src-0Gq92LO7.js";
@@ -459,8 +459,10 @@ function defineModel(def) {
459
459
  if (st.focus != null && !componentIds.includes(st.focus)) throw new Error(`loadmap: ${name} points at unknown component "${st.focus}"`);
460
460
  if (st.seconds != null && !(st.seconds > 0 && Number.isFinite(st.seconds))) throw new Error(`loadmap: ${name} needs seconds above 0, not ${st.seconds}`);
461
461
  takes(name, st.set ?? {}, true);
462
+ if (st.title != null && !st.title.trim()) throw new Error(`loadmap: ${name} has an empty title`);
462
463
  return {
463
464
  text: st.text,
465
+ ...st.title != null ? { title: st.title } : {},
464
466
  values: {
465
467
  ...defaults(),
466
468
  ...from?.values,
@@ -1792,8 +1794,8 @@ const SCHEMA = {
1792
1794
  children: []
1793
1795
  },
1794
1796
  step: {
1795
- doc: "A step of the story the page walks through, in order: its text, and the values to show it at. `loadmap record --story` plays it.",
1796
- example: "step \"At 30×, the workers run out first.\" { load: 30; focus: workers }",
1797
+ doc: "A step of the story the page walks through, in order: its text, and the values to show it at. Play (and `loadmap record --story`) shows the whole diagram, closes in on what the step changes, changes it, and steps back.",
1798
+ example: "step \"At 30×, the workers run out first.\" { load: 30; focus: workers; title: \"Users to 30×\" }",
1797
1799
  args: [{
1798
1800
  name: "label",
1799
1801
  kind: "text"
@@ -1804,6 +1806,11 @@ const SCHEMA = {
1804
1806
  scope: "const",
1805
1807
  doc: "Start from this scenario's values; without one, from the defaults."
1806
1808
  },
1809
+ title: {
1810
+ value: "string",
1811
+ scope: "const",
1812
+ doc: "The few words the diagram shows while Play shows the step. Default: what the step changes."
1813
+ },
1807
1814
  focus: {
1808
1815
  value: "component",
1809
1816
  scope: "const",
@@ -1812,7 +1819,7 @@ const SCHEMA = {
1812
1819
  seconds: {
1813
1820
  value: "number",
1814
1821
  scope: "const",
1815
- doc: "How long a recording holds the step. Default 4."
1822
+ doc: "How long Play holds the whole diagram after the step changes it: the time to read it. Default 4."
1816
1823
  }
1817
1824
  },
1818
1825
  children: [],
@@ -4291,6 +4298,8 @@ var Compiler = class {
4291
4298
  }
4292
4299
  const scenario = this.named(b, "scenario", Object.keys(scenarios), "scenario");
4293
4300
  const focus = this.named(b, "focus", [...components.keys()], "component");
4301
+ const title = this.constProp(b, "title");
4302
+ if (title != null && !title.trim()) this.report.error(this.prop(b, "title").value, "a title needs a few words");
4294
4303
  const seconds = this.constProp(b, "seconds");
4295
4304
  if (seconds != null && !(seconds > 0 && Number.isFinite(seconds))) this.report.error(this.prop(b, "seconds").value, "seconds is a duration above 0");
4296
4305
  const set = this.preset(b, params);
@@ -4299,6 +4308,7 @@ var Compiler = class {
4299
4308
  if (text == null || scenario === null || focus === null) return void 0;
4300
4309
  return {
4301
4310
  text,
4311
+ ...title?.trim() ? { title } : {},
4302
4312
  ...scenario != null ? { scenario } : {},
4303
4313
  ...focus != null ? { focus } : {},
4304
4314
  ...seconds != null && seconds > 0 ? { seconds } : {},
@@ -5048,7 +5058,8 @@ chromium (check and fmt run without it).
5048
5058
  --scenario <label> start from a scenario's values (--set goes on top)
5049
5059
  --set <key=value> a value before recording starts; repeatable (--set load=30 --set pods=6)
5050
5060
  --caption the title, scenario and load above the board, the verdict below it
5051
- --story play the definition's story, a step at a time (with --caption, its text below the board)
5061
+ --story play the definition's story as the page's Play does: close on each change, then the whole
5062
+ diagram (with --caption, each step's text below the board)
5052
5063
  --poster with .png: the board, the verdict, the limits and the scenarios compared
5053
5064
  --seconds <n> length of a video or GIF (default 8, or the script's)
5054
5065
  --fps <n> frames per second (default 30; GIF 15, at most 50)