@n-uf/motion 26.11.2 → 26.11.4
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 +72 -3
- package/README.md +137 -4
- package/dist/{chunk-NFQ4LIIR.js → chunk-C4M62FUT.js} +1 -1
- package/dist/chunk-C4M62FUT.js.map +1 -0
- package/dist/{chunk-LCTGXGOI.js → chunk-CM6WVNDH.js} +13 -61
- package/dist/chunk-CM6WVNDH.js.map +1 -0
- package/dist/chunk-WQQ2E25M.js +212 -0
- package/dist/chunk-WQQ2E25M.js.map +1 -0
- package/dist/drag.d.ts +202 -0
- package/dist/drag.js +151 -0
- package/dist/drag.js.map +1 -0
- package/dist/gestures.d.ts +1 -1
- package/dist/gestures.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -3
- package/dist/layout.d.ts +258 -0
- package/dist/layout.js +312 -0
- package/dist/layout.js.map +1 -0
- package/dist/reveal-my7U6UyE.d.ts +51 -0
- package/dist/testing.d.ts +87 -0
- package/dist/testing.js +93 -0
- package/dist/testing.js.map +1 -0
- package/dist/values.d.ts +80 -4
- package/dist/values.js +15 -1
- package/package.json +13 -1
- package/dist/chunk-LCTGXGOI.js.map +0 -1
- package/dist/chunk-NFQ4LIIR.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/layout/motion.ts","../src/layout/held.ts","../src/layout/flip.ts","../src/layout/dom.ts"],"sourcesContent":["import type { FrameInfo, FrameLoop, Phase } from \"../clock/frame-loop\";\nimport type { Rect } from \"../shapes\";\nimport { popIn, reveal, type PopIn, type RevealFrame } from \"../values/reveal\";\nimport { createSettle, SETTLE_TEMPO, type Settle } from \"../values/settle\";\n\n/**\n * What a {@link Drawable} draws on a frame: where the item is drawn, the box its content is laid out in, how to draw\n * the one at the other without stretching ({@link reveal}), and its appearance ({@link popIn}).\n */\nexport interface DrawFrame {\n /** Where the item is drawn this frame (its frame: background, border, shadow). */\n readonly drawn: Rect;\n /** The box its content is laid out in: where it is heading, or (held) where it was laid out last. */\n readonly box: Rect;\n /** How to draw `box`'s content at `drawn`: a move, the frame at the drawn size, the content clipped. */\n readonly reveal: RevealFrame;\n /** Its uniform appearance: scale about its centre and opacity. */\n readonly pop: PopIn;\n /** How shown it is, 0 (gone) to 1. */\n readonly shown: number;\n /** All the way gone: hidden and at rest (out of sight and out of the way of the pointer). */\n readonly gone: boolean;\n}\n\n/**\n * How an item reaches the screen. The layout motion never measures or touches anything itself: it lays an item's\n * content out once per new box and draws it once per frame through this. {@link domDrawable} writes an element's\n * style; a canvas or a test can draw anything else.\n */\nexport interface Drawable {\n /** Lay the content out in `box` (its position and size): called once per new box, never per frame. */\n layOut(box: Rect): void;\n /** Draw the item for this frame. */\n draw(frame: DrawFrame): void;\n}\n\n/**\n * One item the layout motion moves: give it a new place and it settles there from wherever it is drawn.\n *\n * - {@link LayoutItem.moveTo}: a settle to the new place, retargeted from the drawn rect (no jump, no overshoot);\n * the content is laid out at the new box at once and the item redrawn at once, so no frame shows the old offset\n * from the new box.\n * - A size change is revealed: the content is laid out at the target size and the frame clipped, never scaled.\n * - {@link LayoutItem.show}: appear or disappear with a uniform-scale fade.\n */\nexport interface LayoutItem {\n readonly id: string;\n /** Where it is drawn now. */\n readonly drawn: Rect;\n /** Where it is heading (its settle's target). */\n readonly target: Rect;\n /** The box its content is laid out in. */\n readonly box: Rect;\n /** At rest on its target. */\n readonly settled: boolean;\n /** How shown it is, 0 to 1, and whether it is heading for shown. */\n readonly shown: number;\n readonly showing: boolean;\n /** Its appearance is at rest (fully shown, or gone). */\n readonly shownSettled: boolean;\n /** Settle to `to` from where it is drawn; lays the content out at `to` and redraws at once. */\n moveTo(to: Rect): void;\n /** Be at `to` now, at rest: no glide. */\n jumpTo(to: Rect): void;\n /** Drawn at `from` now, then settle to `to` (a FLIP's invert and play: `from` in the item's own coordinates). */\n glideFrom(from: Rect, to: Rect): void;\n /** Exactly at `r`, at rest (what a pointer holds); the content stays laid out in its box, moved with it. */\n hold(r: Rect): void;\n /** Appear (true) or disappear (false) with a uniform-scale fade; `now`: without the fade. */\n show(on: boolean, options?: { readonly now?: boolean }): void;\n /** Draw it again now (after its drawable's element was laid out anew from outside). */\n redraw(): void;\n}\n\n/** A task the layout motion runs on every frame before it steps the items; true keeps the frames coming. */\nexport type LayoutTask = (frame: FrameInfo) => boolean | void;\n\nexport interface LayoutMotionOptions {\n /** The frame loop every item steps on (one loop for all of them). */\n readonly loop: FrameLoop;\n /** The settle tempo, per second ({@link SETTLE_TEMPO}); default `SETTLE_TEMPO.default`. */\n readonly omega?: number;\n /** The frame phase the items step and draw in; default `\"layout\"`. */\n readonly phase?: Phase;\n /** Where an appearing item grows from, as a share of its size ({@link popIn}'s `from`); default 0.87. */\n readonly popFrom?: number;\n}\n\n/**\n * Layout motion: items with an id and a target rect, each settled to its place on one shared frame loop.\n *\n * Give an item a new place ({@link LayoutItem.moveTo}) and it glides there from wherever it is drawn: the window\n * motion rules of `values/` (settle, reveal, popIn) applied to every item at once. The loop runs only while\n * something moves, or a task asks for frames, and stops by itself.\n *\n * It only animates the rects it is given: which items move where, and when, is the caller's layout.\n */\nexport interface LayoutMotion {\n /** Add an item drawn by `drawable`, at `at`, shown (or gone: `{ shown: false }`). Its content is laid out at once. */\n add(id: string, drawable: Drawable, at: Rect, options?: { readonly shown?: boolean }): LayoutItem;\n get(id: string): LayoutItem | undefined;\n /** Stop moving an item (its drawable is not touched again). */\n remove(id: string): void;\n readonly items: ReadonlyMap<string, LayoutItem>;\n /** Run `task` on every frame, before the items step; returns how to stop it. */\n task(task: LayoutTask): () => void;\n /** Call `listener` on every frame, after the items have stepped and been drawn; returns how to stop it. */\n onFrame(listener: (frame: FrameInfo) => void): () => void;\n /** Call `listener` each time the frames stop (nothing moves); returns how to stop it. */\n onIdle(listener: () => void): () => void;\n /** Make sure at least one more frame runs (a task has something to do). */\n wake(): void;\n /** Frames are running. */\n readonly running: boolean;\n /** Set the tempo for every item (and the ones added later). */\n configure(config: { readonly omega?: number }): void;\n /** Resolves once nothing moves (at once if nothing does). */\n idle(): Promise<void>;\n /** Stop the frames and forget every item. */\n dispose(): void;\n}\n\n/** Two rects the same within a hundredth of a pixel. */\nconst same = (a: Rect, b: Rect): boolean =>\n Math.abs(a.x - b.x) < 0.01 && Math.abs(a.y - b.y) < 0.01 && Math.abs(a.width - b.width) < 0.01 && Math.abs(a.height - b.height) < 0.01;\nconst copy = (r: Rect): Rect => ({ x: r.x, y: r.y, width: r.width, height: r.height });\n\n/** Create the {@link LayoutMotion} for one surface. */\nexport function createLayoutMotion(options: LayoutMotionOptions): LayoutMotion {\n const { loop } = options;\n const phase = options.phase ?? \"layout\";\n const popFrom = options.popFrom ?? 0.87;\n let omega = options.omega ?? SETTLE_TEMPO.default;\n const items = new Map<string, LayoutItem>();\n const steps = new Map<string, (dt: number) => boolean>();\n const tasks = new Set<LayoutTask>();\n const frames = new Set<(frame: FrameInfo) => void>();\n const idles = new Set<() => void>();\n const tempos = new Set<() => void>();\n /** What removing an item undoes besides its entry (its tempo hook). */\n const removers = new Map<string, () => void>();\n let waiters: (() => void)[] = [];\n let stop: (() => void) | null = null;\n let woken = false;\n\n const wake = (): void => {\n woken = true;\n if (stop) return;\n stop = loop.repeat(phase, tick);\n };\n\n function tick(frame: FrameInfo): boolean {\n let moving = woken;\n woken = false;\n for (const task of [...tasks]) if (task(frame)) moving = true;\n for (const step of [...steps.values()]) if (step(frame.delta)) moving = true;\n for (const listener of [...frames]) listener(frame);\n if (moving || woken) return true;\n stop = null;\n const resolve = waiters;\n waiters = [];\n for (const r of resolve) r();\n for (const listener of [...idles]) listener();\n return false;\n }\n\n function add(id: string, drawable: Drawable, at: Rect, opts: { readonly shown?: boolean } = {}): LayoutItem {\n if (items.has(id)) throw new Error(`layout motion: item \"${id}\" is already added (remove it first)`);\n const rect: Settle<Rect> = createSettle<Rect>(copy(at), { omega });\n // A number from 0 to 1: rest within a thousandth, not the default tenth (tuned for pixels).\n const pop: Settle<number> = createSettle(opts.shown === false ? 0 : 1, { omega, restDelta: 0.001 });\n let box = copy(at);\n const frameOf = (): DrawFrame => {\n const drawn = rect.value;\n return { drawn, box, reveal: reveal(drawn, box), pop: popIn(pop.value, popFrom), shown: pop.value, gone: pop.settled && pop.value === 0 };\n };\n const draw = (): void => drawable.draw(frameOf());\n const layOut = (to: Rect): void => {\n box = copy(to);\n drawable.layOut(box);\n };\n const tempo = (): void => {\n rect.configure({ omega });\n pop.configure({ omega });\n };\n const item: LayoutItem = {\n id,\n get drawn() {\n return rect.value;\n },\n get target() {\n return rect.target;\n },\n get box() {\n return box;\n },\n get settled() {\n return rect.settled;\n },\n get shown() {\n return pop.value;\n },\n get showing() {\n return pop.target === 1;\n },\n get shownSettled() {\n return pop.settled;\n },\n moveTo(to) {\n if (same(box, to) && same(rect.target, to)) return;\n layOut(to);\n // Laid out in the new box now: draw it at once at the drawn rect, else until the next frame it would show\n // the old offset from the new box (a dropped item would flash a frame away from where it was let go).\n draw();\n if (same(rect.target, to)) return;\n rect.setTarget(copy(to));\n wake();\n },\n jumpTo(to) {\n layOut(to);\n rect.jumpTo(copy(to));\n draw();\n },\n glideFrom(from, to) {\n rect.jumpTo(copy(from));\n layOut(to);\n draw();\n rect.setTarget(copy(to));\n wake();\n },\n hold(r) {\n rect.hold(copy(r));\n draw();\n },\n show(on, o = {}) {\n const want = on ? 1 : 0;\n if (o.now) pop.jumpTo(want);\n else if (pop.target !== want) {\n pop.setTarget(want);\n wake();\n }\n draw();\n },\n redraw: draw,\n };\n drawable.layOut(box);\n draw();\n items.set(id, item);\n tempos.add(tempo);\n steps.set(id, (dt) => {\n const a = rect.step(dt);\n const b = pop.step(dt);\n draw();\n return a || b;\n });\n removers.set(id, () => tempos.delete(tempo));\n return item;\n }\n\n return {\n add,\n get: (id) => items.get(id),\n remove(id) {\n items.delete(id);\n steps.delete(id);\n removers.get(id)?.();\n removers.delete(id);\n },\n items,\n task(task) {\n tasks.add(task);\n wake();\n return () => tasks.delete(task);\n },\n onFrame(listener) {\n frames.add(listener);\n return () => frames.delete(listener);\n },\n onIdle(listener) {\n idles.add(listener);\n return () => idles.delete(listener);\n },\n wake,\n get running() {\n return stop !== null;\n },\n configure(config) {\n if (config.omega !== undefined) omega = config.omega;\n for (const t of tempos) t();\n },\n idle: () => (stop ? new Promise<void>((r) => waiters.push(r)) : Promise.resolve()),\n dispose() {\n stop?.();\n stop = null;\n items.clear();\n steps.clear();\n tasks.clear();\n frames.clear();\n idles.clear();\n tempos.clear();\n removers.clear();\n const resolve = waiters;\n waiters = [];\n for (const r of resolve) r();\n },\n };\n}\n","import type { Point, Rect } from \"../shapes\";\nimport type { LayoutItem } from \"./motion\";\n\n/**\n * An item held by a pointer: the real item (no copy) follows the pointer 1:1 from where it was grabbed, at the size\n * it was lifted at; its place stays reserved (that is the caller's layout). Then:\n *\n * - {@link HeldDrag.snapTo}: glide into a slot (a snap preview); `null` leaves the slot and glides back to the\n * pointer, following it as it moves ({@link HeldDrag.follow} once a frame), until it is under it again.\n * - {@link HeldDrag.land}: let go into a slot: the landing settles from where it was let go (the release rect), never\n * from its old home. Snapped into that slot already, it simply finishes that glide.\n * - {@link HeldDrag.cancel}: let go with no drop: it glides home from where it was let go.\n * - {@link HeldDrag.preview}: the three drop previews, per frame: indicator and gap keep the item under the pointer\n * (gap with the caller's room open), snap glides it into the slot; leaving glides it back to the pointer.\n * - {@link HeldDrag.resize}: the item takes a new size mid-drag (its content laid out anew by the caller): it settles\n * to it from where it is drawn, the size revealed (never stretched), and is held 1:1 again once there.\n */\nexport interface HeldDrag {\n /** Where the pointer is (null before the first move). */\n readonly pointer: Point | null;\n /** Where the pointer holds the item: the pointer less the grab offset, at the held size (lifted, or resized). */\n readonly held: Rect | null;\n /** The slot it sits in (a snap), or null. */\n readonly snapped: Rect | null;\n /** It left a slot (or took a new size) and is gliding back to the pointer. */\n readonly returning: boolean;\n /** The pointer moved: held 1:1 (unless it sits in a slot or is on its way back). */\n move(pointer: Point): void;\n /**\n * Into `slot` (a glide from where it is drawn; the same slot again does nothing), or out of the slot it sits in\n * (`null`: back to the pointer). Returns what changed: `\"snapped\"`, `\"left\"`, or null.\n */\n snapTo(slot: Rect | null): \"snapped\" | \"left\" | null;\n /** Once a frame: on its way back, retarget to the pointer; true on the frame it is under the pointer again. */\n follow(): boolean;\n /**\n * Once a frame, a drop preview's part for the item (`plan`: `@n-uf/motion/drag`'s `previewPlan`, or any\n * `{ snapItem }`): with `snapItem` it glides into `slot` (snap); else it stays under the pointer, or glides back to\n * it from a slot it left (indicator, gap). The room, if the plan makes any, is the caller's layout. In place of\n * {@link HeldDrag.snapTo} and {@link HeldDrag.follow}; returns what changed.\n */\n preview(plan: { readonly snapItem: boolean }, slot: Rect | null): \"snapped\" | \"left\" | null;\n /**\n * Hold it at `size` from now on (the caller has laid its content out for that size). The grab point keeps its share\n * of the item, so the pointer stays on the same spot of it; the item settles from where it is drawn to its new held\n * rect (its size revealed, never stretched), then is held 1:1 again ({@link HeldDrag.follow} once a frame). In a\n * slot it stays there, taking the new size when it leaves. The same size again does nothing; returns true on a\n * change.\n */\n resize(size: { readonly width: number; readonly height: number }): boolean;\n /** Let go into `slot`: returns the release rect, where the landing starts. */\n land(slot: Rect): Rect;\n /** Let go with no drop: glides `home` from the release rect, which it returns. */\n cancel(home: Rect): Rect;\n}\n\n/** How close (px, every component) the way back has to come to count as under the pointer again. */\nconst CAUGHT = 0.5;\n\n/** Hold `item` from the pointer at `grab` (the pointer's offset from its top-left corner), at its drawn size now. */\nexport function holdItem(item: LayoutItem, grab: Point): HeldDrag {\n let size = { width: item.drawn.width, height: item.drawn.height };\n let at = { x: grab.x, y: grab.y };\n let pointer: Point | null = null;\n let snapped: Rect | null = null;\n let returning = false;\n const heldRect = (): Rect | null => (pointer ? { x: pointer.x - at.x, y: pointer.y - at.y, width: size.width, height: size.height } : null);\n const same = (a: Rect, b: Rect): boolean => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.01;\n const snapTo = (slot: Rect | null): \"snapped\" | \"left\" | null => {\n if (slot) {\n if (snapped && same(snapped, slot)) return null;\n snapped = { ...slot };\n returning = false;\n item.moveTo(slot);\n return \"snapped\";\n }\n if (!snapped) return null;\n snapped = null;\n returning = true;\n return \"left\";\n };\n const follow = (): boolean => {\n const goal = heldRect();\n if (!returning || !goal) return false;\n item.moveTo(goal);\n const d = item.drawn;\n if (Math.max(Math.abs(d.x - goal.x), Math.abs(d.y - goal.y), Math.abs(d.width - goal.width), Math.abs(d.height - goal.height)) >= CAUGHT) return false;\n returning = false;\n item.hold(goal);\n return true;\n };\n const letGo = (to: Rect): Rect => {\n const release = { ...item.drawn };\n snapped = null;\n returning = false;\n item.moveTo(to);\n return release;\n };\n return {\n get pointer() {\n return pointer;\n },\n get held() {\n return heldRect();\n },\n get snapped() {\n return snapped;\n },\n get returning() {\n return returning;\n },\n move(p) {\n pointer = { x: p.x, y: p.y };\n if (snapped || returning) return;\n item.hold(heldRect()!);\n },\n snapTo,\n follow,\n preview(plan, slot) {\n const change = snapTo(plan.snapItem && slot ? slot : null);\n follow();\n return change;\n },\n resize(next) {\n if (Math.abs(next.width - size.width) < 0.01 && Math.abs(next.height - size.height) < 0.01) return false;\n at = { x: size.width ? (at.x / size.width) * next.width : 0, y: size.height ? (at.y / size.height) * next.height : 0 };\n size = { width: next.width, height: next.height };\n if (!snapped && pointer) {\n returning = true;\n follow();\n }\n return true;\n },\n land: letGo,\n cancel: letGo,\n };\n}\n","import type { Rect } from \"../shapes\";\nimport type { LayoutItem } from \"./motion\";\n\n/** A rect as a DOM rect reports it (`getBoundingClientRect()`): left, top, width, height. */\nexport interface RectLike {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Anything that can say where it is drawn: a DOM node, or a test's stand-in. */\nexport interface Measurable {\n getBoundingClientRect(): RectLike;\n}\n\n/** A {@link RectLike} as a {@link Rect}. */\nexport const rectOf = (r: RectLike): Rect => ({ x: r.left, y: r.top, width: r.width, height: r.height });\n\n/** One member of a {@link flip}: an item, the node it draws, and where it goes once the DOM has changed. */\nexport interface FlipEntry {\n readonly item: LayoutItem;\n readonly node: Measurable;\n /**\n * Once the DOM has changed: the old rect (as measured before, in page coordinates) in the item's own coordinates\n * now, and its new place there.\n */\n readonly place: (before: Rect) => { readonly from: Rect; readonly to: Rect };\n}\n\n/**\n * FLIP for DOM groups, on settle: record where each node is drawn (first), change the DOM (`change`: move nodes to\n * other parents, reorder them), then each item is drawn at its old rect and settles to its new place (last, invert,\n * play). No transform tween: a settle from the rect it was drawn at, so it never jumps or overshoots, and its size\n * changes through reveal.\n */\nexport function flip(entries: readonly FlipEntry[], change: () => void): void {\n const before = entries.map((e) => rectOf(e.node.getBoundingClientRect()));\n change();\n entries.forEach((e, i) => {\n const { from, to } = e.place(before[i]!);\n e.item.glideFrom(from, to);\n });\n}\n","import type { Rect } from \"../shapes\";\nimport type { Drawable, DrawFrame } from \"./motion\";\n\n/**\n * The style properties the layout motion writes, as strings (a DOM node's `style` has them all). Structural: the\n * library needs no DOM types.\n */\nexport interface StyleLike {\n left: string;\n top: string;\n width: string;\n height: string;\n transform: string;\n opacity: string;\n clipPath: string;\n visibility: string;\n}\n\n/** Something with a writable {@link StyleLike} `style`: a DOM node. */\nexport interface Styled {\n readonly style: StyleLike;\n}\n\n/**\n * The nodes of a drawn box: `node` is laid out at the box and moved to the drawn rect; `frame` (background, border,\n * shadow) is drawn at the drawn size; `content` is clipped to it. With no `frame` and `content`, `node` itself is\n * clipped (its content laid out at the box, never stretched).\n */\nexport interface BoxNodes {\n readonly node: Styled;\n readonly frame?: Styled;\n readonly content?: Styled;\n}\n\n/** Lay `node` out at `box`: its position and size, in its offset parent's coordinates. */\nexport function layOutBox(node: Styled, box: Rect): void {\n const s = node.style;\n s.left = `${box.x}px`;\n s.top = `${box.y}px`;\n s.width = `${box.width}px`;\n s.height = `${box.height}px`;\n}\n\n/**\n * Draw one frame of a box laid out by {@link layOutBox}: one transform (the move to the drawn rect, and the uniform\n * appearance about its centre), the frame at the drawn size, the content clipped (reveal); hidden when gone.\n */\nexport function drawBox(nodes: BoxNodes, frame: DrawFrame): void {\n const { reveal: r, pop } = frame;\n const cx = frame.drawn.width / 2;\n const cy = frame.drawn.height / 2;\n const s = nodes.node.style;\n s.transform =\n pop.scale === 1 ? `translate(${r.dx}px, ${r.dy}px)` : `translate(${r.dx}px, ${r.dy}px) translate(${cx}px, ${cy}px) scale(${pop.scale}) translate(${-cx}px, ${-cy}px)`;\n s.opacity = pop.opacity === 1 ? \"\" : String(pop.opacity);\n if (nodes.frame) {\n nodes.frame.style.width = `${r.width}px`;\n nodes.frame.style.height = `${r.height}px`;\n }\n const clipped = nodes.content ?? (nodes.frame ? null : nodes.node);\n if (clipped) clipped.style.clipPath = r.clipRight || r.clipBottom ? `inset(0 ${r.clipRight}px ${r.clipBottom}px 0)` : \"\";\n // All the way gone: out of sight and out of the way of the pointer.\n s.visibility = frame.gone ? \"hidden\" : \"\";\n}\n\n/** A {@link Drawable} for DOM nodes: {@link layOutBox} on a new box, {@link drawBox} on every frame. */\nexport function domDrawable(nodes: BoxNodes): Drawable {\n return {\n layOut: (box) => layOutBox(nodes.node, box),\n draw: (frame) => drawBox(nodes, frame),\n };\n}\n"],"mappings":";;;;;;;;AA2HA,IAAM,OAAO,CAAC,GAAS,MACrB,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,QAAQ,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI;AACpI,IAAM,OAAO,CAAC,OAAmB,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,OAAO,EAAE,OAAO,QAAQ,EAAE,OAAO;AAG7E,SAAS,mBAAmB,SAA4C;AAC7E,QAAM,EA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AI;AAC3B,QAAM,KAAK,MAAM,MAAM,QAAQ;AAC/B,QAAM,KAAK,MAAM,MAAM,SAAS;AAChC,QAAM,IAAI,MAAM,KAAK;AACrB,IAAE,YACA,IAAI,UAAU,IAAI,aAAa,EAAE,EAAE,OAAO,EAAE,EAAE,QAAQ,aAAa,EAAE,EAAE,OAAO,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,IAAI,KAAK,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE;AAClK,IAAE,UAAU,IAAI,YAAY,IAAI,KAAK,OAAO,IAAI,OAAO;AACvD,MAAI,MAAM,OAAO;AACf,UAAM,MAAM,MAAM,QAAQ,GAAG,EAAE,KAAK;AACpC,UAAM,MAAM,MAAM,SAAS,GAAG,EAAE,MAAM;AAAA,EACxC;AACA,QAAM,UAAU,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM;AAC7D,MAAI,QAAS,SAAQ,MAAM,WAAW,EAAE,aAAa,EAAE,aAAa,WAAW,EAAE,SAAS,MAAM,EAAE,UAAU,UAAU;AAEtH,IAAE,aAAa,MAAM,OAAO,WAAW;AACzC;AAGO,SAAS,YAAY,OAA2B;AACrD,SAAO;AAAA,IACL,QAAQ,CAAC,QAAQ,UAAU,MAAM,MAAM,GAAG;AAAA,IAC1C,MAAM,CAAC,UAAU,QAAQ,OAAO,KAAK;AAAA,EACvC;AACF;","names":["same"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { R as Rect } from './shapes-EbQlwbCu.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How to draw a window whose rect is gliding without stretching its content.
|
|
5
|
+
*
|
|
6
|
+
* The content is laid out once at the target size and never scaled. The
|
|
7
|
+
* window's element sits at its target in the layout; to draw it at the
|
|
8
|
+
* gliding rect:
|
|
9
|
+
*
|
|
10
|
+
* - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;
|
|
11
|
+
* - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;
|
|
12
|
+
* - clip the content by `clipRight` and `clipBottom` so it fits a frame
|
|
13
|
+
* smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).
|
|
14
|
+
*
|
|
15
|
+
* A window that shrinks shows a band of its own background closing in at the
|
|
16
|
+
* right and bottom; one that grows reveals content already laid out at its
|
|
17
|
+
* new size. Text is never stretched. One transform and one clip per frame, no
|
|
18
|
+
* layout per frame.
|
|
19
|
+
*/
|
|
20
|
+
interface RevealFrame {
|
|
21
|
+
/** Move the element (laid out at the target) right by this much. */
|
|
22
|
+
readonly dx: number;
|
|
23
|
+
/** Move the element (laid out at the target) down by this much. */
|
|
24
|
+
readonly dy: number;
|
|
25
|
+
/** The frame's width: the drawn rect's. */
|
|
26
|
+
readonly width: number;
|
|
27
|
+
/** The frame's height: the drawn rect's. */
|
|
28
|
+
readonly height: number;
|
|
29
|
+
/** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */
|
|
30
|
+
readonly clipRight: number;
|
|
31
|
+
/** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */
|
|
32
|
+
readonly clipBottom: number;
|
|
33
|
+
}
|
|
34
|
+
/** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */
|
|
35
|
+
declare function reveal(drawn: Rect, target: Rect): RevealFrame;
|
|
36
|
+
/** A uniform pop-in (or pop-out, run backwards): scale about the centre and opacity. */
|
|
37
|
+
interface PopIn {
|
|
38
|
+
/** Scale about the window's centre: the same on both axes, so nothing is stretched. */
|
|
39
|
+
readonly scale: number;
|
|
40
|
+
readonly opacity: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Opening and closing: the window grows from `from` of its size to full, about
|
|
44
|
+
* its centre, while fading in. `progress` runs 0 to 1 (take it from a settle
|
|
45
|
+
* on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for
|
|
46
|
+
* pixels and would snap the last 10 %; or from a tween); closing runs it from
|
|
47
|
+
* 1 to 0. Hyprland's default is `popin 87%`.
|
|
48
|
+
*/
|
|
49
|
+
declare function popIn(progress: number, from?: number): PopIn;
|
|
50
|
+
|
|
51
|
+
export { type PopIn as P, type RevealFrame as R, popIn as p, reveal as r };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { R as Rect } from './shapes-EbQlwbCu.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Frame-sampled checks of the motion rules: record what was drawn on each
|
|
5
|
+
* frame (in a unit test on the fake clock, or in a browser spec reading the
|
|
6
|
+
* page each animation frame) and ask whether the motion kept the rules.
|
|
7
|
+
*
|
|
8
|
+
* Every check returns `{ ok, failures }`; a failure names the frame (its time)
|
|
9
|
+
* and the component, so a spec can print it. Pixel tolerances default to half
|
|
10
|
+
* a pixel.
|
|
11
|
+
*/
|
|
12
|
+
/** One drawn frame: the time in ms and the rect on screen. */
|
|
13
|
+
interface RectSample {
|
|
14
|
+
readonly t: number;
|
|
15
|
+
readonly rect: Rect;
|
|
16
|
+
}
|
|
17
|
+
/** A drawn frame with the target the motion was heading for at that frame. */
|
|
18
|
+
interface TargetSample extends RectSample {
|
|
19
|
+
readonly target: Rect;
|
|
20
|
+
}
|
|
21
|
+
/** A drawn frame with where a pointer-held rect should be. */
|
|
22
|
+
interface HeldSample extends RectSample {
|
|
23
|
+
readonly expected: Rect;
|
|
24
|
+
}
|
|
25
|
+
/** A drawn frame of content's transform: the matrix's x and y scale (CSS matrix `a` and `d`). */
|
|
26
|
+
interface ScaleSample {
|
|
27
|
+
readonly t: number;
|
|
28
|
+
readonly a: number;
|
|
29
|
+
readonly d: number;
|
|
30
|
+
}
|
|
31
|
+
/** What a check found. */
|
|
32
|
+
interface CheckResult {
|
|
33
|
+
readonly ok: boolean;
|
|
34
|
+
readonly failures: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
/** {@link checkTempo}'s result: also the measured time to 90 %. */
|
|
37
|
+
interface TempoResult extends CheckResult {
|
|
38
|
+
/** Ms from the start to the first sample 90 % of the way; null if it never got there or there was no move. */
|
|
39
|
+
readonly t90: number | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* No overshoot: between `from` and `to`, every component of every frame stays
|
|
43
|
+
* between its start and end value (plus `tolerance`). Run it per move; size
|
|
44
|
+
* (`width`, `height`) passing is "no wobble".
|
|
45
|
+
*/
|
|
46
|
+
declare function checkNoOvershoot(samples: readonly RectSample[], from: Rect, to: Rect, tolerance?: number): CheckResult;
|
|
47
|
+
/**
|
|
48
|
+
* Monotonic settle: per component, the distance to `to` never grows beyond
|
|
49
|
+
* the closest it has been so far (plus `tolerance`, once: a slow drift away
|
|
50
|
+
* fails too). A bounce or a restart backwards fails it.
|
|
51
|
+
*/
|
|
52
|
+
declare function checkMonotonic(samples: readonly RectSample[], to: Rect, tolerance?: number): CheckResult;
|
|
53
|
+
/**
|
|
54
|
+
* No jumps: no frame moves a component further than a settle at `omega`
|
|
55
|
+
* could in that frame's time, measured against the larger of the distances to
|
|
56
|
+
* the target before and after (plus `slack` px). A snap, a restart from an old
|
|
57
|
+
* place or a teleport fails it; a settle, however often retargeted, passes.
|
|
58
|
+
* Leave held frames out (a pointer may move anything any distance).
|
|
59
|
+
*
|
|
60
|
+
* Sample times must be the time the motion was stepped by (the frame loop's
|
|
61
|
+
* `delta`s summed, as `FrameInfo.delta` hands them out: 1000/60 for the first
|
|
62
|
+
* frame after idle, clamped to 64 ms), not wall-clock timestamps; and `slack`
|
|
63
|
+
* must cover the final snap, so keep it above the settle's `restDelta`.
|
|
64
|
+
*/
|
|
65
|
+
declare function checkNoJumps(samples: readonly TargetSample[], omega: number, slack?: number): CheckResult;
|
|
66
|
+
/** Held 1:1: on every frame the drawn rect is where the pointer puts it (within `tolerance`). */
|
|
67
|
+
declare function checkHeld(samples: readonly HeldSample[], tolerance?: number): CheckResult;
|
|
68
|
+
/**
|
|
69
|
+
* Content never stretched: the content's transform scales x and y by the same
|
|
70
|
+
* factor (within `tolerance`). With `uniformOnly: false` (default true) it must
|
|
71
|
+
* also be 1, i.e. not scaled at all: use that for glides, the default for
|
|
72
|
+
* open and close.
|
|
73
|
+
*/
|
|
74
|
+
declare function checkContentScale(samples: readonly ScaleSample[], options?: {
|
|
75
|
+
uniformOnly?: boolean;
|
|
76
|
+
tolerance?: number;
|
|
77
|
+
}): CheckResult;
|
|
78
|
+
/**
|
|
79
|
+
* Tempo: the move from `from` to `to` is 90 % done (by its largest component)
|
|
80
|
+
* within `t90` ms, give or take `tolerance` (a fraction, default 0.25).
|
|
81
|
+
* Time counts from `startT`: when the move began (the frame its target was
|
|
82
|
+
* set, its rect still `from`). It defaults to the first sample's time, so
|
|
83
|
+
* either pass it or record that frame first.
|
|
84
|
+
*/
|
|
85
|
+
declare function checkTempo(samples: readonly RectSample[], from: Rect, to: Rect, t90: number, tolerance?: number, startT?: number): TempoResult;
|
|
86
|
+
|
|
87
|
+
export { type CheckResult, type HeldSample, type RectSample, type ScaleSample, type TargetSample, type TempoResult, checkContentScale, checkHeld, checkMonotonic, checkNoJumps, checkNoOvershoot, checkTempo };
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/testing/checks.ts
|
|
2
|
+
var KEYS = ["x", "y", "width", "height"];
|
|
3
|
+
var result = (failures) => ({ ok: failures.length === 0, failures });
|
|
4
|
+
var fmt = (n) => (Math.round(n * 100) / 100).toString();
|
|
5
|
+
function checkNoOvershoot(samples, from, to, tolerance = 0.5) {
|
|
6
|
+
const failures = [];
|
|
7
|
+
for (const s of samples) {
|
|
8
|
+
for (const k of KEYS) {
|
|
9
|
+
const lo = Math.min(from[k], to[k]) - tolerance;
|
|
10
|
+
const hi = Math.max(from[k], to[k]) + tolerance;
|
|
11
|
+
const v = s.rect[k];
|
|
12
|
+
if (v < lo || v > hi) failures.push(`t=${fmt(s.t)} ${k}=${fmt(v)} outside [${fmt(lo + tolerance)}, ${fmt(hi - tolerance)}]`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result(failures);
|
|
16
|
+
}
|
|
17
|
+
function checkMonotonic(samples, to, tolerance = 0.5) {
|
|
18
|
+
const failures = [];
|
|
19
|
+
const closest = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const s of samples) {
|
|
21
|
+
for (const k of KEYS) {
|
|
22
|
+
const off = Math.abs(s.rect[k] - to[k]);
|
|
23
|
+
const best = closest.get(k);
|
|
24
|
+
if (best !== void 0 && off > best + tolerance) failures.push(`t=${fmt(s.t)} ${k} moved away from its target: ${fmt(best)} \u2192 ${fmt(off)} px off`);
|
|
25
|
+
if (best === void 0 || off < best) closest.set(k, off);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result(failures);
|
|
29
|
+
}
|
|
30
|
+
function checkNoJumps(samples, omega, slack = 1) {
|
|
31
|
+
const failures = [];
|
|
32
|
+
for (let i = 1; i < samples.length; i++) {
|
|
33
|
+
const a = samples[i - 1];
|
|
34
|
+
const b = samples[i];
|
|
35
|
+
const dt = Math.max(0, b.t - a.t) / 1e3;
|
|
36
|
+
const reach = 1 - Math.exp(-omega * dt);
|
|
37
|
+
for (const k of KEYS) {
|
|
38
|
+
const step = Math.abs(b.rect[k] - a.rect[k]);
|
|
39
|
+
const far = Math.max(Math.abs(a.rect[k] - a.target[k]), Math.abs(a.rect[k] - b.target[k]));
|
|
40
|
+
const limit = far * reach * 1.05 + slack;
|
|
41
|
+
if (step > limit) failures.push(`t=${fmt(b.t)} ${k} jumped ${fmt(step)} px in ${fmt(b.t - a.t)} ms (at most ${fmt(limit)})`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result(failures);
|
|
45
|
+
}
|
|
46
|
+
function checkHeld(samples, tolerance = 0.5) {
|
|
47
|
+
const failures = [];
|
|
48
|
+
for (const s of samples) {
|
|
49
|
+
for (const k of KEYS) {
|
|
50
|
+
const off = Math.abs(s.rect[k] - s.expected[k]);
|
|
51
|
+
if (off > tolerance) failures.push(`t=${fmt(s.t)} ${k} is ${fmt(off)} px from the pointer's place`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result(failures);
|
|
55
|
+
}
|
|
56
|
+
function checkContentScale(samples, options = {}) {
|
|
57
|
+
const tolerance = options.tolerance ?? 1e-3;
|
|
58
|
+
const uniformOnly = options.uniformOnly ?? true;
|
|
59
|
+
const failures = [];
|
|
60
|
+
for (const s of samples) {
|
|
61
|
+
if (Math.abs(s.a - s.d) > tolerance) failures.push(`t=${fmt(s.t)} content stretched: scale ${fmt(s.a)} \xD7 ${fmt(s.d)}`);
|
|
62
|
+
else if (!uniformOnly && (Math.abs(s.a - 1) > tolerance || Math.abs(s.d - 1) > tolerance)) failures.push(`t=${fmt(s.t)} content scaled by ${fmt(s.a)}`);
|
|
63
|
+
}
|
|
64
|
+
return result(failures);
|
|
65
|
+
}
|
|
66
|
+
function checkTempo(samples, from, to, t90, tolerance = 0.25, startT = samples[0]?.t ?? 0) {
|
|
67
|
+
let key = "x";
|
|
68
|
+
for (const k of KEYS) if (Math.abs(to[k] - from[k]) > Math.abs(to[key] - from[key])) key = k;
|
|
69
|
+
const span = to[key] - from[key];
|
|
70
|
+
if (span === 0) return { ok: true, failures: [], t90: null };
|
|
71
|
+
let measured = null;
|
|
72
|
+
for (const s of samples) {
|
|
73
|
+
if ((s.rect[key] - from[key]) / span >= 0.9) {
|
|
74
|
+
measured = s.t - startT;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const failures = [];
|
|
79
|
+
if (measured === null) failures.push(`never got 90 % of the way (${key})`);
|
|
80
|
+
else if (measured < t90 * (1 - tolerance) || measured > t90 * (1 + tolerance)) {
|
|
81
|
+
failures.push(`90 % after ${fmt(measured)} ms, expected ${fmt(t90)} ms \xB1 ${Math.round(tolerance * 100)} %`);
|
|
82
|
+
}
|
|
83
|
+
return { ok: failures.length === 0, failures, t90: measured };
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
checkContentScale,
|
|
87
|
+
checkHeld,
|
|
88
|
+
checkMonotonic,
|
|
89
|
+
checkNoJumps,
|
|
90
|
+
checkNoOvershoot,
|
|
91
|
+
checkTempo
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/testing/checks.ts"],"sourcesContent":["import type { Rect } from \"../shapes\";\n\n/**\n * Frame-sampled checks of the motion rules: record what was drawn on each\n * frame (in a unit test on the fake clock, or in a browser spec reading the\n * page each animation frame) and ask whether the motion kept the rules.\n *\n * Every check returns `{ ok, failures }`; a failure names the frame (its time)\n * and the component, so a spec can print it. Pixel tolerances default to half\n * a pixel.\n */\n\n/** One drawn frame: the time in ms and the rect on screen. */\nexport interface RectSample {\n readonly t: number;\n readonly rect: Rect;\n}\n\n/** A drawn frame with the target the motion was heading for at that frame. */\nexport interface TargetSample extends RectSample {\n readonly target: Rect;\n}\n\n/** A drawn frame with where a pointer-held rect should be. */\nexport interface HeldSample extends RectSample {\n readonly expected: Rect;\n}\n\n/** A drawn frame of content's transform: the matrix's x and y scale (CSS matrix `a` and `d`). */\nexport interface ScaleSample {\n readonly t: number;\n readonly a: number;\n readonly d: number;\n}\n\n/** What a check found. */\nexport interface CheckResult {\n readonly ok: boolean;\n readonly failures: readonly string[];\n}\n\n/** {@link checkTempo}'s result: also the measured time to 90 %. */\nexport interface TempoResult extends CheckResult {\n /** Ms from the start to the first sample 90 % of the way; null if it never got there or there was no move. */\n readonly t90: number | null;\n}\n\nconst KEYS = [\"x\", \"y\", \"width\", \"height\"] as const;\ntype Key = (typeof KEYS)[number];\n\nconst result = (failures: string[]): CheckResult => ({ ok: failures.length === 0, failures });\nconst fmt = (n: number): string => (Math.round(n * 100) / 100).toString();\n\n/**\n * No overshoot: between `from` and `to`, every component of every frame stays\n * between its start and end value (plus `tolerance`). Run it per move; size\n * (`width`, `height`) passing is \"no wobble\".\n */\nexport function checkNoOvershoot(samples: readonly RectSample[], from: Rect, to: Rect, tolerance = 0.5): CheckResult {\n const failures: string[] = [];\n for (const s of samples) {\n for (const k of KEYS) {\n const lo = Math.min(from[k], to[k]) - tolerance;\n const hi = Math.max(from[k], to[k]) + tolerance;\n const v = s.rect[k];\n if (v < lo || v > hi) failures.push(`t=${fmt(s.t)} ${k}=${fmt(v)} outside [${fmt(lo + tolerance)}, ${fmt(hi - tolerance)}]`);\n }\n }\n return result(failures);\n}\n\n/**\n * Monotonic settle: per component, the distance to `to` never grows beyond\n * the closest it has been so far (plus `tolerance`, once: a slow drift away\n * fails too). A bounce or a restart backwards fails it.\n */\nexport function checkMonotonic(samples: readonly RectSample[], to: Rect, tolerance = 0.5): CheckResult {\n const failures: string[] = [];\n const closest = new Map<Key, number>();\n for (const s of samples) {\n for (const k of KEYS) {\n const off = Math.abs(s.rect[k] - to[k]);\n const best = closest.get(k);\n if (best !== undefined && off > best + tolerance) failures.push(`t=${fmt(s.t)} ${k} moved away from its target: ${fmt(best)} → ${fmt(off)} px off`);\n if (best === undefined || off < best) closest.set(k, off);\n }\n }\n return result(failures);\n}\n\n/**\n * No jumps: no frame moves a component further than a settle at `omega`\n * could in that frame's time, measured against the larger of the distances to\n * the target before and after (plus `slack` px). A snap, a restart from an old\n * place or a teleport fails it; a settle, however often retargeted, passes.\n * Leave held frames out (a pointer may move anything any distance).\n *\n * Sample times must be the time the motion was stepped by (the frame loop's\n * `delta`s summed, as `FrameInfo.delta` hands them out: 1000/60 for the first\n * frame after idle, clamped to 64 ms), not wall-clock timestamps; and `slack`\n * must cover the final snap, so keep it above the settle's `restDelta`.\n */\nexport function checkNoJumps(samples: readonly TargetSample[], omega: number, slack = 1): CheckResult {\n const failures: string[] = [];\n for (let i = 1; i < samples.length; i++) {\n const a = samples[i - 1]!;\n const b = samples[i]!;\n const dt = Math.max(0, b.t - a.t) / 1000;\n const reach = 1 - Math.exp(-omega * dt);\n for (const k of KEYS) {\n const step = Math.abs(b.rect[k] - a.rect[k]);\n const far = Math.max(Math.abs(a.rect[k] - a.target[k]), Math.abs(a.rect[k] - b.target[k]));\n const limit = far * reach * 1.05 + slack;\n if (step > limit) failures.push(`t=${fmt(b.t)} ${k} jumped ${fmt(step)} px in ${fmt(b.t - a.t)} ms (at most ${fmt(limit)})`);\n }\n }\n return result(failures);\n}\n\n/** Held 1:1: on every frame the drawn rect is where the pointer puts it (within `tolerance`). */\nexport function checkHeld(samples: readonly HeldSample[], tolerance = 0.5): CheckResult {\n const failures: string[] = [];\n for (const s of samples) {\n for (const k of KEYS) {\n const off = Math.abs(s.rect[k] - s.expected[k]);\n if (off > tolerance) failures.push(`t=${fmt(s.t)} ${k} is ${fmt(off)} px from the pointer's place`);\n }\n }\n return result(failures);\n}\n\n/**\n * Content never stretched: the content's transform scales x and y by the same\n * factor (within `tolerance`). With `uniformOnly: false` (default true) it must\n * also be 1, i.e. not scaled at all: use that for glides, the default for\n * open and close.\n */\nexport function checkContentScale(samples: readonly ScaleSample[], options: { uniformOnly?: boolean; tolerance?: number } = {}): CheckResult {\n const tolerance = options.tolerance ?? 1e-3;\n const uniformOnly = options.uniformOnly ?? true;\n const failures: string[] = [];\n for (const s of samples) {\n if (Math.abs(s.a - s.d) > tolerance) failures.push(`t=${fmt(s.t)} content stretched: scale ${fmt(s.a)} × ${fmt(s.d)}`);\n else if (!uniformOnly && (Math.abs(s.a - 1) > tolerance || Math.abs(s.d - 1) > tolerance)) failures.push(`t=${fmt(s.t)} content scaled by ${fmt(s.a)}`);\n }\n return result(failures);\n}\n\n/**\n * Tempo: the move from `from` to `to` is 90 % done (by its largest component)\n * within `t90` ms, give or take `tolerance` (a fraction, default 0.25).\n * Time counts from `startT`: when the move began (the frame its target was\n * set, its rect still `from`). It defaults to the first sample's time, so\n * either pass it or record that frame first.\n */\nexport function checkTempo(\n samples: readonly RectSample[],\n from: Rect,\n to: Rect,\n t90: number,\n tolerance = 0.25,\n startT: number = samples[0]?.t ?? 0,\n): TempoResult {\n let key: Key = \"x\";\n for (const k of KEYS) if (Math.abs(to[k] - from[k]) > Math.abs(to[key] - from[key])) key = k;\n const span = to[key] - from[key];\n if (span === 0) return { ok: true, failures: [], t90: null };\n let measured: number | null = null;\n for (const s of samples) {\n if ((s.rect[key] - from[key]) / span >= 0.9) {\n measured = s.t - startT;\n break;\n }\n }\n const failures: string[] = [];\n if (measured === null) failures.push(`never got 90 % of the way (${key})`);\n else if (measured < t90 * (1 - tolerance) || measured > t90 * (1 + tolerance)) {\n failures.push(`90 % after ${fmt(measured)} ms, expected ${fmt(t90)} ms ± ${Math.round(tolerance * 100)} %`);\n }\n return { ok: failures.length === 0, failures, t90: measured };\n}\n"],"mappings":";AA+CA,IAAM,OAAO,CAAC,KAAK,KAAK,SAAS,QAAQ;AAGzC,IAAM,SAAS,CAAC,cAAqC,EAAE,IAAI,SAAS,WAAW,GAAG,SAAS;AAC3F,IAAM,MAAM,CAAC,OAAuB,KAAK,MAAM,IAAI,GAAG,IAAI,KAAK,SAAS;AAOjE,SAAS,iBAAiB,SAAgC,MAAY,IAAU,YAAY,KAAkB;AACnH,QAAM,WAAqB,CAAC;AAC5B,aAAW,KAAK,SAAS;AACvB,eAAW,KAAK,MAAM;AACpB,YAAM,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI;AACtC,YAAM,KAAK,KAAK,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI;AACtC,YAAM,IAAI,EAAE,KAAK,CAAC;AAClB,UAAI,IAAI,MAAM,IAAI,GAAI,UAAS,KAAK,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,IAAI,KAAK,SAAS,CAAC,KAAK,IAAI,KAAK,SAAS,CAAC,GAAG;AAAA,IAC7H;AAAA,EACF;AACA,SAAO,OAAO,QAAQ;AACxB;AAOO,SAAS,eAAe,SAAgC,IAAU,YAAY,KAAkB;AACrG,QAAM,WAAqB,CAAC;AAC5B,QAAM,UAAU,oBAAI,IAAiB;AACrC,aAAW,KAAK,S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AI,KAAK,GAAG;AAC/B,MAAI,SAAS,EAAG,QAAO,EAAE,IAAI,MAAM,UAAU,CAAC,GAAG,KAAK,KAAK;AAC3D,MAAI,WAA0B;AAC9B,aAAW,KAAK,SAAS;AACvB,SAAK,EAAE,KAAK,GAAG,IAAI,KAAK,GAAG,KAAK,QAAQ,KAAK;AAC3C,iBAAW,EAAE,IAAI;AACjB;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAqB,CAAC;AAC5B,MAAI,aAAa,KAAM,UAAS,KAAK,8BAA8B,GAAG,GAAG;AAAA,WAChE,WAAW,OAAO,IAAI,cAAc,WAAW,OAAO,IAAI,YAAY;AAC7E,aAAS,KAAK,cAAc,IAAI,QAAQ,CAAC,iBAAiB,IAAI,GAAG,CAAC,YAAS,KAAK,MAAM,YAAY,GAAG,CAAC,IAAI;AAAA,EAC5G;AACA,SAAO,EAAE,IAAI,SAAS,WAAW,GAAG,UAAU,KAAK,SAAS;AAC9D;","names":[]}
|
package/dist/values.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { A as Animatable, W as Widen } from './shapes-EbQlwbCu.js';
|
|
2
|
+
export { P as PopIn, R as RevealFrame, p as popIn, r as reveal } from './reveal-my7U6UyE.js';
|
|
2
3
|
import { e as Phase, a as FrameLoop } from './frame-loop-C88dc9xw.js';
|
|
3
4
|
import { ReadonlySignal } from './signals.js';
|
|
4
5
|
import './port-CmlUctqx.js';
|
|
@@ -133,6 +134,75 @@ interface Tween<T> extends Animator<T> {
|
|
|
133
134
|
*/
|
|
134
135
|
declare function createTween<T extends Animatable>(initial: T, config?: TweenConfig): Tween<Widen<T>>;
|
|
135
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Tempos for {@link createSettle}, in 1/s: a settle covers 90 % of the way in
|
|
139
|
+
* ln(10)/omega seconds and is within 1 % in twice that.
|
|
140
|
+
*
|
|
141
|
+
* - `calm` 20: 90 % in 115 ms, done in 230 ms.
|
|
142
|
+
* - `default` 25: 90 % in 92 ms, done in 184 ms.
|
|
143
|
+
* - `quick` 37: 90 % in 62 ms, done in 124 ms (a fast Hyprland setup).
|
|
144
|
+
*/
|
|
145
|
+
declare const SETTLE_TEMPO: {
|
|
146
|
+
readonly calm: 20;
|
|
147
|
+
readonly default: 25;
|
|
148
|
+
readonly quick: 37;
|
|
149
|
+
};
|
|
150
|
+
/** Settings of {@link createSettle}. */
|
|
151
|
+
interface SettleConfig {
|
|
152
|
+
/** The tempo in 1/s (see {@link SETTLE_TEMPO}). Higher is faster. Default 25. */
|
|
153
|
+
readonly omega?: number;
|
|
154
|
+
/** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */
|
|
155
|
+
readonly restDelta?: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The one curve for things that move to a new place: a window's rect between
|
|
159
|
+
* layout targets, a drawer, a camera. Fast at the start, gentle at the end,
|
|
160
|
+
* and it never passes its target.
|
|
161
|
+
*
|
|
162
|
+
* It is a critically damped spring (stiffness omega², damping 2·omega) with
|
|
163
|
+
* one rule on its velocity, per component:
|
|
164
|
+
*
|
|
165
|
+
* - **Launch.** On a new target, each component gets the velocity
|
|
166
|
+
* omega · distance toward it, from wherever it is drawn: standing still,
|
|
167
|
+
* moving toward it, or moving away (it turns at once rather than drifting
|
|
168
|
+
* further first). From there the spring follows `distance · e^(−omega·t)`
|
|
169
|
+
* exactly: most of the move happens at once, the rest eases in.
|
|
170
|
+
* - **Clamp.** That speed is also the most it may have toward the target, so a
|
|
171
|
+
* velocity set by hand (`setVelocity`, a fling) toward the target is capped
|
|
172
|
+
* there instead of shooting past.
|
|
173
|
+
* - **Carry.** A velocity set by hand away from the target is kept, and the
|
|
174
|
+
* value turns around; a critically damped spring turning around never
|
|
175
|
+
* crosses the target either.
|
|
176
|
+
*
|
|
177
|
+
* So after a new target every component goes straight from where it is drawn
|
|
178
|
+
* to the target and never past it: no overshoot on position, no wobble on
|
|
179
|
+
* size, whatever the retargets. A new target starts from the drawn value,
|
|
180
|
+
* never from the old start.
|
|
181
|
+
*
|
|
182
|
+
* Holding (a pointer owns the value): call `hold(value)` on each move. The
|
|
183
|
+
* value sits exactly there, at rest; the next `setTarget` launches from it.
|
|
184
|
+
*/
|
|
185
|
+
interface Settle<T> extends Animator<T> {
|
|
186
|
+
/** The tempo in 1/s. */
|
|
187
|
+
readonly omega: number;
|
|
188
|
+
/** Put the value at `value`, at rest, with it as the target: a held value follows its owner 1:1. Same as `jumpTo`. */
|
|
189
|
+
hold(value: T): void;
|
|
190
|
+
/** Set the velocity (units per second); a component moving toward the target is clamped as in the launch rule. */
|
|
191
|
+
setVelocity(velocity: T): void;
|
|
192
|
+
/** Change the tempo or rest distance mid-flight; the value and velocity carry on, re-clamped. */
|
|
193
|
+
configure(config: SettleConfig): void;
|
|
194
|
+
}
|
|
195
|
+
/** Defaults of {@link SettleConfig}. */
|
|
196
|
+
declare const SETTLE_DEFAULTS: {
|
|
197
|
+
readonly omega: 25;
|
|
198
|
+
readonly restDelta: 0.1;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* A settle starting at rest on `initial` (a number, a vector, a point or a
|
|
202
|
+
* rect; targets and velocities must have the same shape). See {@link Settle}.
|
|
203
|
+
*/
|
|
204
|
+
declare function createSettle<T extends Animatable>(initial: T, config?: SettleConfig): Settle<Widen<T>>;
|
|
205
|
+
|
|
136
206
|
/** Options of {@link motionValue}. */
|
|
137
207
|
interface MotionOptions {
|
|
138
208
|
/**
|
|
@@ -151,7 +221,7 @@ interface MotionOptions {
|
|
|
151
221
|
}
|
|
152
222
|
/** Options of {@link MotionValue.set}. */
|
|
153
223
|
interface SetOptions<T> {
|
|
154
|
-
/** Start with this velocity (units per second), e.g. a gesture's release velocity. Springs
|
|
224
|
+
/** 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. */
|
|
155
225
|
readonly velocity?: T;
|
|
156
226
|
}
|
|
157
227
|
/**
|
|
@@ -166,9 +236,9 @@ interface MotionValue<T, A extends Animator<unknown> = Animator<T>> extends Read
|
|
|
166
236
|
readonly velocity: T;
|
|
167
237
|
/** Whether it is moving (reactive). */
|
|
168
238
|
readonly moving: boolean;
|
|
169
|
-
/** The spring or tween underneath. */
|
|
239
|
+
/** The spring, settle or tween underneath. Change it through this value (`jump`, not the animator's `hold`), so the signal and the loop follow. */
|
|
170
240
|
readonly animator: A;
|
|
171
|
-
/** Head for `target`; a spring keeps its velocity. */
|
|
241
|
+
/** Head for `target`; a spring keeps its velocity, a settle launches from where it is drawn, a tween restarts. */
|
|
172
242
|
set(target: T, options?: SetOptions<T>): void;
|
|
173
243
|
/** Put the value at `value` at once, at rest. */
|
|
174
244
|
jump(value: T): void;
|
|
@@ -195,7 +265,13 @@ type AnimatorValue<A> = A extends Animator<infer T> ? T : never;
|
|
|
195
265
|
declare function motionValue<A extends Animator<unknown>>(loop: FrameLoop, animator: A, options?: MotionOptions): MotionValue<AnimatorValue<A>, A>;
|
|
196
266
|
/** A spring-driven {@link MotionValue}: `createSpring` plus `motionValue`. */
|
|
197
267
|
declare function springValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: SpringConfig & MotionOptions): MotionValue<Widen<T>, Spring<Widen<T>>>;
|
|
268
|
+
/**
|
|
269
|
+
* A settle-driven {@link MotionValue}: `createSettle` plus `motionValue`. The
|
|
270
|
+
* one curve for things moving to a new place (see {@link Settle}). To hold it
|
|
271
|
+
* to a pointer, `jump` it on each move; the next `set` launches from there.
|
|
272
|
+
*/
|
|
273
|
+
declare function settleValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: SettleConfig & MotionOptions): MotionValue<Widen<T>, Settle<Widen<T>>>;
|
|
198
274
|
/** A tween-driven {@link MotionValue}: `createTween` plus `motionValue`. */
|
|
199
275
|
declare function tweenValue<T extends Animatable>(loop: FrameLoop, initial: T, options?: TweenConfig & MotionOptions): MotionValue<Widen<T>, Tween<Widen<T>>>;
|
|
200
276
|
|
|
201
|
-
export { type Animator, type AnimatorValue, type Easing, type MotionOptions, type MotionValue, SPRING_DEFAULTS, type SetOptions, type Spring, type SpringConfig, type SpringParams, type SpringState, type Tween, type TweenConfig, createSpring, createTween, cubicBezier, ease, easeIn, easeInOut, easeInOutCubic, easeOut, easeOutCubic, linear, motionValue, resolveSpring, springStep, springValue, tweenValue };
|
|
277
|
+
export { type Animator, type AnimatorValue, type Easing, type MotionOptions, type MotionValue, SETTLE_DEFAULTS, SETTLE_TEMPO, SPRING_DEFAULTS, type SetOptions, type Settle, type SettleConfig, type Spring, type SpringConfig, type SpringParams, type SpringState, type Tween, type TweenConfig, createSettle, createSpring, createTween, cubicBezier, ease, easeIn, easeInOut, easeInOutCubic, easeOut, easeOutCubic, linear, motionValue, resolveSpring, settleValue, springStep, springValue, tweenValue };
|
package/dist/values.js
CHANGED
|
@@ -12,13 +12,24 @@ import {
|
|
|
12
12
|
linear,
|
|
13
13
|
motionValue,
|
|
14
14
|
resolveSpring,
|
|
15
|
+
settleValue,
|
|
15
16
|
springStep,
|
|
16
17
|
springValue,
|
|
17
18
|
tweenValue
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CM6WVNDH.js";
|
|
19
20
|
import "./chunk-OOKRBVMB.js";
|
|
21
|
+
import {
|
|
22
|
+
SETTLE_DEFAULTS,
|
|
23
|
+
SETTLE_TEMPO,
|
|
24
|
+
createSettle,
|
|
25
|
+
popIn,
|
|
26
|
+
reveal
|
|
27
|
+
} from "./chunk-WQQ2E25M.js";
|
|
20
28
|
export {
|
|
29
|
+
SETTLE_DEFAULTS,
|
|
30
|
+
SETTLE_TEMPO,
|
|
21
31
|
SPRING_DEFAULTS,
|
|
32
|
+
createSettle,
|
|
22
33
|
createSpring,
|
|
23
34
|
createTween,
|
|
24
35
|
cubicBezier,
|
|
@@ -30,7 +41,10 @@ export {
|
|
|
30
41
|
easeOutCubic,
|
|
31
42
|
linear,
|
|
32
43
|
motionValue,
|
|
44
|
+
popIn,
|
|
33
45
|
resolveSpring,
|
|
46
|
+
reveal,
|
|
47
|
+
settleValue,
|
|
34
48
|
springStep,
|
|
35
49
|
springValue,
|
|
36
50
|
tweenValue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n-uf/motion",
|
|
3
|
-
"version": "26.11.
|
|
3
|
+
"version": "26.11.4",
|
|
4
4
|
"description": "One frame loop with an injected clock, fine-grained signals, springs and tweens, and a DOM-free gesture recogniser. No DOM, no framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animation",
|
|
@@ -57,6 +57,18 @@
|
|
|
57
57
|
"types": "./dist/gestures.d.ts",
|
|
58
58
|
"default": "./dist/gestures.js"
|
|
59
59
|
},
|
|
60
|
+
"./testing": {
|
|
61
|
+
"types": "./dist/testing.d.ts",
|
|
62
|
+
"default": "./dist/testing.js"
|
|
63
|
+
},
|
|
64
|
+
"./drag": {
|
|
65
|
+
"types": "./dist/drag.d.ts",
|
|
66
|
+
"default": "./dist/drag.js"
|
|
67
|
+
},
|
|
68
|
+
"./layout": {
|
|
69
|
+
"types": "./dist/layout.d.ts",
|
|
70
|
+
"default": "./dist/layout.js"
|
|
71
|
+
},
|
|
60
72
|
"./browser": {
|
|
61
73
|
"types": "./dist/browser.d.ts",
|
|
62
74
|
"default": "./dist/browser.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/values/easing.ts","../src/shapes.ts","../src/values/spring.ts","../src/values/tween.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 { 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 { 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 only. */\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 or tween underneath. */\n readonly animator: A;\n /** Head for `target`; a spring keeps its velocity. */\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/** 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,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