@n-uf/motion 26.11.64 → 26.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/browser.d.ts +4 -4
  3. package/dist/browser.js +2 -2
  4. package/dist/{chunk-G5EJSZ3B.js → chunk-BCFPSDOQ.js} +6 -1
  5. package/dist/chunk-BCFPSDOQ.js.map +1 -0
  6. package/dist/{chunk-B53X43GW.js → chunk-F5FNGVQT.js} +6 -5
  7. package/dist/chunk-F5FNGVQT.js.map +1 -0
  8. package/dist/{chunk-K6TAWCGL.js → chunk-GDV76P2H.js} +63 -9
  9. package/dist/chunk-GDV76P2H.js.map +1 -0
  10. package/dist/{chunk-NI7JLDWZ.js → chunk-I4TKJWCD.js} +2 -2
  11. package/dist/chunk-I4TKJWCD.js.map +1 -0
  12. package/dist/{chunk-ALYH6YQK.js → chunk-MTSGXDVI.js} +60 -6
  13. package/dist/chunk-MTSGXDVI.js.map +1 -0
  14. package/dist/{chunk-5EMLVHP3.js → chunk-QZJLWSPO.js} +49 -2
  15. package/dist/chunk-QZJLWSPO.js.map +1 -0
  16. package/dist/{chunk-RWDYRT3H.js → chunk-TJC6AXFM.js} +12 -2
  17. package/dist/chunk-TJC6AXFM.js.map +1 -0
  18. package/dist/clock.d.ts +3 -3
  19. package/dist/clock.js +1 -1
  20. package/dist/drag.js +2 -2
  21. package/dist/{frame-loop-f0V4b464.d.ts → frame-loop-DjAXTSO9.d.ts} +7 -1
  22. package/dist/gestures.d.ts +3 -3
  23. package/dist/gestures.js +6 -2
  24. package/dist/index.d.ts +5 -5
  25. package/dist/index.js +11 -7
  26. package/dist/layout.d.ts +5 -5
  27. package/dist/layout.js +2 -2
  28. package/dist/{motion-sElR1A_c.d.ts → motion--ql49201.d.ts} +44 -10
  29. package/dist/{paged-swipe-CIzjr2DQ.d.ts → paged-swipe-DUfi6V9F.d.ts} +71 -2
  30. package/dist/{port-CmlUctqx.d.ts → port-DOxLK9GR.d.ts} +9 -1
  31. package/dist/{settle-7C9xxbFg.d.ts → settle-BvkDVDhE.d.ts} +39 -9
  32. package/dist/values.d.ts +10 -6
  33. package/dist/values.js +2 -2
  34. package/package.json +1 -1
  35. package/dist/chunk-5EMLVHP3.js.map +0 -1
  36. package/dist/chunk-ALYH6YQK.js.map +0 -1
  37. package/dist/chunk-B53X43GW.js.map +0 -1
  38. package/dist/chunk-G5EJSZ3B.js.map +0 -1
  39. package/dist/chunk-K6TAWCGL.js.map +0 -1
  40. package/dist/chunk-NI7JLDWZ.js.map +0 -1
  41. package/dist/chunk-RWDYRT3H.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,49 @@ within the month), the same scheme as `@n-uf/hypr-tiling`.
5
5
 
6
6
  Unreleased entries live in `changes/` until a release joins them.
7
7
 
8
+ ## 26.12.1
9
+
10
+ - `./clock`, **added: `loop.framesEnded`**, the frames a loop has finished since it was created, counted after the last phase. `resetStats()` leaves it, so two readings tell whether a frame ended between them; the layout motion reads it to tell when a jumped rect was seen. Additive for loops made by `createFrameLoop`; an object that implements `FrameLoop` by hand needs the member.
11
+ - `./layout`, **changed (breaking, behavior): "jump, then target, before a frame" no longer animates.** An item placed by `add` or `jumpTo` that gets a new target (`moveTo`, `retarget`) before a frame of the loop has shown it now goes straight to the target, instead of gliding from a rect that was never on screen: the first frame shows the final place. Glides that started that way stop. Once a frame has ended with the item drawn (batched: written by a batch; `flush()` ends no frame), targets glide from where it is drawn, as before. `jumpTo` and `add` say "be here", and motion checks them; `hold` and `glideFrom` say "it is on screen here", and motion believes them, so a drop right after a pointer move and a FLIP still glide. To animate an entrance, use `glideFrom`.
12
+ - **For tests:** one that changes a layout with no frame after the first draw now sees a jump: run a frame (`clock.frame()`) first. `idle()` right after a jump resolves at once, and a target then is still a jump.
13
+ - **How:** an unbatched jump asks its loop for one frame, through `schedule`, once per burst of jumps. `loop.active`, `loop.stats().queued` and a fake clock's `pendingFrames` show it; it is not a movement, so `onActiveChange` and `idle()` don't. Under reduced motion nothing changes.
14
+ - **The clock's contract**, now on `ClockPort`: a frame is the clock's statement that what was drawn before it ended is now presented. The browser clock keeps it; a timer clock or a host's own scheduler still ends frames, and a rect then counts as seen after one of them. Decision record 0018.
15
+
16
+ ## 26.12.0
17
+
18
+ - A paged swipe's `settling` state now has `releaseVelocity`: how fast the swipe was moving when it ended, in px per ms
19
+ (like `peak` and `commitVelocity`), positive towards `next` like `travel`. A value's velocity is per second, so pass
20
+ `releaseVelocity * 1000`; if you draw the page at `-travel`, pass `-releaseVelocity * 1000`, as in
21
+ `page.set(target, { velocity: -state.releaseVelocity * 1000 })`.
22
+ - It is the travel over the swipe's last `releaseWindow` ms (new, default 50), and a span between the first and last
23
+ sample read that is shorter than 16 ms counts as 16 ms. Samples less than 1 ms apart count once, a sample stamped earlier than the one before it is left out, and at
24
+ most the newest 64 are read. It is 0 when the pointer stood still for `flickRest` before the end; a wheel run ends
25
+ `idle` after its last sample, so with the default timings it ends at 0. It is also 0 when the swipe gives way to
26
+ something else (`block`, `scrolled`, `cancel`).
27
+ - `tracking` and `settling` keep the samples as `samples`. The new `releaseVelocity(samples, endedAt, { lookback, rest })`
28
+ is the same rule for any gesture that ends in a throw (`lookback`: the window, in ms), and the state's field is that
29
+ function on the state's own samples. If you draw the page as some other function of `travel`, map each sample's
30
+ `travel` through it and call `releaseVelocity` on the result: you get the speed of what you draw. Also `RELEASE_RULE` (50 and 100 ms) and the types
31
+ `ReleaseSample` and `ReleaseRule`.
32
+ - The new fields are optional, so states and configs written before them still compile; the reducer always sets
33
+ `samples` and `releaseVelocity`.
34
+ - **Changed (breaking, behavior):** every settle now takes a velocity that is not a finite number as 0. NaN used to make the value NaN, and an infinite
35
+ velocity away from the target made it infinite; an infinite velocity toward the target, which was capped at the
36
+ launch speed, is 0 now too.
37
+ - A settle can be kept between two values: `within: { min, max }` in its config, in `settleValue`'s options and in
38
+ `configure`. It limits how far a set velocity can carry the value: with the value and the target inside `min`…`max`,
39
+ the value never leaves. It doesn't move the value or the target, and a target outside is still reached. It works per
40
+ component, in the value's shape; `-Infinity` or `Infinity` leaves a side open. The range's type is `SettleRange`, and a
41
+ range with `min` above `max`, a NaN side, a `min` of `Infinity` or a `max` of `-Infinity` throws a `RangeError`.
42
+ - A settle never passes its target, but a speed set away from the target (`setVelocity`, or `set(target, { velocity })`)
43
+ makes the value go on, stop and come back. With `within`, that speed is lowered just enough for the value to stop
44
+ before the bound; a value already at the bound starts from rest. A speed toward the target, a new target, reduced
45
+ motion (the value goes to the target at once) and a settle without `within` work as before. Clearing `within` later
46
+ doesn't give back a speed it lowered. `Settle.within` reads the range back.
47
+ - `SettleConfig` takes the value's type as an optional parameter (`SettleConfig<number>`, `SettleConfig<Rect>`). A plain
48
+ `SettleConfig` has no range, so code that creates, configures or drives a settle compiles as it is. A class or a test
49
+ double that implements the `Settle` interface itself gains the `within` member to add.
50
+
8
51
  ## 26.11.64
9
52
 
10
53
  - The landing model: no distance that reaches into a lane is more than a third of that lane's thickness. A new optional
package/dist/browser.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { C as ClockPort, T as TimerSource } from './port-CmlUctqx.js';
1
+ import { C as ClockPort, T as TimerSource } from './port-DOxLK9GR.js';
2
2
  import { R as Rect } from './shapes-EbQlwbCu.js';
3
- import { b as Drawable, a as DrawFrame, L as LayoutItem } from './motion-sElR1A_c.js';
4
- import { M as Machine, h as PagedSwipeState, f as PagedSwipeInput, d as PagedSwipeConfig } from './paged-swipe-CIzjr2DQ.js';
5
- import './frame-loop-f0V4b464.js';
3
+ import { b as Drawable, a as DrawFrame, L as LayoutItem } from './motion--ql49201.js';
4
+ import { M as Machine, h as PagedSwipeState, f as PagedSwipeInput, d as PagedSwipeConfig } from './paged-swipe-DUfi6V9F.js';
5
+ import './frame-loop-DjAXTSO9.js';
6
6
  import './reveal-Dg5fqoWS.js';
7
7
  import './keys-BpcrOp4S.js';
8
8
 
package/dist/browser.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  PAGED_SWIPE_DEFAULTS,
3
3
  createPagedSwipe,
4
4
  wheelDelta
5
- } from "./chunk-K6TAWCGL.js";
5
+ } from "./chunk-GDV76P2H.js";
6
6
  import "./chunk-OOKRBVMB.js";
7
- import "./chunk-RWDYRT3H.js";
7
+ import "./chunk-TJC6AXFM.js";
8
8
 
9
9
  // src/browser/browser-clock.ts
10
10
  function createBrowserClock(options = {}) {
@@ -112,6 +112,7 @@ function createFrameLoop(options) {
112
112
  let frameStart = 0;
113
113
  let disposed = false;
114
114
  let frameError = null;
115
+ let framesEnded = 0;
115
116
  let frameCount = 0;
116
117
  let overBudget = 0;
117
118
  let deferred = 0;
@@ -234,6 +235,7 @@ function createFrameLoop(options) {
234
235
  }
235
236
  restoreCarried();
236
237
  const took = clock.now() - frameStart;
238
+ framesEnded++;
237
239
  frameCount++;
238
240
  lastFrame = took;
239
241
  totalTime += took;
@@ -289,6 +291,9 @@ function createFrameLoop(options) {
289
291
  get phase() {
290
292
  return current < 0 ? null : PHASES[current];
291
293
  },
294
+ get framesEnded() {
295
+ return framesEnded;
296
+ },
292
297
  schedule,
293
298
  repeat(phase, task) {
294
299
  if (disposed) return () => {
@@ -416,4 +421,4 @@ export {
416
421
  createFrameLoop,
417
422
  createFrameCoalescer
418
423
  };
419
- //# sourceMappingURL=chunk-G5EJSZ3B.js.map
424
+ //# sourceMappingURL=chunk-BCFPSDOQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/clock/fake-clock.ts","../src/clock/frame-loop.ts","../src/clock/coalescer.ts"],"sourcesContent":["import type { ClockPort } from \"./port\";\n\n/** Options of {@link createFakeClock}. */\nexport interface FakeClockOptions {\n /** Starting time in ms. Default 0. */\n readonly now?: number;\n /** How far {@link FakeClock.frame} moves time by default. Default 16 (round numbers in tests). */\n readonly frameInterval?: number;\n}\n\n/**\n * A clock that only moves when a test moves it. Timers fire in time order\n * (ties in the order they were set), each with `now()` at its due time.\n * Frame callbacks run on {@link FakeClock.frame}; a callback requested during\n * a frame waits for the next one, as with requestAnimationFrame.\n */\nexport interface FakeClock extends ClockPort {\n /** The default frame step in ms. */\n readonly frameInterval: number;\n /** Frame callbacks waiting for the next frame. */\n readonly pendingFrames: number;\n /** Timers not yet fired. */\n readonly pendingTimers: number;\n /** Move time forward by `ms`, firing the timers that come due on the way. */\n tick(ms: number): void;\n /** Move `now()` forward by `ms` without firing anything: work that takes time. */\n spend(ms: number): void;\n /**\n * Move time forward by `dt` (default {@link FakeClock.frameInterval}), fire due\n * timers, then run the frame callbacks requested before this call. Returns\n * how many callbacks ran.\n */\n frame(dt?: number): number;\n /** Run `count` frames; returns how many callbacks ran in all. */\n frames(count: number, dt?: number): number;\n /**\n * Run frames until none is requested; returns how many frames ran. Throws\n * after `maxFrames` (default 1000): something keeps asking for frames.\n */\n runUntilIdle(options?: { readonly maxFrames?: number; readonly dt?: number }): number;\n}\n\ninterface Timer {\n readonly at: number;\n readonly order: number;\n readonly callback: () => void;\n}\n\n/** A {@link FakeClock} for tests. */\nexport function createFakeClock(options: FakeClockOptions = {}): FakeClock {\n let now = options.now ?? 0;\n const frameInterval = options.frameInterval ?? 16;\n let nextHandle = 1;\n let order = 0;\n let frameCallbacks = new Map<number, () => void>();\n const timers = new Map<number, Timer>();\n\n const checkStep = (ms: number, what: string): void => {\n if (!Number.isFinite(ms) || ms < 0) throw new RangeError(`fake clock: ${what} needs a finite ms >= 0, got ${ms}`);\n };\n\n const fireDue = (until: number): void => {\n for (;;) {\n let dueHandle = -1;\n let due: Timer | null = null;\n for (const [handle, timer] of timers) {\n if (timer.at > until) continue;\n if (due === null || timer.at < due.at || (timer.at === due.at && timer.order < due.order)) {\n due = timer;\n dueHandle = handle;\n }\n }\n if (due === null) return;\n timers.delete(dueHandle);\n if (due.at > now) now = due.at;\n due.callback();\n }\n };\n\n const clock: FakeClock = {\n frameInterval,\n get pendingFrames() {\n return frameCallbacks.size;\n },\n get pendingTimers() {\n return timers.size;\n },\n now: () => now,\n requestFrame(callback) {\n const handle = nextHandle++;\n frameCallbacks.set(handle, callback);\n return handle;\n },\n cancelFrame(handle) {\n frameCallbacks.delete(handle);\n },\n setTimer(callback, ms) {\n const handle = nextHandle++;\n timers.set(handle, { at: now + Math.max(0, ms), order: order++, callback });\n return handle;\n },\n clearTimer(handle) {\n timers.delete(handle);\n },\n tick(ms) {\n checkStep(ms, \"tick\");\n const until = now + ms;\n fireDue(until);\n if (until > now) now = until;\n },\n spend(ms) {\n checkStep(ms, \"spend\");\n now += ms;\n },\n frame(dt = frameInterval) {\n clock.tick(dt);\n const due = frameCallbacks;\n frameCallbacks = new Map();\n for (const callback of due.values()) callback();\n return due.size;\n },\n frames(count, dt) {\n let ran = 0;\n for (let i = 0; i < count; i++) ran += clock.frame(dt);\n return ran;\n },\n runUntilIdle({ maxFrames = 1000, dt } = {}) {\n let frames = 0;\n while (frameCallbacks.size > 0) {\n if (frames >= maxFrames) {\n throw new Error(`fake clock: still requesting frames after ${maxFrames} frames`);\n }\n clock.frame(dt);\n frames++;\n }\n return frames;\n },\n };\n return clock;\n}\n","import type { ClockPort, FrameSource } from \"./port\";\n\n/**\n * The phases of a frame, in the order they run:\n * - `input`: coalesced pointer, wheel and key samples are delivered;\n * - `update`: state changes (a gesture machine's intent, an engine transaction);\n * - `layout`: derived geometry, then motion values step toward their targets;\n * - `write`: the host writes the results out (transforms, canvas, DOM).\n */\nexport type Phase = \"input\" | \"update\" | \"layout\" | \"write\";\n\n/** {@link Phase} in run order. */\nexport const PHASES: readonly Phase[] = [\"input\", \"update\", \"layout\", \"write\"];\n\nconst PHASE_INDEX: Readonly<Record<Phase, number>> = { input: 0, update: 1, layout: 2, write: 3 };\n\n/** What a task sees of the frame it runs in. */\nexport interface FrameInfo {\n /** `clock.now()` when the frame started. */\n readonly time: number;\n /**\n * Ms since the previous frame, clamped to `maxDelta`. The first frame\n * after the loop was idle gets `frameInterval`, not the idle gap.\n */\n readonly delta: number;\n /** Frame counter, from 0. */\n readonly index: number;\n /** The phase running now. */\n readonly phase: Phase;\n /** The loop's frame budget in ms. */\n readonly budget: number;\n /** Ms spent in this frame so far. */\n elapsed(): number;\n /** Ms of budget left in this frame (negative when over). */\n remaining(): number;\n}\n\n/** A one-shot task. */\nexport type FrameTask = (frame: FrameInfo) => void;\n\n/** A task that runs every frame; it stops when it returns `false`. */\nexport type RepeatingTask = (frame: FrameInfo) => boolean | void;\n\n/** Options of {@link FrameLoop.schedule}. */\nexport interface ScheduleOptions {\n /**\n * May wait for a later frame when this frame is over budget. Default\n * `false`: the task runs this frame whatever the cost. Repeating tasks\n * always run.\n */\n readonly deferrable?: boolean;\n}\n\n/** Counters of a frame loop since it was created or last reset. */\nexport interface FrameStats {\n /** Frames run. */\n readonly frames: number;\n /** Frames that took longer than the budget. */\n readonly overBudget: number;\n /** Deferrable tasks moved to a later frame because the budget was spent. */\n readonly deferred: number;\n /** Tasks that threw. */\n readonly errors: number;\n /** Duration of the last frame in ms. */\n readonly lastFrame: number;\n /** Longest frame in ms. */\n readonly longestFrame: number;\n /** Mean frame duration in ms. */\n readonly meanFrame: number;\n /** Duration of each phase in the last frame, in ms. */\n readonly perPhase: Readonly<Record<Phase, number>>;\n /** Repeating tasks currently registered. */\n readonly repeating: number;\n /** One-shot tasks waiting for a frame. */\n readonly queued: number;\n}\n\n/** Options of {@link createFrameLoop}. */\nexport interface FrameLoopOptions {\n /** The clock: frames, time and timers all come from it. */\n readonly clock: ClockPort;\n /** Frame budget in ms. Default 10. */\n readonly budget?: number;\n /** `delta` of the first frame after the loop was idle. Default 1000/60. */\n readonly frameInterval?: number;\n /** Largest `delta` handed to tasks (a long pause doesn't make motion jump). Default 64. */\n readonly maxDelta?: number;\n /**\n * How many times one phase drains tasks that were queued for that same\n * phase while it ran (an effect that triggers another effect). The rest\n * waits for the next frame. Default 8.\n */\n readonly maxRounds?: number;\n /**\n * Called when a task throws; the frame carries on. Without it, the first\n * error of a frame is rethrown once the frame is done (and the next frame\n * is already requested). A repeating task that throws is stopped.\n */\n readonly onError?: (error: unknown, phase: Phase) => void;\n /** Called after a frame that took longer than the budget. */\n readonly onOverBudget?: (stats: FrameStats) => void;\n}\n\n/**\n * One frame loop. It requests a frame only while it has work, runs the\n * phases in order, and goes idle (no frame requested) when nothing is left.\n */\nexport interface FrameLoop {\n /** The clock the loop runs on. */\n readonly clock: ClockPort;\n /** The frame budget in ms. */\n readonly budget: number;\n /** Whether a frame is requested or running. */\n readonly active: boolean;\n /** The phase running now, or `null` outside a frame. */\n readonly phase: Phase | null;\n /**\n * Frames this loop has finished since it was created: a frame counts once\n * all four phases have run. {@link FrameLoop.resetStats} leaves it, so two\n * readings tell whether a frame ended between them.\n */\n readonly framesEnded: number;\n /**\n * Run `task` once in `phase`: in this frame if that phase is still ahead,\n * otherwise in the next one. Scheduling the same function again before it\n * runs does nothing. Returns a cancel function.\n */\n schedule(phase: Phase, task: FrameTask, options?: ScheduleOptions): () => void;\n /** Run `task` in `phase` every frame until it returns `false` or the returned stop is called. */\n repeat(phase: Phase, task: RepeatingTask): () => void;\n /**\n * A scheduler for `effect(fn, { schedule })`: the effect runs in `phase`,\n * at most once per frame. The same function is returned for a phase each time.\n */\n scheduler(phase: Phase): (run: () => void) => void;\n /** A {@link FrameSource} whose frames are this loop's `phase`, for a coalescer. */\n frames(phase: Phase): FrameSource;\n /** Counters since creation or the last {@link FrameLoop.resetStats}. */\n stats(): FrameStats;\n /** Zero the counters. */\n resetStats(): void;\n /** Cancel the requested frame and drop every task. The loop does nothing after this. */\n dispose(): void;\n}\n\ninterface Job {\n readonly task: FrameTask;\n readonly deferrable: boolean;\n cancelled: boolean;\n}\n\ninterface Repeater {\n readonly task: RepeatingTask;\n alive: boolean;\n}\n\n/** Create a frame loop on `options.clock`. */\nexport function createFrameLoop(options: FrameLoopOptions): FrameLoop {\n const clock = options.clock;\n const budget = options.budget ?? 10;\n const frameInterval = options.frameInterval ?? 1000 / 60;\n const maxDelta = options.maxDelta ?? 64;\n const maxRounds = options.maxRounds ?? 8;\n const onError = options.onError;\n const onOverBudget = options.onOverBudget;\n\n const queues: Map<FrameTask, Job>[] = [new Map(), new Map(), new Map(), new Map()];\n const carried: Job[][] = [[], [], [], []];\n const repeaters: Repeater[][] = [[], [], [], []];\n const schedulers: ((run: () => void) => void)[] = [];\n let liveRepeaters = 0;\n let handle: number | null = null;\n let running = false;\n let current = -1;\n let lastTime: number | null = null;\n let index = 0;\n let frameStart = 0;\n let disposed = false;\n let frameError: { error: unknown } | null = null;\n let framesEnded = 0;\n\n let frameCount = 0;\n let overBudget = 0;\n let deferred = 0;\n let errors = 0;\n let lastFrame = 0;\n let longestFrame = 0;\n let totalTime = 0;\n const perPhase = [0, 0, 0, 0];\n\n const queuedCount = (): number => {\n let count = 0;\n for (let p = 0; p < 4; p++) count += queues[p]!.size + carried[p]!.length;\n return count;\n };\n\n const hasWork = (): boolean => liveRepeaters > 0 || queuedCount() > 0;\n\n const request = (): void => {\n if (handle !== null || running || disposed) return;\n handle = clock.requestFrame(runFrame);\n };\n\n /** Drop a requested frame that has nothing left to do. */\n const releaseIfIdle = (): void => {\n if (running || handle === null || hasWork()) return;\n clock.cancelFrame(handle);\n handle = null;\n lastTime = null;\n };\n\n const report = (error: unknown, phase: number): void => {\n errors++;\n if (onError !== undefined) {\n onError(error, PHASES[phase]!);\n } else if (frameError === null) {\n frameError = { error };\n }\n };\n\n const drain = (phase: number, info: FrameInfo): void => {\n const queue = queues[phase]!;\n for (let round = 0; queue.size > 0 && round < maxRounds; round++) {\n const jobs = Array.from(queue.values());\n queue.clear();\n for (let i = 0; i < jobs.length; i++) {\n const job = jobs[i]!;\n if (job.cancelled) continue;\n if (job.deferrable && clock.now() - frameStart >= budget) {\n carried[phase]!.push(job);\n deferred++;\n continue;\n }\n try {\n job.task(info);\n } catch (error) {\n report(error, phase);\n }\n }\n }\n };\n\n const runRepeaters = (phase: number, info: FrameInfo): void => {\n const list = repeaters[phase]!;\n // New repeaters pushed during the pass run in this pass too.\n for (let i = 0; i < list.length; i++) {\n const repeater = list[i]!;\n if (!repeater.alive) continue;\n let keep: boolean | void;\n try {\n keep = repeater.task(info);\n } catch (error) {\n report(error, phase);\n keep = false;\n }\n if (keep === false && repeater.alive) {\n repeater.alive = false;\n liveRepeaters--;\n }\n }\n let kept = 0;\n for (let i = 0; i < list.length; i++) {\n const repeater = list[i]!;\n if (repeater.alive) list[kept++] = repeater;\n }\n list.length = kept;\n };\n\n /** Put deferred jobs back at the front of their queues for the next frame. */\n const restoreCarried = (): void => {\n for (let p = 0; p < 4; p++) {\n const jobs = carried[p]!;\n if (jobs.length === 0) continue;\n const queue = queues[p]!;\n const later = Array.from(queue.values());\n queue.clear();\n for (const job of jobs) if (!job.cancelled) queue.set(job.task, job);\n for (const job of later) if (!queue.has(job.task)) queue.set(job.task, job);\n jobs.length = 0;\n }\n };\n\n function runFrame(): void {\n handle = null;\n if (disposed) return;\n const time = clock.now();\n const delta = lastTime === null ? frameInterval : Math.min(Math.max(time - lastTime, 0), maxDelta);\n lastTime = time;\n frameStart = time;\n const info = {\n time,\n delta,\n index: index++,\n phase: PHASES[0]!,\n budget,\n elapsed: (): number => clock.now() - frameStart,\n remaining: (): number => budget - (clock.now() - frameStart),\n };\n running = true;\n try {\n for (let p = 0; p < 4; p++) {\n current = p;\n info.phase = PHASES[p]!;\n const phaseStart = clock.now();\n drain(p, info);\n runRepeaters(p, info);\n drain(p, info);\n perPhase[p] = clock.now() - phaseStart;\n }\n } finally {\n running = false;\n current = -1;\n }\n restoreCarried();\n const took = clock.now() - frameStart;\n framesEnded++;\n frameCount++;\n lastFrame = took;\n totalTime += took;\n if (took > longestFrame) longestFrame = took;\n if (took > budget) {\n overBudget++;\n if (onOverBudget !== undefined) onOverBudget(stats());\n }\n if (hasWork()) request();\n else lastTime = null;\n if (frameError !== null) {\n const { error } = frameError;\n frameError = null;\n throw error;\n }\n }\n\n const stats = (): FrameStats => ({\n frames: frameCount,\n overBudget,\n deferred,\n errors,\n lastFrame,\n longestFrame,\n meanFrame: frameCount === 0 ? 0 : totalTime / frameCount,\n perPhase: { input: perPhase[0]!, update: perPhase[1]!, layout: perPhase[2]!, write: perPhase[3]! },\n repeating: liveRepeaters,\n queued: queuedCount(),\n });\n\n const schedule = (phase: Phase, task: FrameTask, scheduleOptions?: ScheduleOptions): (() => void) => {\n if (disposed) return () => {};\n const queue = queues[PHASE_INDEX[phase]]!;\n let job = queue.get(task);\n if (job === undefined) {\n job = { task, deferrable: scheduleOptions?.deferrable ?? false, cancelled: false };\n queue.set(task, job);\n request();\n }\n const scheduled = job;\n return () => {\n if (scheduled.cancelled) return;\n scheduled.cancelled = true;\n if (queue.get(task) === scheduled) queue.delete(task);\n releaseIfIdle();\n };\n };\n\n const loop: FrameLoop = {\n clock,\n budget,\n get active() {\n return running || handle !== null;\n },\n get phase() {\n return current < 0 ? null : PHASES[current]!;\n },\n get framesEnded() {\n return framesEnded;\n },\n schedule,\n repeat(phase, task) {\n if (disposed) return () => {};\n const repeater: Repeater = { task, alive: true };\n repeaters[PHASE_INDEX[phase]]!.push(repeater);\n liveRepeaters++;\n request();\n return () => {\n if (!repeater.alive) return;\n repeater.alive = false;\n liveRepeaters--;\n releaseIfIdle();\n };\n },\n scheduler(phase) {\n const p = PHASE_INDEX[phase];\n let made = schedulers[p];\n if (made === undefined) {\n made = (run) => {\n schedule(phase, run);\n };\n schedulers[p] = made;\n }\n return made;\n },\n frames(phase) {\n let next = 1;\n const pending = new Map<number, () => void>();\n return {\n requestFrame(callback) {\n const id = next++;\n const task = (): void => {\n pending.delete(id);\n callback();\n };\n pending.set(id, schedule(phase, task));\n return id;\n },\n cancelFrame(id) {\n const cancel = pending.get(id);\n if (cancel === undefined) return;\n pending.delete(id);\n cancel();\n },\n };\n },\n stats,\n resetStats() {\n frameCount = 0;\n overBudget = 0;\n deferred = 0;\n errors = 0;\n lastFrame = 0;\n longestFrame = 0;\n totalTime = 0;\n perPhase.fill(0);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n if (handle !== null) clock.cancelFrame(handle);\n handle = null;\n for (let p = 0; p < 4; p++) {\n queues[p]!.clear();\n carried[p]!.length = 0;\n for (const repeater of repeaters[p]!) repeater.alive = false;\n repeaters[p]!.length = 0;\n }\n liveRepeaters = 0;\n },\n };\n return loop;\n}\n","import type { FrameSource } from \"./port\";\n\n/** Options of {@link createFrameCoalescer}. */\nexport interface CoalescerOptions<T> {\n /**\n * How a new sample folds into the pending one. Default: keep the latest\n * (pointer positions). Wheel deltas want a sum instead.\n */\n readonly merge?: (pending: T, next: T) => T;\n}\n\n/**\n * Collapses a burst of samples into at most one delivery per frame. Same\n * shape as hypr-tiling's `createFrameCoalescer` (`schedule`, `cancel`),\n * plus `flush` and `pending`.\n */\nexport interface FrameCoalescer<T> {\n /** Record a sample and make sure a frame is requested. */\n schedule(sample: T): void;\n /**\n * Deliver the pending sample now, if there is one (before a pointer-up, so\n * the last move is seen first). Returns whether it delivered.\n */\n flush(): boolean;\n /** Drop the pending sample and the requested frame. Nothing is delivered after this. */\n cancel(): void;\n /** Whether a sample is waiting for its frame. */\n readonly pending: boolean;\n}\n\n/**\n * Deliver samples to `onFrame` once per frame of `frames`: the browser clock,\n * the fake clock, or a frame loop phase (`loop.frames(\"input\")`). `onFrame`\n * also gets how many samples were folded into this one.\n */\nexport function createFrameCoalescer<T>(\n onFrame: (sample: T, count: number) => void,\n frames: FrameSource,\n options: CoalescerOptions<T> = {},\n): FrameCoalescer<T> {\n const merge = options.merge;\n let handle: number | null = null;\n let sample: T | undefined;\n let count = 0;\n\n const deliver = (): void => {\n const delivered = sample as T;\n const folded = count;\n sample = undefined;\n count = 0;\n onFrame(delivered, folded);\n };\n\n const onFrameDue = (): void => {\n handle = null;\n if (count > 0) deliver();\n };\n\n return {\n schedule(next) {\n sample = count > 0 && merge !== undefined ? merge(sample as T, next) : next;\n count++;\n if (handle === null) handle = frames.requestFrame(onFrameDue);\n },\n flush() {\n if (handle !== null) {\n frames.cancelFrame(handle);\n handle = null;\n }\n if (count === 0) return false;\n deliver();\n return true;\n },\n cancel() {\n if (handle !== null) {\n frames.cancelFrame(handle);\n handle = null;\n }\n sample = undefined;\n count = 0;\n },\n get pending() {\n return count > 0;\n },\n };\n}\n"],"mappings":";AAiDO,SAAS,gBAAgB,UAA4B,CAAC,GAAc;AACzE,MAAI,MAAM,QAAQ,OAAO;AACzB,QAAM,gBAAgB,QAAQ,iBAAiB;AAC/C,MAAI,aAAa;AACjB,MAAI,QAAQ;AACZ,MAAI,iBAAiB,oBAAI,IAAwB;AACjD,QAAM,SAAS,oBAAI,IAAmB;AAEtC,QAAM,YAAY,CAAC,IAAY,SAAuB;AACpD,QAAI,CAAC,OAAO,SAAS,EAAE,KAAK,KAAK,EAAG,OAAM,IAAI,WAAW,eAAe,IAAI,gCAAgC,EAAE,EAAE;AAAA,EAClH;AAEA,QAAM,UAAU,CAAC,UAAwB;AACvC,eAAS;AACP,UAAI,YAAY;AAChB,UAAI,MAAoB;AACxB,iBAAW,CAAC,QAAQ,KAAK,KAAK,QAAQ;AACpC,YAAI,MAAM,KAAK,MAAO;AACtB,YAAI,QAAQ,QAAQ,MAAM,KAAK,IAAI,MAAO,MAAM,OAAO,IAAI,MAAM,MAAM,QAAQ,IAAI,OAAQ;AACzF,gBAAM;AACN,sBAAY;AAAA,QACd;AAAA,MACF;AACA,UAAI,QAAQ,KAAM;AAClB,aAAO,OAAO,SAAS;AACvB,UAAI,IAAI,KAAK,IAAK,OAAM,IAAI;AAC5B,UAAI,SAAS;AAAA,IACf;AAAA,EACF;AAEA,QAAM,QAAmB;AAAA,IACvB;AAAA,IACA,IAAI,gBAAgB;AAClB,aAAO,eAAe;AAAA,IACxB;AAAA,IACA,IAAI,gBAAgB;AAClB,aAAO,OAAO;AAAA,IAChB;AAAA,IACA,KAAK,MAAM;AAAA,IACX,aAAa,UAAU;AACrB,YAAM,SAAS;AACf,qBAAe,IAAI,QAAQ,QAAQ;AACnC,aAAO;AAAA,IACT;AAAA,IACA,YAA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AAA,IACjB;AAAA,EACF;AACF;","names":[]}
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  DOUBLE_CLICK,
3
- isHeld
4
- } from "./chunk-RWDYRT3H.js";
3
+ SAME_SAMPLE,
4
+ isHeld,
5
+ sampleOrder
6
+ } from "./chunk-TJC6AXFM.js";
5
7
 
6
8
  // src/drag/intent.ts
7
9
  var DRAG_DEFAULTS = {
@@ -277,7 +279,6 @@ function createDragIntent(options) {
277
279
  var HAND_SLOW_STEP = 3;
278
280
  var HAND_SPEED = { span: 48, steps: 5, gap: 40, slowStep: HAND_SLOW_STEP, still: 20, carry: 0.5, fill: 2.5, accelerating: 1.5, gathering: 1.25 };
279
281
  var FILL_MAX = 32;
280
- var SAME_SAMPLE = 1;
281
282
  function createHandSpeed(options = {}) {
282
283
  const o = { ...HAND_SPEED, ...options };
283
284
  let samples = [];
@@ -325,7 +326,7 @@ function createHandSpeed(options = {}) {
325
326
  return;
326
327
  }
327
328
  const dt = t - last.t;
328
- if (dt < SAME_SAMPLE) {
329
+ if (sampleOrder(last.t, t) !== "next") {
329
330
  if (dt > -Math.max(o.gap, SAME_SAMPLE)) return;
330
331
  if (behind === null || t < behind) behind = t;
331
332
  if (t - behind < Math.max(o.still, SAME_SAMPLE)) return;
@@ -977,4 +978,4 @@ export {
977
978
  MIN_BOX_LENGTH,
978
979
  guideRects
979
980
  };
980
- //# sourceMappingURL=chunk-B53X43GW.js.map
981
+ //# sourceMappingURL=chunk-F5FNGVQT.js.map