@promptctl/rich-js 0.7.0 → 0.9.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 (201) hide show
  1. package/README.md +99 -31
  2. package/dist/core/box.d.ts +96 -42
  3. package/dist/core/box.d.ts.map +1 -1
  4. package/dist/core/box.js +348 -490
  5. package/dist/core/box.js.map +1 -1
  6. package/dist/core/cells.d.ts +46 -1
  7. package/dist/core/cells.d.ts.map +1 -1
  8. package/dist/core/cells.js +55 -14
  9. package/dist/core/cells.js.map +1 -1
  10. package/dist/core/color.d.ts.map +1 -1
  11. package/dist/core/color.js +22 -8
  12. package/dist/core/color.js.map +1 -1
  13. package/dist/core/console.d.ts +30 -14
  14. package/dist/core/console.d.ts.map +1 -1
  15. package/dist/core/console.js +176 -104
  16. package/dist/core/console.js.map +1 -1
  17. package/dist/core/highlighter.d.ts +2 -1
  18. package/dist/core/highlighter.d.ts.map +1 -1
  19. package/dist/core/highlighter.js +28 -6
  20. package/dist/core/highlighter.js.map +1 -1
  21. package/dist/{renderables → core}/json.d.ts +8 -3
  22. package/dist/core/json.d.ts.map +1 -0
  23. package/dist/{renderables → core}/json.js +7 -2
  24. package/dist/core/json.js.map +1 -0
  25. package/dist/core/markup.d.ts +6 -9
  26. package/dist/core/markup.d.ts.map +1 -1
  27. package/dist/core/markup.js +153 -47
  28. package/dist/core/markup.js.map +1 -1
  29. package/dist/core/measure.d.ts +11 -0
  30. package/dist/core/measure.d.ts.map +1 -1
  31. package/dist/core/measure.js +15 -3
  32. package/dist/core/measure.js.map +1 -1
  33. package/dist/core/oklch.d.ts +22 -0
  34. package/dist/core/oklch.d.ts.map +1 -1
  35. package/dist/core/oklch.js +62 -18
  36. package/dist/core/oklch.js.map +1 -1
  37. package/dist/core/pretty.d.ts +122 -0
  38. package/dist/core/pretty.d.ts.map +1 -0
  39. package/dist/core/pretty.js +398 -0
  40. package/dist/core/pretty.js.map +1 -0
  41. package/dist/core/protocol.d.ts +80 -0
  42. package/dist/core/protocol.d.ts.map +1 -1
  43. package/dist/core/protocol.js +85 -0
  44. package/dist/core/protocol.js.map +1 -1
  45. package/dist/core/segment.d.ts +26 -0
  46. package/dist/core/segment.d.ts.map +1 -1
  47. package/dist/core/segment.js +45 -0
  48. package/dist/core/segment.js.map +1 -1
  49. package/dist/core/strip.d.ts +9 -5
  50. package/dist/core/strip.d.ts.map +1 -1
  51. package/dist/core/strip.js +39 -41
  52. package/dist/core/strip.js.map +1 -1
  53. package/dist/core/style.d.ts +19 -0
  54. package/dist/core/style.d.ts.map +1 -1
  55. package/dist/core/style.js +46 -38
  56. package/dist/core/style.js.map +1 -1
  57. package/dist/core/subscription.d.ts +13 -0
  58. package/dist/core/subscription.d.ts.map +1 -0
  59. package/dist/core/subscription.js +13 -0
  60. package/dist/core/subscription.js.map +1 -0
  61. package/dist/core/text.d.ts +102 -4
  62. package/dist/core/text.d.ts.map +1 -1
  63. package/dist/core/text.js +332 -162
  64. package/dist/core/text.js.map +1 -1
  65. package/dist/core/wrap.d.ts +42 -0
  66. package/dist/core/wrap.d.ts.map +1 -0
  67. package/dist/core/wrap.js +128 -0
  68. package/dist/core/wrap.js.map +1 -0
  69. package/dist/host/host-stream.d.ts.map +1 -0
  70. package/dist/host/host-stream.js.map +1 -0
  71. package/dist/host/index.d.ts +4 -0
  72. package/dist/host/index.d.ts.map +1 -0
  73. package/dist/host/index.js +3 -0
  74. package/dist/host/index.js.map +1 -0
  75. package/dist/{widgets → host}/terminal-host.d.ts +20 -64
  76. package/dist/host/terminal-host.d.ts.map +1 -0
  77. package/dist/host/terminal-host.js +133 -0
  78. package/dist/host/terminal-host.js.map +1 -0
  79. package/dist/index.d.ts +13 -36
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +35 -22
  82. package/dist/index.js.map +1 -1
  83. package/dist/node/terminal-host.d.ts +85 -0
  84. package/dist/node/terminal-host.d.ts.map +1 -0
  85. package/dist/node/terminal-host.js +161 -0
  86. package/dist/node/terminal-host.js.map +1 -0
  87. package/dist/node/traceback.d.ts +28 -0
  88. package/dist/node/traceback.d.ts.map +1 -0
  89. package/dist/node/traceback.js +113 -0
  90. package/dist/node/traceback.js.map +1 -0
  91. package/dist/renderables/columns.d.ts +24 -2
  92. package/dist/renderables/columns.d.ts.map +1 -1
  93. package/dist/renderables/columns.js +91 -32
  94. package/dist/renderables/columns.js.map +1 -1
  95. package/dist/renderables/layout.d.ts +61 -5
  96. package/dist/renderables/layout.d.ts.map +1 -1
  97. package/dist/renderables/layout.js +191 -19
  98. package/dist/renderables/layout.js.map +1 -1
  99. package/dist/renderables/markdown.d.ts +1 -1
  100. package/dist/renderables/markdown.d.ts.map +1 -1
  101. package/dist/renderables/markdown.js +7 -14
  102. package/dist/renderables/markdown.js.map +1 -1
  103. package/dist/renderables/padding.d.ts +16 -3
  104. package/dist/renderables/padding.d.ts.map +1 -1
  105. package/dist/renderables/padding.js +96 -47
  106. package/dist/renderables/padding.js.map +1 -1
  107. package/dist/renderables/panel.d.ts +48 -7
  108. package/dist/renderables/panel.d.ts.map +1 -1
  109. package/dist/renderables/panel.js +175 -106
  110. package/dist/renderables/panel.js.map +1 -1
  111. package/dist/renderables/progress.d.ts +3 -3
  112. package/dist/renderables/progress.d.ts.map +1 -1
  113. package/dist/renderables/progress.js +11 -9
  114. package/dist/renderables/progress.js.map +1 -1
  115. package/dist/renderables/progressBar.d.ts +3 -3
  116. package/dist/renderables/progressBar.d.ts.map +1 -1
  117. package/dist/renderables/progressBar.js +9 -15
  118. package/dist/renderables/progressBar.js.map +1 -1
  119. package/dist/renderables/prompt.js +1 -1
  120. package/dist/renderables/prompt.js.map +1 -1
  121. package/dist/renderables/rule.d.ts +1 -1
  122. package/dist/renderables/rule.d.ts.map +1 -1
  123. package/dist/renderables/rule.js +5 -10
  124. package/dist/renderables/rule.js.map +1 -1
  125. package/dist/renderables/spinner.d.ts +2 -2
  126. package/dist/renderables/spinner.d.ts.map +1 -1
  127. package/dist/renderables/spinner.js +6 -11
  128. package/dist/renderables/spinner.js.map +1 -1
  129. package/dist/renderables/status.d.ts.map +1 -1
  130. package/dist/renderables/status.js +5 -11
  131. package/dist/renderables/status.js.map +1 -1
  132. package/dist/renderables/table.d.ts +90 -16
  133. package/dist/renderables/table.d.ts.map +1 -1
  134. package/dist/renderables/table.js +481 -223
  135. package/dist/renderables/table.js.map +1 -1
  136. package/dist/renderables/traceback.d.ts +7 -3
  137. package/dist/renderables/traceback.d.ts.map +1 -1
  138. package/dist/renderables/traceback.js +15 -18
  139. package/dist/renderables/traceback.js.map +1 -1
  140. package/dist/renderables/tree.d.ts +29 -4
  141. package/dist/renderables/tree.d.ts.map +1 -1
  142. package/dist/renderables/tree.js +86 -33
  143. package/dist/renderables/tree.js.map +1 -1
  144. package/dist/template-bindings/color-funcs.d.ts +3 -3
  145. package/dist/template-bindings/color-funcs.js +3 -3
  146. package/dist/template-bindings/helpers.d.ts.map +1 -1
  147. package/dist/template-bindings/helpers.js +19 -1
  148. package/dist/template-bindings/helpers.js.map +1 -1
  149. package/dist/template-bindings/index.d.ts +6 -7
  150. package/dist/template-bindings/index.d.ts.map +1 -1
  151. package/dist/template-bindings/index.js +6 -7
  152. package/dist/template-bindings/index.js.map +1 -1
  153. package/dist/template-bindings/palette-funcs.d.ts +17 -5
  154. package/dist/template-bindings/palette-funcs.d.ts.map +1 -1
  155. package/dist/template-bindings/palette-funcs.js +69 -6
  156. package/dist/template-bindings/palette-funcs.js.map +1 -1
  157. package/dist/template-bindings/style-funcs.d.ts +1 -1
  158. package/dist/template-bindings/style-funcs.js +1 -1
  159. package/dist/themes/ramp.d.ts +84 -0
  160. package/dist/themes/ramp.d.ts.map +1 -0
  161. package/dist/themes/ramp.js +123 -0
  162. package/dist/themes/ramp.js.map +1 -0
  163. package/dist/widgets/dropdown.d.ts +1 -1
  164. package/dist/widgets/dropdown.js +1 -1
  165. package/dist/widgets/event-router.d.ts +3 -2
  166. package/dist/widgets/event-router.d.ts.map +1 -1
  167. package/dist/widgets/focus-manager.d.ts +2 -1
  168. package/dist/widgets/focus-manager.d.ts.map +1 -1
  169. package/dist/widgets/index.d.ts +3 -6
  170. package/dist/widgets/index.d.ts.map +1 -1
  171. package/dist/widgets/index.js +4 -3
  172. package/dist/widgets/index.js.map +1 -1
  173. package/dist/widgets/screen.d.ts +1 -1
  174. package/dist/widgets/screen.d.ts.map +1 -1
  175. package/dist/widgets/text-input.d.ts +2 -3
  176. package/dist/widgets/text-input.d.ts.map +1 -1
  177. package/dist/widgets/text-input.js +4 -12
  178. package/dist/widgets/text-input.js.map +1 -1
  179. package/dist/widgets/types.d.ts +1 -1
  180. package/dist/widgets/types.d.ts.map +1 -1
  181. package/dist/widgets/types.js.map +1 -1
  182. package/dist/widgets/widget-base.d.ts +2 -1
  183. package/dist/widgets/widget-base.d.ts.map +1 -1
  184. package/package.json +38 -6
  185. package/dist/renderables/json.d.ts.map +0 -1
  186. package/dist/renderables/json.js.map +0 -1
  187. package/dist/renderables/pretty.d.ts +0 -29
  188. package/dist/renderables/pretty.d.ts.map +0 -1
  189. package/dist/renderables/pretty.js +0 -141
  190. package/dist/renderables/pretty.js.map +0 -1
  191. package/dist/themes/paletteResolver.d.ts +0 -35
  192. package/dist/themes/paletteResolver.d.ts.map +0 -1
  193. package/dist/themes/paletteResolver.js +0 -88
  194. package/dist/themes/paletteResolver.js.map +0 -1
  195. package/dist/widgets/host-stream.d.ts.map +0 -1
  196. package/dist/widgets/host-stream.js.map +0 -1
  197. package/dist/widgets/terminal-host.d.ts.map +0 -1
  198. package/dist/widgets/terminal-host.js +0 -258
  199. package/dist/widgets/terminal-host.js.map +0 -1
  200. /package/dist/{widgets → host}/host-stream.d.ts +0 -0
  201. /package/dist/{widgets → host}/host-stream.js +0 -0
@@ -3,12 +3,25 @@
3
3
  */
4
4
  import { Segment } from "../core/segment.js";
5
5
  import { RichText } from "../core/text.js";
6
+ import { isMeasurable, withBoundedWidth, withCellWidth } from "../core/protocol.js";
7
+ import { Measurement } from "../core/measure.js";
8
+ import { cellCount } from "../core/cells.js";
9
+ /**
10
+ * A share weight, not a cell count: fractions divide space meaningfully, so
11
+ * this parses where `cellCount` would floor. A weight that cannot name a share
12
+ * — negative, NaN, infinite — reads as zero, which already means "this pane
13
+ * does not grow" and is filtered out before any division. That is what makes
14
+ * every ratio reaching `_distributeSpace` and `_rowBudgetFor` positive.
15
+ */
16
+ function growthRatio(ratio) {
17
+ return Number.isFinite(ratio) && ratio > 0 ? ratio : 0;
18
+ }
6
19
  export class Layout {
7
20
  name;
8
- ratio;
9
- size;
10
- minimumSize;
11
21
  visible;
22
+ _ratio;
23
+ _size;
24
+ _minimumSize;
12
25
  _renderable;
13
26
  _children;
14
27
  _splitDirection;
@@ -26,9 +39,52 @@ export class Layout {
26
39
  this._children = [];
27
40
  this._splitDirection = undefined;
28
41
  }
42
+ /**
43
+ * The three declared numbers, parsed on assignment rather than at the
44
+ * constructor. All three are public and a caller reaches them long after
45
+ * construction — `layout.getByName("pane")!.ratio = -1` walked straight past a
46
+ * constructor-only parse and put a negative weight back into the division that
47
+ * `_rowBudgetFor` and `_distributeSpace` are written to trust.
48
+ *
49
+ * [LAW:parse-dont-validate] The setter is the border, so the guarantee holds
50
+ * for the object's whole lifetime and nothing downstream re-checks. `size` and
51
+ * `minimumSize` are cell counts; `ratio` is a share weight and keeps its
52
+ * fractions. Absence is preserved rather than parsed: an undefined `size`
53
+ * selects a flex pane, and `cellCount` would read it as a declared zero.
54
+ */
55
+ get ratio() {
56
+ return this._ratio;
57
+ }
58
+ set ratio(value) {
59
+ this._ratio = growthRatio(value);
60
+ }
61
+ get size() {
62
+ return this._size;
63
+ }
64
+ set size(value) {
65
+ this._size = value === undefined ? undefined : cellCount(value);
66
+ }
67
+ get minimumSize() {
68
+ return this._minimumSize;
69
+ }
70
+ set minimumSize(value) {
71
+ this._minimumSize = cellCount(value);
72
+ }
29
73
  get children() {
30
74
  return this._children;
31
75
  }
76
+ /**
77
+ * Whether this layout draws `_renderable` or its children.
78
+ *
79
+ * [LAW:one-source-of-truth] `render` and `_naturalWidth` must answer this the
80
+ * same way. Asked separately they did not: `_naturalWidth` read it off the
81
+ * *visible* children, so a layout holding content and a single hidden child
82
+ * reported that content's width while `render` emitted nothing at all, and a
83
+ * fit-mode `Panel` framed twelve cells of air.
84
+ */
85
+ get _isLeaf() {
86
+ return this._children.length === 0;
87
+ }
32
88
  splitColumn(...layouts) {
33
89
  this._children = layouts;
34
90
  this._splitDirection = "column";
@@ -52,13 +108,21 @@ export class Layout {
52
108
  }
53
109
  return undefined;
54
110
  }
55
- *render(options) {
111
+ *render(rawOptions) {
56
112
  if (!this.visible)
57
113
  return;
58
- if (this._children.length === 0) {
59
- // Leaf node — render content
114
+ // Parsed once at the top of the layout rather than at the row split below,
115
+ // because a column split forwards the width to its children untouched and
116
+ // would otherwise hand each of them the caller's raw number.
117
+ const options = withBoundedWidth(rawOptions, this);
118
+ if (this._isLeaf) {
119
+ // Cropped rather than forwarded: a leaf hands its content the offer and
120
+ // content is free to ignore it, and a pane wider than the region it was
121
+ // given is the one thing a layout may never emit — in a row split it
122
+ // overwrites the pane beside it. The row path already crops each share,
123
+ // so this is the same rule at the one place that skipped it.
60
124
  if (this._renderable) {
61
- yield* this._renderable.render(options);
125
+ yield* Segment.cropLines(this._renderable.render(options), options.maxWidth);
62
126
  }
63
127
  return;
64
128
  }
@@ -87,7 +151,9 @@ export class Layout {
87
151
  }
88
152
  }
89
153
  *_renderRow(children, options) {
90
- // Horizontal side-by-side: distribute width, then merge child lines.
154
+ // Horizontal side-by-side: divide the requested width once, then merge
155
+ // child lines. The budget arrives parsed from `render` — unparsed, a NaN
156
+ // width made every share NaN and the merge threw `Invalid array length`.
91
157
  const widths = this._distributeSpace(children, options.maxWidth);
92
158
  const cells = children.map((child, i) => ({
93
159
  width: widths[i],
@@ -100,31 +166,137 @@ export class Layout {
100
166
  _distributeSpace(children, totalSpace) {
101
167
  const sizes = new Array(children.length).fill(0);
102
168
  let remaining = totalSpace;
103
- // Fixed-size children first
104
- const flexChildren = [];
169
+ // Children that do not grow are paid first: a declared `size`, and equally
170
+ // a `ratio` of 0, which is the caller saying this pane stays at its
171
+ // `minimumSize`. Left in the ratio pass below, a zero-ratio child divided
172
+ // by its own ratio and drew its minimum out of a budget the shares had
173
+ // already spent — three panes of `zzz`/`aaaaa`/`bbbbb` consumed
174
+ // `3 + 2*floor(T/2)` cells out of `T`, which no `T` satisfies, and the row
175
+ // only came out right at 16 because the `Math.min(remaining, ...)` below
176
+ // happened to clip the last share to the right number.
177
+ const growing = [];
105
178
  for (let i = 0; i < children.length; i++) {
106
179
  const child = children[i];
107
180
  if (child.size !== undefined) {
108
181
  sizes[i] = Math.min(child.size, remaining);
109
- remaining -= sizes[i];
182
+ }
183
+ else if (child.ratio === 0) {
184
+ sizes[i] = Math.min(child.minimumSize, remaining);
110
185
  }
111
186
  else {
112
- flexChildren.push(i);
187
+ growing.push(i);
188
+ continue;
113
189
  }
190
+ remaining -= sizes[i];
114
191
  }
115
- // Distribute remaining by ratio
116
- if (flexChildren.length > 0 && remaining > 0) {
117
- const totalRatio = flexChildren.reduce((s, idx) => s + children[idx].ratio, 0);
118
- for (const idx of flexChildren) {
192
+ // Distribute what is left by ratio. Each child's share comes off one
193
+ // budget and is bounded by what that budget still holds: `minimumSize` is
194
+ // what a child asks for, `remaining` is what there is to give, and the
195
+ // second beats the first. Applied without that bound — as
196
+ // `Math.max(minimumSize, share)` alone — every child claimed its whole
197
+ // minimum out of a budget that could not cover one of them, so two
198
+ // children of a Layout asked to fit one cell merged into a two-cell row.
199
+ if (growing.length > 0 && remaining > 0) {
200
+ const budget = remaining;
201
+ // Every ratio in here is positive — `growthRatio` parses the rest to zero
202
+ // at the constructor and zero is filtered out above — which is what makes
203
+ // the division safe and `_rowBudgetFor`'s inverse of it finite.
204
+ const totalRatio = growing.reduce((s, idx) => s + children[idx].ratio, 0);
205
+ for (const idx of growing) {
119
206
  const child = children[idx];
120
- const allocated = Math.max(child.minimumSize, Math.floor(remaining * child.ratio / totalRatio));
207
+ const share = Math.floor(budget * child.ratio / totalRatio);
208
+ const allocated = Math.min(remaining, Math.max(child.minimumSize, share));
121
209
  sizes[idx] = allocated;
210
+ remaining -= allocated;
122
211
  }
123
212
  }
124
213
  return sizes;
125
214
  }
126
- measure(options) {
127
- return { minimum: this.minimumSize, maximum: options.maxWidth };
215
+ /**
216
+ * The width this layout would take if nothing constrained it: its content's
217
+ * for a leaf, its children's laid out the way the split lays them out.
218
+ *
219
+ * A `size` counts only across a row, which is the one direction in which it
220
+ * is a width — down a column the same field is a height, and reading it as a
221
+ * width there would report a two-line pane as two cells wide.
222
+ */
223
+ _naturalWidth(options) {
224
+ if (!this.visible)
225
+ return 0;
226
+ if (this._isLeaf) {
227
+ if (this._renderable === undefined)
228
+ return 0;
229
+ // A leaf whose content cannot measure itself has no width of its own to
230
+ // report, so it reports the offer — unbounded included, which is where
231
+ // `withBoundedWidth` says so rather than inventing a number.
232
+ return isMeasurable(this._renderable)
233
+ ? Measurement.get(options, this._renderable).maximum
234
+ : options.maxWidth;
235
+ }
236
+ const visible = this._children.filter((c) => c.visible);
237
+ if (visible.length === 0)
238
+ return 0;
239
+ const widths = visible.map((c) => c._naturalWidth(options));
240
+ if (this._splitDirection === "row")
241
+ return this._rowBudgetFor(visible, widths);
242
+ // Accumulated, not spread: a column split holds as many children as a caller
243
+ // made, and `Math.max(...widths)` passes one argument per child, so a
244
+ // generated dashboard deep enough overruns the engine's argument limit and
245
+ // throws out of `measure()`.
246
+ let widest = 0;
247
+ for (const width of widths)
248
+ widest = Math.max(widest, width);
249
+ return widest;
250
+ }
251
+ /**
252
+ * The budget at which `_distributeSpace` gives every child of a row at least
253
+ * the width it wants — the inverse of the ratio rule above, and the reason
254
+ * this is not the sum of those widths.
255
+ *
256
+ * [LAW:one-source-of-truth] A growing child receives `floor(budget * ratio /
257
+ * totalRatio)`, so to receive `want` cells it needs the budget to reach
258
+ * `want * totalRatio / ratio`, and one budget serves them all: the row needs
259
+ * the largest demand, never their total. Summed instead, a 1:1 split of
260
+ * "left" and "right" reported 9 and then rendered "right" into the 4 cells
261
+ * that `floor(9/2)` actually hands it.
262
+ *
263
+ * The panes that do not grow are paid first here for the same reason they
264
+ * are paid first there — and it is the reason this divides by no zero: a
265
+ * `ratio` of 0 never reaches the division, because a pane that does not grow
266
+ * demands nothing of a budget for growing.
267
+ */
268
+ _rowBudgetFor(children, widths) {
269
+ const growing = children.filter((c) => c.size === undefined && c.ratio !== 0);
270
+ const totalRatio = growing.reduce((sum, c) => sum + c.ratio, 0);
271
+ let pinned = 0;
272
+ let budget = 0;
273
+ for (const [i, child] of children.entries()) {
274
+ if (child.size !== undefined) {
275
+ pinned += child.size;
276
+ }
277
+ else if (child.ratio === 0) {
278
+ pinned += child.minimumSize;
279
+ }
280
+ else {
281
+ const want = Math.max(child.minimumSize, widths[i]);
282
+ budget = Math.max(budget, Math.ceil(want * totalRatio / child.ratio));
283
+ }
284
+ }
285
+ return pinned + budget;
286
+ }
287
+ measure(rawOptions) {
288
+ // `minimumSize` is what this layout asks for and the ceiling is what it was
289
+ // offered; the ceiling wins. Unclamped, a layout measured into no width
290
+ // reported the range 1..0 — a floor above its own ceiling, which the parent
291
+ // that asked cannot divide.
292
+ //
293
+ // The ceiling alone was not the answer either: a layout that reported the
294
+ // whole offer as its maximum told every parent it wanted all of it, so
295
+ // `Panel` in fit mode drew its frame at the full console width around a
296
+ // layout of two short panes, and an unbounded offer came back unbounded.
297
+ const parsed = withCellWidth(rawOptions);
298
+ const maximum = Math.min(this._naturalWidth(parsed), parsed.maxWidth);
299
+ return { minimum: Math.min(this.minimumSize, maximum), maximum };
128
300
  }
129
301
  }
130
302
  //# sourceMappingURL=layout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/renderables/layout.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OA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@@ -13,7 +13,7 @@ export interface MarkdownOptions {
13
13
  }
14
14
  export declare class Markdown implements Renderable, Measurable {
15
15
  readonly markdown: string;
16
- readonly inlineCodeStyle: Style;
16
+ readonly inlineCodeStyle: string | Style;
17
17
  readonly hyperlinks: boolean;
18
18
  constructor(markdown: string, options?: MarkdownOptions);
19
19
  render(options: RenderOptions): Iterable<Segment>;
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/renderables/markdown.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAGrD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACd,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CAChD;AA6ID,qBAAa,QAAS,YAAW,UAAU,EAAE,UAAU;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;gBAEjB,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe;IAMtD,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC;IA6DlD,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAGtE"}
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/renderables/markdown.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACd,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CAChD;AAuID,qBAAa,QAAS,YAAW,UAAU,EAAE,UAAU;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;gBAEjB,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe;IAMtD,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC;IA4DlD,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAGtE"}
@@ -3,16 +3,10 @@
3
3
  * Uses built-in parsing (no external dependency).
4
4
  */
5
5
  import { Segment } from "../core/segment.js";
6
- import { Style, NULL_STYLE } from "../core/style.js";
6
+ import { Style } from "../core/style.js";
7
7
  import { RichText } from "../core/text.js";
8
8
  import { Rule } from "./rule.js";
9
- function resolveStyle(style) {
10
- if (style === undefined)
11
- return NULL_STYLE;
12
- if (typeof style === "string")
13
- return Style.parse(style);
14
- return style;
15
- }
9
+ import { getStyle } from "../core/protocol.js";
16
10
  function tokenize(markdown) {
17
11
  const lines = markdown.split("\n");
18
12
  const tokens = [];
@@ -107,7 +101,7 @@ function applyInlineStyles(text) {
107
101
  }
108
102
  else if (match[4]) {
109
103
  // Inline code: `text`
110
- result.append(match[4], Style.parse("markdown.code"));
104
+ result.append(match[4], "markdown.code");
111
105
  }
112
106
  else if (match[5] && match[6]) {
113
107
  // Link: [text](url)
@@ -127,7 +121,7 @@ export class Markdown {
127
121
  hyperlinks;
128
122
  constructor(markdown, options) {
129
123
  this.markdown = markdown;
130
- this.inlineCodeStyle = resolveStyle(options?.inlineCodeStyle ?? "markdown.code");
124
+ this.inlineCodeStyle = options?.inlineCodeStyle ?? "markdown.code";
131
125
  this.hyperlinks = options?.hyperlinks !== false;
132
126
  }
133
127
  *render(options) {
@@ -135,8 +129,7 @@ export class Markdown {
135
129
  for (const token of tokens) {
136
130
  switch (token.type) {
137
131
  case "heading": {
138
- const styleKey = `markdown.h${Math.min(token.level, 4)}`;
139
- const style = Style.parse(styleKey);
132
+ const style = getStyle(options, `markdown.h${Math.min(token.level, 4)}`);
140
133
  const text = applyInlineStyles(token.text);
141
134
  yield* Segment.applyStyle([...text.render(options)], style);
142
135
  yield Segment.line();
@@ -149,7 +142,7 @@ export class Markdown {
149
142
  break;
150
143
  }
151
144
  case "code_block": {
152
- const codeStyle = Style.parse("markdown.code");
145
+ const codeStyle = getStyle(options, "markdown.code");
153
146
  const lines = token.code.split("\n");
154
147
  for (const line of lines) {
155
148
  yield new Segment(line, codeStyle);
@@ -171,7 +164,7 @@ export class Markdown {
171
164
  }
172
165
  case "blockquote": {
173
166
  const quoteStyle = Style.parse("dim italic");
174
- yield new Segment("▎ ", Style.parse("markdown.hr"));
167
+ yield new Segment("▎ ", getStyle(options, "markdown.hr"));
175
168
  const text = applyInlineStyles(token.text);
176
169
  yield* Segment.applyStyle([...text.render(options)], quoteStyle);
177
170
  yield Segment.line();
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/renderables/markdown.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OA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BAClB,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;oBAC7C,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;oBAC1D,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC3C,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;oBACjE,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;oBACrB,MAAM;gBACR,CAAC;gBAED,KAAK,OAAO;oBACV,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;oBACrB,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAsB;QAC5B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnD,CAAC;CACF"}
@@ -5,20 +5,33 @@ import { Segment } from "../core/segment.js";
5
5
  import { Style } from "../core/style.js";
6
6
  import type { Renderable, Measurable, RenderOptions } from "../core/protocol.js";
7
7
  export type PaddingDimensions = number | [number, number] | [number, number, number, number];
8
+ /**
9
+ * Parses the shapes a caller may write padding in — one number, a vertical/
10
+ * horizontal pair, or all four sides — into the four-sided form every
11
+ * renderable indexes by, flooring each side at zero.
12
+ *
13
+ * [LAW:parse-dont-validate] This is the one crossing between the public
14
+ * padding vocabulary and the internal tuple, which is why the floor lives
15
+ * here and nowhere downstream: past this point `" ".repeat(left)` is safe in
16
+ * any renderable without asking what the caller passed. A negative side used
17
+ * to reach the renderers, where `Panel` drew content rows wider than its own
18
+ * border and `Table` threw outright.
19
+ */
20
+ export declare function normalizePadding(padding: PaddingDimensions): [number, number, number, number];
8
21
  export declare class Padding implements Renderable, Measurable {
9
22
  readonly renderable: Renderable;
10
23
  readonly top: number;
11
24
  readonly right: number;
12
25
  readonly bottom: number;
13
26
  readonly left: number;
14
- readonly style: Style;
27
+ readonly style: string | Style;
15
28
  readonly expand: boolean;
16
29
  constructor(renderable: Renderable, padding: PaddingDimensions, options?: {
17
30
  style?: string | Style;
18
31
  expand?: boolean;
19
32
  });
20
- render(options: RenderOptions): Iterable<Segment>;
21
- measure(options: RenderOptions): {
33
+ render(rawOptions: RenderOptions): Iterable<Segment>;
34
+ measure(rawOptions: RenderOptions): {
22
35
  minimum: number;
23
36
  maximum: number;
24
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"padding.d.ts","sourceRoot":"","sources":["../../src/renderables/padding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACd,MAAM,qBAAqB,CAAC;AAG7B,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,CAAC,MAAM,EAAE,MAAM,CAAC,GAChB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAcrC,qBAAa,OAAQ,YAAW,UAAU,EAAE,UAAU;IACpD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAGvB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAA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,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;IAYvD,MAAM,CAAC,UAAU,EAAE,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC;IA8CrD,OAAO,CAAC,UAAU,EAAE,aAAa,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAsBzE"}
@@ -2,17 +2,70 @@
2
2
  * Padding — wraps a renderable with whitespace padding on all four sides.
3
3
  */
4
4
  import { Segment } from "../core/segment.js";
5
- import { Style, NULL_STYLE } from "../core/style.js";
5
+ import { cellCount } from "../core/cells.js";
6
+ import { NULL_STYLE } from "../core/style.js";
6
7
  import { Measurement } from "../core/measure.js";
7
- import { isMeasurable } from "../core/protocol.js";
8
- function normalizePadding(padding) {
9
- if (typeof padding === "number") {
10
- return [padding, padding, padding, padding];
11
- }
12
- if (padding.length === 2) {
13
- return [padding[0], padding[1], padding[0], padding[1]];
14
- }
15
- return padding;
8
+ import { getStyle, isMeasurable, withBoundedWidth, withCellWidth } from "../core/protocol.js";
9
+ /**
10
+ * Parses the shapes a caller may write padding in — one number, a vertical/
11
+ * horizontal pair, or all four sides — into the four-sided form every
12
+ * renderable indexes by, flooring each side at zero.
13
+ *
14
+ * [LAW:parse-dont-validate] This is the one crossing between the public
15
+ * padding vocabulary and the internal tuple, which is why the floor lives
16
+ * here and nowhere downstream: past this point `" ".repeat(left)` is safe in
17
+ * any renderable without asking what the caller passed. A negative side used
18
+ * to reach the renderers, where `Panel` drew content rows wider than its own
19
+ * border and `Table` threw outright.
20
+ */
21
+ export function normalizePadding(padding) {
22
+ // A padding side is a count of cells like any other, so it is parsed by the
23
+ // same rule rather than by a second copy of it: a fractional side reaches
24
+ // `" ".repeat`, which truncates, while the rows around it are measured
25
+ // arithmetically — so the padding and the border disagree and the frame
26
+ // breaks. `cellCount`'s header carries why the comparison, not `Math.max`.
27
+ //
28
+ // `Infinity` is where a side stops being an offer and the rule needs the one
29
+ // addition. An unbounded *offer* is a question a renderable can answer, so
30
+ // `cellCount` passes it through; an unbounded *side* is a quantity and there
31
+ // is nothing to draw. Unparsed it reached `budget -= got` as
32
+ // `Infinity - Infinity`, and `new Padding(text, Infinity).measure(...)`
33
+ // handed back `{NaN, NaN}` from a public API.
34
+ const side = (n) => (Number.isFinite(n) ? cellCount(n) : 0);
35
+ const sides = typeof padding === "number"
36
+ ? [padding, padding, padding, padding]
37
+ : padding.length === 2
38
+ ? [padding[0], padding[1], padding[0], padding[1]]
39
+ : padding;
40
+ return [side(sides[0]), side(sides[1]), side(sides[2]), side(sides[3])];
41
+ }
42
+ /**
43
+ * Divides the requested width once into the three spans a padded row is made
44
+ * of, in the order they are worth spending cells on.
45
+ *
46
+ * The three used to be derived separately and disagree where it matters:
47
+ * `render` took the canvas as `Math.max(1, maxWidth - left - right)`, which
48
+ * clamps *up*, so a padding of 1 inside a 2-cell request drew 3-cell content
49
+ * rows beside 2-cell blank rows — an open frame the terminal then soft-wraps.
50
+ * Content takes its first cell before padding takes any, for the reason
51
+ * `layoutPanel` gives: a squeeze should cost you the decoration, not the thing
52
+ * being decorated.
53
+ */
54
+ function layoutPadding(outerWidth, leftWanted, rightWanted) {
55
+ let budget = cellCount(outerWidth);
56
+ const take = (want) => {
57
+ const got = Math.min(want, budget);
58
+ budget -= got;
59
+ return got;
60
+ };
61
+ const firstContentCell = take(1);
62
+ const left = take(leftWanted);
63
+ const right = take(rightWanted);
64
+ return { left, contentWidth: firstContentCell + budget, right };
65
+ }
66
+ /** The full width of a padded row — the division, added back up. */
67
+ function rowWidth(geometry) {
68
+ return geometry.left + geometry.contentWidth + geometry.right;
16
69
  }
17
70
  export class Padding {
18
71
  renderable;
@@ -29,64 +82,60 @@ export class Padding {
29
82
  this.right = right;
30
83
  this.bottom = bottom;
31
84
  this.left = left;
32
- this.style = resolveStyle(options?.style);
85
+ this.style = options?.style ?? NULL_STYLE;
33
86
  this.expand = options?.expand !== false;
34
87
  }
35
- *render(options) {
36
- const maxWidth = options.maxWidth;
37
- const horizontalPad = this.left + this.right;
38
- const innerWidth = Math.max(1, maxWidth - horizontalPad);
88
+ *render(rawOptions) {
89
+ const options = withBoundedWidth(rawOptions, this);
90
+ const geometry = layoutPadding(options.maxWidth, this.left, this.right);
39
91
  const innerOptions = {
40
92
  ...options,
41
- maxWidth: innerWidth,
93
+ maxWidth: geometry.contentWidth,
42
94
  };
43
95
  const segments = [...this.renderable.render(innerOptions)];
44
96
  const lines = Segment.splitLines(segments);
45
- const style = this.style.isNull ? undefined : this.style;
46
- const leftPadStr = " ".repeat(this.left);
47
- const blankLine = " ".repeat(maxWidth);
48
- // Top padding
97
+ const resolved = getStyle(options, this.style);
98
+ const style = resolved.isNull ? undefined : resolved;
99
+ // Zero-length spans need no branch to suppress: the wire boundary drops
100
+ // empty segments, so a padding the width could not afford emits nothing.
101
+ const leftPad = new Segment(" ".repeat(geometry.left), style);
102
+ const rightPad = new Segment(" ".repeat(geometry.right), style);
103
+ const blankLine = new Segment(" ".repeat(rowWidth(geometry)), style);
49
104
  for (let i = 0; i < this.top; i++) {
50
- yield new Segment(blankLine, style);
105
+ yield blankLine;
51
106
  yield Segment.line();
52
107
  }
53
- // Content lines with left/right padding
54
108
  for (const line of lines) {
55
- if (this.left > 0)
56
- yield new Segment(leftPadStr, style);
57
- yield* line;
58
- // Pad to fill remaining width
59
- const lineWidth = Segment.getLineLength(line);
60
- const remaining = this.expand
61
- ? innerWidth - lineWidth + this.right
62
- : this.right;
63
- if (remaining > 0)
64
- yield new Segment(" ".repeat(remaining), style);
109
+ yield leftPad;
110
+ // `expand` is the pad half of this call; the crop half is unconditional,
111
+ // because a child that ignored the canvas it was handed (a Table at its
112
+ // natural width) would otherwise burst the padding around it.
113
+ yield* Segment.adjustLineLength(line, geometry.contentWidth, style, this.expand);
114
+ yield rightPad;
65
115
  yield Segment.line();
66
116
  }
67
- // Bottom padding
68
117
  for (let i = 0; i < this.bottom; i++) {
69
- yield new Segment(blankLine, style);
118
+ yield blankLine;
70
119
  yield Segment.line();
71
120
  }
72
121
  }
73
- measure(options) {
74
- const horizontalPad = this.left + this.right;
122
+ measure(rawOptions) {
123
+ const options = withCellWidth(rawOptions);
124
+ const geometry = layoutPadding(options.maxWidth, this.left, this.right);
125
+ const overhead = geometry.left + geometry.right;
75
126
  if (isMeasurable(this.renderable)) {
76
- const measurement = Measurement.get(options, this.renderable);
127
+ const measurement = Measurement.get({ ...options, maxWidth: geometry.contentWidth }, this.renderable);
128
+ // The ceiling is what was offered, and it wins over what the child asks
129
+ // for: a range whose floor sits above its own ceiling — this returned
130
+ // {8, 8} for three cells of padding inside a two-cell offer — is one no
131
+ // parent layout can divide.
132
+ const maximum = Math.min(options.maxWidth, measurement.maximum + overhead);
77
133
  return {
78
- minimum: measurement.minimum + horizontalPad,
79
- maximum: measurement.maximum + horizontalPad,
134
+ minimum: Math.min(measurement.minimum + overhead, maximum),
135
+ maximum,
80
136
  };
81
137
  }
82
- return { minimum: horizontalPad, maximum: options.maxWidth };
138
+ return { minimum: overhead, maximum: options.maxWidth };
83
139
  }
84
140
  }
85
- function resolveStyle(style) {
86
- if (style === undefined)
87
- return NULL_STYLE;
88
- if (typeof style === "string")
89
- return Style.parse(style);
90
- return style;
91
- }
92
141
  //# sourceMappingURL=padding.js.map