@promptctl/rich-js 0.7.0 → 0.8.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.
- package/README.md +31 -30
- package/dist/core/box.d.ts +3 -3
- package/dist/core/box.d.ts.map +1 -1
- package/dist/core/box.js.map +1 -1
- package/dist/core/cells.d.ts +46 -1
- package/dist/core/cells.d.ts.map +1 -1
- package/dist/core/cells.js +55 -14
- package/dist/core/cells.js.map +1 -1
- package/dist/core/console.d.ts +28 -10
- package/dist/core/console.d.ts.map +1 -1
- package/dist/core/console.js +141 -80
- package/dist/core/console.js.map +1 -1
- package/dist/core/markup.d.ts +0 -2
- package/dist/core/markup.d.ts.map +1 -1
- package/dist/core/markup.js +31 -17
- package/dist/core/markup.js.map +1 -1
- package/dist/core/measure.d.ts +11 -0
- package/dist/core/measure.d.ts.map +1 -1
- package/dist/core/measure.js +15 -3
- package/dist/core/measure.js.map +1 -1
- package/dist/core/oklch.d.ts +22 -0
- package/dist/core/oklch.d.ts.map +1 -1
- package/dist/core/oklch.js +62 -18
- package/dist/core/oklch.js.map +1 -1
- package/dist/core/pretty.d.ts +87 -0
- package/dist/core/pretty.d.ts.map +1 -0
- package/dist/core/pretty.js +304 -0
- package/dist/core/pretty.js.map +1 -0
- package/dist/core/protocol.d.ts +64 -0
- package/dist/core/protocol.d.ts.map +1 -1
- package/dist/core/protocol.js +72 -0
- package/dist/core/protocol.js.map +1 -1
- package/dist/core/segment.d.ts +21 -0
- package/dist/core/segment.d.ts.map +1 -1
- package/dist/core/segment.js +40 -1
- package/dist/core/segment.js.map +1 -1
- package/dist/core/subscription.d.ts +13 -0
- package/dist/core/subscription.d.ts.map +1 -0
- package/dist/core/subscription.js +13 -0
- package/dist/core/subscription.js.map +1 -0
- package/dist/core/text.d.ts.map +1 -1
- package/dist/core/text.js +45 -13
- package/dist/core/text.js.map +1 -1
- package/dist/host/host-stream.d.ts +31 -0
- package/dist/host/host-stream.d.ts.map +1 -0
- package/dist/host/host-stream.js +36 -0
- package/dist/host/host-stream.js.map +1 -0
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +3 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/terminal-host.d.ts +144 -0
- package/dist/host/terminal-host.d.ts.map +1 -0
- package/dist/host/terminal-host.js +133 -0
- package/dist/host/terminal-host.js.map +1 -0
- package/dist/index.d.ts +10 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -21
- package/dist/index.js.map +1 -1
- package/dist/node/terminal-host.d.ts +85 -0
- package/dist/node/terminal-host.d.ts.map +1 -0
- package/dist/node/terminal-host.js +161 -0
- package/dist/node/terminal-host.js.map +1 -0
- package/dist/node/traceback.d.ts +28 -0
- package/dist/node/traceback.d.ts.map +1 -0
- package/dist/node/traceback.js +113 -0
- package/dist/node/traceback.js.map +1 -0
- package/dist/renderables/columns.d.ts +24 -2
- package/dist/renderables/columns.d.ts.map +1 -1
- package/dist/renderables/columns.js +91 -32
- package/dist/renderables/columns.js.map +1 -1
- package/dist/renderables/layout.d.ts +61 -5
- package/dist/renderables/layout.d.ts.map +1 -1
- package/dist/renderables/layout.js +191 -19
- package/dist/renderables/layout.js.map +1 -1
- package/dist/renderables/padding.d.ts +15 -2
- package/dist/renderables/padding.d.ts.map +1 -1
- package/dist/renderables/padding.js +92 -37
- package/dist/renderables/padding.js.map +1 -1
- package/dist/renderables/panel.d.ts +44 -3
- package/dist/renderables/panel.d.ts.map +1 -1
- package/dist/renderables/panel.js +149 -80
- package/dist/renderables/panel.js.map +1 -1
- package/dist/renderables/table.d.ts +40 -4
- package/dist/renderables/table.d.ts.map +1 -1
- package/dist/renderables/table.js +276 -158
- package/dist/renderables/table.js.map +1 -1
- package/dist/renderables/traceback.d.ts +6 -2
- package/dist/renderables/traceback.d.ts.map +1 -1
- package/dist/renderables/traceback.js +6 -10
- package/dist/renderables/traceback.js.map +1 -1
- package/dist/renderables/tree.d.ts +27 -2
- package/dist/renderables/tree.d.ts.map +1 -1
- package/dist/renderables/tree.js +82 -23
- package/dist/renderables/tree.js.map +1 -1
- package/dist/template-bindings/color-funcs.d.ts +3 -3
- package/dist/template-bindings/color-funcs.js +3 -3
- package/dist/template-bindings/index.d.ts +6 -7
- package/dist/template-bindings/index.d.ts.map +1 -1
- package/dist/template-bindings/index.js +6 -7
- package/dist/template-bindings/index.js.map +1 -1
- package/dist/template-bindings/palette-funcs.d.ts +17 -5
- package/dist/template-bindings/palette-funcs.d.ts.map +1 -1
- package/dist/template-bindings/palette-funcs.js +69 -6
- package/dist/template-bindings/palette-funcs.js.map +1 -1
- package/dist/template-bindings/style-funcs.d.ts +1 -1
- package/dist/template-bindings/style-funcs.js +1 -1
- package/dist/themes/ramp.d.ts +84 -0
- package/dist/themes/ramp.d.ts.map +1 -0
- package/dist/themes/ramp.js +123 -0
- package/dist/themes/ramp.js.map +1 -0
- package/dist/widgets/dropdown.d.ts +1 -1
- package/dist/widgets/dropdown.js +1 -1
- package/dist/widgets/event-router.d.ts +3 -2
- package/dist/widgets/event-router.d.ts.map +1 -1
- package/dist/widgets/focus-manager.d.ts +2 -1
- package/dist/widgets/focus-manager.d.ts.map +1 -1
- package/dist/widgets/index.d.ts +3 -6
- package/dist/widgets/index.d.ts.map +1 -1
- package/dist/widgets/index.js +4 -3
- package/dist/widgets/index.js.map +1 -1
- package/dist/widgets/screen.d.ts +1 -1
- package/dist/widgets/screen.d.ts.map +1 -1
- package/dist/widgets/terminal-host.d.ts +13 -63
- package/dist/widgets/terminal-host.d.ts.map +1 -1
- package/dist/widgets/terminal-host.js +11 -142
- package/dist/widgets/terminal-host.js.map +1 -1
- package/dist/widgets/text-input.d.ts +2 -3
- package/dist/widgets/text-input.d.ts.map +1 -1
- package/dist/widgets/text-input.js +4 -12
- package/dist/widgets/text-input.js.map +1 -1
- package/dist/widgets/types.d.ts +1 -1
- package/dist/widgets/types.d.ts.map +1 -1
- package/dist/widgets/types.js.map +1 -1
- package/dist/widgets/widget-base.d.ts +2 -1
- package/dist/widgets/widget-base.d.ts.map +1 -1
- package/package.json +20 -4
package/dist/core/measure.js
CHANGED
|
@@ -11,9 +11,21 @@ export class Measurement {
|
|
|
11
11
|
get span() {
|
|
12
12
|
return this.maximum - this.minimum;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* A range with no cell meaning becomes one with the nearest meaning there is:
|
|
16
|
+
* negative floors to zero, an inverted pair collapses to its ceiling, and NaN
|
|
17
|
+
* reads as zero cells the same way `cellCount` reads it.
|
|
18
|
+
*
|
|
19
|
+
* NaN and Infinity are not treated alike here, and the difference is the whole
|
|
20
|
+
* point. `Infinity` is a maximum a renderable means — `Table` reports it when
|
|
21
|
+
* a column asks for every cell there is, and `withBoundedWidth` throws on it
|
|
22
|
+
* so a caller learns their offer was unanswerable. Flooring it to zero would
|
|
23
|
+
* turn that loud failure into a table measured at no width at all.
|
|
24
|
+
*/
|
|
14
25
|
normalize() {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
26
|
+
const cells = (n) => (Number.isNaN(n) ? 0 : n);
|
|
27
|
+
const min = Math.max(0, Math.min(cells(this.minimum), cells(this.maximum)));
|
|
28
|
+
const max = Math.max(0, cells(this.maximum));
|
|
17
29
|
return new Measurement(min, max);
|
|
18
30
|
}
|
|
19
31
|
withMaximum(width) {
|
|
@@ -32,7 +44,7 @@ export class Measurement {
|
|
|
32
44
|
if (options.maxWidth < 1)
|
|
33
45
|
return new Measurement(0, 0);
|
|
34
46
|
const { minimum, maximum } = measurable.measure(options);
|
|
35
|
-
return new Measurement(minimum, Math.min(maximum, options.maxWidth));
|
|
47
|
+
return new Measurement(minimum, Math.min(maximum, options.maxWidth)).normalize();
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
50
|
export function measureRenderables(options, measurables) {
|
package/dist/core/measure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure.js","sourceRoot":"","sources":["../../src/core/measure.ts"],"names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,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IACnF,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAsB,EACtB,WAAyB;IAEzB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAChD,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QACnD,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/core/oklch.d.ts
CHANGED
|
@@ -93,6 +93,28 @@ export declare class Oklch {
|
|
|
93
93
|
* `alpha === 1`. Callers invoke unconditionally; the data decides.
|
|
94
94
|
*/
|
|
95
95
|
applyKey(k: ThemeKey): Oklch;
|
|
96
|
+
/**
|
|
97
|
+
* The color `t` of the way from this one toward `toward`, in OKLCH.
|
|
98
|
+
* `t = 0` is this color, `t = 1` is `toward`; pure.
|
|
99
|
+
*
|
|
100
|
+
* Lightness, chroma and alpha interpolate linearly. Hue takes the shorter
|
|
101
|
+
* arc around the wheel, so blue → red passes through magenta rather than
|
|
102
|
+
* sweeping across green. An achromatic endpoint has no hue of its own —
|
|
103
|
+
* `fromRgba` pins it to 0, which is red — so it adopts the other
|
|
104
|
+
* endpoint's hue (CSS Color 4's "powerless" rule): gray → red stays a red
|
|
105
|
+
* that gains chroma, instead of rotating through the wheel from 0°.
|
|
106
|
+
*
|
|
107
|
+
* `t` must lie in [0, 1]: this is interpolation, not extrapolation, and a
|
|
108
|
+
* `t` outside it (NaN included) is a RangeError, never a colour off the
|
|
109
|
+
* far end of the segment. [LAW:no-silent-failure]
|
|
110
|
+
*
|
|
111
|
+
* [LAW:one-source-of-truth] Achromatic means the same `ACHROMATIC_EPS`
|
|
112
|
+
* that `fromRgba` and `applyKey` pin hue by, so a gray produced by either
|
|
113
|
+
* is a gray here — and the result's hue goes through the same `hueOf`, so
|
|
114
|
+
* a gray produced HERE (t = 0 from a gray, t = 1 toward one) is a gray
|
|
115
|
+
* there too.
|
|
116
|
+
*/
|
|
117
|
+
mix(toward: Oklch, t: number): Oklch;
|
|
96
118
|
/** Linear-sRGB coordinates for an explicit (l, C, h). Pure; `toRgba` passes
|
|
97
119
|
* already-normalized values so this never sees out-of-range inputs. */
|
|
98
120
|
private toLinearRgb;
|
package/dist/core/oklch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oklch.d.ts","sourceRoot":"","sources":["../../src/core/oklch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,wDAAwD;IACxD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,QAAQ,EAAE,QAKrB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAK7B,CAAC;AAEH;;;;;GA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AG,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK;IAwBpC;2EACuE;IACvE,OAAO,CAAC,WAAW;IAoBnB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;CAa1B"}
|
package/dist/core/oklch.js
CHANGED
|
@@ -67,11 +67,26 @@ function clamp01(v) {
|
|
|
67
67
|
// Small tolerance so float-fuzz at the gamut edge doesn't trigger needless
|
|
68
68
|
// chroma reduction on colors that are already representable.
|
|
69
69
|
const GAMUT_EPS = 1e-4;
|
|
70
|
-
// [LAW:one-source-of-truth] Below this chroma a color is
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// scaling collapses C toward 0). Same threshold both places.
|
|
70
|
+
// [LAW:one-source-of-truth] Below this chroma a color is achromatic and its
|
|
71
|
+
// hue is pinned to 0 so round-trips stay stable — the one threshold every
|
|
72
|
+
// chroma reader here shares.
|
|
74
73
|
const ACHROMATIC_EPS = 1e-7;
|
|
74
|
+
// The one spelling of that pin: every producer of an `Oklch` (`fromRgba`,
|
|
75
|
+
// `applyKey`, `mix`) passes its result's chroma and hue through here, so a
|
|
76
|
+
// gray from any of them carries the same hue. The constructor does not —
|
|
77
|
+
// it passes intermediates through by contract. [LAW:single-enforcer]
|
|
78
|
+
const hueOf = (c, h) => (c < ACHROMATIC_EPS ? 0 : h);
|
|
79
|
+
// Endpoint-exact: `t = 0` returns `a` and `t = 1` returns `b` bit-for-bit,
|
|
80
|
+
// which `a + (b - a) * t` does not (the subtraction rounds). One shape for
|
|
81
|
+
// every axis `mix` interpolates. [LAW:one-source-of-truth]
|
|
82
|
+
const lerp = (a, b, t) => a * (1 - t) + b * t;
|
|
83
|
+
// Hue into [0, 360). Exact on a hue already there (fmod is exact), and exact
|
|
84
|
+
// on `x - 360` for a representable x (the sum is x itself), which is what
|
|
85
|
+
// `mix` relies on. One spelling for every producer. [LAW:one-source-of-truth]
|
|
86
|
+
const wrapHue = (h) => {
|
|
87
|
+
const w = h % 360;
|
|
88
|
+
return w < 0 ? w + 360 : w;
|
|
89
|
+
};
|
|
75
90
|
function inGamut(r, g, b) {
|
|
76
91
|
return (r >= -GAMUT_EPS && r <= 1 + GAMUT_EPS &&
|
|
77
92
|
g >= -GAMUT_EPS && g <= 1 + GAMUT_EPS &&
|
|
@@ -128,12 +143,8 @@ export class Oklch {
|
|
|
128
143
|
const aLab = 1.9779984951 * lCube - 2.4285922050 * mCube + 0.4505937099 * sCube;
|
|
129
144
|
const bLab = 0.0259040371 * lCube + 0.7827717662 * mCube - 0.8086757660 * sCube;
|
|
130
145
|
const C = Math.sqrt(aLab * aLab + bLab * bLab);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
H += 360;
|
|
134
|
-
if (C < ACHROMATIC_EPS)
|
|
135
|
-
H = 0;
|
|
136
|
-
return new Oklch(L, C, H, a);
|
|
146
|
+
const H = wrapHue(Math.atan2(bLab, aLab) * (180 / Math.PI));
|
|
147
|
+
return new Oklch(L, C, hueOf(C, H), a);
|
|
137
148
|
}
|
|
138
149
|
/**
|
|
139
150
|
* Polar → OKLab → linear → sRGB (with chroma-bisection gamut clamping).
|
|
@@ -169,14 +180,47 @@ export class Oklch {
|
|
|
169
180
|
return this;
|
|
170
181
|
const newL = clamp01(this.l * k.lightnessScale + k.lightnessShift);
|
|
171
182
|
const newC = Math.max(0, this.c * k.chromaScale);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
const newH = wrapHue(this.h + k.hueShift);
|
|
184
|
+
return new Oklch(newL, newC, hueOf(newC, newH), this.alpha);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The color `t` of the way from this one toward `toward`, in OKLCH.
|
|
188
|
+
* `t = 0` is this color, `t = 1` is `toward`; pure.
|
|
189
|
+
*
|
|
190
|
+
* Lightness, chroma and alpha interpolate linearly. Hue takes the shorter
|
|
191
|
+
* arc around the wheel, so blue → red passes through magenta rather than
|
|
192
|
+
* sweeping across green. An achromatic endpoint has no hue of its own —
|
|
193
|
+
* `fromRgba` pins it to 0, which is red — so it adopts the other
|
|
194
|
+
* endpoint's hue (CSS Color 4's "powerless" rule): gray → red stays a red
|
|
195
|
+
* that gains chroma, instead of rotating through the wheel from 0°.
|
|
196
|
+
*
|
|
197
|
+
* `t` must lie in [0, 1]: this is interpolation, not extrapolation, and a
|
|
198
|
+
* `t` outside it (NaN included) is a RangeError, never a colour off the
|
|
199
|
+
* far end of the segment. [LAW:no-silent-failure]
|
|
200
|
+
*
|
|
201
|
+
* [LAW:one-source-of-truth] Achromatic means the same `ACHROMATIC_EPS`
|
|
202
|
+
* that `fromRgba` and `applyKey` pin hue by, so a gray produced by either
|
|
203
|
+
* is a gray here — and the result's hue goes through the same `hueOf`, so
|
|
204
|
+
* a gray produced HERE (t = 0 from a gray, t = 1 toward one) is a gray
|
|
205
|
+
* there too.
|
|
206
|
+
*/
|
|
207
|
+
mix(toward, t) {
|
|
208
|
+
if (!(t >= 0 && t <= 1)) {
|
|
209
|
+
throw new RangeError(`Oklch.mix: t must be in [0, 1]; got ${t}`);
|
|
210
|
+
}
|
|
211
|
+
const thisHasHue = this.c >= ACHROMATIC_EPS;
|
|
212
|
+
const towardHasHue = toward.c >= ACHROMATIC_EPS;
|
|
213
|
+
const fromH = wrapHue(thisHasHue ? this.h : towardHasHue ? toward.h : 0);
|
|
214
|
+
const toH = wrapHue(towardHasHue ? toward.h : fromH);
|
|
215
|
+
// Shorter arc: endpoints more than half a turn apart lerp across 0°, the
|
|
216
|
+
// larger one taken a turn down. `x - 360` for x ≥ 180 is exact
|
|
217
|
+
// (Sterbenz), so the endpoints survive the shift and the wrap bit-for-bit
|
|
218
|
+
// — an addition of 360 would not.
|
|
219
|
+
const arc = toH - fromH;
|
|
220
|
+
const fromU = arc < -180 ? fromH - 360 : fromH;
|
|
221
|
+
const toU = arc > 180 ? toH - 360 : toH;
|
|
222
|
+
const c = lerp(this.c, toward.c, t);
|
|
223
|
+
return new Oklch(lerp(this.l, toward.l, t), c, hueOf(c, wrapHue(lerp(fromU, toU, t))), lerp(this.alpha, toward.alpha, t));
|
|
180
224
|
}
|
|
181
225
|
/** Linear-sRGB coordinates for an explicit (l, C, h). Pure; `toRgba` passes
|
|
182
226
|
* already-normalized values so this never sees out-of-range inputs. */
|
package/dist/core/oklch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oklch.js","sourceRoot":"","sources":["../../src/core/oklch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA2BvC,MAAM,CAAC,MAAM,QAAQ,GAAa,MAAM,CAAC,MAAM,CAAC;IAC9C,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;IACd,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa,MAAM,CAAC,MAAM,CAAC;IACtD,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;IACd,cAAc,EAAE,CAAC,CAAC;IAClB,cAAc,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,CAAW;IACvC,OAAO,CACL,CAAC,CAAC,QAAQ,GAAG,GAAG,KAAK,CAAC,IAAI,4CAA4C;QACtE,CAAC,CAAC,WAAW,KAAK,CAAC;QACnB,CAAC,CAAC,cAAc,KAAK,CAAC;QACtB,CAAC,CAAC,cAAc,KAAK,CAAC,CACvB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,SAAS,YAAY,CAAC,CAAS;IAC7B,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CA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E,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YAC1C,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;gBAAE,EAAE,GAAG,GAAG,CAAC;;gBAC5C,EAAE,GAAG,GAAG,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pretty — formats JavaScript data structures with highlighting.
|
|
3
|
+
*
|
|
4
|
+
* Lives in `core/` beside `markup` and `emoji` because it does their job: turn
|
|
5
|
+
* foreign input into `RichText`. It composes no other renderable — the trait
|
|
6
|
+
* every file in `renderables/` shares and this one does not — and its imports
|
|
7
|
+
* are core primitives only. `Console.print` accepts `unknown` and must turn any
|
|
8
|
+
* of it into something renderable, so the formatter has to sit where `console`
|
|
9
|
+
* can reach it without an upward edge. [LAW:one-way-deps]
|
|
10
|
+
*/
|
|
11
|
+
import { Segment } from "./segment.js";
|
|
12
|
+
import type { Highlighter } from "./highlighter.js";
|
|
13
|
+
import type { Renderable, Measurable, RenderOptions } from "./protocol.js";
|
|
14
|
+
export interface PrettyOptions {
|
|
15
|
+
indent?: number;
|
|
16
|
+
expandAll?: boolean;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
maxString?: number;
|
|
19
|
+
/**
|
|
20
|
+
* How many levels of nesting to descend before eliding. Unbounded by default.
|
|
21
|
+
*
|
|
22
|
+
* `Console.print` supplies a bound because it formats whatever it is handed;
|
|
23
|
+
* a caller constructing a `Pretty` has seen their data and can say what they
|
|
24
|
+
* want. Past the cap a container renders as `[...]`, `{...}`, `Map {...}` or
|
|
25
|
+
* `Set {...}` — visible, so the reader knows the value continues.
|
|
26
|
+
*/
|
|
27
|
+
maxDepth?: number;
|
|
28
|
+
indentGuides?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Who colours the formatted text. Defaults to a `ReprHighlighter`.
|
|
31
|
+
*
|
|
32
|
+
* Passed rather than imported so a caller's choice survives. `Console.print`
|
|
33
|
+
* routes data arguments through here, and its `highlight` flag and custom
|
|
34
|
+
* `highlighter` have to reach the output the same way they reach a printed
|
|
35
|
+
* string — a `Pretty` reaching for its own singleton would silently outrank
|
|
36
|
+
* both. `NullHighlighter` is the "none" case.
|
|
37
|
+
*/
|
|
38
|
+
highlighter?: Highlighter;
|
|
39
|
+
}
|
|
40
|
+
export declare class Pretty implements Renderable, Measurable {
|
|
41
|
+
readonly data: unknown;
|
|
42
|
+
readonly indent: number;
|
|
43
|
+
readonly expandAll: boolean;
|
|
44
|
+
readonly maxLength: number | undefined;
|
|
45
|
+
readonly maxString: number | undefined;
|
|
46
|
+
readonly maxDepth: number;
|
|
47
|
+
readonly indentGuides: boolean;
|
|
48
|
+
readonly highlighter: Highlighter;
|
|
49
|
+
constructor(data: unknown, options?: PrettyOptions);
|
|
50
|
+
render(options: RenderOptions): Iterable<Segment>;
|
|
51
|
+
measure(_options: RenderOptions): {
|
|
52
|
+
minimum: number;
|
|
53
|
+
maximum: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Where the traversal is, in the two senses that differ.
|
|
57
|
+
*
|
|
58
|
+
* `inset` is how far the output is indented; it resets to 0 whenever a value
|
|
59
|
+
* is measured for a single line, because a compact form carries no
|
|
60
|
+
* indentation. `level` is how deep in the data we are, and only ever
|
|
61
|
+
* increases. Collapsing the two into one number is the mistake this pair
|
|
62
|
+
* exists to make unrepresentable: the depth cap read the layout number, so
|
|
63
|
+
* every compact probe reset it and the cap never fired at all.
|
|
64
|
+
*
|
|
65
|
+
* `open` holds the objects between the root and here, not every object seen.
|
|
66
|
+
* A value joins on the way down and leaves on the way back up, so a cycle is
|
|
67
|
+
* caught while a DAG — one object reached twice through sibling positions —
|
|
68
|
+
* still renders both times. A never-emptied set would call the second sibling
|
|
69
|
+
* circular. [LAW:no-ambient-temporal-coupling] the traversal owns its state
|
|
70
|
+
* explicitly; a field on the instance would leak between renders.
|
|
71
|
+
*/
|
|
72
|
+
private _format;
|
|
73
|
+
/**
|
|
74
|
+
* One position's value, or the marker for why reading it failed.
|
|
75
|
+
*
|
|
76
|
+
* A key and an index are the same job — read one slot of a container someone
|
|
77
|
+
* else built — so they share one method rather than two that must agree.
|
|
78
|
+
* [LAW:one-type-per-behavior] This is also the read that costs the least when
|
|
79
|
+
* it fails: neighbours are unaffected, so `{ a: 1, b: [Threw: …], c: 3 }`
|
|
80
|
+
* still shows everything that could be read.
|
|
81
|
+
*/
|
|
82
|
+
private _at;
|
|
83
|
+
/** The arms for a non-null object, with `value` already on the open path. */
|
|
84
|
+
private _formatObject;
|
|
85
|
+
private _addIndentGuides;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=pretty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty.d.ts","sourceRoot":"","sources":["../../src/core/pretty.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AA6FD,qBAAa,MAAO,YAAW,UAAU,EAAE,UAAU;IACnD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;gBAEtB,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa;IAWjD,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC;IAYlD,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAUtE;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,OAAO;IAqCf;;;;;;;;OAQG;IACH,OAAO,CAAC,GAAG;IAQX,6EAA6E;IAC7E,OAAO,CAAC,aAAa;IAoFrB,OAAO,CAAC,gBAAgB;CAczB"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pretty — formats JavaScript data structures with highlighting.
|
|
3
|
+
*
|
|
4
|
+
* Lives in `core/` beside `markup` and `emoji` because it does their job: turn
|
|
5
|
+
* foreign input into `RichText`. It composes no other renderable — the trait
|
|
6
|
+
* every file in `renderables/` shares and this one does not — and its imports
|
|
7
|
+
* are core primitives only. `Console.print` accepts `unknown` and must turn any
|
|
8
|
+
* of it into something renderable, so the formatter has to sit where `console`
|
|
9
|
+
* can reach it without an upward edge. [LAW:one-way-deps]
|
|
10
|
+
*/
|
|
11
|
+
import { cellLen } from "./cells.js";
|
|
12
|
+
import { Style } from "./style.js";
|
|
13
|
+
import { RichText } from "./text.js";
|
|
14
|
+
import { ReprHighlighter } from "./highlighter.js";
|
|
15
|
+
const reprHighlighter = new ReprHighlighter();
|
|
16
|
+
const rootFrame = (maxWidth) => ({ inset: 0, level: 0, maxWidth, open: new WeakSet() });
|
|
17
|
+
/**
|
|
18
|
+
* The elements of an indexed sequence, or `null` for anything that isn't one.
|
|
19
|
+
*
|
|
20
|
+
* A typed array is an array with a fixed element type, and neither of the two
|
|
21
|
+
* questions asked elsewhere in this file recognises it: `Array.isArray` says
|
|
22
|
+
* false, and its own `toString` answers the bare `1,2,3` — no brackets, nothing
|
|
23
|
+
* for the highlighter to colour per element. Both spellings reach the one arm
|
|
24
|
+
* that knows what a sequence looks like. `DataView` is excluded because it is a
|
|
25
|
+
* window onto bytes, not a sequence of values.
|
|
26
|
+
*
|
|
27
|
+
* Returned as `ArrayLike` rather than a materialised array because both
|
|
28
|
+
* spellings already are one. Converting here would box every element of a
|
|
29
|
+
* multi-megabyte `Buffer` to keep the first `maxLength` of them — bounding the
|
|
30
|
+
* output while leaving the cost of producing it unbounded.
|
|
31
|
+
*/
|
|
32
|
+
function indexedElements(value) {
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
return value;
|
|
35
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The first `limit` items of a sequence, pulled and no more.
|
|
42
|
+
*
|
|
43
|
+
* A `Map` or `Set` reaches its size through `.size`, which iterates nothing, so
|
|
44
|
+
* spreading one only ever served to throw the tail away — `print` of a
|
|
45
|
+
* half-million-entry cache walked all of it to show a hundred. `Infinity` is
|
|
46
|
+
* the unbounded case and never breaks.
|
|
47
|
+
*/
|
|
48
|
+
function take(source, limit) {
|
|
49
|
+
const taken = [];
|
|
50
|
+
if (limit <= 0)
|
|
51
|
+
return taken;
|
|
52
|
+
for (const item of source) {
|
|
53
|
+
taken.push(item);
|
|
54
|
+
if (taken.length >= limit)
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return taken;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* What a value renders as when reading it threw instead of producing it.
|
|
61
|
+
*
|
|
62
|
+
* `Pretty` reflects on data it did not create, and every reflection it performs
|
|
63
|
+
* — a property getter, `Object.keys`, an iterator, `toString` — can throw. The
|
|
64
|
+
* message travels into the output, so the failure stays visible and attributed
|
|
65
|
+
* to the position that produced it. [LAW:no-silent-failure] the error is
|
|
66
|
+
* carried rather than swallowed; a marker naming its cause is not an
|
|
67
|
+
* answer-shaped void, and a diagnostic that takes the program down over one
|
|
68
|
+
* lazily-computed field is unusable on the objects it is most wanted for.
|
|
69
|
+
*/
|
|
70
|
+
function threw(error) {
|
|
71
|
+
return `[Threw: ${error instanceof Error ? error.message : String(error)}]`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Does this value carry its own string form, or must we reflect on its keys?
|
|
75
|
+
*
|
|
76
|
+
* A `Date`, an `Error`, a `RegExp`, or any object that defines `toString`
|
|
77
|
+
* answers the display question itself, and reflecting on such a value throws
|
|
78
|
+
* that answer away — `Object.keys(new Date())` is empty, so key-reflection
|
|
79
|
+
* renders it `{}`. Inheriting `Object.prototype.toString` is the opposite
|
|
80
|
+
* signal: it yields `[object Object]`, a non-answer, so the keys are all the
|
|
81
|
+
* information there is.
|
|
82
|
+
*
|
|
83
|
+
* Both clauses are load-bearing. The identity check separates the two
|
|
84
|
+
* populations; the `typeof` check is what makes `Object.create(null)` — which
|
|
85
|
+
* has no `toString` at all — reflect rather than throw.
|
|
86
|
+
*/
|
|
87
|
+
function describesItself(value) {
|
|
88
|
+
const asRecord = value;
|
|
89
|
+
return (typeof asRecord[Symbol.toPrimitive] === "function" ||
|
|
90
|
+
(typeof asRecord.toString === "function" &&
|
|
91
|
+
asRecord.toString !== Object.prototype.toString));
|
|
92
|
+
}
|
|
93
|
+
export class Pretty {
|
|
94
|
+
data;
|
|
95
|
+
indent;
|
|
96
|
+
expandAll;
|
|
97
|
+
maxLength;
|
|
98
|
+
maxString;
|
|
99
|
+
maxDepth;
|
|
100
|
+
indentGuides;
|
|
101
|
+
highlighter;
|
|
102
|
+
constructor(data, options) {
|
|
103
|
+
this.data = data;
|
|
104
|
+
this.indent = options?.indent ?? 4;
|
|
105
|
+
this.expandAll = options?.expandAll ?? false;
|
|
106
|
+
this.maxLength = options?.maxLength;
|
|
107
|
+
this.maxString = options?.maxString;
|
|
108
|
+
this.maxDepth = options?.maxDepth ?? Infinity;
|
|
109
|
+
this.indentGuides = options?.indentGuides !== false;
|
|
110
|
+
this.highlighter = options?.highlighter ?? reprHighlighter;
|
|
111
|
+
}
|
|
112
|
+
*render(options) {
|
|
113
|
+
const formatted = this._format(this.data, rootFrame(options.maxWidth));
|
|
114
|
+
const text = new RichText(formatted, { end: "" });
|
|
115
|
+
this.highlighter.highlight(text);
|
|
116
|
+
if (this.indentGuides) {
|
|
117
|
+
this._addIndentGuides(text);
|
|
118
|
+
}
|
|
119
|
+
yield* text.render(options);
|
|
120
|
+
}
|
|
121
|
+
measure(_options) {
|
|
122
|
+
const formatted = this._format(this.data, rootFrame(_options.maxWidth));
|
|
123
|
+
const lines = formatted.split("\n");
|
|
124
|
+
let max = 0;
|
|
125
|
+
for (const line of lines) {
|
|
126
|
+
max = Math.max(max, cellLen(line));
|
|
127
|
+
}
|
|
128
|
+
return { minimum: 1, maximum: Math.min(max, _options.maxWidth) };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Where the traversal is, in the two senses that differ.
|
|
132
|
+
*
|
|
133
|
+
* `inset` is how far the output is indented; it resets to 0 whenever a value
|
|
134
|
+
* is measured for a single line, because a compact form carries no
|
|
135
|
+
* indentation. `level` is how deep in the data we are, and only ever
|
|
136
|
+
* increases. Collapsing the two into one number is the mistake this pair
|
|
137
|
+
* exists to make unrepresentable: the depth cap read the layout number, so
|
|
138
|
+
* every compact probe reset it and the cap never fired at all.
|
|
139
|
+
*
|
|
140
|
+
* `open` holds the objects between the root and here, not every object seen.
|
|
141
|
+
* A value joins on the way down and leaves on the way back up, so a cycle is
|
|
142
|
+
* caught while a DAG — one object reached twice through sibling positions —
|
|
143
|
+
* still renders both times. A never-emptied set would call the second sibling
|
|
144
|
+
* circular. [LAW:no-ambient-temporal-coupling] the traversal owns its state
|
|
145
|
+
* explicitly; a field on the instance would leak between renders.
|
|
146
|
+
*/
|
|
147
|
+
_format(value, at) {
|
|
148
|
+
if (value === null)
|
|
149
|
+
return "null";
|
|
150
|
+
if (value === undefined)
|
|
151
|
+
return "undefined";
|
|
152
|
+
switch (typeof value) {
|
|
153
|
+
case "string": {
|
|
154
|
+
let str = value;
|
|
155
|
+
if (this.maxString !== undefined && str.length > this.maxString) {
|
|
156
|
+
str = str.slice(0, this.maxString) + `+${value.length - this.maxString}`;
|
|
157
|
+
}
|
|
158
|
+
return JSON.stringify(str);
|
|
159
|
+
}
|
|
160
|
+
case "number":
|
|
161
|
+
case "bigint":
|
|
162
|
+
return String(value);
|
|
163
|
+
case "boolean":
|
|
164
|
+
return String(value);
|
|
165
|
+
case "symbol":
|
|
166
|
+
return value.toString();
|
|
167
|
+
case "function":
|
|
168
|
+
return `[Function: ${value.name || "anonymous"}]`;
|
|
169
|
+
}
|
|
170
|
+
if (at.open.has(value))
|
|
171
|
+
return "[Circular]";
|
|
172
|
+
at.open.add(value);
|
|
173
|
+
try {
|
|
174
|
+
return this._formatObject(value, at);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
// The container's *shape* would not be read — `Object.keys`, an iterator,
|
|
178
|
+
// `toString`. Nothing can be enumerated, so the whole container degrades;
|
|
179
|
+
// a value that merely would not be read degrades alone, in `_at`.
|
|
180
|
+
return threw(error);
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
at.open.delete(value);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* One position's value, or the marker for why reading it failed.
|
|
188
|
+
*
|
|
189
|
+
* A key and an index are the same job — read one slot of a container someone
|
|
190
|
+
* else built — so they share one method rather than two that must agree.
|
|
191
|
+
* [LAW:one-type-per-behavior] This is also the read that costs the least when
|
|
192
|
+
* it fails: neighbours are unaffected, so `{ a: 1, b: [Threw: …], c: 3 }`
|
|
193
|
+
* still shows everything that could be read.
|
|
194
|
+
*/
|
|
195
|
+
_at(container, key, at) {
|
|
196
|
+
try {
|
|
197
|
+
return this._format(container[key], at);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
return threw(error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** The arms for a non-null object, with `value` already on the open path. */
|
|
204
|
+
_formatObject(value, at) {
|
|
205
|
+
const { maxWidth, open } = at;
|
|
206
|
+
const indentStr = " ".repeat(this.indent * at.inset);
|
|
207
|
+
const innerIndent = " ".repeat(this.indent * (at.inset + 1));
|
|
208
|
+
const deeper = { inset: at.inset + 1, level: at.level + 1, maxWidth, open };
|
|
209
|
+
const onOneLine = { inset: 0, level: at.level + 1, maxWidth, open };
|
|
210
|
+
const elements = indexedElements(value);
|
|
211
|
+
if (elements !== null) {
|
|
212
|
+
if (elements.length === 0)
|
|
213
|
+
return "[]";
|
|
214
|
+
if (at.level >= this.maxDepth)
|
|
215
|
+
return "[...]";
|
|
216
|
+
// Positions rather than values: each index is read through `_at`, so one
|
|
217
|
+
// throwing accessor costs its own slot instead of the whole sequence.
|
|
218
|
+
const shown = Math.min(elements.length, this.maxLength ?? elements.length);
|
|
219
|
+
const positions = Array.from({ length: shown }, (_, i) => i);
|
|
220
|
+
const remaining = elements.length - shown;
|
|
221
|
+
// Try compact first
|
|
222
|
+
if (!this.expandAll) {
|
|
223
|
+
const pieces = positions.map((i) => this._at(elements, i, onOneLine));
|
|
224
|
+
if (remaining > 0)
|
|
225
|
+
pieces.push(`... +${remaining}`);
|
|
226
|
+
const compact = "[" + pieces.join(", ") + "]";
|
|
227
|
+
if (cellLen(indentStr + compact) <= maxWidth)
|
|
228
|
+
return compact;
|
|
229
|
+
}
|
|
230
|
+
const parts = positions.map((i) => innerIndent + this._at(elements, i, deeper));
|
|
231
|
+
if (remaining > 0)
|
|
232
|
+
parts.push(innerIndent + `... +${remaining}`);
|
|
233
|
+
return "[\n" + parts.join(",\n") + "\n" + indentStr + "]";
|
|
234
|
+
}
|
|
235
|
+
if (value instanceof Map) {
|
|
236
|
+
if (value.size === 0)
|
|
237
|
+
return "Map {}";
|
|
238
|
+
if (at.level >= this.maxDepth)
|
|
239
|
+
return "Map {...}";
|
|
240
|
+
const items = take(value.entries(), this.maxLength ?? Infinity);
|
|
241
|
+
const parts = items.map(([k, v]) => innerIndent + this._format(k, deeper) + " => " + this._format(v, deeper));
|
|
242
|
+
const dropped = value.size - items.length;
|
|
243
|
+
if (dropped > 0)
|
|
244
|
+
parts.push(innerIndent + `... +${dropped}`);
|
|
245
|
+
return "Map {\n" + parts.join(",\n") + "\n" + indentStr + "}";
|
|
246
|
+
}
|
|
247
|
+
if (value instanceof Set) {
|
|
248
|
+
if (value.size === 0)
|
|
249
|
+
return "Set {}";
|
|
250
|
+
if (at.level >= this.maxDepth)
|
|
251
|
+
return "Set {...}";
|
|
252
|
+
const items = take(value, this.maxLength ?? Infinity);
|
|
253
|
+
const parts = items.map((v) => innerIndent + this._format(v, deeper));
|
|
254
|
+
const dropped = value.size - items.length;
|
|
255
|
+
if (dropped > 0)
|
|
256
|
+
parts.push(innerIndent + `... +${dropped}`);
|
|
257
|
+
return "Set {\n" + parts.join(",\n") + "\n" + indentStr + "}";
|
|
258
|
+
}
|
|
259
|
+
// Objects that answer the display question themselves. Sits below the
|
|
260
|
+
// Array/Map/Set arms deliberately: an array also overrides `toString`, but
|
|
261
|
+
// "1,2,3" is a poorer answer than the structural form above.
|
|
262
|
+
if (describesItself(value))
|
|
263
|
+
return String(value);
|
|
264
|
+
// Plain objects — no self-description, so the keys are the whole story.
|
|
265
|
+
{
|
|
266
|
+
const obj = value;
|
|
267
|
+
const keys = Object.keys(obj);
|
|
268
|
+
if (keys.length === 0)
|
|
269
|
+
return "{}";
|
|
270
|
+
if (at.level >= this.maxDepth)
|
|
271
|
+
return "{...}";
|
|
272
|
+
const items = this.maxLength !== undefined ? keys.slice(0, this.maxLength) : keys;
|
|
273
|
+
const remaining = this.maxLength !== undefined ? Math.max(0, keys.length - this.maxLength) : 0;
|
|
274
|
+
// Try compact
|
|
275
|
+
if (!this.expandAll) {
|
|
276
|
+
const pieces = items.map((k) => `${k}: ${this._at(obj, k, onOneLine)}`);
|
|
277
|
+
if (remaining > 0)
|
|
278
|
+
pieces.push(`... +${remaining}`);
|
|
279
|
+
const compact = "{ " + pieces.join(", ") + " }";
|
|
280
|
+
if (cellLen(indentStr + compact) <= maxWidth)
|
|
281
|
+
return compact;
|
|
282
|
+
}
|
|
283
|
+
const parts = items.map((k) => innerIndent + `${k}: ${this._at(obj, k, deeper)}`);
|
|
284
|
+
if (remaining > 0)
|
|
285
|
+
parts.push(innerIndent + `... +${remaining}`);
|
|
286
|
+
return "{\n" + parts.join(",\n") + "\n" + indentStr + "}";
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
_addIndentGuides(text) {
|
|
290
|
+
const guideStyle = Style.parse("repr.indent");
|
|
291
|
+
const lines = text.plain.split("\n");
|
|
292
|
+
let offset = 0;
|
|
293
|
+
for (const line of lines) {
|
|
294
|
+
const leadingSpaces = line.length - line.trimStart().length;
|
|
295
|
+
for (let i = 0; i < leadingSpaces; i += this.indent) {
|
|
296
|
+
if (i + offset < text.length) {
|
|
297
|
+
text.stylize(guideStyle, offset + i, offset + i + 1);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
offset += line.length + 1; // +1 for newline
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|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