@marinoscar/platform-cli 0.1.0-next.22 → 0.1.0-next.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +6 -1
  3. package/dist/engine/commands/node.d.ts.map +1 -1
  4. package/dist/engine/commands/node.js +8 -0
  5. package/dist/engine/commands/node.js.map +1 -1
  6. package/dist/engine/config.d.ts +38 -0
  7. package/dist/engine/config.d.ts.map +1 -1
  8. package/dist/engine/config.js +55 -0
  9. package/dist/engine/config.js.map +1 -1
  10. package/dist/engine/create-cli.d.ts +29 -0
  11. package/dist/engine/create-cli.d.ts.map +1 -1
  12. package/dist/engine/create-cli.js +18 -0
  13. package/dist/engine/create-cli.js.map +1 -1
  14. package/dist/engine/index.d.ts +28 -3
  15. package/dist/engine/index.d.ts.map +1 -1
  16. package/dist/engine/index.js +15 -1
  17. package/dist/engine/index.js.map +1 -1
  18. package/dist/engine/node/daemon-channels.d.ts +66 -0
  19. package/dist/engine/node/daemon-channels.d.ts.map +1 -0
  20. package/dist/engine/node/daemon-channels.js +65 -0
  21. package/dist/engine/node/daemon-channels.js.map +1 -0
  22. package/dist/engine/node/daemon.d.ts.map +1 -1
  23. package/dist/engine/node/daemon.js +52 -0
  24. package/dist/engine/node/daemon.js.map +1 -1
  25. package/dist/engine/node/executors/credential-hygiene.d.ts +1 -1
  26. package/dist/engine/node/executors/credential-hygiene.d.ts.map +1 -1
  27. package/dist/engine/node/executors/credential-hygiene.js +23 -2
  28. package/dist/engine/node/executors/credential-hygiene.js.map +1 -1
  29. package/dist/engine/node/executors/index.d.ts +52 -7
  30. package/dist/engine/node/executors/index.d.ts.map +1 -1
  31. package/dist/engine/node/executors/index.js +14 -0
  32. package/dist/engine/node/executors/index.js.map +1 -1
  33. package/dist/engine/node/executors/registry.d.ts.map +1 -1
  34. package/dist/engine/node/executors/registry.js +13 -2
  35. package/dist/engine/node/executors/registry.js.map +1 -1
  36. package/dist/engine/node/ipc-protocol.d.ts +49 -2
  37. package/dist/engine/node/ipc-protocol.d.ts.map +1 -1
  38. package/dist/engine/node/ipc-protocol.js +39 -0
  39. package/dist/engine/node/ipc-protocol.js.map +1 -1
  40. package/dist/engine/node/lifecycle.js +2 -1
  41. package/dist/engine/node/lifecycle.js.map +1 -1
  42. package/dist/engine/node/logger.d.ts +13 -0
  43. package/dist/engine/node/logger.d.ts.map +1 -1
  44. package/dist/engine/node/logger.js.map +1 -1
  45. package/dist/engine/node/memory-watchdog.d.ts +11 -0
  46. package/dist/engine/node/memory-watchdog.d.ts.map +1 -1
  47. package/dist/engine/node/memory-watchdog.js +28 -4
  48. package/dist/engine/node/memory-watchdog.js.map +1 -1
  49. package/dist/engine/node/node-dashboard-source.d.ts +46 -19
  50. package/dist/engine/node/node-dashboard-source.d.ts.map +1 -1
  51. package/dist/engine/node/node-dashboard-source.js +70 -102
  52. package/dist/engine/node/node-dashboard-source.js.map +1 -1
  53. package/dist/engine/node/node-engine.d.ts +7 -1
  54. package/dist/engine/node/node-engine.d.ts.map +1 -1
  55. package/dist/engine/node/node-engine.js +81 -8
  56. package/dist/engine/node/node-engine.js.map +1 -1
  57. package/dist/engine/node/runtime-state.d.ts +24 -0
  58. package/dist/engine/node/runtime-state.d.ts.map +1 -0
  59. package/dist/engine/node/runtime-state.js +19 -0
  60. package/dist/engine/node/runtime-state.js.map +1 -0
  61. package/dist/engine/node/runtime-tuning.d.ts +111 -2
  62. package/dist/engine/node/runtime-tuning.d.ts.map +1 -1
  63. package/dist/engine/node/runtime-tuning.js +133 -4
  64. package/dist/engine/node/runtime-tuning.js.map +1 -1
  65. package/dist/engine/node/service.d.ts.map +1 -1
  66. package/dist/engine/node/service.js +4 -0
  67. package/dist/engine/node/service.js.map +1 -1
  68. package/dist/engine/node/start.d.ts +7 -0
  69. package/dist/engine/node/start.d.ts.map +1 -1
  70. package/dist/engine/node/start.js +33 -1
  71. package/dist/engine/node/start.js.map +1 -1
  72. package/dist/engine/node/worker-env-aliases.d.ts +39 -0
  73. package/dist/engine/node/worker-env-aliases.d.ts.map +1 -0
  74. package/dist/engine/node/worker-env-aliases.js +126 -0
  75. package/dist/engine/node/worker-env-aliases.js.map +1 -0
  76. package/dist/engine/node/worker-env-table.d.ts.map +1 -1
  77. package/dist/engine/node/worker-env-table.js +4 -1
  78. package/dist/engine/node/worker-env-table.js.map +1 -1
  79. package/dist/engine/node/worker-env.d.ts +13 -1
  80. package/dist/engine/node/worker-env.d.ts.map +1 -1
  81. package/dist/engine/node/worker-env.js +8 -0
  82. package/dist/engine/node/worker-env.js.map +1 -1
  83. package/dist/engine/registries.d.ts.map +1 -1
  84. package/dist/engine/registries.js +10 -0
  85. package/dist/engine/registries.js.map +1 -1
  86. package/dist/engine/tui/app-registry.d.ts +103 -0
  87. package/dist/engine/tui/app-registry.d.ts.map +1 -0
  88. package/dist/engine/tui/app-registry.js +103 -0
  89. package/dist/engine/tui/app-registry.js.map +1 -0
  90. package/dist/engine/tui/app.d.ts +9 -1
  91. package/dist/engine/tui/app.d.ts.map +1 -1
  92. package/dist/engine/tui/app.js +52 -18
  93. package/dist/engine/tui/app.js.map +1 -1
  94. package/dist/engine/tui/builtin-screens.d.ts.map +1 -1
  95. package/dist/engine/tui/builtin-screens.js +6 -0
  96. package/dist/engine/tui/builtin-screens.js.map +1 -1
  97. package/dist/engine/tui/context.d.ts +220 -0
  98. package/dist/engine/tui/context.d.ts.map +1 -0
  99. package/dist/engine/tui/context.js +258 -0
  100. package/dist/engine/tui/context.js.map +1 -0
  101. package/dist/engine/tui/dashboard/index.d.ts +8 -0
  102. package/dist/engine/tui/dashboard/index.d.ts.map +1 -0
  103. package/dist/engine/tui/dashboard/index.js +5 -0
  104. package/dist/engine/tui/dashboard/index.js.map +1 -0
  105. package/dist/engine/tui/dashboard/jobs-insights.d.ts +145 -0
  106. package/dist/engine/tui/dashboard/jobs-insights.d.ts.map +1 -0
  107. package/dist/engine/tui/dashboard/jobs-insights.js +63 -0
  108. package/dist/engine/tui/dashboard/jobs-insights.js.map +1 -0
  109. package/dist/engine/tui/dashboard/node-embedded.d.ts +33 -0
  110. package/dist/engine/tui/dashboard/node-embedded.d.ts.map +1 -0
  111. package/dist/engine/tui/dashboard/node-embedded.js +81 -0
  112. package/dist/engine/tui/dashboard/node-embedded.js.map +1 -0
  113. package/dist/engine/tui/dashboard/source.d.ts +274 -0
  114. package/dist/engine/tui/dashboard/source.d.ts.map +1 -0
  115. package/dist/engine/tui/dashboard/source.js +351 -0
  116. package/dist/engine/tui/dashboard/source.js.map +1 -0
  117. package/dist/engine/tui/dashboard/use-dashboard.d.ts +23 -0
  118. package/dist/engine/tui/dashboard/use-dashboard.d.ts.map +1 -0
  119. package/dist/engine/tui/dashboard/use-dashboard.js +32 -0
  120. package/dist/engine/tui/dashboard/use-dashboard.js.map +1 -0
  121. package/dist/engine/tui/index.d.ts +2 -0
  122. package/dist/engine/tui/index.d.ts.map +1 -1
  123. package/dist/engine/tui/index.js +19 -1
  124. package/dist/engine/tui/index.js.map +1 -1
  125. package/dist/engine/tui/layout.d.ts +20 -0
  126. package/dist/engine/tui/layout.d.ts.map +1 -1
  127. package/dist/engine/tui/layout.js +17 -3
  128. package/dist/engine/tui/layout.js.map +1 -1
  129. package/dist/engine/tui/menu-registry.d.ts +124 -0
  130. package/dist/engine/tui/menu-registry.d.ts.map +1 -0
  131. package/dist/engine/tui/menu-registry.js +151 -0
  132. package/dist/engine/tui/menu-registry.js.map +1 -0
  133. package/dist/engine/tui/menu-tree.d.ts +179 -0
  134. package/dist/engine/tui/menu-tree.d.ts.map +1 -0
  135. package/dist/engine/tui/menu-tree.js +250 -0
  136. package/dist/engine/tui/menu-tree.js.map +1 -0
  137. package/dist/engine/tui/raw-mode.d.ts +54 -0
  138. package/dist/engine/tui/raw-mode.d.ts.map +1 -0
  139. package/dist/engine/tui/raw-mode.js +106 -0
  140. package/dist/engine/tui/raw-mode.js.map +1 -0
  141. package/dist/engine/tui/screen-registry.d.ts +4 -2
  142. package/dist/engine/tui/screen-registry.d.ts.map +1 -1
  143. package/dist/engine/tui/screen-registry.js +2 -1
  144. package/dist/engine/tui/screen-registry.js.map +1 -1
  145. package/dist/engine/tui/screens/invoke.d.ts.map +1 -1
  146. package/dist/engine/tui/screens/invoke.js +5 -2
  147. package/dist/engine/tui/screens/invoke.js.map +1 -1
  148. package/dist/engine/tui/screens/jobs.d.ts +12 -0
  149. package/dist/engine/tui/screens/jobs.d.ts.map +1 -0
  150. package/dist/engine/tui/screens/jobs.js +72 -0
  151. package/dist/engine/tui/screens/jobs.js.map +1 -0
  152. package/dist/engine/tui/screens/login.d.ts.map +1 -1
  153. package/dist/engine/tui/screens/login.js +17 -9
  154. package/dist/engine/tui/screens/login.js.map +1 -1
  155. package/dist/engine/tui/screens/logout.d.ts.map +1 -1
  156. package/dist/engine/tui/screens/logout.js +12 -5
  157. package/dist/engine/tui/screens/logout.js.map +1 -1
  158. package/dist/engine/tui/screens/menu.d.ts +4 -1
  159. package/dist/engine/tui/screens/menu.d.ts.map +1 -1
  160. package/dist/engine/tui/screens/menu.js +90 -60
  161. package/dist/engine/tui/screens/menu.js.map +1 -1
  162. package/dist/engine/tui/screens/node.d.ts.map +1 -1
  163. package/dist/engine/tui/screens/node.js +88 -39
  164. package/dist/engine/tui/screens/node.js.map +1 -1
  165. package/dist/engine/tui/screens/not-logged-in.d.ts +12 -0
  166. package/dist/engine/tui/screens/not-logged-in.d.ts.map +1 -0
  167. package/dist/engine/tui/screens/not-logged-in.js +14 -0
  168. package/dist/engine/tui/screens/not-logged-in.js.map +1 -0
  169. package/dist/engine/tui/screens/status.d.ts.map +1 -1
  170. package/dist/engine/tui/screens/status.js +8 -4
  171. package/dist/engine/tui/screens/status.js.map +1 -1
  172. package/dist/engine/tui/scroll-box.d.ts +15 -0
  173. package/dist/engine/tui/scroll-box.d.ts.map +1 -1
  174. package/dist/engine/tui/scroll-box.js +10 -0
  175. package/dist/engine/tui/scroll-box.js.map +1 -1
  176. package/dist/engine/tui/theme.d.ts +179 -0
  177. package/dist/engine/tui/theme.d.ts.map +1 -0
  178. package/dist/engine/tui/theme.js +111 -0
  179. package/dist/engine/tui/theme.js.map +1 -0
  180. package/dist/engine/tui/tty.d.ts +7 -0
  181. package/dist/engine/tui/tty.d.ts.map +1 -1
  182. package/dist/engine/tui/tty.js +8 -1
  183. package/dist/engine/tui/tty.js.map +1 -1
  184. package/dist/engine/tui/ui/active-items.d.ts +40 -0
  185. package/dist/engine/tui/ui/active-items.d.ts.map +1 -0
  186. package/dist/engine/tui/ui/active-items.js +38 -0
  187. package/dist/engine/tui/ui/active-items.js.map +1 -0
  188. package/dist/engine/tui/ui/event-log.d.ts +58 -0
  189. package/dist/engine/tui/ui/event-log.d.ts.map +1 -0
  190. package/dist/engine/tui/ui/event-log.js +32 -0
  191. package/dist/engine/tui/ui/event-log.js.map +1 -0
  192. package/dist/engine/tui/ui/index.d.ts +20 -0
  193. package/dist/engine/tui/ui/index.d.ts.map +1 -0
  194. package/dist/engine/tui/ui/index.js +14 -0
  195. package/dist/engine/tui/ui/index.js.map +1 -0
  196. package/dist/engine/tui/ui/meter-legend.d.ts +26 -0
  197. package/dist/engine/tui/ui/meter-legend.d.ts.map +1 -0
  198. package/dist/engine/tui/ui/meter-legend.js +25 -0
  199. package/dist/engine/tui/ui/meter-legend.js.map +1 -0
  200. package/dist/engine/tui/ui/run-summary.d.ts +58 -0
  201. package/dist/engine/tui/ui/run-summary.d.ts.map +1 -0
  202. package/dist/engine/tui/ui/run-summary.js +29 -0
  203. package/dist/engine/tui/ui/run-summary.js.map +1 -0
  204. package/dist/engine/tui/ui/segment-meter.d.ts +72 -0
  205. package/dist/engine/tui/ui/segment-meter.d.ts.map +1 -0
  206. package/dist/engine/tui/ui/segment-meter.js +128 -0
  207. package/dist/engine/tui/ui/segment-meter.js.map +1 -0
  208. package/dist/engine/tui/ui/status-line.d.ts +42 -0
  209. package/dist/engine/tui/ui/status-line.d.ts.map +1 -0
  210. package/dist/engine/tui/ui/status-line.js +35 -0
  211. package/dist/engine/tui/ui/status-line.js.map +1 -0
  212. package/dist/engine/tui/ui/tone.d.ts +46 -0
  213. package/dist/engine/tui/ui/tone.d.ts.map +1 -0
  214. package/dist/engine/tui/ui/tone.js +48 -0
  215. package/dist/engine/tui/ui/tone.js.map +1 -0
  216. package/dist/node/index.d.ts +2 -2
  217. package/dist/node/index.d.ts.map +1 -1
  218. package/dist/node/index.js +1 -1
  219. package/dist/node/index.js.map +1 -1
  220. package/dist/tui/index.d.ts +2 -2
  221. package/dist/tui/index.d.ts.map +1 -1
  222. package/dist/tui/index.js +6 -4
  223. package/dist/tui/index.js.map +1 -1
  224. package/dist/tui/ui/index.d.ts +2 -0
  225. package/dist/tui/ui/index.d.ts.map +1 -0
  226. package/dist/tui/ui/index.js +10 -0
  227. package/dist/tui/ui/index.js.map +1 -0
  228. package/package.json +8 -3
@@ -0,0 +1,32 @@
1
+ import { useEffect, useSyncExternalStore } from 'react';
2
+ /**
3
+ * Subscribes a screen to a {@link DashboardSource}: starts it on mount, stops
4
+ * it on unmount, and re-renders on every new state.
5
+ *
6
+ * The source is started and stopped by the hook, so build it once (in a
7
+ * `useMemo` or a ref) and pass the same instance on every render. Stopping
8
+ * on unmount is what keeps a reconnect timer or a poll from outliving the
9
+ * screen and holding the ink process open.
10
+ *
11
+ * @typeParam S - The dashboard's data.
12
+ * @typeParam E - One event.
13
+ * @param source - The source to follow; `undefined` renders nothing and starts nothing.
14
+ * @returns The current state (data plus connection fields), or `undefined` with no source.
15
+ * @stability experimental
16
+ * @example
17
+ * ```tsx
18
+ * const source = useMemo(() => new DashboardSource(jobsInsightsReducer, pollFeed(fetchJobs, { intervalMs: 5000 })), []);
19
+ * const state = useDashboard(source);
20
+ * ```
21
+ */
22
+ export function useDashboard(source) {
23
+ const state = useSyncExternalStore((listener) => source?.subscribe(listener) ?? (() => { }), () => source?.getState());
24
+ useEffect(() => {
25
+ if (source === undefined)
26
+ return;
27
+ void source.start();
28
+ return () => source.stop();
29
+ }, [source]);
30
+ return state;
31
+ }
32
+ //# sourceMappingURL=use-dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-dashboard.js","sourceRoot":"","sources":["../../../../src/engine/tui/dashboard/use-dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,YAAY,CAAO,MAAyC;IAC1E,MAAM,KAAK,GAAG,oBAAoB,CAChC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EACvD,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,CACzB,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO;QACjC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export interface StartTuiOptions {
2
2
  stdout?: NodeJS.WriteStream | undefined;
3
3
  stdin?: NodeJS.ReadStream | undefined;
4
+ /** Opens the controlling terminal when stdin cannot take raw mode (a test seam; defaults to `/dev/tty`). */
5
+ openTerminal?: (() => NodeJS.ReadStream | undefined) | undefined;
4
6
  }
5
7
  /**
6
8
  * Mount the app and resolve with the process exit code once it unmounts.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/tui/index.tsx"],"names":[],"mappings":"AAsBA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAiDzE;AAED,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/tui/index.tsx"],"names":[],"mappings":"AAwBA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;IACtC,4GAA4G;IAC5G,YAAY,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;CAClE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAoEzE;AAED,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -2,6 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render } from 'ink';
3
3
  import { EXIT, exitCodeFor, formatError } from '../errors.js';
4
4
  import { App } from './app.js';
5
+ import { cliName } from '../identity.js';
6
+ import { resolveInteractiveStdin } from './raw-mode.js';
5
7
  import { installTerminalRestore, restoreTerminal } from './terminal.js';
6
8
  /**
7
9
  * Mount the app and resolve with the process exit code once it unmounts.
@@ -20,7 +22,21 @@ import { installTerminalRestore, restoreTerminal } from './terminal.js';
20
22
  */
21
23
  export async function startTui(options) {
22
24
  const stdout = options?.stdout ?? process.stdout;
23
- const stdin = options?.stdin ?? process.stdin;
25
+ // A stdin ink can put in raw mode: the given one, else the controlling
26
+ // terminal. `setRawMode` throws EIO on serial, hypervisor and LXC consoles
27
+ // and when fd 0 is redirected; ink would surface that from `render` as a
28
+ // stack trace. With no usable terminal at all, say so and exit through the
29
+ // same path the TTY gate uses (usage error), never a throw.
30
+ const interactive = resolveInteractiveStdin({
31
+ stdin: options?.stdin ?? process.stdin,
32
+ ...(options?.openTerminal === undefined ? {} : { openTerminal: options.openTerminal }),
33
+ });
34
+ if (interactive === null) {
35
+ process.stderr.write(`This terminal cannot run the interactive interface (raw keyboard input is unavailable). ` +
36
+ `Connect with a pseudo-terminal (ssh -t), or run \`${cliName()} --help\` to see the commands.\n`);
37
+ return EXIT.USAGE;
38
+ }
39
+ const stdin = interactive.stream;
24
40
  // Installed BEFORE the first frame, removed in the `finally`. Between those
25
41
  // two points the process may die in ways ink cannot see — a SIGTERM from
26
42
  // another terminal, a SIGHUP when the window closes, a throw in our own async
@@ -65,6 +81,8 @@ export async function startTui(options) {
65
81
  // the rest of the process's life.
66
82
  restoreTerminal({ stdout, stdin });
67
83
  uninstallRestore();
84
+ // Destroys the controlling-terminal stream when this function opened one.
85
+ interactive.release();
68
86
  }
69
87
  }
70
88
  export { evaluateTuiGate, noTuiEnvVar } from './tty.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/tui/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAuBxE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CA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halved is a normal
16
16
  * case, and a TUI that says "your terminal is too small" to someone who can
17
17
  * plainly see text on it is a TUI they stop using.
18
+ * @stability experimental
18
19
  */
19
20
  export declare const NARROW_COLUMNS = 56;
20
21
  /**
@@ -22,10 +23,18 @@ export declare const NARROW_COLUMNS = 56;
22
23
  *
23
24
  * Thirty is about the width of a phone-sized SSH session. There is no useful
24
25
  * layout left at this size, only content, so that is all that is drawn.
26
+ * @stability experimental
25
27
  */
26
28
  export declare const TINY_COLUMNS = 30;
29
+ /**
30
+ * The terminal size and the width tier it falls in.
31
+ *
32
+ * @stability experimental
33
+ */
27
34
  export interface TerminalSize {
35
+ /** Width in cells (80 when the terminal will not say). */
28
36
  columns: number;
37
+ /** Height in rows (24 when the terminal will not say). */
29
38
  rows: number;
30
39
  /** `columns < NARROW_COLUMNS`. Drop borders and side padding. */
31
40
  narrow: boolean;
@@ -45,6 +54,7 @@ export interface TerminalSize {
45
54
  * The listener is removed on unmount. `process.stdout` is a long-lived emitter
46
55
  * shared with the whole runtime, so a leaked listener here outlives the UI and
47
56
  * fires against unmounted components for the rest of the process's life.
57
+ * @stability experimental
48
58
  */
49
59
  export declare function useTerminalSize(): TerminalSize;
50
60
  /**
@@ -65,11 +75,17 @@ export declare function useTerminalSize(): TerminalSize;
65
75
  * `true` and defeat the whole thing.
66
76
  */
67
77
  export declare function useIsMounted(): () => boolean;
78
+ /**
79
+ * Props of {@link Frame}.
80
+ *
81
+ * @stability experimental
82
+ */
68
83
  export interface FrameProps {
69
84
  /** Screen name, shown in the header. */
70
85
  title: string;
71
86
  /** Key hints for the bottom line, e.g. `['↑↓ move', 'enter select']`. */
72
87
  hints?: string[];
88
+ /** The screen content. */
73
89
  children: ReactNode;
74
90
  }
75
91
  /**
@@ -87,6 +103,7 @@ export interface FrameProps {
87
103
  * so the right-hand edge wraps onto the next line and every frame ends with a
88
104
  * row of orphaned box characters. Letting the box size itself and constraining
89
105
  * only the CONTENT is what keeps the frame intact at every width.
106
+ * @stability experimental
90
107
  */
91
108
  export declare function Frame({ title, hints, children }: FrameProps): ReactNode;
92
109
  /**
@@ -99,6 +116,7 @@ export declare function Frame({ title, hints, children }: FrameProps): ReactNode
99
116
  *
100
117
  * Separators are dropped when narrow: at that width the hints wrap, and a
101
118
  * wrapped line beginning with a lone dot reads as corruption.
119
+ * @stability experimental
102
120
  */
103
121
  export declare function KeyHints({ hints }: {
104
122
  hints: string[];
@@ -110,6 +128,7 @@ export declare function KeyHints({ hints }: {
110
128
  * ink measures a Box in cells and these labels are ASCII — padding is exact,
111
129
  * one flex node cheaper per row, and immune to the width-collapse described in
112
130
  * `Frame`.
131
+ * @stability experimental
113
132
  */
114
133
  export declare function Field({ label, value, color, dim, }: {
115
134
  label: string;
@@ -124,6 +143,7 @@ export declare function Field({ label, value, color, dim, }: {
124
143
  * diagnosis. The messages this CLI produces already carry their own remedy
125
144
  * (see errors.ts), so `hint` is for the extra sentence a SCREEN can add and the
126
145
  * error itself cannot — "press r to try again".
146
+ * @stability experimental
127
147
  */
128
148
  export declare function ErrorNotice({ message, hint, }: {
129
149
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/engine/tui/layout.tsx"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAepE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,KAAK,CAAC;AAe/B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,MAAM,EAAE,OAAO,CAAC;IAChB,mEAAmE;IACnE,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAqC9C;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,I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-2,6 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text, useStdout } from 'ink';
3
3
  import { useEffect, useRef, useState } from 'react';
4
4
  import { cliDisplayName, cliVersion } from '../identity.js';
5
+ import { useOptionalTuiApp, useTuiTheme } from './context.js';
6
+ import { textColor } from './theme.js';
5
7
  // =============================================================================
6
8
  // Layout primitives and the narrow-terminal degrade (issue #145, epic #110)
7
9
  // =============================================================================
@@ -28,6 +30,7 @@ import { cliDisplayName, cliVersion } from '../identity.js';
28
30
  * refusal — a user in a tmux split or an 80-column window halved is a normal
29
31
  * case, and a TUI that says "your terminal is too small" to someone who can
30
32
  * plainly see text on it is a TUI they stop using.
33
+ * @stability experimental
31
34
  */
32
35
  export const NARROW_COLUMNS = 56;
33
36
  /**
@@ -35,6 +38,7 @@ export const NARROW_COLUMNS = 56;
35
38
  *
36
39
  * Thirty is about the width of a phone-sized SSH session. There is no useful
37
40
  * layout left at this size, only content, so that is all that is drawn.
41
+ * @stability experimental
38
42
  */
39
43
  export const TINY_COLUMNS = 30;
40
44
  /**
@@ -62,6 +66,7 @@ const FALLBACK_ROWS = 24;
62
66
  * The listener is removed on unmount. `process.stdout` is a long-lived emitter
63
67
  * shared with the whole runtime, so a leaked listener here outlives the UI and
64
68
  * fires against unmounted components for the rest of the process's life.
69
+ * @stability experimental
65
70
  */
66
71
  export function useTerminalSize() {
67
72
  const { stdout } = useStdout();
@@ -145,16 +150,21 @@ export function useIsMounted() {
145
150
  * so the right-hand edge wraps onto the next line and every frame ends with a
146
151
  * row of orphaned box characters. Letting the box size itself and constraining
147
152
  * only the CONTENT is what keeps the frame intact at every width.
153
+ * @stability experimental
148
154
  */
149
155
  export function Frame({ title, hints, children }) {
150
156
  const { narrow, tiny } = useTerminalSize();
157
+ const theme = useTuiTheme();
158
+ const app = useOptionalTuiApp();
159
+ // The app's selections as chips (`[Project: Alpha]`); none registered, none shown.
160
+ const chips = Object.values(app?.selection ?? {}).filter((entry) => entry.text !== undefined);
151
161
  if (tiny) {
152
162
  return _jsx(Box, { flexDirection: "column", children: children });
153
163
  }
154
- const body = (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, color: "cyan", children: cliDisplayName() }), _jsxs(Text, { dimColor: true, children: [" v", cliVersion()] }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { bold: true, children: title })] }), _jsx(Box, { flexDirection: "column", children: children }), hints !== undefined && hints.length > 0 ? _jsx(KeyHints, { hints: hints }) : null] }));
164
+ const body = (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, ...textColor(theme.primary), children: cliDisplayName() }), _jsxs(Text, { dimColor: true, children: [" v", cliVersion()] }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { bold: true, children: title }), chips.map((chip) => (_jsx(Text, { ...textColor(theme.accent), children: ` [${chip.label}: ${chip.text ?? ''}]` }, chip.id)))] }), _jsx(Box, { flexDirection: "column", children: children }), hints !== undefined && hints.length > 0 ? _jsx(KeyHints, { hints: hints }) : null] }));
155
165
  if (narrow)
156
166
  return body;
157
- return (_jsx(Box, { borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, flexDirection: "column", children: body }));
167
+ return (_jsx(Box, { borderStyle: "round", ...(theme.dim === undefined ? {} : { borderColor: theme.dim }), paddingX: 2, paddingY: 1, flexDirection: "column", children: body }));
158
168
  }
159
169
  /**
160
170
  * The bottom line of every screen.
@@ -166,6 +176,7 @@ export function Frame({ title, hints, children }) {
166
176
  *
167
177
  * Separators are dropped when narrow: at that width the hints wrap, and a
168
178
  * wrapped line beginning with a lone dot reads as corruption.
179
+ * @stability experimental
169
180
  */
170
181
  export function KeyHints({ hints }) {
171
182
  const { narrow } = useTerminalSize();
@@ -181,6 +192,7 @@ export function KeyHints({ hints }) {
181
192
  * ink measures a Box in cells and these labels are ASCII — padding is exact,
182
193
  * one flex node cheaper per row, and immune to the width-collapse described in
183
194
  * `Frame`.
195
+ * @stability experimental
184
196
  */
185
197
  export function Field({ label, value, color, dim, }) {
186
198
  return (_jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: label.padEnd(FIELD_LABEL_WIDTH) }), _jsx(Text, { ...(color === undefined ? {} : { color }), ...(dim === true ? { dimColor: true } : {}), children: value })] }));
@@ -193,8 +205,10 @@ const FIELD_LABEL_WIDTH = 10;
193
205
  * diagnosis. The messages this CLI produces already carry their own remedy
194
206
  * (see errors.ts), so `hint` is for the extra sentence a SCREEN can add and the
195
207
  * error itself cannot — "press r to try again".
208
+ * @stability experimental
196
209
  */
197
210
  export function ErrorNotice({ message, hint, }) {
198
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "red", bold: true, children: ["\u2716 ", message] }), hint === undefined ? null : _jsx(Text, { dimColor: true, children: hint })] }));
211
+ const theme = useTuiTheme();
212
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { bold: true, ...textColor(theme.error), children: [theme.glyphs.cross, " ", message] }), hint === undefined ? null : _jsx(Text, { dimColor: true, children: hint })] }));
199
213
  }
200
214
  //# sourceMappingURL=layout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/engine/tui/layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5D,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,SAAS;AACT,gFAAgF;AAEhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,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,EAC1B,OAAO,EACP,IAAI,GAIL;IACC,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,aACzB,MAAC,IAAI,IAAC,IAAI,WAAK,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,aAClC,KAAK,CAAC,MAAM,CAAC,KAAK,OAAG,OAAO,IACxB,EACN,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,QAAQ,kBAAE,IAAI,GAAQ,IACrD,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,124 @@
1
+ import { type TuiMenuContext } from './screen-registry.js';
2
+ import type { TuiColor } from './theme.js';
3
+ /**
4
+ * The id of the implicit root section. Reserved.
5
+ *
6
+ * @stability experimental
7
+ */
8
+ export declare const TUI_MENU_ROOT = "root";
9
+ /**
10
+ * The deepest a section may nest (a section directly under the root is level 1).
11
+ *
12
+ * @stability experimental
13
+ */
14
+ export declare const TUI_MENU_MAX_DEPTH = 4;
15
+ /**
16
+ * A menu label: fixed, or a function of the login state.
17
+ *
18
+ * @stability experimental
19
+ */
20
+ export type TuiMenuLabel = string | ((context: TuiMenuContext) => string);
21
+ /**
22
+ * Fields both node kinds share.
23
+ *
24
+ * @stability experimental
25
+ */
26
+ export interface TuiMenuNodeBase {
27
+ /** Unique across sections and entries: lowercase `[a-z][a-z0-9-]*`; `root` is reserved. */
28
+ id: string;
29
+ /** The section it sits in. Default `root`. */
30
+ parent?: string | undefined;
31
+ /** What the menu shows; a function gets `{ loggedIn }`. */
32
+ label: TuiMenuLabel;
33
+ /** Position among its siblings: lower first; ties sort by id. */
34
+ order: number;
35
+ /**
36
+ * Visible when logged out. Omitted means INHERITED from the nearest ancestor
37
+ * that sets it (default false: hidden until login). An explicit `false`
38
+ * opts one child out of an offline section.
39
+ */
40
+ loggedOut?: boolean | undefined;
41
+ /** Hide the node once logged in (a "Login" entry that moves elsewhere). */
42
+ hideWhenLoggedIn?: boolean | undefined;
43
+ /** A theme token name (`error`, `success`, ...) or a plain colour such as `red`. Presentation only. */
44
+ color?: TuiColor;
45
+ }
46
+ /**
47
+ * A submenu.
48
+ *
49
+ * @stability experimental
50
+ */
51
+ export interface TuiMenuSection extends TuiMenuNodeBase {
52
+ /** Discriminant. */
53
+ kind: 'section';
54
+ /** Shown under the breadcrumb instead of the default hint. */
55
+ subtitle?: string | undefined;
56
+ }
57
+ /**
58
+ * A menu line that opens a registered screen.
59
+ *
60
+ * @stability experimental
61
+ */
62
+ export interface TuiMenuEntry extends TuiMenuNodeBase {
63
+ /** Discriminant. */
64
+ kind: 'entry';
65
+ /** A registered screen route (built-in or `registerTuiScreen`). */
66
+ route: string;
67
+ /** The screen asks for a further input step first; rendered with a trailing `…`. */
68
+ ellipsis?: boolean | undefined;
69
+ /**
70
+ * Opening the screen while logged out shows the shared "not logged in"
71
+ * notice instead. Default: true unless the entry is visible when logged out.
72
+ */
73
+ requiresLogin?: boolean | undefined;
74
+ }
75
+ /**
76
+ * A node of the menu tree.
77
+ *
78
+ * @stability experimental
79
+ */
80
+ export type TuiMenuNode = TuiMenuSection | TuiMenuEntry;
81
+ /**
82
+ * Adds a section or an entry to the TUI menu tree.
83
+ *
84
+ * Unknown `parent` and unknown `route` are rejected when `createCli` builds
85
+ * the CLI (so registration order is free), together with cycles and nesting
86
+ * deeper than {@link TUI_MENU_MAX_DEPTH}.
87
+ *
88
+ * @param node - A section (`kind: 'section'`) or an entry (`kind: 'entry'`, with a `route`).
89
+ * @throws Error when the id is malformed, reserved or taken, a field is missing, or `createCli` has already built the CLI.
90
+ * @stability experimental
91
+ * @extensionPoint registry
92
+ * @example
93
+ * ```ts
94
+ * registerTuiMenuNode({ kind: 'section', id: 'node', label: 'Worker node', order: 40 });
95
+ * registerTuiMenuNode({ kind: 'entry', id: 'node-dashboard', parent: 'node', route: 'node-dashboard', label: 'Dashboard', order: 10 });
96
+ * ```
97
+ */
98
+ export declare function registerTuiMenuNode(node: TuiMenuNode): void;
99
+ /**
100
+ * The menu nodes registered so far, in registration order.
101
+ *
102
+ * @returns A frozen copy.
103
+ * @stability experimental
104
+ */
105
+ export declare function listTuiMenuNodes(): readonly TuiMenuNode[];
106
+ /**
107
+ * Checks the references between nodes and screens.
108
+ *
109
+ * @param nodes - The registered nodes.
110
+ * @param routes - Every screen route that exists.
111
+ * @throws Error naming the offending node id for an unknown or non-section parent, an unknown route, a cycle, or nesting deeper than {@link TUI_MENU_MAX_DEPTH}.
112
+ * @stability experimental
113
+ */
114
+ export declare function validateTuiMenuNodes(nodes: readonly TuiMenuNode[], routes: readonly string[]): void;
115
+ /**
116
+ * Validates the registered nodes against the screens, then refuses later
117
+ * registrations; `createCli` calls it.
118
+ *
119
+ * @throws Error from {@link validateTuiMenuNodes}; nothing is frozen then.
120
+ */
121
+ export declare function freezeTuiMenuRegistry(by: string): void;
122
+ /** Empties the registry. Tests only. */
123
+ export declare function resetTuiMenuRegistryForTests(): void;
124
+ //# sourceMappingURL=menu-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-registry.d.ts","sourceRoot":"","sources":["../../../src/engine/tui/menu-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAiD,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmB3C;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,cAAc,KAAK,MAAM,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,2FAA2F;IAC3F,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,GAA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@@ -0,0 +1,151 @@
1
+ import { createCliRegistry } from '../../core/index.js';
2
+ import { BUILTIN_TUI_SCREENS, listRegisteredTuiScreens } from './screen-registry.js';
3
+ // =============================================================================
4
+ // The TUI menu tree registry (RETRO-G1.1, #1065)
5
+ // =============================================================================
6
+ //
7
+ // `registerTuiScreen` puts a screen in one flat list. A MENU NODE places things
8
+ // in a tree: a SECTION is a submenu (with a breadcrumb, a subtitle and a
9
+ // logged-out rule), an ENTRY opens a registered screen from inside a section.
10
+ // Nothing here is required: a screen that no entry references is shown at the
11
+ // root with its own label and order, exactly as before, so an app that never
12
+ // calls `registerTuiMenuNode` keeps today's menu.
13
+ //
14
+ // PURE ON PURPOSE, like screen-registry.ts: React is not imported at all, so
15
+ // registering a node from `createCli` never loads ink. References (`parent`,
16
+ // `route`) are resolved when `createCli` freezes the registries, not when a
17
+ // node is registered, so the order of registration does not matter.
18
+ // =============================================================================
19
+ /**
20
+ * The id of the implicit root section. Reserved.
21
+ *
22
+ * @stability experimental
23
+ */
24
+ export const TUI_MENU_ROOT = 'root';
25
+ /**
26
+ * The deepest a section may nest (a section directly under the root is level 1).
27
+ *
28
+ * @stability experimental
29
+ */
30
+ export const TUI_MENU_MAX_DEPTH = 4;
31
+ const ID_PATTERN = /^[a-z][a-z0-9-]*$/;
32
+ const registry = createCliRegistry({
33
+ name: 'TUI menu node',
34
+ registerFn: 'registerTuiMenuNode',
35
+ idOf: (node) => node.id,
36
+ validate: (node) => {
37
+ const id = node.id;
38
+ if (typeof id !== 'string' || !ID_PATTERN.test(id)) {
39
+ throw new Error(`TUI menu node id "${String(id)}" is invalid: use lowercase letters, digits and hyphens.`);
40
+ }
41
+ if (id === TUI_MENU_ROOT) {
42
+ throw new Error(`TUI menu node id "${TUI_MENU_ROOT}" is reserved for the menu root.`);
43
+ }
44
+ if (node.kind !== 'section' && node.kind !== 'entry') {
45
+ throw new Error(`TUI menu node "${id}" needs kind "section" or "entry".`);
46
+ }
47
+ if (typeof node.order !== 'number' || !Number.isFinite(node.order)) {
48
+ throw new Error(`TUI menu node "${id}" needs a finite numeric order.`);
49
+ }
50
+ if (typeof node.label !== 'string' && typeof node.label !== 'function') {
51
+ throw new Error(`TUI menu node "${id}" needs a label (a string or a function of the login state).`);
52
+ }
53
+ if (typeof node.label === 'string' && node.label.trim() === '') {
54
+ throw new Error(`TUI menu node "${id}" needs a non-empty label.`);
55
+ }
56
+ if (node.parent !== undefined && (typeof node.parent !== 'string' || node.parent === '')) {
57
+ throw new Error(`TUI menu node "${id}" has an invalid parent.`);
58
+ }
59
+ if (node.kind === 'entry' && (typeof node.route !== 'string' || node.route === '')) {
60
+ throw new Error(`TUI menu entry "${id}" needs the route of a registered screen.`);
61
+ }
62
+ },
63
+ });
64
+ /**
65
+ * Adds a section or an entry to the TUI menu tree.
66
+ *
67
+ * Unknown `parent` and unknown `route` are rejected when `createCli` builds
68
+ * the CLI (so registration order is free), together with cycles and nesting
69
+ * deeper than {@link TUI_MENU_MAX_DEPTH}.
70
+ *
71
+ * @param node - A section (`kind: 'section'`) or an entry (`kind: 'entry'`, with a `route`).
72
+ * @throws Error when the id is malformed, reserved or taken, a field is missing, or `createCli` has already built the CLI.
73
+ * @stability experimental
74
+ * @extensionPoint registry
75
+ * @example
76
+ * ```ts
77
+ * registerTuiMenuNode({ kind: 'section', id: 'node', label: 'Worker node', order: 40 });
78
+ * registerTuiMenuNode({ kind: 'entry', id: 'node-dashboard', parent: 'node', route: 'node-dashboard', label: 'Dashboard', order: 10 });
79
+ * ```
80
+ */
81
+ export function registerTuiMenuNode(node) {
82
+ registry.register(Object.freeze({ ...node }));
83
+ }
84
+ /**
85
+ * The menu nodes registered so far, in registration order.
86
+ *
87
+ * @returns A frozen copy.
88
+ * @stability experimental
89
+ */
90
+ export function listTuiMenuNodes() {
91
+ return registry.list();
92
+ }
93
+ /**
94
+ * Checks the references between nodes and screens.
95
+ *
96
+ * @param nodes - The registered nodes.
97
+ * @param routes - Every screen route that exists.
98
+ * @throws Error naming the offending node id for an unknown or non-section parent, an unknown route, a cycle, or nesting deeper than {@link TUI_MENU_MAX_DEPTH}.
99
+ * @stability experimental
100
+ */
101
+ export function validateTuiMenuNodes(nodes, routes) {
102
+ const byId = new Map(nodes.map((node) => [node.id, node]));
103
+ for (const node of nodes) {
104
+ const parent = node.parent ?? TUI_MENU_ROOT;
105
+ if (parent !== TUI_MENU_ROOT) {
106
+ const found = byId.get(parent);
107
+ if (found === undefined) {
108
+ throw new Error(`TUI menu node "${node.id}" has unknown parent "${parent}".`);
109
+ }
110
+ if (found.kind !== 'section') {
111
+ throw new Error(`TUI menu node "${node.id}" has parent "${parent}", which is an entry; a parent must be a section.`);
112
+ }
113
+ }
114
+ if (node.kind === 'entry' && !routes.includes(node.route)) {
115
+ throw new Error(`TUI menu entry "${node.id}" opens unknown screen route "${node.route}"; register it with registerTuiScreen.`);
116
+ }
117
+ }
118
+ for (const node of nodes) {
119
+ // Walk up; the chain must reach the root within the cap without repeating.
120
+ const seen = new Set([node.id]);
121
+ let level = node.kind === 'section' ? 1 : 0;
122
+ let parent = node.parent ?? TUI_MENU_ROOT;
123
+ while (parent !== TUI_MENU_ROOT) {
124
+ if (seen.has(parent)) {
125
+ throw new Error(`TUI menu node "${node.id}" is part of a cycle through "${parent}".`);
126
+ }
127
+ seen.add(parent);
128
+ level += 1;
129
+ parent = byId.get(parent)?.parent ?? TUI_MENU_ROOT;
130
+ }
131
+ if (level > TUI_MENU_MAX_DEPTH) {
132
+ throw new Error(`TUI menu node "${node.id}" nests ${level} sections deep; the limit is ${TUI_MENU_MAX_DEPTH}.`);
133
+ }
134
+ }
135
+ }
136
+ /**
137
+ * Validates the registered nodes against the screens, then refuses later
138
+ * registrations; `createCli` calls it.
139
+ *
140
+ * @throws Error from {@link validateTuiMenuNodes}; nothing is frozen then.
141
+ */
142
+ export function freezeTuiMenuRegistry(by) {
143
+ const routes = [...BUILTIN_TUI_SCREENS, ...listRegisteredTuiScreens()].map((screen) => screen.route);
144
+ validateTuiMenuNodes(registry.list(), routes);
145
+ registry.freeze(by);
146
+ }
147
+ /** Empties the registry. Tests only. */
148
+ export function resetTuiMenuRegistryForTests() {
149
+ registry.reset();
150
+ }
151
+ //# sourceMappingURL=menu-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-registry.js","sourceRoot":"","sources":["../../../src/engine/tui/menu-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAuB,MAAM,sBAAsB,CAAC;AAG1G,gFAAgF;AAChF,kDAAkD;AAClD,gFAAgF;AAChF,EAAE;AACF,gFAAgF;AAChF,yEAAyE;AACzE,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,oEAAoE;AACpE,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAyEpC,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAEvC,MAAM,QAAQ,GAAG,iBAAiB,CAAc;IAC9C,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,qBAAqB;IACjC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,EAAE,GAAI,IAAyB,CAAC,EAAE,CAAC;QACzC,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,EAAE,CAAC,0DAA0D,CAAC,CAAC;QAC7G,CAAC;QACD,IAAI,EAAE,KA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