@promptctl/rich-js 0.28.0 → 0.29.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 (162) hide show
  1. package/README.md +7 -7
  2. package/dist/core/animation.d.ts +37 -37
  3. package/dist/core/animation.js +61 -61
  4. package/dist/core/ansi.d.ts +4 -4
  5. package/dist/core/ansi.js +9 -9
  6. package/dist/core/bidi.js +6 -6
  7. package/dist/core/cells.d.ts +1 -1
  8. package/dist/core/cells.js +5 -5
  9. package/dist/core/clock.d.ts +1 -1
  10. package/dist/core/color.d.ts +50 -50
  11. package/dist/core/color.js +69 -69
  12. package/dist/core/console.d.ts +8 -8
  13. package/dist/core/console.js +5 -5
  14. package/dist/core/control-codes.d.ts +3 -3
  15. package/dist/core/control-codes.js +7 -7
  16. package/dist/core/easing.d.ts +40 -40
  17. package/dist/core/easing.js +40 -40
  18. package/dist/core/env.d.ts +1 -1
  19. package/dist/core/env.js +1 -1
  20. package/dist/core/export-html.js +1 -1
  21. package/dist/core/export-lines.d.ts +11 -11
  22. package/dist/core/export-lines.js +12 -12
  23. package/dist/core/export-svg.d.ts +3 -3
  24. package/dist/core/export-svg.js +4 -4
  25. package/dist/core/markup.js +1 -1
  26. package/dist/core/memo.d.ts +1 -1
  27. package/dist/core/memo.js +1 -1
  28. package/dist/core/oklch.d.ts +14 -14
  29. package/dist/core/oklch.js +10 -10
  30. package/dist/core/orient.d.ts +3 -3
  31. package/dist/core/orient.js +3 -3
  32. package/dist/core/paint.d.ts +9 -9
  33. package/dist/core/paint.js +3 -3
  34. package/dist/core/pretty.d.ts +1 -1
  35. package/dist/core/pretty.js +3 -3
  36. package/dist/core/protocol.d.ts +26 -26
  37. package/dist/core/protocol.js +22 -22
  38. package/dist/core/render.d.ts +11 -11
  39. package/dist/core/render.js +12 -12
  40. package/dist/core/segment.d.ts +3 -3
  41. package/dist/core/segment.js +5 -5
  42. package/dist/core/strip.d.ts +83 -83
  43. package/dist/core/strip.js +70 -70
  44. package/dist/core/style.d.ts +20 -20
  45. package/dist/core/style.js +55 -55
  46. package/dist/core/text.d.ts +2 -2
  47. package/dist/core/text.js +5 -5
  48. package/dist/core/timeline.d.ts +5 -5
  49. package/dist/core/timeline.js +9 -9
  50. package/dist/core/tween.d.ts +6 -6
  51. package/dist/core/tween.js +10 -10
  52. package/dist/core/view.d.ts +4 -4
  53. package/dist/core/view.js +12 -12
  54. package/dist/host/app.d.ts +9 -9
  55. package/dist/host/app.js +12 -12
  56. package/dist/host/host-environment.d.ts +2 -2
  57. package/dist/host/host-environment.js +2 -2
  58. package/dist/host/index.d.ts +2 -2
  59. package/dist/host/input.d.ts +7 -7
  60. package/dist/host/input.js +4 -4
  61. package/dist/host/terminal-colors.d.ts +2 -2
  62. package/dist/host/terminal-colors.js +4 -4
  63. package/dist/host/terminal-host.d.ts +2 -2
  64. package/dist/host/terminal-host.js +1 -1
  65. package/dist/index.d.ts +14 -14
  66. package/dist/index.js +10 -10
  67. package/dist/node/prompt.d.ts +1 -1
  68. package/dist/node/prompt.js +1 -1
  69. package/dist/node/terminal-host.d.ts +1 -1
  70. package/dist/node/traceback.js +2 -2
  71. package/dist/renderables/change.js +2 -2
  72. package/dist/renderables/effect.d.ts +39 -39
  73. package/dist/renderables/effect.js +45 -45
  74. package/dist/renderables/effects.d.ts +81 -81
  75. package/dist/renderables/effects.js +157 -157
  76. package/dist/renderables/embed.d.ts +1 -1
  77. package/dist/renderables/embed.js +2 -2
  78. package/dist/renderables/flexStrip.d.ts +7 -7
  79. package/dist/renderables/flexStrip.js +15 -15
  80. package/dist/renderables/frames.d.ts +6 -6
  81. package/dist/renderables/frames.js +11 -11
  82. package/dist/renderables/glyph-effect.d.ts +15 -15
  83. package/dist/renderables/glyph-effect.js +17 -17
  84. package/dist/renderables/glyph-effects.d.ts +7 -7
  85. package/dist/renderables/glyph-effects.js +16 -16
  86. package/dist/renderables/html-entities.d.ts +1 -1
  87. package/dist/renderables/html-entities.js +1 -1
  88. package/dist/renderables/lifecycle.d.ts +4 -4
  89. package/dist/renderables/lifecycle.js +12 -12
  90. package/dist/renderables/live.d.ts +2 -2
  91. package/dist/renderables/live.js +7 -7
  92. package/dist/renderables/markdown-parse.js +3 -3
  93. package/dist/renderables/panel.js +3 -3
  94. package/dist/renderables/progress.d.ts +1 -1
  95. package/dist/renderables/progress.js +1 -1
  96. package/dist/renderables/progressBar.d.ts +1 -1
  97. package/dist/renderables/progressBar.js +6 -6
  98. package/dist/renderables/prompt.d.ts +1 -1
  99. package/dist/renderables/scroll.d.ts +1 -1
  100. package/dist/renderables/scroll.js +3 -3
  101. package/dist/renderables/spinner.d.ts +4 -4
  102. package/dist/renderables/spinner.js +10 -10
  103. package/dist/renderables/syntax.d.ts +2 -2
  104. package/dist/renderables/syntax.js +2 -2
  105. package/dist/renderables/table.js +3 -3
  106. package/dist/renderables/traceback.d.ts +1 -1
  107. package/dist/renderables/traceback.js +1 -1
  108. package/dist/renderables/tree.js +3 -3
  109. package/dist/template-bindings/animation-funcs.d.ts +14 -14
  110. package/dist/template-bindings/animation-funcs.js +27 -27
  111. package/dist/template-bindings/color-funcs.d.ts +14 -14
  112. package/dist/template-bindings/color-funcs.js +25 -25
  113. package/dist/template-bindings/index.d.ts +9 -9
  114. package/dist/template-bindings/index.js +9 -9
  115. package/dist/template-bindings/palette-funcs.d.ts +1 -1
  116. package/dist/template-bindings/palette-funcs.js +3 -3
  117. package/dist/template-bindings/style-funcs.d.ts +5 -5
  118. package/dist/template-bindings/style-funcs.js +16 -16
  119. package/dist/themes/{transpose.d.ts → adjust.d.ts} +23 -23
  120. package/dist/themes/{transpose.js → adjust.js} +28 -28
  121. package/dist/themes/buildPalette.d.ts +3 -3
  122. package/dist/themes/buildPalette.js +20 -20
  123. package/dist/themes/colorMath.d.ts +16 -16
  124. package/dist/themes/colorMath.js +32 -32
  125. package/dist/themes/data/ansi-tables.d.ts +2 -2
  126. package/dist/themes/data/ansi-tables.js +2 -2
  127. package/dist/themes/data/types.d.ts +4 -4
  128. package/dist/themes/data/types.js +2 -2
  129. package/dist/themes/palette.d.ts +12 -12
  130. package/dist/themes/palette.js +16 -16
  131. package/dist/themes/ramp.d.ts +17 -17
  132. package/dist/themes/ramp.js +12 -12
  133. package/dist/themes/registry.js +4 -4
  134. package/dist/themes/terminalThemes.d.ts +1 -1
  135. package/dist/themes/terminalThemes.js +1 -1
  136. package/dist/widgets/button.d.ts +2 -2
  137. package/dist/widgets/button.js +4 -4
  138. package/dist/widgets/checkbox.d.ts +2 -2
  139. package/dist/widgets/checkbox.js +2 -2
  140. package/dist/widgets/dropdown.d.ts +2 -2
  141. package/dist/widgets/dropdown.js +3 -3
  142. package/dist/widgets/event-router.d.ts +6 -6
  143. package/dist/widgets/event-router.js +2 -2
  144. package/dist/widgets/focus-manager.d.ts +3 -3
  145. package/dist/widgets/focus-manager.js +3 -3
  146. package/dist/widgets/index.d.ts +2 -2
  147. package/dist/widgets/index.js +1 -1
  148. package/dist/widgets/ink.d.ts +3 -3
  149. package/dist/widgets/ink.js +4 -4
  150. package/dist/widgets/slider.d.ts +2 -2
  151. package/dist/widgets/static-item.d.ts +2 -2
  152. package/dist/widgets/text-input.d.ts +2 -2
  153. package/dist/widgets/text-input.js +5 -5
  154. package/dist/widgets/themed-widget.js +1 -1
  155. package/dist/widgets/toggle.d.ts +3 -3
  156. package/dist/widgets/toggle.js +3 -3
  157. package/dist/widgets/types.d.ts +6 -6
  158. package/dist/widgets/types.js +2 -2
  159. package/dist/widgets/widget-app.d.ts +10 -10
  160. package/dist/widgets/widget-app.js +8 -8
  161. package/dist/widgets/widget-base.d.ts +2 -2
  162. package/package.json +1 -1
@@ -22,7 +22,7 @@
22
22
  * `elastic`, Robert Penner's curves at the constants every animation
23
23
  * library since has shipped. An ease that leaves [0, 1] — a spring or a
24
24
  * back curve overshooting its rest — is still an ease: a `ColorRamp` holds
25
- * its end colours where it does, and an effect's `Curve` saturates at its
25
+ * its end colors where it does, and an effect's `Curve` saturates at its
26
26
  * swing, so the overshoot is read by what can show it (a position, a
27
27
  * count) and clipped by what cannot.
28
28
  *
@@ -33,15 +33,15 @@
33
33
  * [LAW:one-type-per-behavior] An ease is a plain function value. CSS's named
34
34
  * curves are four instances of `cubicBezier`, not four implementations, the
35
35
  * spring in `EASES` is one `spring()`, and `ColorRamp` and every effect take
36
- * the same `Ease`.
36
+ * the same `Easing`.
37
37
  *
38
38
  * Tier 0 of `src/core/`: imports nothing, so `themes/` and every later
39
39
  * `core/` module reach it downhill. [LAW:one-way-deps]
40
40
  */
41
41
  /** Progress in [0, 1] in, progress out: a reshaping of [0, 1] that may leave it, as a spring overshooting its rest does. */
42
- export type Ease = (x: number) => number;
42
+ export type Easing = (x: number) => number;
43
43
  /** Time in seconds (plus any per-cell offset) in, progress in [0, 1] out. */
44
- export type Phase = (t: number) => number;
44
+ export type WrapMode = (t: number) => number;
45
45
  /**
46
46
  * CSS `cubic-bezier(x1, y1, x2, y2)`: the curve from (0, 0) to (1, 1) with
47
47
  * those two control points, read as y at a given x. `x1` and `x2` must lie in
@@ -49,7 +49,7 @@ export type Phase = (t: number) => number;
49
49
  * every input has exactly one output. `y1` and `y2` may leave [0, 1]; the
50
50
  * curve then overshoots, as a CSS "back" curve does.
51
51
  */
52
- export declare function cubicBezier(x1: number, y1: number, x2: number, y2: number): Ease;
52
+ export declare function cubicBezier(x1: number, y1: number, x2: number, y2: number): Easing;
53
53
  /**
54
54
  * Where a `steps()` curve jumps, in CSS's terms. `jump-start` jumps at 0,
55
55
  * `jump-end` at 1, `jump-both` at both, `jump-none` at neither; `start` and
@@ -62,11 +62,11 @@ export type StepPosition = "jump-start" | "jump-end" | "jump-none" | "jump-both"
62
62
  * `position` names — CSS's step algorithm, so `steps(1, "end")` is 0 until
63
63
  * the very end.
64
64
  */
65
- export declare function steps(n: number, position?: StepPosition): Ease;
65
+ export declare function steps(n: number, position?: StepPosition): Easing;
66
66
  /**
67
67
  * The curve `shape` over [0, 1) as an ease that has arrived: its argument
68
68
  * held to [0, 1], and exactly 1 at 1. Every built-in ease is one, so the two
69
- * halves of the `Ease` contract — an argument in [0, 1], the end landed on —
69
+ * halves of the `Easing` contract — an argument in [0, 1], the end landed on —
70
70
  * are enforced here and nowhere else. [LAW:single-enforcer] The end matters
71
71
  * because a curve is 1 at its end only in the limit or up to a rounding — a
72
72
  * spring settles to within `SPRING_REST`, the elastic's ringing never quite
@@ -74,7 +74,7 @@ export declare function steps(n: number, position?: StepPosition): Ease;
74
74
  * and a count or a width eased by it must land on its target, not a
75
75
  * thousandth or an ulp short.
76
76
  */
77
- export declare const settled: (shape: (p: number) => number) => Ease;
77
+ export declare const withSettlingTime: (shape: (p: number) => number) => Easing;
78
78
  /**
79
79
  * A spring's physics: the mass on it, the stiffness of its coil and the
80
80
  * damping it moves against, in the units every animation library spells them
@@ -93,19 +93,19 @@ export interface SpringOptions {
93
93
  * An ease over a duration: CSS's timing function and duration as one value,
94
94
  * the whole of what a one-shot move needs to know about time — a tween's
95
95
  * (`./tween.ts`), a `spring()`'s, and the part of an effect's `Curve` that
96
- * is not its swing. `Phase.once(start, seconds)` through `ease` is the move
96
+ * is not its swing. `WrapMode.once(start, seconds)` through `ease` is the move
97
97
  * on a timeline. [LAW:one-type-per-behavior] One shape, so a spring is handed
98
98
  * to a tween as it is, and a curve written for an effect times a tween.
99
99
  */
100
100
  export interface Timing {
101
101
  /** How the move is shaped, as progress in to progress out. */
102
- readonly ease: Ease;
102
+ readonly ease: Easing;
103
103
  /** How long the move takes, in seconds. */
104
104
  readonly seconds: number;
105
105
  }
106
106
  /**
107
107
  * How close to its rest a spring must come to count as settled: one part in a
108
- * thousand of the way it moves, under a colour channel's step (1/255) and
108
+ * thousand of the way it moves, under a color channel's step (1/255) and
109
109
  * under any cell, so what rounds the spring's value to show it draws the rest
110
110
  * from there on.
111
111
  */
@@ -137,28 +137,28 @@ export declare function spring(options?: SpringOptions): Timing;
137
137
  * `seconds` are `DEFAULT_SPRING`'s; the rest are Penner's at his constants.
138
138
  */
139
139
  export declare const EASES: {
140
- readonly linear: Ease;
141
- readonly ease: Ease;
142
- readonly "ease-in": Ease;
143
- readonly "ease-out": Ease;
144
- readonly "ease-in-out": Ease;
145
- readonly "step-start": Ease;
146
- readonly "step-end": Ease;
147
- readonly step: Ease;
148
- readonly sine: Ease;
149
- readonly spring: Ease;
150
- readonly bounce: Ease;
151
- readonly "back-in": Ease;
152
- readonly "back-out": Ease;
153
- readonly elastic: Ease;
140
+ readonly linear: Easing;
141
+ readonly ease: Easing;
142
+ readonly "ease-in": Easing;
143
+ readonly "ease-out": Easing;
144
+ readonly "ease-in-out": Easing;
145
+ readonly "step-start": Easing;
146
+ readonly "step-end": Easing;
147
+ readonly step: Easing;
148
+ readonly sine: Easing;
149
+ readonly spring: Easing;
150
+ readonly bounce: Easing;
151
+ readonly "back-in": Easing;
152
+ readonly "back-out": Easing;
153
+ readonly elastic: Easing;
154
154
  };
155
- export type EaseName = keyof typeof EASES;
155
+ export type EasingName = keyof typeof EASES;
156
156
  /**
157
157
  * The gate a spelled ease crosses. [LAW:parse-dont-validate] — a name in, the
158
158
  * function out, so nothing downstream holds a string it must check again.
159
159
  * Unknown names throw naming every legal one. [LAW:no-silent-failure]
160
160
  */
161
- export declare function parseEase(name: string): Ease;
161
+ export declare function parseEasing(name: string): Easing;
162
162
  /** Throws, naming `what`, unless `seconds` is a positive, finite number of seconds. */
163
163
  export declare function positiveSeconds(what: string, seconds: number): void;
164
164
  /**
@@ -166,11 +166,11 @@ export declare function positiveSeconds(what: string, seconds: number): void;
166
166
  * way the frames of an animation are each held and then replaced. `at(t)` is
167
167
  * the index of the hold in progress at `t`, counted from the first hold at
168
168
  * `t = 0`, and the sequence wraps every `period` seconds, before zero too,
169
- * as `Phase.loop` wraps. With equal holds `at` is `steps(n)` read as an
169
+ * as `WrapMode.loop` wraps. With equal holds `at` is `steps(n)` read as an
170
170
  * index; the holds here may differ, which `steps` cannot say, so a frame
171
171
  * held for a second and the next for a quarter are one beat.
172
172
  */
173
- export interface Beat {
173
+ export interface StepSequence {
174
174
  readonly holds: readonly number[];
175
175
  /** The sum of the holds: how long one pass takes, in seconds. */
176
176
  readonly period: number;
@@ -180,10 +180,10 @@ export interface Beat {
180
180
  * When the hold in progress at `t` began, in seconds on `t`'s own
181
181
  * timeline: what a sample-and-hold on this beat reads at `t`. Every `t`
182
182
  * inside one hold of one pass answers the same number, to the bit, so an
183
- * effect handed it draws the same frame throughout. With `nextChange`,
183
+ * effect handed it draws the same frame throughout. With `validUntil`,
184
184
  * the two ends of the hold, as every `Animation` answers them.
185
185
  */
186
- lastChange(t: number): number;
186
+ validFrom(t: number): number;
187
187
  /**
188
188
  * When the hold in progress at `t` ends, in seconds on `t`'s own timeline:
189
189
  * the start of the next hold, the first moment `at` places in it, so it is
@@ -191,9 +191,9 @@ export interface Beat {
191
191
  * With `at`, this makes a beat an `Animation` of the hold in progress
192
192
  * (`./animation.ts`).
193
193
  */
194
- nextChange(t: number): number;
194
+ validUntil(t: number): number;
195
195
  /** The beat with its motion taken out: its first hold, held for good, as a loop holds its first value. */
196
- reduced(): Beat;
196
+ reduced(): StepSequence;
197
197
  }
198
198
  /**
199
199
  * `t`, unless it is not a finite number of seconds, which throws naming
@@ -234,14 +234,14 @@ export declare function walkUp(sum: number, reached: (x: number) => boolean, fin
234
234
  * exact to the float and the cost is logarithmic in that distance.
235
235
  */
236
236
  export declare function firstReaching(near: number, reached: (x: number) => boolean): number;
237
- /** `holds` as a `Beat`; a beat with no hold, or a hold that is not a positive number of seconds, throws. */
238
- export declare function beat(holds: readonly number[]): Beat;
239
- /** The three phase shapes. Each takes seconds and returns a `Phase`. */
240
- export declare const Phase: {
237
+ /** `holds` as a `StepSequence`; a beat with no hold, or a hold that is not a positive number of seconds, throws. */
238
+ export declare function stepSequence(holds: readonly number[]): StepSequence;
239
+ /** The three phase shapes. Each takes seconds and returns a `WrapMode`. */
240
+ export declare const WrapMode: {
241
241
  /** 0 before `start`, rising to 1 over `duration` seconds, then held at 1. */
242
- once(start: number, duration: number): Phase;
242
+ once(start: number, duration: number): WrapMode;
243
243
  /** 0 → 1 every `period` seconds, wrapping back to 0; negative `t` wraps too. */
244
- loop(period: number): Phase;
244
+ loop(period: number): WrapMode;
245
245
  /** 0 → 1 → 0 every `period` seconds: there in the first half, back in the second. */
246
- pingPong(period: number): Phase;
246
+ pingPong(period: number): WrapMode;
247
247
  };
@@ -22,7 +22,7 @@
22
22
  * `elastic`, Robert Penner's curves at the constants every animation
23
23
  * library since has shipped. An ease that leaves [0, 1] — a spring or a
24
24
  * back curve overshooting its rest — is still an ease: a `ColorRamp` holds
25
- * its end colours where it does, and an effect's `Curve` saturates at its
25
+ * its end colors where it does, and an effect's `Curve` saturates at its
26
26
  * swing, so the overshoot is read by what can show it (a position, a
27
27
  * count) and clipped by what cannot.
28
28
  *
@@ -33,7 +33,7 @@
33
33
  * [LAW:one-type-per-behavior] An ease is a plain function value. CSS's named
34
34
  * curves are four instances of `cubicBezier`, not four implementations, the
35
35
  * spring in `EASES` is one `spring()`, and `ColorRamp` and every effect take
36
- * the same `Ease`.
36
+ * the same `Easing`.
37
37
  *
38
38
  * Tier 0 of `src/core/`: imports nothing, so `themes/` and every later
39
39
  * `core/` module reach it downhill. [LAW:one-way-deps]
@@ -91,7 +91,7 @@ export function cubicBezier(x1, y1, x2, y2) {
91
91
  }
92
92
  return s;
93
93
  };
94
- return settled((p) => yAt(solve(p)));
94
+ return withSettlingTime((p) => yAt(solve(p)));
95
95
  }
96
96
  /**
97
97
  * CSS `steps(n, position)`: progress held flat in `n` equal intervals, jumping
@@ -115,12 +115,12 @@ export function steps(n, position = "jump-end") {
115
115
  "jump-none": n - 1,
116
116
  }[position];
117
117
  const lift = jumpsAtStart ? 1 : 0;
118
- return settled((p) => Math.min(jumps, Math.floor(p * n) + lift) / jumps);
118
+ return withSettlingTime((p) => Math.min(jumps, Math.floor(p * n) + lift) / jumps);
119
119
  }
120
120
  /**
121
121
  * The curve `shape` over [0, 1) as an ease that has arrived: its argument
122
122
  * held to [0, 1], and exactly 1 at 1. Every built-in ease is one, so the two
123
- * halves of the `Ease` contract — an argument in [0, 1], the end landed on —
123
+ * halves of the `Easing` contract — an argument in [0, 1], the end landed on —
124
124
  * are enforced here and nowhere else. [LAW:single-enforcer] The end matters
125
125
  * because a curve is 1 at its end only in the limit or up to a rounding — a
126
126
  * spring settles to within `SPRING_REST`, the elastic's ringing never quite
@@ -128,19 +128,19 @@ export function steps(n, position = "jump-end") {
128
128
  * and a count or a width eased by it must land on its target, not a
129
129
  * thousandth or an ulp short.
130
130
  */
131
- export const settled = (shape) => (x) => {
131
+ export const withSettlingTime = (shape) => (x) => {
132
132
  const p = Math.min(1, Math.max(0, x));
133
133
  return p === 1 ? 1 : shape(p);
134
134
  };
135
135
  /** The identity ease: progress unchanged. */
136
- const linear = settled((p) => p);
136
+ const linear = withSettlingTime((p) => p);
137
137
  /** CSS `step-end`: 0 until the very end. */
138
138
  const stepEnd = steps(1, "jump-end");
139
139
  /** A half-cosine, flat at both ends: the curve a breathing pulse wants. */
140
- const sine = settled((p) => (1 - Math.cos(Math.PI * p)) / 2);
140
+ const sine = withSettlingTime((p) => (1 - Math.cos(Math.PI * p)) / 2);
141
141
  /**
142
142
  * How close to its rest a spring must come to count as settled: one part in a
143
- * thousand of the way it moves, under a colour channel's step (1/255) and
143
+ * thousand of the way it moves, under a color channel's step (1/255) and
144
144
  * under any cell, so what rounds the spring's value to show it draws the rest
145
145
  * from there on.
146
146
  */
@@ -171,7 +171,7 @@ export function spring(options = {}) {
171
171
  const zeta = damping / (2 * Math.sqrt(stiffness * mass));
172
172
  const decay = zeta * w0;
173
173
  const { displacement, seconds } = zeta < 1 ? ringing(w0, zeta, decay) : creeping(w0, zeta, decay);
174
- return { seconds, ease: settled((p) => 1 - displacement(p * seconds)) };
174
+ return { seconds, ease: withSettlingTime((p) => 1 - displacement(p * seconds)) };
175
175
  }
176
176
  /**
177
177
  * Where `|displacement|` falls through `SPRING_REST` between `lo` and `hi`,
@@ -258,7 +258,7 @@ const BOUNCE_ARCS = [
258
258
  { until: 2.5 / 2.75, centre: 2.25 / 2.75, floor: 0.9375 },
259
259
  { until: Number.POSITIVE_INFINITY, centre: 2.625 / 2.75, floor: 0.984375 },
260
260
  ];
261
- const bounce = settled((p) => {
261
+ const bounce = withSettlingTime((p) => {
262
262
  // The last arc's `until` is unbounded, so an arc is always found.
263
263
  const arc = BOUNCE_ARCS.find(({ until }) => p < until);
264
264
  return 7.5625 * (p - arc.centre) ** 2 + arc.floor;
@@ -272,8 +272,8 @@ const bounce = settled((p) => {
272
272
  * and lands on 1 to the bit.
273
273
  */
274
274
  const BACK_OVERSHOOT = 1.70158;
275
- const backIn = settled((p) => p ** 3 + BACK_OVERSHOOT * p ** 2 * (p - 1));
276
- const backOut = settled((p) => {
275
+ const backIn = withSettlingTime((p) => p ** 3 + BACK_OVERSHOOT * p ** 2 * (p - 1));
276
+ const backOut = withSettlingTime((p) => {
277
277
  const q = p - 1;
278
278
  return 1 + q ** 3 + BACK_OVERSHOOT * q ** 2 * (q + 1);
279
279
  });
@@ -284,7 +284,7 @@ const backOut = settled((p) => {
284
284
  * last — `2^(−10x)·sin((10x − 0.75)·2π/3) + 1`.
285
285
  */
286
286
  const ELASTIC_PERIOD = (2 * Math.PI) / 3;
287
- const elastic = settled((p) => 2 ** (-10 * p) * Math.sin((10 * p - 0.75) * ELASTIC_PERIOD) + 1);
287
+ const elastic = withSettlingTime((p) => 2 ** (-10 * p) * Math.sin((10 * p - 0.75) * ELASTIC_PERIOD) + 1);
288
288
  /**
289
289
  * Every built-in ease by the name a template spells it with — CSS's keyword
290
290
  * names, plus `sine`, plus `step`: the spelling `ColorRamp` used before this
@@ -314,7 +314,7 @@ export const EASES = {
314
314
  * function out, so nothing downstream holds a string it must check again.
315
315
  * Unknown names throw naming every legal one. [LAW:no-silent-failure]
316
316
  */
317
- export function parseEase(name) {
317
+ export function parseEasing(name) {
318
318
  if (!Object.hasOwn(EASES, name)) {
319
319
  throw new RangeError(`unknown ease ${JSON.stringify(name)}; expected one of ` +
320
320
  Object.keys(EASES).map((n) => JSON.stringify(n)).join(", "));
@@ -335,8 +335,8 @@ const STILL = {
335
335
  holds: [Number.POSITIVE_INFINITY],
336
336
  period: Number.POSITIVE_INFINITY,
337
337
  at: () => 0,
338
- lastChange: () => Number.NEGATIVE_INFINITY,
339
- nextChange: () => Number.POSITIVE_INFINITY,
338
+ validFrom: () => Number.NEGATIVE_INFINITY,
339
+ validUntil: () => Number.POSITIVE_INFINITY,
340
340
  reduced: () => STILL,
341
341
  };
342
342
  /**
@@ -352,7 +352,7 @@ export function finiteTime(what, t) {
352
352
  /**
353
353
  * The seconds into the current pass of a `period` at `t`: `t` taken modulo
354
354
  * the period, into [0, period), before zero too. [LAW:single-enforcer] The
355
- * one wrap `Phase.loop` and `beat` both read time through, so a `t` that is
355
+ * one wrap `WrapMode.loop` and `beat` both read time through, so a `t` that is
356
356
  * not a finite number of seconds fails here, loudly, and nowhere else. A
357
357
  * `t` at or past zero is `t % period` alone, which is exact; only a negative
358
358
  * `t` is carried up by a period, so a boundary a host samples exactly lands
@@ -474,21 +474,21 @@ export function firstReaching(near, reached) {
474
474
  lo = mid;
475
475
  }
476
476
  }
477
- /** `holds` as a `Beat`; a beat with no hold, or a hold that is not a positive number of seconds, throws. */
478
- export function beat(holds) {
477
+ /** `holds` as a `StepSequence`; a beat with no hold, or a hold that is not a positive number of seconds, throws. */
478
+ export function stepSequence(holds) {
479
479
  if (holds.length === 0)
480
- throw new RangeError("a beat needs at least one hold");
481
- holds.forEach((hold, i) => positiveSeconds(`beat hold ${i}`, hold));
482
- const period = holds.reduce((sum, hold) => sum + hold, 0);
480
+ throw new RangeError("a step sequence needs at least one step");
481
+ holds.forEach((validity, i) => positiveSeconds(`step ${i}`, validity));
482
+ const period = holds.reduce((sum, validity) => sum + validity, 0);
483
483
  // Where each hold begins, in seconds into the period: the unit
484
484
  // `wrapSeconds` answers in, so the sum a boundary sits at is the number
485
485
  // the wrap of a `t` on that boundary produces, and the hold that begins
486
486
  // there is the one in progress, at any rate the host samples.
487
487
  const starts = [];
488
488
  let elapsed = 0;
489
- for (const hold of holds) {
489
+ for (const validity of holds) {
490
490
  starts.push(elapsed);
491
- elapsed += hold;
491
+ elapsed += validity;
492
492
  }
493
493
  // A copy, and the one `at` walks: what `at` and `period` were built from
494
494
  // stays what `holds` says whatever the caller does to its array.
@@ -520,40 +520,40 @@ export function beat(holds) {
520
520
  holds: own,
521
521
  period,
522
522
  at(t) {
523
- return index(wrapSeconds("Beat.at", t, period));
523
+ return index(wrapSeconds("StepSequence.at", t, period));
524
524
  },
525
- lastChange(t) {
526
- const { pass, into } = passAt("Beat.lastChange", t, period);
527
- return boundary("Beat.lastChange", pass, index(into), t);
525
+ validFrom(t) {
526
+ const { pass, into } = passAt("StepSequence.validFrom", t, period);
527
+ return boundary("StepSequence.validFrom", pass, index(into), t);
528
528
  },
529
529
  // The next hold's start, in the next pass when this hold is the last.
530
- nextChange(t) {
531
- const { pass, into } = passAt("Beat.nextChange", t, period);
530
+ validUntil(t) {
531
+ const { pass, into } = passAt("StepSequence.validUntil", t, period);
532
532
  const i = index(into);
533
533
  const last = i === own.length - 1;
534
- return boundary("Beat.nextChange", pass + (last ? 1 : 0), last ? 0 : i + 1, t);
534
+ return boundary("StepSequence.validUntil", pass + (last ? 1 : 0), last ? 0 : i + 1, t);
535
535
  },
536
536
  reduced: () => STILL,
537
537
  };
538
538
  }
539
- /** The three phase shapes. Each takes seconds and returns a `Phase`. */
540
- export const Phase = {
539
+ /** The three phase shapes. Each takes seconds and returns a `WrapMode`. */
540
+ export const WrapMode = {
541
541
  /** 0 before `start`, rising to 1 over `duration` seconds, then held at 1. */
542
542
  once(start, duration) {
543
543
  if (!Number.isFinite(start))
544
- throw new RangeError(`Phase.once start must be finite, got ${start}`);
545
- positiveSeconds("Phase.once duration", duration);
544
+ throw new RangeError(`WrapMode.once start must be finite, got ${start}`);
545
+ positiveSeconds("WrapMode.once duration", duration);
546
546
  return (t) => Math.min(1, Math.max(0, (t - start) / duration));
547
547
  },
548
548
  /** 0 → 1 every `period` seconds, wrapping back to 0; negative `t` wraps too. */
549
549
  loop(period) {
550
- positiveSeconds("Phase.loop period", period);
551
- return (t) => wrapSeconds("Phase.loop", t, period) / period;
550
+ positiveSeconds("WrapMode.loop period", period);
551
+ return (t) => wrapSeconds("WrapMode.loop", t, period) / period;
552
552
  },
553
553
  /** 0 → 1 → 0 every `period` seconds: there in the first half, back in the second. */
554
554
  pingPong(period) {
555
- positiveSeconds("Phase.pingPong period", period);
556
- const wrap = Phase.loop(period);
555
+ positiveSeconds("WrapMode.pingPong period", period);
556
+ const wrap = WrapMode.loop(period);
557
557
  return (t) => 1 - Math.abs(2 * wrap(t) - 1);
558
558
  },
559
559
  };
@@ -16,7 +16,7 @@
16
16
  export type Env = Readonly<Record<string, string | undefined>>;
17
17
  /**
18
18
  * A terminal that says it cannot be drawn on: `TERM` is `dumb` or `unknown`,
19
- * as Emacs' shell mode sets it. It takes no colour and nothing that moves the
19
+ * as Emacs' shell mode sets it. It takes no color and nothing that moves the
20
20
  * cursor.
21
21
  */
22
22
  export declare function isDumbTerminal(env: Env): boolean;
package/dist/core/env.js CHANGED
@@ -15,7 +15,7 @@
15
15
  */
16
16
  /**
17
17
  * A terminal that says it cannot be drawn on: `TERM` is `dumb` or `unknown`,
18
- * as Emacs' shell mode sets it. It takes no colour and nothing that moves the
18
+ * as Emacs' shell mode sets it. It takes no color and nothing that moves the
19
19
  * cursor.
20
20
  */
21
21
  export function isDumbTerminal(env) {
@@ -37,7 +37,7 @@ const OUTLINE = {
37
37
  encircle: [FRAME, "border-radius:0.5em"],
38
38
  };
39
39
  /**
40
- * The glyph colour, and the background when one is painted.
40
+ * The glyph color, and the background when one is painted.
41
41
  *
42
42
  * Dim arrives already blended into `foreground`. `opacity` is never written:
43
43
  * it fades a painted background along with the glyph, which is the bug the
@@ -3,15 +3,15 @@
3
3
  * lines every exporter draws.
4
4
  *
5
5
  * The HTML and SVG exporters are two encodings of one picture, and this module
6
- * is the picture. What a styled cell *looks like* — which colour its glyph is,
6
+ * is the picture. What a styled cell *looks like* — which color its glyph is,
7
7
  * whether its background is painted, which decorations it carries, where it
8
8
  * links — is decided here, once, and an exporter decides only how to write
9
9
  * that down. Before it existed the decision was made twice, by a CSS method
10
10
  * on `Style` and by a private converter on `Console`, and the two had already
11
- * disagreed: one honoured `underline2`, the other dropped it.
11
+ * disagreed: one honoured `doubleUnderline`, the other dropped it.
12
12
  *
13
13
  * [LAW:types-are-the-program] `ExportLook` has no `reverse`, `dim`, `conceal`
14
- * or default colour, because all four are consumed by `resolveLook` and turned
14
+ * or default color, because all four are consumed by `resolveLook` and turned
15
15
  * into plain RGB. An exporter holding a look cannot forget to swap a reversed
16
16
  * run or to fade a dim one: there is nothing left in its hands to forget. That
17
17
  * is the whole reason the representation is resolved rather than a `Style`
@@ -44,7 +44,7 @@ export type Href = string & {
44
44
  };
45
45
  /**
46
46
  * Where a run's background comes from. `"canvas"` is the theme background
47
- * showing through — nothing painted — and is distinct from a painted colour
47
+ * showing through — nothing painted — and is distinct from a painted color
48
48
  * that happens to equal it, because `on default` and `on #000000` are
49
49
  * different requests even over a black theme.
50
50
  */
@@ -96,25 +96,25 @@ export interface ExportCanvas {
96
96
  * The ground every export is drawn on under `theme`.
97
97
  *
98
98
  * An exporter paints its page or window with this, and a run with no
99
- * background of its own resolves to `"canvas"` rather than a colour, so a run
100
- * showing the canvas and the page around it cannot come out different colours.
99
+ * background of its own resolves to `"canvas"` rather than a color, so a run
100
+ * showing the canvas and the page around it cannot come out different colors.
101
101
  */
102
102
  export declare function exportCanvas(theme?: TerminalTheme): ExportCanvas;
103
103
  /**
104
104
  * A `Style` as it appears on screen under `theme`.
105
105
  *
106
- * The order is the terminal's: the colours are `Style.drawnColors`, the ones
106
+ * The order is the terminal's: the colors are `Style.drawnColors`, the ones
107
107
  * `toSgrCodes` writes, resolved through the theme — `reverse` swaps them,
108
108
  * `dim` fades the glyph toward whatever background it ended up on, and
109
109
  * `conceal` finally paints the glyph in that background. Every step works on
110
- * opaque colour, so no exporter ever draws a translucent one. Text under
110
+ * opaque color, so no exporter ever draws a translucent one. Text under
111
111
  * `conceal` is still present, and still selectable, in both formats.
112
112
  *
113
- * A translucent colour is flattened where the writer flattens it, over
113
+ * A translucent color is flattened where the writer flattens it, over
114
114
  * `SURFACE_BLACK`, not over this export's canvas. The writer's truecolor
115
115
  * bytes are absolute — no terminal theme retints them — so a terminal under
116
- * `theme` shows that colour, and an export that flattened over its own canvas
117
- * would picture a colour no terminal draws.
116
+ * `theme` shows that color, and an export that flattened over its own canvas
117
+ * would picture a color no terminal draws.
118
118
  *
119
119
  * `theme` omitted is `ColorSpec.getTruecolor`'s own fallback — black canvas,
120
120
  * white ink, the standard ANSI table. Choosing it there rather than naming a
@@ -3,15 +3,15 @@
3
3
  * lines every exporter draws.
4
4
  *
5
5
  * The HTML and SVG exporters are two encodings of one picture, and this module
6
- * is the picture. What a styled cell *looks like* — which colour its glyph is,
6
+ * is the picture. What a styled cell *looks like* — which color its glyph is,
7
7
  * whether its background is painted, which decorations it carries, where it
8
8
  * links — is decided here, once, and an exporter decides only how to write
9
9
  * that down. Before it existed the decision was made twice, by a CSS method
10
10
  * on `Style` and by a private converter on `Console`, and the two had already
11
- * disagreed: one honoured `underline2`, the other dropped it.
11
+ * disagreed: one honoured `doubleUnderline`, the other dropped it.
12
12
  *
13
13
  * [LAW:types-are-the-program] `ExportLook` has no `reverse`, `dim`, `conceal`
14
- * or default colour, because all four are consumed by `resolveLook` and turned
14
+ * or default color, because all four are consumed by `resolveLook` and turned
15
15
  * into plain RGB. An exporter holding a look cannot forget to swap a reversed
16
16
  * run or to fade a dim one: there is nothing left in its hands to forget. That
17
17
  * is the whole reason the representation is resolved rather than a `Style`
@@ -82,8 +82,8 @@ const DEFAULT_COLOR = ColorSpec.default();
82
82
  * The ground every export is drawn on under `theme`.
83
83
  *
84
84
  * An exporter paints its page or window with this, and a run with no
85
- * background of its own resolves to `"canvas"` rather than a colour, so a run
86
- * showing the canvas and the page around it cannot come out different colours.
85
+ * background of its own resolves to `"canvas"` rather than a color, so a run
86
+ * showing the canvas and the page around it cannot come out different colors.
87
87
  */
88
88
  export function exportCanvas(theme) {
89
89
  return {
@@ -94,18 +94,18 @@ export function exportCanvas(theme) {
94
94
  /**
95
95
  * A `Style` as it appears on screen under `theme`.
96
96
  *
97
- * The order is the terminal's: the colours are `Style.drawnColors`, the ones
97
+ * The order is the terminal's: the colors are `Style.drawnColors`, the ones
98
98
  * `toSgrCodes` writes, resolved through the theme — `reverse` swaps them,
99
99
  * `dim` fades the glyph toward whatever background it ended up on, and
100
100
  * `conceal` finally paints the glyph in that background. Every step works on
101
- * opaque colour, so no exporter ever draws a translucent one. Text under
101
+ * opaque color, so no exporter ever draws a translucent one. Text under
102
102
  * `conceal` is still present, and still selectable, in both formats.
103
103
  *
104
- * A translucent colour is flattened where the writer flattens it, over
104
+ * A translucent color is flattened where the writer flattens it, over
105
105
  * `SURFACE_BLACK`, not over this export's canvas. The writer's truecolor
106
106
  * bytes are absolute — no terminal theme retints them — so a terminal under
107
- * `theme` shows that colour, and an export that flattened over its own canvas
108
- * would picture a colour no terminal draws.
107
+ * `theme` shows that color, and an export that flattened over its own canvas
108
+ * would picture a color no terminal draws.
109
109
  *
110
110
  * `theme` omitted is `ColorSpec.getTruecolor`'s own fallback — black canvas,
111
111
  * white ink, the standard ANSI table. Choosing it there rather than naming a
@@ -130,10 +130,10 @@ export function resolveLook(style, theme) {
130
130
  background,
131
131
  bold: style.bold === true,
132
132
  italic: style.italic === true,
133
- underline: style.underline2 ? "double" : style.underline ? "single" : "none",
133
+ underline: style.doubleUnderline ? "double" : style.underline ? "single" : "none",
134
134
  strike: style.strike === true,
135
135
  overline: style.overline === true,
136
- blink: style.blink2 ? "fast" : style.blink ? "slow" : "none",
136
+ blink: style.rapidBlink ? "fast" : style.blink ? "slow" : "none",
137
137
  outline: style.encircle ? "encircle" : style.frame ? "frame" : "none",
138
138
  href: style.link === undefined ? null : parseHref(style.link),
139
139
  };
@@ -9,11 +9,11 @@
9
9
  *
10
10
  * The geometry is Rich's — a 20px character, a cell 0.61 of that wide, a row
11
11
  * 1.22 of it tall, the same margin and padding — so a screenshot of the same
12
- * program matches the library this ports. The frame's colour is not Rich's:
12
+ * program matches the library this ports. The frame's color is not Rich's:
13
13
  * Rich strokes it white at 35% whatever the theme, which vanishes around a
14
14
  * light canvas. Here it is the theme's ink blended 35% into the canvas — over
15
- * a black canvas the colour Rich draws — and opaque, so the half of the stroke
16
- * lying outside the canvas does not take on the colour of the page around it.
15
+ * a black canvas the color Rich draws — and opaque, so the half of the stroke
16
+ * lying outside the canvas does not take on the color of the page around it.
17
17
  *
18
18
  * Nor is how a glyph lands on its cell. The exporter has no font engine and
19
19
  * does not know which font the viewer will draw with, so no advance width can
@@ -9,11 +9,11 @@
9
9
  *
10
10
  * The geometry is Rich's — a 20px character, a cell 0.61 of that wide, a row
11
11
  * 1.22 of it tall, the same margin and padding — so a screenshot of the same
12
- * program matches the library this ports. The frame's colour is not Rich's:
12
+ * program matches the library this ports. The frame's color is not Rich's:
13
13
  * Rich strokes it white at 35% whatever the theme, which vanishes around a
14
14
  * light canvas. Here it is the theme's ink blended 35% into the canvas — over
15
- * a black canvas the colour Rich draws — and opaque, so the half of the stroke
16
- * lying outside the canvas does not take on the colour of the page around it.
15
+ * a black canvas the color Rich draws — and opaque, so the half of the stroke
16
+ * lying outside the canvas does not take on the color of the page around it.
17
17
  *
18
18
  * Nor is how a glyph lands on its cell. The exporter has no font engine and
19
19
  * does not know which font the viewer will draw with, so no advance width can
@@ -141,7 +141,7 @@ function textSvg({ text, column, cells }, baseline, inVisualOrder) {
141
141
  /**
142
142
  * One run: its glyphs, then its lines and outline over them, in a group whose
143
143
  * class carries the look — so the lines take the glyph's `fill` and blink
144
- * with it. The outline is a stroke, so it names its colour itself.
144
+ * with it. The outline is a stroke, so it names its color itself.
145
145
  */
146
146
  function runSvg(run, className) {
147
147
  const { look } = run;
@@ -616,7 +616,7 @@ function compose(frame, baseStyle) {
616
616
  // The reversal is the whole of the tie-break, not decoration.
617
617
  // `[red][blue]x[/blue][/red]` yields two spans that both start at 0, and a
618
618
  // stable sort leaves those in the order they arrived — closing order,
619
- // innermost first — which is the outer colour winning. Reversed first, the
619
+ // innermost first — which is the outer color winning. Reversed first, the
620
620
  // outer arrives first and the inner repaints it (rich-markup-krk).
621
621
  const spans = [...frame.spans].reverse().sort((a, b) => a.start - b.start);
622
622
  const result = new RichText(frame.plain);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * memo — a string-keyed memo with a size bound: the one cache shape for a
3
3
  * pure computation whose keys a long-running host derives without end. A
4
- * statusline daemon redrawing a time-varying colour parses a new hex string,
4
+ * statusline daemon redrawing a time-varying color parses a new hex string,
5
5
  * matches a new RGB triple, measures a new cell, on every frame; a memo that
6
6
  * never evicts grows by one entry per frame for the life of the process.
7
7
  */
package/dist/core/memo.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * memo — a string-keyed memo with a size bound: the one cache shape for a
3
3
  * pure computation whose keys a long-running host derives without end. A
4
- * statusline daemon redrawing a time-varying colour parses a new hex string,
4
+ * statusline daemon redrawing a time-varying color parses a new hex string,
5
5
  * matches a new RGB triple, measures a new cell, on every frame; a memo that
6
6
  * never evicts grows by one entry per frame for the life of the process.
7
7
  */