@hadoku/ui-shell 0.1.274 → 0.1.276

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.
@@ -0,0 +1,17 @@
1
+ import { type MotionContext } from '../motion/index.js';
2
+ /**
3
+ * A blow's context, built where the blow is: `overlay`'s particle pool, and the board's stage, of which every
4
+ * blow's Web Animation is a beat (no hold: what a blow is drawn for is held by the view that drew it). Reduced
5
+ * motion is the caller's: it draws none.
6
+ */
7
+ export declare function motionContext(overlay: HTMLElement, tempo?: number): MotionContext;
8
+ /**
9
+ * A small, stable hash of a hit's key: the same key always draws the same arc. FNV-1a alone barely
10
+ * moves when only a key's LAST character differs (measured: `…:pr1`…`:pr8` landed within 0.351–0.398,
11
+ * every seeded visual whose key ends in a counter — a sweeper's balls, a landing's cracks `l${i}`/`w${i}`/
12
+ * `t${i}` — nearly uniform), so the hash is finished with a murmur3 `fmix32`: every bit of the input
13
+ * spreads before the division, deterministic on both screens either way.
14
+ */
15
+ export declare function seedOf(key: string): number;
16
+ /** A damage effect's size at `power` (0 to 1), a ball and its burst or a crash: four fifths at none, two and a half at the heaviest. */
17
+ export declare function damageSize(power: number): number;
@@ -0,0 +1,35 @@
1
+ /* What every effect is drawn with: its context on the board's stage, its seeded randomness and its size by weight. */
2
+ import { everyFrame, particlePool, Stage } from "../motion/index.js";
3
+ /**
4
+ * A blow's context, built where the blow is: `overlay`'s particle pool, and the board's stage, of which every
5
+ * blow's Web Animation is a beat (no hold: what a blow is drawn for is held by the view that drew it). Reduced
6
+ * motion is the caller's: it draws none.
7
+ */
8
+ export function motionContext(overlay, tempo = 1) {
9
+ const stage = Stage.of(overlay) ?? new Stage();
10
+ // What a blow draws there by stylesheet (`crash.css`, `projectile.css`) is a beat too.
11
+ stage.trackCss(overlay, 'effect-');
12
+ return { stage, overlay, tempo, reduced: false, frame: everyFrame, particles: particlePool(overlay) };
13
+ }
14
+ /**
15
+ * A small, stable hash of a hit's key: the same key always draws the same arc. FNV-1a alone barely
16
+ * moves when only a key's LAST character differs (measured: `…:pr1`…`:pr8` landed within 0.351–0.398,
17
+ * every seeded visual whose key ends in a counter — a sweeper's balls, a landing's cracks `l${i}`/`w${i}`/
18
+ * `t${i}` — nearly uniform), so the hash is finished with a murmur3 `fmix32`: every bit of the input
19
+ * spreads before the division, deterministic on both screens either way.
20
+ */
21
+ export function seedOf(key) {
22
+ let h = 2166136261;
23
+ for (let i = 0; i < key.length; i++)
24
+ h = Math.imul(h ^ key.charCodeAt(i), 16777619);
25
+ h ^= h >>> 16;
26
+ h = Math.imul(h, 0x85ebca6b);
27
+ h ^= h >>> 13;
28
+ h = Math.imul(h, 0xc2b2ae35);
29
+ h ^= h >>> 16;
30
+ return (h >>> 0) / 4294967296;
31
+ }
32
+ /** A damage effect's size at `power` (0 to 1), a ball and its burst or a crash: four fifths at none, two and a half at the heaviest. */
33
+ export function damageSize(power) {
34
+ return 0.8 + 1.7 * power;
35
+ }
@@ -0,0 +1,94 @@
1
+ /*
2
+ * A ram's crash (`crash.ts`): a ring of dust, puffs of it, and chips of rock thrown out and falling.
3
+ * Drawn in neutral colours — dust and stone (`--effect-grey`, the theme's neutral or the game's), never the fire of a spell's bolt.
4
+ * `--power-size` scales the ring and the puffs with the damage.
5
+ */
6
+
7
+ .effect-crash {
8
+ --power-size: 1;
9
+ --crash-ms: 0ms;
10
+ --dust: color-mix(in oklab, var(--effect-grey, var(--color-neutral)) 55%, var(--color-text));
11
+ --stone: color-mix(in oklab, var(--effect-grey, var(--color-neutral)) 35%, var(--color-text));
12
+
13
+ position: absolute;
14
+ z-index: calc(var(--z-overlay, 20) + 2);
15
+ width: 0;
16
+ height: 0;
17
+ pointer-events: none;
18
+ }
19
+
20
+ .effect-crash__ring {
21
+ position: absolute;
22
+ left: -40px;
23
+ top: -40px;
24
+ width: 80px;
25
+ height: 80px;
26
+ border-radius: 50%;
27
+ border: 3px solid color-mix(in srgb, var(--dust) 70%, transparent);
28
+ scale: 0.2;
29
+ opacity: 0;
30
+ animation: effect-crash-ring calc(420ms / var(--tempo, 1)) cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
31
+ }
32
+
33
+ @keyframes effect-crash-ring {
34
+ 0% {
35
+ scale: 0.2;
36
+ opacity: 0.9;
37
+ }
38
+
39
+ 100% {
40
+ scale: calc(1.5 * var(--power-size, 1));
41
+ opacity: 0;
42
+ }
43
+ }
44
+
45
+ .effect-crash__dust {
46
+ --dx: 0px;
47
+ --dy: 0px;
48
+
49
+ position: absolute;
50
+ left: -14px;
51
+ top: -14px;
52
+ width: 28px;
53
+ height: 28px;
54
+ border-radius: 50%;
55
+ background: radial-gradient(in srgb circle, color-mix(in srgb, var(--dust) 55%, transparent) 0, transparent 70%);
56
+ opacity: 0;
57
+ /* `--crash-ms` is `crash.ts`'s CRASH_MS, the one source. */
58
+ animation: effect-crash-dust calc(var(--crash-ms) / var(--tempo, 1)) ease-out forwards;
59
+ }
60
+
61
+ @keyframes effect-crash-dust {
62
+ 0% {
63
+ translate: 0 0;
64
+ scale: 0.4;
65
+ opacity: 0.9;
66
+ }
67
+
68
+ 100% {
69
+ translate: var(--dx) var(--dy);
70
+ scale: calc(1.8 * var(--power-size, 1));
71
+ opacity: 0;
72
+ }
73
+ }
74
+
75
+ /* A chip of rock: a small irregular stone, thrown by `crash.ts`'s own animation. */
76
+ .effect-crash__rock {
77
+ position: absolute;
78
+ left: 0;
79
+ top: 0;
80
+ margin: -2px 0 0 -2px;
81
+ background: var(--stone);
82
+ clip-path: polygon(20% 0, 90% 15%, 100% 70%, 55% 100%, 0 75%);
83
+ }
84
+
85
+ /* The board shaking: its container clips for the length of it, so the page never scrolls (table-fit). */
86
+ [data-shaking] {
87
+ overflow: clip;
88
+ }
89
+
90
+ @media (prefers-reduced-motion: reduce) {
91
+ .effect-crash {
92
+ display: none;
93
+ }
94
+ }
@@ -0,0 +1,25 @@
1
+ import { type Point } from '../motion/index.js';
2
+ import './crash.css';
3
+ /** How long a crash's dust and rocks are drawn. */
4
+ export declare const CRASH_MS = 700;
5
+ /** A rock thrown by a crash: where it lands from the blow (px), how high it is thrown, its size and spin. */
6
+ export interface Rock {
7
+ readonly dx: number;
8
+ readonly dy: number;
9
+ readonly lift: number;
10
+ readonly size: number;
11
+ readonly spin: number;
12
+ }
13
+ /** Every particle a crash of `power` throws at its full count: what a beat's budget (`../motion/particles.ts`) is shared against. */
14
+ export declare function crashParticles(power: number): number;
15
+ /** The rocks a crash of `power` throws: more, bigger and further the heavier, at `share` of the full count, at most `most`. Seeded by `key`. */
16
+ export declare function rocks(key: string, power: number, share?: number, most?: number): Rock[];
17
+ /** Draw a crash at `at` (overlay coordinates) inside `root`, at `share` of its particles and out of the board's pool; it removes itself. */
18
+ export declare function crash(root: HTMLElement, at: Point, power: number, key: string, share?: number, tempo?: number): HTMLElement;
19
+ /** How long a shake of `px` runs: longer the further it goes. */
20
+ export declare function shakeMsOf(px: number): number;
21
+ /**
22
+ * Shake `board` by `px`: a few quick, dying jolts, as far and as long as `px` says — a blow's, a
23
+ * landing's or a spell's own, as the caller weighs it. Its container clips while it does. Returns a cancel.
24
+ */
25
+ export declare function shake(board: HTMLElement, px: number, key: string, tempo?: number): () => void;
@@ -0,0 +1,108 @@
1
+ /*
2
+ * The blow of a ram: a neutral crash, not an explosion — a ring of dust, chips of rock
3
+ * thrown out and falling, and the table shaking (`shake`, as far as the caller says), all as heavy as the
4
+ * damage: a creature's blow is a thud of stone and dust, never a spell's fire.
5
+ *
6
+ * Everything is drawn in the board's overlay. The shake moves the board itself, so for its length
7
+ * the board's container clips its paint (`[data-shaking]`): a board moved a few pixels must never
8
+ * give the page a scrollbar (table-fit). Reduced motion: none of it.
9
+ */
10
+ import { animate, markTempo, screenShakeAllowed, shared, Stage } from "../motion/index.js";
11
+ import { damageSize, motionContext, seedOf } from "./context.js";
12
+ import './crash.css';
13
+ /** How long a crash's dust and rocks are drawn. */
14
+ export const CRASH_MS = 700;
15
+ /** On the board's container while the board shakes: it clips, so the page never scrolls for it. */
16
+ const SHAKING_ATTR = 'data-shaking';
17
+ /** A crash's full count of rocks and of dust puffs, at `power`. */
18
+ const rockCount = (power) => 6 + Math.round(14 * power);
19
+ const puffCount = (power) => 3 + Math.round(4 * power);
20
+ /** Every particle a crash of `power` throws at its full count: what a beat's budget (`../motion/particles.ts`) is shared against. */
21
+ export function crashParticles(power) {
22
+ return rockCount(power) + puffCount(power);
23
+ }
24
+ /** The rocks a crash of `power` throws: more, bigger and further the heavier, at `share` of the full count, at most `most`. Seeded by `key`. */
25
+ export function rocks(key, power, share = 1, most = Infinity) {
26
+ const count = Math.min(most, shared(rockCount(power), share, 4));
27
+ const reach = 34 + 70 * power;
28
+ return Array.from({ length: count }, (_, i) => {
29
+ const r = (k) => seedOf(`${key}:${i}:${k}`);
30
+ const angle = (i / count) * Math.PI * 2 + r('a') * 0.8;
31
+ const far = reach * (0.45 + 0.55 * r('d'));
32
+ return {
33
+ dx: Math.cos(angle) * far,
34
+ // Thrown up and out, and landing lower than it started: rocks fall.
35
+ dy: Math.sin(angle) * far * 0.6 + 14 + 18 * r('f'),
36
+ lift: 16 + 30 * power * r('l'),
37
+ size: (2.5 + 4.5 * r('s')) * damageSize(power),
38
+ spin: (r('r') - 0.5) * 540,
39
+ };
40
+ });
41
+ }
42
+ /** Draw a crash at `at` (overlay coordinates) inside `root`, at `share` of its particles and out of the board's pool; it removes itself. */
43
+ export function crash(root, at, power, key, share = 1, tempo = 1) {
44
+ const ctx = motionContext(root, tempo);
45
+ const now = Date.now();
46
+ const puffs = ctx.particles(shared(puffCount(power), share, 2), 2, now, now + CRASH_MS / tempo);
47
+ const thrown = ctx.particles(shared(rockCount(power), share, 4), 4, now, now + CRASH_MS / tempo);
48
+ const el = document.createElement('div');
49
+ el.className = 'effect-crash';
50
+ el.setAttribute('aria-hidden', 'true');
51
+ el.dataset.crash = key;
52
+ el.style.left = `${at.x}px`;
53
+ el.style.top = `${at.y}px`;
54
+ el.style.setProperty('--power-size', damageSize(power).toFixed(2));
55
+ el.style.setProperty('--crash-ms', `${CRASH_MS}ms`);
56
+ markTempo(el, tempo);
57
+ const ring = document.createElement('span');
58
+ ring.className = 'effect-crash__ring';
59
+ el.append(ring);
60
+ for (let i = 0; i < puffs; i++) {
61
+ const puff = document.createElement('span');
62
+ puff.className = 'effect-crash__dust';
63
+ const a = (i / 7) * Math.PI * 2 + seedOf(`${key}:p${i}`) * 1.2;
64
+ puff.style.setProperty('--dx', `${(Math.cos(a) * (18 + 26 * power)).toFixed(1)}px`);
65
+ puff.style.setProperty('--dy', `${(Math.sin(a) * (10 + 14 * power) - 6).toFixed(1)}px`);
66
+ el.append(puff);
67
+ }
68
+ for (const rock of rocks(key, power, share, thrown)) {
69
+ const chip = document.createElement('span');
70
+ chip.className = 'effect-crash__rock';
71
+ chip.style.width = chip.style.height = `${rock.size.toFixed(1)}px`;
72
+ el.append(chip);
73
+ animate(chip, [
74
+ { translate: '0px 0px', rotate: '0deg', opacity: 1 },
75
+ { offset: 0.4, translate: `${(rock.dx * 0.55).toFixed(1)}px ${(rock.dy * 0.4 - rock.lift).toFixed(1)}px`, opacity: 1 },
76
+ { translate: `${rock.dx.toFixed(1)}px ${rock.dy.toFixed(1)}px`, rotate: `${rock.spin.toFixed(0)}deg`, opacity: 0 },
77
+ ], { duration: CRASH_MS * (0.75 + 0.25 * seedOf(`${key}:t`)), easing: 'cubic-bezier(0.2, 0.6, 0.5, 1)', fill: 'forwards' }, ctx);
78
+ }
79
+ root.append(el);
80
+ setTimeout(() => el.remove(), (CRASH_MS + 50) / tempo);
81
+ return el;
82
+ }
83
+ /** How long a shake of `px` runs: longer the further it goes. */
84
+ export function shakeMsOf(px) {
85
+ return px === 0 ? 0 : Math.round(160 + 22 * px);
86
+ }
87
+ /**
88
+ * Shake `board` by `px`: a few quick, dying jolts, as far and as long as `px` says — a blow's, a
89
+ * landing's or a spell's own, as the caller weighs it. Its container clips while it does. Returns a cancel.
90
+ */
91
+ export function shake(board, px, key, tempo = 1) {
92
+ // The player's Screen shake switch (`../motion/switches.ts`): off, the blow lands with the table still.
93
+ if (px <= 0 || !screenShakeAllowed())
94
+ return () => undefined;
95
+ const frames = [{ translate: '0px 0px' }];
96
+ const jolts = 6;
97
+ for (let i = 1; i < jolts; i++) {
98
+ const fade = 1 - i / jolts;
99
+ const a = seedOf(`${key}:j${i}`) * Math.PI * 2;
100
+ frames.push({ translate: `${(Math.cos(a) * px * fade).toFixed(1)}px ${(Math.sin(a) * px * fade).toFixed(1)}px` });
101
+ }
102
+ frames.push({ translate: '0px 0px' });
103
+ const holder = board.parentElement;
104
+ holder?.setAttribute(SHAKING_ATTR, '');
105
+ const jolt = animate(board, frames, { duration: shakeMsOf(px), easing: 'linear', composite: 'add' }, { tempo, stage: Stage.of(board) });
106
+ void jolt.finished.then(() => holder?.removeAttribute(SHAKING_ATTR));
107
+ return jolt.cancel;
108
+ }
@@ -0,0 +1,4 @@
1
+ export type { Point } from '../motion/index.js';
2
+ export { damageSize, motionContext, seedOf } from './context.js';
3
+ export { along, fly, impact, slingFrames, type ProjectileLook } from './projectile.js';
4
+ export { crash, crashParticles, CRASH_MS, rocks, shake, shakeMsOf } from './crash.js';
@@ -0,0 +1,4 @@
1
+ /* The effects a game draws a blow with: a projectile on its sling, its slam, a crash and the table shaking. */
2
+ export { damageSize, motionContext, seedOf } from "./context.js";
3
+ export { along, fly, impact, slingFrames } from "./projectile.js";
4
+ export { crash, crashParticles, CRASH_MS, rocks, shake, shakeMsOf } from "./crash.js";
@@ -0,0 +1,286 @@
1
+ /*
2
+ * Projectiles (`projectile.ts`): the ball, its fire trail and the explosion where it lands. One block
3
+ * per look (`ProjectileLook`). The ball is placed by its animation's transform from the overlay's top
4
+ * left, so it has no `left`/`top` of its own.
5
+ *
6
+ * A bolt is drawn in `--bolt`, and every shade below is mixed from it — a hot core toward
7
+ * `--effect-light` (`--bolt-heat` of the hue in it), a deep rim toward `--effect-dark`, smoke toward
8
+ * `--effect-grey`. A game sets them by its element's `data-colour` (Magic's `bolt-colours.css`: the
9
+ * colour of the card that dealt it); with no rule of the game's, the theme's danger flame below. A
10
+ * heal mote keeps its own green look (the theme's success), but overrides `--bolt` itself so its trail
11
+ * and its blast — built on the SAME `--bolt-core`/`--bolt-rim` mix as a bolt's — come out green too: a
12
+ * heal keeps its look and still takes a bolt's trail and blast. The defaults below weigh nothing (`:where`):
13
+ * a game's rule for the element wins, as the script's inline `--tempo`, `--blast-ms` and drift do.
14
+ */
15
+ :where(.effect-hit, .effect-trail, .effect-impact) {
16
+ --tempo: 1;
17
+ --bolt-heat: 35%;
18
+ --bolt: var(--color-danger);
19
+ --effect-light: var(--color-on-danger);
20
+ --effect-dark: var(--color-danger-dark);
21
+ --effect-grey: var(--color-neutral);
22
+ }
23
+
24
+ .effect-hit {
25
+ position: absolute;
26
+ left: 0;
27
+ top: 0;
28
+ /* Over the stack's cards (`placed.css`'s `--z-overlay`): a bolt sets off from one and must be seen doing it. */
29
+ z-index: calc(var(--z-overlay, 20) + 2);
30
+ border-radius: 50%;
31
+ pointer-events: none;
32
+ }
33
+
34
+ /*
35
+ * Built from `--bolt` on every projectile element, bolt or heal: a bolt's trail and blast read it
36
+ * straight (the game's colour rules); a heal's reads the success override below instead,
37
+ * never computed twice.
38
+ */
39
+ .effect-hit,
40
+ .effect-trail,
41
+ .effect-impact {
42
+ --bolt-core: color-mix(in oklab, var(--bolt) var(--bolt-heat), var(--effect-light));
43
+ --bolt-rim: color-mix(in oklab, var(--bolt) 75%, var(--effect-dark));
44
+ /* The cooled, smoky end every ember and puff fades to. */
45
+ --smoke: color-mix(in oklab, var(--bolt-rim) 45%, var(--effect-grey));
46
+ }
47
+
48
+ /* A bolt: a hot core in its colour's flame, a glow around it. */
49
+ .effect-hit[data-projectile='bolt'] {
50
+ width: 22px;
51
+ height: 22px;
52
+ background: radial-gradient(in srgb circle at 40% 40%, var(--bolt-core) 0 22%, var(--bolt) 50%, var(--bolt-rim) 100%);
53
+ box-shadow:
54
+ 0 0 14px 6px color-mix(in srgb, var(--bolt) 90%, transparent),
55
+ 0 0 36px 14px color-mix(in srgb, var(--bolt) 50%, transparent);
56
+ }
57
+
58
+ /* Heal: a soft green orb — its own look, never a game's colour. */
59
+ .effect-hit[data-projectile='heal'] {
60
+ width: 14px;
61
+ height: 14px;
62
+ background: radial-gradient(in srgb circle at 40% 40%, color-mix(in srgb, var(--color-success) 25%, var(--effect-light)) 0 20%, var(--color-success) 75%);
63
+ box-shadow: 0 0 14px 5px color-mix(in srgb, var(--color-success) 60%, transparent);
64
+ }
65
+
66
+ /* Every heal-look trail ember and blast particle below is built on `--bolt`: pointing it at the success turns the whole generic mix green, with no colour rule of its own to keep in step. */
67
+ .effect-trail[data-projectile='heal'],
68
+ .effect-blast[data-projectile='heal'] {
69
+ --bolt: var(--color-success);
70
+ }
71
+
72
+ /*
73
+ * The fire trail (`trail()` in `projectile.ts`): embers shed along the path the ball actually
74
+ * travelled, cooling from the hot core through the flame to smoke. Centred on the path: `translate`
75
+ * is always `-50% -50%` plus the drift, never the drift alone (v3's bug — the drift replaced the
76
+ * centring, so every ember sat half its own size down-right of the path it was meant to follow).
77
+ *
78
+ * The cooling is three fixed looks faded into one another, never a gradient that changes: the ember
79
+ * itself is the smoke, `::after` the flame over it, `::before` the hot core over both, and only their
80
+ * opacity moves. An animated `background` is restyled, repainted and re-rastered every frame on the
81
+ * main thread for every ember in flight; opacity runs on the compositor.
82
+ */
83
+ .effect-trail {
84
+ position: absolute;
85
+ z-index: calc(var(--z-overlay, 20) + 1);
86
+ margin: 0;
87
+ translate: -50% -50%;
88
+ border-radius: 50%;
89
+ pointer-events: none;
90
+ background: radial-gradient(in srgb circle, color-mix(in srgb, var(--smoke) 60%, transparent) 0 30%, transparent 72%);
91
+ }
92
+
93
+ .effect-trail::before,
94
+ .effect-trail::after {
95
+ content: '';
96
+ position: absolute;
97
+ inset: 0;
98
+ border-radius: inherit;
99
+ }
100
+
101
+ .effect-trail::before {
102
+ z-index: 1;
103
+ background: radial-gradient(in srgb circle, var(--bolt-core) 0 18%, var(--bolt) 45%, color-mix(in srgb, var(--bolt-rim) 60%, transparent) 70%, transparent 72%);
104
+ animation: effect-trail-hot calc(420ms / var(--tempo, 1)) linear forwards;
105
+ }
106
+
107
+ .effect-trail::after {
108
+ background: radial-gradient(in srgb circle, var(--bolt) 0 20%, color-mix(in srgb, var(--bolt-rim) 70%, transparent) 55%, transparent 72%);
109
+ opacity: 0;
110
+ animation: effect-trail-flame calc(420ms / var(--tempo, 1)) linear forwards;
111
+ }
112
+
113
+ @keyframes effect-trail-hot {
114
+ 60%,
115
+ 100% {
116
+ opacity: 0;
117
+ }
118
+ }
119
+
120
+ @keyframes effect-trail-flame {
121
+ 60% {
122
+ opacity: 1;
123
+ }
124
+
125
+ 100% {
126
+ opacity: 0;
127
+ }
128
+ }
129
+
130
+ /*
131
+ * The explosion (`explode()` in `projectile.ts`, `impact()`'s own burst): a white-hot flash, a
132
+ * fireball of puffs billowing out and leaving smoke ghosts, a shockwave ring, spark streaks thrown on
133
+ * their own arcs, and falling embers for a heavy blow. Every layer in the bolt's own colour.
134
+ */
135
+ .effect-impact {
136
+ --blast-ms: 0ms;
137
+
138
+ position: absolute;
139
+ z-index: calc(var(--z-overlay, 20) + 2);
140
+ width: 0;
141
+ height: 0;
142
+ pointer-events: none;
143
+ }
144
+
145
+ .effect-blast > * {
146
+ position: absolute;
147
+ pointer-events: none;
148
+ }
149
+
150
+ .effect-blast__flash {
151
+ left: calc(-1 * var(--r));
152
+ top: calc(-1 * var(--r));
153
+ width: calc(2 * var(--r));
154
+ height: calc(2 * var(--r));
155
+ border-radius: 50%;
156
+ background: radial-gradient(in srgb circle, var(--effect-light) 0 25%, var(--bolt-core) 45%, transparent 70%);
157
+ animation: effect-blast-flash calc(160ms / var(--tempo, 1)) ease-out forwards;
158
+ }
159
+
160
+ @keyframes effect-blast-flash {
161
+ 0% {
162
+ scale: 0.3;
163
+ opacity: 1;
164
+ }
165
+
166
+ 100% {
167
+ scale: 1.8;
168
+ opacity: 0;
169
+ }
170
+ }
171
+
172
+ .effect-blast__puff {
173
+ --drift-x: 0px;
174
+ --drift-y: 0px;
175
+
176
+ border-radius: 50%;
177
+ /* Soft all the way out: a glow, never a disc with an edge. */
178
+ background: radial-gradient(in srgb circle, color-mix(in srgb, var(--bolt-core) 95%, transparent) 0, color-mix(in srgb, var(--bolt) 70%, transparent) 35%, color-mix(in srgb, var(--bolt-rim) 30%, transparent) 60%, transparent 70%);
179
+ scale: 0.2;
180
+ animation: effect-blast-puff calc(var(--blast-ms) / var(--tempo, 1)) cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
181
+ }
182
+
183
+ /* The heart of it: white-hot first. */
184
+ .effect-blast__puff[data-core] {
185
+ background: radial-gradient(in srgb circle, var(--effect-light) 0 12%, var(--bolt-core) 28%, color-mix(in srgb, var(--bolt) 70%, transparent) 50%, transparent 70%);
186
+ }
187
+
188
+ @keyframes effect-blast-puff {
189
+ 0% {
190
+ scale: 0.2;
191
+ opacity: 0.95;
192
+ translate: 0 0;
193
+ }
194
+
195
+ 25% {
196
+ scale: 1;
197
+ opacity: 0.9;
198
+ }
199
+
200
+ 100% {
201
+ scale: 1.4;
202
+ opacity: 0;
203
+ translate: var(--drift-x) var(--drift-y);
204
+ }
205
+ }
206
+
207
+ /* Smoke rising after the fire: the same puffs' ghosts, darker and slower. */
208
+ .effect-blast__puff::after {
209
+ content: '';
210
+ position: absolute;
211
+ inset: 10%;
212
+ border-radius: 50%;
213
+ background: radial-gradient(in srgb circle, color-mix(in srgb, var(--smoke) 45%, transparent) 0, transparent 70%);
214
+ opacity: 0;
215
+ animation: effect-blast-smoke calc(var(--blast-ms) / var(--tempo, 1)) ease-out forwards;
216
+ }
217
+
218
+ @keyframes effect-blast-smoke {
219
+ 40% {
220
+ opacity: 0;
221
+ }
222
+
223
+ 60% {
224
+ opacity: 0.8;
225
+ }
226
+
227
+ 100% {
228
+ opacity: 0;
229
+ translate: 0 -12px;
230
+ }
231
+ }
232
+
233
+ .effect-blast__ring {
234
+ left: calc(-1 * var(--r));
235
+ top: calc(-1 * var(--r));
236
+ width: calc(2 * var(--r));
237
+ height: calc(2 * var(--r));
238
+ box-sizing: border-box;
239
+ border-radius: 50%;
240
+ border: 2px solid color-mix(in srgb, var(--bolt-core) 80%, transparent);
241
+ scale: 0.15;
242
+ animation: effect-blast-ring calc(380ms / var(--tempo, 1)) cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
243
+ }
244
+
245
+ @keyframes effect-blast-ring {
246
+ 0% {
247
+ scale: 0.15;
248
+ opacity: 0.9;
249
+ border-width: 5px;
250
+ }
251
+
252
+ 100% {
253
+ scale: 1;
254
+ opacity: 0;
255
+ border-width: 1px;
256
+ }
257
+ }
258
+
259
+ .effect-blast__spark {
260
+ left: 0;
261
+ top: -1px;
262
+ height: 2px;
263
+ border-radius: 1px;
264
+ transform-origin: 0 50%;
265
+ background: linear-gradient(to right, transparent, var(--bolt) 40%, var(--bolt-core));
266
+ box-shadow: 0 0 4px color-mix(in srgb, var(--bolt) 70%, transparent);
267
+ }
268
+
269
+ .effect-blast__ember {
270
+ left: -2px;
271
+ top: -2px;
272
+ width: 4px;
273
+ height: 4px;
274
+ border-radius: 50%;
275
+ background: var(--bolt-core);
276
+ box-shadow: 0 0 5px 1px color-mix(in srgb, var(--bolt) 80%, transparent);
277
+ }
278
+
279
+ @media (prefers-reduced-motion: reduce) {
280
+ .effect-trail,
281
+ .effect-blast__spark,
282
+ .effect-blast__ember,
283
+ .effect-blast__puff {
284
+ display: none;
285
+ }
286
+ }
@@ -0,0 +1,29 @@
1
+ import { type Point } from '../motion/index.js';
2
+ import './projectile.css';
3
+ /** Every projectile look, by name. Its CSS is `projectile.css`. */
4
+ export type ProjectileLook = 'bolt' | 'heal';
5
+ /** The point at `t` (0–1) on a quadratic curve: the straighter path of a creature's own blow (a ram). */
6
+ export declare function along(start: Point, control: Point, end: Point, t: number): Point;
7
+ /**
8
+ * The sling's path: a cubic Bezier from `start` to `end` that first swings AWAY from the target —
9
+ * pulled back by `8 + (0.05..0.17)·d·power` and out to a seeded side by `0.10..0.26·d` — then curves in.
10
+ * Each cast its own side, bend and pull, seeded by `key`; `size` scales the ball (`damageSize`, bigger
11
+ * for a heavier hit) — applied last, inside the transform, never as a separate CSS `scale`, which would
12
+ * scale the flight with it and send a heavy bolt past its target. The two control points are clamped
13
+ * `16px` inside `bounds` (the overlay's own size): a Bezier never leaves the hull of its control
14
+ * points, so the flight never carries off the board (measured: 0 off-board frames).
15
+ */
16
+ export declare function slingFrames(start: Point, end: Point, power: number, size: number, key: string, bounds: {
17
+ w: number;
18
+ h: number;
19
+ }): Keyframe[];
20
+ /**
21
+ * Fly a projectile of `look` from `start` to `end` (overlay coordinates) over `ms`, inside `root`, on
22
+ * its sling's path (`slingFrames`), trailing fire behind it (`trail`). Returns the ball, marked
23
+ * `data-hit=<key>` while it flies; it and its trail remove themselves when they arrive. Without the Web
24
+ * Animations API (a test's DOM) the ball is placed at the end at once and trails nothing. `ms` is on the hit's own
25
+ * clock, which runs `tempo` times the wall's (`markTempo`). `colour`, when given, is its `data-colour`.
26
+ */
27
+ export declare function fly(root: HTMLElement, start: Point, end: Point, key: string, look: ProjectileLook, ms: number, colour?: string | null, power?: number | null, tempo?: number): HTMLElement;
28
+ /** The slam where a projectile of `look` landed: `explode`'s burst, at `at`, in `colour` when given. */
29
+ export declare function impact(root: HTMLElement, at: Point, look: ProjectileLook, key: string, colour?: string | null, power?: number | null, tempo?: number): HTMLElement;
@@ -0,0 +1,272 @@
1
+ /*
2
+ * What a hit looks like on its way: a projectile that slings off its source, out and back first, then
3
+ * accelerates in, trailing fire, and slams into what it hits. Each arc is a little random, so a
4
+ * sweeper's balls fan out, and it moves as a creature's blow does: winding up away from the target,
5
+ * then gathering speed into it. The slam is the hit; no number is needed beside it.
6
+ *
7
+ * ## The path
8
+ *
9
+ * A cubic Bezier (`slingFrames`): from the source, pulled BACK away from the target and out to one
10
+ * side first — further the heavier the blow — then swinging in. Which side, how far back and how far
11
+ * out come from the hit's own key, so a sweeper's balls fan out instead of flying in a bundle, and a
12
+ * hit is drawn the same way every time it is drawn — seeded PER RESOLUTION (the face-hit key carries
13
+ * the stack item's own id), so two casts at the same player still fly their own arcs. The two control
14
+ * points are clamped inside the overlay: a Bezier never leaves the hull of its own control points, so
15
+ * the flight never carries off the board. The ball runs the curve on an accelerating ease (the kit's
16
+ * `weightEase`): slow and winding up off the source, fastest at the end — more so for a heavier hit, in
17
+ * the same time (a heavy blow creeps at the back of its swing and whips in).
18
+ *
19
+ * ## The trail and the slam
20
+ *
21
+ * `trail` sheds embers along the path the ball actually travelled, cooling from its own colour to
22
+ * smoke. `impact` draws the slam as `explode`: a flash, a fireball of puffs, a shockwave ring, spark
23
+ * streaks on their own arcs, and falling embers for a heavy blow — every particle swarm shared out of
24
+ * the board's pool (`../motion/particles.ts`), never each effect's full count.
25
+ *
26
+ * ## Looks
27
+ *
28
+ * A look is a name in {@link ProjectileLook}, and its rules are in `projectile.css`
29
+ * (`.effect-hit[data-projectile="<name>"]`, its trail, its blast). `bolt` is damage, drawn in the
30
+ * colour a game gives it (`data-colour`, whose `--bolt` the game's own sheet sets: a spell's fireball
31
+ * in the spell's colour); `heal` is life gained, which keeps
32
+ * its own look but takes the same trail and sling as a bolt.
33
+ *
34
+ * Every element is in the board's overlay, never a transform on a card in a row (table-fit).
35
+ */
36
+ import { animate, centre, markTempo, rel, STILL, weightEase } from "../motion/index.js";
37
+ import { damageSize, motionContext, seedOf } from "./context.js";
38
+ import './projectile.css';
39
+ /** The blast's own life at no power; it runs longer the heavier the blow (`explode`'s own `life`). */
40
+ const IMPACT_MS = 420;
41
+ /** Samples of the sling's own path. */
42
+ const SAMPLES = 16;
43
+ /** The point at `t` (0–1) on a quadratic curve: the straighter path of a creature's own blow (a ram). */
44
+ export function along(start, control, end, t) {
45
+ const u = 1 - t;
46
+ return { x: u * u * start.x + 2 * u * t * control.x + t * t * end.x, y: u * u * start.y + 2 * u * t * control.y + t * t * end.y };
47
+ }
48
+ /**
49
+ * The sling's path: a cubic Bezier from `start` to `end` that first swings AWAY from the target —
50
+ * pulled back by `8 + (0.05..0.17)·d·power` and out to a seeded side by `0.10..0.26·d` — then curves in.
51
+ * Each cast its own side, bend and pull, seeded by `key`; `size` scales the ball (`damageSize`, bigger
52
+ * for a heavier hit) — applied last, inside the transform, never as a separate CSS `scale`, which would
53
+ * scale the flight with it and send a heavy bolt past its target. The two control points are clamped
54
+ * `16px` inside `bounds` (the overlay's own size): a Bezier never leaves the hull of its control
55
+ * points, so the flight never carries off the board (measured: 0 off-board frames).
56
+ */
57
+ export function slingFrames(start, end, power, size, key, bounds) {
58
+ const dx = end.x - start.x;
59
+ const dy = end.y - start.y;
60
+ const d = Math.hypot(dx, dy) || 1;
61
+ const ux = dx / d;
62
+ const uy = dy / d;
63
+ const nx = -uy;
64
+ const ny = ux;
65
+ const side = seedOf(`${key}:side`) < 0.5 ? -1 : 1;
66
+ const bend = (0.1 + 0.16 * seedOf(`${key}:bend`)) * d * side;
67
+ const back = 8 + (0.05 + 0.12 * power) * d * (0.8 + 0.4 * seedOf(`${key}:back`));
68
+ // The curve stays inside its control points: keeping them on the board keeps the whole flight on it.
69
+ const pad = 16;
70
+ const inside = (q) => ({ x: Math.min(bounds.w - pad, Math.max(pad, q.x)), y: Math.min(bounds.h - pad, Math.max(pad, q.y)) });
71
+ const p1 = inside({ x: start.x - ux * back + nx * bend, y: start.y - uy * back + ny * bend });
72
+ const reach = 0.45 + 0.2 * seedOf(`${key}:reach`);
73
+ const p2 = inside({ x: start.x + ux * d * reach + nx * bend * 0.9, y: start.y + uy * d * reach + ny * bend * 0.9 });
74
+ return Array.from({ length: SAMPLES + 1 }, (_, i) => {
75
+ const t = i / SAMPLES;
76
+ const u = 1 - t;
77
+ const x = u * u * u * start.x + 3 * u * u * t * p1.x + 3 * u * t * t * p2.x + t * t * t * end.x;
78
+ const y = u * u * u * start.y + 3 * u * u * t * p1.y + 3 * u * t * t * p2.y + t * t * t * end.y;
79
+ const scale = (0.45 + 0.55 * Math.min(1, t / 0.3)) * size;
80
+ return { transform: `translate(${x.toFixed(1)}px, ${y.toFixed(1)}px) translate(-50%, -50%) scale(${scale.toFixed(3)})` };
81
+ });
82
+ }
83
+ /**
84
+ * Fly a projectile of `look` from `start` to `end` (overlay coordinates) over `ms`, inside `root`, on
85
+ * its sling's path (`slingFrames`), trailing fire behind it (`trail`). Returns the ball, marked
86
+ * `data-hit=<key>` while it flies; it and its trail remove themselves when they arrive. Without the Web
87
+ * Animations API (a test's DOM) the ball is placed at the end at once and trails nothing. `ms` is on the hit's own
88
+ * clock, which runs `tempo` times the wall's (`markTempo`). `colour`, when given, is its `data-colour`.
89
+ */
90
+ export function fly(root, start, end, key, look, ms, colour = null, power = null, tempo = 1) {
91
+ const p = power ?? 1;
92
+ const size = power === null ? 1 : damageSize(power);
93
+ const frames = slingFrames(start, end, p, size, key, { w: root.clientWidth, h: root.clientHeight });
94
+ const ball = document.createElement('div');
95
+ ball.className = 'effect-hit';
96
+ ball.setAttribute('aria-hidden', 'true');
97
+ ball.dataset.projectile = look;
98
+ if (colour !== null)
99
+ ball.dataset.colour = colour;
100
+ ball.dataset.hit = key;
101
+ markTempo(ball, tempo);
102
+ root.append(ball);
103
+ const ctx = motionContext(root, tempo);
104
+ const flight = animate(ball, frames, { duration: ms, easing: weightEase(p), fill: 'both' }, ctx);
105
+ if (flight === STILL) {
106
+ ball.style.transform = frames[frames.length - 1].transform;
107
+ return ball;
108
+ }
109
+ void flight.finished.then(() => ball.remove());
110
+ trail(ball, look, key, ms / tempo, power ?? 0, Math.hypot(end.x - start.x, end.y - start.y), ctx);
111
+ return ball;
112
+ }
113
+ /**
114
+ * The fire trail: every frame the ball is in flight it sheds an ember where it is, centred on the path
115
+ * — never behind it, never beside it. Each one shrinks, cools from its own colour through the flame to
116
+ * smoke, and drifts off as it fades: more, bigger and longer-lived the heavier the blow. One ember
117
+ * roughly every `5 - 2·power` px of the ball's own travel, however fast it moves, so the trail is
118
+ * unbroken on a fast screen and on a slow one alike. The whole trail's embers are claimed once from the
119
+ * board's particle pool (`../motion/particles.ts`), estimated from the flight's straight-line `distance` (the
120
+ * sling's own path runs a little longer), so a busy board throttles the trail rather than ignoring the
121
+ * budget. The claim's window ends when the flight does, not past it: `impact`'s own explosion is the
122
+ * SAME hit's next beat, not a rival one, and must find the trail's reservation already freed. `ms` is the
123
+ * flight's wall time; each ember's own life runs at `tempo`.
124
+ */
125
+ function trail(ball, look, key, ms, power, distance, ctx) {
126
+ const { overlay: root, tempo } = ctx;
127
+ const t0 = performance.now();
128
+ const now = Date.now();
129
+ const spacing = 5 - 2 * power;
130
+ const wanted = Math.max(2, Math.round((distance * 1.5) / spacing));
131
+ const budget = ctx.particles(wanted, 2, now, now + ms);
132
+ let n = 0;
133
+ let last = null;
134
+ // Read where the ball is with every other loop's reads, then shed its embers (`ctx.frame`).
135
+ ctx.frame(() => {
136
+ if (!ball.isConnected || performance.now() - t0 > ms || n >= budget)
137
+ return null;
138
+ const r = ball.getBoundingClientRect();
139
+ const b = root.getBoundingClientRect();
140
+ return () => shed(r, b);
141
+ });
142
+ function shed(r, b) {
143
+ const here = centre(rel(r, b));
144
+ const from = last ?? here;
145
+ const steps = Math.min(budget - n, Math.max(1, Math.round(Math.hypot(here.x - from.x, here.y - from.y) / spacing)));
146
+ for (let k = 1; k <= steps; k++) {
147
+ const s = (q) => seedOf(`${key}:t${n}:${q}:mix`);
148
+ n++;
149
+ const f = k / steps;
150
+ const x = from.x + (here.x - from.x) * f;
151
+ const y = from.y + (here.y - from.y) * f;
152
+ const el = document.createElement('span');
153
+ el.className = 'effect-trail';
154
+ el.setAttribute('aria-hidden', 'true');
155
+ el.dataset.projectile = look;
156
+ if (ball.dataset.colour !== undefined)
157
+ el.dataset.colour = ball.dataset.colour;
158
+ markTempo(el, tempo);
159
+ const size = r.width * (0.55 + 0.35 * s('z'));
160
+ Object.assign(el.style, { left: `${x + (s('x') - 0.5) * r.width * 0.25}px`, top: `${y + (s('y') - 0.5) * r.width * 0.25}px`, width: `${size}px`, height: `${size}px` });
161
+ root.append(el);
162
+ const life = ((180 + 240 * power) * (0.75 + 0.5 * s('l'))) / tempo;
163
+ // Centred on the path: the drift is added to the -50% that centres it, never in place of it
164
+ // (v3's bug — the drift's own `translate` replaced the centring, so every ember sat half its
165
+ // own size down-right of the path it was supposed to follow). Its `life` is already wall time.
166
+ void animate(el, [
167
+ { scale: '0.9', opacity: 0.85, translate: '-50% -50%' },
168
+ { scale: '0.15', opacity: 0, translate: `calc(-50% + ${((s('dx') - 0.5) * 10).toFixed(1)}px) calc(-50% + ${(-4 - 10 * s('dy')).toFixed(1)}px)` },
169
+ ], { duration: life, easing: 'ease-out', fill: 'forwards' }).finished.then(() => el.remove());
170
+ }
171
+ last = here;
172
+ }
173
+ }
174
+ /** The slam where a projectile of `look` landed: `explode`'s burst, at `at`, in `colour` when given. */
175
+ export function impact(root, at, look, key, colour = null, power = null, tempo = 1) {
176
+ const burst = document.createElement('div');
177
+ burst.className = 'effect-impact';
178
+ burst.setAttribute('aria-hidden', 'true');
179
+ burst.dataset.projectile = look;
180
+ if (colour !== null)
181
+ burst.dataset.colour = colour;
182
+ burst.dataset.impact = key;
183
+ burst.style.left = `${at.x}px`;
184
+ burst.style.top = `${at.y}px`;
185
+ markTempo(burst, tempo);
186
+ return explode(burst, key, power ?? 0, motionContext(root, tempo));
187
+ }
188
+ /**
189
+ * The explosion: a white-hot flash; a fireball of puffs clustered round the point of impact (the
190
+ * first the white-hot heart), billowing out and leaving smoke ghosts; a shockwave ring from 3 damage
191
+ * up; spark streaks each on their own arc (length, speed, distance, gravity); falling embers for a
192
+ * heavy blow. Every particle swarm (puffs, sparks, falling embers) is claimed once from the board's
193
+ * particle pool (`../motion/particles.ts`), never each swarm's full count on a busy board. A heavier blow
194
+ * throws MORE puffs, not bigger ones: big puffs left after the blast draw the eye away from it. All in the
195
+ * bolt's own colour (`burst.dataset.colour`, read by `projectile.css`'s `--bolt*`).
196
+ */
197
+ function explode(burst, key, power, ctx) {
198
+ const { overlay: root, tempo } = ctx;
199
+ // The varying part is never last: `seedOf` barely moves when only a key's final character does.
200
+ const r = (q) => seedOf(`${key}:x:${q}:mix`);
201
+ const now = Date.now();
202
+ const life = Math.round(IMPACT_MS + 520 * power);
203
+ /** The burst's lengths on the wall, for the particle pool and its own removal. */
204
+ const wall = (ms) => now + ms / tempo;
205
+ burst.classList.add('effect-blast');
206
+ burst.style.setProperty('--blast-ms', `${life}ms`);
207
+ const add = (cls) => {
208
+ const el = document.createElement('span');
209
+ el.className = cls;
210
+ burst.append(el);
211
+ return el;
212
+ };
213
+ // The flash: white-hot, gone in a blink.
214
+ const flash = add('effect-blast__flash');
215
+ flash.style.setProperty('--r', `${Math.round(20 * damageSize(power))}px`);
216
+ // The fireball: puffs around the point of impact, each its own size, lag and drift — more of them
217
+ // the heavier the blow, never bigger ones.
218
+ const puffsWanted = 3 + Math.round(6 * power);
219
+ const puffs = ctx.particles(puffsWanted, 2, now, wall(life));
220
+ for (let i = 0; i < puffs; i++) {
221
+ const el = add('effect-blast__puff');
222
+ // Clustered, not a ring: random angles, most puffs near the middle, the first the biggest and hottest.
223
+ const a = r(`pa${i}`) * Math.PI * 2;
224
+ const off = i === 0 ? 0 : (6 + 12 * power) * Math.sqrt(r(`po${i}`));
225
+ const rad = 13 * (i === 0 ? 1.2 : 0.55 + 0.45 * r(`pr${i}`));
226
+ if (i === 0)
227
+ el.dataset.core = '';
228
+ Object.assign(el.style, { left: `${Math.cos(a) * off - rad}px`, top: `${Math.sin(a) * off - rad}px`, width: `${rad * 2}px`, height: `${rad * 2}px` });
229
+ el.style.setProperty('--drift-x', `${Math.cos(a) * (8 + 14 * power)}px`);
230
+ el.style.setProperty('--drift-y', `${Math.sin(a) * (8 + 14 * power) - 8}px`);
231
+ el.style.animationDelay = `${Math.round((r(`pd${i}`) * 70) / tempo)}ms`;
232
+ }
233
+ // The shockwave: one ring, as wide as the blow.
234
+ if (power > 0.15) {
235
+ const ring = add('effect-blast__ring');
236
+ ring.style.setProperty('--r', `${Math.round(30 + 90 * power)}px`);
237
+ }
238
+ // Sparks: streaks, each thrown on its own arc.
239
+ const sparksWanted = 6 + Math.round(22 * power);
240
+ const sparks = ctx.particles(sparksWanted, 3, now, wall(life));
241
+ for (let i = 0; i < sparks; i++) {
242
+ const el = add('effect-blast__spark');
243
+ const a = (i / sparks) * 360 + r(`sa${i}`) * (360 / sparks) * 1.6;
244
+ const far = (30 + 90 * power) * (0.45 + 0.75 * r(`sd${i}`));
245
+ const rad = (a * Math.PI) / 180;
246
+ const dx = Math.cos(rad) * far;
247
+ const dy = Math.sin(rad) * far;
248
+ el.style.width = `${Math.round(5 + (8 + 10 * power) * r(`sl${i}`))}px`;
249
+ el.style.rotate = `${a}deg`;
250
+ const ms = Math.round((300 + 380 * power) * (0.6 + 0.6 * r(`st${i}`)));
251
+ animate(el, [
252
+ { translate: '0 0', opacity: 1 },
253
+ { translate: `${dx * 0.6}px ${dy * 0.6 - 6}px`, opacity: 1, offset: 0.45 },
254
+ { translate: `${dx}px ${dy + 10 + 30 * power * r(`sg${i}`)}px`, opacity: 0 },
255
+ ], { duration: ms, easing: 'cubic-bezier(0.15, 0.7, 0.35, 1)', fill: 'forwards' }, { tempo });
256
+ }
257
+ // Embers falling after a heavy blow.
258
+ const fallingWanted = power < 0.45 ? 0 : Math.round(3 + 8 * (power - 0.45));
259
+ const falling = fallingWanted === 0 ? 0 : ctx.particles(fallingWanted, 0, now, wall(life + 1300));
260
+ for (let i = 0; i < falling; i++) {
261
+ const el = add('effect-blast__ember');
262
+ const x = (r(`ex${i}`) - 0.5) * (40 + 80 * power);
263
+ animate(el, [
264
+ { translate: `${x * 0.4}px ${-10 - 20 * r(`ey${i}`)}px`, opacity: 0 },
265
+ { opacity: 1, offset: 0.15 },
266
+ { translate: `${x}px ${30 + 50 * r(`ef${i}`)}px`, opacity: 0 },
267
+ ], { duration: Math.round(700 + 600 * r(`et${i}`)), delay: Math.round(120 + 200 * r(`ed${i}`)), easing: 'ease-in', fill: 'both' }, { tempo });
268
+ }
269
+ root.append(burst);
270
+ setTimeout(() => burst.remove(), (life + 1300) / tempo);
271
+ return burst;
272
+ }
@@ -1,19 +1,19 @@
1
- export interface Point {
1
+ export type Point = {
2
2
  readonly x: number;
3
3
  readonly y: number;
4
- }
5
- export interface Box {
4
+ };
5
+ export type Box = {
6
6
  left: number;
7
7
  top: number;
8
8
  width: number;
9
9
  height: number;
10
- }
11
- export interface Rect {
10
+ };
11
+ export type Rect = {
12
12
  left: number;
13
13
  top: number;
14
14
  right: number;
15
15
  bottom: number;
16
- }
16
+ };
17
17
  /** `r` as a box relative to `to`. */
18
18
  export declare const rel: (r: DOMRect, to: DOMRect) => Box;
19
19
  /** The middle of `r`. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/ui-shell",
3
- "version": "0.1.274",
4
- "gitHead": "e4f7cc3b81941103445c6b9a75a320e660760110",
3
+ "version": "0.1.276",
4
+ "gitHead": "6269de09a79b1555f2d0f24ed2ff8c1857520990",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The parts of a game's UI any game keeps: chrome, trim, room shell, embed mount, theme and settings frame, UI scale, usage counting, the sound mixer, motion and generic components. One appId parameterizes its storage keys, events and chat prefix. MIT; imports only react, react-dom, platform-wire and @wolffm/*.",
@@ -58,6 +58,10 @@
58
58
  "types": "./dist/motion/index.d.ts",
59
59
  "import": "./dist/motion/index.js"
60
60
  },
61
+ "./effects": {
62
+ "types": "./dist/effects/index.d.ts",
63
+ "import": "./dist/effects/index.js"
64
+ },
61
65
  "./components": {
62
66
  "types": "./dist/components/index.d.ts",
63
67
  "import": "./dist/components/index.js"
@@ -72,7 +76,7 @@
72
76
  "react-dom": "^19.2.8"
73
77
  },
74
78
  "dependencies": {
75
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.274",
79
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.276",
76
80
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.4",
77
81
  "@wolffm/themes": "npm:@hadoku/themes@^5.14.22",
78
82
  "zod": "^4.6.7"