@ksp-gonogo/uplink-tools 1.0.0 → 1.1.0-rc.50

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 CHANGED
@@ -35,7 +35,7 @@ Once the package is in an Uplink's devDependencies, the same commands answer to
35
35
  | `release` | `bundle`, `bake`, compile the plugin, check the DLL carries what was baked, and `package`; `release prepare` stamps the version and proves a release builds in a scratch folder; an Uplink with no client runs only the release step |
36
36
  | `version` | stamp the release version in every place an Uplink writes it; an Uplink with no client has no version to stamp but its types package's `package.json`, and its plugin takes the version from `GONOGO_UPLINK_VERSION` |
37
37
  | `publish` | copy the released client to where `client.url` is served from, and say the links |
38
- | `deps` | read every dependency the Uplink pins against each channel it is published on; `deps bump` moves the pins that are behind and `deps pin-ckan` writes the CKAN spelling of the pin |
38
+ | `deps` | read every dependency the Uplink pins against each channel it is published on; `deps bump` moves the pins that are behind and `deps pin-ckan` writes the CKAN spelling of the pin; `deps verify-ckan` asks CKAN whether it is the exact spelling |
39
39
  | `page` | write the generated page from what the client registers, with no browser |
40
40
  | `render` | draw every fixture to `renders/` |
41
41
  | `docs` | write the page and draw its pictures; `docs --check` fails on drift |
@@ -48,35 +48,6 @@ function uplinkSpecJson(spec) {
48
48
  }
49
49
 
50
50
  // src/render/widgetRecord.ts
51
- function widgetRecordOf(def) {
52
- return {
53
- id: def.id,
54
- name: def.name,
55
- description: def.description,
56
- tags: [...def.tags],
57
- channels: [...def.channels ?? []],
58
- optionalChannels: [...def.optionalChannels ?? []],
59
- commands: [...def.commands ?? []],
60
- channelFamilies: [...def.channelFamilies ?? []],
61
- optionalChannelFamilies: [...def.optionalChannelFamilies ?? []],
62
- readsFromConfig: def.channelsFromConfig !== void 0,
63
- dataRequirements: (def.dataRequirements ?? []).map((r) => String(r)),
64
- fields: [...def.fields ?? []].map((f) => String(f)),
65
- actions: (def.actions ?? []).map((a) => ({
66
- id: a.id,
67
- label: a.label,
68
- description: a.description ?? null
69
- })),
70
- augmentSlots: [...def.augmentSlots ?? []],
71
- contributionSlots: [...def.contributionSlots ?? []],
72
- requires: (def.requires ?? []).map((r) => String(r)),
73
- replaces: def.replaces ?? null,
74
- pushable: def.pushable === true,
75
- defaultSize: def.defaultSize ? { w: def.defaultSize.w, h: def.defaultSize.h } : null,
76
- minSize: def.minSize ? { w: def.minSize.w, h: def.minSize.h } : null,
77
- tiny: def.tiny !== void 0
78
- };
79
- }
80
51
  var WIDGET_RECORDS_FILE = "docs/widgets.json";
81
52
  function widgetRecordsJson(records) {
82
53
  const widgets = [...records].sort((a, b) => a.id.localeCompare(b.id));
@@ -89,8 +60,7 @@ export {
89
60
  SPEC_VERSION,
90
61
  buildUplinkSpec,
91
62
  uplinkSpecJson,
92
- widgetRecordOf,
93
63
  WIDGET_RECORDS_FILE,
94
64
  widgetRecordsJson
95
65
  };
96
- //# sourceMappingURL=chunk-BHA6GXF5.js.map
66
+ //# sourceMappingURL=chunk-BEM6QB6T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/render/spec.ts","../src/render/widgetRecord.ts"],"sourcesContent":["import { readUplinkDeclaration } from \"@ksp-gonogo/sitrep-sdk/uplink-manifest\";\nimport type {\n InventoryAugment,\n InventoryContribution,\n InventoryErrorCode,\n InventoryReckonerExemption,\n UplinkInventory,\n} from \"../render-probe\";\nimport type { UplinkPackage } from \"./context\";\nimport type { WidgetRecord } from \"./widgetRecord\";\nimport type {\n WireChannel,\n WireCommand,\n WirePayload,\n WireSurface,\n} from \"./wire\";\n\n/**\n * Where `uplink-tools docs` and `uplink-tools page` write an Uplink's spec\n * sheet, relative to its client package. Committed beside the README and\n * checked with it. Useful for showing an Uplink author where the spec sheet is\n * committed. Used by `uplink-tools page` and `uplink-tools docs`, and by the\n * check that the page is current.\n *\n * @category Uplink page\n */\nexport const SPEC_FILE = \"docs/spec.json\";\n\n/**\n * The version of the spec sheet's own shape. A reader that finds a number it\n * does not know should not guess at the fields. Useful for showing an Uplink\n * author which shape of spec sheet a file holds. Used by {@link\n * buildUplinkSpec}.\n *\n * @category Uplink page\n */\nexport const SPEC_VERSION = 1;\n\n/**\n * An Uplink described as data: everything its README lists, for a developer or\n * a tool that reads another author's Uplink. It holds only strings, numbers,\n * booleans, lists and objects, so it can be rendered as text with no markup and\n * no code run.\n *\n * Useful for a developer deciding whether an Uplink's Topics, commands and\n * slots fit what they are building. Written by `uplink-tools page` and\n * `uplink-tools docs`.\n *\n * It does not carry the contract and extension API the client was built\n * against: `gonogo-uplink.json` beside it holds those numbers, and the README\n * prints them in its \"Built against\" row.\n *\n * @category Uplink page\n */\nexport interface UplinkSpec {\n /** The shape version of this file, {@link SPEC_VERSION}. */\n specVersion: number;\n /** Who the Uplink is. */\n uplink: {\n id: string;\n name: string;\n version: string;\n description: string;\n /** The game mod it wraps, when its `uplink.json` names one. */\n wraps: { name: string; builtAgainst?: string; tier?: string } | null;\n };\n /** The Topics it publishes, each with its delivery and delay when the C# declaration could be read. */\n topics: WireChannel[];\n /** Payload shapes reached through a Topic's fields. */\n nestedPayloads: WirePayload[];\n /** Payload shapes no listed Topic routes to. */\n otherPayloads: WirePayload[];\n /** The commands it accepts. */\n commands: WireCommand[];\n /** The argument shapes those commands take. */\n commandArgs: WirePayload[];\n /** The widgets it registers. */\n widgets: WidgetRecord[];\n /** The slots it fills in other widgets. */\n augments: InventoryAugment[];\n /** The values it contributes to named slots. */\n contributions: InventoryContribution[];\n /** The models it runs. */\n models: {\n processors: string[];\n forwardModels: string[];\n publishedTopics: string[];\n inputRuleExemptions: InventoryReckonerExemption[];\n };\n /** The refusal refinements it answers with. */\n errorCodes: InventoryErrorCode[];\n}\n\nfunction byId<Item extends { id: string }>(items: readonly Item[]): Item[] {\n return [...items].sort((a, b) => a.id.localeCompare(b.id));\n}\n\nfunction byName(items: readonly WirePayload[]): WirePayload[] {\n return [...items].sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * The Uplink's spec sheet, built from the same inventory and wire surface its\n * README is built from. Every list is ordered by id, so the file is the same on\n * every machine. Useful for showing an Uplink author a machine-readable\n * description of their Uplink, beside the README. Used by `uplink-tools page`\n * and `uplink-tools docs`, and by the check that the page is current.\n *\n * @category Uplink page\n */\nexport function buildUplinkSpec(\n pkg: UplinkPackage,\n inventory: UplinkInventory,\n wire: WireSurface,\n widgets: readonly WidgetRecord[],\n): UplinkSpec {\n const mod = readUplinkDeclaration(pkg.dir)?.declared.mod;\n return {\n specVersion: SPEC_VERSION,\n uplink: {\n id: inventory.id,\n name: inventory.name,\n version: inventory.version,\n description: (inventory.description ?? \"\").replace(/\\s+/g, \" \").trim(),\n wraps: mod?.name\n ? {\n name: mod.name,\n ...(mod.builtAgainst ? { builtAgainst: mod.builtAgainst } : {}),\n ...(mod.tier ? { tier: mod.tier } : {}),\n }\n : null,\n },\n topics: byId(wire.channels),\n nestedPayloads: byName(wire.nested),\n otherPayloads: byName(wire.payloads),\n commands: byId(wire.commands),\n commandArgs: byName(wire.argShapes),\n widgets: byId(widgets),\n augments: byId(inventory.augments),\n contributions: byId(inventory.contributions),\n models: {\n processors: [...inventory.processors].sort(),\n forwardModels: [...inventory.reckonedTopics].sort(),\n publishedTopics: [...inventory.publishedTopics].sort(),\n inputRuleExemptions: [...inventory.reckonerExemptions].sort((a, b) =>\n a.topic.localeCompare(b.topic),\n ),\n },\n errorCodes: byId(inventory.errorCodes ?? []),\n };\n}\n\n/**\n * The spec sheet as the file holds it: two-space indented JSON ending in a\n * newline. Useful for showing an Uplink author the spec sheet as it is\n * committed. Used by `uplink-tools page` and `uplink-tools docs`, and by the\n * check that the page is current.\n *\n * @category Uplink page\n */\nexport function uplinkSpecJson(spec: UplinkSpec): string {\n return `${JSON.stringify(spec, null, 2)}\\n`;\n}\n","/**\n * Everything an author declared about a widget in `registerComponent`, as data.\n * Fields the registration leaves out are empty lists, `false` or `null`, never\n * missing. Useful for describing a widget to an operator the same way on the\n * Uplink's README and on a docs site. Built by the render probe's inventory and\n * written by {@link widgetRecordsJson}.\n *\n * @category Inventory\n * @categoryDescription Inventory\n * What an Uplink client registered, read back as data: its widgets, augments\n * and contributions with everything their registrations declare. The renderer\n * and the generated page both read it.\n */\nexport interface WidgetRecord {\n /** The registered widget id. */\n id: string;\n /** The widget's display name. */\n name: string;\n /** What the widget shows, as the registration describes it. */\n description: string;\n /** The free-form tags the widget is filed under. */\n tags: string[];\n /** The Topics the widget needs to render. */\n channels: string[];\n /** The Topics the widget reads when they are present and draws without otherwise. */\n optionalChannels: string[];\n /** The commands the widget's controls can send, as the registration lists them. */\n commands: string[];\n /** The Topic families the widget needs to render, each as a pattern such as `trackingStation.vessel.<vessel>.link`. */\n channelFamilies: string[];\n /** The Topic families the widget reads when present and draws without otherwise. */\n optionalChannelFamilies: string[];\n /** Whether the Topics the widget reads depend on the widget's settings, as a graph's chosen series do. */\n readsFromConfig: boolean;\n /** The flat data keys an older widget declares instead of `channels`. */\n dataRequirements: string[];\n /** The fields of its Topics the widget draws. */\n fields: string[];\n /** The actions an input can be bound to, each with the label an operator reads and, when the registration gives one, what it does. */\n actions: { id: string; label: string; description: string | null }[];\n /** The augment slots the widget renders, as the registration names them. */\n augmentSlots: string[];\n /** The contribution slots the widget reads, as the registration names them. */\n contributionSlots: string[];\n /**\n * What the game has to have for the widget to show, from the Topics it\n * requires: `\"flight\"` for a vessel Topic, `\"career\"` for a career Topic.\n */\n requires: string[];\n /** The id of the widget this one replaces, or `null`. */\n replaces: string | null;\n /** Whether a station can push this widget to the main screen. */\n pushable: boolean;\n /** The size a new widget opens at, in grid units, or `null` for the dashboard's default. */\n defaultSize: { w: number; h: number } | null;\n /** The smallest the widget may be resized to, in grid units, or `null` when unset. */\n minSize: { w: number; h: number } | null;\n /** Whether the widget has a tiny form for the smallest tiles. */\n tiny: boolean;\n}\n\n/**\n * Where `uplink-tools docs` writes an Uplink's widget records, relative to its\n * client package. It is committed beside the README and checked with it. Useful\n * for letting a docs site list the Uplink's widgets. Used by the `docs` command\n * and the page check.\n *\n * @category Uplink page\n */\nexport const WIDGET_RECORDS_FILE = \"docs/widgets.json\";\n\n/**\n * Widget records as the JSON file holds them: `{ \"widgets\": [...] }`, ordered\n * by id, two-space indented, ending in a newline. Each entry may carry extra\n * fields after the record's own. Useful for writing the widget records file.\n * Used by the `docs` command and the page check.\n *\n * @category Uplink page\n */\nexport function widgetRecordsJson<Entry extends WidgetRecord>(\n records: readonly Entry[],\n): string {\n const widgets = [...records].sort((a, b) => a.id.localeCompare(b.id));\n return `${JSON.stringify({ widgets }, null, 2)}\\n`;\n}\n"],"mappings":";AAAA,SAAS,6BAA6B;AA0B/B,IAAM,YAAY;AAUlB,IAAM,eAAe;AAyD5B,SAAS,KAAkC,OAAgC;AACzE,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC;AAC3D;AAEA,SAAS,OAAO,OAA8C;AAC5D,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC/D;AAWO,SAAS,gBACd,KACA,WACA,MACA,SACY;AACZ,QAAM,MAAM,sBAAsB,IAAI,GAAG,GAAG,SAAS;AACrD,SAAO;AAAA,IACL,aAAa;AAAA,IACb,QAAQ;AAAA,MACN,IAAI,UAAU;AAAA,MACd,MAAM,UAAU;AAAA,MAChB,SAAS,UAAU;AAAA,MACnB,cAAc,UAAU,eAAe,IAAI,QAAQ,QAAQ,GAAG,EAAE,KAAK;AAAA,MACrE,OAAO,KAAK,OACR;AAAA,QACE,MAAM,IAAI;AAAA,QACV,GAAI,IAAI,eAAe,EAAE,cAAc,IAAI,aAAa,IAAI,CAAC;AAAA,QAC7D,GAAI,IAAI,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAAA,MACvC,IACA;AAAA,IACN;AAAA,IACA,QAAQ,KAAK,KAAK,QAAQ;AAAA,IAC1B,gBAAgB,OAAO,KAAK,MAAM;AAAA,IAClC,eAAe,OAAO,KAAK,QAAQ;AAAA,IACnC,UAAU,KAAK,KAAK,QAAQ;AAAA,IAC5B,aAAa,OAAO,KAAK,SAAS;AAAA,IAClC,SAAS,KAAK,OAAO;AAAA,IACrB,UAAU,KAAK,UAAU,QAAQ;AAAA,IACjC,eAAe,KAAK,UAAU,aAAa;AAAA,IAC3C,QAAQ;AAAA,MACN,YAAY,CAAC,GAAG,UAAU,UAAU,EAAE,KAAK;AAAA,MAC3C,eAAe,CAAC,GAAG,UAAU,cAAc,EAAE,KAAK;AAAA,MAClD,iBAAiB,CAAC,GAAG,UAAU,eAAe,EAAE,KAAK;AAAA,MACrD,qBAAqB,CAAC,GAAG,UAAU,kBAAkB,EAAE;AAAA,QAAK,CAAC,GAAG,MAC9D,EAAE,MAAM,cAAc,EAAE,KAAK;AAAA,MAC/B;AAAA,IACF;AAAA,IACA,YAAY,KAAK,UAAU,cAAc,CAAC,CAAC;AAAA,EAC7C;AACF;AAUO,SAAS,eAAe,MAA0B;AACvD,SAAO,GAAG,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA;AACzC;;;AC7FO,IAAM,sBAAsB;AAU5B,SAAS,kBACd,SACQ;AACR,QAAM,UAAU,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC;AACpE,SAAO,GAAG,KAAK,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;AAAA;AAChD;","names":[]}
@@ -105,6 +105,11 @@ function readChannelDispositions(pkgDir) {
105
105
  // src/render/wire.ts
106
106
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
107
107
  import { join as join2 } from "path";
108
+
109
+ // ../ui-kit/dist/chunk-ZG7NEDVU.js
110
+ var NULL_DISPLAY = "\u2014";
111
+
112
+ // src/render/wire.ts
108
113
  var EMPTY = {
109
114
  present: false,
110
115
  channels: [],
@@ -243,7 +248,7 @@ function shapeElementName(entry) {
243
248
  return entry.replace(/^\*/, "").replace(/\[\]$/, "");
244
249
  }
245
250
  function fieldList(list2) {
246
- if (list2.length === 0) return "\u2013";
251
+ if (list2.length === 0) return NULL_DISPLAY;
247
252
  return list2.map(
248
253
  (f) => f.shape ? `\`${f.name}\` ${f.shape}` : `\`${f.name}\` ${f.unit ?? "?"}`
249
254
  ).join(", ");
@@ -256,7 +261,7 @@ function wireSection(surface) {
256
261
  "| Topic | Payload | Delivery | Delay |",
257
262
  "| --- | --- | --- | --- |",
258
263
  ...surface.channels.map(
259
- (c) => `| \`${c.id}\` | ${c.payload ? `\`${c.payload}${c.array ? "[]" : ""}\`` : "\u2013"} | ${c.disposition.delivery ?? "\u2013"} | ${c.disposition.delay ?? "\u2013"} |`
264
+ (c) => `| \`${c.id}\` | ${c.payload ? `\`${c.payload}${c.array ? "[]" : ""}\`` : NULL_DISPLAY} | ${c.disposition.delivery ?? NULL_DISPLAY} | ${c.disposition.delay ?? NULL_DISPLAY} |`
260
265
  ),
261
266
  ""
262
267
  );
@@ -362,7 +367,8 @@ function buildManifest(inputs) {
362
367
  id: inputs.inventory.id,
363
368
  name: inputs.inventory.name,
364
369
  version: inputs.inventory.version,
365
- description: inputs.inventory.description
370
+ description: inputs.inventory.description,
371
+ widgets: inputs.inventory.widgets.map((w) => w.id)
366
372
  },
367
373
  compat: inputs.inventory.compat,
368
374
  integrity
@@ -377,8 +383,13 @@ function pageRoot(clientDir) {
377
383
  }
378
384
  function installSection(inputs) {
379
385
  const { inventory } = inputs;
380
- const declared = readUplinkDeclaration(inputs.pkg.dir)?.declared;
381
- const label = `${inventory.name} Uplink`;
386
+ return installLines(
387
+ `${inventory.name} Uplink`,
388
+ inventory.id,
389
+ readUplinkDeclaration(inputs.pkg.dir)?.declared
390
+ );
391
+ }
392
+ function installLines(label, id, declared) {
382
393
  if (!declared) {
383
394
  return [
384
395
  "## Install",
@@ -401,7 +412,7 @@ function installSection(inputs) {
401
412
  `Without CKAN, download \`${gamedata}.zip\` from the releases page, unpack it into your Kerbal Space Program folder so that it lands in \`GameData/${gamedata}\`, and install Gonogo the same way.`,
402
413
  ""
403
414
  ];
404
- const releases = releasesUrl(declared.repo, inventory.id);
415
+ const releases = releasesUrl(declared.repo, id);
405
416
  if (releases) lines.push(`Releases: ${releases}`, "");
406
417
  return lines;
407
418
  }
@@ -417,7 +428,7 @@ function releasesUrl(repo, id) {
417
428
  }
418
429
  var README_GENERATED_MARKER = "<!-- Generated by `uplink-tools docs` or `uplink-tools page`.";
419
430
  function list(items) {
420
- return items.length > 0 ? items.map((i) => `\`${i}\``).join(", ") : "\u2013";
431
+ return items.length > 0 ? items.map((i) => `\`${i}\``).join(", ") : NULL_DISPLAY;
421
432
  }
422
433
  function facts(rows) {
423
434
  const present = rows.filter(
@@ -523,11 +534,7 @@ function widgetSection(inputs, widget) {
523
534
  ...widgetFactsOf(widget).map((fact) => [
524
535
  fact.label,
525
536
  widgetFactValueMd(fact.items)
526
- ]),
527
- // How many STATES somebody thought worth showing, not how many pictures.
528
- // A widget with three warning states and one scene is the shape that hides
529
- // a finding, and this is what makes that visible in review.
530
- ["Scenes", String(scenesFor(inputs, "widget", widget.id).length)]
537
+ ])
531
538
  ]);
532
539
  out.push(...collapsed("Widget details", detail));
533
540
  return out;
@@ -595,7 +602,6 @@ function augmentTable(inputs, shown) {
595
602
  `\`${augment.augments}\``,
596
603
  list(augment.channels),
597
604
  augment.requires ? `only while \`${augment.requires}\`` : "",
598
- String(scenesFor(inputs, "augment", augment.id).length),
599
605
  notes.join("; ")
600
606
  ];
601
607
  });
@@ -603,7 +609,7 @@ function augmentTable(inputs, shown) {
603
609
  return [
604
610
  "## Augments",
605
611
  "",
606
- ...table(["Augment", "Into", "Reads", "Presence", "Scenes", "Notes"], rows),
612
+ ...table(["Augment", "Into", "Reads", "Presence", "Notes"], rows),
607
613
  ...inputs.inventory.augments.flatMap(
608
614
  (augment) => imageLinks(
609
615
  inputs.pkg.dir,
@@ -693,26 +699,19 @@ function inputRuleExemptions(inputs) {
693
699
  ...table(["Topic", "Rule", "Why it is sound"], rows)
694
700
  ];
695
701
  }
696
- function buildReadme(inputs, manifest) {
697
- const { inventory } = inputs;
698
- if (!inventory.description?.trim()) {
699
- throw new Error(
700
- 'uplink-tools docs: this client declares no `description`, and the page opens with it.\n\nAdd one to `defineUplinkClient` in client/src/uplink.ts, in one or two sentences saying what the Uplink does:\n defineUplinkClient({ id, version, name, description: "..." })\n\nIt is a field rather than a prose file on purpose. Everything else on the page comes from your registrations, your contract slice and your fixtures, so this is the only sentence anyone writes.'
701
- );
702
- }
703
- const wire = readWireSurface(inputs.pkg.dir);
704
- const mod = declaredMod(inputs.pkg.dir);
705
- const out = [
702
+ function readmeHead(parts) {
703
+ const { name, description, mod, install } = parts;
704
+ return [
706
705
  `${README_GENERATED_MARKER} Do not edit this file: it is written`,
707
706
  " from the registrations, the contract slice and the fixtures. -->",
708
707
  "",
709
- `# ${inventory.name}`,
708
+ `# ${name}`,
710
709
  "",
711
710
  // Whitespace collapsed, not just trimmed. A description written across source
712
711
  // lines arrives carrying the newline and the source indent, and four spaces at
713
712
  // the start of a markdown line is a CODE BLOCK: the Uplink's one sentence
714
713
  // would render as monospace with a scrollbar.
715
- inventory.description.replace(/\s+/g, " ").trim(),
714
+ description.replace(/\s+/g, " ").trim(),
716
715
  "",
717
716
  `An Uplink for [Gonogo](${GONOGO_URL}), the mission-control dashboard for Kerbal Space Program that runs in a web browser on any screen.`,
718
717
  "",
@@ -720,8 +719,44 @@ function buildReadme(inputs, manifest) {
720
719
  `Built against ${mod.name}${mod.builtAgainst ? ` ${mod.builtAgainst}` : ""}.`,
721
720
  ""
722
721
  ] : [],
723
- ...installSection(inputs)
722
+ ...install
724
723
  ];
724
+ }
725
+ function buildClientlessReadme(declared) {
726
+ if (!declared.description?.trim()) {
727
+ throw new Error(
728
+ 'uplink-tools page: this Uplink has no client, so its page is written from uplink.json alone, and the page opens with the `description` field, which uplink.json does not have.\n\nAdd one to uplink.json, in one or two sentences saying what the Uplink does:\n "description": "..."'
729
+ );
730
+ }
731
+ if (!declared.name?.trim() || !declared.id?.trim()) {
732
+ throw new Error(
733
+ "uplink-tools page: this Uplink has no client, so its page is written from uplink.json alone, and uplink.json needs both an `id` and a `name` for it."
734
+ );
735
+ }
736
+ const out = readmeHead({
737
+ name: declared.name,
738
+ description: declared.description,
739
+ mod: declared.mod ?? void 0,
740
+ install: installLines(`${declared.name} Uplink`, declared.id, declared)
741
+ });
742
+ return `${out.join("\n").replace(/\n{3,}/g, "\n\n")}
743
+ `;
744
+ }
745
+ function buildReadme(inputs, manifest) {
746
+ const { inventory } = inputs;
747
+ if (!inventory.description?.trim()) {
748
+ throw new Error(
749
+ 'uplink-tools docs: this client declares no `description`, and the page opens with it.\n\nAdd one to `defineUplinkClient` in client/src/uplink.ts, in one or two sentences saying what the Uplink does:\n defineUplinkClient({ id, version, name, description: "..." })\n\nIt is a field rather than a prose file on purpose. Everything else on the page comes from your registrations, your contract slice and your fixtures, so this is the only sentence anyone writes.'
750
+ );
751
+ }
752
+ const wire = readWireSurface(inputs.pkg.dir);
753
+ const mod = declaredMod(inputs.pkg.dir);
754
+ const out = readmeHead({
755
+ name: inventory.name,
756
+ description: inventory.description,
757
+ mod,
758
+ install: installSection(inputs)
759
+ });
725
760
  const records = widgetRecordsOf(inventory);
726
761
  const undescribed = records.filter((widget) => !widget.description?.trim());
727
762
  if (undescribed.length > 0) {
@@ -778,6 +813,7 @@ export {
778
813
  README_GENERATED_MARKER,
779
814
  scenesAssertingNothing,
780
815
  widgetRecordsOf,
816
+ buildClientlessReadme,
781
817
  buildReadme
782
818
  };
783
- //# sourceMappingURL=chunk-RIB2IDDC.js.map
819
+ //# sourceMappingURL=chunk-EJH2XHCP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/render/channels.ts","../src/render/wire.ts","../../ui-kit/src/nullDisplay.ts","../src/render/docs.ts"],"sourcesContent":["import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\n/**\n * How one channel is sent, as the Uplink's C# `ChannelDeclaration` sets it: its\n * `Delivery` and its `DelayRole`. Useful for showing the operator how each\n * Topic of the Uplink reaches the command centre and whether the signal delay\n * applies to it. Returned by {@link readChannelDispositions}, which reads both\n * a plain declaration and a factory method that returns one, and used by the\n * page generator.\n *\n * When there is C# beside the client and it declares no channel the generated\n * contract names, page generation fails naming it. When there is no C# to\n * read, the page lists every channel without its delivery or delay.\n *\n * @category Uplink page\n */\nexport interface ChannelDisposition {\n /** `lossy-latest`, `reliable-ordered`: the C# enum member, kebab-cased. */\n delivery?: string;\n /** `delayed`, `true-now`. */\n delay?: string;\n}\n\n/** `LossyLatest` -> `lossy-latest`. The enum member is the fact; this is spelling. */\nfunction kebab(member: string): string {\n return member\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1-$2\")\n .toLowerCase();\n}\n\n/**\n * The C# files that could declare this Uplink's channels.\n *\n * Walked up from the client package, because the layouts differ and all three are\n * real: the app's own repo keeps the plugin beside the client (`<Uplink>/*.cs`\n * with `<Uplink>/client/`), the operator's monorepo keeps it in a sibling\n * (`uplinks/<name>/mod/*.cs`), and a flat single-Uplink repo is the second shape\n * with one fewer level. Nothing here names a repo.\n */\nfunction candidateSources(pkgDir: string): string[] {\n const files: string[] = [];\n let dir = pkgDir;\n for (let up = 0; up < 3; up++) {\n dir = resolve(dir, \"..\");\n for (const at of [dir, join(dir, \"mod\")]) {\n if (!existsSync(at)) continue;\n try {\n for (const entry of readdirSync(at, { withFileTypes: true })) {\n if (entry.isFile() && entry.name.endsWith(\".cs\")) {\n files.push(join(at, entry.name));\n }\n }\n } catch {\n // Not a readable directory: the next candidate is the answer.\n }\n }\n if (files.length > 0) return files;\n }\n return files;\n}\n\nconst CONST_STRING = /\\bconst\\s+string\\s+(\\w+)\\s*=\\s*\"([^\"]*)\"/g;\nconst INITIALISER = /new\\s+ChannelDeclaration\\s*\\{/g;\n// `=> new ChannelDeclaration {`, `=> new ChannelDeclaration() {` and the target-typed `=> new() {`.\nconst FACTORY =\n /\\bChannelDeclaration\\s+(\\w+)\\s*\\([^)]*\\)\\s*=>\\s*new\\s*(?:ChannelDeclaration\\s*)?(?:\\(\\s*\\)\\s*)?\\{/g;\n\n/** The body of a brace-balanced block whose opening `{` is at `from`. */\nfunction block(source: string, from: number): string {\n let depth = 0;\n for (let i = from; i < source.length; i++) {\n if (source[i] === \"{\") depth++;\n if (source[i] === \"}\") {\n depth--;\n if (depth === 0) return source.slice(from + 1, i);\n }\n }\n return \"\";\n}\n\nfunction property(body: string, name: string): string | undefined {\n const match = new RegExp(`\\\\b${name}\\\\s*=\\\\s*([\\\\w.]+|\"[^\"]*\")`).exec(body);\n return match?.[1];\n}\n\nfunction enumMember(raw: string | undefined): string | undefined {\n if (!raw) return undefined;\n const member = raw.includes(\".\") ? raw.slice(raw.lastIndexOf(\".\") + 1) : raw;\n return kebab(member);\n}\n\n/**\n * Whether there is any C# for {@link readChannelDispositions} to read near\n * `pkgDir`. Useful for telling a missing declaration from an Uplink that ships\n * no C# at all. Used by the page generator.\n */\nexport function channelSourcesFound(pkgDir: string): boolean {\n return candidateSources(pkgDir).length > 0;\n}\n\n/**\n * How each channel an Uplink's C# declares is sent, read from the C# sources\n * under `pkgDir`, keyed by channel id. Useful for showing the operator how each\n * Topic of the Uplink is delivered and delayed. Used by the page generator.\n *\n * @category Uplink page\n */\nexport function readChannelDispositions(\n pkgDir: string,\n): Map<string, ChannelDisposition> {\n const out = new Map<string, ChannelDisposition>();\n const sources = candidateSources(pkgDir);\n if (sources.length === 0) return out;\n\n const consts = new Map<string, string>();\n const bodies = sources.map((file) => readFileSync(file, \"utf8\"));\n for (const source of bodies) {\n for (const match of source.matchAll(CONST_STRING)) {\n consts.set(match[1], match[2]);\n }\n }\n\n /** Factory name -> the disposition its body declares. */\n const factories = new Map<string, ChannelDisposition>();\n for (const source of bodies) {\n for (const match of source.matchAll(FACTORY)) {\n const body = block(source, match.index + match[0].length - 1);\n factories.set(match[1], {\n delivery: enumMember(property(body, \"Delivery\")),\n delay: enumMember(property(body, \"Delay\")),\n });\n }\n }\n\n const topicOf = (raw: string | undefined): string | undefined => {\n if (!raw) return undefined;\n if (raw.startsWith('\"')) return raw.slice(1, -1);\n // A bare identifier: a const in this Uplink, or a factory's parameter, which\n // is not a topic at all and is handled by the factory pass below.\n return consts.get(raw) ?? consts.get(raw.slice(raw.lastIndexOf(\".\") + 1));\n };\n\n for (const source of bodies) {\n for (const match of source.matchAll(INITIALISER)) {\n const body = block(source, match.index + match[0].length - 1);\n const topic = topicOf(property(body, \"Topic\"));\n if (!topic) continue;\n out.set(topic, {\n delivery: enumMember(property(body, \"Delivery\")),\n delay: enumMember(property(body, \"Delay\")),\n });\n }\n /*\n * Factory call sites: `TrueNow(AvailableTopic)`, and\n * `Ground(ConfidenceTopic, absenceIsData: true)`.\n *\n * Only the FIRST argument is read, and the terminator is `,` or `)` rather\n * than `)` alone. Requiring a single argument was the first version, and the\n * cross-check caught it immediately: one Uplink passes a second argument to\n * one of its factories, so one of its Topics came back with no declaration\n * found. Which is the whole point of the cross-check existing.\n */\n for (const [name, disposition] of factories) {\n const calls = new RegExp(`\\\\b${name}\\\\s*\\\\(\\\\s*([\\\\w.\"]+)\\\\s*[,)]`, \"g\");\n for (const call of source.matchAll(calls)) {\n const topic = topicOf(call[1]);\n if (topic) out.set(topic, disposition);\n }\n }\n }\n return out;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { NULL_DISPLAY } from \"@ksp-gonogo/ui-kit/null-display\";\nimport {\n type ChannelDisposition,\n channelSourcesFound,\n readChannelDispositions,\n} from \"./channels\";\n\n/*\n * The wire surface is read from the Uplink's generated contract slice, the only source derived from the C# declaration rather than restated beside it.\n * `units.json` is read directly; the topic-to-payload map and the array flag are parsed out of `topic-map.ts`, and a channel missing from that parse throws.\n */\n\n/**\n * One field of a payload, as the Uplink's page lists it. Useful for telling an\n * Uplink author which values and units a Topic carries. Held by\n * {@link WirePayload} and written by {@link wireSection}.\n *\n * @category Uplink page\n */\nexport interface WireField {\n /** The field's name on the wire. */\n name: string;\n /** A unit token (`m/s`, `ut`, `flag`) when the field is a scalar. */\n unit?: string;\n /** The nested payload type, with `[]` / `*` plural markers, when it holds one. */\n shape?: string;\n}\n\n/**\n * One channel the Uplink sends, as its page lists it: its Topic, payload,\n * delivery and delay. Useful for showing an Uplink author what the Uplink puts\n * on the stream. Held by {@link WireSurface} and written by\n * {@link wireSection}.\n *\n * @category Uplink page\n */\nexport interface WireChannel {\n /** The channel's Topic id. */\n id: string;\n /** The payload interface name, or undefined for one the slice does not type. */\n payload?: string;\n /** The channel carries a bare JSON array of the payload type. */\n array: boolean;\n /** The fields its payload carries. */\n fields: WireField[];\n /** From the C# declaration site. See `./channels`. */\n disposition: ChannelDisposition;\n}\n\n/**\n * One payload type and its fields, as the Uplink's page lists it. Useful for\n * showing what a Topic or a command carries. Held by {@link WireSurface} and\n * written by {@link wireSection}.\n *\n * @category Uplink page\n */\nexport interface WirePayload {\n /** The payload type's name. */\n name: string;\n /** The fields it carries. */\n fields: WireField[];\n}\n\n/**\n * One command the Uplink accepts, read from its generated command map. Useful\n * for showing an Uplink author which commands an operator can send. Held by\n * {@link WireSurface} and written by {@link commandSection}.\n */\nexport interface WireCommand {\n id: string;\n /** The args interface name. An empty shape means the command takes nothing. */\n args: string;\n /** What a dispatch resolves with, e.g. `CommandResult`. */\n result: string;\n}\n\n/**\n * Everything the Uplink puts on the wire: its channels, payloads and commands,\n * read from its generated contract files. Useful for generating the wire\n * sections of the Uplink's page. Returned by {@link readWireSurface}.\n *\n * @category Uplink page\n */\nexport interface WireSurface {\n /** False when the Uplink has no contract slice, so nothing was generated. */\n present: boolean;\n /** The Topics the Uplink publishes. */\n channels: WireChannel[];\n /**\n * Shapes another payload's field holds, so a reader reaches them through a\n * channel rather than by subscribing to one. Separated from `payloads` because\n * they are the one group whose route onto the wire is visible here, and\n * lumping them in with the command args made the page claim a `*Ext`\n * provider-extension shape was a command's arguments.\n */\n nested: WirePayload[];\n /**\n * Wire shapes nothing on this page can route: a dynamic namespace's payload,\n * or a namespace added inside another channel's extensions bag. The\n * distinction between the two is not in the generated slice, so the page names\n * both rather than picking one. A command's arguments are not in here: they\n * are listed under `commands`.\n */\n payloads: WirePayload[];\n /**\n * The commands this Uplink accepts, and the shape of each one's arguments.\n * Empty for an Uplink that only publishes.\n */\n commands: WireCommand[];\n /** One entry per distinct args type named in `commands`, with its fields. */\n argShapes: WirePayload[];\n}\n\nconst EMPTY: WireSurface = {\n present: false,\n channels: [],\n nested: [],\n payloads: [],\n commands: [],\n argShapes: [],\n};\n\ninterface UnitsJson {\n types?: Record<string, Record<string, string>>;\n topics?: Record<string, Record<string, string>>;\n typeShapes?: Record<string, Record<string, string>>;\n topicShapes?: Record<string, Record<string, string>>;\n}\n\n/**\n * One entry of the generated payload map: ` \"career.status\": CareerStatus;` for\n * a single payload, or the same with a trailing `[]` for an array channel.\n * Anchored to the interface body's two-space indent so a topic id appearing in\n * the file's header prose cannot match, which the real emitted header does.\n */\nconst MAP_ENTRY = /^ {2}\"([^\"]+)\": (\\w+)(\\[\\])?;$/;\n\n/**\n * One entry of the generated command map. Looser than {@link MAP_ENTRY} because\n * a reply is a type expression rather than a bare name: `CommandResult`,\n * `CommandResultOf<Record<string, unknown>>`, or the interface a command that\n * does not answer a `CommandResult` resolves. The whole expression is what the\n * table prints, so it is captured whole.\n */\nconst COMMAND_ENTRY = /^ {2}\"([^\"]+)\": (.+);$/;\n\n/**\n * The two maps in the generated command file, read in one pass: the args map\n * comes first and the reply map second, so the block a line falls in is what\n * says which of the two it belongs to.\n */\nfunction readCommands(dir: string): WireCommand[] {\n const path = join(dir, \"command-map.ts\");\n if (!existsSync(path)) return [];\n\n const args = new Map<string, string>();\n const replies = new Map<string, string>();\n let into: Map<string, string> | null = null;\n for (const line of readFileSync(path, \"utf8\").split(/\\r?\\n/)) {\n if (line.startsWith(\"export interface GeneratedCommandArgsMap\")) {\n into = args;\n continue;\n }\n if (line.startsWith(\"export interface GeneratedCommandReplyMap\")) {\n into = replies;\n continue;\n }\n if (line === \"}\") {\n into = null;\n continue;\n }\n if (into) {\n const match = COMMAND_ENTRY.exec(line);\n if (match) into.set(match[1], match[2]);\n }\n }\n\n return [...args.entries()]\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([id, argsType]) => ({\n id,\n args: argsType,\n // The two maps come out of one codegen pass over one attribute, so a\n // command in the args map and missing from the reply map cannot happen\n // without the emitter changing. The fallback names the bare result rather\n // than printing an empty cell, so a format change shows up as a wrong\n // answer in review rather than as a gap nobody reads.\n result: replies.get(id) ?? \"CommandResult\",\n }));\n}\n\nfunction fields(\n units: Record<string, string> | undefined,\n shapes: Record<string, string> | undefined,\n): WireField[] {\n const names = new Set([\n ...Object.keys(units ?? {}),\n ...Object.keys(shapes ?? {}),\n ]);\n return [...names].sort().map((name) => ({\n name,\n unit: units?.[name],\n shape: shapes?.[name],\n }));\n}\n\n/**\n * Reads the Uplink's wire surface from the generated contract files under\n * `pkgDir`. Useful for listing on the Uplink's page what it sends and accepts.\n * Used by the page generator.\n *\n * @category Uplink page\n */\nexport function readWireSurface(pkgDir: string): WireSurface {\n const dir = join(pkgDir, \"src\", \"__generated__\");\n const unitsPath = join(dir, \"units.json\");\n const topicMapPath = join(dir, \"topic-map.ts\");\n if (!existsSync(unitsPath)) return EMPTY;\n\n const parsedUnits: unknown = JSON.parse(readFileSync(unitsPath, \"utf8\"));\n if (typeof parsedUnits !== \"object\" || parsedUnits === null) {\n throw new Error(`${unitsPath} does not hold a JSON object.`);\n }\n const units: UnitsJson = parsedUnits as UnitsJson;\n\n const mapped = new Map<string, { payload: string; array: boolean }>();\n if (existsSync(topicMapPath)) {\n for (const line of readFileSync(topicMapPath, \"utf8\").split(/\\r?\\n/)) {\n const match = MAP_ENTRY.exec(line);\n if (match) {\n mapped.set(match[1], { payload: match[2], array: match[3] === \"[]\" });\n }\n }\n }\n\n const dispositions = readChannelDispositions(pkgDir);\n // No C# reachable (a client checked out on its own) is not a scan that missed: there is nothing to read.\n const sourcesFound = channelSourcesFound(pkgDir);\n const channels: WireChannel[] = [];\n for (const id of Object.keys(units.topics ?? {}).sort()) {\n const entry = mapped.get(id);\n if (!entry) {\n throw new Error(\n `uplink-tools docs: ${unitsPath} declares the channel \"${id}\" and ` +\n `${topicMapPath} does not say what payload it carries.\\n` +\n \"Both files come out of the same codegen run, so this is not an \" +\n \"authoring mistake: either the two are from different runs (run \" +\n \"`uplink-tools codegen` again), or the emitted topic-map format has changed and \" +\n \"@ksp-gonogo/uplink-tools needs updating to read it.\\n\" +\n \"It throws rather than printing a row with an empty payload, because \" +\n \"a channel table quietly missing its types is the kind of drift this \" +\n \"generator exists to prevent.\",\n );\n }\n /*\n * The cross-check that makes the C# scan safe to be a scan.\n *\n * This topic is declared in the generated slice, so it EXISTS, so a\n * `ChannelDeclaration` for it exists too and the scan should have found one.\n * Coming back empty means the scan missed a shape (a factory, a helper, a\n * layout it did not look in), and a scanner that quietly finds nothing is the\n * failure this project keeps meeting. So it fails here instead, naming the\n * topic, rather than printing a row with two blank columns.\n */\n if (sourcesFound && !dispositions.has(id)) {\n throw new Error(\n `uplink-tools docs: the channel \"${id}\" is declared in the generated ` +\n \"contract slice, and no `ChannelDeclaration` for it was found in this \" +\n \"Uplink's C#.\\n\" +\n \"The scan reads plain object initialisers and single-expression \" +\n \"factories. A declaration built some other way is a shape \" +\n \"@ksp-gonogo/uplink-tools does not read yet, and this fails rather \" +\n \"than printing a row with no delivery and no delay, because a scanner \" +\n \"that silently finds nothing reports a clean pass.\",\n );\n }\n channels.push({\n id,\n payload: entry.payload,\n array: entry.array,\n fields: fields(units.topics?.[id], units.topicShapes?.[id]),\n disposition: dispositions.get(id) ?? {},\n });\n }\n\n /*\n * Channels the C# declares that the generated slice does not type: a topic\n * whose payload lives in `Sitrep.Contract` rather than in this Uplink's own\n * slice, most often. Still this Uplink's wire surface, so still on the page.\n */\n for (const id of [...dispositions.keys()].sort()) {\n if (channels.some((channel) => channel.id === id)) continue;\n channels.push({\n id,\n array: false,\n fields: [],\n disposition: dispositions.get(id) ?? {},\n });\n }\n\n // A type a static channel carries is already described by its channel row, so\n // it is not repeated. What is left splits in two, and the split matters: a\n // shape some field HOLDS is reachable from a channel and can be said to be,\n // while the rest have no route this page can name.\n const named = new Set(channels.map((c) => c.payload));\n const held = new Set(\n [\n ...Object.values(units.typeShapes ?? {}),\n ...Object.values(units.topicShapes ?? {}),\n ].flatMap((byField) => Object.values(byField).map(shapeElementName)),\n );\n\n const describe = (name: string): WirePayload => ({\n name,\n fields: fields(units.types?.[name], units.typeShapes?.[name]),\n });\n const commands = readCommands(dir);\n // A command's args type is routed by the Commands table below, so it leaves\n // the \"nothing can route this\" bucket. Every distinct one is described, even a\n // shape `units.json` has never heard of: an args class with no annotated\n // property (a no-args marker, or one carrying only untyped strings) is absent\n // from that file and would otherwise be named in the table with no row saying\n // what it holds.\n const argTypes = [...new Set(commands.map((c) => c.args))].sort();\n const argTypeSet = new Set(argTypes);\n\n const rest = Object.keys(units.types ?? {})\n .filter((name) => !named.has(name) && !argTypeSet.has(name))\n .sort();\n\n return {\n present: true,\n channels,\n nested: rest.filter((name) => held.has(name)).map(describe),\n payloads: rest.filter((name) => !held.has(name)).map(describe),\n commands,\n argShapes: argTypes.map(describe),\n };\n}\n\n/**\n * The element type of a shape entry, dropping the generated plural markers: a\n * leading `*` is a string-keyed dictionary of it and a trailing `[]` a list. The\n * element is what a consumer indexes into either way, so it is the name that has\n * to match a `types` key.\n */\nfunction shapeElementName(entry: string): string {\n return entry.replace(/^\\*/, \"\").replace(/\\[\\]$/, \"\");\n}\n\nfunction fieldList(list: WireField[]): string {\n if (list.length === 0) return NULL_DISPLAY;\n return list\n .map((f) =>\n f.shape ? `\\`${f.name}\\` ${f.shape}` : `\\`${f.name}\\` ${f.unit ?? \"?\"}`,\n )\n .join(\", \");\n}\n\n/**\n * The page's Topics block as markdown lines: a table of channels with their\n * payload, delivery and delay, then a table of every payload shape with its\n * fields and each field's unit. Empty when the Uplink has no contract slice.\n * Useful for showing an Uplink author what the Uplink sends. Used by the page\n * generator.\n *\n * @category Uplink page\n */\nexport function wireSection(surface: WireSurface): string[] {\n if (!surface.present) return [];\n const out = [\"## Wire\", \"\"];\n\n if (surface.channels.length > 0) {\n out.push(\n \"| Topic | Payload | Delivery | Delay |\",\n \"| --- | --- | --- | --- |\",\n ...surface.channels.map(\n (c) =>\n `| \\`${c.id}\\` | ${c.payload ? `\\`${c.payload}${c.array ? \"[]\" : \"\"}\\`` : NULL_DISPLAY} | ` +\n `${c.disposition.delivery ?? NULL_DISPLAY} | ${c.disposition.delay ?? NULL_DISPLAY} |`,\n ),\n \"\",\n );\n }\n\n const shapes = [...surface.nested, ...surface.payloads].sort((a, b) =>\n a.name.localeCompare(b.name),\n );\n if (shapes.length > 0) {\n out.push(\n \"| Payload | Fields |\",\n \"| --- | --- |\",\n ...shapes.map((p) => `| \\`${p.name}\\` | ${fieldList(p.fields)} |`),\n \"\",\n );\n }\n return out;\n}\n\n/**\n * The page's Commands block as markdown lines: two tables of the commands\n * the Uplink accepts and their argument shapes, beside the Topics block. It is derived\n * from the generated command map, so a command added in C# reaches the table\n * with no hand edit. Useful for showing an Uplink author which commands an\n * operator can send. Used by the page generator.\n *\n * The Result column is what a dispatch resolves with, not what the handler\n * returns: a refusal rejects, carrying its `CommandErrorCode`, so\n * `CommandResult` in that column means the command ran or threw.\n *\n * There is no Delay column, because a command's delay is set in the plugin\n * assembly, which no generated file reaches.\n */\nexport function commandSection(surface: WireSurface): string[] {\n if (surface.commands.length === 0) return [];\n const out = [\n \"## Commands\",\n \"\",\n \"| Command | Args | Result |\",\n \"| --- | --- | --- |\",\n ...surface.commands.map(\n (c) => `| \\`${c.id}\\` | \\`${c.args}\\` | \\`${c.result}\\` |`,\n ),\n \"\",\n ];\n\n if (surface.argShapes.length > 0) {\n out.push(\n \"| Args | Fields |\",\n \"| --- | --- |\",\n ...surface.argShapes.map(\n (p) => `| \\`${p.name}\\` | ${fieldList(p.fields)} |`,\n ),\n \"\",\n );\n }\n return out;\n}\n","// styleguide-emdash.test.ts allows the em dash here and nowhere else.\n/**\n * The null token, the dash that means \"no value to show\": nothing has arrived\n * yet, or the game confirmed there is none. It does not say which, so a widget\n * that has to tell them apart reads the reading's `state` and says so in\n * words. Useful for showing the operator an empty figure wherever only a string\n * fits: a formatter's return value, a template fallback, an attribute value.\n * Used by the tape and the band instruments, and by the Uplink page generator\n * for a table cell with nothing in it. For a bare JSX node use `NullValue`.\n * It is also published as `@ksp-gonogo/ui-kit/null-display`, a module with no\n * imports, so a Node process can read it where the root barrel cannot load.\n *\n * @category Unit\n */\nexport const NULL_DISPLAY = \"—\";\n","import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport {\n buildUplinkManifest,\n NO_BUNDLE_INTEGRITY_WARNING,\n readUplinkDeclaration,\n type UplinkDeclaration,\n type UplinkManifest,\n} from \"@ksp-gonogo/sitrep-sdk/uplink-manifest\";\nimport { NULL_DISPLAY } from \"@ksp-gonogo/ui-kit/null-display\";\nimport type {\n InventoryAugment,\n InventoryContribution,\n InventoryErrorCode,\n UplinkInventory,\n} from \"../render-probe\";\nimport { widgetFactsOf, widgetFactValueMd } from \"../widget-facts\";\nimport type { UplinkPackage } from \"./context\";\nimport type { RenderedAsset } from \"./driver\";\nimport type { Scene } from \"./scenes\";\nimport type { WidgetRecord } from \"./widgetRecord\";\nimport { commandSection, readWireSurface, wireSection } from \"./wire\";\n\n/**\n * What the page generator needs of an asset: a filename and a size, without the\n * rendered `shape`. `page-check.ts` builds this list from the scenes alone, with\n * no browser and so no rendered files, to compare the page's markdown against\n * the code.\n */\nexport type PageAsset = Omit<RenderedAsset, \"shape\">;\n\n/**\n * The assets a render of these scenes writes, named from the scenes alone.\n *\n * The page links images by filename, so the prose can be built without a render\n * as long as the names come out as the renderer's would. The rule mirrors\n * `renderOneScene`: a motion scene records its first size as a GIF, and every\n * other size of any scene is a still.\n */\nexport function linkedAssets(scenes: readonly Scene[]): PageAsset[] {\n return scenes.flatMap((scene) =>\n scene.modes.map((mode, index): PageAsset => {\n const motion = scene.steps !== undefined && scene.steps.length > 0;\n const kind = motion && index === 0 ? \"motion\" : \"still\";\n const ext = kind === \"motion\" ? \"gif\" : \"png\";\n return {\n scene,\n mode: mode.name,\n file: `${scene.name}--${mode.name}.${ext}`,\n kind,\n };\n }),\n );\n}\n\n/** The `integrity` the manifest on disk already carries, or the empty claim. */\nexport function committedIntegrity(manifestPath: string): string {\n try {\n const parsed: unknown = JSON.parse(readFileSync(manifestPath, \"utf8\"));\n const integrity: unknown =\n typeof parsed === \"object\" && parsed !== null\n ? Reflect.get(parsed, \"integrity\")\n : undefined;\n if (typeof integrity === \"string\") return integrity;\n } catch {\n // No manifest yet, or one nothing can parse. Either way there is no hash to keep, and the caller is about to write a whole new file over it.\n }\n return \"\";\n}\n\n/*\n * The manifest first, the page from it.\n *\n * The manifest is the primary output and the README is that manifest plus the\n * Uplink's own declared description. A wrong manifest is parsed by the loader\n * at install time and fails visibly, whereas a wrong paragraph fails silently,\n * so the page is built from the manifest and not the other way round.\n *\n * The page holds the Uplink's description, each widget's own registered\n * description, data in tables, and the screenshots. It leaves out what\n * duplicates a registration (a rationale paragraph per widget), what belongs in\n * the Uplink documentation once (presence-gating, the universal `badges`,\n * `filters` and `meters` segments), repeated boilerplate about missing\n * previews, a closing section of what the page could not say, and an image's\n * alt text repeated as a caption.\n *\n * A reader should be able to skim the whole page in under a minute and come\n * away with what the Uplink does, what its widgets show, and what it puts on\n * the wire. Anything that repeats per item is a table, not a section.\n */\n\n/**\n * The Uplink's `gonogo-uplink.json`: its id, version, compat numbers, bundle\n * integrity and widget list, in the shape `@ksp-gonogo/sitrep-sdk` defines.\n * Useful for telling the app which Gonogo releases an Uplink works with and\n * which bundle file to fetch. Written by `uplink-tools docs`, `page` and\n * `bundle`, which all call the same writer, and returned by {@link buildManifest}.\n *\n * @category Uplink page\n */\nexport type UplinkManifestJson = UplinkManifest;\n\n/**\n * The sha256 of the file the author distributes, and only when they name it.\n *\n * There is no fallback to hashing `dist/index.js`: that file is a `tsc` output,\n * not the bundle anyone ships, and as a gitignored build artifact it would make\n * `--check` compare a committed hash against whatever the last local build\n * produced.\n *\n * With no `--bundle` no new integrity is computed. A hash already in the manifest stays\n * there: it was stamped from a bundle by an earlier `--bundle` run, and writing\n * the page again must not blank it, since an empty one is refused by the app.\n * Only a manifest with no hash at all draws the warning saying what that costs.\n */\nfunction bundleIntegrity(\n pkg: UplinkPackage,\n bundle: string | undefined,\n): { integrity: string; warning?: string } {\n if (!bundle) {\n const kept = committedIntegrity(join(pkg.dir, \"gonogo-uplink.json\"));\n return kept\n ? { integrity: kept }\n : { integrity: \"\", warning: NO_BUNDLE_INTEGRITY_WARNING };\n }\n const candidate = resolve(pkg.dir, bundle);\n try {\n statSync(candidate);\n } catch {\n throw new Error(\n `uplink-tools: --bundle ${bundle} does not exist (looked at ` +\n `${candidate}). Naming a bundle and getting no hash would be worse ` +\n \"than naming none.\",\n );\n }\n const bytes = readFileSync(candidate);\n return {\n integrity: `sha256-${createHash(\"sha256\").update(bytes).digest(\"hex\")}`,\n };\n}\n\n/**\n * What `buildReadme` and `buildManifest` build the page from: the Uplink package,\n * its inventory, its scenes, the pictures drawn for them and where they live.\n * Useful for generating an Uplink's page without a browser, by passing the\n * scenes with no rendered pictures. Used by the renderer behind\n * `uplink-tools docs` and by the page check.\n *\n * @category Uplink page\n */\nexport interface DocsInputs {\n /** The Uplink package. */\n pkg: UplinkPackage;\n /** What its client registers. */\n inventory: UplinkInventory;\n /** The scenes its fixtures define. */\n scenes: Scene[];\n /** The pictures drawn for them. */\n assets: readonly PageAsset[];\n /** Path, relative to the package, of the file distributed to users. */\n bundle?: string;\n /** Where assets live, relative to the package. */\n assetDir: string;\n}\n\n/** What the Uplink wraps, from `uplink.json`'s `mod` block when it has one. */\ntype DeclaredMod = NonNullable<UplinkDeclaration[\"mod\"]>;\n\n/**\n * What `uplink.json` says this Uplink wraps, or nothing.\n *\n * The file is found by the sdk's own search, so the declaration this page prints\n * from is the one the manifest was built from. Absent is normal: an Uplink\n * bundled inside the app's own repo has no separate declaration, and the page\n * omits the sentence it would have filled rather than inventing one.\n */\nfunction declaredMod(pkgDir: string): DeclaredMod | undefined {\n return readUplinkDeclaration(pkgDir)?.declared.mod ?? undefined;\n}\n\n/**\n * Builds the Uplink's manifest with the sdk's manifest writer, with the compat\n * numbers read from the bundle itself, and returns it with a warning when no\n * bundle integrity is available. Useful for generating the manifest an app\n * checks before it loads the Uplink. Used by `uplink-tools docs`, `page` and\n * `bundle`, which build the same manifest from the same files.\n *\n * @category Uplink page\n */\nexport function buildManifest(inputs: DocsInputs): {\n manifest: UplinkManifestJson;\n warning?: string;\n} {\n const { integrity, warning } = bundleIntegrity(inputs.pkg, inputs.bundle);\n return {\n manifest: buildUplinkManifest({\n clientDir: inputs.pkg.dir,\n registered: {\n id: inputs.inventory.id,\n name: inputs.inventory.name,\n version: inputs.inventory.version,\n description: inputs.inventory.description,\n widgets: inputs.inventory.widgets.map((w) => w.id),\n },\n compat: inputs.inventory.compat,\n integrity,\n }),\n warning,\n };\n}\n\n/**\n * The folder the Uplink's page is written in: the one holding `uplink.json`, or\n * for a client with none (an Uplink bundled in the app's own repository) the\n * folder that holds its `client/`. Useful for putting the README where a\n * visitor to the Uplink's folder sees it. Used by `docs`, `page` and the page\n * check.\n */\nexport function pageRoot(clientDir: string): string {\n const declaration = readUplinkDeclaration(clientDir);\n if (declaration) return dirname(declaration.path);\n return basename(clientDir) === \"client\" ? dirname(clientDir) : clientDir;\n}\n\n/**\n * The page's Install section: how a player gets this Uplink into the game, and\n * where its releases are.\n *\n * The CKAN identifier is the folder the plugin installs into, which is also the\n * identifier of the netkan `uplink-tools new` writes. An Uplink bundled in the\n * app's own repository has no `uplink.json` and installs with Gonogo itself.\n */\nfunction installSection(inputs: DocsInputs): string[] {\n const { inventory } = inputs;\n return installLines(\n `${inventory.name} Uplink`,\n inventory.id,\n readUplinkDeclaration(inputs.pkg.dir)?.declared,\n );\n}\n\n/** The Install section for an Uplink named `label`, from its `uplink.json` when it has one. */\nfunction installLines(\n label: string,\n id: string,\n declared: UplinkDeclaration | undefined,\n): string[] {\n if (!declared) {\n return [\n \"## Install\",\n \"\",\n `The ${label} comes with Gonogo, so there is nothing separate to install. Installing Gonogo installs it.`,\n \"\",\n ];\n }\n const gamedata = declared.gamedata;\n if (!gamedata) {\n throw new Error(\n \"uplink-tools docs: uplink.json declares no `gamedata`, and the page's Install \" +\n \"section names the CKAN entry and the zip after it. Add the name of the folder \" +\n 'the plugin installs into under GameData, such as \"GonogoExampleUplink\".',\n );\n }\n const lines = [\n \"## Install\",\n \"\",\n `Install the ${label} with CKAN: search for \\`${gamedata}\\`, tick it and apply. CKAN also installs Gonogo itself${declared.mod?.name ? ` and ${declared.mod.name}` : \"\"}.`,\n \"\",\n `Without CKAN, download \\`${gamedata}.zip\\` from the releases page, unpack it into your Kerbal Space Program folder so that it lands in \\`GameData/${gamedata}\\`, and install Gonogo the same way.`,\n \"\",\n ];\n const releases = releasesUrl(declared.repo, id);\n if (releases) lines.push(`Releases: ${releases}`, \"\");\n return lines;\n}\n\n/** The releases page of the Uplink's repository, narrowed to this Uplink's tags (`<id>-v<version>`) on GitHub. */\nfunction releasesUrl(repo: string | undefined, id: string): string | undefined {\n if (!repo) return undefined;\n const base = repo.replace(/\\/+$/, \"\").replace(/\\.git$/, \"\");\n try {\n if (new URL(base).hostname !== \"github.com\") return `${base}/releases`;\n } catch {\n return undefined;\n }\n return `${base}/releases?q=${encodeURIComponent(`${id}-v`)}`;\n}\n\n/**\n * The first line of every generated `README.md`, and the thing `docs` and `page`\n * look for before they overwrite one. It names both because either writes it.\n * It tells a generated README, which may be overwritten, from one an author\n * wrote, which may not.\n */\nexport const README_GENERATED_MARKER =\n \"<!-- Generated by `uplink-tools docs` or `uplink-tools page`.\";\n\n/** Backticked, comma-joined, or the kit's empty-value mark for a table cell with nothing in it. */\nfunction list(items: readonly string[]): string {\n return items.length > 0\n ? items.map((i) => `\\`${i}\\``).join(\", \")\n : NULL_DISPLAY;\n}\n\n/** A two-column fact table, skipping every row whose value is empty. */\nfunction facts(rows: ReadonlyArray<[string, string | undefined]>): string[] {\n const present = rows.filter(\n ([, value]) => value !== undefined && value !== \"\",\n );\n if (present.length === 0) return [];\n return [\n \"| | |\",\n \"| --- | --- |\",\n ...present.map(([label, value]) => `| ${label} | ${value} |`),\n \"\",\n ];\n}\n\n/** A headed table, or nothing at all when it would have no rows. */\nfunction table(\n headers: readonly string[],\n rows: readonly string[][],\n): string[] {\n if (rows.length === 0) return [];\n return [\n `| ${headers.join(\" | \")} |`,\n `| ${headers.map(() => \"---\").join(\" | \")} |`,\n ...rows.map((cells) => `| ${cells.join(\" | \")} |`),\n \"\",\n ];\n}\n\n/** Where a player finds Gonogo itself. */\nconst GONOGO_URL = \"https://ksp-gonogo.github.io/\";\n\n/**\n * The width, in pixels, every picture on the page is shown at. GitHub ignores\n * CSS in markdown, so the width is an attribute of an `<img>` tag; each picture\n * links to its full-size file.\n */\nexport const PAGE_IMAGE_WIDTH = 400;\n\n/** The width of a picture in the page's gallery of what the Uplink adds to other widgets. */\nexport const GALLERY_IMAGE_WIDTH = 280;\n\n/** Pictures per gallery row. */\nconst GALLERY_COLUMNS = 3;\n\n/** Text safe inside a double-quoted HTML attribute. */\nfunction attr(text: string): string {\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\");\n}\n\n/**\n * Lines wrapped in a collapsed `<details>` block, opened by `summary`.\n *\n * The blank lines after `<summary>` and before `</details>` are what make\n * GitHub render the markdown inside. A leading `## ` heading in `lines` is\n * dropped, since the summary names the block.\n */\nfunction collapsed(summary: string, lines: readonly string[]): string[] {\n const headed = lines[0]?.startsWith(\"## \");\n const content = headed ? lines.slice(lines[1] === \"\" ? 2 : 1) : [...lines];\n if (content.every((l) => l === \"\")) return [];\n return [\n \"<details>\",\n `<summary>${summary}</summary>`,\n \"\",\n ...content,\n ...(content[content.length - 1] === \"\" ? [] : [\"\"]),\n \"</details>\",\n \"\",\n ];\n}\n\n/**\n * The images for one registration, each an `<img>` inside a link to the\n * full-size file. A picture is shown at `width` pixels, or at the size it was\n * drawn at when that is smaller, so a small widget is not enlarged.\n *\n * The scene's caption goes in the alt, where a screen reader and a\n * broken-image placeholder both find it.\n *\n * A picture that has not been drawn is left out. `page` writes this text with\n * no browser, so an Uplink that has never run `docs` has no pictures yet, and a\n * link to one would be a broken image on the page's first day. `docs` draws\n * them before it writes the page, so there they are always found.\n */\nexport function imageLinks(\n pkgDir: string,\n assetDir: string,\n assets: readonly PageAsset[],\n width: number = PAGE_IMAGE_WIDTH,\n): string[] {\n return assets.flatMap((asset) => {\n const tag = imageTag(pkgDir, assetDir, asset, width);\n return tag ? [\"\", tag] : [];\n });\n}\n\n/** One picture as a linked `<img>`, or nothing when it has not been drawn. */\nfunction imageTag(\n pkgDir: string,\n assetDir: string,\n asset: PageAsset,\n width: number,\n): string | undefined {\n const path = `${assetDir}/${asset.file}`;\n if (!existsSync(join(pkgDir, path))) return undefined;\n const fromPage = relative(pageRoot(pkgDir), pkgDir).split(\"\\\\\").join(\"/\");\n const href = attr(encodeURI(fromPage === \"\" ? path : `${fromPage}/${path}`));\n const alt = attr(altFor(asset).replace(/\\s+/g, \" \").trim());\n // Never wider than the size the picture was drawn at, so a small widget is not blown up.\n const natural = asset.scene.modes.find((m) => m.name === asset.mode)?.pxW;\n const shown = natural ? Math.min(width, natural) : width;\n return `<a href=\"${href}\"><img src=\"${href}\" width=\"${shown}\" alt=\"${alt}\"></a>`;\n}\n\nfunction altFor(asset: PageAsset): string {\n return asset.scene.caption ?? asset.scene.name;\n}\n\n/**\n * The page's picture(s) of one registration: every `hero` scene, at its own\n * first mode.\n *\n * A scene's first mode is the one `linkedAssets` records a motion scene's GIF\n * under, so taking it here is what keeps a hero'd motion scene's picture a\n * film rather than the still of some other mode.\n *\n * Throws when a target has scenes and no hero among them, since the author has\n * not yet chosen how to picture it; no fixture is picked by default.\n */\nfunction heroAssetsFor(\n inputs: DocsInputs,\n kind: string,\n id: string,\n): readonly PageAsset[] {\n const scenes = scenesFor(inputs, kind, id);\n if (scenes.length === 0) return [];\n const heroes = new Set(\n scenes.filter((scene) => scene.hero).map((scene) => scene.name),\n );\n if (heroes.size === 0) {\n throw new Error(\n `uplink-tools docs: ${kind} \"${id}\" has ${scenes.length} scene(s) and ` +\n 'none is marked \"_scene.hero\": true, so the page has no picture to ' +\n `show for it:\\n ${scenes.map((s) => s.file).join(\"\\n \")}\\n\\n` +\n 'Mark at least one fixture\\'s \"_scene\" block with \"hero\": true. Any ' +\n \"number may carry it; every one that does is shown.\",\n );\n }\n return inputs.assets.filter(\n (a) =>\n a.scene.target.kind === kind &&\n a.scene.target.id === id &&\n heroes.has(a.scene.name) &&\n a.mode === a.scene.modes[0].name,\n );\n}\n\n/**\n * The scenes declared for one registration, as distinct from the assets rendered\n * from them. One scene becomes several assets (one per size), so counting scenes\n * gives the number of states shown and counting assets the number of pictures.\n */\nfunction scenesFor(inputs: DocsInputs, kind: string, id: string): Scene[] {\n return inputs.scenes.filter(\n (scene) => scene.target.kind === kind && scene.target.id === id,\n );\n}\n\n/**\n * Scenes that assert nothing: those with no `paints`. This is a warning and not a\n * failure, since such a scene still renders, but `paints` is what catches an\n * expected string that does not appear.\n */\nexport function scenesAssertingNothing(inputs: DocsInputs): string[] {\n return inputs.scenes\n .filter((scene) => scene.paints.length === 0)\n .map((scene) => `${scene.target.id} / ${scene.name}`);\n}\n\n/**\n * The Uplink's widgets as {@link WidgetRecord}s, without the harness's own\n * fields such as render sizes. Useful for describing the Uplink's widgets to a\n * reader. Used to build the README's widget sections and `docs/widgets.json`,\n * which both come from this list.\n *\n * @category Uplink page\n */\nexport function widgetRecordsOf(inventory: UplinkInventory): WidgetRecord[] {\n return inventory.widgets.map(({ modes: _m, ...record }) => record);\n}\n\n// Takes the record, never the inventory entry, so nothing reaches a widget's section that `docs/widgets.json` does not also carry.\nfunction widgetSection(inputs: DocsInputs, widget: WidgetRecord): string[] {\n const out = [`### ${widget.name}`, \"\", widget.description, \"\"];\n out.push(\n ...imageLinks(\n inputs.pkg.dir,\n inputs.assetDir,\n heroAssetsFor(inputs, \"widget\", widget.id),\n ),\n \"\",\n );\n const detail = facts([\n ...widgetFactsOf(widget).map((fact): [string, string] => [\n fact.label,\n widgetFactValueMd(fact.items),\n ]),\n ]);\n out.push(...collapsed(\"Widget details\", detail));\n return out;\n}\n\n/**\n * The pictures of what the Uplink adds to other widgets, as a visible gallery:\n * every augment and contribution that has a drawn picture, a small thumbnail\n * each linking to the full size, with the host it adds to beneath. Only the\n * tables stay collapsed.\n *\n * Returns the lines and the assets it shows, which the collapsed tables then\n * leave out.\n */\nfunction addedToOtherWidgets(inputs: DocsInputs): {\n lines: string[];\n shown: ReadonlySet<PageAsset>;\n} {\n const entries = [\n ...inputs.inventory.augments.map((augment) => ({\n kind: \"augment\",\n id: augment.id,\n into: augment.augments,\n })),\n ...inputs.inventory.contributions.map((contribution) => ({\n kind: \"contribution\",\n id: contribution.id,\n into: contribution.contributes,\n })),\n ];\n const cells: string[] = [];\n const shown = new Set<PageAsset>();\n for (const entry of entries) {\n for (const asset of heroAssetsFor(inputs, entry.kind, entry.id)) {\n const tag = imageTag(\n inputs.pkg.dir,\n inputs.assetDir,\n asset,\n GALLERY_IMAGE_WIDTH,\n );\n if (!tag) continue;\n shown.add(asset);\n cells.push(`${tag}<br>\\`${entry.id}\\` in \\`${entry.into}\\``);\n break;\n }\n }\n if (cells.length === 0) return { lines: [], shown };\n const columns = Math.min(GALLERY_COLUMNS, cells.length);\n const rows: string[][] = [];\n for (let i = 0; i < cells.length; i += columns) {\n const row = cells.slice(i, i + columns);\n while (row.length < columns) row.push(\"\");\n rows.push(row);\n }\n return {\n lines: [\n \"## What it adds to other widgets\",\n \"\",\n `|${\" |\".repeat(columns)}`,\n `|${\" --- |\".repeat(columns)}`,\n ...rows.map((row) => `| ${row.join(\" | \")} |`),\n \"\",\n ],\n shown,\n };\n}\n\n/**\n * Every augment in one table, with its images after it, so a reader can compare\n * which host widgets this Uplink reaches into.\n */\nfunction augmentTable(\n inputs: DocsInputs,\n shown: ReadonlySet<PageAsset>,\n): string[] {\n const rows = inputs.inventory.augments.map((augment: InventoryAugment) => {\n const notes: string[] = [];\n if (augment.suppressesVanillaBase) notes.push(\"replaces the host surface\");\n if (augment.settings.length > 0) {\n notes.push(\n `adds ${augment.settings.map((s) => `\\`${s.key}\\` (${s.type})`).join(\", \")}`,\n );\n }\n return [\n `\\`${augment.id}\\``,\n `\\`${augment.augments}\\``,\n list(augment.channels),\n augment.requires ? `only while \\`${augment.requires}\\`` : \"\",\n notes.join(\"; \"),\n ];\n });\n if (rows.length === 0) return [];\n return [\n \"## Augments\",\n \"\",\n ...table([\"Augment\", \"Into\", \"Reads\", \"Presence\", \"Notes\"], rows),\n ...inputs.inventory.augments.flatMap((augment) =>\n imageLinks(\n inputs.pkg.dir,\n inputs.assetDir,\n heroAssetsFor(inputs, \"augment\", augment.id).filter(\n (asset) => !shown.has(asset),\n ),\n ),\n ),\n \"\",\n ];\n}\n\nfunction contributionTable(\n inputs: DocsInputs,\n shown: ReadonlySet<PageAsset>,\n): string[] {\n const rows = inputs.inventory.contributions.map(\n (contribution: InventoryContribution) => [\n `\\`${contribution.id}\\``,\n `\\`${contribution.contributes}\\``,\n list(contribution.deps),\n contribution.requires ? `only while \\`${contribution.requires}\\`` : \"\",\n ],\n );\n if (rows.length === 0) return [];\n return [\n \"## Contributions\",\n \"\",\n ...table([\"Contribution\", \"Into\", \"Computed from\", \"Presence\"], rows),\n ...inputs.inventory.contributions.flatMap((contribution) =>\n imageLinks(\n inputs.pkg.dir,\n inputs.assetDir,\n heroAssetsFor(inputs, \"contribution\", contribution.id).filter(\n (asset) => !shown.has(asset),\n ),\n ),\n ),\n \"\",\n ];\n}\n\n/**\n * The refusal refinements this Uplink answers with, each under the core code a\n * client classifies it by. Absent when the Uplink declares none.\n */\nfunction errorCodeTable(inputs: DocsInputs): string[] {\n return errorCodeSection(inputs.inventory.errorCodes ?? []);\n}\n\n/** The \"Error codes\" section for a list of refinements, or nothing for none. */\nexport function errorCodeSection(\n codes: readonly InventoryErrorCode[],\n): string[] {\n const rows = codes.map((code) => [\n `\\`${code.id}\\``,\n code.refines ? `\\`${code.refines}\\`` : \"\",\n code.sentence,\n code.meaning.replace(/\\s+/g, \" \").trim(),\n ]);\n if (rows.length === 0) return [];\n return [\n \"## Error codes\",\n \"\",\n ...table([\"Code\", \"Refines\", \"Reads as\", \"Meaning\"], rows),\n ];\n}\n\nfunction modelTable(inputs: DocsInputs): string[] {\n const rows = [\n ...inputs.inventory.processors.map((id) => [\"processor\", `\\`${id}\\``]),\n ...inputs.inventory.reckonedTopics.map((id) => [\n \"forward model\",\n `\\`${id}\\``,\n ]),\n ...inputs.inventory.publishedTopics.map((id) => [\n \"published Topic\",\n `\\`${id}\\``,\n ]),\n ];\n if (rows.length === 0) return [];\n return [\n \"## Models\",\n \"\",\n ...table([\"Kind\", \"Id\"], rows),\n ...inputRuleExemptions(inputs),\n ];\n}\n\n/**\n * The input rules this Uplink's models opted out of, under the same heading the\n * models themselves are listed under.\n *\n * Absent when there are none: the store holds every model to a reach no further\n * than its inputs and a band no wider than its inputs warrant, so a page with no\n * such table has models that take both defaults.\n */\nfunction inputRuleExemptions(inputs: DocsInputs): string[] {\n const rows = inputs.inventory.reckonerExemptions.map((exemption) => [\n `\\`${exemption.topic}\\``,\n exemption.rule,\n exemption.reason,\n ]);\n if (rows.length === 0) return [];\n return [\n \"\",\n \"### Input rules these models opt out of\",\n \"\",\n ...table([\"Topic\", \"Rule\", \"Why it is sound\"], rows),\n ];\n}\n\n/** The generated page's opening: marker, title, description, the Gonogo sentence, the wrapped mod and Install. */\nfunction readmeHead(parts: {\n name: string;\n description: string;\n mod: DeclaredMod | undefined;\n install: string[];\n}): string[] {\n const { name, description, mod, install } = parts;\n return [\n `${README_GENERATED_MARKER} Do not edit this file: it is written`,\n \" from the registrations, the contract slice and the fixtures. -->\",\n \"\",\n `# ${name}`,\n \"\",\n // Whitespace collapsed, not just trimmed. A description written across source\n // lines arrives carrying the newline and the source indent, and four spaces at\n // the start of a markdown line is a CODE BLOCK: the Uplink's one sentence\n // would render as monospace with a scrollbar.\n description.replace(/\\s+/g, \" \").trim(),\n \"\",\n `An Uplink for [Gonogo](${GONOGO_URL}), the mission-control dashboard for Kerbal Space Program that runs in a web browser on any screen.`,\n \"\",\n ...(mod?.name\n ? [\n `Built against ${mod.name}${mod.builtAgainst ? ` ${mod.builtAgainst}` : \"\"}.`,\n \"\",\n ]\n : []),\n ...install,\n ];\n}\n\n/**\n * The README of an Uplink with no client package, from its `uplink.json` alone.\n * It is the opening and Install of a client-based page and nothing else, since\n * the widgets, pictures and topics come from a client's registrations. Useful\n * for giving a plugin-only Uplink the same page every other Uplink has. Used by\n * `uplink-tools page`.\n */\nexport function buildClientlessReadme(declared: UplinkDeclaration): string {\n if (!declared.description?.trim()) {\n throw new Error(\n \"uplink-tools page: this Uplink has no client, so its page is written from uplink.json \" +\n \"alone, and the page opens with the `description` field, which uplink.json does not \" +\n \"have.\\n\\nAdd one to uplink.json, in one or two sentences saying what the Uplink does:\\n\" +\n ' \"description\": \"...\"',\n );\n }\n if (!declared.name?.trim() || !declared.id?.trim()) {\n throw new Error(\n \"uplink-tools page: this Uplink has no client, so its page is written from uplink.json \" +\n \"alone, and uplink.json needs both an `id` and a `name` for it.\",\n );\n }\n const out = readmeHead({\n name: declared.name,\n description: declared.description,\n mod: declared.mod ?? undefined,\n install: installLines(`${declared.name} Uplink`, declared.id, declared),\n });\n return `${out.join(\"\\n\").replace(/\\n{3,}/g, \"\\n\\n\")}\\n`;\n}\n\n/**\n * The Uplink's generated page as markdown, built from its description, widgets,\n * augments, contributions, channels and error codes. Throws when the client\n * declares no `description`, which opens the page, or a widget registers none.\n * Useful for keeping an Uplink's README current with what its client registers.\n * Used by `uplink-tools docs` and `page` and by the page check.\n *\n * @category Uplink page\n * @categoryDescription Uplink page\n * The page an Uplink publishes about itself: its README, the manifest beside\n * its bundle, its widget records, and the channels and payloads it puts on the\n * wire, all generated from the code.\n */\nexport function buildReadme(\n inputs: DocsInputs,\n manifest: UplinkManifestJson,\n): string {\n const { inventory } = inputs;\n if (!inventory.description?.trim()) {\n throw new Error(\n \"uplink-tools docs: this client declares no `description`, and the page \" +\n \"opens with it.\\n\\n\" +\n \"Add one to `defineUplinkClient` in client/src/uplink.ts, in one or two \" +\n \"sentences saying what the Uplink does:\\n\" +\n ' defineUplinkClient({ id, version, name, description: \"...\" })\\n\\n' +\n \"It is a field rather than a prose file on purpose. Everything else on \" +\n \"the page comes from your registrations, your contract slice and your \" +\n \"fixtures, so this is the only sentence anyone writes.\",\n );\n }\n\n const wire = readWireSurface(inputs.pkg.dir);\n const mod = declaredMod(inputs.pkg.dir);\n const out: string[] = readmeHead({\n name: inventory.name,\n description: inventory.description,\n mod,\n install: installSection(inputs),\n });\n\n const records = widgetRecordsOf(inventory);\n const undescribed = records.filter((widget) => !widget.description?.trim());\n if (undescribed.length > 0) {\n throw new Error(\n `uplink-tools docs: ${undescribed.map((widget) => `\\`${widget.id}\\``).join(\", \")} ` +\n `register${undescribed.length === 1 ? \"s\" : \"\"} no \\`description\\`, and it is the one ` +\n \"sentence the page and the widget picker have for a widget.\\n\\n\" +\n \"Add one where the widget is registered, in plain words: what it shows \" +\n \"and what an operator can do with it.\\n\" +\n ' registerComponent({ id, name, description: \"...\", ... })',\n );\n }\n if (records.length > 0) {\n out.push(\"## Widgets\", \"\");\n for (const widget of records) {\n out.push(...widgetSection(inputs, widget), \"\");\n }\n }\n const added = addedToOtherWidgets(inputs);\n out.push(...added.lines);\n const developer = [\n ...collapsed(\n \"Uplink details\",\n facts([\n [\"Uplink id\", `\\`${inventory.id}\\``],\n [\n \"Wraps\",\n mod?.tier ? `${mod.name ?? \"\"} (${mod.tier})`.trim() : undefined,\n ],\n [\"Version\", `\\`${inventory.version}\\``],\n [\n \"Built against\",\n `contract ${manifest.contractMajor}.${manifest.contractMinor}, extension API ${manifest.apiVersion}`,\n ],\n ]),\n ),\n ...collapsed(\"Topics\", wireSection(wire)),\n ...collapsed(\"Commands\", commandSection(wire)),\n ...collapsed(\"Augments\", augmentTable(inputs, added.shown)),\n ...collapsed(\"Contributions\", contributionTable(inputs, added.shown)),\n ...collapsed(\"Models\", modelTable(inputs)),\n ...collapsed(\"Error codes\", errorCodeTable(inputs)),\n ];\n out.push(\"## For developers\", \"\", ...developer);\n\n return `${out.join(\"\\n\").replace(/\\n{3,}/g, \"\\n\\n\")}\\n`;\n}\n"],"mappings":";;;;;;AAAA,SAAS,YAAY,aAAa,oBAAoB;AACtD,SAAS,MAAM,eAAe;AAwB9B,SAAS,MAAM,QAAwB;AACrC,SAAO,OACJ,QAAQ,sBAAsB,OAAO,EACrC,QAAQ,yBAAyB,OAAO,EACxC,YAAY;AACjB;AAWA,SAAS,iBAAiB,QAA0B;AAClD,QAAM,QAAkB,CAAC;AACzB,MAAI,MAAM;AACV,WAAS,KAAK,GAAG,KAAK,GAAG,MAAM;AAC7B,UAAM,QAAQ,KAAK,IAAI;AACvB,eAAW,MAAM,CAAC,KAAK,KAAK,KAAK,KAAK,CAAC,GAAG;AACxC,UAAI,CAAC,WAAW,EAAE,EAAG;AACrB,UAAI;AACF,mBAAW,SAAS,YAAY,IAAI,EAAE,eAAe,KAAK,CAAC,GAAG;AAC5D,cAAI,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,KAAK,GAAG;AAChD,kBAAM,KAAK,KAAK,IAAI,MAAM,IAAI,CAAC;AAAA,UACjC;AAAA,QACF;AAAA,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U,UAAU,WAAW,MAAM,CAAC;AAAA,IACzC,GAAG,UAAU,eAAe,eAAe,MAAM,CAAC;AAAA,EACpD;AACA,MAAI,KAAK,qBAAqB,IAAI,GAAG,SAAS;AAE9C,SAAO,GAAG,IAAI,KAAK,IAAI,EAAE,QAAQ,WAAW,MAAM,CAAC;AAAA;AACrD;","names":["existsSync","readFileSync","join","join","existsSync","readFileSync","list","existsSync","readFileSync","join","resolve","readFileSync","join","resolve","existsSync"]}