@n-uf/motion 26.12.4 → 26.12.6
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 +16 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-I4TKJWCD.js → chunk-ELRGR2MI.js} +3 -3
- package/dist/{chunk-I4TKJWCD.js.map → chunk-ELRGR2MI.js.map} +1 -1
- package/dist/{chunk-MTSGXDVI.js → chunk-GLPO4HGL.js} +19 -1
- package/dist/chunk-GLPO4HGL.js.map +1 -0
- package/dist/{chunk-OOKRBVMB.js → chunk-LSIMILAL.js} +1 -1
- package/dist/chunk-LSIMILAL.js.map +1 -0
- package/dist/{chunk-BCFPSDOQ.js → chunk-LUFRN56Q.js} +1 -1
- package/dist/chunk-LUFRN56Q.js.map +1 -0
- package/dist/{chunk-QZJLWSPO.js → chunk-PIQEUBJE.js} +34 -3
- package/dist/chunk-PIQEUBJE.js.map +1 -0
- package/dist/{chunk-XKCRMQZQ.js → chunk-QZG3DQZ7.js} +1 -1
- package/dist/{chunk-XKCRMQZQ.js.map → chunk-QZG3DQZ7.js.map} +1 -1
- package/dist/{chunk-GDV76P2H.js → chunk-R4AHR32W.js} +4 -2
- package/dist/chunk-R4AHR32W.js.map +1 -0
- package/dist/clock.js +1 -1
- package/dist/drag.js +1 -1
- package/dist/gestures.d.ts +2 -1
- package/dist/gestures.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/layout.d.ts +2 -2
- package/dist/layout.js +2 -2
- package/dist/{motion--ql49201.d.ts → motion-CREdoi-4.d.ts} +48 -6
- package/dist/signals.js +1 -1
- package/dist/values.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-BCFPSDOQ.js.map +0 -1
- package/dist/chunk-GDV76P2H.js.map +0 -1
- package/dist/chunk-MTSGXDVI.js.map +0 -1
- package/dist/chunk-OOKRBVMB.js.map +0 -1
- package/dist/chunk-QZJLWSPO.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ within the month), the same scheme as `@n-uf/hypr-tiling`.
|
|
|
5
5
|
|
|
6
6
|
Unreleased entries live in `changes/` until a release joins them.
|
|
7
7
|
|
|
8
|
+
## 26.12.6
|
|
9
|
+
|
|
10
|
+
- **Added:** `LayoutMotion.rebase(dx, dy, { except })`: when the frame a host measures its rects in moves on screen by
|
|
11
|
+
(dx, dy) (a bar appears above the items), motion moves every item's drawn rect, target and box by the opposite, so
|
|
12
|
+
nothing moves on screen and the next targets glide from where the items are. It keeps each item's velocity, its
|
|
13
|
+
appearance and whether a jumped rect has been seen, so a rect no frame showed still never starts a glide. The moved
|
|
14
|
+
box reaches the drawable through `layOut` (the same size, a new place); batched, the loop is asked for one write, not
|
|
15
|
+
a movement. Call it first in the commit; `except` names items not measured in that frame. A number that is not
|
|
16
|
+
finite reads as 0, and (0, 0) does nothing.
|
|
17
|
+
|
|
18
|
+
## 26.12.5
|
|
19
|
+
|
|
20
|
+
- **Changed (types only):** `RawPointerEvent.pointerType` is `PointerKind | (string & {})`, so editors suggest the
|
|
21
|
+
known kinds (`mouse`, `pen`, `touch`) while any other string is still accepted. Unknown types are still treated as
|
|
22
|
+
mouse. No runtime change.
|
|
23
|
+
|
|
8
24
|
## 26.12.4
|
|
9
25
|
|
|
10
26
|
- **Fixed (behavior):** `createLandingModel(...).release` and `createDragIntent(...).release`: a release point that
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as ClockPort, T as TimerSource } from './port-DOxLK9GR.js';
|
|
2
2
|
import { R as Rect } from './shapes-EbQlwbCu.js';
|
|
3
|
-
import { b as Drawable, a as DrawFrame, L as LayoutItem } from './motion
|
|
3
|
+
import { b as Drawable, a as DrawFrame, L as LayoutItem } from './motion-CREdoi-4.js';
|
|
4
4
|
import { M as Machine, h as PagedSwipeState, f as PagedSwipeInput, d as PagedSwipeConfig } from './paged-swipe-DUfi6V9F.js';
|
|
5
5
|
import './frame-loop-DjAXTSO9.js';
|
|
6
6
|
import './reveal-Dg5fqoWS.js';
|
package/dist/browser.js
CHANGED
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/browser/browser-clock.ts","../src/browser/dom.ts","../src/browser/flip.ts","../src/browser/paged-swipe-on.ts"],"sourcesContent":["import type { ClockPort } from \"../clock/port\";\n\n/**\n * The parts of a browser global this adapter uses. Typed here instead of\n * through lib.dom, so the package builds without DOM types and a test (or a\n * worker, or a server) can pass its own host.\n */\nexport interface BrowserHost {\n requestAnimationFrame?(callback: (time: number) => void): number;\n cancelAnimationFrame?(handle: number): void;\n setTimeout(callback: () => void, ms?: number): unknown;\n clearTimeout(handle: unknown): void;\n readonly performance?: { now(): number };\n matchMedia?(query: string): { readonly matches: boolean };\n}\n\n/** Options of {@link createBrowserClock}. */\nexport interface BrowserClockOptions {\n /** The global to use. Default `globalThis`. */\n readonly host?: BrowserHost;\n /** Frame interval when the host has no requestAnimationFrame. Default 1000/60. */\n readonly fallbackFrameInterval?: number;\n}\n\n/**\n * A {@link ClockPort} on requestAnimationFrame, performance.now and\n * setTimeout. Without requestAnimationFrame (a worker, a server) frames come\n * from setTimeout at `fallbackFrameInterval`; without performance, time comes from\n * Date.now.\n */\nexport function createBrowserClock(options: BrowserClockOptions = {}): ClockPort {\n const host = options.host ?? (globalThis as unknown as BrowserHost);\n const fallbackFrameInterval = options.fallbackFrameInterval ?? 1000 / 60;\n const performance = host.performance;\n const now = performance !== undefined ? () => performance.now() : () => Date.now();\n\n // Timer handles are numbers in browsers and objects in Node; the port\n // promises numbers, so keep our own.\n let nextTimer = 1;\n const timers = new Map<number, unknown>();\n\n const setTimer = (callback: () => void, ms: number): number => {\n const id = nextTimer++;\n timers.set(\n id,\n host.setTimeout(() => {\n timers.delete(id);\n callback();\n }, Math.max(0, ms)),\n );\n return id;\n };\n\n const clearTimer = (id: number): void => {\n const handle = timers.get(id);\n if (handle === undefined) return;\n timers.delete(id);\n host.clearTimeout(handle);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method -- always called as `raf.call(host, ...)` below; declaring the BrowserHost members as properties would change the published types\n const raf = host.requestAnimationFrame;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- always called as `caf.call(host, ...)` below; declaring the BrowserHost members as properties would change the published types\n const caf = host.cancelAnimationFrame;\n if (raf !== undefined && caf !== undefined) {\n return {\n now,\n requestFrame: (callback) => raf.call(host, () => callback()),\n cancelFrame: (handle) => caf.call(host, handle),\n setTimer,\n clearTimer,\n };\n }\n return {\n now,\n requestFrame: (callback) => setTimer(callback, fallbackFrameInterval),\n cancelFrame: clearTimer,\n setTimer,\n clearTimer,\n };\n}\n\n/**\n * The user's reduced-motion preference as a function, for a motion value's\n * `reducedMotion` option. It reads the media query on each call, so a change\n * in the system setting applies to the next target and the next frame.\n * Without matchMedia it always returns `false`.\n */\nexport function prefersReducedMotion(host: BrowserHost = globalThis as unknown as BrowserHost): () => boolean {\n const query = host.matchMedia?.(\"(prefers-reduced-motion: reduce)\");\n return () => query?.matches ?? false;\n}\n","import type { Rect } from \"../shapes\";\nimport type { Drawable, DrawFrame } from \"../layout\";\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 center), 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","import type { Rect } from \"../shapes\";\nimport type { LayoutItem } from \"../layout\";\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 { TimerSource } from \"../clock\";\nimport { createPagedSwipe, PAGED_SWIPE_DEFAULTS, wheelDelta, type Machine, type PagedSwipeConfig, type PagedSwipeInput, type PagedSwipeState } from \"../gestures\";\n\n/**\n * Put on an element whose content keeps its own gestures (a map, a carousel, a slider): a swipe that starts on it\n * never pages. Empty for both axes, or `\"x\"` / `\"y\"` for one.\n */\nexport const SWIPE_KEEP_ATTRIBUTE = \"data-swipe-keep\";\n\n/**\n * Kept on every element a {@link pagedSwipeOn} runs on: the ways it can page, per input, space-separated. A finger's\n * are `x+`, `x-`, `y+`, `y-` (the scroll direction a swipe there has: a finger moving left is `x+`); a wheel run's\n * carry a `w` before them (`wx+`). Another swipe further out reads it the way it reads a scroller that can still\n * scroll, for the input in hand, so the nearest one that can take that gesture does. It lives in the DOM, not in\n * module memory, so two copies of this module in one page still see each other.\n */\nexport const SWIPE_PAGES_ATTRIBUTE = \"data-swipe-pages\";\n\n/** The px at the viewport's edges (along the swipe) where the system takes swipes: a finger that starts there never pages. */\nexport const SWIPE_EDGE_ZONE_PX = 24;\n\n/**\n * ms a finger's lift waits before it ends the swipe: the scroll events of the frame the finger lifted in arrive after\n * the lift, and a swipe during which something scrolled must not commit. Two frames at 60 Hz.\n */\nexport const SWIPE_LIFT_WAIT_MS = 34;\n\n/** A DOM listener as `addEventListener` takes it. Typed `any` so a real element or window (lib.dom) can be passed. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- lib.dom's listeners take each event's own type; this shape must accept them all\ntype SwipeListener = (event: any) => void;\n\n/** An element as the driver uses it (typed by shape, so the package builds without lib.dom). */\nexport interface SwipeElement {\n readonly parentElement: SwipeElement | null;\n readonly scrollLeft: number;\n readonly scrollTop: number;\n readonly scrollWidth: number;\n readonly scrollHeight: number;\n readonly clientWidth: number;\n readonly clientHeight: number;\n getAttribute(name: string): string | null;\n setAttribute(name: string, value: string): void;\n removeAttribute(name: string): void;\n contains(other: unknown): boolean;\n addEventListener(type: string, listener: SwipeListener, options?: { readonly passive?: boolean }): void;\n removeEventListener(type: string, listener: SwipeListener): void;\n}\n\n/** The global the driver reads: the viewport, computed styles, and the document-wide scroll events. */\nexport interface SwipeHost {\n readonly innerWidth: number;\n readonly innerHeight: number;\n getComputedStyle(element: SwipeElement): { readonly overflowX: string; readonly overflowY: string; readonly direction: string };\n addEventListener(type: string, listener: SwipeListener, options?: { readonly passive?: boolean; readonly capture?: boolean }): void;\n removeEventListener(type: string, listener: SwipeListener, options?: { readonly capture?: boolean }): void;\n}\n\ninterface TouchPoint {\n readonly identifier: number;\n readonly clientX: number;\n readonly clientY: number;\n}\ninterface TouchLike {\n readonly target: unknown;\n readonly touches: { readonly length: number };\n readonly changedTouches: { readonly length: number; readonly [index: number]: TouchPoint | undefined };\n}\ninterface WheelLike {\n readonly target: unknown;\n readonly deltaX: number;\n readonly deltaY: number;\n readonly deltaMode: number;\n readonly ctrlKey: boolean;\n readonly metaKey: boolean;\n readonly altKey: boolean;\n readonly shiftKey: boolean;\n readonly cancelable?: boolean;\n preventDefault(): void;\n}\ninterface ScrollLike {\n readonly target: unknown;\n}\n\n/** Options of {@link pagedSwipeOn}. */\nexport interface PagedSwipeOnOptions {\n /** The machine's clock: its `now()` stamps every sample. */\n readonly clock: TimerSource;\n readonly config?: Partial<PagedSwipeConfig>;\n /** A finger swipes. Default true. */\n readonly touch?: boolean;\n /** A trackpad's two-finger scroll (a wheel run) swipes. Default false. */\n readonly wheel?: boolean;\n /** Default {@link SWIPE_EDGE_ZONE_PX}. */\n readonly edgeZone?: number;\n /** Default `globalThis`. */\n readonly host?: SwipeHost;\n}\n\n/** What {@link pagedSwipeOn} returns: the running machine (send it `context`, `block`, `settled`), and the way out. */\nexport interface PagedSwipeOn {\n readonly swipe: Machine<PagedSwipeState, PagedSwipeInput>;\n dispose(): void;\n}\n\nconst SCROLLABLE: ReadonlySet<string> = new Set([\"auto\", \"scroll\", \"overlay\"]);\nconst EPSILON = 1;\n\n/** Whether one element can still scroll along `axis` towards `direction` (1: right / down), right-to-left included. */\nexport function canScrollFurther(element: SwipeElement, axis: \"x\" | \"y\", direction: 1 | -1, host: SwipeHost): boolean {\n const style = host.getComputedStyle(element);\n if (axis === \"y\") {\n if (!SCROLLABLE.has(style.overflowY)) return false;\n const max = element.scrollHeight - element.clientHeight;\n if (max <= EPSILON) return false;\n return direction === 1 ? element.scrollTop < max - EPSILON : element.scrollTop > EPSILON;\n }\n if (!SCROLLABLE.has(style.overflowX)) return false;\n const max = element.scrollWidth - element.clientWidth;\n if (max <= EPSILON) return false;\n const left = element.scrollLeft;\n if (style.direction === \"rtl\") return direction === 1 ? left < -EPSILON : left > -max + EPSILON;\n return direction === 1 ? left < max - EPSILON : left > EPSILON;\n}\n\nconst isElement = (node: unknown): node is SwipeElement =>\n typeof node === \"object\" && node !== null && typeof (node as { getAttribute?: unknown }).getAttribute === \"function\";\n\n/** The element an event target stands for (a text node's parent). */\nfunction elementOf(target: unknown): SwipeElement | null {\n if (isElement(target)) return target;\n const parent = typeof target === \"object\" && target !== null ? (target as { parentElement?: unknown }).parentElement : null;\n return isElement(parent) ? parent : null;\n}\n\n/** The way a swipe pages, for one input, as {@link SWIPE_PAGES_ATTRIBUTE} writes it. */\nconst token = (input: \"touch\" | \"wheel\", axis: \"x\" | \"y\", direction: 1 | -1): string => `${input === \"wheel\" ? \"w\" : \"\"}${axis}${direction === 1 ? \"+\" : \"-\"}`;\n\n/**\n * A paged swipe on an element: the machine ({@link createPagedSwipe}) and the DOM that feeds it.\n *\n * - **The nearest thing that way takes the gesture.** From the touched element out to this one, the first of: a\n * scroller that can still scroll that way, or another paged swipe ({@link SWIPE_PAGES_ATTRIBUTE}) with a page that\n * way for the same input, takes it; this swipe then doesn't arm. One with `band` takes every finger's swipe along its\n * axis.\n * - **Claimed starts (a finger only):** a finger that goes down within `edgeZone` of the viewport's edges along the\n * swipe (where the system takes swipes: back, the home bar), or on an element marked {@link SWIPE_KEEP_ATTRIBUTE},\n * never pages. A wheel run ignores both.\n * - **Scrolls:** a scroll inside this element, or of the page, while or just before a finger swipes is sent as\n * `scrolled` (the machine's rest rule). A lift ends the swipe {@link SWIPE_LIFT_WAIT_MS} later, so the scroll events\n * of its last frame still count.\n * - A second finger, or the browser taking the touch, cancels. A cancel that has nothing to animate back (progress 0)\n * ends at once; any other settle waits for the host's `settled`.\n * - Touch listeners are passive; the wheel listener is passive except while a wheel run is tracking, when it holds the\n * page still (`preventDefault`).\n *\n * The page size is the element's client extent along the swipe. The host sends `context` (which pages there are),\n * `block` (a drag owns the pointer), and `settled` when its page transition is done.\n */\nexport function pagedSwipeOn(element: SwipeElement, options: PagedSwipeOnOptions): PagedSwipeOn {\n const config: PagedSwipeConfig = { ...PAGED_SWIPE_DEFAULTS, ...options.config };\n const axis = config.along;\n const host: SwipeHost = options.host ?? (globalThis as unknown as SwipeHost);\n const edgeZone = options.edgeZone ?? SWIPE_EDGE_ZONE_PX;\n const touchOn = options.touch !== false;\n const wheelOn = options.wheel === true;\n const swipe = createPagedSwipe({ clock: options.clock, config });\n const now = (): number => options.clock.now();\n // An element with no layout yet (0) gives no size: the context's or the config's is used.\n const size = (): number | undefined => {\n const extent = axis === \"y\" ? element.clientHeight : element.clientWidth;\n return extent > 0 ? extent : undefined;\n };\n\n /** Whether something between `target` and this element (or this element as a scroller) goes that way first. */\n const nearerGoes = (target: unknown, direction: 1 | -1, input: \"touch\" | \"wheel\"): boolean => {\n const wanted = token(input, axis, direction);\n for (let node = elementOf(target); node !== null; node = node.parentElement) {\n if (canScrollFurther(node, axis, direction, host)) return true;\n if (node === element) return false;\n const pages = node.getAttribute(SWIPE_PAGES_ATTRIBUTE);\n if (pages !== null && pages.split(\" \").includes(wanted)) return true;\n }\n return false;\n };\n\n /** Whether content on the way from `target` to this element keeps its gestures on this axis. */\n const kept = (target: unknown): boolean => {\n for (let node = elementOf(target); node !== null && node !== element; node = node.parentElement) {\n const keep = node.getAttribute(SWIPE_KEEP_ATTRIBUTE);\n if (keep !== null && (keep === \"\" || keep === axis)) return true;\n }\n return false;\n };\n\n const inEdgeZone = (point: TouchPoint): boolean => {\n const at = axis === \"y\" ? point.clientY : point.clientX;\n const extent = axis === \"y\" ? host.innerHeight : host.innerWidth;\n return edgeZone > 0 && (at < edgeZone || at > extent - edgeZone);\n };\n\n // The ways this swipe pages, per input, kept on its element for swipes further out.\n let shownPages: string | null = null;\n const showPages = (state: PagedSwipeState): void => {\n const ways: string[] = [];\n // Blocked (a drag owns the pointer), it pages nowhere: a swipe further out must not yield to it.\n const open = !state.context.blocked;\n const wrapsAny = open && config.wrap && (state.context.hasPrev || state.context.hasNext);\n const next = open && (wrapsAny || state.context.hasNext);\n const prev = open && (wrapsAny || state.context.hasPrev);\n const band = open && config.band === true;\n // A finger's band takes every swipe along the axis; a wheel run never arms towards nothing.\n if (touchOn && (band || next)) ways.push(token(\"touch\", axis, 1));\n if (touchOn && (band || prev)) ways.push(token(\"touch\", axis, -1));\n if (wheelOn && next) ways.push(token(\"wheel\", axis, 1));\n if (wheelOn && prev) ways.push(token(\"wheel\", axis, -1));\n const shown = ways.join(\" \");\n if (shown === shownPages) return;\n shownPages = shown;\n element.setAttribute(SWIPE_PAGES_ATTRIBUTE, shown);\n };\n showPages(swipe.peek());\n\n let touch: { readonly id: number; readonly target: unknown; readonly x: number; readonly y: number } | null = null;\n const tracked = (event: TouchLike): TouchPoint | null => {\n if (touch === null) return null;\n for (let index = 0; index < event.changedTouches.length; index += 1) {\n const point = event.changedTouches[index];\n if (point !== undefined && point.identifier === touch.id) return point;\n }\n return null;\n };\n const cancelTouch = (): void => {\n if (touch === null) return;\n touch = null;\n swipe.send({ type: \"cancel\" });\n };\n // A lift waits SWIPE_LIFT_WAIT_MS, stamped with its own time, so the scrolls of its last frame are seen first.\n let lift: { readonly t: number; readonly timer: number } | null = null;\n const endLift = (): void => {\n if (lift === null) return;\n const { t, timer } = lift;\n lift = null;\n options.clock.clearTimer(timer);\n swipe.send({ type: \"touch-end\", t });\n };\n\n const onTouchStart = (event: TouchLike): void => {\n // A new finger before the last lift was judged: judge it now.\n endLift();\n if (event.touches.length > 1) {\n // A second finger: a pinch, not a swipe.\n cancelTouch();\n return;\n }\n const point = event.changedTouches[0];\n if (point === undefined) return;\n touch = { id: point.identifier, target: event.target, x: point.clientX, y: point.clientY };\n swipe.send({ type: \"touch-start\", x: point.clientX, y: point.clientY, t: now(), size: size(), claimed: inEdgeZone(point) || kept(event.target) });\n };\n const onTouchMove = (event: TouchLike): void => {\n if (touch === null) return;\n if (event.touches.length > 1) {\n cancelTouch();\n return;\n }\n const point = tracked(event);\n if (point === null) return;\n const state = swipe.peek();\n // The walk matters only at arming; a finger moving towards smaller x (or y) heads to `next`, scroll direction 1.\n const travel = axis === \"y\" ? touch.y - point.clientY : touch.x - point.clientX;\n const goes = state.phase === \"armed\" && travel !== 0 ? nearerGoes(touch.target, travel > 0 ? 1 : -1, \"touch\") : false;\n swipe.send({ type: \"touch-move\", x: point.clientX, y: point.clientY, t: now(), canScrollFurther: goes, size: size() });\n };\n const onTouchEnd = (event: TouchLike): void => {\n if (tracked(event) === null) return;\n touch = null;\n endLift();\n lift = { t: now(), timer: options.clock.setTimer(endLift, SWIPE_LIFT_WAIT_MS) };\n };\n const onTouchCancel = (event: TouchLike): void => {\n if (tracked(event) !== null) cancelTouch();\n };\n const onScroll = (event: ScrollLike): void => {\n // A scroll inside this swipe, or of the page itself (its target is the document, not an element).\n if (isElement(event.target) && !element.contains(event.target)) return;\n swipe.send({ type: \"scrolled\", t: now() });\n };\n\n let wheelPassive = true;\n const onWheel = (event: WheelLike): void => {\n const delta = wheelDelta(event.deltaX, event.deltaY, event.deltaMode === 1 || event.deltaMode === 2 ? event.deltaMode : 0);\n const main = axis === \"y\" ? delta.y : delta.x;\n const before = swipe.peek();\n // `preventDefault` only works on a non-passive registration: the one this sample arrived on.\n const holdable = !wheelPassive;\n const goes = main !== 0 && (before.phase === \"idle\" || before.phase === \"armed\") ? nearerGoes(event.target, main > 0 ? 1 : -1, \"wheel\") : false;\n const after = swipe.send({\n type: \"wheel\",\n dx: delta.x,\n dy: delta.y,\n t: now(),\n modifiers: { ctrl: event.ctrlKey, meta: event.metaKey, alt: event.altKey, shift: event.shiftKey },\n canScrollFurther: goes,\n size: size(),\n });\n if (holdable && after.phase === \"tracking\" && after.input === \"wheel\" && event.cancelable !== false) event.preventDefault();\n };\n const attachWheel = (passive: boolean): void => {\n element.removeEventListener(\"wheel\", onWheel);\n element.addEventListener(\"wheel\", onWheel, { passive });\n wheelPassive = passive;\n };\n\n const unsubscribe = swipe.subscribe((next, previous) => {\n if (next.context !== previous.context) showPages(next);\n // A cancel with nothing drawn away from rest has nothing to animate back: it ends at once.\n if (next.phase === \"settling\" && previous.phase !== \"settling\" && next.outcome === \"cancel\" && next.progress === 0) swipe.send({ type: \"settled\" });\n // Non-passive only while a wheel run tracks, so page scrolling never waits on this listener.\n const holding = next.phase === \"tracking\" && next.input === \"wheel\";\n if (wheelOn && holding === wheelPassive) attachWheel(!holding);\n });\n\n if (touchOn) {\n element.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n element.addEventListener(\"touchmove\", onTouchMove, { passive: true });\n element.addEventListener(\"touchend\", onTouchEnd, { passive: true });\n element.addEventListener(\"touchcancel\", onTouchCancel, { passive: true });\n host.addEventListener(\"scroll\", onScroll, { passive: true, capture: true });\n }\n if (wheelOn) attachWheel(true);\n\n let disposed = false;\n return {\n swipe,\n dispose: (): void => {\n if (disposed) return;\n disposed = true;\n if (lift !== null) options.clock.clearTimer(lift.timer);\n lift = null;\n unsubscribe();\n if (touchOn) {\n element.removeEventListener(\"touchstart\", onTouchStart);\n element.removeEventListener(\"touchmove\", onTouchMove);\n element.removeEventListener(\"touchend\", onTouchEnd);\n element.removeEventListener(\"touchcancel\", onTouchCancel);\n host.removeEventListener(\"scroll\", onScroll, { capture: true });\n }\n if (wheelOn) element.removeEventListener(\"wheel\", onWheel);\n element.removeAttribute(SWIPE_PAGES_ATTRIBUTE);\n swipe.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;AA8BO,SAAS,mBAAmB,UAA+B,CAAC,GAAc;AAC/E,QAAM,OAAO,QAAQ,QAAS;AAC9B,QAAM,wBAAwB,QAAQ,yBAAyB,MAAO;AACtE,QAAM,cAAc,KAAK;AACzB,QAAM,MAAM,gBAAgB,SAAY,MAAM,YAAY,IAAI,IAAI,MAAM,KAAK,IAAI;AAIjF,MAAI,YAAY;AAChB,QAAM,SAAS,oBAAI,IAAqB;AAExC,QAAM,WAAW,CAAC,UAAsB,OAAuB;AAC7D,UAAM,KAAK;AACX,WAAO;AAAA,MACL;AAAA,MACA,KAAK,WAAW,MAAM;AACpB,eAAO,OAAO,EAAE;AAChB,iBAAS;AAAA,MACX,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,CAAC,OAAqB;AACvC,UAAM,SAAS,OAAO,IAAI,EAAE;AAC5B,QAAI,WAAW,OAAW;AAC1B,WAAO,OAAO,EAAE;AAChB,SAAK,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,YAAQ,iBAAiB,aAAa,aAAa,EAAE,SAAS,KAAK,CAAC;AACpE,YAAQ,iBAAiB,YAAY,YAAY,EAAE,SAAS,KAAK,CAAC;AAClE,YAAQ,iBAAiB,eAAe,eAAe,EAAE,SAAS,KAAK,CAAC;AACxE,SAAK,iBAAiB,UAAU,UAAU,EAAE,SAAS,MAAM,SAAS,KAAK,CAAC;AAAA,EAC5E;AACA,MAAI,QAAS,aAAY,IAAI;AAE7B,MAAI,WAAW;AACf,SAAO;AAAA,IACL;AAAA,IACA,SAAS,MAAY;AACnB,UAAI,SAAU;AACd,iBAAW;AACX,UAAI,SAAS,KAAM,SAAQ,MAAM,WAAW,KAAK,KAAK;AACtD,aAAO;AACP,kBAAY;AACZ,UAAI,SAAS;AACX,gBAAQ,oBAAoB,cAAc,YAAY;AACtD,gBAAQ,oBAAoB,aAAa,WAAW;AACpD,gBAAQ,oBAAoB,YAAY,UAAU;AAClD,gBAAQ,oBAAoB,eAAe,aAAa;AACxD,aAAK,oBAAoB,UAAU,UAAU,EAAE,SAAS,KAAK,CAAC;AAAA,MAChE;AACA,UAAI,QAAS,SAAQ,oBAAoB,SAAS,OAAO;AACzD,cAAQ,gBAAgB,qBAAqB;AAC7C,YAAM,QAAQ;AAAA,IAChB;AAAA,EACF;AACF;","names":["max"]}
|
|
1
|
+
{"version":3,"sources":["../src/browser/browser-clock.ts","../src/browser/dom.ts","../src/browser/flip.ts","../src/browser/paged-swipe-on.ts"],"sourcesContent":["import type { ClockPort } from \"../clock/port\";\n\n/**\n * The parts of a browser global this adapter uses. Typed here instead of\n * through lib.dom, so the package builds without DOM types and a test (or a\n * worker, or a server) can pass its own host.\n */\nexport interface BrowserHost {\n requestAnimationFrame?(callback: (time: number) => void): number;\n cancelAnimationFrame?(handle: number): void;\n setTimeout(callback: () => void, ms?: number): unknown;\n clearTimeout(handle: unknown): void;\n readonly performance?: { now(): number };\n matchMedia?(query: string): { readonly matches: boolean };\n}\n\n/** Options of {@link createBrowserClock}. */\nexport interface BrowserClockOptions {\n /** The global to use. Default `globalThis`. */\n readonly host?: BrowserHost;\n /** Frame interval when the host has no requestAnimationFrame. Default 1000/60. */\n readonly fallbackFrameInterval?: number;\n}\n\n/**\n * A {@link ClockPort} on requestAnimationFrame, performance.now and\n * setTimeout. Without requestAnimationFrame (a worker, a server) frames come\n * from setTimeout at `fallbackFrameInterval`; without performance, time comes from\n * Date.now.\n */\nexport function createBrowserClock(options: BrowserClockOptions = {}): ClockPort {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- needed in the library's program (no host globals); lint reads this file with Node's\n const host = options.host ?? (globalThis as unknown as BrowserHost);\n const fallbackFrameInterval = options.fallbackFrameInterval ?? 1000 / 60;\n const performance = host.performance;\n const now = performance !== undefined ? () => performance.now() : () => Date.now();\n\n // Timer handles are numbers in browsers and objects in Node; the port\n // promises numbers, so keep our own.\n let nextTimer = 1;\n const timers = new Map<number, unknown>();\n\n const setTimer = (callback: () => void, ms: number): number => {\n const id = nextTimer++;\n timers.set(\n id,\n host.setTimeout(() => {\n timers.delete(id);\n callback();\n }, Math.max(0, ms)),\n );\n return id;\n };\n\n const clearTimer = (id: number): void => {\n const handle = timers.get(id);\n if (handle === undefined) return;\n timers.delete(id);\n host.clearTimeout(handle);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method -- always called as `raf.call(host, ...)` below; declaring the BrowserHost members as properties would change the published types\n const raf = host.requestAnimationFrame;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- always called as `caf.call(host, ...)` below; declaring the BrowserHost members as properties would change the published types\n const caf = host.cancelAnimationFrame;\n if (raf !== undefined && caf !== undefined) {\n return {\n now,\n requestFrame: (callback) => raf.call(host, () => callback()),\n cancelFrame: (handle) => caf.call(host, handle),\n setTimer,\n clearTimer,\n };\n }\n return {\n now,\n requestFrame: (callback) => setTimer(callback, fallbackFrameInterval),\n cancelFrame: clearTimer,\n setTimer,\n clearTimer,\n };\n}\n\n/**\n * The user's reduced-motion preference as a function, for a motion value's\n * `reducedMotion` option. It reads the media query on each call, so a change\n * in the system setting applies to the next target and the next frame.\n * Without matchMedia it always returns `false`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- needed in the library's program (no host globals); lint reads this file with Node's\nexport function prefersReducedMotion(host: BrowserHost = globalThis as unknown as BrowserHost): () => boolean {\n const query = host.matchMedia?.(\"(prefers-reduced-motion: reduce)\");\n return () => query?.matches ?? false;\n}\n","import type { Rect } from \"../shapes\";\nimport type { Drawable, DrawFrame } from \"../layout\";\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 center), 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","import type { Rect } from \"../shapes\";\nimport type { LayoutItem } from \"../layout\";\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 { TimerSource } from \"../clock\";\nimport { createPagedSwipe, PAGED_SWIPE_DEFAULTS, wheelDelta, type Machine, type PagedSwipeConfig, type PagedSwipeInput, type PagedSwipeState } from \"../gestures\";\n\n/**\n * Put on an element whose content keeps its own gestures (a map, a carousel, a slider): a swipe that starts on it\n * never pages. Empty for both axes, or `\"x\"` / `\"y\"` for one.\n */\nexport const SWIPE_KEEP_ATTRIBUTE = \"data-swipe-keep\";\n\n/**\n * Kept on every element a {@link pagedSwipeOn} runs on: the ways it can page, per input, space-separated. A finger's\n * are `x+`, `x-`, `y+`, `y-` (the scroll direction a swipe there has: a finger moving left is `x+`); a wheel run's\n * carry a `w` before them (`wx+`). Another swipe further out reads it the way it reads a scroller that can still\n * scroll, for the input in hand, so the nearest one that can take that gesture does. It lives in the DOM, not in\n * module memory, so two copies of this module in one page still see each other.\n */\nexport const SWIPE_PAGES_ATTRIBUTE = \"data-swipe-pages\";\n\n/** The px at the viewport's edges (along the swipe) where the system takes swipes: a finger that starts there never pages. */\nexport const SWIPE_EDGE_ZONE_PX = 24;\n\n/**\n * ms a finger's lift waits before it ends the swipe: the scroll events of the frame the finger lifted in arrive after\n * the lift, and a swipe during which something scrolled must not commit. Two frames at 60 Hz.\n */\nexport const SWIPE_LIFT_WAIT_MS = 34;\n\n/** A DOM listener as `addEventListener` takes it. Typed `any` so a real element or window (lib.dom) can be passed. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- lib.dom's listeners take each event's own type; this shape must accept them all\ntype SwipeListener = (event: any) => void;\n\n/** An element as the driver uses it (typed by shape, so the package builds without lib.dom). */\nexport interface SwipeElement {\n readonly parentElement: SwipeElement | null;\n readonly scrollLeft: number;\n readonly scrollTop: number;\n readonly scrollWidth: number;\n readonly scrollHeight: number;\n readonly clientWidth: number;\n readonly clientHeight: number;\n getAttribute(name: string): string | null;\n setAttribute(name: string, value: string): void;\n removeAttribute(name: string): void;\n contains(other: unknown): boolean;\n addEventListener(type: string, listener: SwipeListener, options?: { readonly passive?: boolean }): void;\n removeEventListener(type: string, listener: SwipeListener): void;\n}\n\n/** The global the driver reads: the viewport, computed styles, and the document-wide scroll events. */\nexport interface SwipeHost {\n readonly innerWidth: number;\n readonly innerHeight: number;\n getComputedStyle(element: SwipeElement): { readonly overflowX: string; readonly overflowY: string; readonly direction: string };\n addEventListener(type: string, listener: SwipeListener, options?: { readonly passive?: boolean; readonly capture?: boolean }): void;\n removeEventListener(type: string, listener: SwipeListener, options?: { readonly capture?: boolean }): void;\n}\n\ninterface TouchPoint {\n readonly identifier: number;\n readonly clientX: number;\n readonly clientY: number;\n}\ninterface TouchLike {\n readonly target: unknown;\n readonly touches: { readonly length: number };\n readonly changedTouches: { readonly length: number; readonly [index: number]: TouchPoint | undefined };\n}\ninterface WheelLike {\n readonly target: unknown;\n readonly deltaX: number;\n readonly deltaY: number;\n readonly deltaMode: number;\n readonly ctrlKey: boolean;\n readonly metaKey: boolean;\n readonly altKey: boolean;\n readonly shiftKey: boolean;\n readonly cancelable?: boolean;\n preventDefault(): void;\n}\ninterface ScrollLike {\n readonly target: unknown;\n}\n\n/** Options of {@link pagedSwipeOn}. */\nexport interface PagedSwipeOnOptions {\n /** The machine's clock: its `now()` stamps every sample. */\n readonly clock: TimerSource;\n readonly config?: Partial<PagedSwipeConfig>;\n /** A finger swipes. Default true. */\n readonly touch?: boolean;\n /** A trackpad's two-finger scroll (a wheel run) swipes. Default false. */\n readonly wheel?: boolean;\n /** Default {@link SWIPE_EDGE_ZONE_PX}. */\n readonly edgeZone?: number;\n /** Default `globalThis`. */\n readonly host?: SwipeHost;\n}\n\n/** What {@link pagedSwipeOn} returns: the running machine (send it `context`, `block`, `settled`), and the way out. */\nexport interface PagedSwipeOn {\n readonly swipe: Machine<PagedSwipeState, PagedSwipeInput>;\n dispose(): void;\n}\n\nconst SCROLLABLE: ReadonlySet<string> = new Set([\"auto\", \"scroll\", \"overlay\"]);\nconst EPSILON = 1;\n\n/** Whether one element can still scroll along `axis` towards `direction` (1: right / down), right-to-left included. */\nexport function canScrollFurther(element: SwipeElement, axis: \"x\" | \"y\", direction: 1 | -1, host: SwipeHost): boolean {\n const style = host.getComputedStyle(element);\n if (axis === \"y\") {\n if (!SCROLLABLE.has(style.overflowY)) return false;\n const max = element.scrollHeight - element.clientHeight;\n if (max <= EPSILON) return false;\n return direction === 1 ? element.scrollTop < max - EPSILON : element.scrollTop > EPSILON;\n }\n if (!SCROLLABLE.has(style.overflowX)) return false;\n const max = element.scrollWidth - element.clientWidth;\n if (max <= EPSILON) return false;\n const left = element.scrollLeft;\n if (style.direction === \"rtl\") return direction === 1 ? left < -EPSILON : left > -max + EPSILON;\n return direction === 1 ? left < max - EPSILON : left > EPSILON;\n}\n\nconst isElement = (node: unknown): node is SwipeElement =>\n typeof node === \"object\" && node !== null && typeof (node as { getAttribute?: unknown }).getAttribute === \"function\";\n\n/** The element an event target stands for (a text node's parent). */\nfunction elementOf(target: unknown): SwipeElement | null {\n if (isElement(target)) return target;\n const parent = typeof target === \"object\" && target !== null ? (target as { parentElement?: unknown }).parentElement : null;\n return isElement(parent) ? parent : null;\n}\n\n/** The way a swipe pages, for one input, as {@link SWIPE_PAGES_ATTRIBUTE} writes it. */\nconst token = (input: \"touch\" | \"wheel\", axis: \"x\" | \"y\", direction: 1 | -1): string => `${input === \"wheel\" ? \"w\" : \"\"}${axis}${direction === 1 ? \"+\" : \"-\"}`;\n\n/**\n * A paged swipe on an element: the machine ({@link createPagedSwipe}) and the DOM that feeds it.\n *\n * - **The nearest thing that way takes the gesture.** From the touched element out to this one, the first of: a\n * scroller that can still scroll that way, or another paged swipe ({@link SWIPE_PAGES_ATTRIBUTE}) with a page that\n * way for the same input, takes it; this swipe then doesn't arm. One with `band` takes every finger's swipe along its\n * axis.\n * - **Claimed starts (a finger only):** a finger that goes down within `edgeZone` of the viewport's edges along the\n * swipe (where the system takes swipes: back, the home bar), or on an element marked {@link SWIPE_KEEP_ATTRIBUTE},\n * never pages. A wheel run ignores both.\n * - **Scrolls:** a scroll inside this element, or of the page, while or just before a finger swipes is sent as\n * `scrolled` (the machine's rest rule). A lift ends the swipe {@link SWIPE_LIFT_WAIT_MS} later, so the scroll events\n * of its last frame still count.\n * - A second finger, or the browser taking the touch, cancels. A cancel that has nothing to animate back (progress 0)\n * ends at once; any other settle waits for the host's `settled`.\n * - Touch listeners are passive; the wheel listener is passive except while a wheel run is tracking, when it holds the\n * page still (`preventDefault`).\n *\n * The page size is the element's client extent along the swipe. The host sends `context` (which pages there are),\n * `block` (a drag owns the pointer), and `settled` when its page transition is done.\n */\nexport function pagedSwipeOn(element: SwipeElement, options: PagedSwipeOnOptions): PagedSwipeOn {\n const config: PagedSwipeConfig = { ...PAGED_SWIPE_DEFAULTS, ...options.config };\n const axis = config.along;\n const host: SwipeHost = options.host ?? (globalThis as unknown as SwipeHost);\n const edgeZone = options.edgeZone ?? SWIPE_EDGE_ZONE_PX;\n const touchOn = options.touch !== false;\n const wheelOn = options.wheel === true;\n const swipe = createPagedSwipe({ clock: options.clock, config });\n const now = (): number => options.clock.now();\n // An element with no layout yet (0) gives no size: the context's or the config's is used.\n const size = (): number | undefined => {\n const extent = axis === \"y\" ? element.clientHeight : element.clientWidth;\n return extent > 0 ? extent : undefined;\n };\n\n /** Whether something between `target` and this element (or this element as a scroller) goes that way first. */\n const nearerGoes = (target: unknown, direction: 1 | -1, input: \"touch\" | \"wheel\"): boolean => {\n const wanted = token(input, axis, direction);\n for (let node = elementOf(target); node !== null; node = node.parentElement) {\n if (canScrollFurther(node, axis, direction, host)) return true;\n if (node === element) return false;\n const pages = node.getAttribute(SWIPE_PAGES_ATTRIBUTE);\n if (pages !== null && pages.split(\" \").includes(wanted)) return true;\n }\n return false;\n };\n\n /** Whether content on the way from `target` to this element keeps its gestures on this axis. */\n const kept = (target: unknown): boolean => {\n for (let node = elementOf(target); node !== null && node !== element; node = node.parentElement) {\n const keep = node.getAttribute(SWIPE_KEEP_ATTRIBUTE);\n if (keep !== null && (keep === \"\" || keep === axis)) return true;\n }\n return false;\n };\n\n const inEdgeZone = (point: TouchPoint): boolean => {\n const at = axis === \"y\" ? point.clientY : point.clientX;\n const extent = axis === \"y\" ? host.innerHeight : host.innerWidth;\n return edgeZone > 0 && (at < edgeZone || at > extent - edgeZone);\n };\n\n // The ways this swipe pages, per input, kept on its element for swipes further out.\n let shownPages: string | null = null;\n const showPages = (state: PagedSwipeState): void => {\n const ways: string[] = [];\n // Blocked (a drag owns the pointer), it pages nowhere: a swipe further out must not yield to it.\n const open = !state.context.blocked;\n const wrapsAny = open && config.wrap && (state.context.hasPrev || state.context.hasNext);\n const next = open && (wrapsAny || state.context.hasNext);\n const prev = open && (wrapsAny || state.context.hasPrev);\n const band = open && config.band === true;\n // A finger's band takes every swipe along the axis; a wheel run never arms towards nothing.\n if (touchOn && (band || next)) ways.push(token(\"touch\", axis, 1));\n if (touchOn && (band || prev)) ways.push(token(\"touch\", axis, -1));\n if (wheelOn && next) ways.push(token(\"wheel\", axis, 1));\n if (wheelOn && prev) ways.push(token(\"wheel\", axis, -1));\n const shown = ways.join(\" \");\n if (shown === shownPages) return;\n shownPages = shown;\n element.setAttribute(SWIPE_PAGES_ATTRIBUTE, shown);\n };\n showPages(swipe.peek());\n\n let touch: { readonly id: number; readonly target: unknown; readonly x: number; readonly y: number } | null = null;\n const tracked = (event: TouchLike): TouchPoint | null => {\n if (touch === null) return null;\n for (let index = 0; index < event.changedTouches.length; index += 1) {\n const point = event.changedTouches[index];\n if (point !== undefined && point.identifier === touch.id) return point;\n }\n return null;\n };\n const cancelTouch = (): void => {\n if (touch === null) return;\n touch = null;\n swipe.send({ type: \"cancel\" });\n };\n // A lift waits SWIPE_LIFT_WAIT_MS, stamped with its own time, so the scrolls of its last frame are seen first.\n let lift: { readonly t: number; readonly timer: number } | null = null;\n const endLift = (): void => {\n if (lift === null) return;\n const { t, timer } = lift;\n lift = null;\n options.clock.clearTimer(timer);\n swipe.send({ type: \"touch-end\", t });\n };\n\n const onTouchStart = (event: TouchLike): void => {\n // A new finger before the last lift was judged: judge it now.\n endLift();\n if (event.touches.length > 1) {\n // A second finger: a pinch, not a swipe.\n cancelTouch();\n return;\n }\n const point = event.changedTouches[0];\n if (point === undefined) return;\n touch = { id: point.identifier, target: event.target, x: point.clientX, y: point.clientY };\n swipe.send({ type: \"touch-start\", x: point.clientX, y: point.clientY, t: now(), size: size(), claimed: inEdgeZone(point) || kept(event.target) });\n };\n const onTouchMove = (event: TouchLike): void => {\n if (touch === null) return;\n if (event.touches.length > 1) {\n cancelTouch();\n return;\n }\n const point = tracked(event);\n if (point === null) return;\n const state = swipe.peek();\n // The walk matters only at arming; a finger moving towards smaller x (or y) heads to `next`, scroll direction 1.\n const travel = axis === \"y\" ? touch.y - point.clientY : touch.x - point.clientX;\n const goes = state.phase === \"armed\" && travel !== 0 ? nearerGoes(touch.target, travel > 0 ? 1 : -1, \"touch\") : false;\n swipe.send({ type: \"touch-move\", x: point.clientX, y: point.clientY, t: now(), canScrollFurther: goes, size: size() });\n };\n const onTouchEnd = (event: TouchLike): void => {\n if (tracked(event) === null) return;\n touch = null;\n endLift();\n lift = { t: now(), timer: options.clock.setTimer(endLift, SWIPE_LIFT_WAIT_MS) };\n };\n const onTouchCancel = (event: TouchLike): void => {\n if (tracked(event) !== null) cancelTouch();\n };\n const onScroll = (event: ScrollLike): void => {\n // A scroll inside this swipe, or of the page itself (its target is the document, not an element).\n if (isElement(event.target) && !element.contains(event.target)) return;\n swipe.send({ type: \"scrolled\", t: now() });\n };\n\n let wheelPassive = true;\n const onWheel = (event: WheelLike): void => {\n const delta = wheelDelta(event.deltaX, event.deltaY, event.deltaMode === 1 || event.deltaMode === 2 ? event.deltaMode : 0);\n const main = axis === \"y\" ? delta.y : delta.x;\n const before = swipe.peek();\n // `preventDefault` only works on a non-passive registration: the one this sample arrived on.\n const holdable = !wheelPassive;\n const goes = main !== 0 && (before.phase === \"idle\" || before.phase === \"armed\") ? nearerGoes(event.target, main > 0 ? 1 : -1, \"wheel\") : false;\n const after = swipe.send({\n type: \"wheel\",\n dx: delta.x,\n dy: delta.y,\n t: now(),\n modifiers: { ctrl: event.ctrlKey, meta: event.metaKey, alt: event.altKey, shift: event.shiftKey },\n canScrollFurther: goes,\n size: size(),\n });\n if (holdable && after.phase === \"tracking\" && after.input === \"wheel\" && event.cancelable !== false) event.preventDefault();\n };\n const attachWheel = (passive: boolean): void => {\n element.removeEventListener(\"wheel\", onWheel);\n element.addEventListener(\"wheel\", onWheel, { passive });\n wheelPassive = passive;\n };\n\n const unsubscribe = swipe.subscribe((next, previous) => {\n if (next.context !== previous.context) showPages(next);\n // A cancel with nothing drawn away from rest has nothing to animate back: it ends at once.\n if (next.phase === \"settling\" && previous.phase !== \"settling\" && next.outcome === \"cancel\" && next.progress === 0) swipe.send({ type: \"settled\" });\n // Non-passive only while a wheel run tracks, so page scrolling never waits on this listener.\n const holding = next.phase === \"tracking\" && next.input === \"wheel\";\n if (wheelOn && holding === wheelPassive) attachWheel(!holding);\n });\n\n if (touchOn) {\n element.addEventListener(\"touchstart\", onTouchStart, { passive: true });\n element.addEventListener(\"touchmove\", onTouchMove, { passive: true });\n element.addEventListener(\"touchend\", onTouchEnd, { passive: true });\n element.addEventListener(\"touchcancel\", onTouchCancel, { passive: true });\n host.addEventListener(\"scroll\", onScroll, { passive: true, capture: true });\n }\n if (wheelOn) attachWheel(true);\n\n let disposed = false;\n return {\n swipe,\n dispose: (): void => {\n if (disposed) return;\n disposed = true;\n if (lift !== null) options.clock.clearTimer(lift.timer);\n lift = null;\n unsubscribe();\n if (touchOn) {\n element.removeEventListener(\"touchstart\", onTouchStart);\n element.removeEventListener(\"touchmove\", onTouchMove);\n element.removeEventListener(\"touchend\", onTouchEnd);\n element.removeEventListener(\"touchcancel\", onTouchCancel);\n host.removeEventListener(\"scroll\", onScroll, { capture: true });\n }\n if (wheelOn) element.removeEventListener(\"wheel\", onWheel);\n element.removeAttribute(SWIPE_PAGES_ATTRIBUTE);\n swipe.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;AA8BO,SAAS,mBAAmB,UAA+B,CAAC,GAAc;AAE/E,QAAM,OAAO,QAAQ,QAAS;AAC9B,QAAM,wBAAwB,QAAQ,yBAAyB,MAAO;AACtE,QAAM,cAAc,KAAK;AACzB,QAAM,MAAM,gBAAgB,SAAY,MAAM,YAAY,IAAI,IAAI,MAAM,KAAK,IAAI;AAIjF,MAAI,YAAY;AAChB,QAAM,SAAS,oBAAI,IAAqB;AAExC,QAAM,WAAW,CAAC,UAAsB,OAAuB;AAC7D,UAAM,KAAK;AACX,WAAO;AAAA,MACL;AAAA,MACA,KAAK,WAAW,MAAM;AACpB,eAAO,OAAO,EAAE;AAChB,iBAAS;AAAA,MACX,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,CAAC,OAAqB;AACvC,UAAM,SAAS,OAAO,IAAI,EAAE;AAC5B,QAAI,WAAW,OAAW;AAC1B,WAAO,OAAO,EAAE;AAChB,SAAK,aAAa,MAAM;AAAA,EAC1B;AAGA,QAAM,MAAM,KAAK;AAEjB,QAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,UAAa,QAAQ,QAAW;AAC1C,WAAO;AAAA,MACL;AAAA,MACA,cAAc,CAAC,aAAa,IAAI,KAAK,MAAM,MAAM,SAAS,CAAC;AAAA,MAC3D,aAAa,CAAC,WAAW,IAAI,KAAK,MAAM,MAAM;AAAA,MAC9C;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,cAAc,CAAC,aAAa,SAAS,UAAU,qBAAqB;AAAA,IACpE,aAAa;AAAA,IACb;AAAA,IACA;AAAA,EACF;AACF;AASO,SAAS,qBAAqB,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;AACZ,UAAI,SAAS;AACX,gBAAQ,oBAAoB,cAAc,YAAY;AACtD,gBAAQ,oBAAoB,aAAa,WAAW;AACpD,gBAAQ,oBAAoB,YAAY,UAAU;AAClD,gBAAQ,oBAAoB,eAAe,aAAa;AACxD,aAAK,oBAAoB,UAAU,UAAU,EAAE,SAAS,KAAK,CAAC;AAAA,MAChE;AACA,UAAI,QAAS,SAAQ,oBAAoB,SAAS,OAAO;AACzD,cAAQ,gBAAgB,qBAAqB;AAC7C,YAAM,QAAQ;AAAA,IAChB;AAAA,EACF;AACF;","names":["max"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
effect,
|
|
4
4
|
signal,
|
|
5
5
|
untracked
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LSIMILAL.js";
|
|
7
7
|
import {
|
|
8
8
|
ComponentAnimator,
|
|
9
9
|
createSettle,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
sameLayout,
|
|
14
14
|
shapeEquals,
|
|
15
15
|
writeComponents
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GLPO4HGL.js";
|
|
17
17
|
|
|
18
18
|
// src/values/easing.ts
|
|
19
19
|
var linear = (t) => t;
|
|
@@ -469,4 +469,4 @@ export {
|
|
|
469
469
|
settleValue,
|
|
470
470
|
tweenValue
|
|
471
471
|
};
|
|
472
|
-
//# sourceMappingURL=chunk-
|
|
472
|
+
//# sourceMappingURL=chunk-ELRGR2MI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/values/easing.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","import type { Animatable, Widen } from \"../shapes\";\nimport { writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { ComponentAnimator, criticalStep } from \"./step\";\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 criticalStep(solver.omega, Math.exp(-solver.omega * t), d0, v0, t, out);\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 `dt` ms heading for\n * `target`. Doesn't settle or snap; {@link createSpring} does that.\n */\nexport function springStep(state: SpringState, target: number, params: SpringParams, dt: number): SpringState {\n const out = new Float64Array(2);\n advance(solverFor(params), state.value - target, state.velocity, dt / 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 extends ComponentAnimator implements Spring<Animatable> {\n config: SpringConfig;\n params: SpringParams;\n solver: Solver;\n\n constructor(initial: Animatable, config: SpringConfig) {\n super(initial, \"spring\");\n this.config = config;\n this.params = resolveSpring(config);\n this.solver = solverFor(this.params);\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 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 protected begin(): void {}\n\n protected advance(d0: number, v0: number, t: number, out: Float64Array): void {\n advance(this.solver, d0, v0, t, out);\n }\n\n protected rests(_i: number, d: number, v: number): boolean {\n return !(Math.abs(d) > this.params.restDelta || Math.abs(v) > this.params.restSpeed);\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 /** A tween's run is its duration and easing: a velocity set by hand changes nothing. */\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\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(dt: number): boolean {\n if (this.settled) return false;\n this.elapsed += Math.max(0, dt);\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 { createSettle, type Settle, type SettleConfig } from \"./settle\";\nimport { createSpring, type Spring, type SpringConfig } from \"./spring\";\nimport { createTween, type Tween, type TweenConfig } from \"./tween\";\n\n/** Options of {@link motionValue}. */\nexport interface MotionOptions {\n /**\n * The frame phase that steps the value. Default `\"layout\"`: it steps after\n * that phase's one-shot tasks, so a target set in input, update or layout\n * moves the value in the same frame, and `write` sees the new value.\n */\n readonly phase?: Phase;\n /**\n * The reduced-motion switch: while it is (or returns) `true`, every new\n * target is reached at once, and a value in flight snaps on its next frame.\n * A function is read on each `set` and each frame, so it can read a signal\n * or a media query.\n */\n readonly reducedMotion?: boolean | (() => boolean);\n}\n\n/** Options of {@link MotionValue.set}. */\nexport interface SetOptions<T> {\n /**\n * Start with this velocity, in units per second, e.g. a gesture's release velocity (px per ms: `* 1000`). Springs and\n * settles (a settle caps it toward the target, and within its range lowers it away from the target); tweens ignore it.\n */\n readonly velocity?: T;\n}\n\n/**\n * An animated value on a frame loop. Reading `value` inside a computed or an\n * effect tracks it; it changes once per frame while moving and the loop goes\n * idle when it settles.\n */\nexport interface MotionValue<T, A extends Animator<unknown> = Animator<T>> extends ReadonlySignal<T> {\n /** Where the value is heading. */\n readonly target: T;\n /** The current velocity, units per second. */\n readonly velocity: T;\n /** Whether it is moving (reactive). */\n readonly moving: boolean;\n /** The spring, settle or tween underneath. Change it through this value (`jump`, not the animator's `jumpTo`), so the signal and the loop follow. */\n readonly animator: A;\n /** Head for `target`; a spring keeps its velocity, a settle launches from where it is drawn, a tween restarts. */\n set(target: T, options?: SetOptions<T>): void;\n /** Put the value at `value` at once, at rest. */\n jump(value: T): void;\n /** Finish now: put the value on its target, at rest. */\n snap(): void;\n /**\n * Keep heading for whatever `source` returns. `source` is tracked like an\n * effect, and re-read in this value's phase at most once per frame. Returns\n * a stop function.\n */\n follow(source: () => T): () => void;\n /**\n * Call `listener` each time the value comes to rest: on the frame it\n * settles, or at once when `set` (under reduced motion), `snap` or `jump`\n * leaves it at rest. Returns an unsubscribe function.\n */\n onSettle(listener: (value: T) => void): () => void;\n /**\n * Call `listener` after each change of the value (once per frame while it moves, and when `set`, `snap` or `jump`\n * moves it), with the new value; not at once, and not for a write that leaves it the same. The plain way to follow a\n * value: no signals needed. Returns an unsubscribe function.\n */\n subscribe(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 changes = 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 /** Tell the change listeners when the value is no longer `before`. */\n changed(before: T): void {\n const now = this.current.peek();\n if (now !== before) for (const listener of Array.from(this.changes)) listener(now);\n }\n\n /** Publish the animator's value, and tell the change listeners. */\n publish(): void {\n const before = this.current.peek();\n this.current.value = this.animator.value;\n this.changed(before);\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.publish();\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 const before = this.current.peek();\n batch(() => {\n this.current.value = this.animator.value;\n this.movingSignal.value = false;\n });\n this.changed(before);\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 subscribe(listener: (value: T) => void): () => void {\n if (this.disposed) return () => {};\n this.changes.add(listener);\n return () => {\n this.changes.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.changes.clear();\n this.movingSignal.value = false;\n }\n}\n\n/** The value type an animator moves. */\nexport type AnimatorValue<A> = A extends Animator<infer T> ? T : never;\n\n/** Step `animator` on `loop` while it moves, and expose it as a signal. */\nexport function motionValue<A extends Animator<unknown>>(\n loop: FrameLoop,\n animator: A,\n options: MotionOptions = {},\n): MotionValue<AnimatorValue<A>, A> {\n return new Motion(loop, animator, options) as unknown as MotionValue<AnimatorValue<A>, A>;\n}\n\n/** A spring-driven {@link MotionValue}: `createSpring` plus `motionValue`. */\nexport function springValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SpringConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Spring<Widen<T>>> {\n return motionValue(loop, createSpring(initial, options), options) as MotionValue<Widen<T>, Spring<Widen<T>>>;\n}\n\n/**\n * A settle-driven {@link MotionValue}: `createSettle` plus `motionValue`. The\n * one curve for things moving to a new place (see {@link Settle}). To hold it\n * to a pointer, `jump` it on each move; the next `set` launches from there.\n * A range (`within`) keeps a velocity given to `set` from carrying it out.\n */\nexport function settleValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SettleConfig<Widen<T>> & MotionOptions = {},\n): MotionValue<Widen<T>, Settle<Widen<T>>> {\n return motionValue(loop, createSettle(initial, options), options) as MotionValue<Widen<T>, Settle<Widen<T>>>;\n}\n\n/** A tween-driven {@link MotionValue}: `createTween` plus `motionValue`. */\nexport function tweenValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: TweenConfig & MotionOptions = {},\n): MotionValue<Widen<T>, Tween<Widen<T>>> {\n return motionValue(loop, createTween(initial, options), options) as MotionValue<Widen<T>, Tween<Widen<T>>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIO,IAAM,SAAiB,CAAC,MAAM;AAErC,IAAM,UAAU;AAMT,SAAS,YAAY,IAAY,IAAY,IAAY,IAAoB;AAClF,MAAI,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,IAAI;AAC/C,UAAM,IAAI,WAAW,iDAAiD,EAAE,QAAQ,EAAE,EAAE;AAAA,EACtF;AACA,MAAI,OAAO,MAAM,OAAO,GAAI,QAAO;AACnC,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,KAAK,KAAK,MAAM;AAC3B,QAAM,KAAK,IAAI,KAAK;AACpB,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,KAAK,KAAK,MAAM;AAC3B,QAAM,KAAK,IAAI,KAAK;AACpB,QAAM,UAAU,CAAC,QAAwB,KAAK,IAAI,MAAM,IAAI,MAAM;AAClE,QAAM,UAAU,CAAC,QAAwB,KAAK,IAAI,MAAM,IAAI,MAAM;AAClE,QAAM,SAAS,CAAC,OAAuB,IAAI,KAAK,IAAI,IAAI,MAAM,IAAI;AAClE,QAAM,SAAS,CAAC,MAAsB;AACpC,QAAI,IAAI;AACR,aAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,YAAM,QAAQ,QAAQ,CAAC,IAAI;AAC3B,UAAI,KAAK,IAAI,KAAK,IAAI,QAAS,QAAO;AACtC,YAAM,QAAQ,OAAO,CAAC;AACtB,UAAI,KAAK,IAAI,KAAK,IAAI,KAAM;AAC5B,WAAK,QAAQ;AAAA,IACf;AACA,QAAI,MAAM;AACV,QAAI,OAAO;AACX,QAAI;AACJ,aAAS,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,YAAM,QAAQ,QAAQ,CAAC;AAC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3C;AAGO,SAAS,YACd,MACA,SACA,UAAwC,CAAC,GACA;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAQO,SAAS,YACd,MACA,SACA,UAAkD,CAAC,GACV;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAGO,SAAS,WACd,MACA,SACA,UAAuC,CAAC,GACA;AACxC,SAAO,YAAY,MAAM,YAAY,SAAS,OAAO,GAAG,OAAO;AACjE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/values/easing.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","import type { Animatable, Widen } from \"../shapes\";\nimport { writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { ComponentAnimator, criticalStep } from \"./step\";\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 criticalStep(solver.omega, Math.exp(-solver.omega * t), d0, v0, t, out);\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 `dt` ms heading for\n * `target`. Doesn't settle or snap; {@link createSpring} does that.\n */\nexport function springStep(state: SpringState, target: number, params: SpringParams, dt: number): SpringState {\n const out = new Float64Array(2);\n advance(solverFor(params), state.value - target, state.velocity, dt / 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 extends ComponentAnimator implements Spring<Animatable> {\n config: SpringConfig;\n params: SpringParams;\n solver: Solver;\n\n constructor(initial: Animatable, config: SpringConfig) {\n super(initial, \"spring\");\n this.config = config;\n this.params = resolveSpring(config);\n this.solver = solverFor(this.params);\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 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 protected begin(): void {}\n\n protected advance(d0: number, v0: number, t: number, out: Float64Array): void {\n advance(this.solver, d0, v0, t, out);\n }\n\n protected rests(_i: number, d: number, v: number): boolean {\n return !(Math.abs(d) > this.params.restDelta || Math.abs(v) > this.params.restSpeed);\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 /** A tween's run is its duration and easing: a velocity set by hand changes nothing. */\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\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(dt: number): boolean {\n if (this.settled) return false;\n this.elapsed += Math.max(0, dt);\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 { createSettle, type Settle, type SettleConfig } from \"./settle\";\nimport { createSpring, type Spring, type SpringConfig } from \"./spring\";\nimport { createTween, type Tween, type TweenConfig } from \"./tween\";\n\n/** Options of {@link motionValue}. */\nexport interface MotionOptions {\n /**\n * The frame phase that steps the value. Default `\"layout\"`: it steps after\n * that phase's one-shot tasks, so a target set in input, update or layout\n * moves the value in the same frame, and `write` sees the new value.\n */\n readonly phase?: Phase;\n /**\n * The reduced-motion switch: while it is (or returns) `true`, every new\n * target is reached at once, and a value in flight snaps on its next frame.\n * A function is read on each `set` and each frame, so it can read a signal\n * or a media query.\n */\n readonly reducedMotion?: boolean | (() => boolean);\n}\n\n/** Options of {@link MotionValue.set}. */\nexport interface SetOptions<T> {\n /**\n * Start with this velocity, in units per second, e.g. a gesture's release velocity (px per ms: `* 1000`). Springs and\n * settles (a settle caps it toward the target, and within its range lowers it away from the target); tweens ignore it.\n */\n readonly velocity?: T;\n}\n\n/**\n * An animated value on a frame loop. Reading `value` inside a computed or an\n * effect tracks it; it changes once per frame while moving and the loop goes\n * idle when it settles.\n */\nexport interface MotionValue<T, A extends Animator<unknown> = Animator<T>> extends ReadonlySignal<T> {\n /** Where the value is heading. */\n readonly target: T;\n /** The current velocity, units per second. */\n readonly velocity: T;\n /** Whether it is moving (reactive). */\n readonly moving: boolean;\n /** The spring, settle or tween underneath. Change it through this value (`jump`, not the animator's `jumpTo`), so the signal and the loop follow. */\n readonly animator: A;\n /** Head for `target`; a spring keeps its velocity, a settle launches from where it is drawn, a tween restarts. */\n set(target: T, options?: SetOptions<T>): void;\n /** Put the value at `value` at once, at rest. */\n jump(value: T): void;\n /** Finish now: put the value on its target, at rest. */\n snap(): void;\n /**\n * Keep heading for whatever `source` returns. `source` is tracked like an\n * effect, and re-read in this value's phase at most once per frame. Returns\n * a stop function.\n */\n follow(source: () => T): () => void;\n /**\n * Call `listener` each time the value comes to rest: on the frame it\n * settles, or at once when `set` (under reduced motion), `snap` or `jump`\n * leaves it at rest. Returns an unsubscribe function.\n */\n onSettle(listener: (value: T) => void): () => void;\n /**\n * Call `listener` after each change of the value (once per frame while it moves, and when `set`, `snap` or `jump`\n * moves it), with the new value; not at once, and not for a write that leaves it the same. The plain way to follow a\n * value: no signals needed. Returns an unsubscribe function.\n */\n subscribe(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 changes = 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 /** Tell the change listeners when the value is no longer `before`. */\n changed(before: T): void {\n const now = this.current.peek();\n if (now !== before) for (const listener of Array.from(this.changes)) listener(now);\n }\n\n /** Publish the animator's value, and tell the change listeners. */\n publish(): void {\n const before = this.current.peek();\n this.current.value = this.animator.value;\n this.changed(before);\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.publish();\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 const before = this.current.peek();\n batch(() => {\n this.current.value = this.animator.value;\n this.movingSignal.value = false;\n });\n this.changed(before);\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 subscribe(listener: (value: T) => void): () => void {\n if (this.disposed) return () => {};\n this.changes.add(listener);\n return () => {\n this.changes.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.changes.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);\n}\n\n/**\n * A settle-driven {@link MotionValue}: `createSettle` plus `motionValue`. The\n * one curve for things moving to a new place (see {@link Settle}). To hold it\n * to a pointer, `jump` it on each move; the next `set` launches from there.\n * A range (`within`) keeps a velocity given to `set` from carrying it out.\n */\nexport function settleValue<T extends Animatable>(\n loop: FrameLoop,\n initial: T,\n options: SettleConfig<Widen<T>> & MotionOptions = {},\n): MotionValue<Widen<T>, Settle<Widen<T>>> {\n return motionValue(loop, createSettle(initial, options), options);\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);\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,QA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C;AAAA,EACF;AAAA,EAEA,UAAU,UAA0C;AAClD,QAAI,KAAK,SAAU,QAAO,MAAM;AAAA,IAAC;AACjC,SAAK,QAAQ,IAAI,QAAQ;AACzB,WAAO,MAAM;AACX,WAAK,QAAQ,OAAO,QAAQ;AAAA,IAC9B;AAAA,EACF;AAAA,EAEA,UAAgB;AACd,QAAI,KAAK,SAAU;AACnB,SAAK,WAAW;AAChB,SAAK,KAAK;AACV,eAAW,QAAQ,MAAM,KAAK,KAAK,OAAO,EAAG,MAAK;AAClD,SAAK,UAAU,MAAM;AACrB,SAAK,QAAQ,MAAM;AACnB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;AAMO,SAAS,YACd,MACA,UACA,UAAyB,CAAC,GACQ;AAClC,SAAO,IAAI,OAAO,MAAM,UAAU,OAAO;AAC3C;AAGO,SAAS,YACd,MACA,SACA,UAAwC,CAAC,GACA;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAQO,SAAS,YACd,MACA,SACA,UAAkD,CAAC,GACV;AACzC,SAAO,YAAY,MAAM,aAAa,SAAS,OAAO,GAAG,OAAO;AAClE;AAGO,SAAS,WACd,MACA,SACA,UAAuC,CAAC,GACA;AACxC,SAAO,YAAY,MAAM,YAAY,SAAS,OAAO,GAAG,OAAO;AACjE;","names":[]}
|
|
@@ -115,6 +115,20 @@ var ComponentAnimator = class {
|
|
|
115
115
|
this.cachedValue = null;
|
|
116
116
|
this.settled = true;
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Move the value and the target together by `by` (the same shape): the same motion written from another origin. The
|
|
120
|
+
* velocity and whether it is at rest are kept.
|
|
121
|
+
*/
|
|
122
|
+
translate(by) {
|
|
123
|
+
this.check(by, "the offset");
|
|
124
|
+
const d = new Float64Array(this.x.length);
|
|
125
|
+
writeComponents(by, d);
|
|
126
|
+
for (let i = 0; i < this.x.length; i++) {
|
|
127
|
+
this.x[i] = this.x[i] + d[i];
|
|
128
|
+
this.goal[i] = this.goal[i] + d[i];
|
|
129
|
+
}
|
|
130
|
+
this.cachedValue = null;
|
|
131
|
+
}
|
|
118
132
|
snap() {
|
|
119
133
|
this.x.set(this.goal);
|
|
120
134
|
this.v.fill(0);
|
|
@@ -254,6 +268,9 @@ var SettleAnimator = class extends ComponentAnimator {
|
|
|
254
268
|
return !(Math.abs(d) > near || Math.abs(v) > Math.max(this.restSpeed, this.omega * near));
|
|
255
269
|
}
|
|
256
270
|
};
|
|
271
|
+
function translateSettle(settle, by) {
|
|
272
|
+
settle.translate(by);
|
|
273
|
+
}
|
|
257
274
|
function createSettle(initial, config = {}) {
|
|
258
275
|
return new SettleAnimator(initial, config);
|
|
259
276
|
}
|
|
@@ -284,8 +301,9 @@ export {
|
|
|
284
301
|
ComponentAnimator,
|
|
285
302
|
SETTLE_TEMPO,
|
|
286
303
|
SETTLE_DEFAULTS,
|
|
304
|
+
translateSettle,
|
|
287
305
|
createSettle,
|
|
288
306
|
reveal,
|
|
289
307
|
popIn
|
|
290
308
|
};
|
|
291
|
-
//# sourceMappingURL=chunk-
|
|
309
|
+
//# sourceMappingURL=chunk-GLPO4HGL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shapes.ts","../src/values/step.ts","../src/values/settle.ts","../src/values/reveal.ts"],"sourcesContent":["/** 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 // (`Array.isArray` narrows a readonly array to `any[]`: each component is read as the vector's)\n for (let i = 0; i < value.length; i++) out[i] = (value as Vector)[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 } from \"../shapes\";\nimport { layoutOf, makeValue, sameLayout, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\n\n/**\n * The exact critically damped step for one component, shared by the spring and the settle: displacement `d0` from the\n * target and velocity `v0` (per second) after `t` seconds, with `e` = e^(−w·t) worked out once per step. Writes into\n * out[0], out[1]: d(t) = e·(d0 + b·t), v(t) = e·(v0 − w·b·t), b = v0 + w·d0.\n */\nexport function criticalStep(w: number, e: number, d0: number, v0: number, t: number, out: Float64Array): void {\n const b = v0 + w * d0;\n out[0] = e * (d0 + b * t);\n out[1] = e * (v0 - w * b * t);\n}\n\n/**\n * What the spring and the settle share: a value of any {@link Animatable} shape kept as components (position, velocity\n * and target), its shape check, the rest test of a step, jump and snap. Each one adds only its own law: `begin` (what a\n * step works out once), `advance` (one component over `t` seconds) and `rests` (when a component counts as arrived).\n */\nexport abstract class ComponentAnimator implements Animator<Animatable> {\n readonly layout: Layout;\n readonly x: Float64Array;\n readonly v: Float64Array;\n readonly goal: Float64Array;\n readonly scratch = new Float64Array(2);\n settled = true;\n cachedValue: Animatable | null = null;\n /** How errors call it (\"spring\", \"settle\"). */\n private readonly name: string;\n\n constructor(initial: Animatable, name: string) {\n this.name = name;\n this.layout = layoutOf(initial);\n this.x = new Float64Array(this.layout.size);\n this.v = new Float64Array(this.layout.size);\n this.goal = new Float64Array(this.layout.size);\n writeComponents(initial, this.x);\n writeComponents(initial, this.goal);\n }\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(`${this.name}: ${what} has a different shape than the ${this.name}'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 abstract setTarget(target: Animatable): void;\n\n abstract setVelocity(velocity: Animatable): void;\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 /**\n * Move the value and the target together by `by` (the same shape): the same motion written from another origin. The\n * velocity and whether it is at rest are kept.\n */\n translate(by: Animatable): void {\n this.check(by, \"the offset\");\n const d = new Float64Array(this.x.length);\n writeComponents(by, d);\n for (let i = 0; i < this.x.length; i++) {\n this.x[i] = this.x[i]! + d[i]!;\n this.goal[i] = this.goal[i]! + d[i]!;\n }\n this.cachedValue = null;\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 /** Work out what every component's step of `t` seconds shares. */\n protected abstract begin(t: number): void;\n /** One component, `d0` from its target at `v0` per second, after `t` seconds: into out[0], out[1]. */\n protected abstract advance(d0: number, v0: number, t: number, out: Float64Array): void;\n /** Whether component `i`, now `d` from its target at `v` per second, counts as arrived. */\n protected abstract rests(i: number, d: number, v: number): boolean;\n\n step(dt: number): boolean {\n if (this.settled) return false;\n if (!(dt > 0)) return true;\n const t = dt / 1000;\n const { x, v, goal, scratch } = this;\n this.begin(t);\n let resting = true;\n for (let i = 0; i < x.length; i++) {\n this.advance(x[i]! - goal[i]!, v[i]!, t, scratch);\n x[i] = goal[i]! + scratch[0]!;\n v[i] = scratch[1]!;\n if (resting && !this.rests(i, scratch[0]!, scratch[1]!)) resting = false;\n }\n this.cachedValue = null;\n if (resting) this.snap();\n return !this.settled;\n }\n}\n","import type { Animatable, Widen } from \"../shapes\";\nimport { makeValue, writeComponents } from \"../shapes\";\nimport type { Animator } from \"./animator\";\nimport { ComponentAnimator, criticalStep } from \"./step\";\n\n/**\n * Tempos for {@link createSettle}, in 1/s: a settle covers 90 % of the way in\n * ln(10)/omega seconds and is within 1 % in twice that.\n *\n * - `calm` 20: 90 % in 115 ms, done in 230 ms.\n * - `default` 25: 90 % in 92 ms, done in 184 ms.\n * - `quick` 37: 90 % in 62 ms, done in 124 ms (a fast Hyprland setup).\n */\nexport const SETTLE_TEMPO = { calm: 20, default: 25, quick: 37 } as const;\n\n/** The values a settle is kept between, per component, in the value's shape (see {@link SettleConfig.within}). */\nexport interface SettleRange<T> {\n readonly min: T;\n readonly max: T;\n}\n\n/**\n * Settings of {@link createSettle}. `T` is the value's shape (`SettleConfig<number>`, `SettleConfig<Rect>`); a plain\n * `SettleConfig` has no range, and passes to a settle of any shape.\n */\nexport interface SettleConfig<T = never> {\n /** The tempo in 1/s (see {@link SETTLE_TEMPO}). Higher is faster. Default 25. */\n readonly omega?: number;\n /** Distance from the target that counts as arrived. Default 0.1 (tuned for pixels). */\n readonly restDelta?: number;\n /**\n * Limits how far a set velocity can carry the value: with the value and the target inside `min`…`max`, the value\n * never leaves. It does not move the value or the target; a target outside is still reached.\n *\n * A velocity set away from the target (`setVelocity`, or a value's `set(target, { velocity })`) makes the value go\n * on, stop and come back; with a range, that speed is lowered just enough for the value to stop before the bound\n * (to 0 when the value already stands at it, or the range has no width). A speed toward the target, a new target and\n * the rest are as without one. Per component; a side may be `-Infinity` or `Infinity` (open). `null` clears it.\n * Under reduced motion a value goes to its target at once, inside or not. Clearing the range later doesn't give back\n * a speed it lowered. A `min` above `max`, a side that is NaN, a `min` of `Infinity` or a `max` of `-Infinity`\n * throw a `RangeError`, and the settle is left as it was.\n */\n readonly within?: SettleRange<T> | null;\n}\n\n/**\n * The one curve for things that move to a new place: a window's rect between\n * layout targets, a drawer, a camera. Fast at the start, gentle at the end,\n * and it never passes its target.\n *\n * It is a critically damped spring (stiffness omega², damping 2·omega) with\n * one rule on its velocity, per component:\n *\n * - **Launch.** On a new target, each component gets the velocity\n * omega · distance toward it, from wherever it is drawn: standing still,\n * moving toward it, or moving away (it turns at once rather than drifting\n * further first). From there the spring follows `distance · e^(−omega·t)`\n * exactly: most of the move happens at once, the rest eases in.\n * - **Clamp.** That speed is also the most it may have toward the target, so a\n * velocity set by hand (`setVelocity`, a fling) toward the target is capped\n * there instead of shooting past.\n * - **Carry.** A velocity set by hand away from the target is kept, and the\n * value turns around; a critically damped spring turning around never\n * crosses the target either. With a range ({@link SettleConfig.within}) it\n * is lowered just enough for the value to stop before the bound on its side.\n * - **A velocity that is not a finite number** (NaN, ±Infinity, either way) is\n * taken as 0.\n *\n * So after a new target every component goes straight from where it is drawn\n * to the target and never past it: no overshoot on position, no wobble on\n * size, whatever the retargets. A new target starts from the drawn value,\n * never from the old start.\n *\n * Holding (a pointer owns the value): call `jumpTo(value)` on each move. The\n * value sits exactly there, at rest; the next `setTarget` launches from it.\n */\nexport interface Settle<T> extends Animator<T> {\n /** The tempo in 1/s. */\n readonly omega: number;\n /** The range in force ({@link SettleConfig.within}), or null. */\n readonly within: SettleRange<T> | null;\n /**\n * Set the velocity, in units per second (a gesture's release velocity in px per ms is `* 1000`); a component moving\n * toward the target is clamped as in the launch rule, one moving away is kept or, with a range, lowered.\n */\n setVelocity(velocity: T): void;\n /** Change the tempo, rest distance or range mid-flight; the value and velocity carry on, re-clamped and re-lowered. */\n configure(config: SettleConfig<T>): void;\n}\n\n/** Defaults of {@link SettleConfig}. */\nexport const SETTLE_DEFAULTS = { omega: SETTLE_TEMPO.default, restDelta: 0.1 } as const;\n\nfunction positive(name: string, value: number): number {\n if (!(value > 0) || !Number.isFinite(value)) throw new RangeError(`settle: ${name} must be a finite number > 0, got ${value}`);\n return value;\n}\n\n/** How far from its target a settle `a` (≥ 0) from it, moving away at `speed` (≥ 0), gets before it turns back. */\nfunction reach(a: number, speed: number, omega: number): number {\n // d(t) = (a + k·t)·e^(−omega·t), k = speed + omega·a, peaks at t* = speed / (omega·k).\n const k = speed + omega * a;\n return k > 0 ? (k / omega) * Math.exp(-speed / k) : a;\n}\n\n/**\n * The speed a settle `a` (≥ 0) from its target keeps when it moves away at `speed` (≥ 0) with `room` (≥ 0, Infinity:\n * none) between the target and the bound on that side: `speed` when its reach fits, 0 when it already stands at the\n * bound or past it, else the largest speed whose reach is at most `room` less a margin (so the sampled values stay\n * inside despite rounding), by bisection (the reach grows steadily with the speed).\n *\n * The margin, a billionth of the room, covers every rounding: the step's own error is a few float steps of the distance,\n * the room (bound − target) is exact when the two lie close and a half float step of the room otherwise, and the drawn\n * value, target + distance, can't pass target + room = the bound while the distance stays under the room, since float\n * addition keeps order.\n */\nfunction rangedSpeed(a: number, speed: number, room: number, omega: number): number {\n if (!(room < Infinity)) return speed;\n const inside = room - 1e-9 * room;\n if (a >= inside) return 0;\n if (reach(a, speed, omega) <= inside) return speed;\n // The reach grows with the distance too, so it is at least the reach from the target, speed / (omega·e): no speed\n // above omega·e·inside fits. Bisecting from there keeps a huge speed's answer as close as a small one's.\n let low = 0;\n let high = Math.min(speed, omega * Math.E * inside);\n for (let k = 0; k < 60; k += 1) {\n const mid = (low + high) / 2;\n if (reach(a, mid, omega) <= inside) low = mid;\n else high = mid;\n }\n return low;\n}\n\n/** A range's sides as components, checked: the error names what is wrong, and nothing is written on a throw. */\nfunction readRange(settle: SettleAnimator, range: SettleRange<Animatable>): { min: Float64Array; max: Float64Array } {\n settle.check(range.min, \"within's min\");\n settle.check(range.max, \"within's max\");\n const min = new Float64Array(settle.x.length);\n const max = new Float64Array(settle.x.length);\n writeComponents(range.min, min);\n writeComponents(range.max, max);\n for (let i = 0; i < min.length; i++) {\n const lo = min[i]!;\n const hi = max[i]!;\n if (Number.isNaN(lo) || Number.isNaN(hi) || lo > hi || lo === Infinity || hi === -Infinity) {\n throw new RangeError(`settle: within needs min <= max, each a number, min below Infinity and max above -Infinity; got ${lo} and ${hi}`);\n }\n }\n return { min, max };\n}\n\nclass SettleAnimator extends ComponentAnimator implements Settle<Animatable> {\n omega: number;\n restDelta: number;\n // One step's shared numbers (`begin`): e^(−omega·t) and the rest speed.\n private e = 1;\n private restSpeed = 0;\n private range: { min: Float64Array; max: Float64Array } | null = null;\n\n constructor(initial: Animatable, config: SettleConfig<Animatable>) {\n super(initial, \"settle\");\n this.omega = positive(\"omega\", config.omega ?? SETTLE_DEFAULTS.omega);\n this.restDelta = positive(\"restDelta\", config.restDelta ?? SETTLE_DEFAULTS.restDelta);\n if (config.within != null) this.range = readRange(this, config.within);\n }\n\n get within(): SettleRange<Animatable> | null {\n const range = this.range;\n return range === null ? null : { min: makeValue(this.layout, range.min), max: makeValue(this.layout, range.max) };\n }\n\n /** The launch/clamp/carry rule on component `i`: `launch` for a new target, else clamp or carry. */\n rule(i: number, launch: boolean): void {\n const d = this.x[i]! - this.goal[i]!;\n const limit = d === 0 ? 0 : -this.omega * d;\n if (launch) {\n this.v[i] = limit;\n return;\n }\n let v = this.v[i]!;\n if (!Number.isFinite(v)) this.v[i] = v = 0;\n if (v === 0) return;\n // Moving away from the target (d and v the same sign), or off it: carry, within the range if there is one.\n if (d === 0 || d * v > 0) {\n const range = this.range;\n if (range === null) return;\n const goal = this.goal[i]!;\n const bound = v > 0 ? range.max[i]! : range.min[i]!;\n const room = Math.max(0, v > 0 ? bound - goal : goal - bound);\n const kept = rangedSpeed(Math.abs(d), Math.abs(v), room, this.omega);\n // A plain 0 when lowered to nothing, never −0.\n this.v[i] = kept === 0 ? 0 : Math.sign(v) * kept;\n return;\n }\n // Moving toward it: no faster than a launch from here.\n if (Math.abs(v) > Math.abs(limit)) this.v[i] = limit;\n }\n\n setTarget(target: Animatable): void {\n this.check(target, \"the target\");\n writeComponents(target, this.goal);\n for (let i = 0; i < this.x.length; i++) this.rule(i, true);\n this.updateSettled();\n }\n\n setVelocity(velocity: Animatable): void {\n this.check(velocity, \"the velocity\");\n writeComponents(velocity, this.v);\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n this.updateSettled();\n }\n\n configure(config: SettleConfig<Animatable>): void {\n // Everything is checked before anything changes.\n const range = config.within === undefined ? this.range : config.within === null ? null : readRange(this, config.within);\n const omega = config.omega === undefined ? this.omega : positive(\"omega\", config.omega);\n const restDelta = config.restDelta === undefined ? this.restDelta : positive(\"restDelta\", config.restDelta);\n this.omega = omega;\n this.restDelta = restDelta;\n this.range = range;\n for (let i = 0; i < this.x.length; i++) this.rule(i, false);\n }\n\n protected begin(t: number): void {\n this.e = Math.exp(-this.omega * t);\n // At rest when every component is within restDelta and no faster than a launch from there would be.\n this.restSpeed = this.omega * this.restDelta * 1.000001;\n }\n\n protected advance(d0: number, v0: number, t: number, out: Float64Array): void {\n criticalStep(this.omega, this.e, d0, v0, t, out);\n }\n\n protected rests(i: number, d: number, v: number): boolean {\n // Within a few float steps of the goal counts as arrived too: a restDelta finer than that would never be met.\n const near = Math.max(this.restDelta, 4 * Number.EPSILON * Math.abs(this.goal[i]!));\n return !(Math.abs(d) > near || Math.abs(v) > Math.max(this.restSpeed, this.omega * near));\n }\n}\n\n/**\n * Move a settle's value and target together by `by` (the same shape), keeping its velocity and whether it is at rest:\n * the same motion, written from another origin. Internal to the library (not in `values/`'s index): the layout\n * motion's `rebase` uses it. A range ({@link SettleConfig.within}) is not moved: a caller with one moves it itself\n * (the layout motion's settles have none).\n */\nexport function translateSettle<T extends Animatable>(settle: Settle<T>, by: T): void {\n (settle as unknown as SettleAnimator).translate(by);\n}\n\n/**\n * A settle starting at rest on `initial` (a number, a vector, a point or a\n * rect; targets, velocities and a range must have the same shape). See\n * {@link Settle}.\n */\nexport function createSettle<T extends Animatable>(initial: T, config: SettleConfig<Widen<T>> = {}): Settle<Widen<T>> {\n return new SettleAnimator(initial, config) as unknown as Settle<Widen<T>>;\n}\n","import type { Rect } from \"../shapes\";\n\n/**\n * How to draw a window whose rect is gliding without stretching its content.\n *\n * The content is laid out once at the target size and never scaled. The\n * window's element sits at its target in the layout; to draw it at the\n * gliding rect:\n *\n * - move the element by (`dx`, `dy`), so its top-left corner is the drawn rect's;\n * - draw the frame (background, border, shadow) at `width` × `height`: the drawn size;\n * - clip the content by `clipRight` and `clipBottom` so it fits a frame\n * smaller than the target (CSS: `clip-path: inset(0 clipRight clipBottom 0)`).\n *\n * A window that shrinks shows a band of its own background closing in at the\n * right and bottom; one that grows reveals content already laid out at its\n * new size. Text is never stretched. One transform and one clip per frame, no\n * layout per frame.\n */\nexport interface RevealFrame {\n /** Move the element (laid out at the target) right by this much. */\n readonly dx: number;\n /** Move the element (laid out at the target) down by this much. */\n readonly dy: number;\n /** The frame's width: the drawn rect's. */\n readonly width: number;\n /** The frame's height: the drawn rect's. */\n readonly height: number;\n /** Clip this much off the content's right edge (0 when the frame is at least as wide as the target). */\n readonly clipRight: number;\n /** Clip this much off the content's bottom edge (0 when the frame is at least as tall as the target). */\n readonly clipBottom: number;\n}\n\n/** The {@link RevealFrame} for content laid out at `target` and drawn at `drawn`. */\nexport function reveal(drawn: Rect, target: Rect): RevealFrame {\n return {\n dx: drawn.x - target.x,\n dy: drawn.y - target.y,\n width: Math.max(0, drawn.width),\n height: Math.max(0, drawn.height),\n clipRight: Math.max(0, target.width - drawn.width),\n clipBottom: Math.max(0, target.height - drawn.height),\n };\n}\n\n/** A uniform pop-in (or pop-out, run backwards): scale about the center and opacity. */\nexport interface PopIn {\n /** Scale about the window's center: the same on both axes, so nothing is stretched. */\n readonly scale: number;\n readonly opacity: number;\n}\n\n/**\n * Opening and closing: the window grows from `from` of its size to full, about\n * its center, while fading in. `progress` runs 0 to 1 (take it from a settle\n * on a number with `{ restDelta: 0.001 }`, since the default 0.1 is tuned for\n * pixels and would snap the last 10 %; or from a tween); closing runs it from\n * 1 to 0. Hyprland's default is `popin 87%`.\n */\nexport function popIn(progress: number, from = 0.87): PopIn {\n const p = Math.min(1, Math.max(0, progress));\n return { scale: from + (1 - from) * p, opacity: p };\n}\n"],"mappings":";AA+BA,IAAM,SAAS;AACf,IAAM,SAAS;AACf,IAAM,QAAQ;AACd,IAAM,OAAO;AA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AAI,OAAO,UAAU,KAAK,IAAI,KAAK,KAAK,CAAC,CAAE,CAAC;AAClF,WAAO,EAAE,KAAK,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,KAAK,WAAW,KAAK,QAAQ,IAAI;AAAA,EACzF;AACF;AAQO,SAAS,gBAAsC,QAAmB,IAAa;AACpF,EAAC,OAAqC,UAAU,EAAE;AACpD;AAOO,SAAS,aAAmC,SAAY,SAAiC,CAAC,GAAqB;AACpH,SAAO,IAAI,eAAe,SAAS,MAAM;AAC3C;;;AC9NO,SAAS,OAAO,OAAa,QAA2B;AAC7D,SAAO;AAAA,IACL,IAAI,MAAM,IAAI,OAAO;AAAA,IACrB,IAAI,MAAM,IAAI,OAAO;AAAA,IACrB,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK;AAAA,IAC9B,QAAQ,KAAK,IAAI,GAAG,MAAM,MAAM;AAAA,IAChC,WAAW,KAAK,IAAI,GAAG,OAAO,QAAQ,MAAM,KAAK;AAAA,IACjD,YAAY,KAAK,IAAI,GAAG,OAAO,SAAS,MAAM,MAAM;AAAA,EACtD;AACF;AAgBO,SAAS,MAAM,UAAkB,OAAO,MAAa;AAC1D,QAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,CAAC;AAC3C,SAAO,EAAE,OAAO,QAAQ,IAAI,QAAQ,GAAG,SAAS,EAAE;AACpD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/signals/signals.ts"],"sourcesContent":["/**\n * Signals: reactive values, computed values and effects.\n *\n * The graph algorithm is alien-signals' (`alien-signals/system`, the core it\n * publishes for building your own API on, also used by Vue 3.6). A write marks\n * only what depends on it (push); a computed recomputes only when it is read\n * and one of its sources really changed (pull). Both walks are iterative, so\n * depth doesn't eat the stack. bench/RESULTS.md has the comparison that\n * chose it over a hand-written graph and over @preact/signals-core.\n *\n * What this surface adds on top of that core:\n * - `.value` reads and writes, `peek()`, an `equals` option;\n * - a computed that throws keeps the error and rethrows it until a source changes;\n * - effects take a `schedule`: their runs go wherever the scheduler puts them,\n * so a frame loop phase runs each one at most once per frame, however many\n * writes land before it;\n * - an effect loop (effects that keep re-triggering each other) throws\n * instead of hanging.\n *\n * Semantics worth knowing:\n * - an effect's own writes don't re-run it (no self-loops), as in alien-signals and Vue;\n * - writes inside an effect are batched until it returns;\n * - this module's state (the tracking context, the batch depth, the effect\n * queue) is the graph's; there is no clock and no timer here.\n */\nimport { createReactiveSystem, type Link, type ReactiveNode } from \"alien-signals/system\";\n\n/** A value that can be read reactively. */\nexport interface ReadonlySignal<T> {\n /** The current value. Read inside a computed or an effect, it becomes a dependency. */\n readonly value: T;\n /** The current value, without becoming a dependency. */\n peek(): T;\n}\n\n/** A value that can be read reactively and written. */\nexport interface Signal<T> extends ReadonlySignal<T> {\n /** The current value. Writing a different value (by `equals`) notifies dependants. */\n value: T;\n}\n\n/** Decides whether a new value is the same as the old one (then nothing is notified). */\nexport type Equals<T> = (previous: T, next: T) => boolean;\n\n/** Options of {@link signal} and {@link computed}. */\nexport interface SignalOptions<T> {\n /** Equality used to skip notifications. Default `Object.is`; `false` notifies on every write. */\n readonly equals?: Equals<T> | false;\n}\n\n/** What an effect function may return: a cleanup, run before the next run and on dispose. */\nexport type EffectCleanup = () => void;\n\n/** Options of {@link effect}. */\nexport interface EffectOptions {\n /**\n * Where the effect's runs go. Without it, an effect runs synchronously at the\n * end of the outermost batch. With it, the first run and every re-run are\n * handed to `schedule(run)`; `run` is the same function each time, so a\n * scheduler that dedupes by identity (a frame loop's `scheduler(phase)`)\n * runs the effect once however many changes arrived.\n */\n readonly schedule?: (run: () => void) => void;\n}\n\n// alien-signals' ReactiveFlags (a const enum in its types, so mirrored here).\nconst NONE = 0;\nconst MUTABLE = 1;\nconst WATCHING = 2;\nconst RECURSED_CHECK = 4;\nconst RECURSED = 8;\nconst DIRTY = 16;\nconst PENDING = 32;\n\nconst SIGNAL = 0;\nconst COMPUTED = 1;\nconst EFFECT = 2;\n\n/** Runs of one effect within one flush before the graph is declared to be looping. */\nconst MAX_RUNS_PER_FLUSH = 100;\n\ninterface Node extends ReactiveNode {\n readonly kind: typeof SIGNAL | typeof COMPUTED | typeof EFFECT;\n}\n\nlet cycle = 0;\nlet runDepth = 0;\nlet batchDepth = 0;\nlet flushing = false;\nlet flushId = 0;\nlet activeSub: Node | undefined;\nconst queue: (EffectNode | undefined)[] = [];\nlet queueHead = 0;\n\nconst { link, unlink, propagate, checkDirty, shallowPropagate } = createReactiveSystem({\n update(node) {\n return (node as Node).kind === COMPUTED\n ? updateComputed(node as ComputedNode<unknown>)\n : updateSignal(node as SignalNode<unknown>);\n },\n notify(node) {\n // Not watching until it has run: further writes mark it but don't queue it again.\n node.flags &= ~WATCHING;\n queue.push(node as EffectNode);\n },\n unwatched(node) {\n const n = node as Node;\n if (n.kind === COMPUTED) {\n // Nobody observes it any more: let go of its sources; the next read recomputes.\n if (n.depsTail !== undefined) {\n n.flags = MUTABLE | DIRTY;\n disposeDeps(n);\n }\n } else if (n.kind === EFFECT) {\n (n as EffectNode).dispose();\n }\n },\n});\n\nclass SignalNode<T> implements Signal<T>, Node {\n readonly kind = SIGNAL;\n deps: Link | undefined = undefined;\n depsTail: Link | undefined = undefined;\n subs: Link | undefined = undefined;\n subsTail: Link | undefined = undefined;\n flags = MUTABLE;\n current: T;\n pending: T;\n readonly equals: Equals<T> | false;\n\n constructor(value: T, equals: Equals<T> | false) {\n this.current = value;\n this.pending = value;\n this.equals = equals;\n }\n\n get value(): T {\n const value = this.peek();\n if (activeSub !== undefined) link(this, activeSub, cycle);\n return value;\n }\n\n set value(next: T) {\n if (activeSub !== undefined && activeSub.kind === COMPUTED) {\n throw new Error(\"motion: a computed value can't write a signal\");\n }\n if (this.equals !== false && this.equals(this.pending, next)) return;\n this.pending = next;\n this.flags = MUTABLE | DIRTY;\n const subs = this.subs;\n if (subs === undefined) return;\n propagate(subs, runDepth > 0);\n if (batchDepth === 0) flush();\n }\n\n peek(): T {\n if (this.flags & DIRTY && updateSignal(this)) {\n const subs = this.subs;\n if (subs !== undefined) shallowPropagate(subs);\n }\n return this.current;\n }\n}\n\nfunction updateSignal<T>(node: SignalNode<T>): boolean {\n node.flags = MUTABLE;\n const previous = node.current;\n node.current = node.pending;\n return node.equals === false || !node.equals(previous, node.current);\n}\n\nclass ComputedNode<T> implements ReadonlySignal<T>, Node {\n readonly kind = COMPUTED;\n deps: Link | undefined = undefined;\n depsTail: Link | undefined = undefined;\n subs: Link | undefined = undefined;\n subsTail: Link | undefined = undefined;\n flags = NONE;\n current: T | undefined = undefined;\n failed = false;\n error: unknown = undefined;\n readonly getter: (previous: T | undefined) => T;\n readonly equals: Equals<T> | false;\n\n constructor(getter: (previous: T | undefined) => T, equals: Equals<T> | false) {\n this.getter = getter;\n this.equals = equals;\n }\n\n get value(): T {\n refreshComputed(this);\n if (activeSub !== undefined) link(this, activeSub, cycle);\n if (this.failed) throw this.error;\n return this.current as T;\n }\n\n peek(): T {\n refreshComputed(this);\n if (this.failed) throw this.error;\n return this.current as T;\n }\n}\n\nfunction refreshComputed<T>(node: ComputedNode<T>): void {\n const flags = node.flags;\n if (flags & RECURSED_CHECK) throw new Error(\"motion: a computed value depends on itself\");\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- the comma expression clears PENDING and is false on purpose\n if (flags & DIRTY || (flags & PENDING && (checkDirty(node.deps!, node) || ((node.flags = flags & ~PENDING), false)))) {\n if (updateComputed(node)) {\n const subs = node.subs;\n if (subs !== undefined) shallowPropagate(subs);\n }\n } else if (flags === NONE) {\n // First read.\n node.flags = MUTABLE | RECURSED_CHECK;\n const previous = activeSub;\n activeSub = node;\n try {\n ++cycle;\n node.current = node.getter(undefined);\n } catch (error) {\n node.failed = true;\n node.error = error;\n } finally {\n activeSub = previous;\n node.flags &= ~RECURSED_CHECK;\n }\n }\n}\n\n/** Recompute; returns whether the value (or the error state) changed. */\nfunction updateComputed<T>(node: ComputedNode<T>): boolean {\n node.depsTail = undefined;\n node.flags = MUTABLE | RECURSED_CHECK;\n const previousSub = activeSub;\n activeSub = node;\n try {\n ++cycle;\n const previous = node.current;\n let next: T;\n try {\n next = node.getter(previous);\n } catch (error) {\n node.failed = true;\n node.error = error;\n return true;\n }\n if (node.failed) {\n node.failed = false;\n node.error = undefined;\n node.current = next;\n return true;\n }\n if (node.equals !== false && node.equals(previous as T, next)) return false;\n node.current = next;\n return true;\n } finally {\n activeSub = previousSub;\n node.flags &= ~RECURSED_CHECK;\n purgeDeps(node);\n }\n}\n\nclass EffectNode implements Node {\n readonly kind = EFFECT;\n deps: Link | undefined = undefined;\n depsTail: Link | undefined = undefined;\n subs: Link | undefined = undefined;\n subsTail: Link | undefined = undefined;\n flags = DIRTY;\n cleanup: EffectCleanup | undefined = undefined;\n disposed = false;\n lastFlush = 0;\n runsInFlush = 0;\n readonly fn: () => void | EffectCleanup;\n readonly schedule: ((run: () => void) => void) | undefined;\n /** A scheduled run: the effect, then whatever its writes triggered. */\n readonly run: () => void;\n\n constructor(fn: () => void | EffectCleanup, schedule: ((run: () => void) => void) | undefined) {\n this.fn = fn;\n this.schedule = schedule;\n this.run = () => {\n if (this.disposed) return;\n batchDepth++;\n try {\n runEffect(this);\n } finally {\n endBatch();\n }\n };\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.flags = NONE;\n disposeDeps(this);\n if (this.cleanup !== undefined) runCleanup(this);\n }\n}\n\nfunction runEffect(node: EffectNode): void {\n const flags = node.flags;\n if (flags & DIRTY || (flags & PENDING && checkDirty(node.deps!, node))) {\n if (node.cleanup !== undefined) {\n runCleanup(node);\n if (node.disposed) return;\n }\n node.depsTail = undefined;\n node.flags = WATCHING | RECURSED_CHECK;\n const previous = activeSub;\n activeSub = node;\n try {\n ++cycle;\n ++runDepth;\n const cleanup = node.fn();\n node.cleanup = typeof cleanup === \"function\" ? cleanup : undefined;\n } finally {\n --runDepth;\n activeSub = previous;\n node.flags &= ~RECURSED_CHECK;\n purgeDeps(node);\n // It disposed itself during the run: drop whatever it read after that.\n if (node.disposed) disposeDeps(node);\n }\n } else if (!node.disposed) {\n node.flags = WATCHING;\n }\n}\n\nfunction runCleanup(node: EffectNode): void {\n const cleanup = node.cleanup!;\n node.cleanup = undefined;\n const previous = activeSub;\n activeSub = undefined;\n try {\n cleanup();\n } finally {\n activeSub = previous;\n }\n}\n\nfunction disposeDeps(node: ReactiveNode): void {\n let dep = node.depsTail;\n while (dep !== undefined) {\n const previous = dep.prevDep;\n unlink(dep, node);\n dep = previous;\n }\n}\n\nfunction purgeDeps(node: ReactiveNode): void {\n const tail = node.depsTail;\n let dep = tail !== undefined ? tail.nextDep : node.deps;\n while (dep !== undefined) dep = unlink(dep, node);\n}\n\nfunction endBatch(): void {\n if (--batchDepth === 0) flush();\n}\n\nfunction flush(): void {\n if (flushing) return;\n flushing = true;\n batchDepth++;\n const id = ++flushId;\n let failed = false;\n let error: unknown;\n try {\n while (queueHead < queue.length) {\n const node = queue[queueHead]!;\n queue[queueHead++] = undefined;\n if (node.disposed) continue;\n try {\n if (node.schedule !== undefined) {\n node.schedule(node.run);\n continue;\n }\n if (node.lastFlush !== id) {\n node.lastFlush = id;\n node.runsInFlush = 0;\n }\n if (++node.runsInFlush > MAX_RUNS_PER_FLUSH) {\n // Leave it watching so a later change still reaches it.\n node.flags |= WATCHING | RECURSED;\n throw new Error(`motion: effects kept re-triggering each other (one ran more than ${MAX_RUNS_PER_FLUSH} times)`);\n }\n runEffect(node);\n } catch (caught) {\n if (!failed) {\n failed = true;\n error = caught;\n }\n }\n }\n } finally {\n queue.length = 0;\n queueHead = 0;\n batchDepth--;\n flushing = false;\n }\n if (failed) throw error;\n}\n\n/** A writable reactive value. */\nexport function signal<T>(initial: T, options?: SignalOptions<T>): Signal<T> {\n return new SignalNode(initial, options?.equals ?? Object.is);\n}\n\n/**\n * A value derived from other signals. It recomputes lazily, on read, and only\n * when a source changed; `fn` gets the previous value. If `fn` throws, reading\n * the computed throws the same error until a source changes.\n */\nexport function computed<T>(fn: (previous: T | undefined) => T, options?: SignalOptions<T>): ReadonlySignal<T> {\n return new ComputedNode(fn, options?.equals ?? Object.is);\n}\n\n/**\n * Run `fn` now (or through `options.schedule`) and again whenever a signal it\n * read changes. Returns `dispose`. If the first synchronous run throws, the\n * effect is disposed and the error rethrown.\n */\nexport function effect(fn: () => void | EffectCleanup, options?: EffectOptions): () => void {\n const node = new EffectNode(fn, options?.schedule);\n const dispose = (): void => node.dispose();\n if (node.schedule !== undefined) {\n node.schedule(node.run);\n return dispose;\n }\n try {\n node.run();\n } catch (error) {\n node.dispose();\n throw error;\n }\n return dispose;\n}\n\n/** Run `fn` with effects held until it returns; nested batches flush at the outermost end. */\nexport function batch<T>(fn: () => T): T {\n batchDepth++;\n try {\n return fn();\n } finally {\n endBatch();\n }\n}\n\n/** Run `fn` without tracking what it reads. */\nexport function untracked<T>(fn: () => T): T {\n const previous = activeSub;\n activeSub = undefined;\n try {\n return fn();\n } finally {\n activeSub = previous;\n }\n}\n\n/** Whether `value` is a signal or a computed value made by this module. */\nexport function isSignal(value: unknown): value is ReadonlySignal<unknown> {\n return value instanceof SignalNode || value instanceof ComputedNode;\n}\n"],"mappings":";AAyBA,SAAS,4BAA0D;AAyCnE,IAAM,OAAO;AACb,IAAM,UAAU;AAChB,IAAM,WAAW;AACjB,IAAM,iBAAiB;AACvB,IAAM,WAAW;AACjB,IAAM,QAAQ;AACd,IAAM,UAAU;AAEhB,IAAM,SAAS;AACf,IAAM,WAAW;AACjB,IAAM,SAAS;AAGf,IAAM,qBAAqB;AAM3B,IAAI,QAAQ;AACZ,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,WAAW;AACf,IAAI,UAAU;AACd,IAAI;AACJ,IAAM,QAAoC,CAAC;AAC3C,IAAI,YAAY;AAEhB,IAAM,EAAE,MAAM,QAAQ,WAAW,YAAY,iBAAiB,IAAI,qBAAqB;AAAA,EACrF,OAAO,MAAM;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