@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,169 @@
1
+ /**
2
+ * Immutable style descriptors — colors, text attributes, links, metadata.
3
+ */
4
+ import { ColorSpec, ColorDepth } from "./color.js";
5
+ import { type Anchor } from "./anchor.js";
6
+ /**
7
+ * Canonical text-attribute inventory. Single source of truth consumed by
8
+ * `Style.parse` / `Style.toString` and the template bindings — adding an
9
+ * attribute here propagates to every styling surface without a second
10
+ * list to keep in sync. [LAW:one-source-of-truth]
11
+ */
12
+ export declare const ATTRIBUTE_NAMES: readonly ["bold", "dim", "italic", "underline", "blink", "blink2", "reverse", "conceal", "strike", "underline2", "frame", "encircle", "overline"];
13
+ export type AttributeName = (typeof ATTRIBUTE_NAMES)[number];
14
+ export declare const ATTRIBUTE_SGR: Record<AttributeName, number>;
15
+ /**
16
+ * Canonical short-attribute aliases (`b` → `bold`, `i` → `italic`, …).
17
+ * Single source of truth consumed by `Style.parse` and the template
18
+ * bindings — adding an alias here makes it available everywhere.
19
+ * [LAW:one-source-of-truth]
20
+ */
21
+ export declare const ATTRIBUTE_SHORT_ALIASES: Record<string, AttributeName>;
22
+ export interface StyleOptions {
23
+ color?: string | ColorSpec;
24
+ bgcolor?: string | ColorSpec;
25
+ bold?: boolean;
26
+ dim?: boolean;
27
+ italic?: boolean;
28
+ underline?: boolean;
29
+ blink?: boolean;
30
+ blink2?: boolean;
31
+ reverse?: boolean;
32
+ conceal?: boolean;
33
+ strike?: boolean;
34
+ underline2?: boolean;
35
+ frame?: boolean;
36
+ encircle?: boolean;
37
+ overline?: boolean;
38
+ link?: string;
39
+ meta?: Record<string, unknown>;
40
+ anchor?: Anchor;
41
+ }
42
+ export declare class StyleSyntaxError extends Error {
43
+ constructor(message: string, options?: ErrorOptions);
44
+ }
45
+ export declare class Style {
46
+ readonly color: ColorSpec | undefined;
47
+ readonly bgcolor: ColorSpec | undefined;
48
+ readonly bold: boolean | undefined;
49
+ readonly dim: boolean | undefined;
50
+ readonly italic: boolean | undefined;
51
+ readonly underline: boolean | undefined;
52
+ readonly blink: boolean | undefined;
53
+ readonly blink2: boolean | undefined;
54
+ readonly reverse: boolean | undefined;
55
+ readonly conceal: boolean | undefined;
56
+ readonly strike: boolean | undefined;
57
+ readonly underline2: boolean | undefined;
58
+ readonly frame: boolean | undefined;
59
+ readonly encircle: boolean | undefined;
60
+ readonly overline: boolean | undefined;
61
+ readonly link: string | undefined;
62
+ readonly meta: Record<string, unknown> | undefined;
63
+ /**
64
+ * Where this style's cells sat in the output of whatever drew them; see
65
+ * `./anchor.ts`. It draws nothing, and it makes two styles that draw alike
66
+ * unequal, because they came from different places.
67
+ */
68
+ readonly anchor: Anchor | undefined;
69
+ constructor(options?: StyleOptions);
70
+ get isNull(): boolean;
71
+ get transparentBackground(): boolean;
72
+ get backgroundStyle(): Style;
73
+ /**
74
+ * This style with `overrides` in place of its own fields.
75
+ *
76
+ * [LAW:one-source-of-truth] The field list is the class's own fields, so a
77
+ * field added to `Style` is carried by every copy without being named here.
78
+ */
79
+ private with;
80
+ get withoutColor(): Style;
81
+ withLink(link: string | undefined): Style;
82
+ clearMetaAndLinks(): Style;
83
+ /**
84
+ * The same look, drawn from the place `anchor` names, or from nowhere.
85
+ */
86
+ withAnchor(anchor: Anchor | undefined): Style;
87
+ /**
88
+ * This style on the cell `cells` to the right: its anchor shifted along its
89
+ * row, or the style itself when it has no anchor.
90
+ */
91
+ shiftedBy(cells: number): Style;
92
+ /**
93
+ * Merges two styles. `other`'s values take priority.
94
+ */
95
+ add(other: Style | undefined): Style;
96
+ equals(other: Style): boolean;
97
+ /**
98
+ * The colours this style puts on screen at `colorSystem`: each flattened
99
+ * onto what lies beneath it — the background onto the terminal's black, the
100
+ * foreground onto that background — then downgraded to the depth. The one
101
+ * account of what a style draws: `toSgrCodes` encodes exactly these, and a
102
+ * renderable choosing between two ways of drawing measures them.
103
+ */
104
+ drawnColors(colorSystem?: ColorDepth): {
105
+ readonly color: ColorSpec | undefined;
106
+ readonly bgcolor: ColorSpec | undefined;
107
+ };
108
+ /**
109
+ * Returns the SGR parameter list this style emits (e.g. `"1;31;48;2;0;0;255"`),
110
+ * or `""` when the style has no SGR contribution. Excludes OSC 8 link bytes —
111
+ * links are not SGR. The segment encoder (`segmentsToString`) uses this
112
+ * string as the group key for adjacent-same-style coalescing and wraps it in
113
+ * `\x1b[...m`; styled text reaches the wire only through that encoder.
114
+ *
115
+ * [LAW:one-source-of-truth] One computation of SGR codes.
116
+ */
117
+ toSgrCodes(colorSystem: ColorDepth): string;
118
+ /**
119
+ * Serializes to a canonical string that round-trips through `Style.parse()`.
120
+ */
121
+ toString(): string;
122
+ static null(): Style;
123
+ static fromColor(color?: ColorSpec, bgcolor?: ColorSpec): Style;
124
+ static fromMeta(meta: Record<string, unknown>): Style;
125
+ static pickFirst(...args: (Style | undefined)[]): Style;
126
+ static combine(styles: (Style | undefined)[]): Style;
127
+ static chain(...styles: (Style | undefined)[]): Style;
128
+ static normalize(definition: string): string;
129
+ /**
130
+ * Parse a space-separated style definition. Cached.
131
+ *
132
+ * A definition only: `"bold red"` parses, `"repr.number"` does not. Names
133
+ * belong to a `Theme`, and `Theme.resolve` is where one is looked up.
134
+ */
135
+ static parse(definition: string): Style;
136
+ }
137
+ export declare const NULL_STYLE: Style;
138
+ export declare class StyleStack {
139
+ private readonly stack;
140
+ constructor(base?: Style);
141
+ get current(): Style;
142
+ push(style: Style): void;
143
+ pop(): Style;
144
+ }
145
+ export declare class Theme {
146
+ private readonly styles;
147
+ constructor(definitions?: Record<string, string>, options?: {
148
+ inherit?: boolean;
149
+ });
150
+ get(name: string): Style | undefined;
151
+ /**
152
+ * The style a `string | Style` stands for under this theme: a name this
153
+ * theme defines, otherwise a definition for `Style.parse`, which throws
154
+ * `StyleSyntaxError` when the string is neither.
155
+ *
156
+ * [LAW:one-source-of-truth] The theme is the one map from names to styles.
157
+ * The lookup stays outside `Style.parse`'s process-wide cache on purpose:
158
+ * cached there, the first console to resolve `repr.number` would decide it
159
+ * for every console after it, whatever theme each was given.
160
+ */
161
+ resolve(style: string | Style): Style;
162
+ has(name: string): boolean;
163
+ }
164
+ export declare const DEFAULT_STYLES: Record<string, Style>;
165
+ /**
166
+ * The theme a render resolves names against when nothing supplied one — what
167
+ * a renderable sees outside a `Console`, as in `renderToString`.
168
+ */
169
+ export declare const DEFAULT_THEME: Theme;