@promptctl/rich-js 0.18.0 → 0.18.1

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 (221) hide show
  1. package/dist/core/anchor.d.ts +45 -0
  2. package/dist/core/anchor.js +39 -0
  3. package/dist/core/ansi.d.ts +65 -0
  4. package/dist/core/ansi.js +231 -0
  5. package/dist/core/box.d.ts +143 -0
  6. package/dist/core/box.js +379 -0
  7. package/dist/core/cells.d.ts +159 -0
  8. package/dist/core/cells.js +287 -0
  9. package/dist/core/color.d.ts +246 -0
  10. package/dist/core/color.js +1038 -0
  11. package/dist/core/console.d.ts +165 -0
  12. package/dist/core/console.js +527 -0
  13. package/dist/core/emoji.d.ts +24 -0
  14. package/dist/core/emoji.js +391 -0
  15. package/dist/core/export-html.d.ts +59 -0
  16. package/dist/core/export-html.js +200 -0
  17. package/dist/core/export-lines.d.ts +121 -0
  18. package/dist/core/export-lines.js +141 -0
  19. package/dist/core/highlighter.d.ts +33 -0
  20. package/dist/core/highlighter.js +124 -0
  21. package/dist/core/json.d.ts +27 -0
  22. package/dist/core/json.js +53 -0
  23. package/dist/core/markup.d.ts +119 -0
  24. package/dist/core/markup.js +731 -0
  25. package/dist/core/measure.d.ts +27 -0
  26. package/dist/core/measure.js +62 -0
  27. package/dist/core/oklch.d.ts +161 -0
  28. package/dist/core/oklch.js +312 -0
  29. package/dist/core/osc8.d.ts +68 -0
  30. package/dist/core/osc8.js +90 -0
  31. package/dist/core/place.d.ts +30 -0
  32. package/dist/core/place.js +51 -0
  33. package/dist/core/pretty.d.ts +144 -0
  34. package/dist/core/pretty.js +476 -0
  35. package/dist/core/protocol.d.ts +267 -0
  36. package/dist/core/protocol.js +163 -0
  37. package/dist/core/render.d.ts +84 -0
  38. package/dist/core/render.js +145 -0
  39. package/dist/core/segment.d.ts +161 -0
  40. package/dist/core/segment.js +492 -0
  41. package/dist/core/spinnerData.d.ts +12 -0
  42. package/dist/core/spinnerData.js +117 -0
  43. package/dist/core/strip.d.ts +141 -0
  44. package/dist/core/strip.js +305 -0
  45. package/dist/core/style.d.ts +169 -0
  46. package/dist/core/style.js +695 -0
  47. package/dist/core/subscription.d.ts +12 -0
  48. package/dist/core/subscription.js +12 -0
  49. package/dist/core/text.d.ts +256 -0
  50. package/dist/core/text.js +976 -0
  51. package/dist/core/wrap.d.ts +41 -0
  52. package/dist/core/wrap.js +127 -0
  53. package/dist/host/app.d.ts +121 -0
  54. package/dist/host/app.js +255 -0
  55. package/dist/host/host-environment.d.ts +26 -0
  56. package/dist/host/host-environment.js +44 -0
  57. package/dist/host/index.d.ts +5 -0
  58. package/dist/host/index.js +3 -0
  59. package/dist/host/terminal-host.d.ts +179 -0
  60. package/dist/host/terminal-host.js +186 -0
  61. package/dist/index.d.ts +91 -0
  62. package/dist/index.js +107 -0
  63. package/dist/node/prompt.d.ts +21 -0
  64. package/dist/node/prompt.js +30 -0
  65. package/dist/node/save.d.ts +17 -0
  66. package/dist/node/save.js +21 -0
  67. package/dist/node/terminal-host.d.ts +113 -0
  68. package/dist/node/terminal-host.js +227 -0
  69. package/dist/node/traceback.d.ts +37 -0
  70. package/dist/node/traceback.js +134 -0
  71. package/dist/renderables/align.d.ts +16 -0
  72. package/dist/renderables/align.js +33 -0
  73. package/dist/renderables/columns.d.ts +61 -0
  74. package/dist/renderables/columns.js +152 -0
  75. package/dist/renderables/constrain.d.ts +15 -0
  76. package/dist/renderables/constrain.js +37 -0
  77. package/dist/renderables/embed.d.ts +50 -0
  78. package/dist/renderables/embed.js +71 -0
  79. package/dist/renderables/flexStrip.d.ts +41 -0
  80. package/dist/renderables/flexStrip.js +200 -0
  81. package/dist/renderables/group.d.ts +11 -0
  82. package/dist/renderables/group.js +17 -0
  83. package/dist/renderables/layout.d.ts +92 -0
  84. package/dist/renderables/layout.js +312 -0
  85. package/dist/renderables/live.d.ts +50 -0
  86. package/dist/renderables/live.js +175 -0
  87. package/dist/renderables/markdown.d.ts +24 -0
  88. package/dist/renderables/markdown.js +184 -0
  89. package/dist/renderables/padding.d.ts +38 -0
  90. package/dist/renderables/padding.js +141 -0
  91. package/dist/renderables/panel.d.ts +116 -0
  92. package/dist/renderables/panel.js +307 -0
  93. package/dist/renderables/progress.d.ts +90 -0
  94. package/dist/renderables/progress.js +238 -0
  95. package/dist/renderables/progressBar.d.ts +31 -0
  96. package/dist/renderables/progressBar.js +53 -0
  97. package/dist/renderables/prompt.d.ts +49 -0
  98. package/dist/renderables/prompt.js +125 -0
  99. package/dist/renderables/rule.d.ts +25 -0
  100. package/dist/renderables/rule.js +90 -0
  101. package/dist/renderables/spinner.d.ts +31 -0
  102. package/dist/renderables/spinner.js +70 -0
  103. package/dist/renderables/status.d.ts +23 -0
  104. package/dist/renderables/status.js +60 -0
  105. package/dist/renderables/syntax.d.ts +35 -0
  106. package/dist/renderables/syntax.js +115 -0
  107. package/dist/renderables/table.d.ts +194 -0
  108. package/dist/renderables/table.js +795 -0
  109. package/dist/renderables/traceback.d.ts +31 -0
  110. package/dist/renderables/traceback.js +108 -0
  111. package/dist/renderables/tree.d.ts +68 -0
  112. package/dist/renderables/tree.js +150 -0
  113. package/dist/renderables/viewport.d.ts +114 -0
  114. package/dist/renderables/viewport.js +198 -0
  115. package/dist/template-bindings/color-funcs.d.ts +87 -0
  116. package/dist/template-bindings/color-funcs.js +217 -0
  117. package/dist/template-bindings/helpers.d.ts +24 -0
  118. package/dist/template-bindings/helpers.js +48 -0
  119. package/dist/template-bindings/index.d.ts +107 -0
  120. package/dist/template-bindings/index.js +146 -0
  121. package/dist/template-bindings/palette-funcs.d.ts +94 -0
  122. package/dist/template-bindings/palette-funcs.js +141 -0
  123. package/dist/template-bindings/style-funcs.d.ts +28 -0
  124. package/dist/template-bindings/style-funcs.js +155 -0
  125. package/dist/themes/buildPalette.d.ts +36 -0
  126. package/dist/themes/buildPalette.js +56 -0
  127. package/dist/themes/colorMath.d.ts +82 -0
  128. package/dist/themes/colorMath.js +254 -0
  129. package/dist/themes/colorRef.d.ts +51 -0
  130. package/dist/themes/colorRef.js +96 -0
  131. package/dist/themes/data/ansi-tables.d.ts +14 -0
  132. package/dist/themes/data/ansi-tables.js +49 -0
  133. package/dist/themes/data/atom-one-dark.d.ts +3 -0
  134. package/dist/themes/data/atom-one-dark.js +177 -0
  135. package/dist/themes/data/atom-one-light.d.ts +3 -0
  136. package/dist/themes/data/atom-one-light.js +177 -0
  137. package/dist/themes/data/catppuccin-frappe.d.ts +3 -0
  138. package/dist/themes/data/catppuccin-frappe.js +177 -0
  139. package/dist/themes/data/catppuccin-latte.d.ts +3 -0
  140. package/dist/themes/data/catppuccin-latte.js +177 -0
  141. package/dist/themes/data/catppuccin-macchiato.d.ts +3 -0
  142. package/dist/themes/data/catppuccin-macchiato.js +177 -0
  143. package/dist/themes/data/catppuccin-mocha.d.ts +3 -0
  144. package/dist/themes/data/catppuccin-mocha.js +177 -0
  145. package/dist/themes/data/cyberpunk.d.ts +17 -0
  146. package/dist/themes/data/cyberpunk.js +193 -0
  147. package/dist/themes/data/default.d.ts +3 -0
  148. package/dist/themes/data/default.js +160 -0
  149. package/dist/themes/data/dracula.d.ts +3 -0
  150. package/dist/themes/data/dracula.js +177 -0
  151. package/dist/themes/data/flexoki.d.ts +3 -0
  152. package/dist/themes/data/flexoki.js +177 -0
  153. package/dist/themes/data/gruvbox.d.ts +3 -0
  154. package/dist/themes/data/gruvbox.js +177 -0
  155. package/dist/themes/data/index.d.ts +35 -0
  156. package/dist/themes/data/index.js +64 -0
  157. package/dist/themes/data/monokai.d.ts +3 -0
  158. package/dist/themes/data/monokai.js +177 -0
  159. package/dist/themes/data/nord.d.ts +3 -0
  160. package/dist/themes/data/nord.js +177 -0
  161. package/dist/themes/data/rose-pine-dawn.d.ts +3 -0
  162. package/dist/themes/data/rose-pine-dawn.js +177 -0
  163. package/dist/themes/data/rose-pine-moon.d.ts +3 -0
  164. package/dist/themes/data/rose-pine-moon.js +177 -0
  165. package/dist/themes/data/rose-pine.d.ts +3 -0
  166. package/dist/themes/data/rose-pine.js +177 -0
  167. package/dist/themes/data/solarized-dark.d.ts +3 -0
  168. package/dist/themes/data/solarized-dark.js +177 -0
  169. package/dist/themes/data/solarized-light.d.ts +3 -0
  170. package/dist/themes/data/solarized-light.js +177 -0
  171. package/dist/themes/data/svg-export.d.ts +3 -0
  172. package/dist/themes/data/svg-export.js +177 -0
  173. package/dist/themes/data/textual-ansi.d.ts +3 -0
  174. package/dist/themes/data/textual-ansi.js +160 -0
  175. package/dist/themes/data/textual-dark.d.ts +3 -0
  176. package/dist/themes/data/textual-dark.js +160 -0
  177. package/dist/themes/data/textual-light.d.ts +3 -0
  178. package/dist/themes/data/textual-light.js +160 -0
  179. package/dist/themes/data/tokyo-night.d.ts +3 -0
  180. package/dist/themes/data/tokyo-night.js +177 -0
  181. package/dist/themes/data/types.d.ts +31 -0
  182. package/dist/themes/data/types.js +10 -0
  183. package/dist/themes/palette.d.ts +21 -0
  184. package/dist/themes/palette.js +28 -0
  185. package/dist/themes/ramp.d.ts +83 -0
  186. package/dist/themes/ramp.js +122 -0
  187. package/dist/themes/registry.d.ts +44 -0
  188. package/dist/themes/registry.js +94 -0
  189. package/dist/themes/terminalThemes.d.ts +49 -0
  190. package/dist/themes/terminalThemes.js +63 -0
  191. package/dist/themes/transpose.d.ts +87 -0
  192. package/dist/themes/transpose.js +138 -0
  193. package/dist/widgets/button.d.ts +49 -0
  194. package/dist/widgets/button.js +208 -0
  195. package/dist/widgets/checkbox.d.ts +41 -0
  196. package/dist/widgets/checkbox.js +157 -0
  197. package/dist/widgets/dropdown.d.ts +67 -0
  198. package/dist/widgets/dropdown.js +450 -0
  199. package/dist/widgets/event-router.d.ts +71 -0
  200. package/dist/widgets/event-router.js +629 -0
  201. package/dist/widgets/focus-manager.d.ts +45 -0
  202. package/dist/widgets/focus-manager.js +191 -0
  203. package/dist/widgets/hit.d.ts +64 -0
  204. package/dist/widgets/hit.js +113 -0
  205. package/dist/widgets/index.d.ts +20 -0
  206. package/dist/widgets/index.js +14 -0
  207. package/dist/widgets/slider.d.ts +57 -0
  208. package/dist/widgets/slider.js +270 -0
  209. package/dist/widgets/static-item.d.ts +34 -0
  210. package/dist/widgets/static-item.js +54 -0
  211. package/dist/widgets/text-input.d.ts +274 -0
  212. package/dist/widgets/text-input.js +1165 -0
  213. package/dist/widgets/toggle.d.ts +44 -0
  214. package/dist/widgets/toggle.js +180 -0
  215. package/dist/widgets/types.d.ts +87 -0
  216. package/dist/widgets/types.js +30 -0
  217. package/dist/widgets/widget-app.d.ts +63 -0
  218. package/dist/widgets/widget-app.js +199 -0
  219. package/dist/widgets/widget-base.d.ts +40 -0
  220. package/dist/widgets/widget-base.js +165 -0
  221. package/package.json +6 -2
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Console — the central orchestrator for rendering styled output to the terminal.
3
+ */
4
+ import { Style, Theme } from "./style.js";
5
+ import { ColorDepth } from "./color.js";
6
+ import type { Destination } from "./color.js";
7
+ import type { TerminalTheme } from "./color.js";
8
+ import { type JSONOptions } from "./json.js";
9
+ import type { Highlighter } from "./highlighter.js";
10
+ import { type RuleOptions } from "../renderables/rule.js";
11
+ import type { Height, OverflowMethod, RenderOptions, StyleErrorHandler } from "./protocol.js";
12
+ export interface ConsoleSink {
13
+ write(chunk: string | Uint8Array): unknown;
14
+ }
15
+ export interface ConsoleStream extends ConsoleSink {
16
+ readonly isTTY?: boolean;
17
+ readonly columns?: number;
18
+ readonly rows?: number;
19
+ }
20
+ /**
21
+ * The host facilities a `Console` consults: an environment map and the two
22
+ * standard streams. Node's `process` satisfies this shape as-is, which is the
23
+ * point — injecting a fake terminal needs no adapter at either end.
24
+ */
25
+ export interface ConsoleEnvironment {
26
+ readonly env: NodeJS.ProcessEnv;
27
+ readonly stdout?: ConsoleStream;
28
+ readonly stderr?: ConsoleStream;
29
+ }
30
+ export interface ConsoleOptions {
31
+ /**
32
+ * Color encoding. Accepts a string spec (`"auto"`, `"truecolor"`, `"256"`,
33
+ * `"ansi"`, `"none"`), a `ColorDepth` enum value (use this for `WINDOWS`,
34
+ * which has no string spec), or `null` for no color. Default `"auto"`.
35
+ * Colour only: an explicit depth, `null` included, keeps hyperlinks.
36
+ */
37
+ colorSystem?: string | ColorDepth | null;
38
+ /**
39
+ * Whether OSC 8 hyperlinks are emitted. Default: what the destination takes
40
+ * — true for an explicit `colorSystem`, detected under `"auto"` (no TTY or
41
+ * TERM=dumb: false). `false` with `colorSystem: null` writes plain text.
42
+ */
43
+ hyperlinks?: boolean;
44
+ /**
45
+ * The terminal can draw only ASCII: boxes, rules, tree guides and widget
46
+ * marks draw with ASCII characters instead of line-drawing glyphs. A
47
+ * property of the output device, so it is set here once and reaches every
48
+ * renderable this console draws. Default false.
49
+ */
50
+ asciiOnly?: boolean;
51
+ /**
52
+ * Static width (cells). Ignored when `getSize` is provided. Falls back to
53
+ * the `COLUMNS` env var / the bound stream's `columns` / 80.
54
+ */
55
+ width?: number;
56
+ /**
57
+ * Static height (lines). Ignored when `getSize` is provided. Falls back to
58
+ * the `LINES` env var / the bound stream's `rows` / 24.
59
+ */
60
+ height?: number;
61
+ /**
62
+ * Live size source. When provided, the console reads its width/height from
63
+ * this function on every access, overriding any static `width`/`height` and
64
+ * the bound stream's dimensions. Pass this when the output target's
65
+ * dimensions can change at runtime (e.g. xterm.js in a browser).
66
+ *
67
+ * [LAW:dataflow-not-control-flow] Live size is a function value the
68
+ * console reads, not a branch the call site has to install via
69
+ * `Object.defineProperty`.
70
+ */
71
+ getSize?: () => {
72
+ width: number;
73
+ height: number;
74
+ };
75
+ style?: string | Style;
76
+ forceTerminal?: boolean;
77
+ forceInteractive?: boolean;
78
+ stderr?: boolean;
79
+ file?: ConsoleSink;
80
+ /**
81
+ * Host facilities to consult for colour detection, size detection, and the
82
+ * default output sink. Defaults to the ambient `process`, or — where there
83
+ * is no `process` — an empty environment with no streams. Pass this to drive
84
+ * a `Console` deterministically, or to run one against a simulated terminal.
85
+ */
86
+ environment?: ConsoleEnvironment;
87
+ record?: boolean;
88
+ markup?: boolean;
89
+ highlight?: boolean;
90
+ theme?: Theme;
91
+ highlighter?: Highlighter;
92
+ /**
93
+ * Called each time a render resolves a style string it cannot parse — a
94
+ * misspelled name, a key the theme lacks — and degrades it to unstyled.
95
+ * Calls are per resolution, not per distinct string: a style read twice, or
96
+ * redrawn by a refresh, is reported again. Throw from it to make rendering
97
+ * strict.
98
+ */
99
+ onStyleError?: StyleErrorHandler;
100
+ }
101
+ export interface PrintOptions {
102
+ style?: string | Style;
103
+ justify?: "default" | "left" | "center" | "right" | "full";
104
+ overflow?: OverflowMethod;
105
+ highlight?: boolean;
106
+ markup?: boolean;
107
+ softWrap?: boolean;
108
+ crop?: boolean;
109
+ end?: string;
110
+ sep?: string;
111
+ }
112
+ export declare class Console {
113
+ private readonly _destination;
114
+ private _getSize;
115
+ private _style;
116
+ private _isTerminal;
117
+ private _forceInteractive;
118
+ private _file;
119
+ private _stream;
120
+ private _record;
121
+ private _markup;
122
+ private _highlight;
123
+ private _theme;
124
+ private _onStyleError;
125
+ private readonly _asciiOnly;
126
+ private _highlighter;
127
+ private _recorded;
128
+ private _capture;
129
+ constructor(options?: ConsoleOptions);
130
+ get size(): {
131
+ width: number;
132
+ height: number;
133
+ };
134
+ get width(): number;
135
+ get height(): number;
136
+ get isTerminal(): boolean;
137
+ get isInteractive(): boolean;
138
+ get colorSystem(): ColorDepth | null;
139
+ /**
140
+ * Where this console writes: the colour depth it draws at and whether it
141
+ * emits OSC 8 hyperlinks, overrides applied — the value its output is
142
+ * encoded for, for anything that encodes on its behalf (`Live`).
143
+ */
144
+ get destination(): Destination;
145
+ get file(): ConsoleSink;
146
+ get theme(): Theme;
147
+ get options(): RenderOptions & {
148
+ height: Height;
149
+ };
150
+ print(...args: unknown[]): void;
151
+ log(...args: unknown[]): void;
152
+ rule(title?: string, options?: RuleOptions): void;
153
+ printJson(json: string | object, options?: JSONOptions): void;
154
+ beginCapture(): void;
155
+ endCapture(): string;
156
+ exportText({ clear }?: {
157
+ clear?: boolean;
158
+ }): string;
159
+ exportHtml({ theme, clear }?: {
160
+ theme?: TerminalTheme;
161
+ clear?: boolean;
162
+ }): string;
163
+ private _writeSegments;
164
+ private _write;
165
+ }