@alexpeng/dsh-custom-plugin 0.11.0 → 0.13.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/lib/index.js CHANGED
@@ -90,24 +90,49 @@ function mountOnce(packageName, fn) {
90
90
  const CUSTOM_PLUGIN_API_PREFIX = "/api/custom-plugin";
91
91
  /** Path the host serves the fetched Mermaid engine at (script src). */
92
92
  const MERMAID_SCRIPT_PATH = "/custom-plugin/mermaid.js";
93
- /** ASCII preset ids; keep in sync with `ASCII_PRESETS` in `client/bg-ascii.ts`. */
93
+ /** Character-tier scene ids; every one is an open-source `ascii-things`
94
+ * preset. Keep in sync with `SCENE_PRESETS` in `client/bg-scene.ts`. */
94
95
  const BG_FX_ASCII_PRESETS = [
95
- "flow",
96
- "rain",
97
- "ocean",
98
- "whale",
99
- "jelly",
100
- "starfield",
101
- "ripple",
102
- "static"
96
+ "sharks",
97
+ "jellyfish",
98
+ "robots",
99
+ "dog",
100
+ "reef",
101
+ "night",
102
+ "turtle",
103
+ "manta",
104
+ "dolphin",
105
+ "seahorse",
106
+ "hammerhead",
107
+ "tang",
108
+ "koi",
109
+ "starlings",
110
+ "fireflies",
111
+ "city",
112
+ "servers"
113
+ ];
114
+ /** Shader-tier style ids; every one is a Paper Shaders fragment shader.
115
+ * Keep in sync with `SHADER_STYLES` in `client/bg-shader.ts`. */
116
+ const BG_FX_SHADER_STYLES = [
117
+ "mesh",
118
+ "smoke",
119
+ "rays",
120
+ "dither",
121
+ "grain",
122
+ "warp",
123
+ "swirl",
124
+ "metaballs",
125
+ "voronoi",
126
+ "spiral",
127
+ "neuro"
103
128
  ];
104
- /** Shader style ids; keep in sync with `SHADER_STYLES` in `client/bg-shader.ts`. */
105
- const BG_FX_SHADER_STYLES = ["liquid", "grain"];
106
129
  /** Default configuration (also the composition-layer default). */
107
130
  const DEFAULT_CONFIG = {
108
131
  bg: "天青灰",
109
- bgFx: "none",
110
- bgFxPreset: "flow",
132
+ bgFx: "ascii",
133
+ bgFxPreset: "sharks",
134
+ bgAsciiPreset: "sharks",
135
+ bgShaderPreset: "mesh",
111
136
  bgStrength: "standard",
112
137
  bgDensity: -1,
113
138
  bgSpeed: -1,
@@ -116,6 +141,7 @@ const DEFAULT_CONFIG = {
116
141
  bgOpacity: -1,
117
142
  bgIntensity: -1,
118
143
  bgFocus: true,
144
+ bgLagoonInk: false,
119
145
  weather: "none",
120
146
  glass: true,
121
147
  glassMode: "frost",
@@ -372,13 +398,21 @@ function normalizeCfg(raw) {
372
398
  if (typeof value === "string") cfg[key] = value;
373
399
  }
374
400
  }
375
- if (typeof src.bgFx === "boolean") cfg.bgFx = src.bgFx ? "ascii" : "none";
376
- if (cfg.bgFx !== "none" && cfg.bgFx !== "ascii" && cfg.bgFx !== "shader") cfg.bgFx = "none";
401
+ if (src.bgFx !== void 0) {
402
+ if (typeof src.bgFx === "boolean") cfg.bgFx = src.bgFx ? "ascii" : "none";
403
+ else if (src.bgFx !== "none" && src.bgFx !== "ascii" && src.bgFx !== "shader") cfg.bgFx = "none";
404
+ }
377
405
  const shaderTier = cfg.bgFx === "shader";
406
+ const isAsciiPreset = (value) => typeof value === "string" && BG_FX_ASCII_PRESETS.includes(value);
407
+ const isShaderPreset = (value) => typeof value === "string" && BG_FX_SHADER_STYLES.includes(value);
408
+ const legacy = src.bgFxPreset;
409
+ if (src.bgAsciiPreset === void 0 && isAsciiPreset(legacy)) cfg.bgAsciiPreset = legacy;
410
+ if (src.bgShaderPreset === void 0 && isShaderPreset(legacy)) cfg.bgShaderPreset = legacy;
411
+ if (!isAsciiPreset(cfg.bgAsciiPreset)) cfg.bgAsciiPreset = "sharks";
412
+ if (!isShaderPreset(cfg.bgShaderPreset)) cfg.bgShaderPreset = "mesh";
378
413
  const allowed = shaderTier ? BG_FX_SHADER_STYLES : BG_FX_ASCII_PRESETS;
379
- const fallback = shaderTier ? "liquid" : "flow";
380
- const preset = cfg.bgFxPreset;
381
- if (typeof preset !== "string" || !allowed.includes(preset)) cfg.bgFxPreset = fallback;
414
+ const remembered = shaderTier ? cfg.bgShaderPreset : cfg.bgAsciiPreset;
415
+ if (typeof cfg.bgFxPreset !== "string" || !allowed.includes(cfg.bgFxPreset)) cfg.bgFxPreset = remembered;
382
416
  if (cfg.bgStrength !== "soft" && cfg.bgStrength !== "standard" && cfg.bgStrength !== "strong") cfg.bgStrength = "standard";
383
417
  for (const key of [
384
418
  "bgDensity",
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Shell-column measurement for the calm zone. The shell is a three-column
3
+ * grid (sidebar | centre | right panel) with hashed class names, so the centre
4
+ * column is found geometrically instead of by selector:
5
+ *
6
+ * - walk up from the composer to the nearest ancestor that spans ≥75% of the
7
+ * viewport and is ≥60% of its height — the shell frame;
8
+ * - inside it, the direct child that contains the composer is the centre
9
+ * column; at least one tall narrow sibling (sidebar/rail or right panel)
10
+ * must exist, otherwise there is no chrome to protect and the caller keeps
11
+ * the old single-rect behaviour;
12
+ * - the centre column must be at least 320×240 so a transient layout (or a
13
+ * hidden panel) cannot become the calm-zone bounds.
14
+ *
15
+ * The observer-driven veil needs the centre element, not only its rectangle;
16
+ * both wrappers below share the same walk.
17
+ *
18
+ * The DOM is injected structurally so the rule is unit-testable without jsdom.
19
+ */
20
+ /** Rectangle in CSS pixels, top-left origin, viewport coordinates. */
21
+ export interface BgColumnRect {
22
+ x: number;
23
+ y: number;
24
+ w: number;
25
+ h: number;
26
+ }
27
+ /** Minimal DOM node surface the measurement needs. */
28
+ export interface ColumnNodeLike {
29
+ getBoundingClientRect(): {
30
+ left: number;
31
+ top: number;
32
+ width: number;
33
+ height: number;
34
+ };
35
+ readonly parentElement: ColumnNodeLike | null;
36
+ readonly children: ArrayLike<ColumnNodeLike>;
37
+ contains(other: ColumnNodeLike): boolean;
38
+ }
39
+ /** Minimal document surface; only the body is used as the walk sentinel. */
40
+ export interface ColumnDocLike {
41
+ readonly body: ColumnNodeLike;
42
+ }
43
+ /** The centre column's DOM node, for a `ResizeObserver` that tracks its
44
+ * geometry frame-by-frame. */
45
+ export declare function findCenterColumnElement(doc: ColumnDocLike, anchor: ColumnNodeLike, viewportWidth: number, viewportHeight: number): ColumnNodeLike | null;
46
+ export declare function measureCenterColumn(doc: ColumnDocLike, anchor: ColumnNodeLike, viewportWidth: number, viewportHeight: number): BgColumnRect | null;
@@ -13,7 +13,8 @@
13
13
  * surfaces locally and native dialogs at z1000 paint above it.
14
14
  *
15
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`).
16
+ * mounts the open-source scene/shader backdrops inside this node
17
+ * (`bg-scene.ts` and `bg-shader.ts`).
17
18
  * @module @alexpeng/dsh-custom-plugin/client/bg-layer
18
19
  */
19
20
  /** DOM id of the owned background layer. */
@@ -35,7 +36,8 @@ export type BgLayerVerdict = {
35
36
  readonly motion: BgLayerMotion;
36
37
  };
37
38
  /** 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
+ * cached WebGL2 probe (Paper Shaders requires WebGL2); `canvas2d` is required
40
+ * by the character tier. */
39
41
  export interface BgFxCaps extends BgLayerCaps {
40
42
  readonly webgl: boolean;
41
43
  }
@@ -49,10 +51,10 @@ export type BgFxVerdict = {
49
51
  readonly tier: 'ascii' | 'shader';
50
52
  };
51
53
  /**
52
- * Gate for the full `bgFx` enum. The requested shader tier needs WebGL1; when
54
+ * Gate for the full `bgFx` enum. The requested shader tier needs WebGL2; when
53
55
  * 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
+ * character tier so the page keeps an animated background instead of dropping
57
+ * to the plain tint. When neither context exists there is nothing to draw, and
56
58
  * the caller leaves the body fill in place.
57
59
  */
58
60
  export declare function decideBgFxLayer(mode: 'none' | 'ascii' | 'shader', caps: BgFxCaps): BgFxVerdict;
@@ -124,29 +126,51 @@ export declare function mountBgLayer(doc: BgLayerDocLike, verdict: BgLayerMountV
124
126
  /** Remove the layer; a missing node is a no-op (fresh install / already off). */
125
127
  export declare function unmountBgLayer(doc: BgLayerDocLike): void;
126
128
  /**
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.
129
+ * Publish the calm veil's fill base on the layer. Dark mode reads it instead of
130
+ * the page tint, so the veil can fill with the scene's own visible base and
131
+ * only reduce local contrast (see `sceneVeilBase`); using the page tint over a
132
+ * bright lagoon is what turned the rectangle into a dark slab. Light mode keeps
133
+ * reading `--vx-bg-tint`, so setting this variable there is a harmless no-op.
134
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;
135
+ export declare function setBgVeilBase(doc: BgLayerDocLike, base: string): void;
136
+ /** Per-scene calm-veil recipe. Strings keep one helper usable from the scene
137
+ * wrapper (which owns the family) and the shader fallback in the client. */
138
+ export interface BgVeilLook {
139
+ readonly alpha: string;
140
+ readonly blur: string;
141
+ readonly feather: string;
142
142
  }
143
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.
144
+ * Apply the active scene family's veil recipe. The values are set inline on the
145
+ * veil, so they win over the stylesheet defaults; light mode uses the same
146
+ * 44% / 15px / 16px recipe as before, dark mode narrows the ambient blur so
147
+ * fireflies and other small lights survive, keeps ink glyphs legible, and
148
+ * leaves bright paintings with the wider feather.
149
+ */
150
+ export declare function setBgVeilLook(doc: BgLayerDocLike, look: BgVeilLook): void;
151
+ /** DOM id of the rectangular content veil inside the background layer. */
152
+ export declare const BG_VEIL_ID = "vx-bg-veil";
153
+ /** The veil's rectangle, viewport CSS px. */
154
+ export interface BgVeilRect {
155
+ x: number;
156
+ y: number;
157
+ w: number;
158
+ h: number;
159
+ }
160
+ /**
161
+ * The veil is one tinted DOM box over the shell's centre column. It replaces
162
+ * the canvas alpha mask: the faded region is always the same rectangle as the
163
+ * column (no diagonal/rounded feather shape), it can cover the whole column
164
+ * including the header/blank top, and its geometry is a CSS transition target
165
+ * so opening or closing a sidebar slides the faded area instead of flashing a
166
+ * new mask image.
167
+ */
168
+ export declare function ensureBgVeil(doc: BgLayerDocLike): BgLayerElementLike | null;
169
+ /**
170
+ * Place/hide the veil. The first placement is instant (`data-ready` is set in
171
+ * the next frame, after the geometry has been painted); later moves animate
172
+ * through the CSS transition. Outside the rectangle the background stays at
173
+ * full strength, which is what keeps the sidebars, logo and right panel from
174
+ * losing their texture.
151
175
  */
152
- export declare function pickColumnHost(chain: readonly ColumnHostCandidate[]): number;
176
+ export declare function applyBgVeil(doc: BgLayerDocLike, rect: BgVeilRect | null, visible: boolean): void;
@@ -9,7 +9,7 @@
9
9
  * themselves — this module never duplicates a bound.
10
10
  * @module @alexpeng/dsh-custom-plugin/client/bg-params
11
11
  */
12
- import { type AsciiParams, type AsciiPreset } from './bg-ascii.ts';
12
+ import { type SceneParams, type ScenePreset } from './bg-scene.ts';
13
13
  import { type ShaderParams, type ShaderStyle } from './bg-shader.ts';
14
14
  import { type BgFxPreset, type BgStrength, type CustomPluginConfig } from '../protocol.ts';
15
15
  /** Stored value meaning "follow the active preset's own default". */
@@ -32,13 +32,25 @@ export interface BgParamMeta {
32
32
  readonly decimals: number;
33
33
  }
34
34
  export declare const BG_PARAM_META: Record<BgParamKey, BgParamMeta>;
35
- /** Knobs the ASCII tier exposes, in render order. */
35
+ /** Knobs the character tier exposes, in render order. The scene runtime owns
36
+ * frame pacing and glyph size, so only the knobs it can honour are shown. */
36
37
  export declare const BG_ASCII_PARAM_KEYS: readonly BgParamKey[];
37
- /** Knobs the shader tier exposes, in render order (no font/opacity there). */
38
+ /** Knobs the shader tier exposes, in render order. */
38
39
  export declare const BG_SHADER_PARAM_KEYS: readonly BgParamKey[];
39
40
  /** Which sliders a tier shows. `none` shows none, so the panel can hide the
40
41
  * whole block instead of rendering disabled rows. */
41
- export declare function panelParamKeys(tier: BgTier): readonly BgParamKey[];
42
+ export declare function panelParamKeys(tier: BgTier, preset?: BgFxPreset): readonly BgParamKey[];
43
+ /** `单色印刷` only makes sense on a full-colour lagoon painting. */
44
+ export declare function showsLagoonInk(tier: BgTier, preset: BgFxPreset): boolean;
45
+ /** One caption + its preset buttons in the panel. */
46
+ export interface PresetGroup {
47
+ readonly id: 'ink' | 'lagoon' | 'ambient' | 'shader';
48
+ readonly label: string;
49
+ readonly presets: readonly BgFxPreset[];
50
+ }
51
+ /** Presets grouped by family. The dark-only ambient group disappears in light
52
+ * mode; the panel shows a note if the stored preset is hidden by the theme. */
53
+ export declare function presetGroups(tier: BgTier, dark: boolean): readonly PresetGroup[];
42
54
  /** Read the tier from a config snapshot; unknown modes are `none`. */
43
55
  export declare function tierFromCfg(cfg: CustomPluginConfig): BgTier;
44
56
  /**
@@ -96,11 +108,9 @@ export declare function clampInto(value: number, min: number, max: number): numb
96
108
  export declare function setParamInCfg(cfg: CustomPluginConfig, tier: BgTier, preset: BgFxPreset, key: BgParamKey, value: number): CustomPluginConfig;
97
109
  /** Clear every override so each preset's own defaults apply again. */
98
110
  export declare function resetBgParams(cfg: CustomPluginConfig): CustomPluginConfig;
99
- /** ASCII renderer overrides for the current config. All five knobs are
100
- * resolved, so a preset switch is handled by passing the new preset too; the
101
- * strength multiplier rides along as `strength`. */
102
- export declare function asciiParamsFromCfg(cfg: CustomPluginConfig, preset: AsciiPreset): AsciiParams;
103
- /** Shader renderer overrides for the current config. */
111
+ /** Character-tier renderer overrides for the current config. */
112
+ export declare function asciiParamsFromCfg(cfg: CustomPluginConfig, preset: ScenePreset): SceneParams;
113
+ /** Shader-tier renderer overrides for the current config. */
104
114
  export declare function shaderParamsFromCfg(cfg: CustomPluginConfig, style: ShaderStyle): ShaderParams;
105
115
  /** Timer surface the debounced saver needs; injectable for tests. */
106
116
  export interface DebounceTimers {
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Open-source ASCII scene backdrop.
3
+ *
4
+ * The character tier no longer hand-draws its pictures: each preset is a real
5
+ * scene from `ascii-things` (MIT, https://github.com/chuma-beep/ascii-things).
6
+ * Two families share this wrapper:
7
+ *
8
+ * - `ink` scenes (sharks, jellyfish) accept a palette, so they are rendered in
9
+ * the theme's own ink: a white canvas composited with `multiply` on light,
10
+ * a black one with `screen` on dark. The page tint never moves — only the
11
+ * glyphs darken/lighten it.
12
+ * - `lagoon` scenes are full-canvas paintings with their own authored colours
13
+ * (reef/night/turtle/manta/…). They cannot be re-paletted, so the wrapper
14
+ * keeps them at the preset's own opacity over the page tint.
15
+ *
16
+ * The calm zone is a separate tinted veil over the shell's centre column
17
+ * (`bg-layer.ts`), not a canvas mask: the renderer does not know where the
18
+ * content is. DPR, visibility pausing, reduced motion and resize are owned by
19
+ * the scene runtime inside `ascii-things`.
20
+ * @module @alexpeng/dsh-custom-plugin/client/bg-scene
21
+ */
22
+ import type { Palette } from 'ascii-things';
23
+ /** Scene ids the character tier can mount. */
24
+ export type ScenePreset = 'sharks' | 'jellyfish' | 'robots' | 'dog' | 'reef' | 'night' | 'turtle' | 'manta' | 'dolphin' | 'seahorse' | 'hammerhead' | 'tang' | 'koi' | 'starlings' | 'fireflies' | 'city' | 'servers';
25
+ /** Scene family: palette-driven ink, a full-colour lagoon painting, or a dark
26
+ * ambient scene (koi pond, starlings, city…). */
27
+ export type SceneKind = 'ink' | 'lagoon' | 'ambient';
28
+ /** Inclusive slider bounds a scene preset exposes. */
29
+ export interface SceneRange {
30
+ readonly min: number;
31
+ readonly max: number;
32
+ }
33
+ /** Writable bounds per scene preset. */
34
+ export interface SceneRanges {
35
+ readonly density: SceneRange;
36
+ readonly speed: SceneRange;
37
+ readonly opacity: SceneRange;
38
+ }
39
+ /** One scene's authored defaults. `columns` is the art-direction target at
40
+ * density 0.65; the density slider scales it. */
41
+ export interface SceneSpec {
42
+ readonly kind: SceneKind;
43
+ readonly variant?: 'reef' | 'night' | 'turtle' | 'manta' | 'seahorse' | 'dolphin' | 'hammerhead' | 'tang';
44
+ readonly columns: number;
45
+ readonly speed: number;
46
+ readonly opacity: number;
47
+ /** Ink multiplier for the palette-driven scenes; lagoons carry their own. */
48
+ readonly inkScale: number;
49
+ /** Backing-store pixel-ratio cap: full 2× for the crisp ink scenes, 1.5× for
50
+ * the painted/ambient scenes where the extra pixels buy little. */
51
+ readonly maxDpr: number;
52
+ /** Ambient paintings are authored on a dark backdrop and only make sense on
53
+ * a dark page; the wrapper falls back to `sharks` in light mode. */
54
+ readonly theme?: 'dark';
55
+ /** Average colour of the authored canvas, sampled before the page tint and
56
+ * the wrapper opacity are applied (headless Edge, ascii-things 1.1.1,
57
+ * 2026-12-06). Dark mode fills the calm veil with this colour instead of the
58
+ * page tint, so the rectangle only lowers local contrast and never shifts
59
+ * the scene's luminance. Ink scenes omit it: their `screen` composite leaves
60
+ * the tint itself as the visible base. */
61
+ readonly veilBase?: string;
62
+ readonly ranges: SceneRanges;
63
+ }
64
+ /** The shipped scene list. Every entry is a distinct scene from ascii-things —
65
+ * not one field with different knobs. */
66
+ export declare const SCENE_PRESETS: Record<ScenePreset, SceneSpec>;
67
+ /** Scene id fallback for a stale preset in the character tier. */
68
+ export declare const DEFAULT_SCENE: ScenePreset;
69
+ /** Resolve a stored id to a scene; unknown ids fall back to sharks. */
70
+ export declare function resolveScenePreset(preset: string | undefined): ScenePreset;
71
+ /** Theme gate for the dark-only ambient paintings. The stored preset is kept
72
+ * (so returning to dark restores it); only the renderer substitutes `sharks`
73
+ * while the page is light. */
74
+ export declare function scenePresetForTheme(preset: ScenePreset, dark: boolean): ScenePreset;
75
+ /** Scene params written by the panel; every field is already clamped. */
76
+ export interface SceneParams {
77
+ readonly density?: number;
78
+ readonly speed?: number;
79
+ readonly opacity?: number;
80
+ /** Ink-strength multiplier from `BG_STRENGTH_SCALE`. */
81
+ readonly strength?: number;
82
+ }
83
+ /** Resolved values after merging overrides with the preset's defaults. */
84
+ export interface SceneResolved {
85
+ readonly columns: number;
86
+ readonly speed: number;
87
+ readonly opacity: number;
88
+ readonly strength: number;
89
+ }
90
+ /** Merge panel overrides onto the preset defaults. Pure and testable. */
91
+ export declare function resolveSceneSpec(preset: ScenePreset, params: SceneParams): SceneResolved;
92
+ /** True when two resolved scene states would render identically, so a slider
93
+ * event that lands on the same quantised value does not touch the engine. */
94
+ export declare function sameSceneResolved(a: SceneResolved, b: SceneResolved): boolean;
95
+ /** Build the `setOptions` payload for a resolved-state change. Returning null
96
+ * means "nothing to send". The palette is attached only when an ink scene's
97
+ * strength actually changed, so dragging density/speed never rebuilds it. */
98
+ export declare function sceneSetOptionsPatch(prev: SceneResolved, next: SceneResolved, kind: SceneKind, palette: Palette): Record<string, unknown> | null;
99
+ /** How the scene canvas composites over the page tint. */
100
+ export interface SceneLook {
101
+ readonly opacity: number;
102
+ readonly blend: 'multiply' | 'screen' | 'normal';
103
+ readonly filter: string;
104
+ }
105
+ /**
106
+ * Target luma of the *visible* scene base in dark mode, after the wrapper
107
+ * opacity and the exposure are applied. 88 keeps the bright lagoon paintings
108
+ * readable as colour on a dark page instead of nearly black, while the
109
+ * content column still lands below the old bright lagoon sides and the veil
110
+ * base matches the scene so no rectangle appears. Tune this one number, not
111
+ * the veil alpha, when the dark aquarium needs to be brighter or dimmer.
112
+ */
113
+ export declare const DARK_SCENE_TARGET_LUMA = 88;
114
+ /** Dark-mode brightness lift for the near-black ambient scenes. Fireflies and
115
+ * the other night paintings are mostly black with tiny lights; at the shell's
116
+ * 40% transmission they read as an empty page. The lift makes the lights
117
+ * survive without turning the background into a lit panel. */
118
+ export declare const DARK_AMBIENT_BOOST = 1.35;
119
+ /** Visual treatment for one scene. Ink scenes always follow the theme;
120
+ * lagoons keep their authored colour unless the user turns on 单色印刷, which
121
+ * grayscales them and lets the page tint supply the duotone. Ambient scenes
122
+ * are dark-only and composite normally.
123
+ *
124
+ * `exposure` is the dark-mode global dim computed by {@link sceneExposure}. It
125
+ * is applied to the canvas itself, never to the calm veil: a rectangular veil
126
+ * that dims a bright painting is exactly what made the content column read as
127
+ * a pasted dark slab. */
128
+ export declare function sceneLook(spec: SceneSpec, dark: boolean, lagoonInk: boolean, opacity: number, exposure?: number): SceneLook;
129
+ /** Per-family calm-veil recipe. The veil lowers local contrast behind the
130
+ * transcript; it must not erase the scene. Glyph scenes draw at 8–14px, so a
131
+ * backdrop blur of even a few pixels merges neighbouring characters into flat
132
+ * blobs (the reported "背景动效全部糊没了") — ink and ambient scenes keep 0px
133
+ * and the tint does the calming. Only the painted lagoons, whose texture is
134
+ * much larger than a glyph, keep a small softening pass. The dark ambient
135
+ * scenes get the lightest tint so fireflies and other small lights survive. */
136
+ export interface SceneVeilLook {
137
+ readonly alpha: string;
138
+ readonly blur: string;
139
+ readonly feather: string;
140
+ }
141
+ export declare function sceneVeilLook(kind: SceneKind, dark: boolean): SceneVeilLook;
142
+ /**
143
+ * Dark-mode exposure for a scene, derived from its sampled canvas base and the
144
+ * resolved opacity. Ink scenes leave the tint as their base, ambient scenes
145
+ * already sit below the target, and the dark lagoon variant is dark enough, so
146
+ * all three return 1. Bright lagoon paintings are dimmed *globally* here; the
147
+ * calm veil must never be the thing that darkens the content column.
148
+ */
149
+ export declare function sceneExposure(spec: SceneSpec, tint: string, dark: boolean, opacity: number): number;
150
+ /**
151
+ * The colour the dark calm veil fills with: the scene's own visible base
152
+ * (authored average → exposure → opacity × tint), not the page tint. Matching
153
+ * the base is what makes the veil only reduce local contrast; using the page
154
+ * tint instead turns it into a dark slab over bright lagoons and a light grey
155
+ * panel over near-black ambient scenes.
156
+ */
157
+ export declare function sceneVeilBase(spec: SceneSpec, tint: string, dark: boolean, opacity: number, exposure?: number): string;
158
+ /**
159
+ * Build the palette the ink scenes render with. The page tint supplies the
160
+ * ink hue (through `inkFor`'s lightness step), and the five fish levels become
161
+ * alphas of that single colour, so the scene stays monochrome and theme-aware.
162
+ */
163
+ export declare function scenePalette(tint: string, dark: boolean, strength: number): Palette;
164
+ /** The slice of a canvas element this module touches. */
165
+ export interface SceneCanvasLike {
166
+ width: number;
167
+ height: number;
168
+ readonly clientWidth: number;
169
+ readonly clientHeight: number;
170
+ style: Record<string, string>;
171
+ getContext(type: string): SceneCtxLike | null;
172
+ remove(): void;
173
+ }
174
+ /** The slice of a 2D context the mask builder needs. */
175
+ export interface SceneCtxLike {
176
+ createImageData(w: number, h: number): {
177
+ data: Uint8ClampedArray;
178
+ };
179
+ putImageData(image: {
180
+ data: Uint8ClampedArray;
181
+ }, x: number, y: number): void;
182
+ }
183
+ /** The slice of `document` this module touches. */
184
+ export interface SceneDocLike {
185
+ createElement(tag: string): SceneCanvasLike & {
186
+ toDataURL(): string;
187
+ };
188
+ }
189
+ /** The layer host (`div#vx-bg`). */
190
+ export interface SceneHostLike {
191
+ appendChild(node: unknown): unknown;
192
+ style: Record<string, string>;
193
+ getAttribute?: (name: string) => string | null;
194
+ }
195
+ /** Read the plugin's motion attribute so the scene tier pauses exactly like
196
+ * the shader tier when the page is hidden or reduced motion is requested. */
197
+ export declare function sceneMotion(host: SceneHostLike): 'animated' | 'paused' | 'static';
198
+ /** Options for {@link createSceneBackdrop}. */
199
+ export interface SceneBackdropOptions {
200
+ readonly doc: SceneDocLike;
201
+ readonly host: SceneHostLike;
202
+ readonly preset: ScenePreset;
203
+ readonly params: SceneParams;
204
+ readonly tint: string;
205
+ readonly dark: boolean;
206
+ /** 单色印刷 for lagoon paintings; ignored by ink/ambient scenes. */
207
+ readonly lagoonInk?: boolean;
208
+ }
209
+ /** The mounted scene renderer. */
210
+ export interface SceneBackdrop {
211
+ sync(): void;
212
+ setPreset(preset: ScenePreset): void;
213
+ setParams(params: SceneParams): void;
214
+ setLagoonInk(on: boolean): void;
215
+ setTint(tint: string, dark: boolean): void;
216
+ /** Visible scene base for the dark calm veil (see {@link sceneVeilBase}). */
217
+ veilBase(): string;
218
+ /** Per-family veil recipe for the current theme (see {@link sceneVeilLook}). */
219
+ veilLook(): SceneVeilLook;
220
+ destroy(): void;
221
+ }
222
+ /** Create the scene canvas and mount the active ascii-things engine. */
223
+ export declare function createSceneBackdrop(options: SceneBackdropOptions): SceneBackdrop;