@promptctl/rich-js 0.27.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 -6
- package/THIRD-PARTY-NOTICES +42 -0
- package/dist/core/animation.d.ts +65 -46
- package/dist/core/animation.js +91 -67
- package/dist/core/ansi.d.ts +19 -12
- package/dist/core/ansi.js +114 -36
- package/dist/core/bidi-data.d.ts +14 -0
- package/dist/core/bidi-data.js +385 -0
- package/dist/core/bidi.d.ts +89 -0
- package/dist/core/bidi.js +615 -0
- package/dist/core/box.d.ts +9 -1
- package/dist/core/box.js +11 -0
- package/dist/core/cell-widths.d.ts +3 -2
- package/dist/core/cell-widths.js +93 -93
- package/dist/core/cells.d.ts +20 -0
- package/dist/core/cells.js +94 -6
- package/dist/core/clock.d.ts +1 -1
- package/dist/core/color.d.ts +56 -57
- package/dist/core/color.js +79 -81
- package/dist/core/console.d.ts +24 -7
- package/dist/core/console.js +27 -8
- package/dist/core/control-codes.d.ts +61 -0
- package/dist/core/control-codes.js +157 -0
- package/dist/core/easing.d.ts +40 -40
- package/dist/core/easing.js +40 -40
- package/dist/core/env.d.ts +6 -0
- package/dist/core/env.js +9 -1
- package/dist/core/export-html.js +5 -4
- package/dist/core/export-lines.d.ts +13 -11
- package/dist/core/export-lines.js +19 -15
- package/dist/core/export-svg.d.ts +3 -3
- package/dist/core/export-svg.js +10 -9
- package/dist/core/json.js +9 -2
- package/dist/core/markup.js +5 -4
- 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 +68 -0
- package/dist/core/orient.js +224 -0
- package/dist/core/osc8.d.ts +12 -5
- package/dist/core/osc8.js +14 -7
- 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 +23 -19
- package/dist/core/protocol.d.ts +47 -26
- package/dist/core/protocol.js +31 -23
- package/dist/core/render.d.ts +19 -14
- package/dist/core/render.js +30 -17
- package/dist/core/seal.d.ts +26 -0
- package/dist/core/seal.js +75 -0
- package/dist/core/segment.d.ts +12 -4
- package/dist/core/segment.js +16 -6
- package/dist/core/strip.d.ts +83 -83
- package/dist/core/strip.js +70 -70
- package/dist/core/style.d.ts +46 -18
- package/dist/core/style.js +92 -56
- package/dist/core/text-order.d.ts +51 -0
- package/dist/core/text-order.js +50 -0
- package/dist/core/text.d.ts +12 -2
- package/dist/core/text.js +136 -90
- package/dist/core/timeline.d.ts +5 -5
- package/dist/core/timeline.js +11 -11
- package/dist/core/tween.d.ts +6 -6
- package/dist/core/tween.js +10 -10
- package/dist/core/view.d.ts +5 -5
- package/dist/core/view.js +15 -14
- package/dist/core/wrap.d.ts +24 -6
- package/dist/core/wrap.js +82 -16
- package/dist/host/app.d.ts +50 -9
- package/dist/host/app.js +120 -15
- package/dist/host/host-environment.d.ts +2 -2
- package/dist/host/host-environment.js +2 -2
- package/dist/host/index.d.ts +3 -2
- package/dist/host/index.js +1 -0
- package/dist/host/input.d.ts +42 -9
- package/dist/host/input.js +91 -7
- package/dist/host/terminal-colors.d.ts +18 -0
- package/dist/host/terminal-colors.js +46 -0
- package/dist/host/terminal-host.d.ts +4 -3
- package/dist/host/terminal-host.js +1 -1
- package/dist/index.d.ts +17 -16
- package/dist/index.js +11 -11
- 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.d.ts +1 -3
- package/dist/renderables/change.js +6 -8
- package/dist/renderables/effect.d.ts +88 -87
- package/dist/renderables/effect.js +124 -114
- package/dist/renderables/effects.d.ts +105 -76
- package/dist/renderables/effects.js +309 -176
- 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 +7 -16
- package/dist/renderables/frames.js +12 -27
- package/dist/renderables/glyph-effect.d.ts +22 -23
- package/dist/renderables/glyph-effect.js +43 -41
- package/dist/renderables/glyph-effects.d.ts +33 -14
- package/dist/renderables/glyph-effects.js +90 -22
- package/dist/renderables/html-entities.d.ts +1 -1
- package/dist/renderables/html-entities.js +1 -1
- package/dist/renderables/lifecycle.d.ts +8 -10
- package/dist/renderables/lifecycle.js +17 -18
- 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/markdown.js +4 -2
- package/dist/renderables/panel.js +7 -5
- package/dist/renderables/progress.d.ts +1 -1
- package/dist/renderables/progress.js +1 -1
- package/dist/renderables/progressBar.d.ts +3 -3
- package/dist/renderables/progressBar.js +21 -18
- 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 +9 -4
- package/dist/renderables/table.js +5 -4
- 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 +60 -29
- package/dist/template-bindings/animation-funcs.js +126 -43
- 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 +16 -14
- package/dist/template-bindings/index.js +17 -14
- package/dist/template-bindings/palette-funcs.d.ts +2 -2
- package/dist/template-bindings/palette-funcs.js +4 -4
- 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 +6 -5
- package/dist/themes/buildPalette.js +22 -22
- 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/index.js +1 -4
- package/dist/themes/data/textual-ansi.js +0 -143
- 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.d.ts +6 -8
- package/dist/themes/registry.js +6 -8
- package/dist/themes/terminalThemes.d.ts +4 -11
- package/dist/themes/terminalThemes.js +31 -47
- package/dist/widgets/button.d.ts +3 -3
- package/dist/widgets/button.js +8 -8
- package/dist/widgets/checkbox.d.ts +2 -2
- package/dist/widgets/checkbox.js +4 -4
- package/dist/widgets/dropdown.d.ts +3 -3
- package/dist/widgets/dropdown.js +7 -5
- 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 +4 -4
- package/dist/widgets/toggle.d.ts +4 -4
- package/dist/widgets/toggle.js +6 -6
- 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 +5 -4
package/README.md
CHANGED
|
@@ -385,18 +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 colors are assumed. |
|
|
400
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. |
|
|
401
402
|
|
|
402
403
|
`Ctrl-C` quits any demo that stays running.
|
package/THIRD-PARTY-NOTICES
CHANGED
|
@@ -107,3 +107,45 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
107
107
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
108
108
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
109
109
|
SOFTWARE.
|
|
110
|
+
|
|
111
|
+
--------------------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
src/core/bidi-data.ts holds data derived from the Unicode Character Database.
|
|
114
|
+
|
|
115
|
+
UNICODE LICENSE V3
|
|
116
|
+
|
|
117
|
+
COPYRIGHT AND PERMISSION NOTICE
|
|
118
|
+
|
|
119
|
+
Copyright (c) 1991-2026 Unicode, Inc.
|
|
120
|
+
|
|
121
|
+
NOTICE TO USER: Carefully read the following legal agreement. BY DOWNLOADING,
|
|
122
|
+
INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR SOFTWARE, YOU
|
|
123
|
+
UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS
|
|
124
|
+
OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY,
|
|
125
|
+
DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
|
|
126
|
+
|
|
127
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
128
|
+
data files and any associated documentation (the "Data Files") or software and
|
|
129
|
+
any associated documentation (the "Software") to deal in the Data Files or
|
|
130
|
+
Software without restriction, including without limitation the rights to use,
|
|
131
|
+
copy, modify, merge, publish, distribute, and/or sell copies of the Data Files
|
|
132
|
+
or Software, and to permit persons to whom the Data Files or Software are
|
|
133
|
+
furnished to do so, provided that either (a) this copyright and permission
|
|
134
|
+
notice appear with all copies of the Data Files or Software, or (b) this
|
|
135
|
+
copyright and permission notice appear in associated Documentation.
|
|
136
|
+
|
|
137
|
+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
138
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
139
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD
|
|
140
|
+
PARTY RIGHTS.
|
|
141
|
+
|
|
142
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE
|
|
143
|
+
LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY
|
|
144
|
+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
145
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
146
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
|
147
|
+
|
|
148
|
+
Except as contained in this notice, the name of a copyright holder shall not be
|
|
149
|
+
used in advertising or otherwise to promote the sale, use or other dealings in
|
|
150
|
+
these Data Files or Software without prior written authorization of the
|
|
151
|
+
copyright holder.
|
package/dist/core/animation.d.ts
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
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
|
|
9
9
|
* changes every frame, however close together they are drawn. An early
|
|
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
|
-
* `continuous` does.
|
|
12
|
+
* `continuous` does. An answer that depends on what the frame drew, an
|
|
13
|
+
* effect's, is told by that drawing (`Reads`). A value drawn as cells carries this answer on every
|
|
13
14
|
* cell (`Style.hold`, both ends of the hold below), so a host holding
|
|
14
|
-
* the composed frame reads it there (`Segment.
|
|
15
|
-
* 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
|
|
16
17
|
* when to look again.
|
|
17
18
|
*
|
|
18
|
-
* `
|
|
19
|
+
* `validFrom(t)` is the other end of the same hold: the last moment, never
|
|
19
20
|
* after `t`, at which the value may have become `at(t)` — `-Infinity` if it
|
|
20
|
-
* always was, `t` while it moves. Together they bound the hold, `[
|
|
21
|
-
*
|
|
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
|
|
22
23
|
* wider. It is what a host running the animation backwards reads
|
|
23
24
|
* (`./timeline.ts`): run down the timeline, the value next changes where it
|
|
24
25
|
* began. An animation that cannot say answers `t` here too.
|
|
@@ -37,10 +38,10 @@
|
|
|
37
38
|
* which content shows is a fact about time that motion is not: a value with
|
|
38
39
|
* no time could only show a scheduled exit as already gone.
|
|
39
40
|
*
|
|
40
|
-
* The instances already in the tree: a `
|
|
41
|
+
* The instances already in the tree: a `StepSequence` is an animation of which hold
|
|
41
42
|
* is in progress (`./easing.ts`), a `FrameSequence` of the frame shown and a
|
|
42
43
|
* `Spinner` of the spinner drawn (`../renderables/`), and an `Effect` is, for
|
|
43
|
-
* 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
|
|
44
45
|
* move (`../renderables/effect.ts`). Every kind of motion is one more.
|
|
45
46
|
*
|
|
46
47
|
* An animation of renderables is a renderable — its face, `placedRender`:
|
|
@@ -66,24 +67,41 @@
|
|
|
66
67
|
* of motion is built from — a constant, a value moving every moment, a map
|
|
67
68
|
* over the value, several at once, one animation after another, and one
|
|
68
69
|
* played again every period — and each says how
|
|
69
|
-
* `
|
|
70
|
+
* `validUntil` composes, so an animation built from them answers it without
|
|
70
71
|
* its author doing anything.
|
|
71
72
|
*
|
|
72
73
|
* Tier 5 of `src/core/`: `./easing.ts`, `./measure.ts`, `./protocol.ts`,
|
|
73
74
|
* `./segment.ts` and `./style.ts`, nothing else. [LAW:one-way-deps]
|
|
74
75
|
*/
|
|
75
|
-
import { type
|
|
76
|
+
import { type StepSequence } from "./easing.js";
|
|
76
77
|
import { type Measurable, type Motion, type Renderable, type RenderOptions } from "./protocol.js";
|
|
77
78
|
import { Segment } from "./segment.js";
|
|
78
|
-
import { Style, type
|
|
79
|
+
import { Style, type ValidityInterval } from "./style.js";
|
|
80
|
+
/**
|
|
81
|
+
* What a frame's drawing said of the hold the element named `key`, drawn at
|
|
82
|
+
* `t`, is in, or nothing if the frame heard of no such drawing: handed to an
|
|
83
|
+
* animation asked about a frame already drawn, so an answer only a drawing
|
|
84
|
+
* knows goes up through the combinators that remapped the time. It reads by
|
|
85
|
+
* `key` and not by the effect, which `reduced()` and a `repeat`'s `nth` build
|
|
86
|
+
* anew at each asking, and by `t`, since one element may be drawn at two
|
|
87
|
+
* moments. Parts sharing both share the intersection of what was drawn:
|
|
88
|
+
* narrower and never wider. A drawing a container hid, by not handing on its
|
|
89
|
+
* options, reads as none and stays early, unless a part sharing its key and
|
|
90
|
+
* `t` told. A measurement, which draws nothing, answers held for good for
|
|
91
|
+
* every part (`UNLAID`). An animation that does not read it ignores it, and
|
|
92
|
+
* one that forwards it to no part stays early. [LAW:one-source-of-truth] The
|
|
93
|
+
* frame's one drawing says it, so the answer cannot disagree with what the
|
|
94
|
+
* frame shows.
|
|
95
|
+
*/
|
|
96
|
+
export type Reads = (t: number, key: string) => ValidityInterval | undefined;
|
|
79
97
|
/** A value of `T` at a time in seconds, and the hold it is in: what every animation answers, whatever its values. */
|
|
80
|
-
export interface
|
|
98
|
+
export interface Behavior<T> {
|
|
81
99
|
/** The value at `t` seconds. */
|
|
82
100
|
at(t: number): T;
|
|
83
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. */
|
|
84
|
-
|
|
102
|
+
validUntil(t: number, moves?: Reads): number;
|
|
85
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. */
|
|
86
|
-
|
|
104
|
+
validFrom(t: number, moves?: Reads): number;
|
|
87
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. */
|
|
88
106
|
reduced(): Animation<T>;
|
|
89
107
|
}
|
|
@@ -95,14 +113,12 @@ export interface Timed<T> {
|
|
|
95
113
|
* number is no renderable and a `Panel` refuses it; a tween mapped to a
|
|
96
114
|
* `RichText` is one, and a `Panel` holds it.
|
|
97
115
|
*/
|
|
98
|
-
export type Animation<T> =
|
|
116
|
+
export type Animation<T> = Behavior<T> & ([T] extends [Renderable] ? Renderable & Measurable : unknown);
|
|
99
117
|
/** What a frame drawn at a time shows of an animation, and what that says. */
|
|
100
118
|
export interface Shown<T> {
|
|
101
119
|
readonly value: T;
|
|
102
|
-
/** The first moment, never before the time drawn at, the value may stop being this. */
|
|
103
|
-
readonly nextChange: number;
|
|
104
120
|
/** The animation the value is drawn from: the one handed in, or under reduced motion its reduced form. */
|
|
105
|
-
readonly drawn:
|
|
121
|
+
readonly drawn: Behavior<T>;
|
|
106
122
|
/** Whether it is the animation reduced: drawn under reduced motion, changing only where content does. */
|
|
107
123
|
readonly reduced: boolean;
|
|
108
124
|
}
|
|
@@ -114,19 +130,19 @@ export interface Shown<T> {
|
|
|
114
130
|
* the template functions choose here, so a host told once
|
|
115
131
|
* reduces every one.
|
|
116
132
|
*/
|
|
117
|
-
export declare function shownAt<T>(animation:
|
|
118
|
-
/** The hold `shown`, drawn at `t`, is in: its animation's two answers there. */
|
|
119
|
-
export declare function
|
|
133
|
+
export declare function shownAt<T>(animation: Behavior<T>, t: number, motion: Motion): Shown<T>;
|
|
134
|
+
/** The hold `shown`, drawn at `t`, is in: its animation's two answers there, given what its drawing said. */
|
|
135
|
+
export declare function validityOf(shown: Shown<unknown>, t: number, moves?: Reads): ValidityInterval;
|
|
120
136
|
/** The style saying a cell is in `hold`. */
|
|
121
|
-
export declare function
|
|
137
|
+
export declare function stampValidity(validity: ValidityInterval): Style;
|
|
122
138
|
/**
|
|
123
139
|
* `segments`, every one carrying `hold` under whatever it already said: the
|
|
124
|
-
* later `
|
|
140
|
+
* later `validFrom` and the sooner `validUntil` win (`Style.add`), so a
|
|
125
141
|
* frame's hold is the intersection of its cells', narrower than the truth
|
|
126
142
|
* and never wider. [LAW:single-enforcer] The one way a time is put on drawn
|
|
127
143
|
* cells, by whatever draws for a time it knows.
|
|
128
144
|
*/
|
|
129
|
-
export declare function
|
|
145
|
+
export declare function stampValidityFrame(segments: Iterable<Segment>, validity: ValidityInterval): Iterable<Segment>;
|
|
130
146
|
/**
|
|
131
147
|
* The moment a frame drawn under `options` is drawn for: the frame's time,
|
|
132
148
|
* which the host writes once a frame (`RenderOptions.frame`), or with no
|
|
@@ -138,35 +154,38 @@ export declare function stampFrame(segments: Iterable<Segment>, hold: Hold): Ite
|
|
|
138
154
|
export declare function frameTimeOf(options: RenderOptions): number;
|
|
139
155
|
/**
|
|
140
156
|
* An animation placed in the frame `options` draws: its value at the frame's
|
|
141
|
-
* time (`frameTimeOf`, `shownAt`), drawn by `draw
|
|
142
|
-
* with its hold there under whatever
|
|
143
|
-
* the frame (`RenderOptions.
|
|
144
|
-
* element not yet entered — may have cells
|
|
145
|
-
* taking a row to say it in.
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
157
|
+
* time (`frameTimeOf`, `shownAt`), drawn whole by `draw` under the options it
|
|
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.onValidity`),
|
|
160
|
+
* because a frame of no cells — an element not yet entered — may have cells
|
|
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 (`Reads`); each report
|
|
163
|
+
* goes on outward too, since a value drawn inside a placement in this value
|
|
164
|
+
* may be a part of an animation placed further out. [LAW:single-enforcer]
|
|
165
|
+
* The one placement: an animation of renderables (`placedRender`), an effect
|
|
166
|
+
* and a widget drawing one cell from an animation of its own (a caret's
|
|
167
|
+
* blink) place through it, so how a time reaches an animation and how its
|
|
168
|
+
* hold reaches the frame is written once.
|
|
150
169
|
*/
|
|
151
|
-
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>;
|
|
152
171
|
/**
|
|
153
172
|
* An animation's face, `render`: `placed`, its value drawn as the renderable
|
|
154
173
|
* it is. A container — the library's or a user's — that draws its children
|
|
155
174
|
* through `render` draws an animation among them with no word about time:
|
|
156
175
|
* the hold goes back the way the time came in. [LAW:composability]
|
|
157
176
|
*/
|
|
158
|
-
export declare function placedRender(animation:
|
|
177
|
+
export declare function placedRender(animation: Behavior<unknown>, options: RenderOptions): Iterable<Segment>;
|
|
159
178
|
/**
|
|
160
179
|
* An animation's face, `measure`: what it shows at the frame's time, measured,
|
|
161
|
-
* and its hold there told (`RenderOptions.
|
|
180
|
+
* and its hold there told (`RenderOptions.onValidity`), because a container lays
|
|
162
181
|
* out from the measurement and must lay out again when it changes.
|
|
163
182
|
*/
|
|
164
|
-
export declare function placedMeasure(animation:
|
|
183
|
+
export declare function placedMeasure(animation: Behavior<unknown>, options: RenderOptions): {
|
|
165
184
|
minimum: number;
|
|
166
185
|
maximum: number;
|
|
167
186
|
};
|
|
168
187
|
/** What `Animation.of` makes of `X`: `X`, with the face its values call for. */
|
|
169
|
-
export type Faced<X extends
|
|
188
|
+
export type Faced<X extends Behavior<unknown>> = X & Animation<X extends Behavior<infer T> ? T : never>;
|
|
170
189
|
export declare const Animation: {
|
|
171
190
|
/**
|
|
172
191
|
* `timed` as an animation: every member it carries kept (`membersOf`),
|
|
@@ -177,7 +196,7 @@ export declare const Animation: {
|
|
|
177
196
|
* animation made here has the face, and one whose values are not
|
|
178
197
|
* renderables throws when it is drawn.
|
|
179
198
|
*/
|
|
180
|
-
of<X extends
|
|
199
|
+
of<X extends Behavior<unknown>>(timed: X): Faced<NoInfer<X>>;
|
|
181
200
|
/**
|
|
182
201
|
* Whether `animation` never changes again from `t`: a one-shot that has
|
|
183
202
|
* run, a loop at a depth that shows no motion. [LAW:single-enforcer] The
|
|
@@ -186,7 +205,7 @@ export declare const Animation: {
|
|
|
186
205
|
* once. An early answer the contract allows is a finite one, so `Infinity`
|
|
187
206
|
* is only ever a true never.
|
|
188
207
|
*/
|
|
189
|
-
done(animation:
|
|
208
|
+
done(animation: Behavior<unknown>, t: number): boolean;
|
|
190
209
|
/** `value` at every time, never changing. */
|
|
191
210
|
constant<T>(value: T): Animation<T>;
|
|
192
211
|
/**
|
|
@@ -214,14 +233,14 @@ export declare const Animation: {
|
|
|
214
233
|
* `animation`'s value through `f`, changing when it does. Two values `f`
|
|
215
234
|
* maps alike make an early answer, which the contract allows.
|
|
216
235
|
*/
|
|
217
|
-
map<T, U>(animation:
|
|
236
|
+
map<T, U>(animation: Behavior<T>, f: (value: T) => U): Animation<U>;
|
|
218
237
|
/**
|
|
219
238
|
* Every one of `animations` at once, their values in order, changing when
|
|
220
239
|
* the soonest of them does — so a stack of effects drawn together holds
|
|
221
240
|
* still exactly while each of them does, and reduced each reduced — a
|
|
222
241
|
* stagger with every child arrived. None never changes.
|
|
223
242
|
*/
|
|
224
|
-
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>;
|
|
225
244
|
/**
|
|
226
245
|
* `animation` sampled once a hold of `beat`: within a hold, its value at
|
|
227
246
|
* the hold's start, and at each hold's start it moves on. It changes at the
|
|
@@ -234,7 +253,7 @@ export declare const Animation: {
|
|
|
234
253
|
* [LAW:one-source-of-truth] The one stepping rule, for an effect's frames
|
|
235
254
|
* and a transition's schedule alike.
|
|
236
255
|
*/
|
|
237
|
-
|
|
256
|
+
sampleAndHold<T>(animation: Behavior<T>, stepSequence: StepSequence): Animation<T>;
|
|
238
257
|
/**
|
|
239
258
|
* `first` until `seconds`, then `then`, handed the time since it began —
|
|
240
259
|
* each part on its own clock from 0, as every effect is. Before the switch
|
|
@@ -244,7 +263,7 @@ export declare const Animation: {
|
|
|
244
263
|
* shows on time; a one-shot that is the motion into what follows says its
|
|
245
264
|
* own end (`transition`, `../renderables/effects.ts`).
|
|
246
265
|
*/
|
|
247
|
-
sequence<T>(first:
|
|
266
|
+
sequence<T>(first: Behavior<T>, seconds: number, then: Behavior<T>): Animation<T>;
|
|
248
267
|
/**
|
|
249
268
|
* `nth(n)` for every time in the `n`th turn, `[n·period, (n+1)·period)`,
|
|
250
269
|
* handed the time since that turn began — a one-shot played again every
|
|
@@ -257,5 +276,5 @@ export declare const Animation: {
|
|
|
257
276
|
* something new still shows it on time and a one-shot inside cuts to its
|
|
258
277
|
* end there. Nothing is walked through: a call reads only its turn.
|
|
259
278
|
*/
|
|
260
|
-
repeat<T>(period: number, nth: (n: number) =>
|
|
279
|
+
repeat<T>(period: number, nth: (n: number) => Behavior<T>): Animation<T>;
|
|
261
280
|
};
|