@alexpeng/dsh-custom-plugin 0.9.3 → 0.11.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +1730 -866
  2. package/NOTICE +71 -0
  3. package/README.i18n.yaml +7 -7
  4. package/README.md +344 -335
  5. package/README.zh.md +309 -302
  6. package/lib/client.js +10260 -2063
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +235 -99
  9. package/lib/types/balance.d.ts +44 -0
  10. package/lib/types/client/api.d.ts +13 -8
  11. package/lib/types/client/bg-ascii.d.ts +405 -0
  12. package/lib/types/client/bg-field.d.ts +62 -0
  13. package/lib/types/client/bg-focus.d.ts +63 -0
  14. package/lib/types/client/bg-jelly.d.ts +53 -0
  15. package/lib/types/client/bg-layer.d.ts +152 -0
  16. package/lib/types/client/bg-ocean.d.ts +31 -0
  17. package/lib/types/client/bg-params.d.ts +142 -0
  18. package/lib/types/client/bg-pointer.d.ts +107 -0
  19. package/lib/types/client/bg-shader.d.ts +329 -0
  20. package/lib/types/client/bg-wake.d.ts +57 -0
  21. package/lib/types/client/bg-whale.d.ts +56 -0
  22. package/lib/types/client/custom.d.ts +4 -1
  23. package/lib/types/client/index.d.ts +1 -1
  24. package/lib/types/client/palette.d.ts +100 -0
  25. package/lib/types/client/panel-bounds.d.ts +65 -0
  26. package/lib/types/client/styles.d.ts +9 -4
  27. package/lib/types/client/ui/anchor.d.ts +55 -0
  28. package/lib/types/client/ui/appearance-controls.d.ts +24 -0
  29. package/lib/types/client/ui/command-model.d.ts +28 -0
  30. package/lib/types/client/ui/folders-model.d.ts +31 -0
  31. package/lib/types/client/ui/index-bridge.d.ts +6 -0
  32. package/lib/types/client/ui/overlays.d.ts +66 -0
  33. package/lib/types/client/ui/primitives.d.ts +93 -0
  34. package/lib/types/client/ui/prompt-model.d.ts +37 -0
  35. package/lib/types/host-service.d.ts +68 -15
  36. package/lib/types/pricing.d.ts +8 -4
  37. package/lib/types/protocol.d.ts +48 -2
  38. package/lib/types/usage.d.ts +8 -4
  39. package/locale/en.json +1 -1
  40. package/locale/zh.json +1 -1
  41. package/package.json +106 -105
@@ -0,0 +1,329 @@
1
+ /**
2
+ * WebGL1 backdrop: one full-screen triangle, one fragment shader, no library.
3
+ *
4
+ * This is the shader tier of `div#vx-bg`. It shares the layer, the motion
5
+ * attribute (`data-vx-bg-motion`), the tint (`--vx-bg-tint`), the visibility
6
+ * rules and the one-way degradation ladder with the ASCII renderer, but it is
7
+ * exclusive with it: the two never coexist, and leaving this tier calls
8
+ * `WEBGL_lose_context` so the page never accumulates contexts.
9
+ *
10
+ * The uniform contract is fixed (time, resolution, dpr, surface, ink, speed,
11
+ * density, intensity, seed). Surface and ink are the same values the ASCII
12
+ * tier uses, so both tiers read correctly on light/dark themes and every
13
+ * palette; the ink keeps `inkFor`'s fixed lightness delta and nothing neon or
14
+ * highly saturated enters the shader.
15
+ *
16
+ * `liquid` also reads the pointer through two extra vec4s (`u_pointer`,
17
+ * `u_pulse`): the cursor becomes an eddy that turns the cloud, and a press
18
+ * expands a ring from where it landed. `grain` declares `animated:false` and
19
+ * never runs a frame loop, so it deliberately ignores both — a static speck
20
+ * field that reacts to the mouse would not be static any more.
21
+ *
22
+ * Styles are self-declared static or animated. A style that does not depend on
23
+ * `u_time` draws one frame and never schedules rAF; the caller never has to
24
+ * sniff pixels to discover that (readPixels would force a sync far more
25
+ * expensive than the frame it saves).
26
+ * @module @alexpeng/dsh-custom-plugin/client/bg-shader
27
+ */
28
+ import { type BgFocusRect } from './bg-focus.ts';
29
+ import { type BgPointerEventLike } from './bg-pointer.ts';
30
+ /** Every shader style id. */
31
+ export type ShaderStyle = 'liquid' | 'grain';
32
+ /** Inclusive numeric bounds for the future settings panel. */
33
+ export interface ShaderRange {
34
+ readonly min: number;
35
+ readonly max: number;
36
+ }
37
+ /** Writable bounds per style; defaults sit inside these. */
38
+ export interface ShaderStyleRanges {
39
+ readonly speed: ShaderRange;
40
+ readonly density: ShaderRange;
41
+ readonly intensity: ShaderRange;
42
+ readonly seed: ShaderRange;
43
+ readonly fps: ShaderRange;
44
+ }
45
+ /** Tunables of one style. `animated: false` means "draw one frame, never
46
+ * schedule rAF" — a physical property of the shader, not a runtime guess. */
47
+ export interface ShaderStyleSpec {
48
+ readonly speed: number;
49
+ readonly density: number;
50
+ readonly intensity: number;
51
+ readonly seed: number;
52
+ readonly fps: number;
53
+ readonly animated: boolean;
54
+ /** Per-style multiplier on the theme's base ΔL (see `inkFor`). The user's
55
+ * soft/standard/strong strength choice multiplies this again. */
56
+ readonly inkScale: number;
57
+ readonly ranges: ShaderStyleRanges;
58
+ }
59
+ /**
60
+ * Two deliberately different pieces rather than one field with knobs:
61
+ * `liquid` is a low-frequency domain-warped ink cloud that drifts; `grain` is
62
+ * a fine, static film grain with a soft edge falloff. Both derive their ink
63
+ * from the surface brightness, so they work on light, dark and every palette.
64
+ */
65
+ export declare const SHADER_STYLES: Record<ShaderStyle, ShaderStyleSpec>;
66
+ /** Resolve a stored preset id to a shader style. An ASCII id or any unknown
67
+ * string is a stale cross-tier combination and falls back to the default. */
68
+ export declare function resolveShaderStyle(preset: string | undefined): ShaderStyle;
69
+ /** Panel overrides for one shader style. Values are clamped into the style's
70
+ * own `ranges` before they reach a uniform; `strength` is the user's
71
+ * soft/standard/strong multiplier on the ink step (clamped to the ink band). */
72
+ export type ShaderParams = Partial<Record<'speed' | 'density' | 'intensity' | 'fps' | 'strength', number>>;
73
+ /**
74
+ * Resolve overrides against one style. Missing keys fall back to the style
75
+ * default, so a style switch never inherits a value it cannot honour. Returns
76
+ * the base spec object itself when nothing is overridden.
77
+ */
78
+ export declare function resolveShaderSpec(style: ShaderStyle, params: ShaderParams): ShaderStyleSpec;
79
+ /** Hard bounds the uniform contract promises, independent of a style. */
80
+ export declare const SHADER_UNIFORM_RANGES: {
81
+ readonly speed: {
82
+ readonly min: 0;
83
+ readonly max: 2;
84
+ };
85
+ readonly density: {
86
+ readonly min: 0.5;
87
+ readonly max: 2;
88
+ };
89
+ readonly intensity: {
90
+ readonly min: 0;
91
+ readonly max: 1;
92
+ };
93
+ readonly seed: {
94
+ readonly min: 0;
95
+ readonly max: 9999;
96
+ };
97
+ };
98
+ /** Vertex shader for the single full-screen triangle (GLSL ES 1.00). */
99
+ export declare const SHADER_VERTEX_SOURCE = "attribute vec2 a_pos;\nvarying vec2 v_uv;\nvoid main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}";
100
+ /**
101
+ * Fragment shaders, one per style. Both end in `mix(u_surface, u_ink, …)` with
102
+ * alpha 1: the layer is the opaque page background while it is mounted, which
103
+ * is the same contract the ASCII canvas honours with its surface fill.
104
+ */
105
+ export declare const SHADER_FRAGMENT_SOURCE: Record<ShaderStyle, string>;
106
+ /** Numeric values handed to the GPU for one draw. Plain data so the uniform
107
+ * mapping is unit-testable without a GL context. */
108
+ export interface ShaderUniformValues {
109
+ time: number;
110
+ width: number;
111
+ height: number;
112
+ dpr: number;
113
+ surface: [number, number, number];
114
+ ink: [number, number, number];
115
+ speed: number;
116
+ density: number;
117
+ intensity: number;
118
+ seed: number;
119
+ /** `[x, y, w, h]` in CSS px; `w <= 0` disables the mask. */
120
+ focus: [number, number, number, number];
121
+ focusFeather: number;
122
+ focusFloor: number;
123
+ /** `[x, y, active, speed]` in CSS px; `active <= 0` disables the eddy. */
124
+ pointer: [number, number, number, number];
125
+ /** `[x, y, age, active]` in CSS px; `active <= 0` disables the ring. */
126
+ pulse: [number, number, number, number];
127
+ }
128
+ /** One pointer sample for the shader. `speed` is 0..1 (already normalised). */
129
+ export interface ShaderPointerInput {
130
+ x: number;
131
+ y: number;
132
+ active: boolean;
133
+ speed: number;
134
+ }
135
+ /** One press sample for the shader; `age` is seconds since the press. */
136
+ export interface ShaderPulseInput {
137
+ x: number;
138
+ y: number;
139
+ age: number;
140
+ }
141
+ /** How long a press ring is allowed to expand, in seconds. */
142
+ export declare const SHADER_PULSE_LIFE = 2.6;
143
+ /** Inputs for {@link shaderUniforms}; `dark` is derived from the surface. */
144
+ export interface ShaderUniformInput {
145
+ time: number;
146
+ width: number;
147
+ height: number;
148
+ dpr: number;
149
+ spec: ShaderStyleSpec;
150
+ surface: string;
151
+ /** Multiplier applied by the degradation ladder (L2). */
152
+ densityScale?: number;
153
+ /** Reading-column calm zone from the appearance painter. */
154
+ focus?: BgFocusRect | null;
155
+ /** Live pointer sample; absent means "no eddy". */
156
+ pointer?: ShaderPointerInput | null;
157
+ /** Live press sample; absent or expired means "no ring". */
158
+ pulse?: ShaderPulseInput | null;
159
+ }
160
+ /**
161
+ * Map runtime state onto the uniform contract. Visibility time is clamped at
162
+ * zero; resolution is CSS pixels (never backing pixels); dpr honours the same
163
+ * 2× cap as the ASCII tier; density and the other knobs stay inside the
164
+ * documented ranges even if a future panel or a hand-edited state file writes
165
+ * something else. The ink is `inkFor(surface, dark)` so both tiers use exactly
166
+ * the same lightness delta.
167
+ */
168
+ export declare function shaderUniforms(input: ShaderUniformInput): ShaderUniformValues;
169
+ /** The GL call surface this renderer uses (kept structural for tests). */
170
+ export interface ShaderGL {
171
+ readonly VERTEX_SHADER: number;
172
+ readonly FRAGMENT_SHADER: number;
173
+ readonly COMPILE_STATUS: number;
174
+ readonly LINK_STATUS: number;
175
+ readonly ARRAY_BUFFER: number;
176
+ readonly STATIC_DRAW: number;
177
+ readonly FLOAT: number;
178
+ readonly TRIANGLES: number;
179
+ readonly COLOR_BUFFER_BIT: number;
180
+ createShader(type: number): object | null;
181
+ shaderSource(shader: object, source: string): void;
182
+ compileShader(shader: object): void;
183
+ getShaderParameter(shader: object, pname: number): boolean;
184
+ getShaderInfoLog(shader: object): string | null;
185
+ deleteShader(shader: object): void;
186
+ createProgram(): object | null;
187
+ attachShader(program: object, shader: object): void;
188
+ linkProgram(program: object): void;
189
+ getProgramParameter(program: object, pname: number): boolean;
190
+ getProgramInfoLog(program: object): string | null;
191
+ deleteProgram(program: object): void;
192
+ useProgram(program: object | null): void;
193
+ createBuffer(): object | null;
194
+ bindBuffer(target: number, buffer: object | null): void;
195
+ bufferData(target: number, data: Float32Array, usage: number): void;
196
+ deleteBuffer(buffer: object): void;
197
+ getAttribLocation(program: object, name: string): number;
198
+ enableVertexAttribArray(index: number): void;
199
+ vertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void;
200
+ getUniformLocation(program: object, name: string): object | null;
201
+ uniform1f(location: object | null, value: number): void;
202
+ uniform2f(location: object | null, x: number, y: number): void;
203
+ uniform3f(location: object | null, x: number, y: number, z: number): void;
204
+ uniform4f(location: object | null, x: number, y: number, z: number, w: number): void;
205
+ viewport(x: number, y: number, width: number, height: number): void;
206
+ drawArrays(mode: number, first: number, count: number): void;
207
+ clearColor(r: number, g: number, b: number, a: number): void;
208
+ clear(mask: number): void;
209
+ getExtension(name: string): unknown;
210
+ getParameter(pname: number): unknown;
211
+ }
212
+ /** WebGL context attributes the spec fixes. */
213
+ export interface ShaderContextAttributes {
214
+ readonly alpha: boolean;
215
+ readonly antialias: boolean;
216
+ readonly depth: boolean;
217
+ readonly stencil: boolean;
218
+ readonly powerPreference: 'low-power';
219
+ }
220
+ /** The canvas surface this renderer owns. */
221
+ export interface ShaderCanvasLike {
222
+ width: number;
223
+ height: number;
224
+ className: string;
225
+ style: {
226
+ width: string;
227
+ height: string;
228
+ };
229
+ getContext(contextId: 'webgl', attributes?: ShaderContextAttributes): ShaderGL | null;
230
+ addEventListener(type: 'webglcontextlost', listener: (event: ShaderContextLostEvent) => void): void;
231
+ removeEventListener(type: 'webglcontextlost', listener: (event: ShaderContextLostEvent) => void): void;
232
+ remove(): void;
233
+ }
234
+ /** The only context-loss field this renderer reads. */
235
+ export interface ShaderContextLostEvent {
236
+ preventDefault(): void;
237
+ }
238
+ /** The host element (`div#vx-bg`) as this renderer sees it. */
239
+ export interface ShaderHostLike {
240
+ readonly clientWidth: number;
241
+ readonly clientHeight: number;
242
+ getAttribute(name: string): string | null;
243
+ appendChild(node: ShaderCanvasLike): unknown;
244
+ style: {
245
+ getPropertyValue(name: string): string;
246
+ };
247
+ }
248
+ /** The slice of `Document` this renderer touches. */
249
+ export interface ShaderDocLike {
250
+ createElement(tag: string): ShaderCanvasLike;
251
+ addEventListener(type: 'visibilitychange', listener: () => void): void;
252
+ removeEventListener(type: 'visibilitychange', listener: () => void): void;
253
+ readonly hidden: boolean;
254
+ }
255
+ /** The slice of `MediaQueryList` this renderer touches. */
256
+ export interface ShaderMediaQueryLike {
257
+ readonly matches: boolean;
258
+ addEventListener(type: 'change', listener: () => void): void;
259
+ removeEventListener(type: 'change', listener: () => void): void;
260
+ }
261
+ /** The slice of `ResizeObserver` this renderer touches. */
262
+ export interface ShaderResizeObserverLike {
263
+ observe(target: unknown): void;
264
+ disconnect(): void;
265
+ }
266
+ /** The slice of `Window` this renderer touches. Pointer listeners are optional
267
+ * so a minimal test window without them still boots the tier (the eddy is
268
+ * simply inert there). */
269
+ export interface ShaderWinLike {
270
+ readonly devicePixelRatio: number;
271
+ readonly innerWidth?: number;
272
+ readonly innerHeight?: number;
273
+ requestAnimationFrame(callback: (now: number) => void): number;
274
+ cancelAnimationFrame(handle: number): void;
275
+ matchMedia(query: string): ShaderMediaQueryLike;
276
+ ResizeObserver?: new (callback: () => void) => ShaderResizeObserverLike;
277
+ addEventListener?(type: string, listener: (event: BgPointerEventLike) => void, options?: {
278
+ passive?: boolean;
279
+ }): void;
280
+ removeEventListener?(type: string, listener: (event: BgPointerEventLike) => void, options?: {
281
+ passive?: boolean;
282
+ }): void;
283
+ }
284
+ /** Observable renderer state; the live probe and tests read this. */
285
+ export interface ShaderBackdropStats {
286
+ level: number;
287
+ width: number;
288
+ height: number;
289
+ frames: number;
290
+ alive: boolean;
291
+ contextLost: boolean;
292
+ style: ShaderStyle;
293
+ /** Actual back-end string from `WEBGL_debug_renderer_info`, when exposed. */
294
+ renderer: string | null;
295
+ }
296
+ /** Options accepted by {@link createShaderBackdrop}. */
297
+ export interface ShaderBackdropOptions {
298
+ doc: ShaderDocLike;
299
+ win: ShaderWinLike;
300
+ host: ShaderHostLike;
301
+ style?: ShaderStyle;
302
+ /** Panel overrides for the boot style; clamps to its `ranges`. */
303
+ params?: ShaderParams;
304
+ /** Called once when the GPU drops this context. The caller falls back to
305
+ * ASCII; this renderer never tries to recover on its own. */
306
+ onFallback?: (reason: 'context-lost') => void;
307
+ }
308
+ /** Handle owned by the appearance painter. */
309
+ export interface ShaderBackdrop {
310
+ sync(): void;
311
+ /** Rebuild the program for another style. False means compile failed and
312
+ * the previous style is still live, so the caller can fall back. */
313
+ setStyle(style: ShaderStyle): boolean;
314
+ /** Replace the panel overrides for the current style. Values are clamped
315
+ * into that style's `ranges`; a style switch keeps the overrides and
316
+ * re-clamps them. Repaints immediately so a dragging slider is visible. */
317
+ setParams(params: ShaderParams): void;
318
+ /** Move the calm zone (the reading column); `null` disables the mask. */
319
+ setFocus(rect: BgFocusRect | null): void;
320
+ destroy(): void;
321
+ readonly stats: ShaderBackdropStats;
322
+ }
323
+ /**
324
+ * Create the shader backdrop and attach its canvas. Returns null when WebGL1
325
+ * is unavailable or the program does not compile; in that case the canvas is
326
+ * removed and no context is left alive, and the caller falls back to ASCII and
327
+ * tells the user.
328
+ */
329
+ export declare function createShaderBackdrop(options: ShaderBackdropOptions): ShaderBackdrop | null;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * A small height-field wave tank shared by interactive pieces.
3
+ *
4
+ * Diffusion alone only blurs an impulse; it never makes a ripple travel. This
5
+ * is a two-buffer wave equation instead: height `h` and vertical velocity `v`
6
+ * are advanced with a five-point Laplacian, damped, then swapped. A ring
7
+ * injection therefore expands, interferes with the next ring and dies out on
8
+ * its own — the property that makes dragging a finger on the water read as
9
+ * water rather than as a moving spotlight.
10
+ *
11
+ * Both passes are O(cols × rows), allocation-free, and the field is rebuilt
12
+ * only when the grid actually changes.
13
+ * @module @alexpeng/dsh-custom-plugin/client/bg-wake
14
+ */
15
+ /** Wave coupling. Above ~0.5 the explicit scheme is unstable in 2D. */
16
+ export declare const WAKE_C2 = 0.28;
17
+ /** Per-step velocity damping (energy loss). */
18
+ export declare const WAKE_DAMPING = 0.975;
19
+ /** Per-step height decay (slow return to flat water). */
20
+ export declare const WAKE_DECAY = 0.993;
21
+ /** Clamp so a burst of injections can never make the surface explode. */
22
+ export declare const WAKE_MAX = 1.4;
23
+ /** Two height buffers and two velocity buffers, all `cols × rows`. */
24
+ export interface BgWakeField {
25
+ cols: number;
26
+ rows: number;
27
+ height: Float32Array;
28
+ nextHeight: Float32Array;
29
+ velocity: Float32Array;
30
+ nextVelocity: Float32Array;
31
+ }
32
+ /** Allocate a flat field. */
33
+ export declare function createWakeField(cols: number, rows: number): BgWakeField;
34
+ /** Resize in place. Returns true when the grid changed and the caller must
35
+ * treat the surface as freshly flat. */
36
+ export declare function resizeWakeField(field: BgWakeField, cols: number, rows: number): boolean;
37
+ /** Drop every wave but keep the buffers. */
38
+ export declare function clearWake(field: BgWakeField): void;
39
+ /**
40
+ * Advance one step. The outer one-cell border is absorbing (zeroed) so the
41
+ * viewport edge does not act like a bathtub wall and bounce rings back.
42
+ */
43
+ export declare function stepWake(field: BgWakeField): void;
44
+ /**
45
+ * A soft circular depression (pointer drag). `radius` and `x/y` are in cells.
46
+ * The write is clamped to the field and never allocates.
47
+ */
48
+ export declare function injectWake(field: BgWakeField, x: number, y: number, radius: number, strength: number): void;
49
+ /**
50
+ * A ring impulse (a click). The profile is a Gaussian band around `radius`;
51
+ * `strength` may be negative for the rebound half of a splash.
52
+ */
53
+ export declare function injectWakeRing(field: BgWakeField, x: number, y: number, radius: number, width: number, strength: number): void;
54
+ /** A small wake behind a swimming fish. */
55
+ export declare function injectWakeTrail(field: BgWakeField, x: number, y: number, strength: number): void;
56
+ /** Nearest-cell height sample (used by fish steering and tests). */
57
+ export declare function sampleWake(field: BgWakeField, x: number, y: number): number;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `whale`: a large ASCII whale that crosses the page, with a spout and bubbles.
3
+ *
4
+ * The scene has three layers:
5
+ * 1. a very faint sea — drifting value-noise water plus two long swell lines
6
+ * that roll across the lower and middle bands of the page;
7
+ * 2. one whale, rasterised once from a hand-tuned outline into a cell mask
8
+ * (a shader-like silhouette with a character ramp inside: dark rim, mid
9
+ * spine, light belly, a hole for the eye and a darker mouth line), swimming
10
+ * leftwards with a slow bob and a tail that beats;
11
+ * 3. particles — a spout above the blowhole every few seconds, a bubble trail
12
+ * behind the tail, and a few bubbles where the user clicks.
13
+ *
14
+ * Every cell of the whale is marked in `emphasis`, so the calm zone may thin it
15
+ * but never erase it: a recognisable picture is the whole point of the preset,
16
+ * and the 0.15 floor would leave a ghost. The sea and the automatic bubbles
17
+ * are *not* marked — only the whale and the bubbles the user just caused keep
18
+ * the `EFFECT_FOCUS_FLOOR` strength inside the reading column.
19
+ *
20
+ * The pointer is felt, not obeyed: inside a 14-cell radius the whale speeds up
21
+ * a little and banks away vertically; a click inside 18 cells startles it (a
22
+ * short burst of speed plus a spout). Nothing here allocates per frame — the
23
+ * mask is module-level, the particle pool is fixed, the per-column swell scratch
24
+ * grows only with the grid.
25
+ * @module @alexpeng/dsh-custom-plugin/client/bg-whale
26
+ */
27
+ import { type AsciiPiece } from './bg-field.ts';
28
+ /** Mask-space size of the whale in grid cells. The cells are ~1.9× taller
29
+ * than wide, so 50×12 cells reads back as a ~3:1 silhouette on screen. */
30
+ export declare const WHALE_ART_W = 50;
31
+ export declare const WHALE_ART_H = 12;
32
+ /** One baked whale cell: offset from the mask origin, ramp level (0–9, mapped
33
+ * to the live ramp length at paint time), hole kind (0 none, 1 eye, 2 mouth)
34
+ * and tail weight. */
35
+ export interface WhaleCell {
36
+ readonly dx: number;
37
+ readonly dy: number;
38
+ readonly level: number;
39
+ readonly hole: 0 | 1 | 2;
40
+ readonly wag: number;
41
+ }
42
+ /**
43
+ * Rasterise the whale outline into cells. Runs once at module load: the rim is
44
+ * one step darker than the interior (and the interior darkens toward the
45
+ * spine), which is what draws the silhouette through the ramp alone, so a
46
+ * ~260-cell whale costs one blit per cell and no overlay pass at all.
47
+ */
48
+ export declare function buildWhaleCells(): WhaleCell[];
49
+ /** The baked mask, shared by every instance (it never changes). */
50
+ export declare const WHALE_CELLS: readonly WhaleCell[];
51
+ /**
52
+ * Create the whale piece. The returned function owns the whale position, the
53
+ * particle pool and the sea scratch; all three are reused for the piece's
54
+ * lifetime and reset only when the grid changes.
55
+ */
56
+ export declare function createWhalePiece(levels: number, dither: boolean): AsciiPiece;
@@ -63,7 +63,10 @@ export interface OverlayProps {
63
63
  useSessions: SnapshotSelectorHook<SessionListLike>;
64
64
  useWorkspaces: SnapshotSelectorHook<WorkspaceListLike>;
65
65
  }
66
- export interface QuoteDockProps extends SessionScopedProps {
66
+ /** Bridges the host's input actions into `insertDraft` so prompts and the
67
+ * command palette can write into the composer. Quote selection lives in DSH
68
+ * itself now, so this no longer owns a selection popup. */
69
+ export interface InputBridgeProps extends SessionScopedProps {
67
70
  input: InputStateLike;
68
71
  inputActions: InputActionsLike;
69
72
  }
@@ -2,7 +2,7 @@
2
2
  * Browser-half entry for dsh-custom-plugin.
3
3
  *
4
4
  * Mounts the Custom UI surfaces (overlay, timeline, folders, prompts,
5
- * balance, quote reply) through eight injections into seven official slots.
5
+ * balance) through eight injections into seven official slots.
6
6
  * The slots ledger is
7
7
  * the only coupling point: the declarations are provided by the web shell
8
8
  * itself, so this plugin needs no family-side integration to work. All
@@ -25,6 +25,59 @@ export declare function hexToRgb(hex: string): [number, number, number];
25
25
  * Invalid input degrades to a neutral gray at the same lightness.
26
26
  */
27
27
  export declare function toDarkRamp(hex: string, lightness: number): string;
28
+ /**
29
+ * Character ink for the ASCII backdrop: the surface keeps its hue, saturation
30
+ * is compressed the same way the dark ramp compresses it, and lightness moves
31
+ * by a fixed per-theme delta (up on dark surfaces, down on light ones), scaled
32
+ * by the caller (`inkScale`: one value per piece plus the user's strength
33
+ * choice). The target is "clearly on screen but not competing with body text",
34
+ * not WCAG text contrast.
35
+ *
36
+ * The two deltas are calibrated independently, from the composited page rather
37
+ * than the raw canvas, and on 2026-11-08 the light side was re-taken because
38
+ * the previous target was wrong: −0.31 measured 0.15% mean ink mass / 2.99%
39
+ * peak — but through the shell's stacked surfaces (≈10% transmission, see
40
+ * `BACKDROP_ALPHA_*`) and onto the `+` / `*` half of the ramp, whose glyphs
41
+ * cover 5.5% / 4.4% of a cell. The numbers described a picture the user
42
+ * correctly called "根本看不出来". −0.7 lands the ink at 179 luma under the
43
+ * surface (ink luma 55 on 234.8), and with the backdrop alphas and
44
+ * `FLOW_LEVEL_FLOOR` the on/off A/B is now an unmistakable character field in
45
+ * the margins and a faint texture behind the reading column.
46
+ *
47
+ * On the dark canvas (#1c1e21, 29.8 luma) the same *relative* step is
48
+ * perceptually much stronger, and the eye is also less sensitive at low
49
+ * luminance: the DeVries-Rose law puts the threshold contrast at roughly
50
+ * sqrt(234.8 / 29.8) ≈ 2.8× the light one, so a dark patch needs ~2.5–2.8× the
51
+ * light relative modulation to feel equal — not the same number. +0.38
52
+ * delivered 6.7× (9.37% Michelson) and read as the loudest thing on screen;
53
+ * +0.15 measures 2.1–2.7× on mean ink mass across all eight pieces (0.34% dark
54
+ * vs 0.15% light for `flow`; 8.17% vs 2.99% peak), i.e. inside that band.
55
+ * Going lower misses it: +0.10 only reaches 1.4×. Equalising the raw Michelson
56
+ * instead would need a ~1-luma step on dark, which is invisible.
57
+ */
58
+ export declare function inkFor(surfaceHex: string, dark: boolean, scale?: number): string;
59
+ /** Lower bound of the ink-strength multiplier. */
60
+ export declare const INK_SCALE_MIN = 0.4;
61
+ /** Upper bound of the ink-strength multiplier. */
62
+ export declare const INK_SCALE_MAX = 2.2;
63
+ /** Clamp an ink-strength multiplier; missing/non-finite means 1 (the
64
+ * calibrated per-theme delta). */
65
+ export declare function inkScaleFor(value: number | undefined): number;
66
+ /** Ink lightness drop from a light surface. Re-calibrated 2026-11-08 on the
67
+ * live Desktop host after the 1%-Michelson target was rejected by the user as
68
+ * "根本看不出来": the old −0.31 measured its numbers through the shell's ≈10%
69
+ * transmission window and on the light half of the ramp, which is "texture
70
+ * exists", not "texture is seen". −0.7 puts the ink at 179 luma under the
71
+ * surface; the live A/B target (关闭 vs 开启 一眼能分出来) is met together with
72
+ * the backdrop token alphas and `FLOW_LEVEL_FLOOR`. See {@link inkFor}. */
73
+ export declare const LIGHT_INK_DELTA = -0.7;
74
+ /** Ink lightness lift from a dark surface. Smaller in magnitude than the
75
+ * light drop on purpose: the DeVries-Rose threshold contrast at 29.8 luma is
76
+ * ~2.8× the light one, so dark needs a bigger *relative* step but a smaller
77
+ * absolute one. +0.15 measures 0.34% mean ink mass / 8.17% peak, i.e. 2.1–2.7×
78
+ * the light figure across pieces; the old +0.38 measured 6.7× and glared.
79
+ * See {@link inkFor}. */
80
+ export declare const DARK_INK_DELTA = 0.15;
28
81
  /** Body-canvas lightness for the dark variant of a palette family. */
29
82
  export declare const DARK_CANVAS_LIGHTNESS = 0.12;
30
83
  /** How much of a family's HSL saturation survives on the dark ramp. 0.55
@@ -32,3 +85,50 @@ export declare const DARK_CANVAS_LIGHTNESS = 0.12;
32
85
  * (gold / rose / peach) down from "eye-catching" to "ambient" on the dark
33
86
  * canvas; 0.4 turned them into mud, 0.7 still glared. */
34
87
  export declare const DARK_SATURATION_SCALE = 0.55;
88
+ /**
89
+ * Surface alpha of each shell background token while a backdrop renderer is
90
+ * mounted. The "veil" that makes the layer reachable at all.
91
+ *
92
+ * The layer is geometrically behind every content surface, so what the eye
93
+ * sees of it is the product of each stacked surface's *complement* alpha.
94
+ * Measured 2026-11-08 on the live Desktop host (1280×822 CSS, dpr 1.5,
95
+ * 天青灰 + glass): the reading column stacks three translucent surfaces
96
+ * (`--dsw-alias-bg-base` twice, `--dsw-alias-bg-layer-1` once) at the shell's
97
+ * glass values 0.5 / 0.5 / 0.6, so only **10%** of the ink reaches the eye —
98
+ * an ink step of 162 raw luma composites to 16 luma, which is why every ΔL
99
+ * calibration from the previous round measured "texture exists" and the user
100
+ * still saw nothing. The sidebar multiplied out to 24% the same way.
101
+ *
102
+ * These three values lower the alphas of the *same* RGB, so the page hue does
103
+ * not move at all (the canvas tint equals the family colour): the reading
104
+ * column now transmits ≈ 0.41 and the sidebar ≈ 0.40, i.e. 4× the ink, and
105
+ * cards / dialogs / the composer keep their own untouched opaque fills so
106
+ * text-heavy surfaces never get texture behind them. Only the three tokens
107
+ * measured in the live stack are overridden (`-bg-layer-2` and `-bg-overlay`
108
+ * are left alone: they paint menus and overlays, and no measured content
109
+ * surface sits behind them). Do not raise these back toward the shell values
110
+ * to "restore the glass look" — that is exactly the 10%-transmission state the
111
+ * user rejected.
112
+ */
113
+ export declare const BACKDROP_ALPHA_BASE = 0.25;
114
+ /** `--dsw-alias-bg-layer-1` — the frame and the outer content shell. */
115
+ export declare const BACKDROP_ALPHA_LAYER1 = 0.27;
116
+ /** `--dsw-specific-sidebar-fill` — the sidebar column (tab colour, a notch
117
+ * denser than the base). */
118
+ export declare const BACKDROP_ALPHA_SIDEBAR = 0.27;
119
+ /**
120
+ * Identity of the theme-token override an appearance repaint would install.
121
+ *
122
+ * Re-registering the very same variables through the theme service is a costly
123
+ * no-op: it re-applies tokens for the whole shell even when the palette and the
124
+ * glass toggle did not move (which is what every slider tick does). The painter
125
+ * compares this key and skips the registration when it has not changed.
126
+ *
127
+ * `'none'` means the painter leaves the shell's own tokens alone; `'neutral'`
128
+ * is the glass-only override; `'backdrop'` is the low-alpha override a mounted
129
+ * renderer needs (no palette); `palette:<name>|glass:<0|1>|backdrop:<0|1>` is a
130
+ * family override (glass changes the alpha form of the same values, and a
131
+ * mounted renderer replaces them with the backdrop alphas, so all three
132
+ * dimensions are part of the key).
133
+ */
134
+ export declare function appearanceTokenKey(bg: string | undefined, glass: boolean, backdrop?: boolean): string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Panel placement for the floating personalize panel.
3
+ *
4
+ * The panel is a non-modal popover over a live page: it must never cover the
5
+ * bottom input dock (the composer grows with the draft and moves between the
6
+ * hero and session layouts), must stay inside the viewport, and must keep the
7
+ * spot the user dragged it to unless that spot breaks either rule. All of that
8
+ * is geometry only, so it lives here as pure functions and is pinned by
9
+ * `tests/panel-bounds.spec.ts`; the DOM measurement stays in `custom.tsx`.
10
+ * @module @alexpeng/dsh-custom-plugin/client/panel-bounds
11
+ */
12
+ /** Kept between the panel's bottom edge and the composer's top edge. */
13
+ export declare const COMPOSER_CLEARANCE = 10;
14
+ export interface PanelSize {
15
+ readonly w: number;
16
+ readonly h: number;
17
+ }
18
+ /** Anything with an axis-aligned border box (a `DOMRect` satisfies this). */
19
+ export interface PanelBox {
20
+ readonly top: number;
21
+ readonly bottom: number;
22
+ readonly width: number;
23
+ readonly height: number;
24
+ }
25
+ export interface PanelFrameInput {
26
+ readonly viewport: PanelSize;
27
+ /** Where the panel sits when it has never been dragged. */
28
+ readonly preferred: {
29
+ readonly right: number;
30
+ readonly top: number;
31
+ };
32
+ readonly width: number;
33
+ readonly maxHeight: number;
34
+ /** Shortest usable panel: below this the body is unreadable, so the frame
35
+ * moves up instead of shrinking further. */
36
+ readonly minHeight: number;
37
+ readonly margin: number;
38
+ /** Viewport y of the protected strip (composer top minus clearance), or
39
+ * null when the page has no composer to avoid. */
40
+ readonly safeBottom: number | null;
41
+ /** Resting place from a previous drag, or null for the default anchor. */
42
+ readonly pos: {
43
+ readonly x: number;
44
+ readonly y: number;
45
+ } | null;
46
+ }
47
+ export interface PanelFrame {
48
+ readonly left: number;
49
+ readonly top: number;
50
+ readonly width: number;
51
+ readonly height: number;
52
+ }
53
+ /**
54
+ * Place the panel: clamp the width into the viewport, raise the bottom limit
55
+ * above the composer, shorten from the bottom (never from the top, which
56
+ * carries the drag handle), and clamp a dragged position on both axes.
57
+ */
58
+ export declare function panelFrame(input: PanelFrameInput): PanelFrame;
59
+ /**
60
+ * Pick the composer's top edge from the editable text boxes on the page: the
61
+ * composer is the lowest editable box with usable area. Returns null when the
62
+ * page shows none (a dialog-only screen), which leaves the panel on the
63
+ * viewport-height fallback.
64
+ */
65
+ export declare function pickComposerTop(boxes: readonly PanelBox[], viewport: PanelSize, minWidth?: number, minHeight?: number): number | null;