@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,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;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `ocean` 2.0: a living water surface instead of two fixed sine swells.
3
+ *
4
+ * Three layers make the scene:
5
+ * 1. a divergence-free current (the curl of a drifting stream function) that
6
+ * moves the whole surface without piling water into one corner;
7
+ * 2. a {@link BgWakeField} wave tank. Pointer drags, clicks and fish wakes
8
+ * inject height impulses that propagate, interfere and fade — the water
9
+ * remembers what touched it;
10
+ * 3. eighteen small fish plus two large koi. Steering is boids-lite
11
+ * (alignment / cohesion / separation / mill); the pointer pushes them
12
+ * away and a click startles the school, which then regroups.
13
+ *
14
+ * The piece writes only ramp levels plus two optional per-cell buffers:
15
+ * `emphasis` marks interaction cells so the renderer may keep them visible at
16
+ * a reduced strength inside the calm zone, and `overlay` carries the fish
17
+ * glyphs (direction marks for the small fish, body/edge/head/tail cells for
18
+ * the koi). The renderer draws those with `fillText` after the atlas blit, so
19
+ * no second atlas is needed.
20
+ *
21
+ * The flow-field constants are re-derived for grid cells; the stream-function
22
+ * form follows `stackedlol/ascii-sharks` (MIT, see NOTICE). No code from the
23
+ * `dsh-ascii-ocean` plugin is copied — its LICENSE file has no licence text.
24
+ * @module @alexpeng/dsh-custom-plugin/client/bg-ocean
25
+ */
26
+ import { type AsciiPiece } from './bg-field.ts';
27
+ /**
28
+ * Create the ocean piece. The returned function owns its wake tank and fish
29
+ * arrays; they are rebuilt only when the grid changes, never per frame.
30
+ */
31
+ export declare function createOceanPiece(levels: number, dither: boolean): AsciiPiece;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * The background-motion panel's pure half: which knobs a tier exposes, how a
3
+ * stored flat value maps onto a preset's declared `ranges`, and the debounced
4
+ * saver the sliders use.
5
+ *
6
+ * Everything here is React-free and DOM-free on purpose. The panel component
7
+ * only renders; all clamping, fallback and timing rules live in functions a
8
+ * node test can call directly. The two renderer modules own the `ranges`
9
+ * themselves — this module never duplicates a bound.
10
+ * @module @alexpeng/dsh-custom-plugin/client/bg-params
11
+ */
12
+ import { type AsciiParams, type AsciiPreset } from './bg-ascii.ts';
13
+ import { type ShaderParams, type ShaderStyle } from './bg-shader.ts';
14
+ import { type BgFxPreset, type BgStrength, type CustomPluginConfig } from '../protocol.ts';
15
+ /** Stored value meaning "follow the active preset's own default". */
16
+ export declare const BG_PARAM_UNSET = -1;
17
+ /** Slider debounce: one POST per pause, not one per input event. */
18
+ export declare const BG_PARAM_SAVE_MS = 320;
19
+ /** The three-tier value space of `bgFx`. */
20
+ export type BgTier = 'none' | 'ascii' | 'shader';
21
+ /** Every knob the panel can render. */
22
+ export type BgParamKey = 'density' | 'speed' | 'fps' | 'fontPx' | 'opacity' | 'intensity';
23
+ /** The flat config field that stores one knob. */
24
+ export type BgParamCfgKey = 'bgDensity' | 'bgSpeed' | 'bgFps' | 'bgFontPx' | 'bgOpacity' | 'bgIntensity';
25
+ /** Presentation metadata for one slider row. */
26
+ export interface BgParamMeta {
27
+ readonly key: BgParamKey;
28
+ readonly cfgKey: BgParamCfgKey;
29
+ readonly label: string;
30
+ readonly unit: string;
31
+ readonly step: number;
32
+ readonly decimals: number;
33
+ }
34
+ export declare const BG_PARAM_META: Record<BgParamKey, BgParamMeta>;
35
+ /** Knobs the ASCII tier exposes, in render order. */
36
+ export declare const BG_ASCII_PARAM_KEYS: readonly BgParamKey[];
37
+ /** Knobs the shader tier exposes, in render order (no font/opacity there). */
38
+ export declare const BG_SHADER_PARAM_KEYS: readonly BgParamKey[];
39
+ /** Which sliders a tier shows. `none` shows none, so the panel can hide the
40
+ * whole block instead of rendering disabled rows. */
41
+ export declare function panelParamKeys(tier: BgTier): readonly BgParamKey[];
42
+ /** Read the tier from a config snapshot; unknown modes are `none`. */
43
+ export declare function tierFromCfg(cfg: CustomPluginConfig): BgTier;
44
+ /**
45
+ * Ink-strength multipliers on top of each piece's calibrated ink step.
46
+ *
47
+ * Re-scaled on 2026-11-11: the user found the old `standard` (1.0×) too dark,
48
+ * so the default moved to the value he had been using as 柔和 (0.62×) and the
49
+ * whole ladder was shifted down — 柔和 0.45× / 标准 0.62× / 强烈 0.9×. They
50
+ * scale only the ink's lightness step; the grid geometry, speed and frame
51
+ * pacing are untouched.
52
+ */
53
+ export declare const BG_STRENGTH_SCALE: Record<BgStrength, number>;
54
+ /** Presentation order and labels of the three strength choices. The labels
55
+ * are 柔和 / 标准 / 强烈 (2026-11-11): the first step keeps its original name
56
+ * and the top step is 强烈; the stored values and scales never moved. */
57
+ export declare const BG_STRENGTH_META: ReadonlyArray<{
58
+ readonly value: BgStrength;
59
+ readonly label: string;
60
+ }>;
61
+ /** Read the strength from a config snapshot; unknown values are 'soft'. */
62
+ export declare function strengthFromCfg(cfg: CustomPluginConfig): BgStrength;
63
+ /** Write the strength into a config snapshot (shallow copy, like every panel
64
+ * edit). The value space is closed, so an unknown input lands on 'standard'. */
65
+ export declare function setStrengthInCfg(cfg: CustomPluginConfig, value: BgStrength): CustomPluginConfig;
66
+ /**
67
+ * Pick the preset a tier can mount. Switching tiers with a preset id from the
68
+ * other tier (or a hand-edited unknown value) lands on that tier's default
69
+ * instead of mounting a piece the renderer does not know.
70
+ */
71
+ export declare function presetForTier(tier: BgTier, preset: string | undefined): BgFxPreset;
72
+ /** Inclusive slider bounds for one knob, or null when the tier has no such
73
+ * knob. Reads the active preset's own `ranges` — never a local copy. */
74
+ export declare function paramRange(tier: BgTier, preset: BgFxPreset, key: BgParamKey): {
75
+ min: number;
76
+ max: number;
77
+ } | null;
78
+ /** The preset's own value for a knob. */
79
+ export declare function paramDefault(tier: BgTier, preset: BgFxPreset, key: BgParamKey): number;
80
+ /** True when the stored value is a real override (anything but the sentinel). */
81
+ export declare function paramConfigured(cfg: CustomPluginConfig, key: BgParamKey): boolean;
82
+ /**
83
+ * The value a slider should display: the stored override clamped into the
84
+ * current preset's range, or that preset's default when unset. An unknown
85
+ * preset already resolved to the tier default upstream.
86
+ */
87
+ export declare function effectiveParam(cfg: CustomPluginConfig, tier: BgTier, preset: BgFxPreset, key: BgParamKey): number;
88
+ /** Clamp a number into an inclusive band. Non-finite values take the minimum,
89
+ * which is the conservative choice for every knob here. */
90
+ export declare function clampInto(value: number, min: number, max: number): number;
91
+ /**
92
+ * Write one slider value into a config snapshot: clamp first, then overwrite
93
+ * the flat field. The cfg object is shallow-copied, matching every other panel
94
+ * edit, so the store can diff and subscribers re-render once.
95
+ */
96
+ export declare function setParamInCfg(cfg: CustomPluginConfig, tier: BgTier, preset: BgFxPreset, key: BgParamKey, value: number): CustomPluginConfig;
97
+ /** Clear every override so each preset's own defaults apply again. */
98
+ 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. */
104
+ export declare function shaderParamsFromCfg(cfg: CustomPluginConfig, style: ShaderStyle): ShaderParams;
105
+ /** Timer surface the debounced saver needs; injectable for tests. */
106
+ export interface DebounceTimers {
107
+ set(callback: () => void, delayMs: number): unknown;
108
+ clear(handle: unknown): void;
109
+ }
110
+ /** Handle returned by {@link createDebouncedSaver}. */
111
+ export interface DebouncedSaver {
112
+ /** (Re)start the timer; a burst of calls still fires `save` once. */
113
+ push(): void;
114
+ /** Drop the pending call, e.g. when "restore defaults" saves immediately. */
115
+ cancel(): void;
116
+ isPending(): boolean;
117
+ }
118
+ /**
119
+ * One timer per burst: every slider input restarts it, and only the pause
120
+ * after the last event POSTs. The save reads the live store when it fires, so
121
+ * the debounced write always carries the final value.
122
+ */
123
+ export declare function createDebouncedSaver(save: () => void, delayMs: number, timers?: DebounceTimers): DebouncedSaver;
124
+ /** The slice the appearance tab subscribes to. Kept as one named function so
125
+ * a test can pin the scope: the tab never subscribes to turns, toasts, usage
126
+ * or any other per-turn field. */
127
+ export declare function selectAppearanceSlice(state: {
128
+ cfg: CustomPluginConfig;
129
+ dark: boolean;
130
+ }): {
131
+ cfg: CustomPluginConfig;
132
+ dark: boolean;
133
+ };
134
+ /**
135
+ * The one-line note the panel shows when the active preset draws exactly one
136
+ * frame and never animates. Switching to such a preset looks like "nothing
137
+ * happened" because the still picture is the whole point, so the panel says so
138
+ * in place instead of firing a toast. Returns null for every animated preset.
139
+ */
140
+ export declare function presetStillNote(tier: BgTier, preset: BgFxPreset): string | null;
141
+ /** Every preset id the active tier can show, in panel order. */
142
+ export declare function tierPresets(tier: BgTier): readonly BgFxPreset[];
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Passive pointer state for the background pieces.
3
+ *
4
+ * The backdrop canvas deliberately carries `pointer-events:none` and sits
5
+ * below the content surfaces, so it can never receive a pointer event itself.
6
+ * A window-level listener is the only way to know where the pointer is, and it
7
+ * must be *passive*: the background is decoration, never allowed to delay a
8
+ * scroll, a selection or a click. Nothing here starts a frame — the renderer
9
+ * calls {@link syncBgPointer} once per existing frame, so interaction adds no
10
+ * second rAF loop.
11
+ *
12
+ * Two rules make the pointer read as weight instead of a teleporting cursor:
13
+ * the position follows the raw sample with a short time constant
14
+ * ({@link POINTER_POS_TAU_MS}) and the velocity with a slightly longer one
15
+ * ({@link POINTER_VEL_TAU_MS}). Both are advanced by the event handlers *and*
16
+ * by `syncBgPointer` against one monotonic clock, so the easing is frame-rate
17
+ * independent instead of depending on how often the browser delivers moves.
18
+ * While the pointer rests the velocity is damped out and is exactly zero after
19
+ * {@link POINTER_IDLE_MS}, so an inertia field cannot keep blowing on a stale
20
+ * sample; a drift slower than {@link POINTER_DEAD_SPEED} reports no force at
21
+ * all, which is what keeps a hand resting on the mouse from stirring the page.
22
+ * @module @alexpeng/dsh-custom-plugin/client/bg-pointer
23
+ */
24
+ /** The slice of `PointerEvent` this module reads. Structural so tests can
25
+ * dispatch plain objects and the DOM needs no cast at the call site. */
26
+ export interface BgPointerEventLike {
27
+ clientX: number;
28
+ clientY: number;
29
+ pointerType?: string;
30
+ button?: number;
31
+ }
32
+ /** The slice of a `Window`-shaped target this module touches. */
33
+ export interface BgPointerTargetLike {
34
+ addEventListener(type: string, listener: (event: BgPointerEventLike) => void, options?: {
35
+ passive?: boolean;
36
+ }): void;
37
+ removeEventListener(type: string, listener: (event: BgPointerEventLike) => void, options?: {
38
+ passive?: boolean;
39
+ }): void;
40
+ }
41
+ /** Mutable state the renderer reads once per frame. */
42
+ export interface BgPointerState {
43
+ /** Eased position in CSS pixels, heading for `targetX` / `targetY`. */
44
+ x: number;
45
+ y: number;
46
+ /** A pointer has been seen and has not left the window since. */
47
+ active: boolean;
48
+ /** Primary button held down. */
49
+ down: boolean;
50
+ /** Reported smoothed velocity in CSS pixels per second. Zero below the dead
51
+ * speed and after {@link POINTER_IDLE_MS} of no input. */
52
+ vx: number;
53
+ vy: number;
54
+ /** Increments once per primary press. */
55
+ pulseId: number;
56
+ /** Press position in CSS pixels (raw, never eased: a click lands where the
57
+ * user clicked). */
58
+ pulseX: number;
59
+ pulseY: number;
60
+ /** Raw position the eased one is heading for, CSS pixels. */
61
+ targetX: number;
62
+ targetY: number;
63
+ /** Smoothed velocity at the last accepted move, before the idle damping;
64
+ * `vx` / `vy` are derived from it on every frame. */
65
+ rawVx: number;
66
+ rawVy: number;
67
+ /** Clock reading of the last accepted input, ms. -1 until the first one,
68
+ * and again after the pointer leaves. */
69
+ lastInputAt: number;
70
+ /** Clock reading of the last eased-position step, ms. */
71
+ lastPosAt: number;
72
+ }
73
+ /** Time constant of the position follow. At a 110 Hz pointer this is the
74
+ * `lerp ≈ 0.15` feel the interaction round settled on; because the step is
75
+ * time-based it stays the same at 60 Hz or 1000 Hz. */
76
+ export declare const POINTER_POS_TAU_MS = 70;
77
+ /** Time constant of the velocity smoothing. Longer than the position: force
78
+ * should ramp, not spike, when the hand changes direction. */
79
+ export declare const POINTER_VEL_TAU_MS = 90;
80
+ /** Below this speed the reported velocity is zero: a slow drift must not
81
+ * stir the fog, bend the rain or spin the eddy. The onset is a smoothstep up
82
+ * to twice this value, so crossing it never steps the force. */
83
+ export declare const POINTER_DEAD_SPEED = 80;
84
+ /** No input for this long and every interaction value is zero. */
85
+ export declare const POINTER_IDLE_MS = 1500;
86
+ /** One monotonic clock for the listeners and the frame-time sync. Exported so
87
+ * a test or a harness can drive both sides on the same clock. */
88
+ export declare function bgPointerClock(): number;
89
+ /** A fresh, inactive state. The struct is reused for the life of a renderer. */
90
+ export declare function createBgPointerState(): BgPointerState;
91
+ /** Reset in place (destroy / preset switch); no allocation. */
92
+ export declare function resetBgPointerState(state: BgPointerState): void;
93
+ /**
94
+ * Advance interaction time once per rendered frame. Called by both tiers
95
+ * before they read the pointer: the eased position keeps converging after the
96
+ * last event, the velocity damps out while the pointer rests, and after
97
+ * {@link POINTER_IDLE_MS} every value is exactly zero with the position
98
+ * snapped onto the target. A renderer that is not drawing never calls this,
99
+ * so a paused page cannot be woken up by the pointer.
100
+ */
101
+ export declare function syncBgPointer(state: BgPointerState, now?: number): void;
102
+ /**
103
+ * Attach the passive listeners. Touch moves are ignored (the user is
104
+ * scrolling); a touch tap still counts as a press. Returns the disposer, which
105
+ * removes exactly the listeners it added.
106
+ */
107
+ export declare function attachBgPointer(target: BgPointerTargetLike, state: BgPointerState, clock?: () => number): () => void;