@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Effected — a renderable whose finished cells' looks —
|
|
2
|
+
* Effected — a renderable whose finished cells' looks — colors and text
|
|
3
3
|
* attributes — pass through an effect at a moment `t`.
|
|
4
4
|
*
|
|
5
5
|
* An effect is, for what an element draws in a frame, an `Animation`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* function `at(t)` returns, but for those a wrapper keeps back — `confined`
|
|
12
12
|
* hands over only the cells its owners drew, so an effect never counts on
|
|
13
13
|
* seeing them all — and for a strip's join cells painted from the items beside
|
|
14
|
-
* them, which are no one's to paint: a seam's
|
|
14
|
+
* them, which are no one's to paint: a seam's colors are its neighbours'
|
|
15
15
|
* edges, so once the effect has painted every other cell, each such cell is
|
|
16
16
|
* resolved again from the cells beside it as the effect left them
|
|
17
17
|
* (`JoinedCell`, `../core/strip.ts`), the way the joiner drew it. Shimmer,
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
* a cell by what the element drew (`EffectCell.pair`), or by nesting one
|
|
23
23
|
* wrapper in another, which measures the inner one's output instead.
|
|
24
24
|
*
|
|
25
|
-
* A cell's look is one value, its
|
|
26
|
-
* (`CellLook`), rather than an attribute stage beside the
|
|
27
|
-
* everything that takes an `Effect` — `confined`, `
|
|
25
|
+
* A cell's look is one value, its colors and its attributes together
|
|
26
|
+
* (`CellLook`), rather than an attribute stage beside the color one, so
|
|
27
|
+
* everything that takes an `Effect` — `confined`, `sampleAndHold`,
|
|
28
28
|
* `Animation.all`, nesting over a glyph effect — takes one that moves
|
|
29
29
|
* attributes with no second copy of itself. `reverse` is the one attribute
|
|
30
30
|
* a look leaves out (`CellAttributes`): it decides which of a style's slots
|
|
31
|
-
* a
|
|
31
|
+
* a color on screen is in, and a swap of the two is already a color move.
|
|
32
32
|
*
|
|
33
33
|
* What the element draws (`Drawn`) — the cells the effect will be handed,
|
|
34
|
-
* and the
|
|
34
|
+
* and the colors of its words — is measured here, in the render, off the
|
|
35
35
|
* same reading of each segment its cells are drawn from, and handed to the
|
|
36
36
|
* effect once a frame. It is what an effect keeping words legible is settled
|
|
37
37
|
* against (`onColors`, `./effects.ts`), so no caller derives it a second time
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
* to the effect and is never cut, and a run cut out of a segment keeps that
|
|
52
52
|
* segment's link and meta and carries its anchor shifted to the run's first
|
|
53
53
|
* cell (`Style.shiftedBy`), so hit testing still finds the owner.
|
|
54
|
-
* - A cell whose
|
|
54
|
+
* - A cell whose colors come back unchanged keeps its original `ColorSpec`,
|
|
55
55
|
* one whose attributes come back as its style set them keeps them, and a
|
|
56
56
|
* segment whose every cell is unchanged is yielded with its look as
|
|
57
57
|
* it was, so the identity effect is byte-identical; what an `Effected` gains is when
|
|
58
58
|
* the frame next changes (`Style.hold`), which writes no byte.
|
|
59
59
|
* Neighbouring cells the output depth
|
|
60
60
|
* writes alike stay one segment: a segment is cut only where the written
|
|
61
|
-
*
|
|
61
|
+
* colors or the attributes change, so two colors that land on one index
|
|
62
62
|
* are one run.
|
|
63
|
-
* - New
|
|
63
|
+
* - New colors are built with `ColorSpec.fromRgba`, never parsed from a
|
|
64
64
|
* string, so no frame adds an entry to a parse cache.
|
|
65
|
-
* - With no
|
|
65
|
+
* - With no color output (`colorSystem: null`) no style is written at all,
|
|
66
66
|
* attributes included, so there is nothing for an effect to change, and
|
|
67
67
|
* the child's segments pass through untouched.
|
|
68
68
|
*
|
|
@@ -70,15 +70,15 @@
|
|
|
70
70
|
* what the child drew, so a sweep crosses the element, not the screen.
|
|
71
71
|
*/
|
|
72
72
|
import { type Anchor } from "../core/anchor.js";
|
|
73
|
-
import { Animation, type
|
|
73
|
+
import { Animation, type Reads, type Shown } from "../core/animation.js";
|
|
74
74
|
import { ColorDepth, type ColorRgba, type TerminalColors } from "../core/color.js";
|
|
75
75
|
import type { Measurable, Renderable, RenderOptions } from "../core/protocol.js";
|
|
76
76
|
import { Segment } from "../core/segment.js";
|
|
77
|
-
import { type Attributes, type
|
|
77
|
+
import { type Attributes, type ValidityInterval } from "../core/style.js";
|
|
78
78
|
/**
|
|
79
79
|
* A cell's foreground and background as they appear on screen — the glyph's
|
|
80
|
-
*
|
|
81
|
-
* Under `reverse` they are the style's two
|
|
80
|
+
* color and the color behind it — which are the colors an effect moves.
|
|
81
|
+
* Under `reverse` they are the style's two colors swapped.
|
|
82
82
|
*/
|
|
83
83
|
export interface CellColors {
|
|
84
84
|
readonly fg: ColorRgba;
|
|
@@ -90,7 +90,7 @@ export interface CellColors {
|
|
|
90
90
|
* one lets a style laid beneath show through, as it does undrawn.
|
|
91
91
|
*/
|
|
92
92
|
export type CellAttributes = Omit<Attributes, "reverse">;
|
|
93
|
-
/** What an effect moves in a cell: its
|
|
93
|
+
/** What an effect moves in a cell: its colors as the screen shows them, and its attributes. */
|
|
94
94
|
export interface CellLook extends CellColors {
|
|
95
95
|
readonly attributes: CellAttributes;
|
|
96
96
|
}
|
|
@@ -107,27 +107,27 @@ export interface EffectCell {
|
|
|
107
107
|
/**
|
|
108
108
|
* The ink and ground the element drew the cell in: what the cell is, where
|
|
109
109
|
* the `CellLook` beside it is what is there now. Under one effect they are
|
|
110
|
-
* the same
|
|
110
|
+
* the same colors; under `layered` (`./effects.ts`) the look is what the
|
|
111
111
|
* layers beneath left, so an effect recognises a cell by its pair and moves
|
|
112
112
|
* its look. [LAW:one-source-of-truth] A pair's `terminal` is what tells a
|
|
113
|
-
*
|
|
113
|
+
* color the terminal resolved from one the element wrote at the same hex.
|
|
114
114
|
*/
|
|
115
115
|
readonly pair: Pair;
|
|
116
116
|
/**
|
|
117
117
|
* Who drew the cell, and where it sits in their output, as
|
|
118
118
|
* `Segment.anchorAt` reads it off a frame: what tells one owner's cells
|
|
119
|
-
* from another's when their
|
|
119
|
+
* from another's when their colors are alike (`confined`).
|
|
120
120
|
*/
|
|
121
121
|
readonly anchor: Anchor | undefined;
|
|
122
122
|
/** The drawing of a box the cell is the frame of (`Style.boxFrame`), or none. */
|
|
123
123
|
readonly boxFrame: object | undefined;
|
|
124
124
|
}
|
|
125
|
-
/** Where a cell sits and who drew it: an `EffectCell` before it has a seed or
|
|
125
|
+
/** Where a cell sits and who drew it: an `EffectCell` before it has a seed or colors. */
|
|
126
126
|
export type Placed = Pick<EffectCell, "row" | "col" | "anchor" | "boxFrame">;
|
|
127
127
|
/**
|
|
128
128
|
* A cell as `Drawn.all` lists it: where it sits and who drew it, the
|
|
129
129
|
* columns its glyph takes, its ink and ground as the screen shows them, and
|
|
130
|
-
* whether a strip's joiner drew it — a seam, no item's, whose
|
|
130
|
+
* whether a strip's joiner drew it — a seam, no item's, whose colors are its
|
|
131
131
|
* neighbours' edges. Each is read off the one look and the one walk the cell
|
|
132
132
|
* is later handed with, so an effect that groups cells into the runs they
|
|
133
133
|
* are drawn in — `wheel`'s segments — reads what the frame hands, never a
|
|
@@ -145,9 +145,9 @@ export interface ListedCell extends Placed {
|
|
|
145
145
|
*/
|
|
146
146
|
export interface Pair extends CellColors {
|
|
147
147
|
/**
|
|
148
|
-
* Whether the glyph's
|
|
148
|
+
* Whether the glyph's color and the color behind it, as the screen shows
|
|
149
149
|
* them, are the terminal's own: a slot the element's style leaves unset or
|
|
150
|
-
* sets to `default`. Such a
|
|
150
|
+
* sets to `default`. Such a color is resolved through the terminal, so its
|
|
151
151
|
* hex can equal one the element wrote; this is what tells them apart.
|
|
152
152
|
*/
|
|
153
153
|
readonly terminal: {
|
|
@@ -156,7 +156,7 @@ export interface Pair extends CellColors {
|
|
|
156
156
|
};
|
|
157
157
|
/**
|
|
158
158
|
* Whether the ink is written in the style's ground slot and the ground in
|
|
159
|
-
* its ink slot. Below truecolor the slot decides what a moved
|
|
159
|
+
* its ink slot. Below truecolor the slot decides what a moved color can
|
|
160
160
|
* land on: a slot set to `default` draws the terminal's foreground in one
|
|
161
161
|
* and its background in the other.
|
|
162
162
|
*/
|
|
@@ -164,7 +164,7 @@ export interface Pair extends CellColors {
|
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
166
|
* What the element an effect wraps draws in one frame: the cells the effect
|
|
167
|
-
* is handed, and the
|
|
167
|
+
* is handed, and the colors the element draws its words in, as the screen
|
|
168
168
|
* shows them — what an effect that must keep the words legible is measured
|
|
169
169
|
* against. A word cell is one whose glyph is not blank and that a strip's
|
|
170
170
|
* joiner did not draw (`JOIN`): a seam's ink is the fill beside it, not words.
|
|
@@ -195,11 +195,11 @@ export interface Drawn {
|
|
|
195
195
|
cells(): readonly ListedCell[];
|
|
196
196
|
/** Every distinct ink and ground of a word cell. */
|
|
197
197
|
readonly pairs: readonly Pair[];
|
|
198
|
-
/** The
|
|
198
|
+
/** The colors the element sets itself in its word cells, by hex: never the terminal's, whatever its hex. */
|
|
199
199
|
readonly colors: ReadonlySet<string>;
|
|
200
200
|
/** Of `colors`, the ones a word cell has for its ground. */
|
|
201
201
|
readonly fills: ReadonlySet<string>;
|
|
202
|
-
/** The depth the frame is written at: below truecolor a moved
|
|
202
|
+
/** The depth the frame is written at: below truecolor a moved color lands on a palette color. */
|
|
203
203
|
readonly depth: ColorDepth;
|
|
204
204
|
/** The terminal the frame is drawn on. */
|
|
205
205
|
readonly terminal: TerminalColors;
|
|
@@ -212,7 +212,7 @@ export type EffectFrame = (look: CellLook, cell: EffectCell) => CellLook;
|
|
|
212
212
|
* frame by the shape of the call, never by a cache asking whether this cell's
|
|
213
213
|
* frame is the last one's.
|
|
214
214
|
*
|
|
215
|
-
* Its `
|
|
215
|
+
* Its `validUntil` is when the frame next changes: a stepped effect its next
|
|
216
216
|
* step's start, a transition `t` until it is done and `Infinity` after, a
|
|
217
217
|
* loop that holds every cell still, at the frame's depth or with nothing in
|
|
218
218
|
* it to move, `Infinity` there, and a loop that moves `t`
|
|
@@ -234,13 +234,13 @@ export interface EffectedOptions {
|
|
|
234
234
|
* good over no cell, since it changes how cells look and never which exist.
|
|
235
235
|
* What drew none says for itself when it will (a lifecycle not yet entered).
|
|
236
236
|
*/
|
|
237
|
-
export declare function
|
|
237
|
+
export declare function validityOver(anyCell: boolean, shown: Shown<unknown>, t: number): ValidityInterval;
|
|
238
238
|
/**
|
|
239
239
|
* An `Effected` at `t`, or an element through an effect at a time an
|
|
240
240
|
* animation's `at` was handed — a lifecycle's time since it entered: `renderable`
|
|
241
241
|
* with its cells' looks passed through `effect` at `t`. Its cells say nothing
|
|
242
242
|
* of when that changes, since `t` is not the frame's clock: it tells the hold
|
|
243
|
-
* it drew in (`RenderOptions.
|
|
243
|
+
* it drew in (`RenderOptions.onReads`), and whatever placed the animation
|
|
244
244
|
* carries that onto the frame's and stamps it. [LAW:one-type-per-behavior]
|
|
245
245
|
*/
|
|
246
246
|
export declare class Recolored implements Renderable, Measurable {
|
|
@@ -268,7 +268,7 @@ export declare class Recolored implements Renderable, Measurable {
|
|
|
268
268
|
maximum: number;
|
|
269
269
|
};
|
|
270
270
|
/**
|
|
271
|
-
* The specs that draw a cell's slot
|
|
271
|
+
* The specs that draw a cell's slot colors `to` where the segment drew
|
|
272
272
|
* `from` with `wire`: each moved slot in the spec `movedSpecs` writes it
|
|
273
273
|
* in, the rest as `wire` wrote them.
|
|
274
274
|
*/
|
|
@@ -281,7 +281,7 @@ export declare class Recolored implements Renderable, Measurable {
|
|
|
281
281
|
* nothing drawn its answer to when it changes is `t`, at every time: early,
|
|
282
282
|
* never false. Placed, on its own or as a part of any combinator, it says
|
|
283
283
|
* exactly: the frame's drawing told the effect's hold at that time and the
|
|
284
|
-
* output's depth (`
|
|
284
|
+
* output's depth (`Reads`), so at a depth that shows no motion a loop says it
|
|
285
285
|
* never changes there and the host sleeps.
|
|
286
286
|
*/
|
|
287
287
|
export declare class Effected implements Animation<Renderable> {
|
|
@@ -291,8 +291,8 @@ export declare class Effected implements Animation<Renderable> {
|
|
|
291
291
|
constructor(renderable: Renderable, effect: Effect, options: EffectedOptions);
|
|
292
292
|
/** The element through the effect at `t`, unstamped. */
|
|
293
293
|
at(t: number): Recolored;
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
validUntil(t: number, moves?: Reads): number;
|
|
295
|
+
validFrom(t: number, moves?: Reads): number;
|
|
296
296
|
/** The element under the effect with its motion taken out. */
|
|
297
297
|
reduced(): Effected;
|
|
298
298
|
/** Drawn at the frame's time, its cells stamped with the effect's exact hold there. */
|
|
@@ -302,9 +302,9 @@ export declare class Effected implements Animation<Renderable> {
|
|
|
302
302
|
maximum: number;
|
|
303
303
|
};
|
|
304
304
|
/**
|
|
305
|
-
* The
|
|
305
|
+
* The colors the screen shows for `pair` once it is drawn moved to `to`,
|
|
306
306
|
* both as the screen shows them, at `depth` on `terminal`: what an effect
|
|
307
|
-
* moving a pair's
|
|
307
|
+
* moving a pair's colors leaves its words reading in.
|
|
308
308
|
* [LAW:one-source-of-truth] Read through `movedSpecs`, the one writer a
|
|
309
309
|
* moved slot is written with.
|
|
310
310
|
*/
|
|
@@ -312,7 +312,7 @@ export declare class Effected implements Animation<Renderable> {
|
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* A cell's seed: FNV-1a of the element's key and the cell's position, scaled
|
|
315
|
-
* into [0, 1). [LAW:one-source-of-truth] One rule for a
|
|
315
|
+
* into [0, 1). [LAW:one-source-of-truth] One rule for a color effect's seeds
|
|
316
316
|
* and a glyph effect's, so one element under both twinkles from one seed.
|
|
317
317
|
*/
|
|
318
318
|
export declare function cellSeed(key: string, row: number, col: number): number;
|
|
@@ -329,13 +329,13 @@ export interface WalkedGlyph {
|
|
|
329
329
|
* column, and its anchor shifted to that column as `Style.shiftedBy` shifts
|
|
330
330
|
* a run's. A control segment draws nothing and has none.
|
|
331
331
|
* [LAW:one-source-of-truth] The one walk: what `Drawn.cells` lists, what the
|
|
332
|
-
* render hands a
|
|
332
|
+
* render hands a color effect, and what a glyph effect (`./glyph-effect.ts`)
|
|
333
333
|
* is handed are all read off it.
|
|
334
334
|
*/
|
|
335
335
|
export declare function walkGlyphs(segments: readonly Segment[]): (readonly WalkedGlyph[])[];
|
|
336
336
|
/**
|
|
337
337
|
* Whether `text` draws ink: anything but blanks. [LAW:one-source-of-truth]
|
|
338
|
-
* The one test, so the words a
|
|
338
|
+
* The one test, so the words a color effect lights are the words a glyph
|
|
339
339
|
* effect (`./glyph-effects.ts`) scrambles and its particles pass behind.
|
|
340
340
|
*/
|
|
341
341
|
export declare function inked(text: string): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Effected — a renderable whose finished cells' looks —
|
|
2
|
+
* Effected — a renderable whose finished cells' looks — colors and text
|
|
3
3
|
* attributes — pass through an effect at a moment `t`.
|
|
4
4
|
*
|
|
5
5
|
* An effect is, for what an element draws in a frame, an `Animation`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* function `at(t)` returns, but for those a wrapper keeps back — `confined`
|
|
12
12
|
* hands over only the cells its owners drew, so an effect never counts on
|
|
13
13
|
* seeing them all — and for a strip's join cells painted from the items beside
|
|
14
|
-
* them, which are no one's to paint: a seam's
|
|
14
|
+
* them, which are no one's to paint: a seam's colors are its neighbours'
|
|
15
15
|
* edges, so once the effect has painted every other cell, each such cell is
|
|
16
16
|
* resolved again from the cells beside it as the effect left them
|
|
17
17
|
* (`JoinedCell`, `../core/strip.ts`), the way the joiner drew it. Shimmer,
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
* a cell by what the element drew (`EffectCell.pair`), or by nesting one
|
|
23
23
|
* wrapper in another, which measures the inner one's output instead.
|
|
24
24
|
*
|
|
25
|
-
* A cell's look is one value, its
|
|
26
|
-
* (`CellLook`), rather than an attribute stage beside the
|
|
27
|
-
* everything that takes an `Effect` — `confined`, `
|
|
25
|
+
* A cell's look is one value, its colors and its attributes together
|
|
26
|
+
* (`CellLook`), rather than an attribute stage beside the color one, so
|
|
27
|
+
* everything that takes an `Effect` — `confined`, `sampleAndHold`,
|
|
28
28
|
* `Animation.all`, nesting over a glyph effect — takes one that moves
|
|
29
29
|
* attributes with no second copy of itself. `reverse` is the one attribute
|
|
30
30
|
* a look leaves out (`CellAttributes`): it decides which of a style's slots
|
|
31
|
-
* a
|
|
31
|
+
* a color on screen is in, and a swap of the two is already a color move.
|
|
32
32
|
*
|
|
33
33
|
* What the element draws (`Drawn`) — the cells the effect will be handed,
|
|
34
|
-
* and the
|
|
34
|
+
* and the colors of its words — is measured here, in the render, off the
|
|
35
35
|
* same reading of each segment its cells are drawn from, and handed to the
|
|
36
36
|
* effect once a frame. It is what an effect keeping words legible is settled
|
|
37
37
|
* against (`onColors`, `./effects.ts`), so no caller derives it a second time
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
* to the effect and is never cut, and a run cut out of a segment keeps that
|
|
52
52
|
* segment's link and meta and carries its anchor shifted to the run's first
|
|
53
53
|
* cell (`Style.shiftedBy`), so hit testing still finds the owner.
|
|
54
|
-
* - A cell whose
|
|
54
|
+
* - A cell whose colors come back unchanged keeps its original `ColorSpec`,
|
|
55
55
|
* one whose attributes come back as its style set them keeps them, and a
|
|
56
56
|
* segment whose every cell is unchanged is yielded with its look as
|
|
57
57
|
* it was, so the identity effect is byte-identical; what an `Effected` gains is when
|
|
58
58
|
* the frame next changes (`Style.hold`), which writes no byte.
|
|
59
59
|
* Neighbouring cells the output depth
|
|
60
60
|
* writes alike stay one segment: a segment is cut only where the written
|
|
61
|
-
*
|
|
61
|
+
* colors or the attributes change, so two colors that land on one index
|
|
62
62
|
* are one run.
|
|
63
|
-
* - New
|
|
63
|
+
* - New colors are built with `ColorSpec.fromRgba`, never parsed from a
|
|
64
64
|
* string, so no frame adds an entry to a parse cache.
|
|
65
|
-
* - With no
|
|
65
|
+
* - With no color output (`colorSystem: null`) no style is written at all,
|
|
66
66
|
* attributes included, so there is nothing for an effect to change, and
|
|
67
67
|
* the child's segments pass through untouched.
|
|
68
68
|
*
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
* what the child drew, so a sweep crosses the element, not the screen.
|
|
71
71
|
*/
|
|
72
72
|
import { drawnBy, shiftAnchor } from "../core/anchor.js";
|
|
73
|
-
import { Animation,
|
|
73
|
+
import { Animation, validityOf, placedRender, shownAt } from "../core/animation.js";
|
|
74
74
|
import { cellLen, graphemes } from "../core/cells.js";
|
|
75
75
|
import { ColorDepth, ColorSpec, resolveTerminal, SURFACE_BLACK } from "../core/color.js";
|
|
76
76
|
import { fnv1a } from "../core/fnv1a.js";
|
|
@@ -85,15 +85,15 @@ import { finiteTime } from "../core/easing.js";
|
|
|
85
85
|
* good over no cell, since it changes how cells look and never which exist.
|
|
86
86
|
* What drew none says for itself when it will (a lifecycle not yet entered).
|
|
87
87
|
*/
|
|
88
|
-
export function
|
|
89
|
-
return anyCell ?
|
|
88
|
+
export function validityOver(anyCell, shown, t) {
|
|
89
|
+
return anyCell ? validityOf(shown, t) : NEVER_CHANGES;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* An `Effected` at `t`, or an element through an effect at a time an
|
|
93
93
|
* animation's `at` was handed — a lifecycle's time since it entered: `renderable`
|
|
94
94
|
* with its cells' looks passed through `effect` at `t`. Its cells say nothing
|
|
95
95
|
* of when that changes, since `t` is not the frame's clock: it tells the hold
|
|
96
|
-
* it drew in (`RenderOptions.
|
|
96
|
+
* it drew in (`RenderOptions.onReads`), and whatever placed the animation
|
|
97
97
|
* carries that onto the frame's and stamps it. [LAW:one-type-per-behavior]
|
|
98
98
|
*/
|
|
99
99
|
export class Recolored {
|
|
@@ -109,15 +109,15 @@ export class Recolored {
|
|
|
109
109
|
}
|
|
110
110
|
render(options) {
|
|
111
111
|
const segments = render(this.renderable, options);
|
|
112
|
-
// With no
|
|
112
|
+
// With no color output nothing the effect does is written, so the child
|
|
113
113
|
// is what is shown, and it changes when the child says it does.
|
|
114
114
|
if (options.colorSystem === null) {
|
|
115
|
-
options.
|
|
115
|
+
options.onReads?.(this._t, this.key, NEVER_CHANGES);
|
|
116
116
|
return segments;
|
|
117
117
|
}
|
|
118
118
|
// No depth named is no downgrade, as `drawnColors` reads it.
|
|
119
119
|
const depth = options.colorSystem ?? ColorDepth.TRUECOLOR;
|
|
120
|
-
// [LAW:one-source-of-truth] Every
|
|
120
|
+
// [LAW:one-source-of-truth] Every color below resolves on the frame's
|
|
121
121
|
// terminal, so two effects in a frame cannot disagree.
|
|
122
122
|
const terminal = resolveTerminal(options.terminal, depth);
|
|
123
123
|
// [LAW:one-source-of-truth] The frame is measured before any cell is
|
|
@@ -127,7 +127,7 @@ export class Recolored {
|
|
|
127
127
|
const walked = walk(looked);
|
|
128
128
|
const drawn = measured(looked, () => walked, depth, terminal);
|
|
129
129
|
const shown = shownAt(this.effect(drawn), this._t, options);
|
|
130
|
-
options.
|
|
130
|
+
options.onReads?.(this._t, this.key, validityOver(walked.some(({ glyphs }) => glyphs.some(({ cell }) => cell !== undefined)), shown, this._t));
|
|
131
131
|
return this._recolored(walked, shown.value, drawn);
|
|
132
132
|
}
|
|
133
133
|
*_recolored(walked, frame, drawn) {
|
|
@@ -158,7 +158,7 @@ export class Recolored {
|
|
|
158
158
|
*_repainted(segment, look, glyphs, moved, drawn) {
|
|
159
159
|
const { style: base, wire, slots, pair, attributes } = look;
|
|
160
160
|
// [LAW:one-source-of-truth] A run is cells the wire writes alike: each
|
|
161
|
-
// cell is drawn at the output depth first and merged on the
|
|
161
|
+
// cell is drawn at the output depth first and merged on the colors that
|
|
162
162
|
// writes and on its attributes, so two truecolors landing on one index
|
|
163
163
|
// stay one run. A cell the effect gave its neighbour's look is drawn as
|
|
164
164
|
// that neighbour was.
|
|
@@ -209,9 +209,9 @@ export class Recolored {
|
|
|
209
209
|
// slot in, the spec the joiner reads of an item drawn so: a palette slot
|
|
210
210
|
// stays that slot, which the lift tells apart by number, never an RGB read
|
|
211
211
|
// back through a palette the writer did not use. Only the terminal's own
|
|
212
|
-
//
|
|
212
|
+
// color names none, and the terminal the effect draws on says what it is.
|
|
213
213
|
// Each such spec is kept, so the writer below knows it by identity: an
|
|
214
|
-
// RGB a blend or another
|
|
214
|
+
// RGB a blend or another color lands on is not the terminal's own.
|
|
215
215
|
const terminals = new Set();
|
|
216
216
|
const edgeOf = (spec, foreground) => {
|
|
217
217
|
if (!spec?.isDefault)
|
|
@@ -253,9 +253,9 @@ export class Recolored {
|
|
|
253
253
|
// [LAW:one-source-of-truth] Each slot is written as the depth writes what
|
|
254
254
|
// it resolved to, by the writer the lift measured it with
|
|
255
255
|
// (`Style.drawnColors`), so a lifted ink stands off its ground in the bytes
|
|
256
|
-
// as it did when measured. A slot resolved to the
|
|
256
|
+
// as it did when measured. A slot resolved to the color it was before
|
|
257
257
|
// keeps the spec it was written in, as a painted cell's unmoved slot does.
|
|
258
|
-
// The terminal's own
|
|
258
|
+
// The terminal's own colors, which stand in a moved edge as the spec of
|
|
259
259
|
// the RGB the effect's terminal gives them and reach a slot unchanged or
|
|
260
260
|
// not at all, are written by the writer that wrote them on the item
|
|
261
261
|
// beside, on that terminal, which writes its own ground below truecolor as
|
|
@@ -268,7 +268,7 @@ export class Recolored {
|
|
|
268
268
|
if (sameSpec(now, before))
|
|
269
269
|
return wrote;
|
|
270
270
|
// [LAW:no-silent-failure] Unreachable: a move only fills an edge in, so
|
|
271
|
-
// a slot that resolved to a
|
|
271
|
+
// a slot that resolved to a color when drawn resolves to one after.
|
|
272
272
|
if (now === undefined)
|
|
273
273
|
throw new Error(`a seam cell resolved to ${before?.name ?? "nothing"} when drawn and to nothing after an effect moved its neighbours`);
|
|
274
274
|
return terminals.has(now) ? round : drew;
|
|
@@ -283,7 +283,7 @@ export class Recolored {
|
|
|
283
283
|
return Measurement.get(options, this.renderable);
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
|
-
* The specs that draw a cell's slot
|
|
286
|
+
* The specs that draw a cell's slot colors `to` where the segment drew
|
|
287
287
|
* `from` with `wire`: each moved slot in the spec `movedSpecs` writes it
|
|
288
288
|
* in, the rest as `wire` wrote them.
|
|
289
289
|
*/
|
|
@@ -299,7 +299,7 @@ export class Recolored {
|
|
|
299
299
|
* nothing drawn its answer to when it changes is `t`, at every time: early,
|
|
300
300
|
* never false. Placed, on its own or as a part of any combinator, it says
|
|
301
301
|
* exactly: the frame's drawing told the effect's hold at that time and the
|
|
302
|
-
* output's depth (`
|
|
302
|
+
* output's depth (`Reads`), so at a depth that shows no motion a loop says it
|
|
303
303
|
* never changes there and the host sleeps.
|
|
304
304
|
*/
|
|
305
305
|
export class Effected {
|
|
@@ -315,11 +315,11 @@ export class Effected {
|
|
|
315
315
|
at(t) {
|
|
316
316
|
return new Recolored(this.renderable, this.effect, { t, key: this.key });
|
|
317
317
|
}
|
|
318
|
-
|
|
319
|
-
return moves?.(t, this.key)?.
|
|
318
|
+
validUntil(t, moves) {
|
|
319
|
+
return moves?.(t, this.key)?.validUntil ?? t;
|
|
320
320
|
}
|
|
321
|
-
|
|
322
|
-
return moves?.(t, this.key)?.
|
|
321
|
+
validFrom(t, moves) {
|
|
322
|
+
return moves?.(t, this.key)?.validFrom ?? t;
|
|
323
323
|
}
|
|
324
324
|
/** The element under the effect with its motion taken out. */
|
|
325
325
|
reduced() {
|
|
@@ -334,9 +334,9 @@ export class Effected {
|
|
|
334
334
|
return Measurement.get(options, this.renderable);
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
|
-
* The
|
|
337
|
+
* The colors the screen shows for `pair` once it is drawn moved to `to`,
|
|
338
338
|
* both as the screen shows them, at `depth` on `terminal`: what an effect
|
|
339
|
-
* moving a pair's
|
|
339
|
+
* moving a pair's colors leaves its words reading in.
|
|
340
340
|
* [LAW:one-source-of-truth] Read through `movedSpecs`, the one writer a
|
|
341
341
|
* moved slot is written with.
|
|
342
342
|
*/
|
|
@@ -348,7 +348,7 @@ export class Effected {
|
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
350
|
* A cell's seed: FNV-1a of the element's key and the cell's position, scaled
|
|
351
|
-
* into [0, 1). [LAW:one-source-of-truth] One rule for a
|
|
351
|
+
* into [0, 1). [LAW:one-source-of-truth] One rule for a color effect's seeds
|
|
352
352
|
* and a glyph effect's, so one element under both twinkles from one seed.
|
|
353
353
|
*/
|
|
354
354
|
export function cellSeed(key, row, col) {
|
|
@@ -374,7 +374,7 @@ function looks(segments, depth, terminal) {
|
|
|
374
374
|
* column, and its anchor shifted to that column as `Style.shiftedBy` shifts
|
|
375
375
|
* a run's. A control segment draws nothing and has none.
|
|
376
376
|
* [LAW:one-source-of-truth] The one walk: what `Drawn.cells` lists, what the
|
|
377
|
-
* render hands a
|
|
377
|
+
* render hands a color effect, and what a glyph effect (`./glyph-effect.ts`)
|
|
378
378
|
* is handed are all read off it.
|
|
379
379
|
*/
|
|
380
380
|
export function walkGlyphs(segments) {
|
|
@@ -398,7 +398,7 @@ export function walkGlyphs(segments) {
|
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
400
|
* Whether `text` draws ink: anything but blanks. [LAW:one-source-of-truth]
|
|
401
|
-
* The one test, so the words a
|
|
401
|
+
* The one test, so the words a color effect lights are the words a glyph
|
|
402
402
|
* effect (`./glyph-effects.ts`) scrambles and its particles pass behind.
|
|
403
403
|
*/
|
|
404
404
|
export function inked(text) {
|
|
@@ -450,7 +450,7 @@ function edgesBeside(walked, drawings) {
|
|
|
450
450
|
}
|
|
451
451
|
/** Whether `style` draws in its ink on a blank glyph: a line under, through or over it, or a frame round it. */
|
|
452
452
|
function drawsLines(style) {
|
|
453
|
-
return [style.underline, style.
|
|
453
|
+
return [style.underline, style.doubleUnderline, style.strike, style.overline, style.frame, style.encircle].some((on) => on === true);
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
456
|
* What `looked` draws: `Drawn`'s measure, taken once per frame. Its `all`
|
|
@@ -475,7 +475,7 @@ function measured(looked, walked, depth, terminal) {
|
|
|
475
475
|
let shown;
|
|
476
476
|
const words = looked.flatMap(({ segment, look }) => (look !== undefined && inked(segment.text) && !look.seam ? [look.pair] : []));
|
|
477
477
|
const pairs = [...new Map(words.map((pair) => [`${pair.fg.hex}/${pair.bg.hex}/${pair.terminal.fg}/${pair.terminal.bg}/${pair.reverse}`, pair])).values()];
|
|
478
|
-
// [LAW:one-source-of-truth] A slot the terminal fills is no
|
|
478
|
+
// [LAW:one-source-of-truth] A slot the terminal fills is no color of the element's, whatever its hex.
|
|
479
479
|
const own = (slot) => pairs.flatMap((pair) => (pair.terminal[slot] ? [] : [pair[slot].hex]));
|
|
480
480
|
return {
|
|
481
481
|
all: () => (all ??= listed().map(({ cell }) => cell)),
|
|
@@ -527,29 +527,29 @@ export function drawnOf(segments, depth, terminal) {
|
|
|
527
527
|
return measured(looked, () => walk(looked), depth, on);
|
|
528
528
|
}
|
|
529
529
|
/**
|
|
530
|
-
* A style's
|
|
530
|
+
* A style's color slots as the screen shows them, or the reverse: `reverse`
|
|
531
531
|
* swaps glyph and ground, and swapping twice is where you started.
|
|
532
532
|
*/
|
|
533
533
|
function onScreen(slots, reverse) {
|
|
534
534
|
return reverse ? { fg: slots.bg, bg: slots.fg } : slots;
|
|
535
535
|
}
|
|
536
536
|
/**
|
|
537
|
-
* The specs a cell's slots are written in once their
|
|
537
|
+
* The specs a cell's slots are written in once their colors move from
|
|
538
538
|
* `from`, what the written specs draw, to `to`: each laid on what is beneath
|
|
539
539
|
* it — the ground on `SURFACE_BLACK`, the glyph on that ground, as the writer
|
|
540
|
-
* lays any translucent
|
|
540
|
+
* lays any translucent color (`Style.drawnColors`) — then matched at `depth`
|
|
541
541
|
* (`ColorSpec.matchMove`). A slot the depth shows no move in has none, and
|
|
542
542
|
* keeps the spec it was written in.
|
|
543
543
|
*/
|
|
544
544
|
function movedSpecs(from, to, depth, terminal) {
|
|
545
|
-
// [LAW:one-source-of-truth] The writer's surface, so one translucent
|
|
545
|
+
// [LAW:one-source-of-truth] The writer's surface, so one translucent color draws one way in a frame.
|
|
546
546
|
const ground = to.bg.compositeOver(SURFACE_BLACK);
|
|
547
547
|
const glyph = to.fg.compositeOver(ground);
|
|
548
548
|
return { fg: ColorSpec.matchMove(from.fg, glyph, depth, terminal, true), bg: ColorSpec.matchMove(from.bg, ground, depth, terminal, false) };
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
551
|
-
* Whether two cells'
|
|
552
|
-
* the default
|
|
551
|
+
* Whether two cells' colors are written alike. A slot with no color is not
|
|
552
|
+
* the default color: it writes nothing, so a style a container lays beneath
|
|
553
553
|
* (`Segment.applyStyle`) still shows through it, where `39`/`49` would not.
|
|
554
554
|
*/
|
|
555
555
|
function writesAlike(a, b) {
|
|
@@ -587,7 +587,7 @@ export function cellAttributes(of) {
|
|
|
587
587
|
function sameAttributes(a, b) {
|
|
588
588
|
return a === b || MOVED.every((name) => a[name] === b[name]);
|
|
589
589
|
}
|
|
590
|
-
/** Whether two specs are one
|
|
590
|
+
/** Whether two specs are one color as written: the same kind, naming the same color. */
|
|
591
591
|
function sameSpec(a, b) {
|
|
592
592
|
return a === b || (a !== undefined && b !== undefined && a.type === b.type && a.name === b.name);
|
|
593
593
|
}
|