@alexpeng/dsh-custom-plugin 0.9.3 → 0.10.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/CHANGELOG.md +1687 -866
- package/NOTICE +71 -0
- package/README.i18n.yaml +7 -7
- package/README.md +344 -335
- package/README.zh.md +309 -302
- package/lib/client.js +9458 -2063
- package/lib/client.js.map +1 -1
- package/lib/index.js +233 -99
- package/lib/types/balance.d.ts +44 -0
- package/lib/types/client/api.d.ts +13 -8
- package/lib/types/client/bg-ascii.d.ts +397 -0
- package/lib/types/client/bg-field.d.ts +60 -0
- package/lib/types/client/bg-focus.d.ts +63 -0
- package/lib/types/client/bg-layer.d.ts +152 -0
- package/lib/types/client/bg-ocean.d.ts +31 -0
- package/lib/types/client/bg-params.d.ts +142 -0
- package/lib/types/client/bg-pointer.d.ts +107 -0
- package/lib/types/client/bg-shader.d.ts +329 -0
- package/lib/types/client/bg-wake.d.ts +57 -0
- package/lib/types/client/custom.d.ts +4 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/palette.d.ts +100 -0
- package/lib/types/client/panel-bounds.d.ts +65 -0
- package/lib/types/client/styles.d.ts +9 -4
- package/lib/types/client/ui/anchor.d.ts +55 -0
- package/lib/types/client/ui/appearance-controls.d.ts +24 -0
- package/lib/types/client/ui/command-model.d.ts +28 -0
- package/lib/types/client/ui/folders-model.d.ts +31 -0
- package/lib/types/client/ui/index-bridge.d.ts +6 -0
- package/lib/types/client/ui/overlays.d.ts +66 -0
- package/lib/types/client/ui/primitives.d.ts +93 -0
- package/lib/types/client/ui/prompt-model.d.ts +37 -0
- package/lib/types/host-service.d.ts +68 -15
- package/lib/types/pricing.d.ts +8 -4
- package/lib/types/protocol.d.ts +48 -2
- package/lib/types/usage.d.ts +8 -4
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +106 -105
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ASCII character backdrop: the renderer that lives inside `div#vx-bg`.
|
|
3
|
+
*
|
|
4
|
+
* The hot loop never builds strings. Each piece writes one ramp level per
|
|
5
|
+
* cell into a reused `Uint8Array`, and the renderer blits a pre-baked glyph
|
|
6
|
+
* atlas with `drawImage` only — one atlas per (theme, font, dpr, tile size),
|
|
7
|
+
* rebuilt on demand and never per frame. That is what keeps a 15 fps field of
|
|
8
|
+
* ~10k cells free of per-frame allocations and `fillText` metric work.
|
|
9
|
+
*
|
|
10
|
+
* Motion is read from the layer's `data-vx-bg-motion` attribute and the
|
|
11
|
+
* surface from `--vx-bg-tint`; page visibility and the reduced-motion media
|
|
12
|
+
* query are observed here as well. Degradation follows a fixed ladder —
|
|
13
|
+
* frame rate → density → mono → dither → static frame → off — and never
|
|
14
|
+
* climbs back on its own inside one session.
|
|
15
|
+
*
|
|
16
|
+
* Phase 3a ships the ASCII system presets — `flow`, `rain`, `ocean`,
|
|
17
|
+
* `starfield`, `ripple`, plus the zero-rAF `static` tier. Each preset is its
|
|
18
|
+
* own piece (falling trails, horizontal swells, sparse stars, concentric
|
|
19
|
+
* rings), not the flow field with different knobs. Switching presets reuses
|
|
20
|
+
* the canvas and the grid buffer; the atlas is rebuilt only when the ramp,
|
|
21
|
+
* ink, theme or cell geometry changes.
|
|
22
|
+
* @module @alexpeng/dsh-custom-plugin/client/bg-ascii
|
|
23
|
+
*/
|
|
24
|
+
import { type BgFocusRect } from './bg-focus.ts';
|
|
25
|
+
import { type AsciiPiece } from './bg-field.ts';
|
|
26
|
+
import { type BgPointerEventLike } from './bg-pointer.ts';
|
|
27
|
+
export { FLOW_LEVEL_FLOOR, quantizeLevel } from './bg-field.ts';
|
|
28
|
+
export type { AsciiInput, AsciiPiece } from './bg-field.ts';
|
|
29
|
+
export { createOceanPiece } from './bg-ocean.ts';
|
|
30
|
+
/** Upper bound for the backing-store scale. */
|
|
31
|
+
export declare const DPR_CAP = 2;
|
|
32
|
+
/** Hard grid caps: beyond these the cell size grows instead of the grid. */
|
|
33
|
+
export declare const MAX_COLS = 240;
|
|
34
|
+
/** Hard grid caps: beyond these the cell size grows instead of the grid. */
|
|
35
|
+
export declare const MAX_ROWS = 96;
|
|
36
|
+
/** Monospace stack; `ui-monospace` resolves locally, so nothing is fetched. */
|
|
37
|
+
export declare const MONO_STACK = "ui-monospace, SFMono-Regular, Menlo, Consolas, \"Cascadia Mono\", \"DejaVu Sans Mono\", monospace";
|
|
38
|
+
/** Glyph ramps. Only guaranteed-monospace ASCII; CJK and box drawing are
|
|
39
|
+
* deliberately excluded because their advance is not 0.6 em in every face. */
|
|
40
|
+
export type AsciiCharset = 'classic' | 'blocks' | 'dots';
|
|
41
|
+
/** Glyph ramps ordered by increasing ink density. */
|
|
42
|
+
export declare const CHARSET: Record<AsciiCharset, string>;
|
|
43
|
+
/** Every ASCII piece id. `static` is the zero-rAF tier. */
|
|
44
|
+
export type AsciiPreset = 'flow' | 'rain' | 'ocean' | 'starfield' | 'ripple' | 'static';
|
|
45
|
+
/** Inclusive numeric bounds a future settings panel may write. */
|
|
46
|
+
export interface AsciiRange {
|
|
47
|
+
readonly min: number;
|
|
48
|
+
readonly max: number;
|
|
49
|
+
}
|
|
50
|
+
/** Writable bounds per preset; defaults above sit inside these. */
|
|
51
|
+
export interface AsciiPresetRanges {
|
|
52
|
+
readonly density: AsciiRange;
|
|
53
|
+
readonly speed: AsciiRange;
|
|
54
|
+
readonly fps: AsciiRange;
|
|
55
|
+
readonly fontPx: AsciiRange;
|
|
56
|
+
readonly opacity: AsciiRange;
|
|
57
|
+
}
|
|
58
|
+
/** Tunables of one preset. */
|
|
59
|
+
export interface AsciiPresetSpec {
|
|
60
|
+
readonly density: number;
|
|
61
|
+
readonly speed: number;
|
|
62
|
+
readonly fps: number;
|
|
63
|
+
readonly charset: AsciiCharset;
|
|
64
|
+
readonly dither: boolean;
|
|
65
|
+
readonly opacity: number;
|
|
66
|
+
readonly fontPx: number;
|
|
67
|
+
/** Per-piece ink multiplier on the theme's base ΔL. The dense `blocks`
|
|
68
|
+
* pieces need none (1.0); the `dots` pieces carry far less ink per cell, so
|
|
69
|
+
* they lift the ink to reach the same perceived strength. Also multiplied by
|
|
70
|
+
* the user's soft/standard/strong strength choice. */
|
|
71
|
+
readonly inkScale: number;
|
|
72
|
+
/** The piece consumes pointer input and may mark interaction cells in the
|
|
73
|
+
* emphasis buffer. `flow` and `ocean` opt in today; `static` deliberately
|
|
74
|
+
* does not, so its one frame stays deterministic. */
|
|
75
|
+
readonly interactive?: boolean;
|
|
76
|
+
/** Shape-aware rendering: a cell on a contour swaps its ramp glyph for a
|
|
77
|
+
* directional stroke of similar ink weight (the MIT `glyph-graphics` idea).
|
|
78
|
+
* The `dots` pieces and `rain` keep their plain ramp. */
|
|
79
|
+
readonly shapeAware?: boolean;
|
|
80
|
+
readonly ranges: AsciiPresetRanges;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* System presets. `flow` is the default animated tier; `static` draws one
|
|
84
|
+
* deterministic flow frame (zero rAF). The other four are genuinely different
|
|
85
|
+
* pieces: vertical falling trails, horizontal swells, sparse parallax stars
|
|
86
|
+
* and concentric rings. `density` varies the cell size, so only `flow` and
|
|
87
|
+
* `static` share one baked atlas today.
|
|
88
|
+
*
|
|
89
|
+
* `inkScale` is the per-piece visibility calibration (measurements in
|
|
90
|
+
* AGENTS.md, 2026-11-08, 1280×822 dpr 1.5, reading column over the composited
|
|
91
|
+
* page): a dot glyph carries ~1/6 of a block glyph's ink, so the dots pieces
|
|
92
|
+
* need a bigger per-cell step to be seen at all, and the sparse starfield
|
|
93
|
+
* needs a brighter point rather than more area. These numbers are measured,
|
|
94
|
+
* not taste: `flow` at 1.0 reads 0.15% mean ink mass / 2.99% peak; `ocean` at
|
|
95
|
+
* 1.4 with density 0.65 reads 0.17% / 4.37%; `ripple` at 1.25 reads 0.11% /
|
|
96
|
+
* 3.11%; `starfield` at 1.6 reads a 5.15% star peak while staying <0.4%
|
|
97
|
+
* covered; `rain` stays at 1.1 because its 13.3% inter-frame change (the
|
|
98
|
+
* highest of the six) is what carries it, not its ink mass.
|
|
99
|
+
*/
|
|
100
|
+
export declare const ASCII_PRESETS: Record<AsciiPreset, AsciiPresetSpec>;
|
|
101
|
+
/** Resolve a stored preset id to an ASCII piece. A shader-tier id (or any
|
|
102
|
+
* unknown string) is a stale combination and falls back to `flow`. */
|
|
103
|
+
export declare function resolveAsciiPreset(preset: string | undefined): AsciiPreset;
|
|
104
|
+
/** Panel overrides for one ASCII preset. Every value is clamped into the
|
|
105
|
+
* preset's own `ranges` before it is used, so an out-of-range value (a stale
|
|
106
|
+
* state file, a slider crossing a preset switch) never reaches the grid.
|
|
107
|
+
* `strength` is the user's soft/standard/strong multiplier, applied on top of
|
|
108
|
+
* the piece's own `inkScale`; it is clamped to the ink scale band, not to a
|
|
109
|
+
* preset range. */
|
|
110
|
+
export type AsciiParams = Partial<Record<'density' | 'speed' | 'fps' | 'fontPx' | 'opacity' | 'strength', number>>;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve overrides against one preset. Missing or invalid keys fall back to
|
|
113
|
+
* the preset's own default, so a preset switch never inherits a value the new
|
|
114
|
+
* piece cannot honour. The returned `inkScale` is the piece's calibrated value
|
|
115
|
+
* times the user's strength multiplier. Returns the base spec object itself
|
|
116
|
+
* when nothing is overridden (no allocation until the user actually moves a
|
|
117
|
+
* slider).
|
|
118
|
+
*/
|
|
119
|
+
export declare function resolveAsciiSpec(preset: AsciiPreset, params: AsciiParams): AsciiPresetSpec;
|
|
120
|
+
/** Resize debounce before the grid is rebuilt. */
|
|
121
|
+
export declare const RESIZE_DEBOUNCE_MS = 150;
|
|
122
|
+
/** Frames per degradation statistics window. */
|
|
123
|
+
export declare const LADDER_WINDOW = 60;
|
|
124
|
+
/** A window is "over budget" above this multiple of the frame budget. */
|
|
125
|
+
export declare const LADDER_OVER_BUDGET = 1.6;
|
|
126
|
+
/** Consecutive bad windows before one ladder step. */
|
|
127
|
+
export declare const LADDER_BAD_WINDOWS = 2;
|
|
128
|
+
/** Last rung: 0 full … 5 static frame, 6 no glyphs (surface only). */
|
|
129
|
+
export declare const DEGRADE_MAX = 6;
|
|
130
|
+
/** Inside the calm zone, cells an interactive piece marks as part of the
|
|
131
|
+
* effect (a ripple crest, a fish) keep this fraction of the ramp instead of
|
|
132
|
+
* the zone's 0.15 floor. Raised 0.5 → 0.65 on 2026-11-11: the user asked for
|
|
133
|
+
* the pointer response to read more clearly, and a user-caused ripple may sit
|
|
134
|
+
* nearer the column's own contrast than the ambient texture — the ambient
|
|
135
|
+
* stays at the 0.15 floor, so only what the hand just did gets brighter. */
|
|
136
|
+
export declare const EFFECT_FOCUS_FLOOR = 0.65;
|
|
137
|
+
/**
|
|
138
|
+
* Measure the cell in CSS pixels. `measureText` ignores the current
|
|
139
|
+
* transform, so the probe needs no dpr scaling: 50 glyphs cancel the
|
|
140
|
+
* sub-pixel rounding of a single advance. Row height is 1.15 em, leaving
|
|
141
|
+
* roughly 0.18 em above and below the ink so rows never touch.
|
|
142
|
+
*/
|
|
143
|
+
export declare function measureCell(ctx: AsciiCtxLike, fontPx: number): {
|
|
144
|
+
cellW: number;
|
|
145
|
+
cellH: number;
|
|
146
|
+
};
|
|
147
|
+
/** A surface counts as dark below this weighted brightness (0..255). */
|
|
148
|
+
export declare function isDarkSurface(hex: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* The `flow` piece: a slowly drifting value-noise field. `t` is already
|
|
151
|
+
* scaled by the preset speed. Dithering only makes sense on short ramps;
|
|
152
|
+
* at 16 levels it adds noise instead of removing banding.
|
|
153
|
+
*
|
|
154
|
+
* The field is lifted by {@link FLOW_LEVEL_FLOOR} before quantisation. That
|
|
155
|
+
* lift is the round-1 visibility fix, and it is a *coverage* fix, not an ink
|
|
156
|
+
* fix: value noise spends most of its area near 0.5, which quantises onto the
|
|
157
|
+
* `blocks` ramp's mid glyphs (`+` / `*`) — measured at 12 px those carry only
|
|
158
|
+
* 5.5% / 4.4% of a cell's ink area, against 12% for `#`, 17% for `%` and 23%
|
|
159
|
+
* for `@`. Raising the ink ΔL further does nothing to that (the ink is already
|
|
160
|
+
* near-black and the surface halves it), while the lift moves the typical cell
|
|
161
|
+
* from `+` to `#`-`%`, i.e. 2–3× the ink mass on screen.
|
|
162
|
+
*/
|
|
163
|
+
export declare function createFlowPiece(levels: number, dither: boolean, interactive?: boolean): AsciiPiece;
|
|
164
|
+
/**
|
|
165
|
+
* The `rain` piece: falling columns. Each column owns a phase, a fall speed
|
|
166
|
+
* and a trail length derived from its index; roughly one column in seven is
|
|
167
|
+
* dormant, so the rain reads as patchy weather rather than a curtain. The
|
|
168
|
+
* head is the brightest cell and the trail fades quadratically behind it.
|
|
169
|
+
*
|
|
170
|
+
* The pointer bends whole columns sideways instead of editing individual
|
|
171
|
+
* drops: a drag is wind (displacement scaled by pointer speed and falling off
|
|
172
|
+
* with distance), and simply resting on the page parts the curtain into a
|
|
173
|
+
* tunnel around the cursor. A press pushes the nearby columns away and
|
|
174
|
+
* brightens only their heads for a moment — the trail itself is untouched.
|
|
175
|
+
* With no input every weight stays at zero, so the frame is bit-identical to
|
|
176
|
+
* the pre-interaction rain.
|
|
177
|
+
*/
|
|
178
|
+
export declare function createRainPiece(levels: number, dither: boolean): AsciiPiece;
|
|
179
|
+
/**
|
|
180
|
+
* The `starfield` piece: sparse stars on a mostly blank field, drifting and
|
|
181
|
+
* twinkling slowly. The cells below the star thresholds stay at level 0, so
|
|
182
|
+
* the blit loop skips them and the tier is the cheapest. The thresholds are
|
|
183
|
+
* calibrated (see `ASCII_PRESETS.starfield`), and the field is split into
|
|
184
|
+
* three depth layers that drift at different speeds — far 0.05 rows/s, mid
|
|
185
|
+
* 0.10, near 0.18 — so the picture has parallax without a second canvas.
|
|
186
|
+
* The pointer shifts those layers by up to 15 px (≈1 cell horizontally) in
|
|
187
|
+
* proportion to its distance from the page centre, eased at 0.12 per frame.
|
|
188
|
+
*
|
|
189
|
+
* The pointer cannot make a sparse field denser without breaking its
|
|
190
|
+
* character, so direct interaction is light: a press scatters a burst of live
|
|
191
|
+
* stars and a drag drops a thin trail. Dwelling adds the slower cue — stars
|
|
192
|
+
* inside a 150 px ellipse brighten, and after about a second a small cluster
|
|
193
|
+
* of near-miss cells has accumulated; both fade out in roughly a second once
|
|
194
|
+
* the pointer leaves, leaving the baseline bit-identical.
|
|
195
|
+
*/
|
|
196
|
+
export declare function createStarfieldPiece(levels: number, _dither: boolean): AsciiPiece;
|
|
197
|
+
/**
|
|
198
|
+
* The `ripple` piece: concentric rings from three fixed origins, plus rings
|
|
199
|
+
* the pointer drops. Each ring decays with distance from its origin, keeping
|
|
200
|
+
* the field low-contrast — crests brighten, troughs fall back toward the base,
|
|
201
|
+
* nothing saturates. Dithering stays off: the stipple would break the contour
|
|
202
|
+
* lines the rings are read through.
|
|
203
|
+
*
|
|
204
|
+
* A press drops one strong ring where it lands; its amplitude and speed grow
|
|
205
|
+
* with the pointer velocity, so a flick throws a harder splash than a resting
|
|
206
|
+
* click. A drag leaves a trail of weak ones about every 0.22 s and every five
|
|
207
|
+
* cells, so the pointer moves like a fingertip across water. Slots are a fixed
|
|
208
|
+
* ring buffer — no allocation per drop, no growth with drag length.
|
|
209
|
+
*/
|
|
210
|
+
export declare function createRipplePiece(levels: number, dither: boolean): AsciiPiece;
|
|
211
|
+
/** Pick the piece for one preset. `static` reuses the flow field at t=0. */
|
|
212
|
+
export declare function createPresetPiece(preset: AsciiPreset, levels: number, dither: boolean): AsciiPiece;
|
|
213
|
+
/** Structural canvas surface needed by the renderer and by tests. */
|
|
214
|
+
export interface AsciiCtxLike {
|
|
215
|
+
font: string;
|
|
216
|
+
textAlign: string;
|
|
217
|
+
textBaseline: string;
|
|
218
|
+
globalAlpha: number;
|
|
219
|
+
fillStyle: string;
|
|
220
|
+
imageSmoothingEnabled: boolean;
|
|
221
|
+
measureText(text: string): {
|
|
222
|
+
width: number;
|
|
223
|
+
};
|
|
224
|
+
fillText(text: string, x: number, y: number): void;
|
|
225
|
+
fillRect(x: number, y: number, width: number, height: number): void;
|
|
226
|
+
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
227
|
+
drawImage(image: AsciiCanvasLike, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void;
|
|
228
|
+
}
|
|
229
|
+
/** Structural canvas surface needed by the renderer and by tests. */
|
|
230
|
+
export interface AsciiCanvasLike {
|
|
231
|
+
width: number;
|
|
232
|
+
height: number;
|
|
233
|
+
className: string;
|
|
234
|
+
style: {
|
|
235
|
+
width: string;
|
|
236
|
+
height: string;
|
|
237
|
+
};
|
|
238
|
+
getContext(contextId: '2d'): AsciiCtxLike | null;
|
|
239
|
+
remove(): void;
|
|
240
|
+
}
|
|
241
|
+
/** The host element (`div#vx-bg`) as the renderer sees it. */
|
|
242
|
+
export interface AsciiHostLike {
|
|
243
|
+
readonly clientWidth: number;
|
|
244
|
+
readonly clientHeight: number;
|
|
245
|
+
getAttribute(name: string): string | null;
|
|
246
|
+
appendChild(node: AsciiCanvasLike): unknown;
|
|
247
|
+
style: {
|
|
248
|
+
getPropertyValue(name: string): string;
|
|
249
|
+
};
|
|
250
|
+
/** Optional viewport offset. The page host sits at 0,0; the conversation
|
|
251
|
+
* host is a fixed layer over the column, so pointer CSS px must be shifted
|
|
252
|
+
* into host-local coordinates before they become grid cells. */
|
|
253
|
+
getBoundingClientRect?(): {
|
|
254
|
+
readonly left: number;
|
|
255
|
+
readonly top: number;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/** The slice of `Document` this renderer touches. */
|
|
259
|
+
export interface AsciiDocLike {
|
|
260
|
+
createElement(tag: string): AsciiCanvasLike;
|
|
261
|
+
addEventListener(type: 'visibilitychange', listener: () => void): void;
|
|
262
|
+
removeEventListener(type: 'visibilitychange', listener: () => void): void;
|
|
263
|
+
readonly hidden: boolean;
|
|
264
|
+
}
|
|
265
|
+
/** The slice of `MediaQueryList` this renderer touches. */
|
|
266
|
+
export interface AsciiMediaQueryLike {
|
|
267
|
+
readonly matches: boolean;
|
|
268
|
+
addEventListener(type: 'change', listener: () => void): void;
|
|
269
|
+
removeEventListener(type: 'change', listener: () => void): void;
|
|
270
|
+
}
|
|
271
|
+
/** The slice of `ResizeObserver` this renderer touches. */
|
|
272
|
+
export interface AsciiResizeObserverLike {
|
|
273
|
+
observe(target: unknown): void;
|
|
274
|
+
disconnect(): void;
|
|
275
|
+
}
|
|
276
|
+
/** The slice of `Window` this renderer touches. The pointer methods are
|
|
277
|
+
* optional so a minimal fake window (and a host without PointerEvent) simply
|
|
278
|
+
* leaves interaction off instead of failing to boot. */
|
|
279
|
+
export interface AsciiWinLike {
|
|
280
|
+
readonly devicePixelRatio: number;
|
|
281
|
+
readonly innerWidth?: number;
|
|
282
|
+
readonly innerHeight?: number;
|
|
283
|
+
requestAnimationFrame(callback: (now: number) => void): number;
|
|
284
|
+
cancelAnimationFrame(handle: number): void;
|
|
285
|
+
matchMedia(query: string): AsciiMediaQueryLike;
|
|
286
|
+
ResizeObserver?: new (callback: () => void) => AsciiResizeObserverLike;
|
|
287
|
+
addEventListener?: (type: string, listener: (event: BgPointerEventLike) => void, options?: {
|
|
288
|
+
passive?: boolean;
|
|
289
|
+
}) => void;
|
|
290
|
+
removeEventListener?: (type: string, listener: (event: BgPointerEventLike) => void, options?: {
|
|
291
|
+
passive?: boolean;
|
|
292
|
+
}) => void;
|
|
293
|
+
}
|
|
294
|
+
/** One baked glyph atlas: the ramp tiles followed by optional directional
|
|
295
|
+
* extras, already coloured and faded. */
|
|
296
|
+
export interface Atlas {
|
|
297
|
+
canvas: AsciiCanvasLike;
|
|
298
|
+
/** Tile size in CSS px (the destination unit). */
|
|
299
|
+
tileW: number;
|
|
300
|
+
tileH: number;
|
|
301
|
+
/** Tile size in backing px (the source unit). */
|
|
302
|
+
pxW: number;
|
|
303
|
+
pxH: number;
|
|
304
|
+
glyphs: string[];
|
|
305
|
+
/** 1 when the glyph is a space; the draw loop skips those tiles. */
|
|
306
|
+
empty: Uint8Array;
|
|
307
|
+
/** (level × 5 + direction) → tile index, or null for a plain ramp atlas. */
|
|
308
|
+
chart: Uint8Array | null;
|
|
309
|
+
}
|
|
310
|
+
/** Inputs for {@link buildAtlas}; the canvas factory keeps tests DOM-free. */
|
|
311
|
+
export interface AtlasOptions {
|
|
312
|
+
createCanvas: () => AsciiCanvasLike;
|
|
313
|
+
chars: string;
|
|
314
|
+
ink: string;
|
|
315
|
+
dark: boolean;
|
|
316
|
+
dpr: number;
|
|
317
|
+
tileW: number;
|
|
318
|
+
tileH: number;
|
|
319
|
+
fontPx: number;
|
|
320
|
+
opacity: number;
|
|
321
|
+
/** Which ramp this is; selects the directional extras. */
|
|
322
|
+
charset?: AsciiCharset;
|
|
323
|
+
/** Bake the directional extras and the chart. */
|
|
324
|
+
shape?: boolean;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Bake one coloured tile per ramp level, plus optional directional extras.
|
|
328
|
+
* Level 0 is the blank glyph and the last ramp level is the densest one in
|
|
329
|
+
* **both** themes — pieces write levels, not glyphs, so a level must mean the
|
|
330
|
+
* same thing whichever ink the theme picks. Empty tiles are marked for the
|
|
331
|
+
* draw loop. Per-level alpha is baked here too, which is why the hot loop
|
|
332
|
+
* never touches `globalAlpha`.
|
|
333
|
+
*/
|
|
334
|
+
export declare function buildAtlas(options: AtlasOptions): Atlas | null;
|
|
335
|
+
/** Rolling degradation statistics. Fields stay mutable: no per-window alloc. */
|
|
336
|
+
export interface LadderState {
|
|
337
|
+
level: number;
|
|
338
|
+
badWindows: number;
|
|
339
|
+
sum: number;
|
|
340
|
+
count: number;
|
|
341
|
+
}
|
|
342
|
+
/** Fresh ladder pinned to rung 0. */
|
|
343
|
+
export declare function createLadder(): LadderState;
|
|
344
|
+
/**
|
|
345
|
+
* Feed one accepted draw interval. A window closes every
|
|
346
|
+
* {@link LADDER_WINDOW} frames; two consecutive over-budget windows step the
|
|
347
|
+
* ladder down one rung. A good window clears one bad window, so a single
|
|
348
|
+
* spike never degrades. Returns true when a step happened.
|
|
349
|
+
*/
|
|
350
|
+
export declare function observeFrame(state: LadderState, interval: number, budget: number): boolean;
|
|
351
|
+
/** Observable renderer state; tests and the live probe read this. */
|
|
352
|
+
export interface AsciiBackdropStats {
|
|
353
|
+
level: number;
|
|
354
|
+
cols: number;
|
|
355
|
+
rows: number;
|
|
356
|
+
frames: number;
|
|
357
|
+
atlasBuilds: number;
|
|
358
|
+
/** Cells the last frame marked as interaction effects (ripple crests, fish). */
|
|
359
|
+
emphasisCells: number;
|
|
360
|
+
/** Cells the last frame drew as overlay glyphs (small fish directions). */
|
|
361
|
+
overlayCells: number;
|
|
362
|
+
alive: boolean;
|
|
363
|
+
}
|
|
364
|
+
/** Options accepted by {@link createAsciiBackdrop}. */
|
|
365
|
+
export interface AsciiBackdropOptions {
|
|
366
|
+
doc: AsciiDocLike;
|
|
367
|
+
win: AsciiWinLike;
|
|
368
|
+
host: AsciiHostLike;
|
|
369
|
+
preset?: AsciiPreset;
|
|
370
|
+
/** Panel overrides for the boot preset; clamps to its `ranges`. */
|
|
371
|
+
params?: AsciiParams;
|
|
372
|
+
}
|
|
373
|
+
/** Handle owned by the appearance painter. */
|
|
374
|
+
export interface AsciiBackdrop {
|
|
375
|
+
/** Re-read motion + tint and paint/resume/stop accordingly. */
|
|
376
|
+
sync(): void;
|
|
377
|
+
/** Switch piece; resets the ladder to rung 0 and repaints immediately. The
|
|
378
|
+
* canvas and level buffer survive; the atlas is reused when its key (ramp,
|
|
379
|
+
* ink, theme, dpr, cell size, font, opacity) is unchanged. */
|
|
380
|
+
setPreset(preset: AsciiPreset): void;
|
|
381
|
+
/** Replace the panel overrides for the current preset. Values are clamped
|
|
382
|
+
* into that preset's `ranges`; a preset switch keeps the overrides and
|
|
383
|
+
* re-clamps them. Repaints immediately so a dragging slider is visible. */
|
|
384
|
+
setParams(params: AsciiParams): void;
|
|
385
|
+
/** Move the calm zone (the reading column). `null` disables the mask. The
|
|
386
|
+
* per-cell caps are rebuilt only when the zone or the grid actually moves. */
|
|
387
|
+
setFocus(rect: BgFocusRect | null): void;
|
|
388
|
+
/** Stop everything and free the canvas, listeners, arrays and atlases. */
|
|
389
|
+
destroy(): void;
|
|
390
|
+
readonly stats: AsciiBackdropStats;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Create the renderer and attach its canvas to the layer. The caller mounts
|
|
394
|
+
* `div#vx-bg` first (so the motion attribute and tint already exist), then
|
|
395
|
+
* calls {@link AsciiBackdrop.sync}.
|
|
396
|
+
*/
|
|
397
|
+
export declare function createAsciiBackdrop(options: AsciiBackdropOptions): AsciiBackdrop;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared field primitives for the ASCII backdrop pieces.
|
|
3
|
+
*
|
|
4
|
+
* A piece writes one ramp level per cell into a caller-owned `Uint8Array` and
|
|
5
|
+
* never allocates in its hot loop. Interaction is injected through
|
|
6
|
+
* {@link AsciiInput}; pieces that draw something other than water (fish
|
|
7
|
+
* glyphs) write a slot into the optional `overlay` buffer, and pieces whose
|
|
8
|
+
* cells must stay readable inside the calm zone mark them in `emphasis`.
|
|
9
|
+
*
|
|
10
|
+
* Keeping these types here (rather than in `bg-ascii.ts`) lets `bg-ocean.ts`
|
|
11
|
+
* depend on the contract without importing the renderer, so there is no
|
|
12
|
+
* module cycle between the piece and the canvas that hosts it.
|
|
13
|
+
* @module @alexpeng/dsh-custom-plugin/client/bg-field
|
|
14
|
+
*/
|
|
15
|
+
/** One frame is one ramp-level index per cell. The extra arguments are
|
|
16
|
+
* optional so the four older pieces and their tests keep compiling. */
|
|
17
|
+
export type AsciiPiece = (t: number, out: Uint8Array, cols: number, rows: number, input?: AsciiInput, emphasis?: Uint8Array, overlay?: Uint8Array) => void;
|
|
18
|
+
/** Pointer state in grid coordinates. The renderer maps CSS pixels onto cells
|
|
19
|
+
* once per frame, so a piece never touches the DOM or the event object. */
|
|
20
|
+
export interface AsciiInput {
|
|
21
|
+
/** Pointer position in cells. */
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
/** The pointer has been seen and has not left the window. */
|
|
25
|
+
active: boolean;
|
|
26
|
+
/** Primary button held down. */
|
|
27
|
+
down: boolean;
|
|
28
|
+
/** Smoothed velocity in cells per second. */
|
|
29
|
+
vx: number;
|
|
30
|
+
vy: number;
|
|
31
|
+
/** Increments once per press; a piece reacts to a change. */
|
|
32
|
+
pulseId: number;
|
|
33
|
+
pulseX: number;
|
|
34
|
+
pulseY: number;
|
|
35
|
+
}
|
|
36
|
+
/** Glyphs a piece may place through the overlay buffer. Index 0 is "none";
|
|
37
|
+
* 1–8 are single-cell direction marks for the small fish, 9–13 are the body,
|
|
38
|
+
* edge, head and tail cells of a koi. */
|
|
39
|
+
export declare const OVERLAY_GLYPHS: readonly string[];
|
|
40
|
+
/** Lowest field value the `flow` / `static` piece may emit, as a fraction of
|
|
41
|
+
* the ramp. 0.45 keeps the darkest cell around the middle of the ramp instead
|
|
42
|
+
* of the blank space glyph: the ink *area* per cell, not the ink darkness, is
|
|
43
|
+
* what the eye reads through the 0.5-alpha content surface. */
|
|
44
|
+
export declare const FLOW_LEVEL_FLOOR = 0.45;
|
|
45
|
+
/** Contrast and gamma stay internal: exposed knobs made every preset look
|
|
46
|
+
* worse. Values are deliberate no-ops until a preset needs them. */
|
|
47
|
+
export declare const CONTRAST = 1;
|
|
48
|
+
export declare const GAMMA = 1;
|
|
49
|
+
/** Bayer 4×4 ordered dither matrix (row-major). */
|
|
50
|
+
export declare const BAYER4: Uint8Array<ArrayBuffer>;
|
|
51
|
+
/** Quantize a 0..1 field value to a ramp index. Clamping lives here so a
|
|
52
|
+
* piece can never write outside the atlas. */
|
|
53
|
+
export declare function quantizeLevel(value: number, levels: number): number;
|
|
54
|
+
/** 32-bit integer hash → 0..1. `Math.imul` keeps the multiplications honest;
|
|
55
|
+
* plain `*` would lose the low bits once the product passes 2^53. */
|
|
56
|
+
export declare function hash2(x: number, y: number): number;
|
|
57
|
+
/** Smooth value noise; one octave is enough for a decorative drift field. */
|
|
58
|
+
export declare function valueNoise(x: number, y: number): number;
|
|
59
|
+
/** Shared tail of every piece: clamp, optional Bayer dither, quantize. */
|
|
60
|
+
export declare function shade(out: Uint8Array, i: number, v: number, levels: number, dither: boolean, row: number, col: number): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial focus mask for the backdrop: the ink keeps full strength around the
|
|
3
|
+
* shell's edges and fades toward the reading column, so the texture never sits
|
|
4
|
+
* directly behind body copy. Geometry only — the DOM measurement lives in
|
|
5
|
+
* `custom.tsx`, so both renderer tiers and the unit tests share one rule.
|
|
6
|
+
*
|
|
7
|
+
* The mask is deliberately *not* a radial vignette: the fade follows the real
|
|
8
|
+
* content rectangle (feathered on every side), so a sidebar collapse or a
|
|
9
|
+
* window resize moves the calm zone with the text instead of leaving a
|
|
10
|
+
* mismatched circle on screen.
|
|
11
|
+
*/
|
|
12
|
+
/** Rectangle in CSS pixels, top-left origin, viewport coordinates. */
|
|
13
|
+
export interface BgFocusRect {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
w: number;
|
|
17
|
+
h: number;
|
|
18
|
+
}
|
|
19
|
+
/** Feather width of the fade, CSS px. 150 is kept from rounds 2–3, but for a
|
|
20
|
+
* different reason now: with the composer-span rect the visible gutter is only
|
|
21
|
+
* ~141 px wide (x 280..421 at 1280), so the ramp has to finish *inside* it — at
|
|
22
|
+
* 150 the weight reaches 0.97 at the gutter's outer edge and 1.0 a few px
|
|
23
|
+
* further out, which is the strongest "edge strong → body faint" the layout
|
|
24
|
+
* allows. Round 4 A/B'd 220 and rejected it: a band wider than the gutter
|
|
25
|
+
* dilutes the one region the user can actually see (canvas gutter mean 0.0141
|
|
26
|
+
* vs sidebar 0.0744, i.e. the gutter sat at 19% of full strength while the
|
|
27
|
+
* paragraph area was already down at 0.0060 — ratio 2.37×). */
|
|
28
|
+
export declare const FOCUS_FEATHER_PX = 150;
|
|
29
|
+
/** Ink retained at the middle of the reading column, as a fraction of full
|
|
30
|
+
* strength. Round 4 lowered this from 0.45 to 0.15: the canvas already showed
|
|
31
|
+
* a 3.96× mean ratio at 0.45 (column 0.0151 vs gutter 0.0599), yet the
|
|
32
|
+
* page-scale A/B read as one flat wash — a uniform 45% inside a zone that
|
|
33
|
+
* covers almost the whole content area has nothing to be compared against.
|
|
34
|
+
* 0.15 leaves a barely-there texture behind the copy while the gutter keeps
|
|
35
|
+
* full strength, and the text contrast measured 14.32:1 at 0.45, so it can
|
|
36
|
+
* only improve here. */
|
|
37
|
+
export declare const FOCUS_FLOOR = 0.15;
|
|
38
|
+
/** Reject geometry that cannot describe a real column. */
|
|
39
|
+
export declare function normalizeFocusRect(rect: BgFocusRect | null | undefined): BgFocusRect | null;
|
|
40
|
+
/**
|
|
41
|
+
* The "避让正文" gate: the rect the renderers get. `false` means the mask does
|
|
42
|
+
* not participate at all — `null` reaches `setFocus`, so the ASCII tier never
|
|
43
|
+
* allocates caps and the shader never uploads `u_focus`. This is deliberately
|
|
44
|
+
* not "weight every cell by 1": that would keep the whole pipeline running
|
|
45
|
+
* for a page the user asked to be uniform.
|
|
46
|
+
*/
|
|
47
|
+
export declare function focusRectFor(bgFocus: boolean | undefined, rect: BgFocusRect | null): BgFocusRect | null;
|
|
48
|
+
/** True when two rects describe the same zone; used to skip mask rebuilds. */
|
|
49
|
+
export declare function sameFocusRect(a: BgFocusRect | null, b: BgFocusRect | null): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Ink weight (0..1) at a CSS point: `floor` inside the rect, rising to 1 at
|
|
52
|
+
* `feather` px outside it with a smoothstep ramp (C1-continuous, so the fade
|
|
53
|
+
* has no visible band at either end).
|
|
54
|
+
*/
|
|
55
|
+
export declare function focusWeight(px: number, py: number, rect: BgFocusRect, feather: number, floor: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* Per-cell level caps for the ASCII tier. A cell may not exceed its cap, which
|
|
58
|
+
* thins the glyph ramp toward the column centre; the ramp order is preserved
|
|
59
|
+
* so the piece keeps its own look. The cap is quantised anyway (a ramp has
|
|
60
|
+
* 9–15 steps), so a per-cell dither breaks the level boundaries into a soft
|
|
61
|
+
* grain instead of concentric rims.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildFocusCaps(cols: number, rows: number, cellW: number, cellH: number, rect: BgFocusRect, feather: number, floor: number, lastLevel: number, out?: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page-background layer skeleton: one decorative element below the content
|
|
3
|
+
* surfaces, plus the gates that decide whether it may exist at all.
|
|
4
|
+
*
|
|
5
|
+
* Layer facts measured on dsh 0.2.1-rc.5 (2026-11-06, 1440x900): `<html>` is
|
|
6
|
+
* transparent and `body` carries the opaque canvas fill, so a
|
|
7
|
+
* `position:fixed; z-index:-1` child of `body` paints above that background
|
|
8
|
+
* and below every content surface. The surfaces are 0.5–0.62 alpha only while
|
|
9
|
+
* glass is on: with `glass:false` the layer is fully covered, which the
|
|
10
|
+
* renderer step must treat as "invisible by design", not as a bug. The layer
|
|
11
|
+
* must never live in `.vx-root` — that container sits inside the shell's
|
|
12
|
+
* `.pI_x6G_overlayLayer` (`z-index:20`), so its 2147483000 only orders plugin
|
|
13
|
+
* surfaces locally and native dialogs at z1000 paint above it.
|
|
14
|
+
*
|
|
15
|
+
* Phase 1 owns the layer, its config path and the degradation gates; Phase 2
|
|
16
|
+
* adds the ASCII canvas renderer inside this node (see `bg-ascii.ts`).
|
|
17
|
+
* @module @alexpeng/dsh-custom-plugin/client/bg-layer
|
|
18
|
+
*/
|
|
19
|
+
/** DOM id of the owned background layer. */
|
|
20
|
+
export declare const BG_LAYER_ID = "vx-bg";
|
|
21
|
+
/** Motion state the renderer step will honour. */
|
|
22
|
+
export type BgLayerMotion = 'animated' | 'static' | 'paused';
|
|
23
|
+
/** Environment facts the gates read; injected so tests need no DOM. */
|
|
24
|
+
export interface BgLayerCaps {
|
|
25
|
+
readonly canvas2d: boolean;
|
|
26
|
+
readonly reducedMotion: boolean;
|
|
27
|
+
readonly hidden: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Whether the layer may mount, and if so the motion state to record. */
|
|
30
|
+
export type BgLayerVerdict = {
|
|
31
|
+
readonly mount: false;
|
|
32
|
+
readonly reason: 'disabled' | 'no-canvas';
|
|
33
|
+
} | {
|
|
34
|
+
readonly mount: true;
|
|
35
|
+
readonly motion: BgLayerMotion;
|
|
36
|
+
};
|
|
37
|
+
/** Capability facts for the two renderer tiers. `webgl` is the result of the
|
|
38
|
+
* cached WebGL1 probe; `canvas2d` is required by the ASCII fallback. */
|
|
39
|
+
export interface BgFxCaps extends BgLayerCaps {
|
|
40
|
+
readonly webgl: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Verdict for the multi-tier gate: which renderer the layer will host. */
|
|
43
|
+
export type BgFxVerdict = {
|
|
44
|
+
readonly mount: false;
|
|
45
|
+
readonly reason: 'disabled' | 'no-canvas';
|
|
46
|
+
} | {
|
|
47
|
+
readonly mount: true;
|
|
48
|
+
readonly motion: BgLayerMotion;
|
|
49
|
+
readonly tier: 'ascii' | 'shader';
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Gate for the full `bgFx` enum. The requested shader tier needs WebGL1; when
|
|
53
|
+
* the probe failed but a 2D context exists, the same layer mounts with the
|
|
54
|
+
* ASCII tier so the page keeps an animated background instead of dropping to
|
|
55
|
+
* the plain tint. When neither context exists there is nothing to draw, and
|
|
56
|
+
* the caller leaves the body fill in place.
|
|
57
|
+
*/
|
|
58
|
+
export declare function decideBgFxLayer(mode: 'none' | 'ascii' | 'shader', caps: BgFxCaps): BgFxVerdict;
|
|
59
|
+
/**
|
|
60
|
+
* Build-before-teardown swap. The two tiers are mutually exclusive, so the
|
|
61
|
+
* replacement must be constructed (and its first frame painted) before the
|
|
62
|
+
* old renderer is destroyed: that order is what prevents a blank frame while
|
|
63
|
+
* the opaque body fill is still transparent. A failed build leaves the current
|
|
64
|
+
* renderer untouched, so the caller can fall back without losing the layer.
|
|
65
|
+
*/
|
|
66
|
+
export declare function swapBgRenderer<R extends {
|
|
67
|
+
destroy(): void;
|
|
68
|
+
}>(current: R | null, build: () => R | null): R | null;
|
|
69
|
+
/**
|
|
70
|
+
* Decide whether the background layer may exist. The layer is off by
|
|
71
|
+
* convention: `bgFx` starts `'none'`, so an untouched install never creates a
|
|
72
|
+
* DOM node. Without a 2D canvas context the ASCII renderer has nothing to
|
|
73
|
+
* draw and the plain body tint is the documented fallback; mounting an empty
|
|
74
|
+
* node would add surface without value.
|
|
75
|
+
*/
|
|
76
|
+
export declare function decideBgLayer(enabled: boolean, caps: BgLayerCaps): BgLayerVerdict;
|
|
77
|
+
/**
|
|
78
|
+
* The tint handed to the layer for the current palette and theme. Light mode
|
|
79
|
+
* uses the family's pastel; dark mode derives it through `toDarkRamp` with the
|
|
80
|
+
* same body-canvas lightness the appearance painter uses, so a theme flip
|
|
81
|
+
* re-paints the layer through the existing `applyAppearance` effect deps.
|
|
82
|
+
*
|
|
83
|
+
* The neutral tint must equal the shell's own no-palette base fill, because the
|
|
84
|
+
* backdrop token set paints that fill at a low alpha over this canvas: a
|
|
85
|
+
* mismatched tint would shift the whole page by the difference (measured −7
|
|
86
|
+
* luma on every content pixel while the tint was `#ffffff` against the shell's
|
|
87
|
+
* `#f8f9fb` — a tone change, not texture). Matching the canvas keeps the
|
|
88
|
+
* on/off difference purely ink.
|
|
89
|
+
*/
|
|
90
|
+
export declare function bgLayerTint(bg: string | undefined, dark: boolean): string;
|
|
91
|
+
/** The slice of a DOM element this layer owns (kept structural for tests). */
|
|
92
|
+
export interface BgLayerElementLike {
|
|
93
|
+
id: string;
|
|
94
|
+
className: string;
|
|
95
|
+
readonly clientWidth: number;
|
|
96
|
+
readonly clientHeight: number;
|
|
97
|
+
setAttribute(name: string, value: string): void;
|
|
98
|
+
getAttribute(name: string): string | null;
|
|
99
|
+
appendChild(node: unknown): unknown;
|
|
100
|
+
style: {
|
|
101
|
+
setProperty(name: string, value: string): void;
|
|
102
|
+
getPropertyValue(name: string): string;
|
|
103
|
+
};
|
|
104
|
+
remove(): void;
|
|
105
|
+
}
|
|
106
|
+
/** The slice of `Document` this layer touches. */
|
|
107
|
+
export interface BgLayerDocLike {
|
|
108
|
+
readonly body: {
|
|
109
|
+
appendChild(node: BgLayerElementLike): unknown;
|
|
110
|
+
};
|
|
111
|
+
createElement(tag: string): BgLayerElementLike;
|
|
112
|
+
getElementById(id: string): BgLayerElementLike | null;
|
|
113
|
+
}
|
|
114
|
+
/** The mount-shaped half of {@link BgLayerVerdict}. */
|
|
115
|
+
export type BgLayerMountVerdict = Extract<BgLayerVerdict, {
|
|
116
|
+
mount: true;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Create or update the layer. Idempotent: a second call re-applies the motion
|
|
120
|
+
* attribute and tint on the existing node instead of appending a duplicate,
|
|
121
|
+
* which is what the appearance painter needs on every theme/config repaint.
|
|
122
|
+
*/
|
|
123
|
+
export declare function mountBgLayer(doc: BgLayerDocLike, verdict: BgLayerMountVerdict, tint: string): BgLayerElementLike;
|
|
124
|
+
/** Remove the layer; a missing node is a no-op (fresh install / already off). */
|
|
125
|
+
export declare function unmountBgLayer(doc: BgLayerDocLike): void;
|
|
126
|
+
/**
|
|
127
|
+
* Where the active preset paints.
|
|
128
|
+
*
|
|
129
|
+
* `ocean` is the first piece that is mounted *inside* the conversation column
|
|
130
|
+
* (see `ColumnBgAnchor`): the shell's conversation surface is opaque, so a
|
|
131
|
+
* body-level layer behind it is invisible in the chat. Other presets keep the
|
|
132
|
+
* page-level layer. Keeping the decision pure makes it testable and keeps the
|
|
133
|
+
* painter and the React anchor from disagreeing.
|
|
134
|
+
*/
|
|
135
|
+
export type BgLayerScope = 'page' | 'conversation';
|
|
136
|
+
export declare function bgLayerScope(bgFx: string | undefined, bgFxPreset: string | undefined): BgLayerScope;
|
|
137
|
+
/** One ancestor of the slot anchor, reduced to what the host picker reads. */
|
|
138
|
+
export interface ColumnHostCandidate {
|
|
139
|
+
readonly className: string;
|
|
140
|
+
readonly height: number;
|
|
141
|
+
readonly opaque: boolean;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Pick the conversation column host from an anchor's ancestor chain, ordered
|
|
145
|
+
* nearest-first. The reference implementation (`dsh-ascii-ocean`) looks for
|
|
146
|
+
* the AppFrame centre column class and then takes the outermost ancestor that
|
|
147
|
+
* still fills it, which is the node that owns the column's background. The
|
|
148
|
+
* fallback is the outermost ancestor with an opaque background.
|
|
149
|
+
*
|
|
150
|
+
* Returns the index into `chain`, or -1 when nothing is usable.
|
|
151
|
+
*/
|
|
152
|
+
export declare function pickColumnHost(chain: readonly ColumnHostCandidate[]): number;
|