@n-uf/motion 26.11.52 → 26.11.54

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 (46) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +22 -29
  3. package/dist/browser.d.ts +79 -3
  4. package/dist/browser.js +49 -3
  5. package/dist/browser.js.map +1 -1
  6. package/dist/chunk-4XGH5367.js +379 -0
  7. package/dist/chunk-4XGH5367.js.map +1 -0
  8. package/dist/{chunk-SIAZRWYD.js → chunk-ALYH6YQK.js} +4 -7
  9. package/dist/chunk-ALYH6YQK.js.map +1 -0
  10. package/dist/{chunk-BVPVUJ42.js → chunk-G5EJSZ3B.js} +77 -30
  11. package/dist/chunk-G5EJSZ3B.js.map +1 -0
  12. package/dist/chunk-IT2FMZOM.js +989 -0
  13. package/dist/chunk-IT2FMZOM.js.map +1 -0
  14. package/dist/{chunk-V7DEXKBZ.js → chunk-NI7JLDWZ.js} +35 -8
  15. package/dist/chunk-NI7JLDWZ.js.map +1 -0
  16. package/dist/{chunk-7EAAKM6U.js → chunk-QMGPJ2FG.js} +37 -89
  17. package/dist/chunk-QMGPJ2FG.js.map +1 -0
  18. package/dist/chunk-RWDYRT3H.js +14 -0
  19. package/dist/chunk-RWDYRT3H.js.map +1 -0
  20. package/dist/clock.d.ts +40 -7
  21. package/dist/clock.js +3 -1
  22. package/dist/double-click-DBfbiP2U.d.ts +39 -0
  23. package/dist/drag.d.ts +170 -192
  24. package/dist/drag.js +24 -892
  25. package/dist/drag.js.map +1 -1
  26. package/dist/{frame-loop-C88dc9xw.d.ts → frame-loop-f0V4b464.d.ts} +11 -11
  27. package/dist/gestures.d.ts +40 -74
  28. package/dist/gestures.js +8 -7
  29. package/dist/index.d.ts +10 -6
  30. package/dist/index.js +60 -10
  31. package/dist/layout.d.ts +9 -233
  32. package/dist/layout.js +7 -427
  33. package/dist/layout.js.map +1 -1
  34. package/dist/motion-sElR1A_c.d.ts +163 -0
  35. package/dist/reveal-Dg5fqoWS.d.ts +51 -0
  36. package/dist/{reveal-C-ewJfFn.d.ts → settle-7C9xxbFg.d.ts} +7 -57
  37. package/dist/values.d.ts +15 -7
  38. package/dist/values.js +2 -2
  39. package/package.json +2 -2
  40. package/dist/chunk-7EAAKM6U.js.map +0 -1
  41. package/dist/chunk-BVPVUJ42.js.map +0 -1
  42. package/dist/chunk-IJSIYH2D.js +0 -7
  43. package/dist/chunk-IJSIYH2D.js.map +0 -1
  44. package/dist/chunk-SIAZRWYD.js.map +0 -1
  45. package/dist/chunk-V7DEXKBZ.js.map +0 -1
  46. package/dist/double-click-jtUSNuHL.d.ts +0 -16
@@ -1,7 +1,7 @@
1
1
  // src/clock/fake-clock.ts
2
2
  function createFakeClock(options = {}) {
3
3
  let now = options.now ?? 0;
4
- const frameMs = options.frameMs ?? 16;
4
+ const frameInterval = options.frameInterval ?? 16;
5
5
  let nextHandle = 1;
6
6
  let order = 0;
7
7
  let frameCallbacks = /* @__PURE__ */ new Map();
@@ -27,7 +27,7 @@ function createFakeClock(options = {}) {
27
27
  }
28
28
  };
29
29
  const clock = {
30
- frameMs,
30
+ frameInterval,
31
31
  get pendingFrames() {
32
32
  return frameCallbacks.size;
33
33
  },
@@ -61,7 +61,7 @@ function createFakeClock(options = {}) {
61
61
  checkStep(ms, "spend");
62
62
  now += ms;
63
63
  },
64
- frame(dt = frameMs) {
64
+ frame(dt = frameInterval) {
65
65
  clock.tick(dt);
66
66
  const due = frameCallbacks;
67
67
  frameCallbacks = /* @__PURE__ */ new Map();
@@ -93,9 +93,9 @@ var PHASES = ["input", "update", "layout", "write"];
93
93
  var PHASE_INDEX = { input: 0, update: 1, layout: 2, write: 3 };
94
94
  function createFrameLoop(options) {
95
95
  const clock = options.clock;
96
- const budgetMs = options.budgetMs ?? 10;
97
- const frameMs = options.frameMs ?? 1e3 / 60;
98
- const maxDeltaMs = options.maxDeltaMs ?? 64;
96
+ const budget = options.budget ?? 10;
97
+ const frameInterval = options.frameInterval ?? 1e3 / 60;
98
+ const maxDelta = options.maxDelta ?? 64;
99
99
  const maxRounds = options.maxRounds ?? 8;
100
100
  const onError = options.onError;
101
101
  const onOverBudget = options.onOverBudget;
@@ -116,10 +116,10 @@ function createFrameLoop(options) {
116
116
  let overBudget = 0;
117
117
  let deferred = 0;
118
118
  let errors = 0;
119
- let lastMs = 0;
120
- let maxMs = 0;
121
- let totalMs = 0;
122
- const phaseMs = [0, 0, 0, 0];
119
+ let lastFrame = 0;
120
+ let longestFrame = 0;
121
+ let totalTime = 0;
122
+ const perPhase = [0, 0, 0, 0];
123
123
  const queuedCount = () => {
124
124
  let count = 0;
125
125
  for (let p = 0; p < 4; p++) count += queues[p].size + carried[p].length;
@@ -152,7 +152,7 @@ function createFrameLoop(options) {
152
152
  for (let i = 0; i < jobs.length; i++) {
153
153
  const job = jobs[i];
154
154
  if (job.cancelled) continue;
155
- if (job.deferrable && clock.now() - frameStart >= budgetMs) {
155
+ if (job.deferrable && clock.now() - frameStart >= budget) {
156
156
  carried[phase].push(job);
157
157
  deferred++;
158
158
  continue;
@@ -205,7 +205,7 @@ function createFrameLoop(options) {
205
205
  handle = null;
206
206
  if (disposed) return;
207
207
  const time = clock.now();
208
- const delta = lastTime === null ? frameMs : Math.min(Math.max(time - lastTime, 0), maxDeltaMs);
208
+ const delta = lastTime === null ? frameInterval : Math.min(Math.max(time - lastTime, 0), maxDelta);
209
209
  lastTime = time;
210
210
  frameStart = time;
211
211
  const info = {
@@ -213,9 +213,9 @@ function createFrameLoop(options) {
213
213
  delta,
214
214
  index: index++,
215
215
  phase: PHASES[0],
216
- budgetMs,
216
+ budget,
217
217
  elapsed: () => clock.now() - frameStart,
218
- remaining: () => budgetMs - (clock.now() - frameStart)
218
+ remaining: () => budget - (clock.now() - frameStart)
219
219
  };
220
220
  running = true;
221
221
  try {
@@ -226,7 +226,7 @@ function createFrameLoop(options) {
226
226
  drain(p, info);
227
227
  runRepeaters(p, info);
228
228
  drain(p, info);
229
- phaseMs[p] = clock.now() - phaseStart;
229
+ perPhase[p] = clock.now() - phaseStart;
230
230
  }
231
231
  } finally {
232
232
  running = false;
@@ -235,10 +235,10 @@ function createFrameLoop(options) {
235
235
  restoreCarried();
236
236
  const took = clock.now() - frameStart;
237
237
  frameCount++;
238
- lastMs = took;
239
- totalMs += took;
240
- if (took > maxMs) maxMs = took;
241
- if (took > budgetMs) {
238
+ lastFrame = took;
239
+ totalTime += took;
240
+ if (took > longestFrame) longestFrame = took;
241
+ if (took > budget) {
242
242
  overBudget++;
243
243
  if (onOverBudget !== void 0) onOverBudget(stats());
244
244
  }
@@ -255,10 +255,10 @@ function createFrameLoop(options) {
255
255
  overBudget,
256
256
  deferred,
257
257
  errors,
258
- lastMs,
259
- maxMs,
260
- meanMs: frameCount === 0 ? 0 : totalMs / frameCount,
261
- phaseMs: { input: phaseMs[0], update: phaseMs[1], layout: phaseMs[2], write: phaseMs[3] },
258
+ lastFrame,
259
+ longestFrame,
260
+ meanFrame: frameCount === 0 ? 0 : totalTime / frameCount,
261
+ perPhase: { input: perPhase[0], update: perPhase[1], layout: perPhase[2], write: perPhase[3] },
262
262
  repeating: liveRepeaters,
263
263
  queued: queuedCount()
264
264
  });
@@ -282,7 +282,7 @@ function createFrameLoop(options) {
282
282
  };
283
283
  const loop = {
284
284
  clock,
285
- budgetMs,
285
+ budget,
286
286
  get active() {
287
287
  return running || handle !== null;
288
288
  },
@@ -342,10 +342,10 @@ function createFrameLoop(options) {
342
342
  overBudget = 0;
343
343
  deferred = 0;
344
344
  errors = 0;
345
- lastMs = 0;
346
- maxMs = 0;
347
- totalMs = 0;
348
- phaseMs.fill(0);
345
+ lastFrame = 0;
346
+ longestFrame = 0;
347
+ totalTime = 0;
348
+ perPhase.fill(0);
349
349
  },
350
350
  dispose() {
351
351
  if (disposed) return;
@@ -364,9 +364,56 @@ function createFrameLoop(options) {
364
364
  return loop;
365
365
  }
366
366
 
367
+ // src/clock/coalescer.ts
368
+ function createFrameCoalescer(onFrame, frames, options = {}) {
369
+ const merge = options.merge;
370
+ let handle = null;
371
+ let sample;
372
+ let count = 0;
373
+ const deliver = () => {
374
+ const delivered = sample;
375
+ const folded = count;
376
+ sample = void 0;
377
+ count = 0;
378
+ onFrame(delivered, folded);
379
+ };
380
+ const onFrameDue = () => {
381
+ handle = null;
382
+ if (count > 0) deliver();
383
+ };
384
+ return {
385
+ schedule(next) {
386
+ sample = count > 0 && merge !== void 0 ? merge(sample, next) : next;
387
+ count++;
388
+ if (handle === null) handle = frames.requestFrame(onFrameDue);
389
+ },
390
+ flush() {
391
+ if (handle !== null) {
392
+ frames.cancelFrame(handle);
393
+ handle = null;
394
+ }
395
+ if (count === 0) return false;
396
+ deliver();
397
+ return true;
398
+ },
399
+ cancel() {
400
+ if (handle !== null) {
401
+ frames.cancelFrame(handle);
402
+ handle = null;
403
+ }
404
+ sample = void 0;
405
+ count = 0;
406
+ },
407
+ get pending() {
408
+ return count > 0;
409
+ }
410
+ };
411
+ }
412
+
367
413
  export {
368
414
  createFakeClock,
369
415
  PHASES,
370
- createFrameLoop
416
+ createFrameLoop,
417
+ createFrameCoalescer
371
418
  };
372
- //# sourceMappingURL=chunk-BVPVUJ42.js.map
419
+ //# sourceMappingURL=chunk-G5EJSZ3B.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 * 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\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 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 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;AACj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