@promptctl/rich-js 0.23.0 → 0.24.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 (117) hide show
  1. package/THIRD-PARTY-NOTICES +29 -1
  2. package/dist/core/animation.d.ts +78 -0
  3. package/dist/core/animation.js +107 -0
  4. package/dist/core/cell-widths.d.ts +9 -0
  5. package/dist/core/cell-widths.js +140 -0
  6. package/dist/core/cells.d.ts +17 -11
  7. package/dist/core/cells.js +100 -25
  8. package/dist/core/clock.d.ts +9 -1
  9. package/dist/core/clock.js +22 -2
  10. package/dist/core/color.d.ts +10 -0
  11. package/dist/core/color.js +36 -1
  12. package/dist/core/console.js +5 -5
  13. package/dist/core/easing.d.ts +138 -7
  14. package/dist/core/easing.js +355 -17
  15. package/dist/core/json.js +2 -1
  16. package/dist/core/measure.js +2 -2
  17. package/dist/core/place.js +2 -1
  18. package/dist/core/pretty.js +2 -2
  19. package/dist/core/protocol.d.ts +73 -19
  20. package/dist/core/protocol.js +56 -15
  21. package/dist/core/render.js +2 -1
  22. package/dist/core/segment.d.ts +28 -1
  23. package/dist/core/segment.js +60 -44
  24. package/dist/core/strip.d.ts +107 -29
  25. package/dist/core/strip.js +242 -131
  26. package/dist/core/style.d.ts +18 -1
  27. package/dist/core/style.js +49 -9
  28. package/dist/core/text.js +26 -15
  29. package/dist/core/timeline.d.ts +84 -0
  30. package/dist/core/timeline.js +144 -0
  31. package/dist/core/tween.d.ts +49 -0
  32. package/dist/core/tween.js +69 -0
  33. package/dist/host/app.js +4 -6
  34. package/dist/host/index.d.ts +1 -1
  35. package/dist/host/input.d.ts +37 -13
  36. package/dist/host/input.js +146 -56
  37. package/dist/host/terminal-host.d.ts +16 -0
  38. package/dist/host/terminal-host.js +1 -0
  39. package/dist/index.d.ts +16 -11
  40. package/dist/index.js +15 -5
  41. package/dist/node/terminal-host.d.ts +8 -1
  42. package/dist/node/terminal-host.js +2 -0
  43. package/dist/renderables/align.d.ts +3 -2
  44. package/dist/renderables/align.js +3 -0
  45. package/dist/renderables/columns.d.ts +3 -2
  46. package/dist/renderables/columns.js +7 -2
  47. package/dist/renderables/constrain.d.ts +3 -2
  48. package/dist/renderables/constrain.js +5 -1
  49. package/dist/renderables/effect.d.ts +83 -30
  50. package/dist/renderables/effect.js +155 -57
  51. package/dist/renderables/effects.d.ts +88 -39
  52. package/dist/renderables/effects.js +444 -105
  53. package/dist/renderables/embed.d.ts +10 -0
  54. package/dist/renderables/embed.js +18 -9
  55. package/dist/renderables/flexStrip.d.ts +3 -2
  56. package/dist/renderables/flexStrip.js +6 -1
  57. package/dist/renderables/frames.d.ts +116 -0
  58. package/dist/renderables/frames.js +133 -0
  59. package/dist/renderables/group.d.ts +3 -2
  60. package/dist/renderables/group.js +5 -2
  61. package/dist/renderables/html-entities.d.ts +8 -0
  62. package/dist/renderables/html-entities.js +386 -0
  63. package/dist/renderables/layout.d.ts +3 -2
  64. package/dist/renderables/layout.js +15 -2
  65. package/dist/renderables/list-view.d.ts +3 -2
  66. package/dist/renderables/list-view.js +12 -5
  67. package/dist/renderables/live.d.ts +23 -7
  68. package/dist/renderables/live.js +69 -35
  69. package/dist/renderables/markdown-parse.d.ts +109 -0
  70. package/dist/renderables/markdown-parse.js +1421 -0
  71. package/dist/renderables/markdown-url.d.ts +19 -0
  72. package/dist/renderables/markdown-url.js +314 -0
  73. package/dist/renderables/markdown.d.ts +7 -6
  74. package/dist/renderables/markdown.js +363 -499
  75. package/dist/renderables/padding.d.ts +8 -20
  76. package/dist/renderables/padding.js +32 -50
  77. package/dist/renderables/panel.d.ts +26 -26
  78. package/dist/renderables/panel.js +67 -103
  79. package/dist/renderables/progress.d.ts +5 -3
  80. package/dist/renderables/progress.js +14 -3
  81. package/dist/renderables/progressBar.js +4 -4
  82. package/dist/renderables/python-space.d.ts +13 -0
  83. package/dist/renderables/python-space.js +24 -0
  84. package/dist/renderables/spinner.d.ts +73 -27
  85. package/dist/renderables/spinner.js +110 -51
  86. package/dist/renderables/status.d.ts +8 -3
  87. package/dist/renderables/status.js +8 -5
  88. package/dist/renderables/syntax.js +2 -1
  89. package/dist/renderables/table.d.ts +19 -11
  90. package/dist/renderables/table.js +140 -156
  91. package/dist/renderables/traceback.d.ts +1 -1
  92. package/dist/renderables/traceback.js +6 -5
  93. package/dist/renderables/tree.d.ts +6 -5
  94. package/dist/renderables/tree.js +11 -7
  95. package/dist/renderables/viewport.d.ts +13 -5
  96. package/dist/renderables/viewport.js +41 -20
  97. package/dist/template-bindings/animation-funcs.d.ts +37 -0
  98. package/dist/template-bindings/animation-funcs.js +83 -0
  99. package/dist/template-bindings/color-funcs.d.ts +13 -0
  100. package/dist/template-bindings/color-funcs.js +1 -1
  101. package/dist/template-bindings/helpers.d.ts +6 -0
  102. package/dist/template-bindings/helpers.js +12 -3
  103. package/dist/template-bindings/index.d.ts +6 -2
  104. package/dist/template-bindings/index.js +8 -3
  105. package/dist/themes/ramp.d.ts +18 -3
  106. package/dist/themes/ramp.js +23 -2
  107. package/dist/widgets/focus-manager.d.ts +21 -14
  108. package/dist/widgets/focus-manager.js +28 -29
  109. package/dist/widgets/index.d.ts +1 -1
  110. package/dist/widgets/static-item.d.ts +4 -3
  111. package/dist/widgets/static-item.js +9 -7
  112. package/dist/widgets/text-input.d.ts +28 -18
  113. package/dist/widgets/text-input.js +144 -101
  114. package/dist/widgets/widget-app.d.ts +19 -3
  115. package/dist/widgets/widget-app.js +39 -21
  116. package/dist/widgets/widget-base.js +0 -3
  117. package/package.json +2 -5
@@ -10,7 +10,11 @@
10
10
  * a slow glow, sunlight moving on water, the colours of daylight, fireflies, ink
11
11
  * blooming in water, mist lifting — because a motion the eye recognises
12
12
  * reads as calm and alive, where a motion it has to learn reads as a widget.
13
- * What makes those motions familiar is what every curve here keeps:
13
+ * One effect here is not ambience but a signal, and keeps none of this on
14
+ * purpose: `steppedInk` steps its ink through colours on a beat, the news
15
+ * that something is at its limit, and jumps from slot to slot where the
16
+ * loops hold still. What makes the loops' motions familiar is what every
17
+ * curve of theirs keeps:
14
18
  *
15
19
  * - Nothing jumps. Every curve is continuous in time, built from smooth
16
20
  * noise (`core/noise.ts`) and smooth waveforms, so at one frame a second a cell
@@ -43,16 +47,17 @@
43
47
  * (`examples/effects-playground/programs.ts`), on the published library.
44
48
  */
45
49
  import { ColorRgba } from "../core/color.js";
46
- import { type Ease } from "../core/easing.js";
50
+ import { type Timing } from "../core/easing.js";
47
51
  import { type Drawn, type Effect, type EffectCell } from "./effect.js";
48
52
  /** What a loop does to one colour at strength `w` in [0, 1]: at 0, nothing. */
49
53
  export type Touch = (color: ColorRgba, w: number) => ColorRgba;
50
54
  /**
51
- * How strongly a loop acts at a moment `t` on each cell, in [0, 1]; `onColors`
52
- * holds a field outside it to it. Staged as `Effect` is: what holds for the
53
- * whole moment is worked out once, then every cell is asked.
55
+ * How strongly a loop acts at a moment `t` on each cell of a frame drawing
56
+ * what `Drawn` says, in [0, 1]; `onColors` holds a field outside it to it.
57
+ * Staged as `Effect` is: what holds for the whole moment is worked out once,
58
+ * then every cell is asked.
54
59
  */
55
- export type Field = (t: number) => (cell: EffectCell) => number;
60
+ export type Field = (t: number, drawn: Drawn) => (cell: EffectCell) => number;
56
61
  /** A looping effect: what it does to a colour, and where and when, how strongly. */
57
62
  export interface Loop {
58
63
  readonly touch: Touch;
@@ -79,9 +84,10 @@ export declare function shares({ pairs, depth, theme }: Drawn, colors: ReadonlyS
79
84
  * A loop as an `Effect` on the element's own colours, by hex, wherever a cell
80
85
  * shows them, each touched at its share of the cell's strength: the share
81
86
  * `shares` settles for it against the pairs the element draws its words in
82
- * (`Drawn`), touched as `Effected` writes them at the frame's depth — below
83
- * truecolor a touched colour lands on a colour the slot can write, and the
84
- * contrast it spends is that colour's. `colors` are the ones lit, by default every colour the element
87
+ * (`Drawn`), touched as `Effected` writes them at the frame's depth — at 256
88
+ * colours a touched colour lands on a colour the slot can write, and the
89
+ * contrast it spends is that colour's; on a sixteen-colour terminal nothing
90
+ * moves (`stillOnSlots`). `colors` are the ones lit, by default every colour the element
85
91
  * sets itself. A powerline strip's fill is the ground of its cells and the
86
92
  * ink of the seam glyphs between them, so the arrow moves with the cell it
87
93
  * points out of. A colour the terminal supplies (`EffectCell.terminal`) is
@@ -98,12 +104,14 @@ export declare function onColors(loop: Loop, colors?: ReadonlySet<string>): Effe
98
104
  * says; a colour it gives none, and one the terminal supplies, stays as it is.
99
105
  */
100
106
  export declare function atShares(loop: Loop, share: (drawn: Drawn) => ReadonlyMap<string, number>): Effect;
101
- /** How the curves below are tuned: one period (or duration), ease and swing. */
102
- export interface Curve {
103
- /** Seconds: a looping effect's period, a transition's duration. */
104
- readonly seconds: number;
105
- /** Intensity in [0, 1] to the fraction of `swing` applied. One that overshoots, as a CSS `cubic-bezier` may, saturates: an effect never acts past its swing. */
106
- readonly ease: Ease;
107
+ /**
108
+ * How the curves below are tuned: a `Timing` — seconds, a looping effect's
109
+ * period or a transition's duration, and an ease, intensity in [0, 1] to
110
+ * the fraction of `swing` applied; one that overshoots, as a CSS
111
+ * `cubic-bezier` may, saturates, since an effect never acts past its swing —
112
+ * and the swing itself.
113
+ */
114
+ export interface Curve extends Timing {
107
115
  /** How far the move goes at full intensity, in [0, 1]; what 1 means is the effect's. */
108
116
  readonly swing: number;
109
117
  }
@@ -116,32 +124,32 @@ export interface Curve {
116
124
  export declare const EFFECT_CURVES: {
117
125
  readonly shimmer: {
118
126
  readonly seconds: 109;
119
- readonly ease: Ease;
127
+ readonly ease: import("../core/easing.js").Ease;
120
128
  readonly swing: 0.9;
121
129
  };
122
130
  readonly pulse: {
123
131
  readonly seconds: 43;
124
- readonly ease: Ease;
132
+ readonly ease: import("../core/easing.js").Ease;
125
133
  readonly swing: 0.85;
126
134
  };
127
135
  readonly sparkle: {
128
136
  readonly seconds: 139;
129
- readonly ease: Ease;
137
+ readonly ease: import("../core/easing.js").Ease;
130
138
  readonly swing: 0.95;
131
139
  };
132
140
  readonly wheel: {
133
141
  readonly seconds: 907;
134
- readonly ease: Ease;
142
+ readonly ease: import("../core/easing.js").Ease;
135
143
  readonly swing: 1;
136
144
  };
137
145
  readonly fade: {
138
146
  readonly seconds: 20;
139
- readonly ease: Ease;
147
+ readonly ease: import("../core/easing.js").Ease;
140
148
  readonly swing: 1;
141
149
  };
142
150
  readonly dissolve: {
143
151
  readonly seconds: 30;
144
- readonly ease: Ease;
152
+ readonly ease: import("../core/easing.js").Ease;
145
153
  readonly swing: 1;
146
154
  };
147
155
  };
@@ -177,8 +185,9 @@ export declare function pulse(curve: Curve, glow: ColorRgba, z: number): Loop;
177
185
  /**
178
186
  * Shimmer, as sunlight moving across water. Swing: how far into `light` the
179
187
  * brightest glint goes, 0–1. A soft band of light, `width` columns either
180
- * side of its centre, crosses columns 0 to `span`, entering and leaving
181
- * fully off the row, `STRIDE` columns in about three quarters of a period. Its passes
188
+ * side of its centre, crosses the element from the first column a frame
189
+ * lists (`Drawn.cells`) to the last, entering and leaving fully off it,
190
+ * `STRIDE` columns in about three quarters of a period. Its passes
182
191
  * come the way light comes and goes on water as clouds move: while the sun
183
192
  * is out they are bright and follow close on one another, one sometimes
184
193
  * catching the last; under cloud they thin to faint ones with the row still
@@ -188,11 +197,17 @@ export declare function pulse(curve: Curve, glow: ColorRgba, z: number): Loop;
188
197
  * on a slow current and re-forming as they go, so the glints dance while
189
198
  * the band glides. Before the first pass enters, the row is untouched.
190
199
  */
191
- export declare function shimmer(curve: Curve, span: number, width: number, glow: ColorRgba, z: number): Loop;
200
+ export declare function shimmer(curve: Curve, width: number, glow: ColorRgba, z: number): Loop;
192
201
  /**
193
202
  * Sparkle, as fireflies. Swing: how far into the firefly's `light` a glow
194
- * goes at its brightest, 0–1. About one firefly to every eight columns of
195
- * `span`, each keeping near a home of its own. A firefly flashes — kindles,
203
+ * goes at its brightest, 0–1. Fireflies keep to a lattice laid from the
204
+ * element's first column and top row as a frame lists its cells
205
+ * (`Drawn.cells`): one every `PER` columns along a row of the lattice, a row
206
+ * of the lattice every `ROWS` rows, each firefly near a home of its own.
207
+ * The lattice does not hang on how wide or deep the element is, so one that
208
+ * grows or shrinks at its last column or bottom row moves no firefly; one
209
+ * whose first column moves, as centred words that change length do, carries
210
+ * its fireflies with it. A firefly flashes — kindles,
196
211
  * drifts a few cells glowing, slowing as it fades — then flies on in the
197
212
  * dark and flashes again somewhere a few cells off, the way fireflies at
198
213
  * dusk are seen: a short lit stroke, then gone, each time a little
@@ -203,13 +218,14 @@ export declare function shimmer(curve: Curve, span: number, width: number, glow:
203
218
  * turn: its brightest flash, rise and fall, takes `FLASH` of it, and a
204
219
  * dimmer one less.
205
220
  */
206
- export declare function sparkle(curve: Curve, span: number, glow: ColorRgba, z: number): Loop;
221
+ export declare function sparkle(curve: Curve, glow: ColorRgba, z: number): Loop;
207
222
  /**
208
- * How much of each cell shows at `t`: 1 is the cell as drawn, 0 is the cell
209
- * gone to the terminal's ground. Read per cell, so cells can arrive or leave
210
- * apart, and staged as `Field` is. One outside [0, 1] is held to it.
223
+ * How much of each cell shows at `t` in a frame drawing what `Drawn` says: 1
224
+ * is the cell as drawn, 0 is the cell gone to the terminal's ground. Read per
225
+ * cell, so cells can arrive or leave apart, and staged as `Effect` is. One
226
+ * outside [0, 1] is held to it.
211
227
  */
212
- export type Visibility = (t: number) => (cell: EffectCell) => number;
228
+ export type Visibility = (t: number, drawn: Drawn) => (cell: EffectCell) => number;
213
229
  /**
214
230
  * A cell mixed toward the ground of the terminal the frame is drawn on
215
231
  * (`Drawn.theme`) by how hidden it is: its fill toward the ground, and its ink
@@ -225,6 +241,8 @@ export declare function veiled(visibility: Visibility, swing: number): Effect;
225
241
  * draws it at the time since it began. `done(t)` is true from the moment
226
242
  * every cell has arrived or gone, so the caller knows when to stop drawing an
227
243
  * element that is leaving, or to drop the effect from one that has arrived.
244
+ * Until then the effect's frame changes every frame, and from then never:
245
+ * its `nextChange` is `done` read as a time. [LAW:one-source-of-truth]
228
246
  */
229
247
  export interface Transition {
230
248
  readonly effect: Effect;
@@ -259,19 +277,50 @@ export declare function dissolveOut(curve: Curve, z: number): Transition;
259
277
  * together; on the terminal's ground, a run of text's ink is a segment of
260
278
  * its own. A segment's stray is slow noise of its own, at `STRAY_PERIODS`,
261
279
  * so no two keep step, and the row never shows one spread of hues twice.
262
- * Lightness and chroma are kept, so the words read as they did; the turn
263
- * only happens to the element's own colours (`Drawn.colors`), never the
264
- * terminal's.
280
+ * A colour keeps its luminance as it turns (`hueTurned`), so every pair of
281
+ * words reads at the contrast it rested at; at 256 colours a turned colour
282
+ * lands on a colour the depth writes, one that keeps every pair of words it
283
+ * is drawn in at its floor (`floorOf`) — its resting contrast or WCAG AA,
284
+ * whichever is lower — as `shares` keeps the light's (`turnedBounds`). The
285
+ * turn only happens to the element's own colours (`Drawn.colors`), never the
286
+ * terminal's. On a sixteen-colour terminal nothing turns (`stillOnSlots`).
265
287
  */
266
288
  export declare function wheel(curve: Curve, z: number): Effect;
289
+ /** One step of a signal: the ink it draws, and how long it is held, in seconds. */
290
+ export interface ColorStep {
291
+ readonly color: ColorRgba;
292
+ readonly seconds: number;
293
+ }
294
+ /**
295
+ * A signal: every cell's ink stepping through `steps`' colours on a beat,
296
+ * one colour a hold, looping, for the time it is handed — a gauge's
297
+ * chevrons in bright changing colours. The ground is left as the cell draws
298
+ * it, and the words stay legible on it: each step's ink is written as the
299
+ * colour nearest the step's (OKLab's ΔE) that the depth draws and that
300
+ * reads on the cell's ground, as `Effected` writes it, at the cell's floor
301
+ * (`floorOf`) — its resting contrast or `LEGIBLE`, whichever is lower, the
302
+ * floor every loop here keeps. In truecolor that is the step itself, or its
303
+ * hue and chroma at the lightness nearest it that reaches the floor
304
+ * (`ensureContrast`, the one slide a template's `readableOn` makes too);
305
+ * below truecolor, the nearest of the colours the depth has an index for, so on a
306
+ * sixteen-colour terminal it steps from slot to slot, the one effect here
307
+ * that does (`stillOnSlots`). A cell whose ground no offered colour reads
308
+ * on keeps the ink it rested in.
309
+ *
310
+ * The search is settled once for each ink, ground and step, so a frame
311
+ * inside a step redoes none, and nor does a later pass of the beat: at sixty
312
+ * frames a second a one-second step is sixty identical frames, and the
313
+ * frame changes when the beat does: the signal is the beat mapped to inks.
314
+ * [LAW:no-ambient-temporal-coupling] The beat is `core/easing.ts`'s, and
315
+ * nothing here reads a clock.
316
+ */
317
+ export declare function steppedInk(steps: readonly ColorStep[]): Effect;
267
318
  /**
268
- * What a catalogue effect is made for: the element it is drawn on, as wide as
269
- * `span` columns — how far a shimmer crosses, how many fireflies keep to it —
270
- * and at `z` in the noise, so two elements under one effect do not move in
271
- * lockstep.
319
+ * What a catalogue effect is made for: the element it is drawn on, at `z` in
320
+ * the noise, so two elements under one effect do not move in lockstep. How
321
+ * wide the element is, the effect reads off each frame (`Drawn.cells`).
272
322
  */
273
323
  export interface EffectTarget {
274
- readonly span: number;
275
324
  readonly z: number;
276
325
  }
277
326
  /** The names of the effects that loop. */