@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/CHANGELOG.md +224 -0
- package/NOTICE +35 -45
- package/README.i18n.yaml +2 -2
- package/README.md +14 -11
- package/README.zh.md +13 -10
- package/lib/client.js +13676 -5118
- package/lib/client.js.map +1 -1
- package/lib/index.js +52 -18
- package/lib/types/client/bg-columns.d.ts +46 -0
- package/lib/types/client/bg-layer.d.ts +51 -27
- package/lib/types/client/bg-params.d.ts +19 -9
- package/lib/types/client/bg-scene.d.ts +223 -0
- package/lib/types/client/bg-shader.d.ts +106 -267
- package/lib/types/client/glass/ambient.d.ts +18 -0
- package/lib/types/client/glass/glass-engine.d.ts +58 -0
- package/lib/types/client/glass/glass-tokens.d.ts +111 -0
- package/lib/types/client/glass/host-surfaces.d.ts +96 -0
- package/lib/types/client/glass/liquid-filter.d.ts +90 -0
- package/lib/types/client/palette.d.ts +15 -9
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/client/ui/appearance-controls.d.ts +1 -0
- package/lib/types/client/ui/overlays.d.ts +13 -0
- package/lib/types/protocol.d.ts +35 -19
- package/package.json +5 -2
- package/lib/types/balance.d.ts +0 -44
- package/lib/types/client/bg-ascii.d.ts +0 -405
- package/lib/types/client/bg-field.d.ts +0 -62
- package/lib/types/client/bg-focus.d.ts +0 -63
- package/lib/types/client/bg-jelly.d.ts +0 -53
- package/lib/types/client/bg-ocean.d.ts +0 -31
- package/lib/types/client/bg-pointer.d.ts +0 -107
- package/lib/types/client/bg-wake.d.ts +0 -57
- package/lib/types/client/bg-whale.d.ts +0 -56
|
@@ -1,107 +0,0 @@
|
|
|
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;
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,56 +0,0 @@
|
|
|
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;
|