@promptctl/rich-js 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +13 -26
  2. package/package.json +7 -3
  3. package/dist/core/box.d.ts +0 -144
  4. package/dist/core/box.js +0 -391
  5. package/dist/core/cells.d.ts +0 -148
  6. package/dist/core/cells.js +0 -266
  7. package/dist/core/color.d.ts +0 -250
  8. package/dist/core/color.js +0 -1029
  9. package/dist/core/console.d.ts +0 -156
  10. package/dist/core/console.js +0 -472
  11. package/dist/core/emoji.d.ts +0 -24
  12. package/dist/core/emoji.js +0 -391
  13. package/dist/core/export-html.d.ts +0 -24
  14. package/dist/core/export-html.js +0 -106
  15. package/dist/core/export-lines.d.ts +0 -121
  16. package/dist/core/export-lines.js +0 -141
  17. package/dist/core/highlighter.d.ts +0 -33
  18. package/dist/core/highlighter.js +0 -124
  19. package/dist/core/json.d.ts +0 -27
  20. package/dist/core/json.js +0 -53
  21. package/dist/core/markup.d.ts +0 -97
  22. package/dist/core/markup.js +0 -619
  23. package/dist/core/measure.d.ts +0 -27
  24. package/dist/core/measure.js +0 -61
  25. package/dist/core/oklch.d.ts +0 -161
  26. package/dist/core/oklch.js +0 -312
  27. package/dist/core/osc8.d.ts +0 -68
  28. package/dist/core/osc8.js +0 -90
  29. package/dist/core/pretty.d.ts +0 -141
  30. package/dist/core/pretty.js +0 -472
  31. package/dist/core/protocol.d.ts +0 -137
  32. package/dist/core/protocol.js +0 -101
  33. package/dist/core/render.d.ts +0 -84
  34. package/dist/core/render.js +0 -145
  35. package/dist/core/segment.d.ts +0 -142
  36. package/dist/core/segment.js +0 -433
  37. package/dist/core/spinnerData.d.ts +0 -10
  38. package/dist/core/spinnerData.js +0 -115
  39. package/dist/core/strip.d.ts +0 -145
  40. package/dist/core/strip.js +0 -308
  41. package/dist/core/style.d.ts +0 -144
  42. package/dist/core/style.js +0 -723
  43. package/dist/core/subscription.d.ts +0 -12
  44. package/dist/core/subscription.js +0 -12
  45. package/dist/core/text.d.ts +0 -255
  46. package/dist/core/text.js +0 -990
  47. package/dist/core/wrap.d.ts +0 -41
  48. package/dist/core/wrap.js +0 -127
  49. package/dist/host/host-stream.d.ts +0 -30
  50. package/dist/host/host-stream.js +0 -35
  51. package/dist/host/index.d.ts +0 -3
  52. package/dist/host/index.js +0 -2
  53. package/dist/host/terminal-host.d.ts +0 -143
  54. package/dist/host/terminal-host.js +0 -132
  55. package/dist/index.d.ts +0 -87
  56. package/dist/index.js +0 -104
  57. package/dist/node/prompt.d.ts +0 -21
  58. package/dist/node/prompt.js +0 -30
  59. package/dist/node/save.d.ts +0 -17
  60. package/dist/node/save.js +0 -21
  61. package/dist/node/terminal-host.d.ts +0 -84
  62. package/dist/node/terminal-host.js +0 -160
  63. package/dist/node/traceback.d.ts +0 -27
  64. package/dist/node/traceback.js +0 -112
  65. package/dist/renderables/align.d.ts +0 -16
  66. package/dist/renderables/align.js +0 -46
  67. package/dist/renderables/columns.d.ts +0 -61
  68. package/dist/renderables/columns.js +0 -168
  69. package/dist/renderables/constrain.d.ts +0 -15
  70. package/dist/renderables/constrain.js +0 -37
  71. package/dist/renderables/flexStrip.d.ts +0 -41
  72. package/dist/renderables/flexStrip.js +0 -200
  73. package/dist/renderables/group.d.ts +0 -11
  74. package/dist/renderables/group.js +0 -15
  75. package/dist/renderables/layout.d.ts +0 -92
  76. package/dist/renderables/layout.js +0 -315
  77. package/dist/renderables/live.d.ts +0 -47
  78. package/dist/renderables/live.js +0 -131
  79. package/dist/renderables/markdown.d.ts +0 -24
  80. package/dist/renderables/markdown.js +0 -182
  81. package/dist/renderables/padding.d.ts +0 -38
  82. package/dist/renderables/padding.js +0 -140
  83. package/dist/renderables/panel.d.ts +0 -116
  84. package/dist/renderables/panel.js +0 -322
  85. package/dist/renderables/progress.d.ts +0 -90
  86. package/dist/renderables/progress.js +0 -241
  87. package/dist/renderables/progressBar.d.ts +0 -31
  88. package/dist/renderables/progressBar.js +0 -52
  89. package/dist/renderables/prompt.d.ts +0 -49
  90. package/dist/renderables/prompt.js +0 -125
  91. package/dist/renderables/rule.d.ts +0 -24
  92. package/dist/renderables/rule.js +0 -90
  93. package/dist/renderables/spinner.d.ts +0 -29
  94. package/dist/renderables/spinner.js +0 -64
  95. package/dist/renderables/status.d.ts +0 -23
  96. package/dist/renderables/status.js +0 -60
  97. package/dist/renderables/syntax.d.ts +0 -35
  98. package/dist/renderables/syntax.js +0 -114
  99. package/dist/renderables/table.d.ts +0 -182
  100. package/dist/renderables/table.js +0 -697
  101. package/dist/renderables/traceback.d.ts +0 -31
  102. package/dist/renderables/traceback.js +0 -109
  103. package/dist/renderables/tree.d.ts +0 -54
  104. package/dist/renderables/tree.js +0 -159
  105. package/dist/template-bindings/color-funcs.d.ts +0 -87
  106. package/dist/template-bindings/color-funcs.js +0 -219
  107. package/dist/template-bindings/helpers.d.ts +0 -24
  108. package/dist/template-bindings/helpers.js +0 -48
  109. package/dist/template-bindings/index.d.ts +0 -107
  110. package/dist/template-bindings/index.js +0 -144
  111. package/dist/template-bindings/palette-funcs.d.ts +0 -94
  112. package/dist/template-bindings/palette-funcs.js +0 -151
  113. package/dist/template-bindings/style-funcs.d.ts +0 -28
  114. package/dist/template-bindings/style-funcs.js +0 -151
  115. package/dist/themes/buildPalette.d.ts +0 -36
  116. package/dist/themes/buildPalette.js +0 -56
  117. package/dist/themes/colorMath.d.ts +0 -82
  118. package/dist/themes/colorMath.js +0 -254
  119. package/dist/themes/colorRef.d.ts +0 -51
  120. package/dist/themes/colorRef.js +0 -96
  121. package/dist/themes/data/atom-one-dark.d.ts +0 -3
  122. package/dist/themes/data/atom-one-dark.js +0 -158
  123. package/dist/themes/data/atom-one-light.d.ts +0 -3
  124. package/dist/themes/data/atom-one-light.js +0 -158
  125. package/dist/themes/data/catppuccin-frappe.d.ts +0 -3
  126. package/dist/themes/data/catppuccin-frappe.js +0 -158
  127. package/dist/themes/data/catppuccin-latte.d.ts +0 -3
  128. package/dist/themes/data/catppuccin-latte.js +0 -158
  129. package/dist/themes/data/catppuccin-macchiato.d.ts +0 -3
  130. package/dist/themes/data/catppuccin-macchiato.js +0 -158
  131. package/dist/themes/data/catppuccin-mocha.d.ts +0 -3
  132. package/dist/themes/data/catppuccin-mocha.js +0 -158
  133. package/dist/themes/data/cyberpunk.d.ts +0 -17
  134. package/dist/themes/data/cyberpunk.js +0 -191
  135. package/dist/themes/data/default.d.ts +0 -3
  136. package/dist/themes/data/default.js +0 -158
  137. package/dist/themes/data/dracula.d.ts +0 -3
  138. package/dist/themes/data/dracula.js +0 -158
  139. package/dist/themes/data/flexoki.d.ts +0 -3
  140. package/dist/themes/data/flexoki.js +0 -158
  141. package/dist/themes/data/gruvbox.d.ts +0 -3
  142. package/dist/themes/data/gruvbox.js +0 -158
  143. package/dist/themes/data/index.d.ts +0 -35
  144. package/dist/themes/data/index.js +0 -64
  145. package/dist/themes/data/monokai.d.ts +0 -3
  146. package/dist/themes/data/monokai.js +0 -158
  147. package/dist/themes/data/nord.d.ts +0 -3
  148. package/dist/themes/data/nord.js +0 -158
  149. package/dist/themes/data/rose-pine-dawn.d.ts +0 -3
  150. package/dist/themes/data/rose-pine-dawn.js +0 -158
  151. package/dist/themes/data/rose-pine-moon.d.ts +0 -3
  152. package/dist/themes/data/rose-pine-moon.js +0 -158
  153. package/dist/themes/data/rose-pine.d.ts +0 -3
  154. package/dist/themes/data/rose-pine.js +0 -158
  155. package/dist/themes/data/solarized-dark.d.ts +0 -3
  156. package/dist/themes/data/solarized-dark.js +0 -158
  157. package/dist/themes/data/solarized-light.d.ts +0 -3
  158. package/dist/themes/data/solarized-light.js +0 -158
  159. package/dist/themes/data/svg-export.d.ts +0 -3
  160. package/dist/themes/data/svg-export.js +0 -158
  161. package/dist/themes/data/textual-ansi.d.ts +0 -3
  162. package/dist/themes/data/textual-ansi.js +0 -158
  163. package/dist/themes/data/textual-dark.d.ts +0 -3
  164. package/dist/themes/data/textual-dark.js +0 -158
  165. package/dist/themes/data/textual-light.d.ts +0 -3
  166. package/dist/themes/data/textual-light.js +0 -158
  167. package/dist/themes/data/tokyo-night.d.ts +0 -3
  168. package/dist/themes/data/tokyo-night.js +0 -158
  169. package/dist/themes/data/types.d.ts +0 -15
  170. package/dist/themes/data/types.js +0 -1
  171. package/dist/themes/palette.d.ts +0 -21
  172. package/dist/themes/palette.js +0 -28
  173. package/dist/themes/ramp.d.ts +0 -83
  174. package/dist/themes/ramp.js +0 -122
  175. package/dist/themes/registry.d.ts +0 -43
  176. package/dist/themes/registry.js +0 -82
  177. package/dist/themes/terminalThemes.d.ts +0 -54
  178. package/dist/themes/terminalThemes.js +0 -68
  179. package/dist/themes/transpose.d.ts +0 -87
  180. package/dist/themes/transpose.js +0 -138
  181. package/dist/widgets/button.d.ts +0 -49
  182. package/dist/widgets/button.js +0 -206
  183. package/dist/widgets/checkbox.d.ts +0 -41
  184. package/dist/widgets/checkbox.js +0 -155
  185. package/dist/widgets/dropdown.d.ts +0 -67
  186. package/dist/widgets/dropdown.js +0 -453
  187. package/dist/widgets/event-router.d.ts +0 -78
  188. package/dist/widgets/event-router.js +0 -622
  189. package/dist/widgets/focus-manager.d.ts +0 -26
  190. package/dist/widgets/focus-manager.js +0 -193
  191. package/dist/widgets/index.d.ts +0 -22
  192. package/dist/widgets/index.js +0 -15
  193. package/dist/widgets/screen.d.ts +0 -98
  194. package/dist/widgets/screen.js +0 -530
  195. package/dist/widgets/slider.d.ts +0 -57
  196. package/dist/widgets/slider.js +0 -270
  197. package/dist/widgets/static-item.d.ts +0 -40
  198. package/dist/widgets/static-item.js +0 -60
  199. package/dist/widgets/text-input.d.ts +0 -274
  200. package/dist/widgets/text-input.js +0 -1162
  201. package/dist/widgets/toggle.d.ts +0 -44
  202. package/dist/widgets/toggle.js +0 -179
  203. package/dist/widgets/types.d.ts +0 -108
  204. package/dist/widgets/types.js +0 -31
  205. package/dist/widgets/widget-base.d.ts +0 -42
  206. package/dist/widgets/widget-base.js +0 -173
@@ -1,193 +0,0 @@
1
- /**
2
- * FocusManager — flat focus cycling over registered widgets.
3
- * [LAW:one-source-of-truth] single authority for which widget has focus.
4
- * [LAW:dataflow-not-control-flow] focus transitions are observable state;
5
- * widgets react to focus/blur events, the manager never skips dispatch.
6
- */
7
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
8
- var useValue = arguments.length > 2;
9
- for (var i = 0; i < initializers.length; i++) {
10
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
11
- }
12
- return useValue ? value : void 0;
13
- };
14
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
15
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
16
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
17
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
18
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
19
- var _, done = false;
20
- for (var i = decorators.length - 1; i >= 0; i--) {
21
- var context = {};
22
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
23
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
24
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
25
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
26
- if (kind === "accessor") {
27
- if (result === void 0) continue;
28
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
29
- if (_ = accept(result.get)) descriptor.get = _;
30
- if (_ = accept(result.set)) descriptor.set = _;
31
- if (_ = accept(result.init)) initializers.unshift(_);
32
- }
33
- else if (_ = accept(result)) {
34
- if (kind === "field") initializers.unshift(_);
35
- else descriptor[key] = _;
36
- }
37
- }
38
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
39
- done = true;
40
- };
41
- import { action, observableRef, observableShallow } from "mobx";
42
- let DefaultFocusManager = (() => {
43
- let _instanceExtraInitializers = [];
44
- let _widgetList_decorators;
45
- let _widgetList_initializers = [];
46
- let _widgetList_extraInitializers = [];
47
- let _currentWidget_decorators;
48
- let _currentWidget_initializers = [];
49
- let _currentWidget_extraInitializers = [];
50
- let _register_decorators;
51
- let _unregister_decorators;
52
- let _next_decorators;
53
- let _prev_decorators;
54
- let _focus_decorators;
55
- let _blur_decorators;
56
- let _setFocus_decorators;
57
- return class DefaultFocusManager {
58
- static {
59
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
60
- _widgetList_decorators = [observableShallow];
61
- _currentWidget_decorators = [observableRef];
62
- _register_decorators = [action];
63
- _unregister_decorators = [action];
64
- _next_decorators = [action];
65
- _prev_decorators = [action];
66
- _focus_decorators = [action];
67
- _blur_decorators = [action];
68
- _setFocus_decorators = [action];
69
- __esDecorate(this, null, _widgetList_decorators, { kind: "accessor", name: "widgetList", static: false, private: false, access: { has: obj => "widgetList" in obj, get: obj => obj.widgetList, set: (obj, value) => { obj.widgetList = value; } }, metadata: _metadata }, _widgetList_initializers, _widgetList_extraInitializers);
70
- __esDecorate(this, null, _currentWidget_decorators, { kind: "accessor", name: "currentWidget", static: false, private: false, access: { has: obj => "currentWidget" in obj, get: obj => obj.currentWidget, set: (obj, value) => { obj.currentWidget = value; } }, metadata: _metadata }, _currentWidget_initializers, _currentWidget_extraInitializers);
71
- __esDecorate(this, null, _register_decorators, { kind: "method", name: "register", static: false, private: false, access: { has: obj => "register" in obj, get: obj => obj.register }, metadata: _metadata }, null, _instanceExtraInitializers);
72
- __esDecorate(this, null, _unregister_decorators, { kind: "method", name: "unregister", static: false, private: false, access: { has: obj => "unregister" in obj, get: obj => obj.unregister }, metadata: _metadata }, null, _instanceExtraInitializers);
73
- __esDecorate(this, null, _next_decorators, { kind: "method", name: "next", static: false, private: false, access: { has: obj => "next" in obj, get: obj => obj.next }, metadata: _metadata }, null, _instanceExtraInitializers);
74
- __esDecorate(this, null, _prev_decorators, { kind: "method", name: "prev", static: false, private: false, access: { has: obj => "prev" in obj, get: obj => obj.prev }, metadata: _metadata }, null, _instanceExtraInitializers);
75
- __esDecorate(this, null, _focus_decorators, { kind: "method", name: "focus", static: false, private: false, access: { has: obj => "focus" in obj, get: obj => obj.focus }, metadata: _metadata }, null, _instanceExtraInitializers);
76
- __esDecorate(this, null, _blur_decorators, { kind: "method", name: "blur", static: false, private: false, access: { has: obj => "blur" in obj, get: obj => obj.blur }, metadata: _metadata }, null, _instanceExtraInitializers);
77
- __esDecorate(this, null, _setFocus_decorators, { kind: "method", name: "setFocus", static: false, private: false, access: { has: obj => "setFocus" in obj, get: obj => obj.setFocus }, metadata: _metadata }, null, _instanceExtraInitializers);
78
- if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
79
- }
80
- #widgetList_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _widgetList_initializers, []));
81
- get widgetList() { return this.#widgetList_accessor_storage; }
82
- set widgetList(value) { this.#widgetList_accessor_storage = value; }
83
- #currentWidget_accessor_storage = (__runInitializers(this, _widgetList_extraInitializers), __runInitializers(this, _currentWidget_initializers, null));
84
- get currentWidget() { return this.#currentWidget_accessor_storage; }
85
- set currentWidget(value) { this.#currentWidget_accessor_storage = value; }
86
- changeHandlers = (__runInitializers(this, _currentWidget_extraInitializers), new Set());
87
- get current() {
88
- return this.currentWidget;
89
- }
90
- get widgets() {
91
- return this.widgetList;
92
- }
93
- register(widget) {
94
- // [LAW:one-source-of-truth] register is idempotent — the widgetList is
95
- // a set in spirit, not a multiset. Without this guard, double-registration
96
- // would duplicate the widget so next/prev cycle through it twice and
97
- // unregister only removes one copy.
98
- if (this.widgetList.includes(widget))
99
- return;
100
- this.widgetList = [...this.widgetList, widget];
101
- if (!this.currentWidget && widget.focusable && !widget.disabled) {
102
- this.setFocus(widget);
103
- }
104
- }
105
- unregister(widget) {
106
- const idx = this.widgetList.indexOf(widget);
107
- if (idx === -1)
108
- return;
109
- this.widgetList = this.widgetList.filter((w) => w !== widget);
110
- if (this.currentWidget === widget) {
111
- // [LAW:single-enforcer] WidgetBase.focus()/blur() already route through
112
- // handleFocus, so calling both would double-dispatch and trigger any
113
- // subclass side effect (e.g. Dropdown clearing filter/overlay) twice.
114
- widget.blur();
115
- const next = this.widgetList.find((w) => w.focusable && !w.disabled) ?? null;
116
- if (next)
117
- next.focus();
118
- this.currentWidget = next;
119
- this.emitChange();
120
- }
121
- }
122
- next() {
123
- const focusable = this.focusableWidgets();
124
- if (focusable.length === 0)
125
- return;
126
- const currentIdx = this.currentWidget ? focusable.indexOf(this.currentWidget) : -1;
127
- const nextIdx = (currentIdx + 1) % focusable.length;
128
- this.setFocus(focusable[nextIdx]);
129
- }
130
- prev() {
131
- const focusable = this.focusableWidgets();
132
- if (focusable.length === 0)
133
- return;
134
- const currentIdx = this.currentWidget ? focusable.indexOf(this.currentWidget) : -1;
135
- const prevIdx = currentIdx <= 0 ? focusable.length - 1 : currentIdx - 1;
136
- this.setFocus(focusable[prevIdx]);
137
- }
138
- focus(widget) {
139
- if (!widget.focusable || widget.disabled)
140
- return;
141
- if (!this.widgetList.includes(widget))
142
- return;
143
- this.setFocus(widget);
144
- }
145
- blur() {
146
- if (!this.currentWidget)
147
- return;
148
- // [LAW:single-enforcer] blur() already dispatches handleFocus on
149
- // WidgetBase — see unregister() for the rationale.
150
- this.currentWidget.blur();
151
- this.currentWidget = null;
152
- this.emitChange();
153
- }
154
- onChange(handler) {
155
- this.changeHandlers.add(handler);
156
- return () => this.changeHandlers.delete(handler);
157
- }
158
- // [LAW:single-enforcer] FocusManager owns Tab/Shift+Tab semantics. The
159
- // router registers this as a normal-priority handler at construction —
160
- // it runs after the focused widget, so a widget can `event.stop()`
161
- // to suppress traversal (e.g. Dropdown when its overlay is open).
162
- handleKey(event) {
163
- if (event.key !== "tab")
164
- return;
165
- if (event.shift)
166
- this.prev();
167
- else
168
- this.next();
169
- event.stop();
170
- }
171
- // --- Private ---
172
- focusableWidgets() {
173
- return this.widgetList.filter((w) => w.focusable && !w.disabled);
174
- }
175
- setFocus(widget) {
176
- if (this.currentWidget === widget)
177
- return;
178
- // [LAW:single-enforcer] focus()/blur() already dispatch handleFocus —
179
- // see unregister() for the rationale.
180
- if (this.currentWidget)
181
- this.currentWidget.blur();
182
- this.currentWidget = widget;
183
- widget.focus();
184
- this.emitChange();
185
- }
186
- emitChange() {
187
- for (const handler of this.changeHandlers) {
188
- handler(this.currentWidget);
189
- }
190
- }
191
- };
192
- })();
193
- export { DefaultFocusManager };
@@ -1,22 +0,0 @@
1
- export type { KeyEventInit, KeyHandlerPriority, KeyHandlerOptions, WidgetMouseEvent, WidgetFocusEvent, WidgetBounds, InteractiveWidget, OverlayRenderable, FocusManager, Screen, MountEntry, Placement, } from "./types.js";
2
- export { FLOW, hasOverlay, KeyEvent } from "./types.js";
3
- export { StaticItem } from "./static-item.js";
4
- export type { StaticItemOptions } from "./static-item.js";
5
- export { WidgetBase } from "./widget-base.js";
6
- export { DefaultFocusManager } from "./focus-manager.js";
7
- export { DefaultScreen } from "./screen.js";
8
- export type { ScreenOptions, ColorSystemSpec } from "./screen.js";
9
- export { Button } from "./button.js";
10
- export type { ButtonVariant, ButtonOptions } from "./button.js";
11
- export { Checkbox } from "./checkbox.js";
12
- export type { CheckboxOptions } from "./checkbox.js";
13
- export { Toggle } from "./toggle.js";
14
- export type { ToggleVariant, ToggleOptions } from "./toggle.js";
15
- export { TextInput, charGreedyWrap } from "./text-input.js";
16
- export type { TextInputOptions, WrapStrategy, WrapRow } from "./text-input.js";
17
- export { Dropdown } from "./dropdown.js";
18
- export type { DropdownOptions } from "./dropdown.js";
19
- export { Slider } from "./slider.js";
20
- export type { SliderOptions } from "./slider.js";
21
- export { EventRouter } from "./event-router.js";
22
- export type { EventRouterOptions } from "./event-router.js";
@@ -1,15 +0,0 @@
1
- export { FLOW, hasOverlay, KeyEvent } from "./types.js";
2
- export { StaticItem } from "./static-item.js";
3
- export { WidgetBase } from "./widget-base.js";
4
- export { DefaultFocusManager } from "./focus-manager.js";
5
- export { DefaultScreen } from "./screen.js";
6
- export { Button } from "./button.js";
7
- export { Checkbox } from "./checkbox.js";
8
- export { Toggle } from "./toggle.js";
9
- export { TextInput, charGreedyWrap } from "./text-input.js";
10
- export { Dropdown } from "./dropdown.js";
11
- export { Slider } from "./slider.js";
12
- export { EventRouter } from "./event-router.js";
13
- // The terminal seam is not re-exported here. It lives on the `host` subpath,
14
- // and a second path to `TerminalHost` would be the two-clocks problem the
15
- // subpath split exists to remove.
@@ -1,98 +0,0 @@
1
- /**
2
- * Screen — owns the render loop and ANSI output for interactive widgets.
3
- *
4
- * [LAW:dataflow-not-control-flow] Same pipeline runs every frame: render
5
- * widgets to Segment[], split into lines, encode to ANSI, write to stdout
6
- * with cursor-up + overwrite. Variability lives in the values (which widgets
7
- * are visible, what they render), never in whether the pipeline runs.
8
- *
9
- * [LAW:one-source-of-truth] Layout (widget bounds) is computed here and
10
- * written to widget.bounds. Mouse hit-testing reads the same bounds — the
11
- * Screen is the single authority on where each widget is drawn.
12
- *
13
- * [LAW:single-enforcer] Cursor management lives in one place: `draw()`
14
- * tracks `lastLineCount` and emits a single `\x1b[<n>A` to reposition.
15
- * Per-line `\x1b[K` (erase to end of line) overwrites old content without
16
- * flicker — no clear-and-redraw cycle.
17
- *
18
- * Reactivity: `mobx.autorun` re-fires on any observable read during render
19
- * (label, focused, hovered, active, disabled, visible, the widget list
20
- * itself). Renders are debounced to a microtask so a burst of state changes
21
- * within one tick produces one frame.
22
- *
23
- * Layout (per-widget Placement):
24
- *
25
- * flow — vertical stack at x=0; advances the layout cursor by the
26
- * widget's measured height. Default placement; preserves the
27
- * historical single-column behavior so existing consumers
28
- * (and the screen tests) need no migration.
29
- * inline — same row as the preceding flow/inline neighbor; x packs
30
- * after that neighbor's right edge plus a one-cell gap. The
31
- * row's height is the max of its members; the cursor advances
32
- * past the tallest member when the next non-inline item is
33
- * placed (or at end of frame).
34
- * fixed — absolute (x, y); independent of the cursor. Used for
35
- * anchored content like status/log rows that the host wants
36
- * placed at a known coordinate regardless of flow growth.
37
- *
38
- * The overlay pass (single enforcer) runs after base layout: any widget
39
- * implementing OverlayRenderable contributes overlay segments anchored
40
- * directly below its inline footprint, and Screen unions the overlay
41
- * area into the widget's bounds for hit-testing.
42
- *
43
- * Design alternatives considered:
44
- * 1. Per-widget Placement (chosen) — smallest type that covers the legal
45
- * variability; one total switch in computeFrame; back-compat default.
46
- * 2. Named regions (header/body/status as flow containers) — adds a
47
- * two-step API surface (declare regions, then mount into them) and
48
- * another concept; rejected as larger than the problem requires.
49
- * 3. Host-supplied layout function — pushes layout out of Screen,
50
- * defeating single-enforcer; rejected.
51
- */
52
- import { ColorDepth } from "../core/color.js";
53
- import type { Screen, InteractiveWidget, FocusManager, MountEntry } from "./types.js";
54
- import type { TerminalHost } from "../host/terminal-host.js";
55
- export type ColorSystemSpec = ColorDepth | "auto" | "truecolor" | "256" | "ansi" | "none" | null;
56
- export interface ScreenOptions {
57
- /**
58
- * The I/O capability the screen renders against. Construct a
59
- * `NodeTerminalHost` for production node demos, or pass a host that
60
- * wraps mock streams for tests. The seam is the type — Screen never
61
- * reaches for `process.*`.
62
- */
63
- host: TerminalHost;
64
- width?: number;
65
- colorSystem?: ColorSystemSpec;
66
- focusManager?: FocusManager;
67
- /**
68
- * When true (default when the host reports `isTTY`), hide the cursor
69
- * on start and restore it on stop. Disable for non-TTY output and tests.
70
- */
71
- manageCursor?: boolean;
72
- }
73
- export declare class DefaultScreen implements Screen {
74
- readonly focusManager: FocusManager;
75
- accessor widgetList: InteractiveWidget[];
76
- private readonly placements;
77
- private _activeOverlays;
78
- private _running;
79
- private autorunDispose;
80
- private renderScheduled;
81
- private pendingFrame;
82
- private lastLineCount;
83
- private readonly host;
84
- private readonly widthOverride;
85
- private readonly destination;
86
- private readonly manageCursor;
87
- constructor(options: ScreenOptions);
88
- get running(): boolean;
89
- get widgets(): readonly InteractiveWidget[];
90
- mount(...entries: MountEntry[]): void;
91
- unmount(widget: InteractiveWidget): void;
92
- start(): void;
93
- stop(): void;
94
- private get width();
95
- private computeFrame;
96
- private scheduleRender;
97
- private draw;
98
- }