@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.
- package/README.md +7 -7
- package/dist/core/animation.d.ts +37 -37
- package/dist/core/animation.js +61 -61
- package/dist/core/ansi.d.ts +4 -4
- package/dist/core/ansi.js +9 -9
- package/dist/core/bidi.js +6 -6
- package/dist/core/cells.d.ts +1 -1
- package/dist/core/cells.js +5 -5
- package/dist/core/clock.d.ts +1 -1
- package/dist/core/color.d.ts +50 -50
- package/dist/core/color.js +69 -69
- package/dist/core/console.d.ts +8 -8
- package/dist/core/console.js +5 -5
- package/dist/core/control-codes.d.ts +3 -3
- package/dist/core/control-codes.js +7 -7
- package/dist/core/easing.d.ts +40 -40
- package/dist/core/easing.js +40 -40
- package/dist/core/env.d.ts +1 -1
- package/dist/core/env.js +1 -1
- package/dist/core/export-html.js +1 -1
- package/dist/core/export-lines.d.ts +11 -11
- package/dist/core/export-lines.js +12 -12
- package/dist/core/export-svg.d.ts +3 -3
- package/dist/core/export-svg.js +4 -4
- package/dist/core/markup.js +1 -1
- package/dist/core/memo.d.ts +1 -1
- package/dist/core/memo.js +1 -1
- package/dist/core/oklch.d.ts +14 -14
- package/dist/core/oklch.js +10 -10
- package/dist/core/orient.d.ts +3 -3
- package/dist/core/orient.js +3 -3
- package/dist/core/paint.d.ts +9 -9
- package/dist/core/paint.js +3 -3
- package/dist/core/pretty.d.ts +1 -1
- package/dist/core/pretty.js +3 -3
- package/dist/core/protocol.d.ts +26 -26
- package/dist/core/protocol.js +22 -22
- package/dist/core/render.d.ts +11 -11
- package/dist/core/render.js +12 -12
- package/dist/core/segment.d.ts +3 -3
- package/dist/core/segment.js +5 -5
- package/dist/core/strip.d.ts +83 -83
- package/dist/core/strip.js +70 -70
- package/dist/core/style.d.ts +20 -20
- package/dist/core/style.js +55 -55
- package/dist/core/text.d.ts +2 -2
- package/dist/core/text.js +5 -5
- package/dist/core/timeline.d.ts +5 -5
- package/dist/core/timeline.js +9 -9
- package/dist/core/tween.d.ts +6 -6
- package/dist/core/tween.js +10 -10
- package/dist/core/view.d.ts +4 -4
- package/dist/core/view.js +12 -12
- package/dist/host/app.d.ts +9 -9
- package/dist/host/app.js +12 -12
- package/dist/host/host-environment.d.ts +2 -2
- package/dist/host/host-environment.js +2 -2
- package/dist/host/index.d.ts +2 -2
- package/dist/host/input.d.ts +7 -7
- package/dist/host/input.js +4 -4
- package/dist/host/terminal-colors.d.ts +2 -2
- package/dist/host/terminal-colors.js +4 -4
- package/dist/host/terminal-host.d.ts +2 -2
- package/dist/host/terminal-host.js +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.js +10 -10
- package/dist/node/prompt.d.ts +1 -1
- package/dist/node/prompt.js +1 -1
- package/dist/node/terminal-host.d.ts +1 -1
- package/dist/node/traceback.js +2 -2
- package/dist/renderables/change.js +2 -2
- package/dist/renderables/effect.d.ts +39 -39
- package/dist/renderables/effect.js +45 -45
- package/dist/renderables/effects.d.ts +81 -81
- package/dist/renderables/effects.js +157 -157
- package/dist/renderables/embed.d.ts +1 -1
- package/dist/renderables/embed.js +2 -2
- package/dist/renderables/flexStrip.d.ts +7 -7
- package/dist/renderables/flexStrip.js +15 -15
- package/dist/renderables/frames.d.ts +6 -6
- package/dist/renderables/frames.js +11 -11
- package/dist/renderables/glyph-effect.d.ts +15 -15
- package/dist/renderables/glyph-effect.js +17 -17
- package/dist/renderables/glyph-effects.d.ts +7 -7
- package/dist/renderables/glyph-effects.js +16 -16
- package/dist/renderables/html-entities.d.ts +1 -1
- package/dist/renderables/html-entities.js +1 -1
- package/dist/renderables/lifecycle.d.ts +4 -4
- package/dist/renderables/lifecycle.js +12 -12
- package/dist/renderables/live.d.ts +2 -2
- package/dist/renderables/live.js +7 -7
- package/dist/renderables/markdown-parse.js +3 -3
- package/dist/renderables/panel.js +3 -3
- package/dist/renderables/progress.d.ts +1 -1
- package/dist/renderables/progress.js +1 -1
- package/dist/renderables/progressBar.d.ts +1 -1
- package/dist/renderables/progressBar.js +6 -6
- package/dist/renderables/prompt.d.ts +1 -1
- package/dist/renderables/scroll.d.ts +1 -1
- package/dist/renderables/scroll.js +3 -3
- package/dist/renderables/spinner.d.ts +4 -4
- package/dist/renderables/spinner.js +10 -10
- package/dist/renderables/syntax.d.ts +2 -2
- package/dist/renderables/syntax.js +2 -2
- package/dist/renderables/table.js +3 -3
- package/dist/renderables/traceback.d.ts +1 -1
- package/dist/renderables/traceback.js +1 -1
- package/dist/renderables/tree.js +3 -3
- package/dist/template-bindings/animation-funcs.d.ts +14 -14
- package/dist/template-bindings/animation-funcs.js +27 -27
- package/dist/template-bindings/color-funcs.d.ts +14 -14
- package/dist/template-bindings/color-funcs.js +25 -25
- package/dist/template-bindings/index.d.ts +9 -9
- package/dist/template-bindings/index.js +9 -9
- package/dist/template-bindings/palette-funcs.d.ts +1 -1
- package/dist/template-bindings/palette-funcs.js +3 -3
- package/dist/template-bindings/style-funcs.d.ts +5 -5
- package/dist/template-bindings/style-funcs.js +16 -16
- package/dist/themes/{transpose.d.ts → adjust.d.ts} +23 -23
- package/dist/themes/{transpose.js → adjust.js} +28 -28
- package/dist/themes/buildPalette.d.ts +3 -3
- package/dist/themes/buildPalette.js +20 -20
- package/dist/themes/colorMath.d.ts +16 -16
- package/dist/themes/colorMath.js +32 -32
- package/dist/themes/data/ansi-tables.d.ts +2 -2
- package/dist/themes/data/ansi-tables.js +2 -2
- package/dist/themes/data/types.d.ts +4 -4
- package/dist/themes/data/types.js +2 -2
- package/dist/themes/palette.d.ts +12 -12
- package/dist/themes/palette.js +16 -16
- package/dist/themes/ramp.d.ts +17 -17
- package/dist/themes/ramp.js +12 -12
- package/dist/themes/registry.js +4 -4
- package/dist/themes/terminalThemes.d.ts +1 -1
- package/dist/themes/terminalThemes.js +1 -1
- package/dist/widgets/button.d.ts +2 -2
- package/dist/widgets/button.js +4 -4
- package/dist/widgets/checkbox.d.ts +2 -2
- package/dist/widgets/checkbox.js +2 -2
- package/dist/widgets/dropdown.d.ts +2 -2
- package/dist/widgets/dropdown.js +3 -3
- package/dist/widgets/event-router.d.ts +6 -6
- package/dist/widgets/event-router.js +2 -2
- package/dist/widgets/focus-manager.d.ts +3 -3
- package/dist/widgets/focus-manager.js +3 -3
- package/dist/widgets/index.d.ts +2 -2
- package/dist/widgets/index.js +1 -1
- package/dist/widgets/ink.d.ts +3 -3
- package/dist/widgets/ink.js +4 -4
- package/dist/widgets/slider.d.ts +2 -2
- package/dist/widgets/static-item.d.ts +2 -2
- package/dist/widgets/text-input.d.ts +2 -2
- package/dist/widgets/text-input.js +5 -5
- package/dist/widgets/themed-widget.js +1 -1
- package/dist/widgets/toggle.d.ts +3 -3
- package/dist/widgets/toggle.js +3 -3
- package/dist/widgets/types.d.ts +6 -6
- package/dist/widgets/types.js +2 -2
- package/dist/widgets/widget-app.d.ts +10 -10
- package/dist/widgets/widget-app.js +8 -8
- package/dist/widgets/widget-base.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -385,19 +385,19 @@ npm run demo
|
|
|
385
385
|
| `npm run demo-inputs` | rich-config | The widgets — checkbox, toggle, slider, dropdown, text input, button — driving a theme and palette viewer. |
|
|
386
386
|
| `npm run demo:dropdown` | dropdown-demo | Three `Dropdown` widgets: a plain one, one filtered as you type, and one whose options change every few seconds. |
|
|
387
387
|
| `npm run template-bindings` | rich-template-bindings | Type a template on the left and watch it render on the right. |
|
|
388
|
-
| `npm run themes-and-color-studio` | themes-and-color-studio | A printed tour of
|
|
389
|
-
| `npm run strip` | rich-strip | Every built-in `
|
|
390
|
-
| `npm run effects-feel` | effects-feel | Shimmer, a gentle pulse on chosen elements, sparkle, a hue wheel, fade-in and a dissolve-out that eddies back before it goes, on a powerline strip and a run of text, at a
|
|
388
|
+
| `npm run themes-and-color-studio` | themes-and-color-studio | A printed tour of colors, palettes, bundled themes, and contrast. Prints once and exits; set any of `EXPORT_HTML=out.html`, `EXPORT_SVG=out.svg` and `EXPORT_TEXT=out.txt` to also save it to each file named. |
|
|
389
|
+
| `npm run strip` | rich-strip | Every built-in `Separator`, printed side by side. Prints once and exits. |
|
|
390
|
+
| `npm run effects-feel` | effects-feel | Shimmer, a gentle pulse on chosen elements, sparkle, a hue wheel, fade-in and a dissolve-out that eddies back before it goes, on a powerline strip and a run of text, at a color depth you choose, with keys to step the frame rate, the demo's pace and the theme while it runs. A demo for agreeing how the effects feel; `npm run effects-feel -- --help` lists the flags and keys. |
|
|
391
391
|
| `npm run glyph-effects` | glyph-effects | Text typed, scrambled until it resolves, crossed by a wave of capitals, and rained and snowed on, each glyph effect in the catalogue and a few made by hand, for twenty seconds. |
|
|
392
|
-
| `npm run attribute-effects` | attribute-effects | A line that blinks, pulses bold, and blinks its underline and its italics on
|
|
393
|
-
| `npm run gradient-effects` | gradient-effects | A
|
|
392
|
+
| `npm run attribute-effects` | attribute-effects | A line that blinks, pulses bold, and blinks its underline and its italics on steps of its own: the attribute effects in the catalogue and two made by hand from `blink`, for twenty seconds. |
|
|
393
|
+
| `npm run gradient-effects` | gradient-effects | A color ramp laid across three rules and three panel borders, one scrolling, one turning its hues, one swaying and settling a quarter turn round, while the titles and the words inside keep their own color, for twenty seconds. |
|
|
394
394
|
| `npm run transitions` | transitions | A build status changing state every three seconds, crossfaded in one panel and wiped in the other, each cell passing through the terminal's ground and nothing beside it moving while it changes, for twenty seconds. |
|
|
395
395
|
| `npm run lifecycle` | lifecycle | A build log whose lines type themselves in as they are appended and leave four seconds later, dissolved, backspaced or scrambled away in turn, each dropped from the log once it is gone, for twenty seconds. |
|
|
396
396
|
| `npm run scroll` | scroll | A marquee crossing a fixed width, a log tail stepping a row a second, and a panel sliding in from the left and holding: one window moved three ways, for twenty seconds. |
|
|
397
|
-
| `npm run animation-playground` | animation-playground | Every kind of motion — tweens, moving ramps, a marching border, glyph and attribute effects, transitions, a list that comes and goes, a marquee, staggers and a blinking caret — on one timeline, with buttons to pause, reverse, scrub, change speed, reduce motion, drop to sixteen
|
|
397
|
+
| `npm run animation-playground` | animation-playground | Every kind of motion — tweens, moving ramps, a marching border, glyph and attribute effects, transitions, a list that comes and goes, a marquee, staggers and a blinking caret — on one timeline, with buttons to pause, reverse, scrub, change speed, reduce motion, drop to sixteen colors or none, and paint at one frame a second or sixty. |
|
|
398
398
|
| `npm run markup-plugins` | rich-markup-plugins | Custom markup tags registered through `MarkupRegistry`. Prints once and exits. |
|
|
399
399
|
| `npm run viewport` | rich-viewport | A selection you move through a list taller than its window with the arrow keys, `j`/`k`, PgUp/PgDn and Home/End, kept in view by `Viewport.ensureVisible`; the mouse wheel scrolls the window, and `q` quits. |
|
|
400
|
-
| `npm run terminal-colors` | terminal-colors | Your terminal asked for its own foreground and background with OSC 10 and OSC 11, shown as swatches, and whether it answered or the
|
|
400
|
+
| `npm run terminal-colors` | terminal-colors | Your terminal asked for its own foreground and background with OSC 10 and OSC 11, shown as swatches, and whether it answered or the colors are assumed. |
|
|
401
401
|
| `npm run terminal-host` | terminal-host | Each key you press printed as the bytes the terminal sends for it, and each resize as the new size — a program written against `TerminalHost` alone. `examples/terminal-host/embed.ts` runs the same program on an xterm.js terminal in your own page. |
|
|
402
402
|
|
|
403
403
|
`Ctrl-C` quits any demo that stays running.
|
package/dist/core/animation.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Animation — a value for a time, and when it next changes: the one type
|
|
3
3
|
* anything in rich-js that changes with time is an instance of.
|
|
4
4
|
*
|
|
5
|
-
* `at(t)` is the value at `t` seconds. `
|
|
5
|
+
* `at(t)` is the value at `t` seconds. `validUntil(t)` is the first moment,
|
|
6
6
|
* on `t`'s own timeline, at which the value may stop being `at(t)`: never
|
|
7
7
|
* before `t`. A later time says the value is held until then, `Infinity`
|
|
8
8
|
* that it never changes again, and `t` itself that it is moving at `t` — it
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
* answer costs a host a frame that draws what the last one did; a late one
|
|
11
11
|
* skips a change. So an animation that cannot say answers `t`, as
|
|
12
12
|
* `continuous` does. An answer that depends on what the frame drew, an
|
|
13
|
-
* effect's, is told by that drawing (`
|
|
13
|
+
* effect's, is told by that drawing (`Reads`). A value drawn as cells carries this answer on every
|
|
14
14
|
* cell (`Style.hold`, both ends of the hold below), so a host holding
|
|
15
|
-
* the composed frame reads it there (`Segment.
|
|
16
|
-
* not drawn — a number, a
|
|
15
|
+
* the composed frame reads it there (`Segment.validUntil`); a value that is
|
|
16
|
+
* not drawn — a number, a color — has `validUntil` as its only way to say
|
|
17
17
|
* when to look again.
|
|
18
18
|
*
|
|
19
|
-
* `
|
|
19
|
+
* `validFrom(t)` is the other end of the same hold: the last moment, never
|
|
20
20
|
* after `t`, at which the value may have become `at(t)` — `-Infinity` if it
|
|
21
|
-
* always was, `t` while it moves. Together they bound the hold, `[
|
|
22
|
-
*
|
|
21
|
+
* always was, `t` while it moves. Together they bound the hold, `[validFrom(t),
|
|
22
|
+
* validUntil(t))`, and the answer may be narrower than the truth and never
|
|
23
23
|
* wider. It is what a host running the animation backwards reads
|
|
24
24
|
* (`./timeline.ts`): run down the timeline, the value next changes where it
|
|
25
25
|
* began. An animation that cannot say answers `t` here too.
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
* which content shows is a fact about time that motion is not: a value with
|
|
39
39
|
* no time could only show a scheduled exit as already gone.
|
|
40
40
|
*
|
|
41
|
-
* The instances already in the tree: a `
|
|
41
|
+
* The instances already in the tree: a `StepSequence` is an animation of which hold
|
|
42
42
|
* is in progress (`./easing.ts`), a `FrameSequence` of the frame shown and a
|
|
43
43
|
* `Spinner` of the spinner drawn (`../renderables/`), and an `Effect` is, for
|
|
44
|
-
* what an element draws in a frame, an animation of how its cells'
|
|
44
|
+
* what an element draws in a frame, an animation of how its cells' colors
|
|
45
45
|
* move (`../renderables/effect.ts`). Every kind of motion is one more.
|
|
46
46
|
*
|
|
47
47
|
* An animation of renderables is a renderable — its face, `placedRender`:
|
|
@@ -67,16 +67,16 @@
|
|
|
67
67
|
* of motion is built from — a constant, a value moving every moment, a map
|
|
68
68
|
* over the value, several at once, one animation after another, and one
|
|
69
69
|
* played again every period — and each says how
|
|
70
|
-
* `
|
|
70
|
+
* `validUntil` composes, so an animation built from them answers it without
|
|
71
71
|
* its author doing anything.
|
|
72
72
|
*
|
|
73
73
|
* Tier 5 of `src/core/`: `./easing.ts`, `./measure.ts`, `./protocol.ts`,
|
|
74
74
|
* `./segment.ts` and `./style.ts`, nothing else. [LAW:one-way-deps]
|
|
75
75
|
*/
|
|
76
|
-
import { type
|
|
76
|
+
import { type StepSequence } from "./easing.js";
|
|
77
77
|
import { type Measurable, type Motion, type Renderable, type RenderOptions } from "./protocol.js";
|
|
78
78
|
import { Segment } from "./segment.js";
|
|
79
|
-
import { Style, type
|
|
79
|
+
import { Style, type ValidityInterval } from "./style.js";
|
|
80
80
|
/**
|
|
81
81
|
* What a frame's drawing said of the hold the element named `key`, drawn at
|
|
82
82
|
* `t`, is in, or nothing if the frame heard of no such drawing: handed to an
|
|
@@ -93,15 +93,15 @@ import { Style, type Hold } from "./style.js";
|
|
|
93
93
|
* frame's one drawing says it, so the answer cannot disagree with what the
|
|
94
94
|
* frame shows.
|
|
95
95
|
*/
|
|
96
|
-
export type
|
|
96
|
+
export type Reads = (t: number, key: string) => ValidityInterval | undefined;
|
|
97
97
|
/** A value of `T` at a time in seconds, and the hold it is in: what every animation answers, whatever its values. */
|
|
98
|
-
export interface
|
|
98
|
+
export interface Behavior<T> {
|
|
99
99
|
/** The value at `t` seconds. */
|
|
100
100
|
at(t: number): T;
|
|
101
101
|
/** The first moment, never before `t`, at which the value may stop being `at(t)`: `t` while it moves, `Infinity` once it never will. */
|
|
102
|
-
|
|
102
|
+
validUntil(t: number, moves?: Reads): number;
|
|
103
103
|
/** The last moment, never after `t`, at which the value may have become `at(t)`: `t` while it moves, `-Infinity` if it always was. */
|
|
104
|
-
|
|
104
|
+
validFrom(t: number, moves?: Reads): number;
|
|
105
105
|
/** This animation with its motion taken out — a loop at its first value, a one-shot cut to its end — drawn in its place under reduced motion. */
|
|
106
106
|
reduced(): Animation<T>;
|
|
107
107
|
}
|
|
@@ -113,12 +113,12 @@ export interface Timed<T> {
|
|
|
113
113
|
* number is no renderable and a `Panel` refuses it; a tween mapped to a
|
|
114
114
|
* `RichText` is one, and a `Panel` holds it.
|
|
115
115
|
*/
|
|
116
|
-
export type Animation<T> =
|
|
116
|
+
export type Animation<T> = Behavior<T> & ([T] extends [Renderable] ? Renderable & Measurable : unknown);
|
|
117
117
|
/** What a frame drawn at a time shows of an animation, and what that says. */
|
|
118
118
|
export interface Shown<T> {
|
|
119
119
|
readonly value: T;
|
|
120
120
|
/** The animation the value is drawn from: the one handed in, or under reduced motion its reduced form. */
|
|
121
|
-
readonly drawn:
|
|
121
|
+
readonly drawn: Behavior<T>;
|
|
122
122
|
/** Whether it is the animation reduced: drawn under reduced motion, changing only where content does. */
|
|
123
123
|
readonly reduced: boolean;
|
|
124
124
|
}
|
|
@@ -130,19 +130,19 @@ export interface Shown<T> {
|
|
|
130
130
|
* the template functions choose here, so a host told once
|
|
131
131
|
* reduces every one.
|
|
132
132
|
*/
|
|
133
|
-
export declare function shownAt<T>(animation:
|
|
133
|
+
export declare function shownAt<T>(animation: Behavior<T>, t: number, motion: Motion): Shown<T>;
|
|
134
134
|
/** The hold `shown`, drawn at `t`, is in: its animation's two answers there, given what its drawing said. */
|
|
135
|
-
export declare function
|
|
135
|
+
export declare function validityOf(shown: Shown<unknown>, t: number, moves?: Reads): ValidityInterval;
|
|
136
136
|
/** The style saying a cell is in `hold`. */
|
|
137
|
-
export declare function
|
|
137
|
+
export declare function stampValidity(validity: ValidityInterval): Style;
|
|
138
138
|
/**
|
|
139
139
|
* `segments`, every one carrying `hold` under whatever it already said: the
|
|
140
|
-
* later `
|
|
140
|
+
* later `validFrom` and the sooner `validUntil` win (`Style.add`), so a
|
|
141
141
|
* frame's hold is the intersection of its cells', narrower than the truth
|
|
142
142
|
* and never wider. [LAW:single-enforcer] The one way a time is put on drawn
|
|
143
143
|
* cells, by whatever draws for a time it knows.
|
|
144
144
|
*/
|
|
145
|
-
export declare function
|
|
145
|
+
export declare function stampValidityFrame(segments: Iterable<Segment>, validity: ValidityInterval): Iterable<Segment>;
|
|
146
146
|
/**
|
|
147
147
|
* The moment a frame drawn under `options` is drawn for: the frame's time,
|
|
148
148
|
* which the host writes once a frame (`RenderOptions.frame`), or with no
|
|
@@ -156,10 +156,10 @@ export declare function frameTimeOf(options: RenderOptions): number;
|
|
|
156
156
|
* An animation placed in the frame `options` draws: its value at the frame's
|
|
157
157
|
* time (`frameTimeOf`, `shownAt`), drawn whole by `draw` under the options it
|
|
158
158
|
* is handed, every segment then stamped with its hold there under whatever
|
|
159
|
-
* its own cells say, and the hold told to the frame (`RenderOptions.
|
|
159
|
+
* its own cells say, and the hold told to the frame (`RenderOptions.onValidity`),
|
|
160
160
|
* because a frame of no cells — an element not yet entered — may have cells
|
|
161
161
|
* later, and must say when without taking a row to say it in. Drawn first,
|
|
162
|
-
* because the hold is asked with what the drawing said (`
|
|
162
|
+
* because the hold is asked with what the drawing said (`Reads`); each report
|
|
163
163
|
* goes on outward too, since a value drawn inside a placement in this value
|
|
164
164
|
* may be a part of an animation placed further out. [LAW:single-enforcer]
|
|
165
165
|
* The one placement: an animation of renderables (`placedRender`), an effect
|
|
@@ -167,25 +167,25 @@ export declare function frameTimeOf(options: RenderOptions): number;
|
|
|
167
167
|
* blink) place through it, so how a time reaches an animation and how its
|
|
168
168
|
* hold reaches the frame is written once.
|
|
169
169
|
*/
|
|
170
|
-
export declare function placed<T>(animation:
|
|
170
|
+
export declare function placed<T>(animation: Behavior<T>, options: RenderOptions, draw: (value: T, options: RenderOptions) => Iterable<Segment>): Iterable<Segment>;
|
|
171
171
|
/**
|
|
172
172
|
* An animation's face, `render`: `placed`, its value drawn as the renderable
|
|
173
173
|
* it is. A container — the library's or a user's — that draws its children
|
|
174
174
|
* through `render` draws an animation among them with no word about time:
|
|
175
175
|
* the hold goes back the way the time came in. [LAW:composability]
|
|
176
176
|
*/
|
|
177
|
-
export declare function placedRender(animation:
|
|
177
|
+
export declare function placedRender(animation: Behavior<unknown>, options: RenderOptions): Iterable<Segment>;
|
|
178
178
|
/**
|
|
179
179
|
* An animation's face, `measure`: what it shows at the frame's time, measured,
|
|
180
|
-
* and its hold there told (`RenderOptions.
|
|
180
|
+
* and its hold there told (`RenderOptions.onValidity`), because a container lays
|
|
181
181
|
* out from the measurement and must lay out again when it changes.
|
|
182
182
|
*/
|
|
183
|
-
export declare function placedMeasure(animation:
|
|
183
|
+
export declare function placedMeasure(animation: Behavior<unknown>, options: RenderOptions): {
|
|
184
184
|
minimum: number;
|
|
185
185
|
maximum: number;
|
|
186
186
|
};
|
|
187
187
|
/** What `Animation.of` makes of `X`: `X`, with the face its values call for. */
|
|
188
|
-
export type Faced<X extends
|
|
188
|
+
export type Faced<X extends Behavior<unknown>> = X & Animation<X extends Behavior<infer T> ? T : never>;
|
|
189
189
|
export declare const Animation: {
|
|
190
190
|
/**
|
|
191
191
|
* `timed` as an animation: every member it carries kept (`membersOf`),
|
|
@@ -196,7 +196,7 @@ export declare const Animation: {
|
|
|
196
196
|
* animation made here has the face, and one whose values are not
|
|
197
197
|
* renderables throws when it is drawn.
|
|
198
198
|
*/
|
|
199
|
-
of<X extends
|
|
199
|
+
of<X extends Behavior<unknown>>(timed: X): Faced<NoInfer<X>>;
|
|
200
200
|
/**
|
|
201
201
|
* Whether `animation` never changes again from `t`: a one-shot that has
|
|
202
202
|
* run, a loop at a depth that shows no motion. [LAW:single-enforcer] The
|
|
@@ -205,7 +205,7 @@ export declare const Animation: {
|
|
|
205
205
|
* once. An early answer the contract allows is a finite one, so `Infinity`
|
|
206
206
|
* is only ever a true never.
|
|
207
207
|
*/
|
|
208
|
-
done(animation:
|
|
208
|
+
done(animation: Behavior<unknown>, t: number): boolean;
|
|
209
209
|
/** `value` at every time, never changing. */
|
|
210
210
|
constant<T>(value: T): Animation<T>;
|
|
211
211
|
/**
|
|
@@ -233,14 +233,14 @@ export declare const Animation: {
|
|
|
233
233
|
* `animation`'s value through `f`, changing when it does. Two values `f`
|
|
234
234
|
* maps alike make an early answer, which the contract allows.
|
|
235
235
|
*/
|
|
236
|
-
map<T, U>(animation:
|
|
236
|
+
map<T, U>(animation: Behavior<T>, f: (value: T) => U): Animation<U>;
|
|
237
237
|
/**
|
|
238
238
|
* Every one of `animations` at once, their values in order, changing when
|
|
239
239
|
* the soonest of them does — so a stack of effects drawn together holds
|
|
240
240
|
* still exactly while each of them does, and reduced each reduced — a
|
|
241
241
|
* stagger with every child arrived. None never changes.
|
|
242
242
|
*/
|
|
243
|
-
all<const T extends readonly unknown[]>(animations: { readonly [K in keyof T]:
|
|
243
|
+
all<const T extends readonly unknown[]>(animations: { readonly [K in keyof T]: Behavior<T[K]>; }): Animation<T>;
|
|
244
244
|
/**
|
|
245
245
|
* `animation` sampled once a hold of `beat`: within a hold, its value at
|
|
246
246
|
* the hold's start, and at each hold's start it moves on. It changes at the
|
|
@@ -253,7 +253,7 @@ export declare const Animation: {
|
|
|
253
253
|
* [LAW:one-source-of-truth] The one stepping rule, for an effect's frames
|
|
254
254
|
* and a transition's schedule alike.
|
|
255
255
|
*/
|
|
256
|
-
|
|
256
|
+
sampleAndHold<T>(animation: Behavior<T>, stepSequence: StepSequence): Animation<T>;
|
|
257
257
|
/**
|
|
258
258
|
* `first` until `seconds`, then `then`, handed the time since it began —
|
|
259
259
|
* each part on its own clock from 0, as every effect is. Before the switch
|
|
@@ -263,7 +263,7 @@ export declare const Animation: {
|
|
|
263
263
|
* shows on time; a one-shot that is the motion into what follows says its
|
|
264
264
|
* own end (`transition`, `../renderables/effects.ts`).
|
|
265
265
|
*/
|
|
266
|
-
sequence<T>(first:
|
|
266
|
+
sequence<T>(first: Behavior<T>, seconds: number, then: Behavior<T>): Animation<T>;
|
|
267
267
|
/**
|
|
268
268
|
* `nth(n)` for every time in the `n`th turn, `[n·period, (n+1)·period)`,
|
|
269
269
|
* handed the time since that turn began — a one-shot played again every
|
|
@@ -276,5 +276,5 @@ export declare const Animation: {
|
|
|
276
276
|
* something new still shows it on time and a one-shot inside cuts to its
|
|
277
277
|
* end there. Nothing is walked through: a call reads only its turn.
|
|
278
278
|
*/
|
|
279
|
-
repeat<T>(period: number, nth: (n: number) =>
|
|
279
|
+
repeat<T>(period: number, nth: (n: number) => Behavior<T>): Animation<T>;
|
|
280
280
|
};
|
package/dist/core/animation.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Animation — a value for a time, and when it next changes: the one type
|
|
3
3
|
* anything in rich-js that changes with time is an instance of.
|
|
4
4
|
*
|
|
5
|
-
* `at(t)` is the value at `t` seconds. `
|
|
5
|
+
* `at(t)` is the value at `t` seconds. `validUntil(t)` is the first moment,
|
|
6
6
|
* on `t`'s own timeline, at which the value may stop being `at(t)`: never
|
|
7
7
|
* before `t`. A later time says the value is held until then, `Infinity`
|
|
8
8
|
* that it never changes again, and `t` itself that it is moving at `t` — it
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
* answer costs a host a frame that draws what the last one did; a late one
|
|
11
11
|
* skips a change. So an animation that cannot say answers `t`, as
|
|
12
12
|
* `continuous` does. An answer that depends on what the frame drew, an
|
|
13
|
-
* effect's, is told by that drawing (`
|
|
13
|
+
* effect's, is told by that drawing (`Reads`). A value drawn as cells carries this answer on every
|
|
14
14
|
* cell (`Style.hold`, both ends of the hold below), so a host holding
|
|
15
|
-
* the composed frame reads it there (`Segment.
|
|
16
|
-
* not drawn — a number, a
|
|
15
|
+
* the composed frame reads it there (`Segment.validUntil`); a value that is
|
|
16
|
+
* not drawn — a number, a color — has `validUntil` as its only way to say
|
|
17
17
|
* when to look again.
|
|
18
18
|
*
|
|
19
|
-
* `
|
|
19
|
+
* `validFrom(t)` is the other end of the same hold: the last moment, never
|
|
20
20
|
* after `t`, at which the value may have become `at(t)` — `-Infinity` if it
|
|
21
|
-
* always was, `t` while it moves. Together they bound the hold, `[
|
|
22
|
-
*
|
|
21
|
+
* always was, `t` while it moves. Together they bound the hold, `[validFrom(t),
|
|
22
|
+
* validUntil(t))`, and the answer may be narrower than the truth and never
|
|
23
23
|
* wider. It is what a host running the animation backwards reads
|
|
24
24
|
* (`./timeline.ts`): run down the timeline, the value next changes where it
|
|
25
25
|
* began. An animation that cannot say answers `t` here too.
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
* which content shows is a fact about time that motion is not: a value with
|
|
39
39
|
* no time could only show a scheduled exit as already gone.
|
|
40
40
|
*
|
|
41
|
-
* The instances already in the tree: a `
|
|
41
|
+
* The instances already in the tree: a `StepSequence` is an animation of which hold
|
|
42
42
|
* is in progress (`./easing.ts`), a `FrameSequence` of the frame shown and a
|
|
43
43
|
* `Spinner` of the spinner drawn (`../renderables/`), and an `Effect` is, for
|
|
44
|
-
* what an element draws in a frame, an animation of how its cells'
|
|
44
|
+
* what an element draws in a frame, an animation of how its cells' colors
|
|
45
45
|
* move (`../renderables/effect.ts`). Every kind of motion is one more.
|
|
46
46
|
*
|
|
47
47
|
* An animation of renderables is a renderable — its face, `placedRender`:
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
* of motion is built from — a constant, a value moving every moment, a map
|
|
68
68
|
* over the value, several at once, one animation after another, and one
|
|
69
69
|
* played again every period — and each says how
|
|
70
|
-
* `
|
|
70
|
+
* `validUntil` composes, so an animation built from them answers it without
|
|
71
71
|
* its author doing anything.
|
|
72
72
|
*
|
|
73
73
|
* Tier 5 of `src/core/`: `./easing.ts`, `./measure.ts`, `./protocol.ts`,
|
|
74
74
|
* `./segment.ts` and `./style.ts`, nothing else. [LAW:one-way-deps]
|
|
75
75
|
*/
|
|
76
|
-
import {
|
|
76
|
+
import { stepSequence, firstReaching, passAt, positiveSeconds } from "./easing.js";
|
|
77
77
|
import { Measurement } from "./measure.js";
|
|
78
78
|
import { isRenderable, render } from "./protocol.js";
|
|
79
79
|
import { Segment } from "./segment.js";
|
|
@@ -92,22 +92,22 @@ export function shownAt(animation, t, motion) {
|
|
|
92
92
|
return { value: drawn.at(t), drawn, reduced };
|
|
93
93
|
}
|
|
94
94
|
/** The hold `shown`, drawn at `t`, is in: its animation's two answers there, given what its drawing said. */
|
|
95
|
-
export function
|
|
96
|
-
return {
|
|
95
|
+
export function validityOf(shown, t, moves) {
|
|
96
|
+
return { validFrom: shown.drawn.validFrom(t, moves), validUntil: shown.drawn.validUntil(t, moves) };
|
|
97
97
|
}
|
|
98
98
|
/** The style saying a cell is in `hold`. */
|
|
99
|
-
export function
|
|
100
|
-
return new Style({
|
|
99
|
+
export function stampValidity(validity) {
|
|
100
|
+
return new Style({ validity });
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* `segments`, every one carrying `hold` under whatever it already said: the
|
|
104
|
-
* later `
|
|
104
|
+
* later `validFrom` and the sooner `validUntil` win (`Style.add`), so a
|
|
105
105
|
* frame's hold is the intersection of its cells', narrower than the truth
|
|
106
106
|
* and never wider. [LAW:single-enforcer] The one way a time is put on drawn
|
|
107
107
|
* cells, by whatever draws for a time it knows.
|
|
108
108
|
*/
|
|
109
|
-
export function
|
|
110
|
-
return Segment.applyStyle(segments,
|
|
109
|
+
export function stampValidityFrame(segments, validity) {
|
|
110
|
+
return Segment.applyStyle(segments, stampValidity(validity));
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* The moment a frame drawn under `options` is drawn for: the frame's time,
|
|
@@ -130,10 +130,10 @@ function drawable(value) {
|
|
|
130
130
|
* An animation placed in the frame `options` draws: its value at the frame's
|
|
131
131
|
* time (`frameTimeOf`, `shownAt`), drawn whole by `draw` under the options it
|
|
132
132
|
* is handed, every segment then stamped with its hold there under whatever
|
|
133
|
-
* its own cells say, and the hold told to the frame (`RenderOptions.
|
|
133
|
+
* its own cells say, and the hold told to the frame (`RenderOptions.onValidity`),
|
|
134
134
|
* because a frame of no cells — an element not yet entered — may have cells
|
|
135
135
|
* later, and must say when without taking a row to say it in. Drawn first,
|
|
136
|
-
* because the hold is asked with what the drawing said (`
|
|
136
|
+
* because the hold is asked with what the drawing said (`Reads`); each report
|
|
137
137
|
* goes on outward too, since a value drawn inside a placement in this value
|
|
138
138
|
* may be a part of an animation placed further out. [LAW:single-enforcer]
|
|
139
139
|
* The one placement: an animation of renderables (`placedRender`), an effect
|
|
@@ -146,15 +146,15 @@ export function* placed(animation, options, draw) {
|
|
|
146
146
|
const shown = shownAt(animation, t, options);
|
|
147
147
|
const said = new Map();
|
|
148
148
|
const part = (at, key) => `${at} ${key}`;
|
|
149
|
-
const
|
|
149
|
+
const onReads = (at, key, validity) => {
|
|
150
150
|
const known = said.get(part(at, key));
|
|
151
|
-
said.set(part(at, key), known === undefined ?
|
|
152
|
-
options.
|
|
151
|
+
said.set(part(at, key), known === undefined ? validity : intersection(known, validity));
|
|
152
|
+
options.onReads?.(at, key, validity);
|
|
153
153
|
};
|
|
154
|
-
const segments = [...draw(shown.value, { ...options,
|
|
155
|
-
const
|
|
156
|
-
options.
|
|
157
|
-
yield*
|
|
154
|
+
const segments = [...draw(shown.value, { ...options, onReads })];
|
|
155
|
+
const validity = validityOf(shown, t, (at, key) => said.get(part(at, key)));
|
|
156
|
+
options.onValidity?.(validity);
|
|
157
|
+
yield* stampValidityFrame(segments, validity);
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* An animation's face, `render`: `placed`, its value drawn as the renderable
|
|
@@ -167,13 +167,13 @@ export function placedRender(animation, options) {
|
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* An animation's face, `measure`: what it shows at the frame's time, measured,
|
|
170
|
-
* and its hold there told (`RenderOptions.
|
|
170
|
+
* and its hold there told (`RenderOptions.onValidity`), because a container lays
|
|
171
171
|
* out from the measurement and must lay out again when it changes.
|
|
172
172
|
*/
|
|
173
173
|
export function placedMeasure(animation, options) {
|
|
174
174
|
const t = frameTimeOf(options);
|
|
175
175
|
const shown = shownAt(animation, t, options);
|
|
176
|
-
options.
|
|
176
|
+
options.onValidity?.(validityOf(shown, t, UNLAID));
|
|
177
177
|
return Measurement.get(options, drawable(shown.value));
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -229,11 +229,11 @@ export const Animation = {
|
|
|
229
229
|
* is only ever a true never.
|
|
230
230
|
*/
|
|
231
231
|
done(animation, t) {
|
|
232
|
-
return animation.
|
|
232
|
+
return animation.validUntil(t) === Number.POSITIVE_INFINITY;
|
|
233
233
|
},
|
|
234
234
|
/** `value` at every time, never changing. */
|
|
235
235
|
constant(value) {
|
|
236
|
-
const still = Animation.of({ at: () => value,
|
|
236
|
+
const still = Animation.of({ at: () => value, validUntil: () => Number.POSITIVE_INFINITY, validFrom: () => Number.NEGATIVE_INFINITY, reduced: () => still });
|
|
237
237
|
return still;
|
|
238
238
|
},
|
|
239
239
|
/**
|
|
@@ -243,8 +243,8 @@ export const Animation = {
|
|
|
243
243
|
cut(before, after) {
|
|
244
244
|
const cut = Animation.of({
|
|
245
245
|
at: (t) => (t < 0 ? before : after),
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
validUntil: (t) => (t < 0 ? 0 : Number.POSITIVE_INFINITY),
|
|
247
|
+
validFrom: (t) => (t < 0 ? Number.NEGATIVE_INFINITY : 0),
|
|
248
248
|
reduced: () => cut,
|
|
249
249
|
});
|
|
250
250
|
return cut;
|
|
@@ -256,7 +256,7 @@ export const Animation = {
|
|
|
256
256
|
* it says its own end (`transition`, `../renderables/effects.ts`).
|
|
257
257
|
*/
|
|
258
258
|
continuous(at) {
|
|
259
|
-
return Animation.of({ at,
|
|
259
|
+
return Animation.of({ at, validUntil: (t) => t, validFrom: (t) => t, reduced: () => Animation.constant(at(0)) });
|
|
260
260
|
},
|
|
261
261
|
/**
|
|
262
262
|
* The time itself, in seconds, moving at every moment: what a clock, a
|
|
@@ -267,7 +267,7 @@ export const Animation = {
|
|
|
267
267
|
* [LAW:types-are-the-program]
|
|
268
268
|
*/
|
|
269
269
|
time() {
|
|
270
|
-
const time = Animation.of({ at: (t) => t,
|
|
270
|
+
const time = Animation.of({ at: (t) => t, validUntil: (t) => t, validFrom: (t) => t, reduced: () => time });
|
|
271
271
|
return time;
|
|
272
272
|
},
|
|
273
273
|
/**
|
|
@@ -277,8 +277,8 @@ export const Animation = {
|
|
|
277
277
|
map(animation, f) {
|
|
278
278
|
return Animation.of({
|
|
279
279
|
at: (t) => f(animation.at(t)),
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
validUntil: (t, moves) => animation.validUntil(t, moves),
|
|
281
|
+
validFrom: (t, moves) => animation.validFrom(t, moves),
|
|
282
282
|
reduced: () => Animation.map(animation.reduced(), f),
|
|
283
283
|
});
|
|
284
284
|
},
|
|
@@ -295,8 +295,8 @@ export const Animation = {
|
|
|
295
295
|
at: (t) => animations.map((animation) => animation.at(t)),
|
|
296
296
|
// A fold, not a spread: a stagger over a table's rows is a list as long
|
|
297
297
|
// as the table, past what an engine takes as arguments.
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
validUntil: (t, moves) => animations.reduce((soonest, animation) => Math.min(soonest, animation.validUntil(t, moves)), Number.POSITIVE_INFINITY),
|
|
299
|
+
validFrom: (t, moves) => animations.reduce((latest, animation) => Math.max(latest, animation.validFrom(t, moves)), Number.NEGATIVE_INFINITY),
|
|
300
300
|
reduced: () => Animation.all(animations.map((animation) => animation.reduced())),
|
|
301
301
|
});
|
|
302
302
|
},
|
|
@@ -312,24 +312,24 @@ export const Animation = {
|
|
|
312
312
|
* [LAW:one-source-of-truth] The one stepping rule, for an effect's frames
|
|
313
313
|
* and a transition's schedule alike.
|
|
314
314
|
*/
|
|
315
|
-
|
|
315
|
+
sampleAndHold(animation, stepSequence) {
|
|
316
316
|
return Animation.of({
|
|
317
|
-
at: (t) => animation.at(
|
|
318
|
-
|
|
319
|
-
const moved = animation.
|
|
317
|
+
at: (t) => animation.at(stepSequence.validFrom(t)),
|
|
318
|
+
validUntil(t, moves) {
|
|
319
|
+
const moved = animation.validUntil(stepSequence.validFrom(t), moves);
|
|
320
320
|
if (moved === Number.POSITIVE_INFINITY)
|
|
321
321
|
return moved;
|
|
322
|
-
const end =
|
|
322
|
+
const end = stepSequence.validUntil(t);
|
|
323
323
|
// The hold boundaries after `t` are `end`, then each hold's end in turn;
|
|
324
324
|
// the value turns at the first one the animation has moved by.
|
|
325
|
-
return moved <= end ? end :
|
|
325
|
+
return moved <= end ? end : stepSequence.validFrom(moved) === moved ? moved : stepSequence.validUntil(moved);
|
|
326
326
|
},
|
|
327
327
|
// The value held now began at this hold's start at the latest: an early
|
|
328
328
|
// answer where the animation had not moved by it, which the contract
|
|
329
329
|
// allows. One that always was never turned on any beat.
|
|
330
|
-
|
|
331
|
-
const began =
|
|
332
|
-
const moved = animation.
|
|
330
|
+
validFrom(t, moves) {
|
|
331
|
+
const began = stepSequence.validFrom(t);
|
|
332
|
+
const moved = animation.validFrom(began, moves);
|
|
333
333
|
return moved === Number.NEGATIVE_INFINITY ? moved : began;
|
|
334
334
|
},
|
|
335
335
|
// Reduced, nothing moves between beats, so there is nothing to sample on them.
|
|
@@ -355,19 +355,19 @@ export const Animation = {
|
|
|
355
355
|
const carried = (local) => (Number.isFinite(local) ? firstReaching(local + seconds, (x) => x - seconds >= local) : local);
|
|
356
356
|
return Animation.of({
|
|
357
357
|
at: (t) => (t - seconds >= 0 ? then.at(t - seconds) : first.at(t)),
|
|
358
|
-
|
|
358
|
+
validUntil(t, moves) {
|
|
359
359
|
const into = t - seconds;
|
|
360
360
|
if (into < 0)
|
|
361
|
-
return Math.min(first.
|
|
362
|
-
return Math.max(t, carried(then.
|
|
361
|
+
return Math.min(first.validUntil(t, moves), seconds);
|
|
362
|
+
return Math.max(t, carried(then.validUntil(into, moves)));
|
|
363
363
|
},
|
|
364
364
|
// After the switch the value became what it is at the switch or when
|
|
365
365
|
// `then`'s did since, whichever is later; before it, when `first`'s did.
|
|
366
|
-
|
|
366
|
+
validFrom(t, moves) {
|
|
367
367
|
const into = t - seconds;
|
|
368
368
|
if (into < 0)
|
|
369
|
-
return first.
|
|
370
|
-
return Math.min(t, Math.max(seconds, carried(then.
|
|
369
|
+
return first.validFrom(t, moves);
|
|
370
|
+
return Math.min(t, Math.max(seconds, carried(then.validFrom(into, moves))));
|
|
371
371
|
},
|
|
372
372
|
reduced: () => Animation.sequence(first.reduced(), seconds, then.reduced()),
|
|
373
373
|
});
|
|
@@ -387,10 +387,10 @@ export const Animation = {
|
|
|
387
387
|
repeat(period, nth) {
|
|
388
388
|
positiveSeconds("Animation.repeat period", period);
|
|
389
389
|
// [LAW:single-enforcer] Which turn a time is in, and how far into it, is
|
|
390
|
-
// `passAt`, the wrap a `beat` and `
|
|
390
|
+
// `passAt`, the wrap a `beat` and `WrapMode.loop` read time through, so a
|
|
391
391
|
// repeat beside a loop of the same period turns on the same float; where
|
|
392
392
|
// a turn begins and the next begins are a one-hold beat's two ends.
|
|
393
|
-
const turns =
|
|
393
|
+
const turns = stepSequence([period]);
|
|
394
394
|
// The turn's moment `local`, on its own clock, carried onto this one: the
|
|
395
395
|
// first float the wrap places at or past `local` in turn `n`, or in a
|
|
396
396
|
// later turn, found as `sequence` carries its second part's.
|
|
@@ -405,14 +405,14 @@ export const Animation = {
|
|
|
405
405
|
const { pass, into } = passAt("Animation.repeat", t, period);
|
|
406
406
|
return nth(pass).at(into);
|
|
407
407
|
},
|
|
408
|
-
|
|
408
|
+
validUntil(t, moves) {
|
|
409
409
|
const { pass, into } = passAt("Animation.repeat", t, period);
|
|
410
|
-
return Math.max(t, Math.min(turns.
|
|
410
|
+
return Math.max(t, Math.min(turns.validUntil(t), carried(pass, turns.validFrom(t), nth(pass).validUntil(into, moves))));
|
|
411
411
|
},
|
|
412
|
-
|
|
412
|
+
validFrom(t, moves) {
|
|
413
413
|
const { pass, into } = passAt("Animation.repeat", t, period);
|
|
414
|
-
const began = turns.
|
|
415
|
-
return Math.min(t, Math.max(began, carried(pass, began, nth(pass).
|
|
414
|
+
const began = turns.validFrom(t);
|
|
415
|
+
return Math.min(t, Math.max(began, carried(pass, began, nth(pass).validFrom(into, moves))));
|
|
416
416
|
},
|
|
417
417
|
reduced: () => Animation.repeat(period, (n) => nth(n).reduced()),
|
|
418
418
|
});
|
package/dist/core/ansi.d.ts
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* own `new Console()`, a CLI's output shown inside a Panel, a log replayed into
|
|
8
8
|
* a Table cell.
|
|
9
9
|
*
|
|
10
|
-
* [LAW:types-are-the-program] Every
|
|
11
|
-
* escape names — `31` the standard
|
|
10
|
+
* [LAW:types-are-the-program] Every color decodes to the `ColorSpec` its
|
|
11
|
+
* escape names — `31` the standard color 1, `38;5;n` palette index n,
|
|
12
12
|
* `38;2;r;g;b` that truecolor — and none is resolved to RGB here. A standard
|
|
13
|
-
*
|
|
13
|
+
* color is a slot in whatever theme draws it, so one captured run exports
|
|
14
14
|
* correctly under a light theme and a dark one; resolved here, dark mode would
|
|
15
|
-
* show light mode's
|
|
15
|
+
* show light mode's colors. Resolution belongs to `export-lines`.
|
|
16
16
|
*
|
|
17
17
|
* [LAW:types-are-the-program] The link is decoder state of its own, beside
|
|
18
18
|
* the SGR style, not a field of it: a terminal ends a hyperlink only at an OSC
|
package/dist/core/ansi.js
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* own `new Console()`, a CLI's output shown inside a Panel, a log replayed into
|
|
8
8
|
* a Table cell.
|
|
9
9
|
*
|
|
10
|
-
* [LAW:types-are-the-program] Every
|
|
11
|
-
* escape names — `31` the standard
|
|
10
|
+
* [LAW:types-are-the-program] Every color decodes to the `ColorSpec` its
|
|
11
|
+
* escape names — `31` the standard color 1, `38;5;n` palette index n,
|
|
12
12
|
* `38;2;r;g;b` that truecolor — and none is resolved to RGB here. A standard
|
|
13
|
-
*
|
|
13
|
+
* color is a slot in whatever theme draws it, so one captured run exports
|
|
14
14
|
* correctly under a light theme and a dark one; resolved here, dark mode would
|
|
15
|
-
* show light mode's
|
|
15
|
+
* show light mode's colors. Resolution belongs to `export-lines`.
|
|
16
16
|
*
|
|
17
17
|
* [LAW:types-are-the-program] The link is decoder state of its own, beside
|
|
18
18
|
* the SGR style, not a field of it: a terminal ends a hyperlink only at an OSC
|
|
@@ -70,7 +70,7 @@ const STRING_ESCAPE = String.raw `\x1b[\]P_^X][^\n]*?(?:\x07|\x1b\\|\x9c|\n|$)`;
|
|
|
70
70
|
const ESCAPES = [
|
|
71
71
|
String.raw `\r|\x1b\[(?<sgr>[0-9;:]*)m|\x1b\[(?<mode>[012]?)K|\x1b\[[0-?]*[ -/]*[@-~]|${STRING_ESCAPE}|\x1b[ -/]*[0-~]`,
|
|
72
72
|
String.raw `(?<underscore>_\x08)?(?<struck>\P{Cc})(?:\x08\k<struck>)+|_\x08(?<underlined>\P{Cc})|\x08`,
|
|
73
|
-
controlClass((disposition) => disposition !== "keep" && disposition !== "
|
|
73
|
+
controlClass((disposition) => disposition !== "keep" && disposition !== "zeroWidth"),
|
|
74
74
|
].join("|");
|
|
75
75
|
const escapes = () => new RegExp(ESCAPES, "gu");
|
|
76
76
|
// A string escape goes first so a line break in its payload stays in the payload.
|
|
@@ -120,7 +120,7 @@ function next(rest) {
|
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* `5;n` or `2;r;g;b`, the arguments of `38` and `48`. A sequence cut short
|
|
123
|
-
* names no
|
|
123
|
+
* names no color, and the codes it did consume are spent, as in Rich.
|
|
124
124
|
*/
|
|
125
125
|
function extendedColor(rest) {
|
|
126
126
|
const kind = next(rest);
|
|
@@ -145,8 +145,8 @@ const SGR_OPS = new Map([
|
|
|
145
145
|
[23, adding({ italic: false })],
|
|
146
146
|
// ECMA-48: 24 is "neither singly nor doubly underlined", 25 "steady" at
|
|
147
147
|
// either speed. Rich's table clears only the first of each pair.
|
|
148
|
-
[24, adding({ underline: false,
|
|
149
|
-
[25, adding({ blink: false,
|
|
148
|
+
[24, adding({ underline: false, doubleUnderline: false })],
|
|
149
|
+
[25, adding({ blink: false, rapidBlink: false })],
|
|
150
150
|
[27, adding({ reverse: false })],
|
|
151
151
|
[28, adding({ conceal: false })],
|
|
152
152
|
[29, adding({ strike: false })],
|
|
@@ -154,7 +154,7 @@ const SGR_OPS = new Map([
|
|
|
154
154
|
[39, adding({ color: ColorSpec.default() })],
|
|
155
155
|
[48, (style, rest) => style.add(new Style({ bgcolor: extendedColor(rest) }))],
|
|
156
156
|
[49, adding({ bgcolor: ColorSpec.default() })],
|
|
157
|
-
// Underline
|
|
157
|
+
// Underline color has no field on Style; its arguments are still spent, or
|
|
158
158
|
// `58;2;1;2;3` would read on as bold, dim and italic.
|
|
159
159
|
[58, (style, rest) => (extendedColor(rest), style)],
|
|
160
160
|
[54, adding({ frame: false, encircle: false })],
|