@promptctl/rich-js 0.22.0 → 0.23.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/dist/core/strip.d.ts +4 -4
- package/dist/core/strip.js +9 -7
- package/dist/renderables/effect.d.ts +13 -8
- package/dist/renderables/effect.js +17 -9
- package/package.json +1 -1
package/dist/core/strip.d.ts
CHANGED
|
@@ -77,11 +77,11 @@ export interface Joiner<T extends StyledRenderable = StyledRenderable> {
|
|
|
77
77
|
*/
|
|
78
78
|
export declare const JOIN: object;
|
|
79
79
|
/**
|
|
80
|
-
* Which of a cell's two colours on screen are `
|
|
81
|
-
*
|
|
82
|
-
* `CellJoiner` drew, the sides shown in
|
|
80
|
+
* Which of a cell's two colours on screen are one of `owners`': both, for a
|
|
81
|
+
* cell one of them drew, itself or through an owner nested in its output; for
|
|
82
|
+
* a cell a `CellJoiner` drew, the sides shown in one of their colours.
|
|
83
83
|
*/
|
|
84
|
-
export declare function colorsOwnedBy(anchor: Anchor | undefined,
|
|
84
|
+
export declare function colorsOwnedBy(anchor: Anchor | undefined, owners: ReadonlySet<object>): {
|
|
85
85
|
readonly fg: boolean;
|
|
86
86
|
readonly bg: boolean;
|
|
87
87
|
};
|
package/dist/core/strip.js
CHANGED
|
@@ -59,16 +59,18 @@ class ColorOwners {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Which of a cell's two colours on screen are `
|
|
63
|
-
*
|
|
64
|
-
* `CellJoiner` drew, the sides shown in
|
|
62
|
+
* Which of a cell's two colours on screen are one of `owners`': both, for a
|
|
63
|
+
* cell one of them drew, itself or through an owner nested in its output; for
|
|
64
|
+
* a cell a `CellJoiner` drew, the sides shown in one of their colours.
|
|
65
65
|
*/
|
|
66
|
-
export function colorsOwnedBy(anchor,
|
|
66
|
+
export function colorsOwnedBy(anchor, owners) {
|
|
67
67
|
for (let level = anchor; level; level = level.inner) {
|
|
68
|
-
if (level.owner
|
|
68
|
+
if (owners.has(level.owner))
|
|
69
69
|
return { fg: true, bg: true };
|
|
70
|
-
if (level.owner instanceof ColorOwners)
|
|
71
|
-
|
|
70
|
+
if (level.owner instanceof ColorOwners) {
|
|
71
|
+
const { fg, bg } = level.owner;
|
|
72
|
+
return { fg: fg !== null && owners.has(fg), bg: bg !== null && owners.has(bg) };
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
return { fg: false, bg: false };
|
|
74
76
|
}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* draws in that frame in, a function of the frame out; and into that, a
|
|
7
7
|
* cell's colours and where the cell is, the cell's new colours out. Whatever
|
|
8
8
|
* holds for the whole frame is worked out in the first stage, once, and every
|
|
9
|
-
* cell of the frame is handed to the second
|
|
9
|
+
* cell of the frame is handed to the second, but for those a wrapper keeps
|
|
10
|
+
* back: `confined` hands over only the cells its owners drew, so a second
|
|
11
|
+
* stage never counts on seeing them all. Shimmer, pulse, fade and
|
|
10
12
|
* dissolve are all this one shape, differing by what the function does with
|
|
11
13
|
* its inputs [LAW:one-type-per-behavior]; two effects stack by nesting one
|
|
12
14
|
* wrapper in another, which is the same as calling one after the other but
|
|
@@ -170,14 +172,17 @@ export declare class Effected implements Renderable, Measurable {
|
|
|
170
172
|
private seed;
|
|
171
173
|
}
|
|
172
174
|
/**
|
|
173
|
-
* `effect` on the colours `
|
|
174
|
-
* its output, and every other colour left as it is: one item of a
|
|
175
|
-
* items share a fill,
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* (`colorsOwnedBy`,
|
|
175
|
+
* `effect` on the colours any of `owners` drew, itself or through an owner
|
|
176
|
+
* nested in its output, and every other colour left as it is: one item of a
|
|
177
|
+
* strip whose items share a fill, the items of a row one other item stands
|
|
178
|
+
* apart from, one widget of a screen. A seam cell shows its two neighbours
|
|
179
|
+
* side by side, a powerline arrow in the fill it points out of over the fill
|
|
180
|
+
* it points into, so each side moves with its own item (`colorsOwnedBy`,
|
|
181
|
+
* `../core/strip.ts`). A cell none of them drew is never handed to the
|
|
182
|
+
* effect, so confining one effect to many owners costs one call a cell, not
|
|
183
|
+
* one for each owner.
|
|
179
184
|
*/
|
|
180
|
-
export declare function confined(effect: Effect,
|
|
185
|
+
export declare function confined(effect: Effect, ...owners: readonly object[]): Effect;
|
|
181
186
|
/**
|
|
182
187
|
* What `segments`, drawn at `depth` on `theme`, draw their words in, measured
|
|
183
188
|
* as `Effected` measures its child for every frame. Measure an element's
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* draws in that frame in, a function of the frame out; and into that, a
|
|
7
7
|
* cell's colours and where the cell is, the cell's new colours out. Whatever
|
|
8
8
|
* holds for the whole frame is worked out in the first stage, once, and every
|
|
9
|
-
* cell of the frame is handed to the second
|
|
9
|
+
* cell of the frame is handed to the second, but for those a wrapper keeps
|
|
10
|
+
* back: `confined` hands over only the cells its owners drew, so a second
|
|
11
|
+
* stage never counts on seeing them all. Shimmer, pulse, fade and
|
|
10
12
|
* dissolve are all this one shape, differing by what the function does with
|
|
11
13
|
* its inputs [LAW:one-type-per-behavior]; two effects stack by nesting one
|
|
12
14
|
* wrapper in another, which is the same as calling one after the other but
|
|
@@ -185,18 +187,24 @@ function measured(looked, depth, theme) {
|
|
|
185
187
|
return { pairs, colors: new Set([...own("fg"), ...own("bg")]), fills: new Set(own("bg")), depth, theme };
|
|
186
188
|
}
|
|
187
189
|
/**
|
|
188
|
-
* `effect` on the colours `
|
|
189
|
-
* its output, and every other colour left as it is: one item of a
|
|
190
|
-
* items share a fill,
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* (`colorsOwnedBy`,
|
|
190
|
+
* `effect` on the colours any of `owners` drew, itself or through an owner
|
|
191
|
+
* nested in its output, and every other colour left as it is: one item of a
|
|
192
|
+
* strip whose items share a fill, the items of a row one other item stands
|
|
193
|
+
* apart from, one widget of a screen. A seam cell shows its two neighbours
|
|
194
|
+
* side by side, a powerline arrow in the fill it points out of over the fill
|
|
195
|
+
* it points into, so each side moves with its own item (`colorsOwnedBy`,
|
|
196
|
+
* `../core/strip.ts`). A cell none of them drew is never handed to the
|
|
197
|
+
* effect, so confining one effect to many owners costs one call a cell, not
|
|
198
|
+
* one for each owner.
|
|
194
199
|
*/
|
|
195
|
-
export function confined(effect,
|
|
200
|
+
export function confined(effect, ...owners) {
|
|
201
|
+
const confinedTo = new Set(owners);
|
|
196
202
|
return (t, drawn) => {
|
|
197
203
|
const frame = effect(t, drawn);
|
|
198
204
|
return (colors, cell) => {
|
|
199
|
-
const owned = colorsOwnedBy(cell.anchor,
|
|
205
|
+
const owned = colorsOwnedBy(cell.anchor, confinedTo);
|
|
206
|
+
if (!owned.fg && !owned.bg)
|
|
207
|
+
return colors;
|
|
200
208
|
const moved = frame(colors, cell);
|
|
201
209
|
return { fg: owned.fg ? moved.fg : colors.fg, bg: owned.bg ? moved.bg : colors.bg };
|
|
202
210
|
};
|