@n-uf/motion 26.11.1 → 26.11.3

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 CHANGED
@@ -3,6 +3,45 @@
3
3
  Versions are calendar versions, `YY.M.R` (year, month of the release, counter
4
4
  within the month), the same scheme as `@n-uf/hypr-tiling`.
5
5
 
6
+ ## 26.11.3
7
+
8
+ - New in `values/`: the window motion rules, the one motion model for
9
+ hypr-tiling and pdf-n-uf's surface.
10
+ - `createSettle(initial, { omega?, restDelta? })` and `settleValue(loop, …)`:
11
+ the curve for moving to a new place. A critically damped spring whose
12
+ velocity is set on every new target to `omega · distance` toward it, so it
13
+ follows `distance · e^(−omega·t)` from wherever it is drawn: front-loaded
14
+ (90 % in `ln(10)/omega` s), and it never passes its target, on position
15
+ or size, however often it is retargeted. A velocity set by hand toward
16
+ the target is capped at that speed; one away from it is kept. Tempos in
17
+ `SETTLE_TEMPO` (`calm` 20, `default` 25, `quick` 37 per second).
18
+ - `settle.hold(value)`: what a pointer owns sits exactly under it, at rest;
19
+ the next target launches from there.
20
+ - `reveal(drawn, target)`: draw a gliding window without stretching its
21
+ content (move, frame at the drawn size, clip the content laid out at the
22
+ target size). `popIn(progress, from = 0.87)`: uniform open and close.
23
+ - New entry `@n-uf/motion/testing`: frame-sampled checks of those rules
24
+ (`checkNoOvershoot`, `checkMonotonic`, `checkNoJumps`, `checkHeld`,
25
+ `checkContentScale`, `checkTempo`), each returning `{ ok, failures }`.
26
+ - Nothing existing changes behaviour.
27
+
28
+ ## 26.11.2
29
+
30
+ - A two-finger pan is no longer taken for a pinch. One finger's event arrives
31
+ before the other's, and a pan's leading finger alone changes the distance
32
+ like a pinch (fingers 120 px apart, 7.5 px per event: 6.3 % against the 5 %
33
+ threshold, while the centre moved only 3.75 px). The kind is now read once
34
+ both fingers have moved as often as each other since the last look (so a
35
+ lead of one or two events is caught up first); a finger at rest sends no
36
+ moves, so one three moves ahead is read on its own (a pinch around an
37
+ anchored thumb); a finger lifting from an undecided pair is read once, so a
38
+ quick pinch still counts. A move that changes no position (pressure only)
39
+ doesn't count. The thresholds keep their meaning; the API is unchanged.
40
+ - What a host sees differently: `pinch` `start` can come one to three moves
41
+ later than before (it still carries everything since the second finger
42
+ landed), and a pair cancelled before it decided emits no `pinch` `cancel`
43
+ (nothing had started).
44
+
6
45
  ## 26.11.1
7
46
 
8
47
  - The recogniser takes the platform (`platform`, default `"other"`). On
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @n-uf/motion
2
2
 
3
+ > [!CAUTION]
4
+ > ## Not yet stable
5
+ >
6
+ > **@n-uf/motion is young and still changing. Its API (the frame loop, signals, springs and tweens, and the gesture recogniser) and its timing behaviour are not final.**
7
+ >
8
+ > Version numbers are dates (YY.M.R), not semantic versions, so any release may break things, including how frames are scheduled, how springs settle and how gestures are timed. Pin an exact version and read the [CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/motion/CHANGELOG.md) before you upgrade. If you need a stable animation library, use [Motion](https://motion.dev) or [GSAP](https://gsap.com). Both work on the DOM, so neither is a drop-in replacement.
9
+
3
10
  One frame loop with an injected clock, fine-grained signals, springs and
4
11
  tweens, and a DOM-free gesture recogniser. No DOM, no framework, no globals:
5
12
  the host hands in a clock, and tests hand in a fake one.
@@ -14,15 +21,19 @@ npm i @n-uf/motion
14
21
  recomputes only what depends on it, and effects can run once per frame.
15
22
  - **values/**: springs and tweens over numbers, points, rects and vectors,
16
23
  stepped by the clock, with velocity that carries over a retarget, settle
17
- detection and a reduced-motion switch.
24
+ detection and a reduced-motion switch; and the window motion rules:
25
+ `settle` (one fast-then-gentle curve that never passes its target), hold
26
+ (what a pointer owns sits exactly under it) and `reveal` (glide a window
27
+ without stretching its content).
18
28
  - **gestures/**: a recogniser that turns pointer, wheel and trackpad events
19
29
  (plain objects) into one gesture stream (click or drag, double click, long
20
30
  press, pinch, scroll, zoom, recovery from lost releases), a frame coalescer,
21
31
  and a dwell (spring-load) machine.
22
32
 
23
- One package, six entries: `@n-uf/motion` (everything in the core), its four
33
+ One package, seven entries: `@n-uf/motion` (everything in the core), its four
24
34
  folders on their own (`@n-uf/motion/clock`, `/signals`, `/values`,
25
- `/gestures`), and `@n-uf/motion/browser`, the clock on
35
+ `/gestures`), `@n-uf/motion/testing` (frame-sampled checks of the motion
36
+ rules, for tests and browser specs), and `@n-uf/motion/browser`, the clock on
26
37
  `requestAnimationFrame` and the reduced-motion media query. The core entries
27
38
  touch no host; importing several of them still gives one signal graph.
28
39
 
@@ -148,12 +159,60 @@ rect.set({ x: 300, y: 40, width: 240, height: 100 });
148
159
  clock.runUntilIdle(); // settled at { x: 300, y: 40, width: 240, height: 100 }
149
160
  ```
150
161
 
162
+ ### Window motion: settle, hold, reveal
163
+
164
+ Three rules make windows move the way a tiling window manager feels smooth
165
+ (Hyprland is the reference): what the pointer holds is glued to it, everything
166
+ else moves on one front-loaded curve that never passes its target, and content
167
+ is never stretched.
168
+
169
+ | | |
170
+ |---|---|
171
+ | `createSettle(initial, { omega?, restDelta? })` | The one curve for moving to a new place. On a new target every component gets the velocity `omega · distance` toward it from wherever it is drawn, so it follows `distance · e^(−omega·t)`: 90 % in `ln(10)/omega` s, then it eases in, and never passes the target (no overshoot on position, no wobble on size), however often it is retargeted. A velocity set by hand toward the target is capped at that speed; one away from it is kept, and the value turns around without crossing. |
172
+ | `SETTLE_TEMPO` | `{ calm: 20, default: 25, quick: 37 }` (1/s): 90 % in 115, 92 or 62 ms. |
173
+ | `settle.hold(value)` | Hold: put the value exactly there, at rest (same as `jumpTo`). Call it on each pointer move; the next `setTarget` launches from there. |
174
+ | `settleValue(loop, initial, { omega?, restDelta?, phase?, reducedMotion? })` | The settle on a frame loop. Hold it with `mv.jump(rect)`. |
175
+ | `reveal(drawn, target)` | How to draw a window gliding at `drawn` whose content is laid out at `target`: move the element by `dx, dy`, draw the frame (chrome) at `width × height`, clip the content by `clipRight, clipBottom`. No scale, no layout per frame. |
176
+ | `popIn(progress, from = 0.87)` | Opening and closing: a uniform scale about the centre plus opacity. Drive `progress` with a settle on a number with `{ restDelta: 0.001 }` (the default 0.1 is for pixels) or a tween. |
177
+
178
+ ```ts
179
+ import { createFakeClock, createFrameLoop, settleValue } from "@n-uf/motion";
180
+
181
+ const clock = createFakeClock();
182
+ const loop = createFrameLoop({ clock });
183
+ const win = settleValue(loop, { x: 0, y: 0, width: 400, height: 300 });
184
+ win.set({ x: 400, y: 0, width: 200, height: 300 }); // a reflow: position and size arrive together
185
+ clock.frame();
186
+ win.set({ x: 300, y: 0, width: 300, height: 300 }); // retargeted mid-flight: on from where it is drawn
187
+ clock.runUntilIdle();
188
+ console.log(win.value); // { x: 300, y: 0, width: 300, height: 300 }, never past it on the way
189
+ ```
190
+
191
+ ## testing/
192
+
193
+ `@n-uf/motion/testing` checks recorded frames against the rules. Record what
194
+ was drawn each frame (on the fake clock, or in a browser spec once per
195
+ animation frame) and ask:
196
+
197
+ | | |
198
+ |---|---|
199
+ | `checkNoOvershoot(samples, from, to, tolerance?)` | Every component stays between its start and end: no overshoot, no size wobble. |
200
+ | `checkMonotonic(samples, to, tolerance?)` | The distance to the target never grows: no bounce, no restart backwards. |
201
+ | `checkNoJumps(samples, omega, slack?)` | No frame moves further than a settle at `omega` could: catches snaps and restarts from an old place. Sample times are the stepped time (the loop's `delta`s), not wall-clock timestamps. |
202
+ | `checkHeld(samples, tolerance?)` | A held rect is where the pointer puts it, every frame. |
203
+ | `checkContentScale(samples, { uniformOnly?, tolerance? })` | Content's transform is never non-uniform (stretched); with `uniformOnly: false`, never scaled at all. |
204
+ | `checkTempo(samples, from, to, t90, tolerance?, startT?)` | 90 % of the way within `t90` ms of `startT` (default: the first sample, so record the frame the move began); returns the measured time too. |
205
+
206
+ Each returns `{ ok, failures }`, a failure naming the frame and component.
207
+ The motion lab in the [n-uf/motion repository](https://github.com/n-uf/motion)
208
+ (`apps/lab`) runs them on every move.
209
+
151
210
  ## gestures/
152
211
 
153
212
  | | |
154
213
  |---|---|
155
214
  | `createRecognizer({ toCanvas, timers?, dragModifier?, platform?, thresholds?, longPress?, multiClick?, pinch?, wheel?, staleMs? }, emit)` | Raw pointer, wheel and Safari gesture events in, `InputGesture`s out: `press`, `dragStart`, `move`, `longPress`, `release` (with `click` and `clickCount`), `cancel` (with a reason), `hover`, `pinch` (touch or trackpad, pinch or two-finger pan), `scroll`, `zoom`. Methods: `feed`, `cancel(reason)`, `reset`, `active`, `pinching`, `setDragModifier`, `dispose`. |
156
- | `RECOGNIZER_DEFAULTS` | Click-or-drag thresholds 4 / 6 / 8 px (mouse / pen / touch), long press after 500 ms for touch and pen, double click within 300 ms and 5 px, pinch at 5 % scale or 10 px pan. |
215
+ | `RECOGNIZER_DEFAULTS` | Click-or-drag thresholds 4 / 6 / 8 px (mouse / pen / touch), long press after 500 ms for touch and pen, double click within 300 ms and 5 px, pinch at 5 % scale or 10 px pan (read once both fingers have moved as often as each other, or one is three moves ahead, or one lifts). |
157
216
  | `wheelDeltaPx`, `classifyWheel`, `dampWheelPan`, `WHEEL_DEFAULTS`, `WHEEL_PAN_DEFAULTS` | Wheel normalisation: lines and pages to px, Cmd/Ctrl+wheel (and the ctrl+wheel trackpad pinch) zooms by 2^(−dy / 300), Shift turns a vertical wheel horizontal, and a damped pan per event. |
158
217
  | `toModifiers`, `resolveDragModifier`, `defaultDragModifier`, `isHeld`, `modHeld`, `platformButton` | Modifier keys in one shape; the drag modifier per platform (Cmd on macOS, Alt elsewhere); on macOS a Ctrl+click is the secondary button. |
159
218
  | `createFrameCoalescer(onFrame, frames, { merge? })` | `schedule(sample)`, `flush()`, `cancel()`, `pending`. One delivery per frame with the latest sample (or `merge`d ones) and how many were folded. Same shape as hypr-tiling's. |
@@ -195,7 +254,7 @@ their own.
195
254
 
196
255
  Everything runs on `createFakeClock()`: frames, timers, springs and machine
197
256
  deadlines move only when the test moves the clock, so motion is exact and
198
- repeatable.
257
+ repeatable. `@n-uf/motion/testing` (above) checks the frames you record.
199
258
 
200
259
  ## Benchmarks
201
260
 
@@ -393,6 +393,146 @@ function createTween(initial, config = {}) {
393
393
  return new TweenAnimator(initial, config);
394
394
  }
395
395
 
396
+ // src/values/settle.ts
397
+ var SETTLE_TEMPO = { calm: 20, default: 25, quick: 37 };
398
+ var SETTLE_DEFAULTS = { omega: SETTLE_TEMPO.default, restDelta: 0.1 };
399
+ function positive2(name, value) {
400
+ if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`settle: ${name} must be a finite number > 0, got ${value}`);
401
+ return value;
402
+ }
403
+ var SettleAnimator = class {
404
+ layout;
405
+ x;
406
+ v;
407
+ goal;
408
+ omega;
409
+ restDelta;
410
+ settled = true;
411
+ cachedValue = null;
412
+ constructor(initial, config) {
413
+ this.layout = layoutOf(initial);
414
+ this.x = new Float64Array(this.layout.size);
415
+ this.v = new Float64Array(this.layout.size);
416
+ this.goal = new Float64Array(this.layout.size);
417
+ writeComponents(initial, this.x);
418
+ writeComponents(initial, this.goal);
419
+ this.omega = positive2("omega", config.omega ?? SETTLE_DEFAULTS.omega);
420
+ this.restDelta = positive2("restDelta", config.restDelta ?? SETTLE_DEFAULTS.restDelta);
421
+ }
422
+ get value() {
423
+ if (this.cachedValue === null) this.cachedValue = makeValue(this.layout, this.x);
424
+ return this.cachedValue;
425
+ }
426
+ get velocity() {
427
+ return makeValue(this.layout, this.v);
428
+ }
429
+ get target() {
430
+ return makeValue(this.layout, this.goal);
431
+ }
432
+ check(value, what) {
433
+ if (!sameLayout(layoutOf(value), this.layout)) {
434
+ throw new TypeError(`settle: ${what} has a different shape than the settle's value`);
435
+ }
436
+ }
437
+ /** The launch/clamp/carry rule on component `i`: `launch` for a new target, else clamp or carry. */
438
+ rule(i, launch) {
439
+ const d = this.x[i] - this.goal[i];
440
+ const v = this.v[i];
441
+ const limit = d === 0 ? 0 : -this.omega * d;
442
+ if (launch) {
443
+ this.v[i] = limit;
444
+ return;
445
+ }
446
+ if (d === 0) return;
447
+ if (d * v > 0) return;
448
+ if (Math.abs(v) > Math.abs(limit)) this.v[i] = limit;
449
+ }
450
+ updateSettled() {
451
+ for (let i = 0; i < this.x.length; i++) {
452
+ if (this.x[i] !== this.goal[i] || this.v[i] !== 0) {
453
+ this.settled = false;
454
+ return;
455
+ }
456
+ }
457
+ this.settled = true;
458
+ }
459
+ setTarget(target) {
460
+ this.check(target, "the target");
461
+ writeComponents(target, this.goal);
462
+ for (let i = 0; i < this.x.length; i++) this.rule(i, true);
463
+ this.updateSettled();
464
+ }
465
+ setVelocity(velocity) {
466
+ this.check(velocity, "the velocity");
467
+ writeComponents(velocity, this.v);
468
+ for (let i = 0; i < this.x.length; i++) this.rule(i, false);
469
+ this.updateSettled();
470
+ }
471
+ jumpTo(value) {
472
+ this.check(value, "the value");
473
+ writeComponents(value, this.x);
474
+ writeComponents(value, this.goal);
475
+ this.v.fill(0);
476
+ this.cachedValue = null;
477
+ this.settled = true;
478
+ }
479
+ hold(value) {
480
+ this.jumpTo(value);
481
+ }
482
+ snap() {
483
+ this.x.set(this.goal);
484
+ this.v.fill(0);
485
+ this.cachedValue = null;
486
+ this.settled = true;
487
+ }
488
+ configure(config) {
489
+ if (config.omega !== void 0) this.omega = positive2("omega", config.omega);
490
+ if (config.restDelta !== void 0) this.restDelta = positive2("restDelta", config.restDelta);
491
+ for (let i = 0; i < this.x.length; i++) this.rule(i, false);
492
+ }
493
+ step(dtMs) {
494
+ if (this.settled) return false;
495
+ if (!(dtMs > 0)) return true;
496
+ const w = this.omega;
497
+ const t = dtMs / 1e3;
498
+ const e = Math.exp(-w * t);
499
+ const { x, v, goal, restDelta } = this;
500
+ const restSpeed = w * restDelta * 1.000001;
501
+ let resting = true;
502
+ for (let i = 0; i < x.length; i++) {
503
+ const d = x[i] - goal[i];
504
+ const b = v[i] + w * d;
505
+ const nd = e * (d + b * t);
506
+ v[i] = e * (v[i] - w * b * t);
507
+ x[i] = goal[i] + nd;
508
+ const near = Math.max(restDelta, 4 * Number.EPSILON * Math.abs(goal[i]));
509
+ if (resting && (Math.abs(nd) > near || Math.abs(v[i]) > Math.max(restSpeed, w * near))) resting = false;
510
+ }
511
+ this.cachedValue = null;
512
+ if (resting) this.snap();
513
+ return !this.settled;
514
+ }
515
+ };
516
+ function createSettle(initial, config = {}) {
517
+ return new SettleAnimator(initial, config);
518
+ }
519
+
520
+ // src/values/reveal.ts
521
+ function reveal(drawn, target) {
522
+ return {
523
+ dx: drawn.x - target.x,
524
+ dy: drawn.y - target.y,
525
+ width: Math.max(0, drawn.width),
526
+ height: Math.max(0, drawn.height),
527
+ clipRight: Math.max(0, target.width - drawn.width),
528
+ clipBottom: Math.max(0, target.height - drawn.height)
529
+ };
530
+ }
531
+ function popIn(progress, from = 0.87) {
532
+ const p = Math.min(1, Math.max(0, progress));
533
+ return { scale: from + (1 - from) * p, opacity: p };
534
+ }
535
+
396
536
  // src/values/motion-value.ts
397
537
  var Motion = class {
398
538
  loop;
@@ -530,6 +670,9 @@ function motionValue(loop, animator, options = {}) {
530
670
  function springValue(loop, initial, options = {}) {
531
671
  return motionValue(loop, createSpring(initial, options), options);
532
672
  }
673
+ function settleValue(loop, initial, options = {}) {
674
+ return motionValue(loop, createSettle(initial, options), options);
675
+ }
533
676
  function tweenValue(loop, initial, options = {}) {
534
677
  return motionValue(loop, createTween(initial, options), options);
535
678
  }
@@ -549,8 +692,14 @@ export {
549
692
  springStep,
550
693
  createSpring,
551
694
  createTween,
695
+ SETTLE_TEMPO,
696
+ SETTLE_DEFAULTS,
697
+ createSettle,
698
+ reveal,
699
+ popIn,
552
700
  motionValue,
553
701
  springValue,
702
+ settleValue,
554
703
  tweenValue
555
704
  };
556
- //# sourceMappingURL=chunk-LCTGXGOI.js.map
705
+ //# sourceMappingURL=chunk-6W5KW7XQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/values/easing.ts","../src/shapes.ts","../src/values/spring.ts","../src/values/tween.ts","../src/values/settle.ts","../src/values/reveal.ts","../src/values/motion-value.ts"],"sourcesContent":["/** Maps progress in [0, 1] to eased progress (0 at 0, 1 at 1). */\nexport type Easing = (progress: number) => number;\n\n/** No easing. */\nexport const linear: Easing = (t) => t;\n\nconst EPSILON = 1e-7;\n\n/**\n * The CSS `cubic-bezier(x1, y1, x2, y2)` curve as a function, solved\n * numerically (Newton steps, then bisection). `x1` and `x2` must be in [0, 1].\n */\nexport function cubicBezier(x1: number, y1: number, x2: number, y2: number): Easing {\n if (!(x1 >= 0 && x1 <= 1 && x2 >= 0 && x2 <= 1)) {\n throw new RangeError(`cubicBezier: x1 and x2 must be in [0, 1], got ${x1} and ${x2}`);\n }\n if (x1 === y1 && x2 === y2) return linear;\n const cx = 3 * x1;\n const bx = 3 * (x2 - x1) - cx;\n const ax = 1 - cx - bx;\n const cy = 3 * y1;\n const by = 3 * (y2 - y1) - cy;\n const ay = 1 - cy - by;\n const sampleX = (t: number): number => ((ax * t + bx) * t + cx) * t;\n const sampleY = (t: number): number => ((ay * t + by) * t + cy) * t;\n const slopeX = (t: number): number => (3 * ax * t + 2 * bx) * t + cx;\n const solveX = (x: number): number => {\n let t = x;\n for (let i = 0; i < 8; i++) {\n const error = sampleX(t) - x;\n if (Math.abs(error) < EPSILON) return t;\n const slope = slopeX(t);\n if (Math.abs(slope) < 1e-6) break;\n t -= error / slope;\n }\n let low = 0;\n let high = 1;\n t = x;\n for (let i = 0; i < 40; i++) {\n const value = sampleX(t);\n if (Math.abs(value - x) < EPSILON) return t;\n if (x > value) low = t;\n else high = t;\n t = (low + high) / 2;\n }\n return t;\n };\n return (progress) => (progress <= 0 ? 0 : progress >= 1 ? 1 : sampleY(solveX(progress)));\n}\n\n/** CSS `ease`. */\nexport const ease: Easing = /* @__PURE__ */ cubicBezier(0.25, 0.1, 0.25, 1);\n/** CSS `ease-in`. */\nexport const easeIn: Easing = /* @__PURE__ */ cubicBezier(0.42, 0, 1, 1);\n/** CSS `ease-out`. */\nexport const easeOut: Easing = /* @__PURE__ */ cubicBezier(0, 0, 0.58, 1);\n/** CSS `ease-in-out`. */\nexport const easeInOut: Easing = /* @__PURE__ */ cubicBezier(0.42, 0, 0.58, 1);\n/** Cubic ease-out: fast start, gentle stop. The tween default. */\nexport const easeOutCubic: Easing = (t) => 1 - (1 - t) ** 3;\n/** Cubic ease-in-out. */\nexport const easeInOutCubic: Easing = (t) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2);\n","/** A point or a 2D vector. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** An axis-aligned rectangle. */\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Any number of components. */\nexport type Vector = readonly number[];\n\n/** The value shapes springs and tweens move: plain numbers, nothing else. */\nexport type Animatable = number | Point | Rect | Vector;\n\n/** The shape type of an {@link Animatable}: literal numbers widen to `number`. */\nexport type Widen<T> = T extends number\n ? number\n : T extends Vector\n ? Vector\n : T extends Rect\n ? Rect\n : T extends Point\n ? Point\n : never;\n\nconst SCALAR = 0;\nconst VECTOR = 1;\nconst POINT = 2;\nconst RECT = 3;\n\n/** How a shape maps onto a flat list of numbers. Internal to values/. */\nexport interface Layout {\n readonly kind: typeof SCALAR | typeof VECTOR | typeof POINT | typeof RECT;\n readonly size: number;\n}\n\nconst SCALAR_LAYOUT: Layout = { kind: SCALAR, size: 1 };\nconst POINT_LAYOUT: Layout = { kind: POINT, size: 2 };\nconst RECT_LAYOUT: Layout = { kind: RECT, size: 4 };\n\nexport function layoutOf(value: Animatable): Layout {\n if (typeof value === \"number\") return SCALAR_LAYOUT;\n if (Array.isArray(value)) return { kind: VECTOR, size: value.length };\n if (\"width\" in value) return RECT_LAYOUT;\n return POINT_LAYOUT;\n}\n\nexport function sameLayout(a: Layout, b: Layout): boolean {\n return a.kind === b.kind && a.size === b.size;\n}\n\n/** Copy `value`'s components into `out`. */\nexport function writeComponents(value: Animatable, out: Float64Array): void {\n if (typeof value === \"number\") {\n out[0] = value;\n } else if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) out[i] = value[i]!;\n } else if (\"width\" in value) {\n out[0] = value.x;\n out[1] = value.y;\n out[2] = value.width;\n out[3] = value.height;\n } else {\n const point = value as Point;\n out[0] = point.x;\n out[1] = point.y;\n }\n}\n\n/** A fresh value of `layout`'s shape from `components`. */\nexport function makeValue(layout: Layout, components: Float64Array): Animatable {\n switch (layout.kind) {\n case SCALAR:\n return components[0]!;\n case POINT:\n return { x: components[0]!, y: components[1]! };\n case RECT:\n return { x: components[0]!, y: components[1]!, width: components[2]!, height: components[3]! };\n default:\n return Array.from(components);\n }\n}\n\n/** Component-wise equality of two values of the same shape. */\nexport function shapeEquals(a: Animatable, b: Animatable): boolean {\n if (typeof a === \"number\" || typeof b === \"number\") return a === b;\n if (Array.isArray(a) || Array.isArray(b)) {\n const u = a as Vector;\n const v = b as Vector;\n if (u.length !== v.length) return false;\n for (let i = 0; i < u.length; i++) if (u[i] !== v[i]) return false;\n return true;\n }\n const p = a as Partial<Rect>;\n const q = b as Partial<Rect>;\n return p.x === q.x && p.y === q.y && p.width === q.width && p.height === q.height;\n}\n","import type { Animatable, Layout, Widen } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\n\n/**\n * Spring settings. Time is in milliseconds everywhere in the API; the physics\n * runs in seconds, so velocity is in units per second.\n */\nexport interface SpringConfig {\n /** Spring constant k. Higher is snappier. Default 300. */\n readonly stiffness?: number;\n /** Damping coefficient c. When set it wins over `dampingRatio`. */\n readonly damping?: number;\n /**\n * Damping as a fraction of critical damping: 1 is critical (the fastest\n * approach with no overshoot), below 1 overshoots and rings, above 1 is\n * sluggish. Default 1.\n */\n readonly dampingRatio?: number;\n /** Mass m. Default 1. */\n readonly mass?: number;\n /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */\n readonly restDelta?: number;\n /** Speed, in units per second, that counts as stopped. Default 1 (tuned for pixels). */\n readonly restSpeed?: number;\n}\n\n/** A {@link SpringConfig} with every field resolved. */\nexport interface SpringParams {\n readonly stiffness: number;\n readonly damping: number;\n readonly dampingRatio: number;\n readonly mass: number;\n readonly restDelta: number;\n readonly restSpeed: number;\n}\n\n/** Defaults of {@link SpringConfig}: critically damped. */\nexport const SPRING_DEFAULTS: SpringParams = {\n stiffness: 300,\n damping: 2 * Math.sqrt(300),\n dampingRatio: 1,\n mass: 1,\n restDelta: 0.1,\n restSpeed: 1,\n};\n\nfunction positive(name: string, value: number): number {\n if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`spring: ${name} must be a finite number > 0, got ${value}`);\n return value;\n}\n\n/** Resolve a {@link SpringConfig} over the defaults. Throws on a non-positive field. */\nexport function resolveSpring(config: SpringConfig = {}): SpringParams {\n const stiffness = positive(\"stiffness\", config.stiffness ?? SPRING_DEFAULTS.stiffness);\n const mass = positive(\"mass\", config.mass ?? SPRING_DEFAULTS.mass);\n const critical = 2 * Math.sqrt(stiffness * mass);\n const damping = positive(\n config.damping !== undefined ? \"damping\" : \"dampingRatio\",\n config.damping ?? (config.dampingRatio ?? SPRING_DEFAULTS.dampingRatio) * critical,\n );\n return {\n stiffness,\n damping,\n dampingRatio: damping / critical,\n mass,\n restDelta: positive(\"restDelta\", config.restDelta ?? SPRING_DEFAULTS.restDelta),\n restSpeed: positive(\"restSpeed\", config.restSpeed ?? SPRING_DEFAULTS.restSpeed),\n };\n}\n\nconst UNDERDAMPED = 0;\nconst CRITICAL = 1;\nconst OVERDAMPED = 2;\n\n/** The closed-form solution's constants for one set of params. */\ninterface Solver {\n readonly mode: typeof UNDERDAMPED | typeof CRITICAL | typeof OVERDAMPED;\n readonly omega: number;\n readonly decay: number;\n readonly omegaD: number;\n readonly r1: number;\n readonly r2: number;\n}\n\nfunction solverFor(params: SpringParams): Solver {\n const omega = Math.sqrt(params.stiffness / params.mass);\n const zeta = params.dampingRatio;\n if (Math.abs(zeta - 1) < 1e-6) return { mode: CRITICAL, omega, decay: omega, omegaD: 0, r1: 0, r2: 0 };\n if (zeta < 1) {\n return { mode: UNDERDAMPED, omega, decay: zeta * omega, omegaD: omega * Math.sqrt(1 - zeta * zeta), r1: 0, r2: 0 };\n }\n const root = Math.sqrt(zeta * zeta - 1);\n return { mode: OVERDAMPED, omega, decay: 0, omegaD: 0, r1: -omega * (zeta - root), r2: -omega * (zeta + root) };\n}\n\n/**\n * Advance one component exactly: displacement `d0` from the target and\n * velocity `v0` (per second) after `t` seconds. Writes into out[0], out[1].\n * Exact for any `t`, so the curve doesn't depend on the frame rate.\n */\nfunction advance(solver: Solver, d0: number, v0: number, t: number, out: Float64Array): void {\n if (solver.mode === CRITICAL) {\n const w = solver.omega;\n const e = Math.exp(-w * t);\n const b = v0 + w * d0;\n out[0] = e * (d0 + b * t);\n out[1] = e * (v0 - w * b * t);\n } else if (solver.mode === UNDERDAMPED) {\n const a = solver.decay;\n const wd = solver.omegaD;\n const e = Math.exp(-a * t);\n const cos = Math.cos(wd * t);\n const sin = Math.sin(wd * t);\n out[0] = e * (d0 * cos + ((v0 + a * d0) / wd) * sin);\n out[1] = e * (v0 * cos - ((a * v0 + solver.omega * solver.omega * d0) / wd) * sin);\n } else {\n const { r1, r2 } = solver;\n const c2 = (v0 - r1 * d0) / (r2 - r1);\n const c1 = d0 - c2;\n const e1 = Math.exp(r1 * t);\n const e2 = Math.exp(r2 * t);\n out[0] = c1 * e1 + c2 * e2;\n out[1] = c1 * r1 * e1 + c2 * r2 * e2;\n }\n}\n\n/** A scalar spring's position and velocity (units per second). */\nexport interface SpringState {\n readonly value: number;\n readonly velocity: number;\n}\n\n/**\n * One pure spring step for a scalar: where `state` is after `dtMs` heading for\n * `target`. Doesn't settle or snap; {@link createSpring} does that.\n */\nexport function springStep(state: SpringState, target: number, params: SpringParams, dtMs: number): SpringState {\n const out = new Float64Array(2);\n advance(solverFor(params), state.value - target, state.velocity, dtMs / 1000, out);\n return { value: target + out[0]!, velocity: out[1]! };\n}\n\n/** A spring over any {@link Animatable} shape, stepped by hand or by `motionValue`. */\nexport interface Spring<T> extends Animator<T> {\n /** The resolved settings. */\n readonly params: SpringParams;\n /** Set the velocity in units per second (a gesture's release velocity). */\n setVelocity(velocity: T): void;\n /** Change settings mid-flight; position and velocity carry on. */\n configure(config: SpringConfig): void;\n}\n\nclass SpringAnimator implements Spring<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly v: Float64Array;\n readonly goal: Float64Array;\n readonly scratch = new Float64Array(2);\n config: SpringConfig;\n params: SpringParams;\n solver: Solver;\n settled = true;\n cachedValue: Animatable | null = null;\n\n constructor(initial: Animatable, config: SpringConfig) {\n this.layout = layoutOf(initial);\n const size = this.layout.size;\n this.x = new Float64Array(size);\n this.v = new Float64Array(size);\n this.goal = new Float64Array(size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.goal);\n this.config = config;\n this.params = resolveSpring(config);\n this.solver = solverFor(this.params);\n }\n\n get value(): Animatable {\n if (this.cachedValue === null) this.cachedValue = makeValue(this.layout, this.x);\n return this.cachedValue;\n }\n\n get velocity(): Animatable {\n return makeValue(this.layout, this.v);\n }\n\n get target(): Animatable {\n return makeValue(this.layout, this.goal);\n }\n\n check(value: Animatable, what: string): void {\n if (!sameLayout(layoutOf(value), this.layout)) {\n throw new TypeError(`spring: ${what} has a different shape than the spring's value`);\n }\n }\n\n /** At rest exactly when on the target and not moving. */\n updateSettled(): void {\n for (let i = 0; i < this.x.length; i++) {\n if (this.x[i] !== this.goal[i] || this.v[i] !== 0) {\n this.settled = false;\n return;\n }\n }\n this.settled = true;\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n // Position and velocity stay as they are: a retarget carries the motion on.\n this.updateSettled();\n }\n\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n writeComponents(velocity, this.v);\n this.updateSettled();\n }\n\n jumpTo(value: Animatable): void {\n this.check(value, \"the value\");\n writeComponents(value, this.x);\n writeComponents(value, this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n snap(): void {\n this.x.set(this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n configure(config: SpringConfig): void {\n this.config = { ...this.config, ...config };\n this.params = resolveSpring(this.config);\n this.solver = solverFor(this.params);\n }\n\n step(dtMs: number): boolean {\n if (this.settled) return false;\n if (!(dtMs > 0)) return true;\n const t = dtMs / 1000;\n const { x, v, goal, scratch } = this;\n const { restDelta, restSpeed } = this.params;\n let resting = true;\n for (let i = 0; i < x.length; i++) {\n advance(this.solver, x[i]! - goal[i]!, v[i]!, t, scratch);\n x[i] = goal[i]! + scratch[0]!;\n v[i] = scratch[1]!;\n if (resting && (Math.abs(scratch[0]!) > restDelta || Math.abs(scratch[1]!) > restSpeed)) resting = false;\n }\n this.cachedValue = null;\n if (resting) this.snap();\n return !this.settled;\n }\n}\n\n/**\n * A spring starting at rest on `initial`. `initial` fixes the shape: a\n * number, a vector (array), a point `{ x, y }` or a rect `{ x, y, width,\n * height }`; targets and velocities must have the same shape.\n */\nexport function createSpring<T extends Animatable>(initial: T, config: SpringConfig = {}): Spring<Widen<T>> {\n return new SpringAnimator(initial, config) as unknown as Spring<Widen<T>>;\n}\n","import type { Animatable, Layout, Widen } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { easeOutCubic, type Easing } from \"./easing\";\n\n/** Tween settings. */\nexport interface TweenConfig {\n /** Length of a run in ms. Default 250. 0 jumps to the target on the next step. */\n readonly duration?: number;\n /** Easing of the run. Default {@link easeOutCubic}. */\n readonly easing?: Easing;\n}\n\n/** A tween over any {@link Animatable} shape. */\nexport interface Tween<T> extends Animator<T> {\n /** Run progress in [0, 1]. */\n readonly progress: number;\n /** Change duration or easing; applies from the next target. */\n configure(config: TweenConfig): void;\n}\n\nclass TweenAnimator implements Tween<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly from: Float64Array;\n readonly goal: Float64Array;\n duration: number;\n easing: Easing;\n elapsed = 0;\n settled = true;\n cachedValue: Animatable | null = null;\n\n constructor(initial: Animatable, config: TweenConfig) {\n this.layout = layoutOf(initial);\n const size = this.layout.size;\n this.x = new Float64Array(size);\n this.from = new Float64Array(size);\n this.goal = new Float64Array(size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.from);\n writeComponents(initial, this.goal);\n this.duration = 250;\n this.easing = easeOutCubic;\n this.configure(config);\n }\n\n get value(): Animatable {\n if (this.cachedValue === null) this.cachedValue = makeValue(this.layout, this.x);\n return this.cachedValue;\n }\n\n get target(): Animatable {\n return makeValue(this.layout, this.goal);\n }\n\n get progress(): number {\n if (this.settled) return 1;\n return this.duration <= 0 ? 0 : Math.min(1, this.elapsed / this.duration);\n }\n\n /** The eased curve's slope at the current progress, as units per second. */\n get velocity(): Animatable {\n const out = new Float64Array(this.layout.size);\n if (!this.settled && this.duration > 0) {\n const p = this.progress;\n const h = 1e-3;\n const lo = Math.max(0, p - h);\n const hi = Math.min(1, p + h);\n const slope = (this.easing(hi) - this.easing(lo)) / (hi - lo);\n const perSecond = (slope / this.duration) * 1000;\n for (let i = 0; i < out.length; i++) out[i] = (this.goal[i]! - this.from[i]!) * perSecond;\n }\n return makeValue(this.layout, out);\n }\n\n configure(config: TweenConfig): void {\n if (config.duration !== undefined) {\n if (!(config.duration >= 0) || !Number.isFinite(config.duration)) {\n throw new RangeError(`tween: duration must be a finite number >= 0, got ${config.duration}`);\n }\n this.duration = config.duration;\n }\n if (config.easing !== undefined) this.easing = config.easing;\n }\n\n check(value: Animatable, what: string): void {\n if (!sameLayout(layoutOf(value), this.layout)) {\n throw new TypeError(`tween: ${what} has a different shape than the tween's value`);\n }\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n // A new run starts from wherever the value is now (no jump).\n this.from.set(this.x);\n this.elapsed = 0;\n this.settled = true;\n for (let i = 0; i < this.x.length; i++) {\n if (this.x[i] !== this.goal[i]) {\n this.settled = false;\n break;\n }\n }\n }\n\n jumpTo(value: Animatable): void {\n this.check(value, \"the value\");\n writeComponents(value, this.x);\n writeComponents(value, this.from);\n writeComponents(value, this.goal);\n this.cachedValue = null;\n this.settled = true;\n }\n\n snap(): void {\n this.x.set(this.goal);\n this.from.set(this.goal);\n this.cachedValue = null;\n this.settled = true;\n }\n\n step(dtMs: number): boolean {\n if (this.settled) return false;\n this.elapsed += Math.max(0, dtMs);\n const p = this.duration <= 0 ? 1 : Math.min(1, this.elapsed / this.duration);\n if (p >= 1) {\n this.snap();\n return false;\n }\n const eased = this.easing(p);\n for (let i = 0; i < this.x.length; i++) {\n this.x[i] = this.from[i]! + (this.goal[i]! - this.from[i]!) * eased;\n }\n this.cachedValue = null;\n return true;\n }\n}\n\n/**\n * A tween starting at rest on `initial` (same shapes as `createSpring`).\n * Velocity doesn't carry over a retarget: a new target starts a new run from\n * the current value. Use a spring where motion must stay continuous.\n */\nexport function createTween<T extends Animatable>(initial: T, config: TweenConfig = {}): Tween<Widen<T>> {\n return new TweenAnimator(initial, config) as unknown as Tween<Widen<T>>;\n}\n","import type { Animatable, Layout, Widen } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\n\n/**\n * Tempos for {@link createSettle}, in 1/s: a settle covers 90 % of the way in\n * ln(10)/omega seconds and is within 1 % in twice that.\n *\n * - `calm` 20: 90 % in 115 ms, done in 230 ms.\n * - `default` 25: 90 % in 92 ms, done in 184 ms.\n * - `quick` 37: 90 % in 62 ms, done in 124 ms (a fast Hyprland setup).\n */\nexport const SETTLE_TEMPO = { calm: 20, default: 25, quick: 37 } as const;\n\n/** Settings of {@link createSettle}. */\nexport interface SettleConfig {\n /** The tempo in 1/s (see {@link SETTLE_TEMPO}). Higher is faster. Default 25. */\n readonly omega?: number;\n /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */\n readonly restDelta?: number;\n}\n\n/**\n * The one curve for things that move to a new place: a window's rect between\n * layout targets, a drawer, a camera. Fast at the start, gentle at the end,\n * and it never passes its target.\n *\n * It is a critically damped spring (stiffness omega², damping 2·omega) with\n * one rule on its velocity, per component:\n *\n * - **Launch.** On a new target, each component gets the velocity\n * omega · distance toward it, from wherever it is drawn: standing still,\n * moving toward it, or moving away (it turns at once rather than drifting\n * further first). From there the spring follows `distance · e^(−omega·t)`\n * exactly: most of the move happens at once, the rest eases in.\n * - **Clamp.** That speed is also the most it may have toward the target, so a\n * velocity set by hand (`setVelocity`, a fling) toward the target is capped\n * there instead of shooting past.\n * - **Carry.** A velocity set by hand away from the target is kept, and the\n * value turns around; a critically damped spring turning around never\n * crosses the target either.\n *\n * So after a new target every component goes straight from where it is drawn\n * to the target and never past it: no overshoot on position, no wobble on\n * size, whatever the retargets. A new target starts from the drawn value,\n * never from the old start.\n *\n * Holding (a pointer owns the value): call `hold(value)` on each move. The\n * value sits exactly there, at rest; the next `setTarget` launches from it.\n */\nexport interface Settle<T> extends Animator<T> {\n /** The tempo in 1/s. */\n readonly omega: number;\n /** Put the value at `value`, at rest, with it as the target: a held value follows its owner 1:1. Same as `jumpTo`. */\n hold(value: T): void;\n /** Set the velocity (units per second); a component moving toward the target is clamped as in the launch rule. */\n setVelocity(velocity: T): void;\n /** Change the tempo or rest distance mid-flight; the value and velocity carry on, re-clamped. */\n configure(config: SettleConfig): void;\n}\n\n/** Defaults of {@link SettleConfig}. */\nexport const SETTLE_DEFAULTS = { omega: SETTLE_TEMPO.default, restDelta: 0.1 } as const;\n\nfunction positive(name: string, value: number): number {\n if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`settle: ${name} must be a finite number > 0, got ${value}`);\n return value;\n}\n\nclass SettleAnimator implements Settle<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly v: Float64Array;\n readonly goal: Float64Array;\n omega: number;\n restDelta: number;\n settled = true;\n cachedValue: Animatable | null = null;\n\n constructor(initial: Animatable, config: SettleConfig) {\n this.layout = layoutOf(initial);\n this.x = new Float64Array(this.layout.size);\n this.v = new Float64Array(this.layout.size);\n this.goal = new Float64Array(this.layout.size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.goal);\n this.omega = positive(\"omega\", config.omega ?? SETTLE_DEFAULTS.omega);\n this.restDelta = positive(\"restDelta\", config.restDelta ?? SETTLE_DEFAULTS.restDelta);\n }\n\n get value(): Animatable {\n if (this.cachedValue === null) this.cachedValue = makeValue(this.layout, this.x);\n return this.cachedValue;\n }\n\n get velocity(): Animatable {\n return makeValue(this.layout, this.v);\n }\n\n get target(): Animatable {\n return makeValue(this.layout, this.goal);\n }\n\n check(value: Animatable, what: string): void {\n if (!sameLayout(layoutOf(value), this.layout)) {\n throw new TypeError(`settle: ${what} has a different shape than the settle's value`);\n }\n }\n\n /** The launch/clamp/carry rule on component `i`: `launch` for a new target, else clamp or carry. */\n rule(i: number, launch: boolean): void {\n const d = this.x[i]! - this.goal[i]!;\n const v = this.v[i]!;\n const limit = d === 0 ? 0 : -this.omega * d;\n if (launch) {\n this.v[i] = limit;\n return;\n }\n if (d === 0) return;\n // Moving away from the target (d and v the same sign): carry.\n if (d * v > 0) return;\n // Moving toward it: no faster than a launch from here.\n if (Math.abs(v) > Math.abs(limit)) this.v[i] = limit;\n }\n\n updateSettled(): void {\n for (let i = 0; i < this.x.length; i++) {\n if (this.x[i] !== this.goal[i] || this.v[i] !== 0) {\n this.settled = false;\n return;\n }\n }\n this.settled = true;\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n for (let i = 0; i < this.x.length; i++) this.rule(i, true);\n this.updateSettled();\n }\n\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n writeComponents(velocity, this.v);\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n this.updateSettled();\n }\n\n jumpTo(value: Animatable): void {\n this.check(value, \"the value\");\n writeComponents(value, this.x);\n writeComponents(value, this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n hold(value: Animatable): void {\n this.jumpTo(value);\n }\n\n snap(): void {\n this.x.set(this.goal);\n this.v.fill(0);\n this.cachedValue = null;\n this.settled = true;\n }\n\n configure(config: SettleConfig): void {\n if (config.omega !== undefined) this.omega = positive(\"omega\", config.omega);\n if (config.restDelta !== undefined) this.restDelta = positive(\"restDelta\", config.restDelta);\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n }\n\n step(dtMs: number): boolean {\n if (this.settled) return false;\n if (!(dtMs > 0)) return true;\n const w = this.omega;\n const t = dtMs / 1000;\n const e = Math.exp(-w * t);\n const { x, v, goal, restDelta } = this;\n // At rest when every component is within restDelta and no faster than a launch from there would be.\n const restSpeed = w * restDelta * 1.000001;\n let resting = true;\n for (let i = 0; i < x.length; i++) {\n // The exact critically damped step: d(t) = e^(−wt)·(d + b·t), b = v + w·d.\n const d = x[i]! - goal[i]!;\n const b = v[i]! + w * d;\n const nd = e * (d + b * t);\n v[i] = e * (v[i]! - w * b * t);\n x[i] = goal[i]! + nd;\n // Within a few float steps of the goal counts as arrived too: a restDelta finer than that would never be met.\n const near = Math.max(restDelta, 4 * Number.EPSILON * Math.abs(goal[i]!));\n if (resting && (Math.abs(nd) > near || Math.abs(v[i]!) > Math.max(restSpeed, w * near))) resting = false;\n }\n this.cachedValue = null;\n if (resting) this.snap();\n return !this.settled;\n }\n}\n\n/**\n * A settle starting at rest on `initial` (a number, a vector, a point or a\n * rect; targets and velocities must have the same shape). See {@link Settle}.\n */\nexport function createSettle<T extends Animatable>(initial: T, config: SettleConfig = {}): Settle<Widen<T>> {\n return new SettleAnimator(initial, config) as unknown as Settle<Widen<T>>;\n}\n","import type { Rect } from \"../shapes\";\n\n/**\n * How to draw a window whose rect is gliding without stretching its content.\n *\n * The content is laid out once at the target size and never scaled. The\n * window's element sits at its target in the layout; to draw it at the\n * gliding rect:\n *\n * - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;\n * - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;\n * - clip the content by `clipRight` and `clipBottom` so it fits a frame\n * smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).\n *\n * A window that shrinks shows a band of its own background closing in at the\n * right and bottom; one that grows reveals content already laid out at its\n * new size. Text is never stretched. One transform and one clip per frame, no\n * layout per frame.\n */\nexport interface RevealFrame {\n /** Move the element (laid out at the target) right by this much. */\n readonly dx: number;\n /** Move the element (laid out at the target) down by this much. */\n readonly dy: number;\n /** The frame's width: the drawn rect's. */\n readonly width: number;\n /** The frame's height: the drawn rect's. */\n readonly height: number;\n /** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */\n readonly clipRight: number;\n /** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */\n readonly clipBottom: number;\n}\n\n/** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */\nexport function reveal(drawn: Rect, target: Rect): RevealFrame {\n return {\n dx: drawn.x - target.x,\n dy: drawn.y - target.y,\n width: Math.max(0, drawn.width),\n height: Math.max(0, drawn.height),\n clipRight: Math.max(0, target.width - drawn.width),\n clipBottom: Math.max(0, target.height - drawn.height),\n };\n}\n\n/** A uniform pop-in (or pop-out, run backwards): scale about the centre and opacity. */\nexport interface PopIn {\n /** Scale about the window's centre: the same on both axes, so nothing is stretched. */\n readonly scale: number;\n readonly opacity: number;\n}\n\n/**\n * Opening and closing: the window grows from `from` of its size to full, about\n * its centre, while fading in. `progress` runs 0 to 1 (take it from a settle\n * on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for\n * pixels and would snap the last 10 %; or from a tween); closing runs it from\n * 1 to 0. Hyprland's default is `popin 87%`.\n */\nexport function popIn(progress: number, from = 0.87): PopIn {\n const p = Math.min(1, Math.max(0, progress));\n return { scale: from + (1 - from) * p, opacity: p };\n}\n","import type { FrameInfo, FrameLoop, Phase } from \"../clock/frame-loop\";\nimport type { Animatable, Widen } from \"../shapes\";\nimport { shapeEquals } from \"../shapes\";\nimport { batch, effect, signal, untracked, type ReadonlySignal, type Signal } from \"../signals/signals\";\nimport type { Animator } from \"./animator\";\nimport { createSettle, type Settle, type SettleConfig } from \"./settle\";\nimport { createSpring, type Spring, type SpringConfig } from \"./spring\";\nimport { createTween, type Tween, type TweenConfig } from \"./tween\";\n\n/** Options of {@link motionValue}. */\nexport interface MotionOptions {\n /**\n * The frame phase that steps the value. Default `\"layout\"`: it steps after\n * that phase's one-shot tasks, so a target set in input, update or layout\n * moves the value in the same frame, and `write` sees the new value.\n */\n readonly phase?: Phase;\n /**\n * The reduced-motion switch: while it is (or returns) `true`, every new\n * target is reached at once, and a value in flight snaps on its next frame.\n * A function is read on each `set` and each frame, so it can read a signal\n * or a media query.\n */\n readonly reducedMotion?: boolean | (() => boolean);\n}\n\n/** Options of {@link MotionValue.set}. */\nexport interface SetOptions<T> {\n /** Start with this velocity (units per second), e.g. a gesture's release velocity. Springs and settles (a settle caps it toward the target); tweens ignore it. */\n readonly velocity?: T;\n}\n\n/**\n * An animated value on a frame loop. Reading `value` inside a computed or an\n * effect tracks it; it changes once per frame while moving and the loop goes\n * idle when it settles.\n */\nexport interface MotionValue<T, A extends Animator<unknown> = Animator<T>> extends ReadonlySignal<T> {\n /** Where the value is heading. */\n readonly target: T;\n /** The current velocity, units per second. */\n readonly velocity: T;\n /** Whether it is moving (reactive). */\n readonly moving: boolean;\n /** The spring, settle or tween underneath. Change it through this value (`jump`, not the animator's `hold`), so the signal and the loop follow. */\n readonly animator: A;\n /** Head for `target`; a spring keeps its velocity, a settle launches from where it is drawn, a tween restarts. */\n set(target: T, options?: SetOptions<T>): void;\n /** Put the value at `value` at once, at rest. */\n jump(value: T): void;\n /** Finish now: put the value on its target, at rest. */\n snap(): void;\n /**\n * Keep heading for whatever `source` returns. `source` is tracked like an\n * effect, and re-read in this value's phase at most once per frame. Returns\n * a stop function.\n */\n follow(source: () => T): () => void;\n /**\n * Call `listener` each time the value comes to rest: on the frame it\n * settles, or at once when `set` (under reduced motion), `snap` or `jump`\n * leaves it at rest. Returns an unsubscribe function.\n */\n onSettle(listener: (value: T) => void): () => void;\n /** Stop stepping, drop listeners and follows. */\n dispose(): void;\n}\n\nclass Motion<T> implements MotionValue<T> {\n readonly loop: FrameLoop;\n readonly animator: Animator<T>;\n readonly phase: Phase;\n readonly reduced: () => boolean;\n readonly current: Signal<T>;\n readonly movingSignal: Signal<boolean>;\n readonly listeners = new Set<(value: T) => void>();\n readonly follows = new Set<() => void>();\n stop: (() => void) | null = null;\n disposed = false;\n\n constructor(loop: FrameLoop, animator: Animator<T>, options: MotionOptions) {\n this.loop = loop;\n this.animator = animator;\n this.phase = options.phase ?? \"layout\";\n const reducedMotion = options.reducedMotion ?? false;\n this.reduced = typeof reducedMotion === \"function\" ? reducedMotion : () => reducedMotion;\n this.current = signal(animator.value, {\n equals: shapeEquals as (a: T, b: T) => boolean,\n });\n this.movingSignal = signal(false);\n if (!animator.settled) this.start();\n }\n\n get value(): T {\n return this.current.value;\n }\n\n peek(): T {\n return this.current.peek();\n }\n\n get target(): T {\n return this.animator.target;\n }\n\n get velocity(): T {\n return this.animator.velocity;\n }\n\n get moving(): boolean {\n return this.movingSignal.value;\n }\n\n readonly tick = (frame: FrameInfo): boolean => {\n if (this.reduced()) this.animator.snap();\n else this.animator.step(frame.delta);\n if (!this.animator.settled) {\n this.current.value = this.animator.value;\n return true;\n }\n this.stop = null;\n this.rest();\n return false;\n };\n\n start(): void {\n if (this.stop !== null || this.disposed) return;\n this.stop = this.loop.repeat(this.phase, this.tick);\n this.movingSignal.value = true;\n }\n\n halt(): void {\n if (this.stop === null) return;\n this.stop();\n this.stop = null;\n }\n\n /** Publish the resting value and tell the listeners. */\n rest(): void {\n batch(() => {\n this.current.value = this.animator.value;\n this.movingSignal.value = false;\n });\n const value = this.animator.value;\n for (const listener of Array.from(this.listeners)) listener(value);\n }\n\n set(target: T, options?: SetOptions<T>): void {\n if (this.disposed) return;\n untracked(() => {\n this.animator.setTarget(target);\n if (options?.velocity !== undefined) this.animator.setVelocity?.(options.velocity);\n if (this.reduced()) this.animator.snap();\n if (this.animator.settled) {\n this.halt();\n this.rest();\n } else {\n this.start();\n }\n });\n }\n\n jump(value: T): void {\n if (this.disposed) return;\n untracked(() => {\n this.animator.jumpTo(value);\n this.halt();\n this.rest();\n });\n }\n\n snap(): void {\n if (this.disposed) return;\n untracked(() => {\n this.animator.snap();\n this.halt();\n this.rest();\n });\n }\n\n follow(source: () => T): () => void {\n if (this.disposed) return () => {};\n const dispose = effect(\n () => {\n const target = source();\n this.set(target);\n },\n { schedule: this.loop.scheduler(this.phase) },\n );\n const stop = (): void => {\n dispose();\n this.follows.delete(stop);\n };\n this.follows.add(stop);\n return stop;\n }\n\n onSettle(listener: (value: T) => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.halt();\n for (const stop of Array.from(this.follows)) stop();\n this.listeners.clear();\n this.movingSignal.value = false;\n }\n}\n\n/** The value type an animator moves. */\nexport type AnimatorValue<A> = A extends Animator<infer T> ? T : never;\n\n/** Step `animator` on `loop` while it moves, and expose it as a signal. */\nexport function motionValue<A extends Animator<unknown>>(\n loop: FrameLoop,\n animator: A,\n options: MotionOptions = {},\n): MotionValue<AnimatorValue<A>, A> {\n return new Motion(loop, animator, options) as unknown as MotionValue<AnimatorValue<A>, A>;\n}\n\n/** A spring-driven {@link MotionValue}: `createSpring` plus `motionValue`. */\nexport function springValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SpringConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Spring<Widen<T>>> {\n return motionValue(loop, createSpring(initial, options), options) as MotionValue<Widen<T>, Spring<Widen<T>>>;\n}\n\n/**\n * A settle-driven {@link MotionValue}: `createSettle` plus `motionValue`. The\n * one curve for things moving to a new place (see {@link Settle}). To hold it\n * to a pointer, `jump` it on each move; the next `set` launches from there.\n */\nexport function settleValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SettleConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Settle<Widen<T>>> {\n return motionValue(loop, createSettle(initial, options), options) as MotionValue<Widen<T>, Settle<Widen<T>>>;\n}\n\n/** A tween-driven {@link MotionValue}: `createTween` plus `motionValue`. */\nexport function tweenValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: TweenConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Tween<Widen<T>>> {\n return motionValue(loop, createTween(initial, options), options) as MotionValue<Widen<T>, Tween<Widen<T>>>;\n}\n"],"mappings":";;;;;;;;AAIO,IAAM,SAAiB,CAAC,MAAM;AAErC,IAAM,UAAU;AAMT,SAAS,YAAY,IAAY,IAAY,IAAY,IAAoB;AAClF,MAAI,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,IAAI;AAC/C,UAAM,IAAI,WAAW,iDAAiD,EAAE,QAAQ,EAAE,EAAE;AAAA,EACtF;AACA,MAAI,OAAO,MAAM,OAAO,GAAI,QAAO;AACnC,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,KAAK,KAAK,MAAM;AAC3B,QAAM,KAAK,IAAI,KAAK;AACpB,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,KAAK,KAAK,MAAM;AAC3B,QAAM,KAAK,IAAI,KAAK;AACpB,QAAM,UAAU,CAAC,QAAwB,KAAK,IAAI,MAAM,IAAI,MAAM;AAClE,QAAM,UAAU,CAAC,QAAwB,KAAK,IAAI,MAAM,IAAI,MAAM;AAClE,QAAM,SAAS,CAAC,OAAuB,IAAI,KAAK,IAAI,IAAI,MAAM,IAAI;AAClE,QAAM,SAAS,CAAC,MAAsB;AACpC,QAAI,IAAI;AACR,aAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,YAAM,QAAQ,QAAQ,CAAC,IAAI;AAC3B,UAAI,KAAK,IAAI,KAAK,IAAI,QAAS,QAAO;AACtC,YAAM,QAAQ,OAAO,CAAC;AACtB,UAAI,KAAK,IAAI,KAAK,IAAI,KAAM;AAC5B,WA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nB,SAAK,WAAW;AAChB,SAAK,KAAK;AACV,eAAW,QAAQ,MAAM,KAAK,KAAK,OAAO,EAAG,MAAK;AAClD,SAAK,UAAU,MAAM;AACrB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;AAMO,SAAS,YACd,MACA,UACA,UAAyB,CAAC,GACQ;AAClC,SAAO,IAAI,OAAO,MAAM,UAAU,OAAO;AAC3C;AAGO,SAAS,YACd,MACA,SACA,UAAwC,CAAC,GACA;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAOO,SAAS,YACd,MACA,SACA,UAAwC,CAAC,GACA;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAGO,SAAS,WACd,MACA,SACA,UAAuC,CAAC,GACA;AACxC,SAAO,YAAY,MAAM,YAAY,SAAS,OAAO,GAAG,OAAO;AACjE;","names":["positive"]}
@@ -62,6 +62,7 @@ var RECOGNIZER_DEFAULTS = Object.freeze({
62
62
  multiClick: Object.freeze({ ms: 300, px: 5 }),
63
63
  pinch: Object.freeze({ scaleThreshold: 0.05, panThreshold: 10 })
64
64
  });
65
+ var SOLO_MOVES = 3;
65
66
  function kindOf(pointerType) {
66
67
  return pointerType === "touch" || pointerType === "pen" ? pointerType : "mouse";
67
68
  }
@@ -161,11 +162,18 @@ function createRecognizer(options, emit) {
161
162
  touchLocked = touches.size > 0;
162
163
  if (p && p.kind) emit(pinchEvent(phase, p.lastCenter, 1, { x: 0, y: 0 }, time, modifiers, "touch", p.kind));
163
164
  };
164
- const updatePinch = (time, modifiers) => {
165
+ const updatePinch = (id, time, modifiers, moved, lifting = false) => {
165
166
  const p = pinch;
166
167
  const now = pinchState();
167
168
  if (!p || !now) return;
168
169
  if (!p.kind) {
170
+ if (!moved && !lifting) return;
171
+ const moves = (p.reported.get(id) ?? 0) + (moved ? 1 : 0);
172
+ p.reported.set(id, moves);
173
+ const other = p.reported.get(p.ids[0] === id ? p.ids[1] : p.ids[0]) ?? 0;
174
+ const even = moves > 0 && moves === other;
175
+ if (!lifting && !even && Math.abs(moves - other) < SOLO_MOVES) return;
176
+ p.reported.clear();
169
177
  const scaleChange = Math.abs(now.d / p.startDist - 1);
170
178
  const panDist = dist(now.center, p.startCenter);
171
179
  if (scaleChange > pinchCfg.scaleThreshold) p.kind = "pinch";
@@ -221,7 +229,7 @@ function createRecognizer(options, emit) {
221
229
  const b = touches.get(ids[1]);
222
230
  const d = Math.max(1, dist(a.screen, b.screen));
223
231
  const c = mid(a.screen, b.screen);
224
- pinch = { ids, startDist: d, startCenter: c, lastDist: d, lastCenter: c, kind: null };
232
+ pinch = { ids, startDist: d, startCenter: c, lastDist: d, lastCenter: c, kind: null, reported: /* @__PURE__ */ new Map() };
225
233
  return;
226
234
  }
227
235
  if (touches.size > 2) return;
@@ -252,12 +260,14 @@ function createRecognizer(options, emit) {
252
260
  const kind = kindOf(e.pointerType);
253
261
  if (kind === "touch") {
254
262
  const t = touches.get(e.pointerId);
263
+ const to = finitePoint(e.screen);
264
+ const moved = !t || t.screen.x !== to.x || t.screen.y !== to.y;
255
265
  if (t) {
256
- t.screen = finitePoint(e.screen);
266
+ t.screen = to;
257
267
  t.time = e.time;
258
268
  }
259
269
  if (pinch && pinch.ids.includes(e.pointerId)) {
260
- updatePinch(e.time, toModifiers(e.modifiers));
270
+ updatePinch(e.pointerId, e.time, toModifiers(e.modifiers), moved);
261
271
  return;
262
272
  }
263
273
  }
@@ -284,6 +294,13 @@ function createRecognizer(options, emit) {
284
294
  };
285
295
  const onUp = (e) => {
286
296
  if (kindOf(e.pointerType) === "touch") {
297
+ const t = touches.get(e.pointerId);
298
+ if (t && pinch && !pinch.kind && pinch.ids.includes(e.pointerId)) {
299
+ const to = finitePoint(e.screen);
300
+ const moved = t.screen.x !== to.x || t.screen.y !== to.y;
301
+ t.screen = to;
302
+ updatePinch(e.pointerId, e.time, toModifiers(e.modifiers), moved, true);
303
+ }
287
304
  touches.delete(e.pointerId);
288
305
  if (pinch && pinch.ids.includes(e.pointerId)) {
289
306
  endPinch("end", e.time, toModifiers(e.modifiers));
@@ -577,4 +594,4 @@ export {
577
594
  dwellDeadline,
578
595
  createDwellMachine
579
596
  };
580
- //# sourceMappingURL=chunk-QPOUWB7H.js.map
597
+ //# sourceMappingURL=chunk-NFQ4LIIR.js.map